Title: [221803] trunk
Revision
221803
Author
[email protected]
Date
2017-09-08 17:10:45 -0700 (Fri, 08 Sep 2017)

Log Message

Implement the attribute HTMLImageElement.async
https://bugs.webkit.org/show_bug.cgi?id=176204

Patch by Said Abou-Hallawa <[email protected]> on 2017-09-08
Reviewed by Darin Adler.

Source/WebCore:

Adding this attribute to the <img> element will force async decoding for
this image all the times. None of the heuristics, which  prevents flickering
the image, will be checked.

Test: fast/images/async-attribute-with-small-image.html

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::parseAttribute):
* html/HTMLImageElement.h:
(WebCore::HTMLImageElement::async const):
* html/HTMLImageElement.idl:
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::decodingModeForImageDraw const):

LayoutTests:

* fast/images/async-attribute-with-small-image-expected.html: Added.
* fast/images/async-attribute-with-small-image.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (221802 => 221803)


--- trunk/LayoutTests/ChangeLog	2017-09-08 23:11:41 UTC (rev 221802)
+++ trunk/LayoutTests/ChangeLog	2017-09-09 00:10:45 UTC (rev 221803)
@@ -1,3 +1,13 @@
+2017-09-08  Said Abou-Hallawa  <[email protected]>
+
+        Implement the attribute HTMLImageElement.async 
+        https://bugs.webkit.org/show_bug.cgi?id=176204
+
+        Reviewed by Darin Adler.
+
+        * fast/images/async-attribute-with-small-image-expected.html: Added.
+        * fast/images/async-attribute-with-small-image.html: Added.
+
 2017-09-08  Per Arne Vollan  <[email protected]>
 
         Fix duplicate entry warnings on Windows.

Added: trunk/LayoutTests/fast/images/async-attribute-with-small-image-expected.html (0 => 221803)


--- trunk/LayoutTests/fast/images/async-attribute-with-small-image-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/images/async-attribute-with-small-image-expected.html	2017-09-09 00:10:45 UTC (rev 221803)
@@ -0,0 +1,3 @@
+<body>
+    <img src=""
+ </body>

Added: trunk/LayoutTests/fast/images/async-attribute-with-small-image.html (0 => 221803)


--- trunk/LayoutTests/fast/images/async-attribute-with-small-image.html	                        (rev 0)
+++ trunk/LayoutTests/fast/images/async-attribute-with-small-image.html	2017-09-09 00:10:45 UTC (rev 221803)
@@ -0,0 +1,37 @@
+<body>
+    <img async>
+    <script>
+        function loadImage(image, src) {
+            return new Promise((resolve) => {
+                image._onload_ = (() => {
+                    if (window.internals && window.testRunner) {
+                        // Force layout and display so the image gets drawn.
+                        document.body.offsetHeight;
+                        testRunner.display();
+
+                        // Listen for the webkitImageFrameReady event after requesting
+                        // the image decoding.
+                        image.addEventListener("webkitImageFrameReady", function() {
+                            resolve();
+                        }, false);
+                    } else
+                        resolve();
+                });
+                image.src = ""
+            });
+        }
+        (function() {
+            if (window.internals && window.testRunner) {
+                internals.clearMemoryCache();
+                internals.settings.setWebkitImageReadyEventEnabled(true);
+                testRunner.waitUntilDone();
+            }
+ 
+            var image = document.querySelector("img");
+            loadImage(image, "resources/green-24x24.jpg", true).then(() => {
+                if (window.testRunner)
+                    testRunner.notifyDone();
+            });
+        })();
+    </script>
+</body>

Modified: trunk/Source/WebCore/ChangeLog (221802 => 221803)


--- trunk/Source/WebCore/ChangeLog	2017-09-08 23:11:41 UTC (rev 221802)
+++ trunk/Source/WebCore/ChangeLog	2017-09-09 00:10:45 UTC (rev 221803)
@@ -1,3 +1,24 @@
+2017-09-08  Said Abou-Hallawa  <[email protected]>
+
+        Implement the attribute HTMLImageElement.async 
+        https://bugs.webkit.org/show_bug.cgi?id=176204
+
+        Reviewed by Darin Adler.
+
+        Adding this attribute to the <img> element will force async decoding for
+        this image all the times. None of the heuristics, which  prevents flickering
+        the image, will be checked.
+
+        Test: fast/images/async-attribute-with-small-image.html
+
+        * html/HTMLImageElement.cpp:
+        (WebCore::HTMLImageElement::parseAttribute):
+        * html/HTMLImageElement.h:
+        (WebCore::HTMLImageElement::async const):
+        * html/HTMLImageElement.idl:
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::decodingModeForImageDraw const):
+
 2017-09-08  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r221773.

Modified: trunk/Source/WebCore/html/HTMLImageElement.idl (221802 => 221803)


--- trunk/Source/WebCore/html/HTMLImageElement.idl	2017-09-08 23:11:41 UTC (rev 221802)
+++ trunk/Source/WebCore/html/HTMLImageElement.idl	2017-09-09 00:10:45 UTC (rev 221803)
@@ -40,6 +40,7 @@
     [Reflect] attribute DOMString useMap;
     [Reflect] attribute unsigned long vspace;
     attribute unsigned long width;
+    [Reflect] attribute boolean async;
 
     // Extensions
     readonly attribute boolean complete;

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (221802 => 221803)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2017-09-08 23:11:41 UTC (rev 221802)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2017-09-09 00:10:45 UTC (rev 221803)
@@ -36,6 +36,7 @@
 #include "GraphicsContext.h"
 #include "HTMLFrameOwnerElement.h"
 #include "HTMLFrameSetElement.h"
+#include "HTMLImageElement.h"
 #include "HTMLNames.h"
 #include "ImageBuffer.h"
 #include "ImageQualityController.h"
@@ -326,6 +327,8 @@
 #endif
     if (bitmapImage.isLargeImageAsyncDecodingEnabledForTesting())
         return DecodingMode::Asynchronous;
+    if (is<HTMLImageElement>(element()) && element()->hasAttribute(asyncAttr))
+        return DecodingMode::Asynchronous;
     if (document().isImageDocument())
         return DecodingMode::Synchronous;
     if (paintInfo.paintBehavior & PaintBehaviorSnapshotting)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to