Changeset 182247 in webkit
- Timestamp:
- Apr 1, 2015 12:02:35 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r182242 r182247 1 2015-04-01 Yoav Weiss <yoav@yoav.ws> 2 3 Async loading of image resources 4 https://bugs.webkit.org/show_bug.cgi?id=134488 5 6 Reviewed by Dean Jackson. 7 8 * fast/dom/HTMLImageElement/image-load-post-onload-expected.txt: Added. 9 * fast/dom/HTMLImageElement/image-load-post-onload.html: Added. 10 * fast/dom/HTMLImageElement/image-loading-gc.html: Cosmetic changes. 11 * fast/dom/HTMLImageElement/sizes/image-sizes-js-change-reverse-expected.txt: Added. 12 * fast/dom/HTMLImageElement/sizes/image-sizes-js-change-reverse.html: Added. 13 * fast/dom/image-object.html: Cosmetic changes. 14 * http/tests/misc/image-blocked-src-change-expected.txt: Removed line numbers from console. 15 * http/tests/misc/image-blocked-src-no-change-expected.txt: Removed line numbers from console. 16 * http/tests/security/contentSecurityPolicy/report-blocked-file-uri-expected.txt: Removed line numbers from console. 17 * http/tests/security/frame-loading-via-document-write-expected.txt: Removed line numbers from console. 18 * http/tests/security/local-image-from-remote-expected.txt: Removed line numbers from console. 19 1 20 2015-03-31 Simon Fraser <simon.fraser@apple.com> 2 21 -
trunk/LayoutTests/fast/dom/HTMLImageElement/image-loading-gc.html
r120792 r182247 33 33 </script> 34 34 <body onload="runTest()"> 35 <div>This tests that an image element won't be garbage collected when it's loading, even if it doesn't have any references. 35 <div>This tests that an image element won't be garbage collected when it's loading, even if it doesn't have any references.</div> 36 36 <div id="result">FAILURE</div> 37 37 </body> -
trunk/LayoutTests/fast/dom/image-object.html
r120792 r182247 47 47 numErrs++; 48 48 } 49 50 i2 = new Image() 49 i2 = new Image(); 51 50 i2.onload = imageLoaded; 52 51 i2.src = 'resources/apple.gif'; -
trunk/LayoutTests/http/tests/misc/image-blocked-src-change-expected.txt
r136657 r182247 1 CONSOLE MESSAGE: line 44:Not allowed to load local resource: compass.jpg1 CONSOLE MESSAGE: Not allowed to load local resource: compass.jpg 2 2 Test case for bug 17897 : Not Rendering Images Imported from XHTML Document 3 3 -
trunk/LayoutTests/http/tests/misc/image-blocked-src-no-change-expected.txt
r178527 r182247 1 CONSOLE MESSAGE: line 27:Not allowed to load local resource: compass.jpg2 CONSOLE MESSAGE: line 21:Not allowed to load local resource: compass.jpg1 CONSOLE MESSAGE: Not allowed to load local resource: compass.jpg 2 CONSOLE MESSAGE: Not allowed to load local resource: compass.jpg 3 3 Test case for bug 17897 : Not Rendering Images Imported from XHTML Document 4 4 -
trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-blocked-file-uri-expected.txt
r146758 r182247 6 6 REQUEST_METHOD: POST 7 7 === POST DATA === 8 {"csp-report":{"document-uri":"http://127.0.0.1:8000/security/contentSecurityPolicy/report-blocked-file-uri.html","referrer":"","violated-directive":"img-src 'none'","original-policy":"img-src 'none'; report-uri resources/save-report.php","blocked-uri":"file" ,"source-file":"http://127.0.0.1:8000/security/contentSecurityPolicy/report-blocked-file-uri.html","line-number":12}}8 {"csp-report":{"document-uri":"http://127.0.0.1:8000/security/contentSecurityPolicy/report-blocked-file-uri.html","referrer":"","violated-directive":"img-src 'none'","original-policy":"img-src 'none'; report-uri resources/save-report.php","blocked-uri":"file"}} -
trunk/LayoutTests/http/tests/security/frame-loading-via-document-write-expected.txt
r136657 r182247 1 CONSOLE MESSAGE: line 1:Not allowed to load local resource: abe.png1 CONSOLE MESSAGE: Not allowed to load local resource: abe.png 2 2 3 3 -
trunk/LayoutTests/http/tests/security/local-image-from-remote-expected.txt
r178527 r182247 1 CONSOLE MESSAGE: line 14:Not allowed to load local resource: compass.jpg1 CONSOLE MESSAGE: Not allowed to load local resource: compass.jpg 2 2 This test is to see if a remote file can include a local image. 3 3 Currently this test cannot be run manually on Windows because we do not have a function like pathToLocalResource() outside of DRT. -
trunk/Source/WebCore/ChangeLog
r182244 r182247 1 2015-04-01 Yoav Weiss <yoav@yoav.ws> 2 3 Async loading of image resources 4 https://bugs.webkit.org/show_bug.cgi?id=134488 5 6 Reviewed by Dean Jackson. 7 8 This patch changes image loading to be asynchronous (per spec), in order 9 for it to be agnostic to property setting order when it comes to src, srcset and crossorigin, 10 as well as to enable future hooking of the <picture>-based selection logic on top of it. 11 12 Tests: fast/dom/HTMLImageElement/image-load-post-onload.html 13 fast/dom/HTMLImageElement/sizes/image-sizes-js-change-reverse.html 14 15 * WebCore.xcodeproj/project.pbxproj: Change MicroTask.h to be private. 16 * bindings/js/JSEventListener.cpp: 17 (WebCore::JSEventListener::handleEvent): Add a microtask checkpoint after event handling. 18 * bindings/js/ScheduledAction.cpp: 19 (WebCore::ScheduledAction::execute): Add a microtask checkpoint after running of a scheduled action. 20 * html/HTMLImageElement.cpp: 21 (WebCore::HTMLImageElement::didMoveToNewDocument): Add the old document to call of elementDidMoveToNewDocument. 22 * html/HTMLImageLoader.cpp: 23 (WebCore::HTMLImageLoader::notifyFinished): Avoid a crash when notifyFinished is called and there's no CachedImage. 24 * html/HTMLInputElement.cpp: 25 (WebCore::HTMLInputElement::didMoveToNewDocument): Add the old document to call of elementDidMoveToNewDocument. 26 * html/HTMLPlugInImageElement.cpp: 27 (WebCore::HTMLPlugInImageElement::didMoveToNewDocument): Add the old document to call of elementDidMoveToNewDocument. 28 * html/HTMLVideoElement.cpp: 29 (WebCore::HTMLVideoElement::didMoveToNewDocument): Add the old document to call of elementDidMoveToNewDocument. 30 * html/parser/HTMLDocumentParser.cpp: 31 (WebCore::HTMLDocumentParser::attemptToRunDeferredScriptsAndEnd): Add a microtask checkpoint. 32 * loader/ImageLoader.cpp: Move image resource loading to be asynchronous. 33 (WebCore::ImageLoader::ImageLoaderTask::create): 34 (WebCore::ImageLoader::ImageLoaderTask::run): Run the image loading microtask and called doUpdateFromElement. 35 (WebCore::ImageLoader::ImageLoaderTask::ImageLoaderTask): 36 (WebCore::ImageLoader::ImageLoader): 37 (WebCore::ImageLoader::doUpdateFromElement): This is split from the previous updateFromElement, and performs the actual resource loading. 38 (WebCore::ImageLoader::updateFromElement): Now only prepares the stage for the actual image resource loading. 39 (WebCore::ImageLoader::shouldLoadImmediately): If this returns true, the image resource is loaded immediately, without queueing a microtask. 40 (WebCore::ImageLoader::notifyFinished): Add asserts. 41 (WebCore::ImageLoader::elementDidMoveToNewDocument): Handle document load event counters decrementing and incrementing. 42 * loader/ImageLoader.h: 43 (WebCore::ImageLoader::imageComplete): Make sure that the image is complete only if there aren't any pending tasks. 44 (WebCore::ImageLoader::hasPendingActivity): Make sure that pending activity takes pending tasks into account. 45 (WebCore::ImageLoader::hasPendingTask): Getter to know if an ImageLoader has a pending task. (Used by the image loading microtask) 46 (WebCore::ImageLoader::createWeakPtr): Create a weakPtr to be used by the microtask, so it can called back the loader if it's still alive. 47 * loader/cache/CachedResourceLoader.cpp: 48 (WebCore::CachedResourceLoader::canRequest): Add a 'shouldBypassMainWorldContentSecurityPolicy' flag and act upon it. 49 (WebCore::CachedResourceLoader::requestImage): Add a 'shouldBypassMainWorldContentSecurityPolicy' flag. 50 (WebCore::CachedResourceLoader::requestResource): Add a 'shouldBypassMainWorldContentSecurityPolicy' flag. 51 * loader/cache/CachedResourceLoader.h: 52 (WebCore::CachedResourceLoader::canRequest): Add a 'shouldBypassMainWorldContentSecurityPolicy' flag and act upon it. 53 (WebCore::CachedResourceLoader::requestImage): Add a 'shouldBypassMainWorldContentSecurityPolicy' flag. 54 (WebCore::CachedResourceLoader::requestResource): Add a 'shouldBypassMainWorldContentSecurityPolicy' flag. 55 * svg/SVGImageElement.cpp: 56 (WebCore::SVGImageElement::didMoveToNewDocument): Add the old document to call of elementDidMoveToNewDocument. 57 * xml/parser/XMLDocumentParser.cpp: 58 (WebCore::XMLDocumentParser::end): Add a microtask checkpoint after XML finishes parsing. 59 1 60 2015-04-01 Alex Christensen <achristensen@webkit.org> 2 61 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r182211 r182247 2102 2102 536D5A25193F40FC00CE4CAB /* SourceSizeList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 536D5A24193F40FC00CE4CAB /* SourceSizeList.cpp */; }; 2103 2103 536D5A27193F410B00CE4CAB /* SourceSizeList.h in Headers */ = {isa = PBXBuildFile; fileRef = 536D5A26193F410B00CE4CAB /* SourceSizeList.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2104 53B895AF19DC7ED9009CAA93 /* MicroTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 53B895AD19DC7C37009CAA93 /* MicroTask.h */; settings = {ATTRIBUTES = (P ublic, ); }; };2104 53B895AF19DC7ED9009CAA93 /* MicroTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 53B895AD19DC7C37009CAA93 /* MicroTask.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2105 2105 53C8298D13D8D92700DE2DEB /* RenderFlexibleBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53C8298B13D8D92700DE2DEB /* RenderFlexibleBox.cpp */; }; 2106 2106 53C8298E13D8D92700DE2DEB /* RenderFlexibleBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 53C8298C13D8D92700DE2DEB /* RenderFlexibleBox.h */; settings = {ATTRIBUTES = (Private, ); }; }; -
trunk/Source/WebCore/bindings/js/JSEventListener.cpp
r182205 r182247 30 30 #include "JSMainThreadExecState.h" 31 31 #include "JSMainThreadExecStateInstrumentation.h" 32 #include "MicroTask.h" 32 33 #include "ScriptController.h" 33 34 #include "WorkerGlobalScope.h" … … 152 153 } 153 154 } 155 if (scriptExecutionContext->isDocument()) 156 MicroTaskQueue::singleton().runMicroTasks(); 154 157 } 155 158 -
trunk/Source/WebCore/bindings/js/ScheduledAction.cpp
r176065 r182247 35 35 #include "JSMainThreadExecStateInstrumentation.h" 36 36 #include "JSWorkerGlobalScope.h" 37 #include "MicroTask.h" 37 38 #include "ScriptController.h" 38 39 #include "ScriptExecutionContext.h" … … 126 127 else 127 128 frame->script().executeScriptInWorld(*m_isolatedWorld, m_code); 129 130 MicroTaskQueue::singleton().runMicroTasks(); 128 131 } 129 132 -
trunk/Source/WebCore/html/HTMLImageElement.cpp
r182120 r182247 453 453 void HTMLImageElement::didMoveToNewDocument(Document* oldDocument) 454 454 { 455 m_imageLoader.elementDidMoveToNewDocument( );455 m_imageLoader.elementDidMoveToNewDocument(oldDocument); 456 456 HTMLElement::didMoveToNewDocument(oldDocument); 457 457 } -
trunk/Source/WebCore/html/HTMLImageLoader.cpp
r181412 r182247 77 77 { 78 78 CachedImage* cachedImage = image(); 79 if (!cachedImage) 80 return; 79 81 80 82 Ref<Element> protect(element()); -
trunk/Source/WebCore/html/HTMLInputElement.cpp
r181615 r182247 1496 1496 { 1497 1497 if (imageLoader()) 1498 imageLoader()->elementDidMoveToNewDocument( );1498 imageLoader()->elementDidMoveToNewDocument(oldDocument); 1499 1499 1500 1500 bool needsSuspensionCallback = this->needsSuspensionCallback(); -
trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp
r182205 r182247 307 307 308 308 if (m_imageLoader) 309 m_imageLoader->elementDidMoveToNewDocument( );309 m_imageLoader->elementDidMoveToNewDocument(oldDocument); 310 310 311 311 HTMLPlugInElement::didMoveToNewDocument(oldDocument); -
trunk/Source/WebCore/html/HTMLVideoElement.cpp
r182120 r182247 310 310 { 311 311 if (m_imageLoader) 312 m_imageLoader->elementDidMoveToNewDocument( );312 m_imageLoader->elementDidMoveToNewDocument(oldDocument); 313 313 HTMLMediaElement::didMoveToNewDocument(oldDocument); 314 314 } -
trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp
r178648 r182247 35 35 #include "HTMLDocument.h" 36 36 #include "InspectorInstrumentation.h" 37 #include "MicroTask.h" 37 38 38 39 namespace WebCore { … … 410 411 return; 411 412 end(); 413 if (!isExecutingScript()) 414 MicroTaskQueue::singleton().runMicroTasks(); 412 415 } 413 416 -
trunk/Source/WebCore/loader/ImageLoader.cpp
r181897 r182247 3 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 4 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 Apple Inc. All rights reserved. 5 * Copyright 2014 The Chromium Authors. All rights reserved. 6 * Copyright (C) 2015 Akamai Technologies Inc. All rights reserved. 5 7 * 6 8 * This library is free software; you can redistribute it and/or … … 35 37 #include "HTMLObjectElement.h" 36 38 #include "HTMLParserIdioms.h" 39 #include "MemoryCache.h" 37 40 #include "Page.h" 38 41 #include "RenderImage.h" 39 42 #include "RenderSVGImage.h" 43 #include "ScriptController.h" 40 44 #include "SecurityOrigin.h" 41 45 #include <wtf/NeverDestroyed.h> … … 64 68 namespace WebCore { 65 69 70 class ImageLoader::ImageLoaderTask : public MicroTask { 71 public: 72 ImageLoaderTask(WeakPtr<ImageLoader> loader, CachedResourceLoader::ShouldBypassMainWorldContentSecurityPolicy shouldBypassMainWorldContentSecurityPolicy) 73 : m_loader(loader) 74 , m_shouldBypassMainWorldContentSecurityPolicy(shouldBypassMainWorldContentSecurityPolicy) 75 { 76 } 77 78 private: 79 virtual void run() override 80 { 81 if (m_loader && m_loader->hasPendingTask()) 82 m_loader->doUpdateFromElement(m_shouldBypassMainWorldContentSecurityPolicy); 83 } 84 85 WeakPtr<ImageLoader> m_loader; 86 CachedResourceLoader::ShouldBypassMainWorldContentSecurityPolicy m_shouldBypassMainWorldContentSecurityPolicy; 87 }; 88 66 89 static ImageEventSender& beforeLoadEventSender() 67 90 { … … 92 115 , m_image(0) 93 116 , m_derefElementTimer(*this, &ImageLoader::timerFired) 117 , m_weakFactory(this) 94 118 , m_hasPendingBeforeLoadEvent(false) 95 119 , m_hasPendingLoadEvent(false) … … 98 122 , m_loadManually(false) 99 123 , m_elementIsProtected(false) 124 , m_hasPendingTask(false) 100 125 { 101 126 } … … 160 185 } 161 186 162 void ImageLoader::updateFromElement() 163 { 164 // If we're not making renderers for the page, then don't load images. We don't want to slow 165 // down the raw HTML parsing case by loading images we don't intend to display. 166 Document& document = element().document(); 167 if (!document.hasLivingRenderTree()) 168 return; 169 170 AtomicString attr = element().imageSourceURL(); 171 172 // Avoid loading a URL we already failed to load. 173 if (!m_failedLoadURL.isEmpty() && attr == m_failedLoadURL) 174 return; 175 187 void ImageLoader::doUpdateFromElement(CachedResourceLoader::ShouldBypassMainWorldContentSecurityPolicy shouldBypassMainWorldContentSecurityPolicy) 188 { 189 m_hasPendingTask = false; 190 Document& document = m_element.document(); 191 AtomicString attr = m_element.imageSourceURL(); 192 193 String srcURI = sourceURI(attr); 194 URL url; 195 // Set url value only if srcURI is not empty. Otherwise, url will be the URL for the document itself. 196 if (!srcURI.isEmpty()) 197 url = document.completeURL(srcURI); 176 198 // Do not load any image if the 'src' attribute is missing or if it is 177 199 // an empty string. 178 200 CachedResourceHandle<CachedImage> newImage = 0; 179 if (!attr.isNull() && !stripLeadingAndTrailingHTMLSpaces(attr).isEmpty()) { 180 CachedResourceRequest request(ResourceRequest(document.completeURL(sourceURI(attr)))); 201 if (!url.isNull()) { 202 ResourceRequest resourceRequest(url); 203 CachedResourceRequest request(resourceRequest); 181 204 request.setInitiator(&element()); 182 205 183 String crossOriginMode = element().fastGetAttribute(HTMLNames::crossoriginAttr);206 AtomicString crossOriginMode = m_element.fastGetAttribute(HTMLNames::crossoriginAttr); 184 207 if (!crossOriginMode.isNull()) { 185 208 StoredCredentials allowCredentials = equalIgnoringCase(crossOriginMode, "use-credentials") ? AllowStoredCredentials : DoNotAllowStoredCredentials; … … 196 219 document.cachedResourceLoader().setAutoLoadImages(autoLoadOtherImages); 197 220 } else 198 newImage = document.cachedResourceLoader().requestImage(request );221 newImage = document.cachedResourceLoader().requestImage(request, shouldBypassMainWorldContentSecurityPolicy); 199 222 200 223 // If we do not have an image here, it means that a cross-site … … 214 237 errorEventSender().dispatchEventSoon(*this); 215 238 } 216 239 217 240 CachedImage* oldImage = m_image.get(); 218 241 if (newImage != oldImage) { … … 266 289 // from this function as doing so might result in the destruction of this ImageLoader. 267 290 updatedHasPendingEvent(); 291 document.decrementLoadEventDelayCount(); 292 } 293 294 void ImageLoader::updateFromElement() 295 { 296 AtomicString attribute = m_element.imageSourceURL(); 297 298 // Avoid loading a URL we already failed to load. 299 if (!m_failedLoadURL.isEmpty() && attribute == m_failedLoadURL) 300 return; 301 302 // If we're not making renderers for the page, then don't load images. We don't want to slow 303 // down the raw HTML parsing case by loading images we don't intend to display. 304 Document& document = element().document(); 305 if (!document.hasLivingRenderTree()) 306 return; 307 308 CachedResourceLoader::ShouldBypassMainWorldContentSecurityPolicy shouldBypassMainWorldContentSecurityPolicy = CachedResourceLoader::ShouldBypassMainWorldContentSecurityPolicy::No; 309 if (document.frame() && document.frame()->script().shouldBypassMainWorldContentSecurityPolicy()) 310 shouldBypassMainWorldContentSecurityPolicy = CachedResourceLoader::ShouldBypassMainWorldContentSecurityPolicy::Yes; 311 312 if (!m_hasPendingTask) { 313 m_hasPendingTask = true; 314 document.incrementLoadEventDelayCount(); 315 if (shouldLoadImmediately(attribute)) 316 doUpdateFromElement(CachedResourceLoader::ShouldBypassMainWorldContentSecurityPolicy::No); 317 else 318 MicroTaskQueue::singleton().queueMicroTask(std::make_unique<ImageLoaderTask>(createWeakPtr(), shouldBypassMainWorldContentSecurityPolicy)); 319 } 320 } 321 322 bool ImageLoader::shouldLoadImmediately(const AtomicString& attribute) const 323 { 324 String srcURI = sourceURI(attribute); 325 URL url = element().document().completeURL(srcURI); 326 return (srcURI.isEmpty() 327 || url.isEmpty() 328 || m_loadManually 329 || !is<HTMLImageElement>(m_element) 330 || url.protocolIsData() 331 || MemoryCache::singleton().resourceForURL(url)); 268 332 } 269 333 … … 277 341 { 278 342 ASSERT(m_failedLoadURL.isEmpty()); 343 ASSERT(resource); 279 344 ASSERT(resource == m_image.get()); 280 345 … … 285 350 if (!m_hasPendingLoadEvent) 286 351 return; 352 353 ASSERT(image()); 354 ASSERT(element().document().securityOrigin()); 287 355 288 356 if (element().fastHasAttribute(HTMLNames::crossoriginAttr) … … 465 533 } 466 534 467 void ImageLoader::elementDidMoveToNewDocument() 468 { 535 void ImageLoader::elementDidMoveToNewDocument(Document* oldDocument) 536 { 537 if (m_hasPendingTask) { 538 if (oldDocument) 539 oldDocument->decrementLoadEventDelayCount(); 540 m_element.document().incrementLoadEventDelayCount(); 541 } 469 542 clearFailedLoadURL(); 470 543 clearImage(); -
trunk/Source/WebCore/loader/ImageLoader.h
r181849 r182247 26 26 #include "CachedImageClient.h" 27 27 #include "CachedResourceHandle.h" 28 #include "CachedResourceLoader.h" 29 #include "MicroTask.h" 28 30 #include "Timer.h" 31 #include <wtf/RefCounted.h> 32 #include <wtf/WeakPtr.h> 29 33 #include <wtf/text/AtomicString.h> 30 34 31 35 namespace WebCore { 32 36 37 class Document; 33 38 class Element; 34 39 class ImageLoader; 35 40 class RenderImageResource; 41 class URL; 42 class Task; 36 43 37 44 template<typename T> class EventSender; … … 51 58 void updateFromElementIgnoringPreviousError(); 52 59 53 void elementDidMoveToNewDocument( );60 void elementDidMoveToNewDocument(Document* oldDocument); 54 61 55 62 Element& element() { return m_element; } 56 63 const Element& element() const { return m_element; } 57 64 58 bool imageComplete() const { return m_imageComplete ; }65 bool imageComplete() const { return m_imageComplete && !m_hasPendingTask; } 59 66 60 67 CachedImage* image() const { return m_image.get(); } … … 64 71 65 72 bool hasPendingBeforeLoadEvent() const { return m_hasPendingBeforeLoadEvent; } 66 bool hasPendingActivity() const { return m_hasPendingLoadEvent || m_hasPendingErrorEvent ; }73 bool hasPendingActivity() const { return m_hasPendingLoadEvent || m_hasPendingErrorEvent || m_hasPendingTask; } 67 74 68 75 void dispatchPendingEvent(ImageEventSender*); … … 72 79 static void dispatchPendingErrorEvents(); 73 80 81 bool hasPendingTask() const { return m_hasPendingTask; } 82 74 83 protected: 75 84 explicit ImageLoader(Element&); … … 77 86 78 87 private: 88 class ImageLoaderTask; 89 90 // Called from the task or from updateFromElement to initiate the load. 91 void doUpdateFromElement(CachedResourceLoader::ShouldBypassMainWorldContentSecurityPolicy); 79 92 virtual void dispatchLoadEvent() = 0; 80 93 virtual String sourceURI(const AtomicString&) const = 0; … … 94 107 void timerFired(); 95 108 109 // Determine whether to initiate a synchronous load or to schedule a microtask. 110 bool shouldLoadImmediately(const AtomicString& attribtue) const; 111 WeakPtr<ImageLoader> createWeakPtr() { return m_weakFactory.createWeakPtr(); } 112 96 113 Element& m_element; 97 114 CachedResourceHandle<CachedImage> m_image; 98 115 Timer m_derefElementTimer; 116 WeakPtrFactory<ImageLoader> m_weakFactory; 99 117 AtomicString m_failedLoadURL; 100 118 bool m_hasPendingBeforeLoadEvent : 1; … … 104 122 bool m_loadManually : 1; 105 123 bool m_elementIsProtected : 1; 124 bool m_hasPendingTask : 1; 106 125 }; 107 126 -
trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp
r182016 r182247 174 174 } 175 175 176 CachedResourceHandle<CachedImage> CachedResourceLoader::requestImage(CachedResourceRequest& request )176 CachedResourceHandle<CachedImage> CachedResourceLoader::requestImage(CachedResourceRequest& request, ShouldBypassMainWorldContentSecurityPolicy shouldBypassMainWorldContentSecurityPolicy) 177 177 { 178 178 if (Frame* frame = this->frame()) { … … 186 186 187 187 request.setDefer(clientDefersImage(request.resourceRequest().url()) ? CachedResourceRequest::DeferredByClient : CachedResourceRequest::NoDefer); 188 return downcast<CachedImage>(requestResource(CachedResource::ImageResource, request ).get());188 return downcast<CachedImage>(requestResource(CachedResource::ImageResource, request, shouldBypassMainWorldContentSecurityPolicy).get()); 189 189 } 190 190 … … 358 358 } 359 359 360 bool CachedResourceLoader::canRequest(CachedResource::Type type, const URL& url, const ResourceLoaderOptions& options, bool forPreload )360 bool CachedResourceLoader::canRequest(CachedResource::Type type, const URL& url, const ResourceLoaderOptions& options, bool forPreload, ShouldBypassMainWorldContentSecurityPolicy bypassMainWorldContentSecurityPolicy) 361 361 { 362 362 if (document() && !document()->securityOrigin()->canDisplay(url)) { … … 367 367 } 368 368 369 369 370 // FIXME: Convert this to check the isolated world's Content Security Policy once webkit.org/b/104520 is solved. 370 bool shouldBypassMainWorldContentSecurityPolicy = (frame() && frame()->script().shouldBypassMainWorldContentSecurityPolicy()); 371 bool shouldBypassMainWorldContentSecurityPolicy = (bypassMainWorldContentSecurityPolicy == ShouldBypassMainWorldContentSecurityPolicy::Yes) 372 || (frame() && frame()->script().shouldBypassMainWorldContentSecurityPolicy()); 371 373 372 374 // Some types of resources can be loaded only from the same origin. Other … … 493 495 } 494 496 495 CachedResourceHandle<CachedResource> CachedResourceLoader::requestResource(CachedResource::Type type, CachedResourceRequest& request )497 CachedResourceHandle<CachedResource> CachedResourceLoader::requestResource(CachedResource::Type type, CachedResourceRequest& request, ShouldBypassMainWorldContentSecurityPolicy shouldBypassMainWorldContentSecurityPolicy) 496 498 { 497 499 URL url = request.resourceRequest().url(); … … 505 507 return nullptr; 506 508 507 if (!canRequest(type, url, request.options(), request.forPreload() ))509 if (!canRequest(type, url, request.options(), request.forPreload(), shouldBypassMainWorldContentSecurityPolicy)) 508 510 return nullptr; 509 511 -
trunk/Source/WebCore/loader/cache/CachedResourceLoader.h
r179626 r182247 72 72 ~CachedResourceLoader(); 73 73 74 CachedResourceHandle<CachedImage> requestImage(CachedResourceRequest&); 74 enum class ShouldBypassMainWorldContentSecurityPolicy { No, Yes }; 75 76 CachedResourceHandle<CachedImage> requestImage(CachedResourceRequest&, ShouldBypassMainWorldContentSecurityPolicy = ShouldBypassMainWorldContentSecurityPolicy::No); 75 77 CachedResourceHandle<CachedCSSStyleSheet> requestCSSStyleSheet(CachedResourceRequest&); 76 78 CachedResourceHandle<CachedCSSStyleSheet> requestUserCSSStyleSheet(CachedResourceRequest&); … … 132 134 void checkForPendingPreloads(); 133 135 void printPreloadStats(); 134 bool canRequest(CachedResource::Type, const URL&, const ResourceLoaderOptions&, bool forPreload = false );136 bool canRequest(CachedResource::Type, const URL&, const ResourceLoaderOptions&, bool forPreload = false, ShouldBypassMainWorldContentSecurityPolicy = ShouldBypassMainWorldContentSecurityPolicy::No); 135 137 136 138 static const ResourceLoaderOptions& defaultCachedResourceOptions(); … … 141 143 explicit CachedResourceLoader(DocumentLoader*); 142 144 143 CachedResourceHandle<CachedResource> requestResource(CachedResource::Type, CachedResourceRequest& );145 CachedResourceHandle<CachedResource> requestResource(CachedResource::Type, CachedResourceRequest&, ShouldBypassMainWorldContentSecurityPolicy = ShouldBypassMainWorldContentSecurityPolicy::No); 144 146 CachedResourceHandle<CachedResource> revalidateResource(const CachedResourceRequest&, CachedResource*); 145 147 CachedResourceHandle<CachedResource> loadResource(CachedResource::Type, CachedResourceRequest&); -
trunk/Source/WebCore/svg/SVGImageElement.cpp
r182121 r182247 206 206 void SVGImageElement::didMoveToNewDocument(Document* oldDocument) 207 207 { 208 m_imageLoader.elementDidMoveToNewDocument( );208 m_imageLoader.elementDidMoveToNewDocument(oldDocument); 209 209 SVGGraphicsElement::didMoveToNewDocument(oldDocument); 210 210 } -
trunk/Source/WebCore/xml/parser/XMLDocumentParser.cpp
r178648 r182247 41 41 #include "HTMLStyleElement.h" 42 42 #include "ImageLoader.h" 43 #include "MicroTask.h" 43 44 #include "ProcessingInstruction.h" 44 45 #include "ResourceError.h" … … 201 202 clearCurrentNodeStack(); 202 203 document()->finishedParsing(); 204 MicroTaskQueue::singleton().runMicroTasks(); 203 205 } 204 206
Note: See TracChangeset
for help on using the changeset viewer.