Unreviewed, rolling out r182247.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Apr 2015 00:22:54 +0000 (00:22 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Apr 2015 00:22:54 +0000 (00:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=143326

unfortunately broke some tests (Requested by dino on #webkit).

Reverted changeset:

"Async loading of image resources"
https://bugs.webkit.org/show_bug.cgi?id=134488
http://trac.webkit.org/changeset/182247

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182266 268f45cc-cd09-0410-ab3c-d52691b4dbfc

28 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/HTMLImageElement/image-load-post-onload-expected.txt [deleted file]
LayoutTests/fast/dom/HTMLImageElement/image-load-post-onload.html [deleted file]
LayoutTests/fast/dom/HTMLImageElement/image-loading-gc.html
LayoutTests/fast/dom/HTMLImageElement/sizes/image-sizes-js-change-reverse-expected.txt [deleted file]
LayoutTests/fast/dom/HTMLImageElement/sizes/image-sizes-js-change-reverse.html [deleted file]
LayoutTests/fast/dom/image-object.html
LayoutTests/http/tests/misc/image-blocked-src-change-expected.txt
LayoutTests/http/tests/misc/image-blocked-src-no-change-expected.txt
LayoutTests/http/tests/security/contentSecurityPolicy/report-blocked-file-uri-expected.txt
LayoutTests/http/tests/security/frame-loading-via-document-write-expected.txt
LayoutTests/http/tests/security/local-image-from-remote-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSEventListener.cpp
Source/WebCore/bindings/js/ScheduledAction.cpp
Source/WebCore/html/HTMLImageElement.cpp
Source/WebCore/html/HTMLImageLoader.cpp
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLPlugInImageElement.cpp
Source/WebCore/html/HTMLVideoElement.cpp
Source/WebCore/html/parser/HTMLDocumentParser.cpp
Source/WebCore/loader/ImageLoader.cpp
Source/WebCore/loader/ImageLoader.h
Source/WebCore/loader/cache/CachedResourceLoader.cpp
Source/WebCore/loader/cache/CachedResourceLoader.h
Source/WebCore/svg/SVGImageElement.cpp
Source/WebCore/xml/parser/XMLDocumentParser.cpp

index 4d2d1c1..478bace 100644 (file)
@@ -1,3 +1,16 @@
+2015-04-01  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r182247.
+        https://bugs.webkit.org/show_bug.cgi?id=143326
+
+        unfortunately broke some tests (Requested by dino on #webkit).
+
+        Reverted changeset:
+
+        "Async loading of image resources"
+        https://bugs.webkit.org/show_bug.cgi?id=134488
+        http://trac.webkit.org/changeset/182247
+
 2015-04-01  Dean Jackson  <dino@apple.com>
 
         fast/events/mouse-cursor-image-set.html is timing out on Apple platforms
diff --git a/LayoutTests/fast/dom/HTMLImageElement/image-load-post-onload-expected.txt b/LayoutTests/fast/dom/HTMLImageElement/image-load-post-onload-expected.txt
deleted file mode 100644 (file)
index 484c1d5..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-This tests that an image element is loading even if its src was changed after the page's onload event.
-SUCCESS
diff --git a/LayoutTests/fast/dom/HTMLImageElement/image-load-post-onload.html b/LayoutTests/fast/dom/HTMLImageElement/image-load-post-onload.html
deleted file mode 100644 (file)
index 95ae520..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<!DOCTYPE html>
-<html>
-<script>
-function runTest() {
-    if (window.testRunner) {
-        testRunner.dumpAsText();
-        testRunner.waitUntilDone();
-    }
-
-    var image = new Image();
-    var first = true;
-    image.onload = function () {
-        if (!first) {
-            document.getElementById('result').innerHTML = 'SUCCESS';
-            if (window.testRunner)
-                testRunner.notifyDone();
-        }
-        image.src = 'resources/image-set-4x.png';
-        first = false;
-    }
-
-    image.src = 'resources/blue_rect.jpg'
-}
-</script>
-<body onload="runTest()">
-    <div>This tests that an image element is loading even if its src was changed after the page's onload event.</div>
-<div id="result">FAILURE</div>
-</body>
-</html>
index 869dad3..7203500 100644 (file)
@@ -32,7 +32,7 @@ function runTest() {
 }
 </script>
 <body onload="runTest()">
-    <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>
+<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 id="result">FAILURE</div>
 </body>
 </html>
diff --git a/LayoutTests/fast/dom/HTMLImageElement/sizes/image-sizes-js-change-reverse-expected.txt b/LayoutTests/fast/dom/HTMLImageElement/sizes/image-sizes-js-change-reverse-expected.txt
deleted file mode 100644 (file)
index 1599929..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-image-set-4x.png has MIME type image/png
-PASS currentSrcFileName("foo") is "image-set-4x.png"
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
diff --git a/LayoutTests/fast/dom/HTMLImageElement/sizes/image-sizes-js-change-reverse.html b/LayoutTests/fast/dom/HTMLImageElement/sizes/image-sizes-js-change-reverse.html
deleted file mode 100644 (file)
index a17e4fe..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE html>
-<script src="../../../../resources/srcset-helper.js"></script>
-<script src="../../../../resources/js-test.js"></script>
-<script src="../resources/currentSrcHelper.js"></script>
-<script>
-    if (window.testRunner)
-        testRunner.dumpAsText();
-
-    function updateSrc() {
-        var img = document.getElementById("foo");
-        // Here we're setting sizes last, and srcset after src to make sure image loading is done is "stable-state"
-        img.src = "../resources/blue-100-px-square.png"
-        img.srcset = "../../../hidpi/resources/image-set-1x.png 200w, ../../../hidpi/resources/image-set-2x.png 400w, ../resources/image-set-4x.png 800w";
-        img.sizes = "400px";
-    }
-
-    addEventListener("DOMContentLoaded", function() {
-        if (sessionStorage.pageReloaded)
-            testRunner.dumpResourceResponseMIMETypes();
-        updateSrc();
-    }, false);
-
-    function runTest()
-    {
-        shouldBe('currentSrcFileName("foo")', '"image-set-4x.png"');
-    }
-</script>
-<img id="foo">
index 0b7512f..9472933 100644 (file)
@@ -46,7 +46,8 @@ function runTests() {
         debug('FAILURE: Empty image should have complete set to true.');
         numErrs++;
     }
-    i2 = new Image();
+    
+    i2 = new Image()
     i2.onload = imageLoaded;
     i2.src = 'resources/apple.gif';
 }
index 6b53db7..65ab53f 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: Not allowed to load local resource: compass.jpg
+CONSOLE MESSAGE: line 44: Not allowed to load local resource: compass.jpg
 Test case for bug 17897 : Not Rendering Images Imported from XHTML Document
 
 You should see PASSED once and 250 x 50 green box. The console should also show a blocked attempt to load a local resource.
index 7ec9097..552f00a 100644 (file)
@@ -1,5 +1,5 @@
-CONSOLE MESSAGE: Not allowed to load local resource: compass.jpg
-CONSOLE MESSAGE: Not allowed to load local resource: compass.jpg
+CONSOLE MESSAGE: line 27: Not allowed to load local resource: compass.jpg
+CONSOLE MESSAGE: line 21: Not allowed to load local resource: compass.jpg
 Test case for bug 17897 : Not Rendering Images Imported from XHTML Document
 
 This test checks that setting an image url should lead to load even if the image was in error and the url is not changed.
index 43b76e4..2ca2b09 100644 (file)
@@ -5,4 +5,4 @@ CONTENT_TYPE: application/json
 HTTP_REFERER: http://127.0.0.1:8000/security/contentSecurityPolicy/report-blocked-file-uri.html
 REQUEST_METHOD: POST
 === POST DATA ===
-{"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"}}
+{"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}}
index 78e8746..d4b9f90 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: Not allowed to load local resource: abe.png
+CONSOLE MESSAGE: line 1: Not allowed to load local resource: abe.png
 
 
 --------
index 3fcc3ec..17ea23b 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: Not allowed to load local resource: compass.jpg
+CONSOLE MESSAGE: line 14: Not allowed to load local resource: compass.jpg
 This test is to see if a remote file can include a local image. 
 Currently this test cannot be run manually on Windows because we do not have a function like pathToLocalResource() outside of DRT. 
 
index dcec65a..ec4697c 100644 (file)
@@ -1,3 +1,16 @@
+2015-04-01  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r182247.
+        https://bugs.webkit.org/show_bug.cgi?id=143326
+
+        unfortunately broke some tests (Requested by dino on #webkit).
+
+        Reverted changeset:
+
+        "Async loading of image resources"
+        https://bugs.webkit.org/show_bug.cgi?id=134488
+        http://trac.webkit.org/changeset/182247
+
 2015-04-01  Alex Christensen  <achristensen@webkit.org>
 
         [Content Extensions] Only add unique universal action locations.
index 168ce51..82a253a 100644 (file)
                536D5A23193E8E0C00CE4CAB /* ParsingUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 536D5A22193E8E0C00CE4CAB /* ParsingUtilities.h */; };
                536D5A25193F40FC00CE4CAB /* SourceSizeList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 536D5A24193F40FC00CE4CAB /* SourceSizeList.cpp */; };
                536D5A27193F410B00CE4CAB /* SourceSizeList.h in Headers */ = {isa = PBXBuildFile; fileRef = 536D5A26193F410B00CE4CAB /* SourceSizeList.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               53B895AF19DC7ED9009CAA93 /* MicroTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 53B895AD19DC7C37009CAA93 /* MicroTask.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               53B895AF19DC7ED9009CAA93 /* MicroTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 53B895AD19DC7C37009CAA93 /* MicroTask.h */; settings = {ATTRIBUTES = (Public, ); }; };
                53C8298D13D8D92700DE2DEB /* RenderFlexibleBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53C8298B13D8D92700DE2DEB /* RenderFlexibleBox.cpp */; };
                53C8298E13D8D92700DE2DEB /* RenderFlexibleBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 53C8298C13D8D92700DE2DEB /* RenderFlexibleBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
                53E29E5E167A8A1900586D3D /* InternalSettingsGenerated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53E29E5C167A8A1900586D3D /* InternalSettingsGenerated.cpp */; };
