Title: [266720] trunk
Revision
266720
Author
[email protected]
Date
2020-09-08 04:59:42 -0700 (Tue, 08 Sep 2020)

Log Message

Fix crash in image-loading-lazy-slow.html WPT test
https://bugs.webkit.org/show_bug.cgi?id=215998

Patch by Rob Buis <[email protected]> on 2020-09-08
Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

Adjust image-loading-lazy-slow.html to enable lazy image loading.

* web-platform-tests/html/semantics/embedded-content/the-img-element/image-loading-lazy-slow.html:

Source/WebCore:

When setting images to an empty src, make sure
to reset any lazy image load information.

* html/LazyLoadImageObserver.h:
* loader/ImageLoader.cpp:
(WebCore::ImageLoader::updateFromElement):
(WebCore::ImageLoader::elementDidMoveToNewDocument):
(WebCore::ImageLoader::resetLazyImageLoading):
* loader/ImageLoader.h:
(WebCore::ImageLoader::isDeferred const):

LayoutTests:

Mark image-loading-lazy-slow.html as ImageOnlyFailure.

* TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (266719 => 266720)


--- trunk/LayoutTests/ChangeLog	2020-09-08 10:49:42 UTC (rev 266719)
+++ trunk/LayoutTests/ChangeLog	2020-09-08 11:59:42 UTC (rev 266720)
@@ -1,3 +1,14 @@
+2020-09-08  Rob Buis  <[email protected]>
+
+        Fix crash in image-loading-lazy-slow.html WPT test
+        https://bugs.webkit.org/show_bug.cgi?id=215998
+
+        Reviewed by Youenn Fablet.
+
+        Mark image-loading-lazy-slow.html as ImageOnlyFailure.
+
+        * TestExpectations:
+
 2020-09-07  Chris Dumez  <[email protected]>
 
         AudioParam.cancelAndHoldAtTime() is missing

Modified: trunk/LayoutTests/TestExpectations (266719 => 266720)


