Title: [257054] trunk
Revision
257054
Author
[email protected]
Date
2020-02-20 06:46:05 -0800 (Thu, 20 Feb 2020)

Log Message

Lazy load images using base url at parse time
https://bugs.webkit.org/show_bug.cgi?id=207902

Patch by Rob Buis <[email protected]> on 2020-02-20
Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Update improved test results.

* web-platform-tests/html/semantics/embedded-content/the-img-element/original-base-url-applied-2-expected.txt:
* web-platform-tests/html/semantics/embedded-content/the-img-element/original-base-url-applied-expected.txt:

Source/WebCore:

The spec says to use the base url at parse time for request
url, ignoring changes to base url after that [1]. To fix this
add a new state LoadImmediately to LazyImageLoadState where
the parse time url from the initial request is reused.

[1] https://html.spec.whatwg.org/multipage/images.html#update-the-image-data

Tests: imported/web-platform-tests/html/semantics/embedded-content/the-img-element/original-base-url-applied-2.html
       imported/web-platform-tests/html/semantics/embedded-content/the-img-element/original-base-url-applied.html

* loader/ImageLoader.cpp:
(WebCore::ImageLoader::updateFromElement):
(WebCore::ImageLoader::loadDeferredImage):
* loader/ImageLoader.h:

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (257053 => 257054)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-02-20 14:28:36 UTC (rev 257053)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-02-20 14:46:05 UTC (rev 257054)
@@ -1,3 +1,15 @@
+2020-02-20  Rob Buis  <[email protected]>
+
+        Lazy load images using base url at parse time
+        https://bugs.webkit.org/show_bug.cgi?id=207902
+
+        Reviewed by Darin Adler.
+
+        Update improved test results.
+
+        * web-platform-tests/html/semantics/embedded-content/the-img-element/original-base-url-applied-2-expected.txt:
+        * web-platform-tests/html/semantics/embedded-content/the-img-element/original-base-url-applied-expected.txt:
+
 2020-02-19  Rob Buis  <[email protected]>
 
         Main implementation for lazy image loading

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/original-base-url-applied-2-expected.txt (257053 => 257054)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/original-base-url-applied-2-expected.txt	2020-02-20 14:28:36 UTC (rev 257053)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/original-base-url-applied-2-expected.txt	2020-02-20 14:46:05 UTC (rev 257054)
@@ -1,4 +1,4 @@
 
 
-FAIL Deferred images with loading='lazy' use the original base URL specified at the parse time assert_unreached: The image request should not load relative to the current (incorrect) base URL. Reached unreachable code
+PASS Deferred images with loading='lazy' use the original base URL specified at the parse time 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/original-base-url-applied-expected.txt (257053 => 257054)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/original-base-url-applied-expected.txt	2020-02-20 14:28:36 UTC (rev 257053)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/original-base-url-applied-expected.txt	2020-02-20 14:46:05 UTC (rev 257054)
@@ -1,5 +1,5 @@
   
 
 PASS Test that when deferred iframe is loaded, it uses the base URL computed at parse time. 
-FAIL Test that when deferred img is loaded, it uses the base URL computed at parse time. assert_unreached: The image load should not fail, trying to load with invalid base URL. Reached unreachable code
+PASS Test that when deferred img is loaded, it uses the base URL computed at parse time. 
 

Modified: trunk/Source/WebCore/ChangeLog (257053 => 257054)


--- trunk/Source/WebCore/ChangeLog	2020-02-20 14:28:36 UTC (rev 257053)
+++ trunk/Source/WebCore/ChangeLog	2020-02-20 14:46:05 UTC (rev 257054)
@@ -1,3 +1,25 @@
+2020-02-20  Rob Buis  <[email protected]>
+
+        Lazy load images using base url at parse time
+        https://bugs.webkit.org/show_bug.cgi?id=207902
+
+        Reviewed by Darin Adler.
+
+        The spec says to use the base url at parse time for request
+        url, ignoring changes to base url after that [1]. To fix this
+        add a new state LoadImmediately to LazyImageLoadState where
+        the parse time url from the initial request is reused.
+
+        [1] https://html.spec.whatwg.org/multipage/images.html#update-the-image-data
+
+        Tests: imported/web-platform-tests/html/semantics/embedded-content/the-img-element/original-base-url-applied-2.html
+               imported/web-platform-tests/html/semantics/embedded-content/the-img-element/original-base-url-applied.html
+
+        * loader/ImageLoader.cpp:
+        (WebCore::ImageLoader::updateFromElement):
+        (WebCore::ImageLoader::loadDeferredImage):
+        * loader/ImageLoader.h:
+
 2020-02-20  Don Olmstead  <[email protected]>
 
         [CMake] Add WPE::libwpe target

Modified: trunk/Source/WebCore/loader/ImageLoader.cpp (257053 => 257054)


--- trunk/Source/WebCore/loader/ImageLoader.cpp	2020-02-20 14:28:36 UTC (rev 257053)
+++ trunk/Source/WebCore/loader/ImageLoader.cpp	2020-02-20 14:46:05 UTC (rev 257054)
@@ -184,7 +184,10 @@
 
         auto crossOriginAttribute = element().attributeWithoutSynchronization(HTMLNames::crossoriginAttr);
 
-        ResourceRequest resourceRequest(document.completeURL(sourceURI(attr)));
+        // Use url from original request for lazy loads that are no longer in deferred state.
+        URL imageURL = m_lazyImageLoadState == LazyImageLoadState::LoadImmediately
+            ? m_image->url() : document.completeURL(sourceURI(attr));
+        ResourceRequest resourceRequest(imageURL);
         resourceRequest.setInspectorInitiatorNodeIdentifier(InspectorInstrumentation::identifierForNode(m_element));
 
         auto request = createPotentialAccessControlRequest(WTFMove(resourceRequest), WTFMove(options), document, crossOriginAttribute);
@@ -586,7 +589,7 @@
 {
     if (m_lazyImageLoadState != LazyImageLoadState::Deferred)
         return;
-    m_lazyImageLoadState = LazyImageLoadState::FullImage;
+    m_lazyImageLoadState = LazyImageLoadState::LoadImmediately;
     updateFromElement();
 }
 

Modified: trunk/Source/WebCore/loader/ImageLoader.h (257053 => 257054)


--- trunk/Source/WebCore/loader/ImageLoader.h	2020-02-20 14:28:36 UTC (rev 257053)
+++ trunk/Source/WebCore/loader/ImageLoader.h	2020-02-20 14:46:05 UTC (rev 257054)
@@ -84,7 +84,7 @@
     void notifyFinished(CachedResource&) override;
 
 private:
-    enum class LazyImageLoadState : uint8_t { None, Deferred, FullImage };
+    enum class LazyImageLoadState : uint8_t { None, Deferred, LoadImmediately, FullImage };
 
     virtual void dispatchLoadEvent() = 0;
     virtual String sourceURI(const AtomString&) const = 0;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to