index 9d2ce6b..ffb0580 100644 (file)
@@ -29,7 +29,6 @@
 #include "JSEventTarget.h"
 #include "JSMainThreadExecState.h"
 #include "JSMainThreadExecStateInstrumentation.h"
-#include "MicroTask.h"
 #include "ScriptController.h"
 #include "WorkerGlobalScope.h"
 #include <runtime/ExceptionHelpers.h>
@@ -152,8 +151,6 @@ void JSEventListener::handleEvent(ScriptExecutionContext* scriptExecutionContext
             }
         }
     }
-    if (scriptExecutionContext->isDocument())
-        MicroTaskQueue::singleton().runMicroTasks();
 }
 
 bool JSEventListener::virtualisAttribute() const
index b42fffb..060e6fa 100644 (file)
@@ -34,7 +34,6 @@
 #include "JSMainThreadExecState.h"
 #include "JSMainThreadExecStateInstrumentation.h"
 #include "JSWorkerGlobalScope.h"
-#include "MicroTask.h"
 #include "ScriptController.h"
 #include "ScriptExecutionContext.h"
 #include "ScriptSourceCode.h"
@@ -126,8 +125,6 @@ void ScheduledAction::execute(Document& document)
         executeFunctionInContext(window, window->shell(), document);
     else
         frame->script().executeScriptInWorld(*m_isolatedWorld, m_code);