--- trunk/LayoutTests/TestExpectations	2020-09-08 10:49:42 UTC (rev 266719)
+++ trunk/LayoutTests/TestExpectations	2020-09-08 11:59:42 UTC (rev 266720)
@@ -543,6 +543,7 @@
 imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe-modify-scrolling-attr-to-yes.html [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/adopt-from-image-document.html [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/image-loading-lazy-slow-aspect-ratio.html [ ImageOnlyFailure ]
+imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/image-loading-lazy-slow.html [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/html/semantics/forms/the-option-element/dynamic-content-change-rendering.html [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/reset-algorithm-rendering.html [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/html/semantics/forms/the-textarea-element/multiline-placeholder-cr.html [ ImageOnlyFailure ]

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (266719 => 266720)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-09-08 10:49:42 UTC (rev 266719)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-09-08 11:59:42 UTC (rev 266720)
@@ -1,3 +1,14 @@
+2020-09-08  Rob Buis  <[email protected]>
+
+        Fix crash in image-loading-lazy-slow.html WPT test
+        https://bugs.webkit.org/show_bug.cgi?id=215998
+
+        Reviewed by Youenn Fablet.
+
+        Adjust image-loading-lazy-slow.html to enable lazy image loading.
+
+        * web-platform-tests/html/semantics/embedded-content/the-img-element/image-loading-lazy-slow.html:
+
 2020-09-07  Sergio Villar Senin  <[email protected]>
 
         [css-flex] Don't skip flexboxes with auto height for percentage computations in quirks mode

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/image-loading-lazy-slow.html (266719 => 266720)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/image-loading-lazy-slow.html	2020-09-08 10:49:42 UTC (rev 266719)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/image-loading-lazy-slow.html	2020-09-08 11:59:42 UTC (rev 266720)
@@ -1,4 +1,4 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ experimental:enableLazyImageLoading=true ] -->
 <html class="reftest-wait">
   <link rel="match" href=""
   <link rel="author" title="Chris Harrelson" href=""

Modified: trunk/Source/WebCore/ChangeLog (266719 => 266720)


--- trunk/Source/WebCore/ChangeLog	2020-09-08 10:49:42 UTC (rev 266719)
+++ trunk/Source/WebCore/ChangeLog	2020-09-08 11:59:42 UTC (rev 266720)
@@ -1,3 +1,21 @@
+2020-09-08  Rob Buis  <[email protected]>
+
+        Fix crash in image-loading-lazy-slow.html WPT test
+        https://bugs.webkit.org/show_bug.cgi?id=215998
+
+        Reviewed by Youenn Fablet.
+
+        When setting images to an empty src, make sure
+        to reset any lazy image load information.
+
+        * html/LazyLoadImageObserver.h:
+        * loader/ImageLoader.cpp:
+        (WebCore::ImageLoader::updateFromElement):
+        (WebCore::ImageLoader::elementDidMoveToNewDocument):
+        (WebCore::ImageLoader::resetLazyImageLoading):
+        * loader/ImageLoader.h:
+        (WebCore::ImageLoader::isDeferred const):
+
 2020-09-08  Antti Koivisto  <[email protected]>
 
         Comparing styles with large but identical custom property maps is slow

Modified: trunk/Source/WebCore/html/LazyLoadImageObserver.h (266719 => 266720)


--- trunk/Source/WebCore/html/LazyLoadImageObserver.h	2020-09-08 10:49:42 UTC (rev 266719)
+++ trunk/Source/WebCore/html/LazyLoadImageObserver.h	2020-09-08 11:59:42 UTC (rev 266720)
@@ -38,6 +38,8 @@
     static void observe(Element&);
     static void unobserve(Element&, Document&);
 
+    bool isObserved(Element&) const;
+
 private:
     friend class Document;
 
@@ -48,7 +50,6 @@
     LazyLoadImageObserver() = default;
 
     IntersectionObserver* intersectionObserver(Document&);
-    bool isObserved(Element&) const;
 
     // The intersection observer responsible for loading the image once it's near the viewport.
     RefPtr<IntersectionObserver> m_lazyLoadIntersectionObserver;

Modified: trunk/Source/WebCore/loader/ImageLoader.cpp (266719 => 266720)


--- trunk/Source/WebCore/loader/ImageLoader.cpp	2020-09-08 10:49:42 UTC (rev 266719)
+++ trunk/Source/WebCore/loader/ImageLoader.cpp	2020-09-08 11:59:42 UTC (rev 266720)
@@ -275,7 +275,8 @@
             // being queued to fire. Ensure this happens after beforeload is
             // dispatched.
             newImage->addClient(*this);
-        }
+        } else
+            resetLazyImageLoading(element().document());
         if (oldImage) {
             oldImage->removeClient(*this);
             updateRenderer();
@@ -578,9 +579,7 @@
 {
     clearFailedLoadURL();
     clearImage();
-    if (isDeferred())
-        LazyLoadImageObserver::unobserve(element(), oldDocument);
-    m_lazyImageLoadState = LazyImageLoadState::None;
+    resetLazyImageLoading(oldDocument);
 }
 
 inline void ImageLoader::clearFailedLoadURL()
@@ -596,4 +595,11 @@
     updateFromElement(RelevantMutation::No);
 }
 
+void ImageLoader::resetLazyImageLoading(Document& document)
+{
+    if (isDeferred())
+        LazyLoadImageObserver::unobserve(element(), document);
+    m_lazyImageLoadState = LazyImageLoadState::None;
 }
+
+}

Modified: trunk/Source/WebCore/loader/ImageLoader.h (266719 => 266720)


--- trunk/Source/WebCore/loader/ImageLoader.h	2020-09-08 10:49:42 UTC (rev 266719)
+++ trunk/Source/WebCore/loader/ImageLoader.h	2020-09-08 11:59:42 UTC (rev 266720)
@@ -81,7 +81,7 @@
 
     void loadDeferredImage();
 
-    bool isDeferred() const { return m_lazyImageLoadState == LazyImageLoadState::Deferred; }
+    bool isDeferred() const { return m_lazyImageLoadState == LazyImageLoadState::Deferred || m_lazyImageLoadState == LazyImageLoadState::LoadImmediately; }
 
     Document& document() { return m_element.document(); }
 
@@ -90,6 +90,7 @@
     void notifyFinished(CachedResource&, const NetworkLoadMetrics&) override;
 
 private:
+    void resetLazyImageLoading(Document&);
     enum class LazyImageLoadState : uint8_t { None, Deferred, LoadImmediately, FullImage };
 
     virtual void dispatchLoadEvent() = 0;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to