Title: [219364] trunk
Revision
219364
Author
[email protected]
Date
2017-07-11 14:33:19 -0700 (Tue, 11 Jul 2017)

Log Message

REGRESSION(r219045): The <body> element does not get repainted when its background image finishes decoding
https://bugs.webkit.org/show_bug.cgi?id=174376

Patch by Said Abou-Hallawa <[email protected]> on 2017-07-11
Reviewed by Simon Fraser.

Source/WebCore:

When adding a CachedImageClient to CachedImage::m_pendingImageDrawingClients
and the CachedImageClient is not one of the CachedImage::m_clients, we
should cancel the repaint optimization in CachedImage::imageFrameAvailable().
This can be done by adding all the CachedImage::m_clients to CachedImage::
m_pendingImageDrawingClients.

Test: fast/images/async-image-body-background-image.html

* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::addPendingImageDrawingClient):

LayoutTests:

* fast/images/async-image-body-background-image-expected.html: Added.
* fast/images/async-image-body-background-image.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (219363 => 219364)


--- trunk/LayoutTests/ChangeLog	2017-07-11 21:09:31 UTC (rev 219363)
+++ trunk/LayoutTests/ChangeLog	2017-07-11 21:33:19 UTC (rev 219364)
@@ -1,3 +1,13 @@
+2017-07-11  Said Abou-Hallawa  <[email protected]>
+
+        REGRESSION(r219045): The <body> element does not get repainted when its background image finishes decoding
+        https://bugs.webkit.org/show_bug.cgi?id=174376
+
+        Reviewed by Simon Fraser.
+
+        * fast/images/async-image-body-background-image-expected.html: Added.
+        * fast/images/async-image-body-background-image.html: Added.
+
 2017-07-11  Youenn Fablet  <[email protected]>
 
         We should do ICE candidate filtering at the Document level

Added: trunk/LayoutTests/fast/images/async-image-body-background-image-expected.html (0 => 219364)


--- trunk/LayoutTests/fast/images/async-image-body-background-image-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/images/async-image-body-background-image-expected.html	2017-07-11 21:33:19 UTC (rev 219364)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+    iframe {
+        width: 200px;
+        height: 100px;
+        background-color: green;
+    }
+</style>
+</head>
+<body>
+    <iframe frameBorder="0"></iframe>
+</body>
+</html>

Added: trunk/LayoutTests/fast/images/async-image-body-background-image.html (0 => 219364)


--- trunk/LayoutTests/fast/images/async-image-body-background-image.html	                        (rev 0)
+++ trunk/LayoutTests/fast/images/async-image-body-background-image.html	2017-07-11 21:33:19 UTC (rev 219364)
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+    iframe {
+        width: 200px;
+        height: 100px;
+    }
+</style>
+</head>
+<body>
+    <iframe frameBorder="0" srcdoc="<body style='image-rendering: crisp-edges; background-position: -100px -33000px; background-size: 400px 66200px;'></body>"></iframe>
+    <script>
+        function setElementImageBackground(element, image) {
+            return new Promise((resolve) => {
+                element.style.backgroundImage = 'url(' + image.src + ')';
+
+                // Force layout and display so the image frame starts decoding
+                document.body.offsetHeight;
+                testRunner.display();
+ 
+                element.addEventListener("webkitImageFrameReady", function() {
+                    resolve();
+                }, false);
+            });
+        }
+
+        (function() {
+            if (window.internals && window.testRunner) {
+                internals.clearMemoryCache();
+                internals.settings.setWebkitImageReadyEventEnabled(true);
+                internals.settings.setLargeImageAsyncDecodingEnabled(true);
+                testRunner.waitUntilDone();
+            }
+
+            var image = new Image();
+            image._onload_ = function() {
+                var iframeDocument = document.querySelector('iframe').contentWindow.document;
+
+                if (window.internals && window.testRunner) {
+                    setElementImageBackground(iframeDocument.querySelector("body"), image).then(() => {
+                        testRunner.notifyDone();
+                    });
+                } else
+                    iframeDocument.querySelector("body").style.backgroundImage = 'url(' + image.src + ')';
+            }
+            image.src = ""
+        })();
+    </script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (219363 => 219364)


--- trunk/Source/WebCore/ChangeLog	2017-07-11 21:09:31 UTC (rev 219363)
+++ trunk/Source/WebCore/ChangeLog	2017-07-11 21:33:19 UTC (rev 219364)
@@ -1,3 +1,21 @@
+2017-07-11  Said Abou-Hallawa  <[email protected]>
+
+        REGRESSION(r219045): The <body> element does not get repainted when its background image finishes decoding
+        https://bugs.webkit.org/show_bug.cgi?id=174376
+
+        Reviewed by Simon Fraser.
+
+        When adding a CachedImageClient to CachedImage::m_pendingImageDrawingClients
+        and the CachedImageClient is not one of the CachedImage::m_clients, we
+        should cancel the repaint optimization in CachedImage::imageFrameAvailable().
+        This can be done by adding all the CachedImage::m_clients to CachedImage::
+        m_pendingImageDrawingClients.
+
+        Test: fast/images/async-image-body-background-image.html
+
+        * loader/cache/CachedImage.cpp:
+        (WebCore::CachedImage::addPendingImageDrawingClient):
+
 2017-07-11  Chris Dumez  <[email protected]>
 
         Unreviewed, fix Windows build after r219355.

Modified: trunk/Source/WebCore/loader/cache/CachedImage.cpp (219363 => 219364)


--- trunk/Source/WebCore/loader/cache/CachedImage.cpp	2017-07-11 21:09:31 UTC (rev 219363)
+++ trunk/Source/WebCore/loader/cache/CachedImage.cpp	2017-07-11 21:33:19 UTC (rev 219364)
@@ -142,7 +142,20 @@
 void CachedImage::addPendingImageDrawingClient(CachedImageClient& client)
 {
     ASSERT(client.resourceClientType() == CachedImageClient::expectedType());
-    m_pendingImageDrawingClients.add(&client);
+    if (m_pendingImageDrawingClients.contains(&client))
+        return;
+    if (!m_clients.contains(&client)) {
+        // If the <html> element does not have its own background sepecfied, painting the root box
+        // renderer uses the style of the <body> element, see RenderView::rendererForRootBackground().
+        // In this case, the client we are asked to add is the root box renderer. Since we can't add
+        // a client to m_pendingImageDrawingClients unless it is one of the m_clients, we are going
+        // to cancel the repaint optimization we do in CachedImage::imageFrameAvailable() by adding
+        // all the m_clients to m_pendingImageDrawingClients.
+        CachedResourceClientWalker<CachedImageClient> walker(m_clients);
+        while (auto* client = walker.next())
+            m_pendingImageDrawingClients.add(client);
+    } else
+        m_pendingImageDrawingClients.add(&client);
 }
 
 void CachedImage::switchClientsToRevalidatedResource()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to