-
-    MicroTaskQueue::singleton().runMicroTasks();
 }
 
 void ScheduledAction::execute(WorkerGlobalScope& workerGlobalScope)
index 1b3f783..89954cf 100644 (file)
@@ -452,7 +452,7 @@ void HTMLImageElement::addSubresourceAttributeURLs(ListHashSet<URL>& urls) const
 
 void HTMLImageElement::didMoveToNewDocument(Document* oldDocument)
 {
-    m_imageLoader.elementDidMoveToNewDocument(oldDocument);
+    m_imageLoader.elementDidMoveToNewDocument();
     HTMLElement::didMoveToNewDocument(oldDocument);
 }
 
index b81de31..3e5f81c 100644 (file)
@@ -76,8 +76,6 @@ String HTMLImageLoader::sourceURI(const AtomicString& attr) const
 void HTMLImageLoader::notifyFinished(CachedResource*)
 {
     CachedImage* cachedImage = image();
-    if (!cachedImage)
-        return;
 
     Ref<Element> protect(element());
     ImageLoader::notifyFinished(cachedImage);
index 29fb23e..ec247ce 100644 (file)
@@ -1495,7 +1495,7 @@ void HTMLInputElement::removedFrom(ContainerNode& insertionPoint)
 void HTMLInputElement::didMoveToNewDocument(Document* oldDocument)
 {
     if (imageLoader())
-        imageLoader()->elementDidMoveToNewDocument(oldDocument);
+        imageLoader()->elementDidMoveToNewDocument();
 
     bool needsSuspensionCallback = this->needsSuspensionCallback();
     if (oldDocument) {
index 0cf9d59..83f1b7e 100644 (file)
@@ -306,7 +306,7 @@ void HTMLPlugInImageElement::didMoveToNewDocument(Document* oldDocument)
     }
 
     if (m_imageLoader)
-        m_imageLoader->elementDidMoveToNewDocument(oldDocument);
+        m_imageLoader->elementDidMoveToNewDocument();
 
     HTMLPlugInElement::didMoveToNewDocument(oldDocument);
 }
index 8d434f9..a94b1d9 100644 (file)
@@ -309,7 +309,7 @@ void HTMLVideoElement::setWebkitWirelessVideoPlaybackDisabled(bool disabled)
 void HTMLVideoElement::didMoveToNewDocument(Document* oldDocument)
 {
     if (m_imageLoader)
-        m_imageLoader->elementDidMoveToNewDocument(oldDocument);
+        m_imageLoader->elementDidMoveToNewDocument();
     HTMLMediaElement::didMoveToNewDocument(oldDocument);
 }
 
index a5dddf8..93c5f93 100644 (file)
@@ -34,7 +34,6 @@
 #include "HTMLTreeBuilder.h"
 #include "HTMLDocument.h"
 #include "InspectorInstrumentation.h"
-#include "MicroTask.h"
 
 namespace WebCore {
 
@@ -410,8 +409,6 @@ void HTMLDocumentParser::attemptToRunDeferredScriptsAndEnd()
     if (m_scriptRunner && !m_scriptRunner->executeScriptsWaitingForParsing())
         return;
     end();
-    if (!isExecutingScript())
-        MicroTaskQueue::singleton().runMicroTasks();
 }
 
 void HTMLDocumentParser::attemptToEnd()
index 627b7b6..0919212 100644 (file)
@@ -2,8 +2,6 @@
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 Apple Inc. All rights reserved.
- * Copyright 2014 The Chromium Authors. All rights reserved.
- * Copyright (C) 2015 Akamai Technologies Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 #include "HTMLNames.h"
 #include "HTMLObjectElement.h"
 #include "HTMLParserIdioms.h"
-#include "MemoryCache.h"
 #include "Page.h"
 #include "RenderImage.h"
 #include "RenderSVGImage.h"
-#include "ScriptController.h"
 #include "SecurityOrigin.h"
 #include <wtf/NeverDestroyed.h>
 
@@ -67,25 +63,6 @@ template<> struct ValueCheck<WebCore::ImageLoader*> {
 
 namespace WebCore {
 
-class ImageLoader::ImageLoaderTask : public MicroTask {
-public:
-    ImageLoaderTask(WeakPtr<ImageLoader> loader, CachedResourceLoader::ShouldBypassMainWorldContentSecurityPolicy shouldBypassMainWorldContentSecurityPolicy)
-        : m_loader(loader)
-        , m_shouldBypassMainWorldContentSecurityPolicy(shouldBypassMainWorldContentSecurityPolicy)
-    {
-    }
-
-private:
-    virtual void run() override
-    {
-        if (m_loader && m_loader->hasPendingTask())
-            m_loader->doUpdateFromElement(m_shouldBypassMainWorldContentSecurityPolicy);
-    }
-
-    WeakPtr<ImageLoader> m_loader;
-    CachedResourceLoader::ShouldBypassMainWorldContentSecurityPolicy m_shouldBypassMainWorldContentSecurityPolicy;
-};
-
 static ImageEventSender& beforeLoadEventSender()
 {
     static NeverDestroyed<ImageEventSender> sender(eventNames().beforeloadEvent);
@@ -114,14 +91,12 @@ ImageLoader::ImageLoader(Element& element)
     : m_element(element)
     , m_image(0)
     , m_derefElementTimer(*this, &ImageLoader::timerFired)
-    , m_weakFactory(this)
     , m_hasPendingBeforeLoadEvent(false)
     , m_hasPendingLoadEvent(false)
     , m_hasPendingErrorEvent(false)
     , m_imageComplete(true)
     , m_loadManually(false)
     , m_elementIsProtected(false)
-    , m_hasPendingTask(false)
 {
 }
 
@@ -184,26 +159,28 @@ void ImageLoader::clearImageWithoutConsideringPendingLoadEvent()
         imageResource->resetAnimation();
 }
 
-void ImageLoader::doUpdateFromElement(CachedResourceLoader::ShouldBypassMainWorldContentSecurityPolicy shouldBypassMainWorldContentSecurityPolicy)
+void ImageLoader::updateFromElement()
 {
-    m_hasPendingTask = false;
-    Document& document = m_element.document();
-    AtomicString attr = m_element.imageSourceURL();
-
-    String srcURI = sourceURI(attr);
-    URL url;
-    // Set url value only if srcURI is not empty. Otherwise, url will be the URL for the document itself.
-    if (!srcURI.isEmpty())
-        url = document.completeURL(srcURI);
+    // If we're not making renderers for the page, then don't load images.  We don't want to slow
+    // down the raw HTML parsing case by loading images we don't intend to display.
+    Document& document = element().document();
+    if (!document.hasLivingRenderTree())
+        return;
+
+    AtomicString attr = element().imageSourceURL();
+
+    // Avoid loading a URL we already failed to load.
+    if (!m_failedLoadURL.isEmpty() && attr == m_failedLoadURL)
+        return;
+
     // Do not load any image if the 'src' attribute is missing or if it is
     // an empty string.
     CachedResourceHandle<CachedImage> newImage = 0;
-    if (!url.isNull()) {
-        ResourceRequest resourceRequest(url);
-        CachedResourceRequest request(resourceRequest);
+    if (!attr.isNull() && !stripLeadingAndTrailingHTMLSpaces(attr).isEmpty()) {
+        CachedResourceRequest request(ResourceRequest(document.completeURL(sourceURI(attr))));
         request.setInitiator(&element());
 
-        AtomicString crossOriginMode = m_element.fastGetAttribute(HTMLNames::crossoriginAttr);
+        String crossOriginMode = element().fastGetAttribute(HTMLNames::crossoriginAttr);
         if (!crossOriginMode.isNull()) {
             StoredCredentials allowCredentials = equalIgnoringCase(crossOriginMode, "use-credentials") ? AllowStoredCredentials : DoNotAllowStoredCredentials;
             updateRequestForAccessControl(request.mutableResourceRequest(), document.securityOrigin(), allowCredentials);
@@ -218,7 +195,7 @@ void ImageLoader::doUpdateFromElement(CachedResourceLoader::ShouldBypassMainWorl
             document.cachedResourceLoader().m_documentResources.set(newImage->url(), newImage.get());
             document.cachedResourceLoader().setAutoLoadImages(autoLoadOtherImages);
         } else
-            newImage = document.cachedResourceLoader().requestImage(request, shouldBypassMainWorldContentSecurityPolicy);
+            newImage = document.cachedResourceLoader().requestImage(request);
 
         // If we do not have an image here, it means that a cross-site
         // violation occurred, or that the image was blocked via Content
@@ -236,7 +213,7 @@ void ImageLoader::doUpdateFromElement(CachedResourceLoader::ShouldBypassMainWorl
         m_hasPendingErrorEvent = true;
         errorEventSender().dispatchEventSoon(*this);
     }
-
+    
     CachedImage* oldImage = m_image.get();
     if (newImage != oldImage) {
         if (m_hasPendingBeforeLoadEvent) {
@@ -288,47 +265,6 @@ void ImageLoader::doUpdateFromElement(CachedResourceLoader::ShouldBypassMainWorl
     // Only consider updating the protection ref-count of the Element immediately before returning
     // from this function as doing so might result in the destruction of this ImageLoader.
     updatedHasPendingEvent();
-    document.decrementLoadEventDelayCount();
-}
-
-void ImageLoader::updateFromElement()
-{
-    AtomicString attribute = m_element.imageSourceURL();
-
-    // Avoid loading a URL we already failed to load.
-    if (!m_failedLoadURL.isEmpty() && attribute == m_failedLoadURL)
-        return;
-
-    // If we're not making renderers for the page, then don't load images. We don't want to slow
-    // down the raw HTML parsing case by loading images we don't intend to display.
-    Document& document = element().document();
-    if (!document.hasLivingRenderTree())
-        return;
-
-    CachedResourceLoader::ShouldBypassMainWorldContentSecurityPolicy shouldBypassMainWorldContentSecurityPolicy = CachedResourceLoader::ShouldBypassMainWorldContentSecurityPolicy::No;
-    if (document.frame() && document.frame()->script().shouldBypassMainWorldContentSecurityPolicy())
-        shouldBypassMainWorldContentSecurityPolicy = CachedResourceLoader::ShouldBypassMainWorldContentSecurityPolicy::Yes;
-
-    if (!m_hasPendingTask) {
-        m_hasPendingTask = true;
-        document.incrementLoadEventDelayCount();
-        if (shouldLoadImmediately(attribute))
-            doUpdateFromElement(CachedResourceLoader::ShouldBypassMainWorldContentSecurityPolicy::No);
-        else
-            MicroTaskQueue::singleton().queueMicroTask(std::make_unique<ImageLoaderTask>(createWeakPtr(), shouldBypassMainWorldContentSecurityPolicy));
-    }
-}
-
-bool ImageLoader::shouldLoadImmediately(const AtomicString& attribute) const
-{
-    String srcURI = sourceURI(attribute);
-    URL url = element().document().completeURL(srcURI);
-    return (srcURI.isEmpty()
-        || url.isEmpty()
-        || m_loadManually
-        || !is<HTMLImageElement>(m_element)
-        || url.protocolIsData()
-        || MemoryCache::singleton().resourceForURL(url));
 }
 
 void ImageLoader::updateFromElementIgnoringPreviousError()
@@ -340,7 +276,6 @@ void ImageLoader::updateFromElementIgnoringPreviousError()
 void ImageLoader::notifyFinished(CachedResource* resource)
 {
     ASSERT(m_failedLoadURL.isEmpty());
-    ASSERT(resource);
     ASSERT(resource == m_image.get());
 
     m_imageComplete = true;
@@ -350,9 +285,6 @@ void ImageLoader::notifyFinished(CachedResource* resource)
     if (!m_hasPendingLoadEvent)
         return;
 
-    ASSERT(image());
-    ASSERT(element().document().securityOrigin());
-
     if (element().fastHasAttribute(HTMLNames::crossoriginAttr)
         && !element().document().securityOrigin()->canRequest(image()->response().url())
         && !resource->passesAccessControlCheck(element().document().securityOrigin())) {
@@ -532,13 +464,8 @@ void ImageLoader::dispatchPendingErrorEvents()
     errorEventSender().dispatchPendingEvents();
 }
 
-void ImageLoader::elementDidMoveToNewDocument(Document* oldDocument)
+void ImageLoader::elementDidMoveToNewDocument()
 {
-    if (m_hasPendingTask) {
-        if (oldDocument)
-            oldDocument->decrementLoadEventDelayCount();
-        m_element.document().incrementLoadEventDelayCount();
-    }
     clearFailedLoadURL();
     clearImage();
 }
index 7f740b2..8449f11 100644 (file)
 
 #include "CachedImageClient.h"
 #include "CachedResourceHandle.h"
-#include "CachedResourceLoader.h"
-#include "MicroTask.h"
 #include "Timer.h"
-#include <wtf/RefCounted.h>
-#include <wtf/WeakPtr.h>
 #include <wtf/text/AtomicString.h>
 
 namespace WebCore {
 
-class Document;
 class Element;
 class ImageLoader;
 class RenderImageResource;
-class URL;
-class Task;
 
 template<typename T> class EventSender;
 typedef EventSender<ImageLoader> ImageEventSender;
@@ -57,12 +50,12 @@ public:
     // doesn't change; starts new load unconditionally (matches Firefox and Opera behavior).
     void updateFromElementIgnoringPreviousError();
 
-    void elementDidMoveToNewDocument(Document* oldDocument);
+    void elementDidMoveToNewDocument();
 
     Element& element() { return m_element; }
     const Element& element() const { return m_element; }
 
-    bool imageComplete() const { return m_imageComplete && !m_hasPendingTask; }
+    bool imageComplete() const { return m_imageComplete; }
 
     CachedImage* image() const { return m_image.get(); }
     void clearImage(); // Cancels pending beforeload and load events, and doesn't dispatch new ones.
@@ -70,7 +63,7 @@ public:
     void setLoadManually(bool loadManually) { m_loadManually = loadManually; }
 
     bool hasPendingBeforeLoadEvent() const { return m_hasPendingBeforeLoadEvent; }
-    bool hasPendingActivity() const { return m_hasPendingLoadEvent || m_hasPendingErrorEvent || m_hasPendingTask; }
+    bool hasPendingActivity() const { return m_hasPendingLoadEvent || m_hasPendingErrorEvent; }
 
     void dispatchPendingEvent(ImageEventSender*);
 
@@ -78,17 +71,11 @@ public:
     static void dispatchPendingLoadEvents();
     static void dispatchPendingErrorEvents();
 
-    bool hasPendingTask() const { return m_hasPendingTask; }
-
 protected:
     explicit ImageLoader(Element&);
     virtual void notifyFinished(CachedResource*) override;
 
 private:
-    class ImageLoaderTask;
-
-    // Called from the task or from updateFromElement to initiate the load.
-    void doUpdateFromElement(CachedResourceLoader::ShouldBypassMainWorldContentSecurityPolicy);
     virtual void dispatchLoadEvent() = 0;
     virtual String sourceURI(const AtomicString&) const = 0;
 
@@ -106,14 +93,9 @@ private:
 
     void timerFired();
 
-    // Determine whether to initiate a synchronous load or to schedule a microtask.
-    bool shouldLoadImmediately(const AtomicString& attribtue) const;
-    WeakPtr<ImageLoader> createWeakPtr() { return m_weakFactory.createWeakPtr(); }
-
     Element& m_element;
     CachedResourceHandle<CachedImage> m_image;
     Timer m_derefElementTimer;
-    WeakPtrFactory<ImageLoader> m_weakFactory;
     AtomicString m_failedLoadURL;
     bool m_hasPendingBeforeLoadEvent : 1;
     bool m_hasPendingLoadEvent : 1;
@@ -121,7 +103,6 @@ private:
     bool m_imageComplete : 1;
     bool m_loadManually : 1;
     bool m_elementIsProtected : 1;
-    bool m_hasPendingTask : 1;
 };
 
 }
index 94f380a..f3c2af0 100644 (file)
@@ -173,7 +173,7 @@ SessionID CachedResourceLoader::sessionID() const
     return sessionID;
 }
 
-CachedResourceHandle<CachedImage> CachedResourceLoader::requestImage(CachedResourceRequest& request, ShouldBypassMainWorldContentSecurityPolicy shouldBypassMainWorldContentSecurityPolicy)
+CachedResourceHandle<CachedImage> CachedResourceLoader::requestImage(CachedResourceRequest& request)
 {
     if (Frame* frame = this->frame()) {
         if (frame->loader().pageDismissalEventBeingDispatched() != FrameLoader::NoDismissal) {
@@ -185,7 +185,7 @@ CachedResourceHandle<CachedImage> CachedResourceLoader::requestImage(CachedResou
     }
     
     request.setDefer(clientDefersImage(request.resourceRequest().url()) ? CachedResourceRequest::DeferredByClient : CachedResourceRequest::NoDefer);
-    return downcast<CachedImage>(requestResource(CachedResource::ImageResource, request, shouldBypassMainWorldContentSecurityPolicy).get());
+    return downcast<CachedImage>(requestResource(CachedResource::ImageResource, request).get());
 }
 
 CachedResourceHandle<CachedFont> CachedResourceLoader::requestFont(CachedResourceRequest& request, bool isSVG)
@@ -357,7 +357,7 @@ bool CachedResourceLoader::checkInsecureContent(CachedResource::Type type, const
     return true;
 }
 
-bool CachedResourceLoader::canRequest(CachedResource::Type type, const URL& url, const ResourceLoaderOptions& options, bool forPreload, ShouldBypassMainWorldContentSecurityPolicy bypassMainWorldContentSecurityPolicy)
+bool CachedResourceLoader::canRequest(CachedResource::Type type, const URL& url, const ResourceLoaderOptions& options, bool forPreload)
 {
     if (document() && !document()->securityOrigin()->canDisplay(url)) {
         if (!forPreload)
@@ -366,10 +366,8 @@ bool CachedResourceLoader::canRequest(CachedResource::Type type, const URL& url,
         return 0;
     }
 
-
     // FIXME: Convert this to check the isolated world's Content Security Policy once webkit.org/b/104520 is solved.
-    bool shouldBypassMainWorldContentSecurityPolicy = (bypassMainWorldContentSecurityPolicy == ShouldBypassMainWorldContentSecurityPolicy::Yes)
-        || (frame() && frame()->script().shouldBypassMainWorldContentSecurityPolicy());
+    bool shouldBypassMainWorldContentSecurityPolicy = (frame() && frame()->script().shouldBypassMainWorldContentSecurityPolicy());
 
     // Some types of resources can be loaded only from the same origin.  Other
     // types of resources, like Images, Scripts, and CSS, can be loaded from
@@ -494,7 +492,7 @@ static inline void logMemoryCacheResourceRequest(Frame* frame, const String& des
         frame->mainFrame().diagnosticLoggingClient().logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceRequestKey(), description, value, ShouldSample::Yes);
 }
 
-CachedResourceHandle<CachedResource> CachedResourceLoader::requestResource(CachedResource::Type type, CachedResourceRequest& request, ShouldBypassMainWorldContentSecurityPolicy shouldBypassMainWorldContentSecurityPolicy)
+CachedResourceHandle<CachedResource> CachedResourceLoader::requestResource(CachedResource::Type type, CachedResourceRequest& request)
 {
     URL url = request.resourceRequest().url();
     
@@ -506,7 +504,7 @@ CachedResourceHandle<CachedResource> CachedResourceLoader::requestResource(Cache
     if (!url.isValid())
         return nullptr;
 
-    if (!canRequest(type, url, request.options(), request.forPreload(), shouldBypassMainWorldContentSecurityPolicy))
+    if (!canRequest(type, url, request.options(), request.forPreload()))
         return nullptr;
 
 #if ENABLE(CONTENT_EXTENSIONS)
index 26b260a..5447d4f 100644 (file)
@@ -71,9 +71,7 @@ public:
     static Ref<CachedResourceLoader> create(DocumentLoader* documentLoader) { return adoptRef(*new CachedResourceLoader(documentLoader)); }
     ~CachedResourceLoader();
 
-    enum class ShouldBypassMainWorldContentSecurityPolicy { No, Yes };
-
-    CachedResourceHandle<CachedImage> requestImage(CachedResourceRequest&, ShouldBypassMainWorldContentSecurityPolicy = ShouldBypassMainWorldContentSecurityPolicy::No);
+    CachedResourceHandle<CachedImage> requestImage(CachedResourceRequest&);
     CachedResourceHandle<CachedCSSStyleSheet> requestCSSStyleSheet(CachedResourceRequest&);
     CachedResourceHandle<CachedCSSStyleSheet> requestUserCSSStyleSheet(CachedResourceRequest&);
     CachedResourceHandle<CachedScript> requestScript(CachedResourceRequest&);
@@ -133,7 +131,7 @@ public:
     void preload(CachedResource::Type, CachedResourceRequest&, const String& charset);
     void checkForPendingPreloads();
     void printPreloadStats();
-    bool canRequest(CachedResource::Type, const URL&, const ResourceLoaderOptions&, bool forPreload = false, ShouldBypassMainWorldContentSecurityPolicy = ShouldBypassMainWorldContentSecurityPolicy::No);
+    bool canRequest(CachedResource::Type, const URL&, const ResourceLoaderOptions&, bool forPreload = false);
 
     static const ResourceLoaderOptions& defaultCachedResourceOptions();
 
@@ -142,7 +140,7 @@ public:
 private:
     explicit CachedResourceLoader(DocumentLoader*);
 
-    CachedResourceHandle<CachedResource> requestResource(CachedResource::Type, CachedResourceRequest&, ShouldBypassMainWorldContentSecurityPolicy = ShouldBypassMainWorldContentSecurityPolicy::No);
+    CachedResourceHandle<CachedResource> requestResource(CachedResource::Type, CachedResourceRequest&);
     CachedResourceHandle<CachedResource> revalidateResource(const CachedResourceRequest&, CachedResource*);
     CachedResourceHandle<CachedResource> loadResource(CachedResource::Type, CachedResourceRequest&);
 #if ENABLE(RESOURCE_TIMING)
index 9aa90a2..b366812 100644 (file)
@@ -205,7 +205,7 @@ void SVGImageElement::addSubresourceAttributeURLs(ListHashSet<URL>& urls) const
 
 void SVGImageElement::didMoveToNewDocument(Document* oldDocument)
 {
-    m_imageLoader.elementDidMoveToNewDocument(oldDocument);
+    m_imageLoader.elementDidMoveToNewDocument();
     SVGGraphicsElement::didMoveToNewDocument(oldDocument);
 }
 
index 521e749..f55a615 100644 (file)
@@ -40,7 +40,6 @@
 #include "HTMLNames.h"
 #include "HTMLStyleElement.h"
 #include "ImageLoader.h"
-#include "MicroTask.h"
 #include "ProcessingInstruction.h"
 #include "ResourceError.h"
 #include "ResourceRequest.h"
@@ -201,7 +200,6 @@ void XMLDocumentParser::end()
     document()->setReadyState(Document::Interactive);
     clearCurrentNodeStack();
     document()->finishedParsing();
-    MicroTaskQueue::singleton().runMicroTasks();
 }
 
 void XMLDocumentParser::finish()