Title: [225616] trunk
Revision
225616
Author
[email protected]
Date
2017-12-06 19:36:03 -0800 (Wed, 06 Dec 2017)

Log Message

Support the decoding="sync/async" syntax for image async attribute
https://bugs.webkit.org/show_bug.cgi?id=179432

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

Source/WebCore:

Support the HTMLElementImage decoding attribute to allow controlling the
decoding of an image as per:
        https://github.com/whatwg/html/pull/3221
        https://whatpr.org/html/3221/images.html#decoding-images

Tests: fast/images/decode-decoding-attribute-async-large-image.html
       fast/images/decoding-attribute-async-small-image.html
       fast/images/decoding-attribute-dynamic-async-small-image.html
       fast/images/decoding-attribute-sync-large-image.html

* html/HTMLAttributeNames.in:
* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::decodingMode const):
* html/HTMLImageElement.h:
* html/HTMLImageElement.idl:
* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::draw):
(WebCore::BitmapImage::internalStartAnimation):
(WebCore::BitmapImage::advanceAnimation):
(WebCore::BitmapImage::internalAdvanceAnimation):
* platform/graphics/DecodingOptions.h:
(WebCore::DecodingOptions::DecodingOptions):
(WebCore::DecodingOptions::isAuto const):
(WebCore::DecodingOptions::isAsynchronousCompatibleWith const):
(WebCore::DecodingOptions::isNone const): Deleted.
* platform/graphics/ImageDecoder.h:
* platform/graphics/ImageFrame.cpp:
(WebCore::ImageFrame::clearImage):
* platform/graphics/ImageSource.cpp:
(WebCore::ImageSource::frameAtIndexCacheIfNeeded):
* platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.h:
* platform/graphics/cg/ImageDecoderCG.h:
* platform/graphics/win/ImageDecoderDirect2D.h:
* platform/image-decoders/ScalableImageDecoder.h:
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::decodingModeForImageDraw const):
The element attributes and the document settings should be checked before
checking our heuristics. And since the "decoding" attribute is per an image
and isLargeImageAsyncDecodingEnabledForTesting() is a global setting, the
decoding attribute should be checked first.

LayoutTests:

* fast/images/async-attribute-with-small-image-expected.html: Removed.
* fast/images/async-attribute-with-small-image.html: Removed.
* fast/images/decode-decoding-attribute-async-large-image-expected.html: Added.
* fast/images/decode-decoding-attribute-async-large-image.html: Added.
* fast/images/decoding-attribute-async-small-image-expected.html: Added.
* fast/images/decoding-attribute-async-small-image.html: Added.
* fast/images/decoding-attribute-dynamic-async-small-image-expected.html: Added.
* fast/images/decoding-attribute-dynamic-async-small-image.html: Added.
* fast/images/decoding-attribute-sync-large-image-expected.html: Added.
* fast/images/decoding-attribute-sync-large-image.html: Added.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (225615 => 225616)


--- trunk/LayoutTests/ChangeLog	2017-12-07 03:30:08 UTC (rev 225615)
+++ trunk/LayoutTests/ChangeLog	2017-12-07 03:36:03 UTC (rev 225616)
@@ -1,3 +1,21 @@
+2017-12-06  Said Abou-Hallawa  <[email protected]>
+
+        Support the decoding="sync/async" syntax for image async attribute
+        https://bugs.webkit.org/show_bug.cgi?id=179432
+
+        Reviewed by Darin Adler.
+
+        * fast/images/async-attribute-with-small-image-expected.html: Removed.
+        * fast/images/async-attribute-with-small-image.html: Removed.
+        * fast/images/decode-decoding-attribute-async-large-image-expected.html: Added.
+        * fast/images/decode-decoding-attribute-async-large-image.html: Added.
+        * fast/images/decoding-attribute-async-small-image-expected.html: Added.
+        * fast/images/decoding-attribute-async-small-image.html: Added.
+        * fast/images/decoding-attribute-dynamic-async-small-image-expected.html: Added.
+        * fast/images/decoding-attribute-dynamic-async-small-image.html: Added.
+        * fast/images/decoding-attribute-sync-large-image-expected.html: Added.
+        * fast/images/decoding-attribute-sync-large-image.html: Added.
+
 2017-12-06  Fujii Hironori  <[email protected]>
 
         AX: Layout test imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_tests1.html flaky crash

Deleted: trunk/LayoutTests/fast/images/async-attribute-with-small-image-expected.html (225615 => 225616)


--- trunk/LayoutTests/fast/images/async-attribute-with-small-image-expected.html	2017-12-07 03:30:08 UTC (rev 225615)
+++ trunk/LayoutTests/fast/images/async-attribute-with-small-image-expected.html	2017-12-07 03:36:03 UTC (rev 225616)
@@ -1,3 +0,0 @@
-<body>
-    <img src=""
- </body>

Deleted: trunk/LayoutTests/fast/images/async-attribute-with-small-image.html (225615 => 225616)


--- trunk/LayoutTests/fast/images/async-attribute-with-small-image.html	2017-12-07 03:30:08 UTC (rev 225615)
+++ trunk/LayoutTests/fast/images/async-attribute-with-small-image.html	2017-12-07 03:36:03 UTC (rev 225616)
@@ -1,37 +0,0 @@
-<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>

Added: trunk/LayoutTests/fast/images/decode-decoding-attribute-async-large-image-expected.html (0 => 225616)


--- trunk/LayoutTests/fast/images/decode-decoding-attribute-async-large-image-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/images/decode-decoding-attribute-async-large-image-expected.html	2017-12-07 03:36:03 UTC (rev 225616)
@@ -0,0 +1,4 @@
+<body>
+    <p>This test ensures if the src of an image with decoding="async" is set to the src of a decoded image, no further decoding will be requested.</p>
+    <img src=""
+</body>

Added: trunk/LayoutTests/fast/images/decode-decoding-attribute-async-large-image.html (0 => 225616)


--- trunk/LayoutTests/fast/images/decode-decoding-attribute-async-large-image.html	                        (rev 0)
+++ trunk/LayoutTests/fast/images/decode-decoding-attribute-async-large-image.html	2017-12-07 03:36:03 UTC (rev 225616)
@@ -0,0 +1,20 @@
+<body>
+    <p>This test ensures if the src of an image with decoding="async" is set to the src of a decoded image, no further decoding will be requested.</p>
+    <img decoding="async">
+    <script>
+        (function() {
+            if (window.internals && window.testRunner) {
+                internals.clearMemoryCache();
+                testRunner.waitUntilDone();
+            }
+
+            var image = new Image;
+            image.src = ""
+            image.decode().then(() => {
+                document.querySelector("img").src = ""
+                if (window.testRunner)
+                    testRunner.notifyDone();
+            });
+        })();
+    </script>
+</body>

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


--- trunk/LayoutTests/fast/images/decoding-attribute-async-small-image-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/images/decoding-attribute-async-small-image-expected.html	2017-12-07 03:36:03 UTC (rev 225616)
@@ -0,0 +1,4 @@
+<body>
+    <p>This test ensures an image with decoding="async" will be decoded asynchronously regardless of its size.</p>
+    <img src=""
+</body>

Copied: trunk/LayoutTests/fast/images/decoding-attribute-async-small-image.html (from rev 225615, trunk/LayoutTests/fast/images/async-attribute-with-small-image.html) (0 => 225616)


--- trunk/LayoutTests/fast/images/decoding-attribute-async-small-image.html	                        (rev 0)
+++ trunk/LayoutTests/fast/images/decoding-attribute-async-small-image.html	2017-12-07 03:36:03 UTC (rev 225616)
@@ -0,0 +1,39 @@
+<body>
+    <p>This test ensures an image with decoding="async" will be decoded asynchronously regardless of its size.</p>
+    <img decoding="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>

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


--- trunk/LayoutTests/fast/images/decoding-attribute-dynamic-async-small-image-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/images/decoding-attribute-dynamic-async-small-image-expected.html	2017-12-07 03:36:03 UTC (rev 225616)
@@ -0,0 +1,4 @@
+<body>
+	<p>This test ensures if the decoding attribute of an image is set dynamically to "async", the image will be decoded asynchronously regardless of its size.</p>
+    <img src=""
+</body>

Copied: trunk/LayoutTests/fast/images/decoding-attribute-dynamic-async-small-image.html (from rev 225615, trunk/LayoutTests/fast/images/async-attribute-with-small-image.html) (0 => 225616)


--- trunk/LayoutTests/fast/images/decoding-attribute-dynamic-async-small-image.html	                        (rev 0)
+++ trunk/LayoutTests/fast/images/decoding-attribute-dynamic-async-small-image.html	2017-12-07 03:36:03 UTC (rev 225616)
@@ -0,0 +1,40 @@
+<body>
+    <p>This test ensures if the decoding attribute of an image is set dynamically to "async", the image will be decoded asynchronously regardless of its size.</p>
+    <img decoding="sync">
+    <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");
+            image.decoding="async";
+            loadImage(image, "resources/green-24x24.jpg", true).then(() => {
+                if (window.testRunner)
+                    testRunner.notifyDone();
+            });
+        })();
+    </script>
+</body>

Added: trunk/LayoutTests/fast/images/decoding-attribute-sync-large-image-expected.html (0 => 225616)


--- trunk/LayoutTests/fast/images/decoding-attribute-sync-large-image-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/images/decoding-attribute-sync-large-image-expected.html	2017-12-07 03:36:03 UTC (rev 225616)
@@ -0,0 +1,4 @@
+<body>
+	<p>This test ensures an image with decoding="sync" will be decoded synchronously regardless of its size.</p>
+    <img src=""
+</body>

Added: trunk/LayoutTests/fast/images/decoding-attribute-sync-large-image.html (0 => 225616)


--- trunk/LayoutTests/fast/images/decoding-attribute-sync-large-image.html	                        (rev 0)
+++ trunk/LayoutTests/fast/images/decoding-attribute-sync-large-image.html	2017-12-07 03:36:03 UTC (rev 225616)
@@ -0,0 +1,20 @@
+<body>
+    <p>This test ensures an image with decoding="sync" will be decoded synchronously regardless of its size.</p>
+    <img decoding="sync">
+    <script>
+        (function() {
+            if (window.internals && window.testRunner) {
+                internals.clearMemoryCache();
+                internals.settings.setLargeImageAsyncDecodingEnabled(true);
+                testRunner.waitUntilDone();
+            }
+
+            var image = document.querySelector("img");
+            image._onload_ = (() => {
+                if (window.testRunner)
+                    testRunner.notifyDone();
+            });
+            image.src = ""
+        })();
+    </script>
+</body>

Modified: trunk/Source/WebCore/ChangeLog (225615 => 225616)


--- trunk/Source/WebCore/ChangeLog	2017-12-07 03:30:08 UTC (rev 225615)
+++ trunk/Source/WebCore/ChangeLog	2017-12-07 03:36:03 UTC (rev 225616)
@@ -1,3 +1,51 @@
+2017-12-06  Said Abou-Hallawa  <[email protected]>
+
+        Support the decoding="sync/async" syntax for image async attribute
+        https://bugs.webkit.org/show_bug.cgi?id=179432
+
+        Reviewed by Darin Adler.
+
+        Support the HTMLElementImage decoding attribute to allow controlling the
+        decoding of an image as per:
+                https://github.com/whatwg/html/pull/3221
+                https://whatpr.org/html/3221/images.html#decoding-images
+
+        Tests: fast/images/decode-decoding-attribute-async-large-image.html
+               fast/images/decoding-attribute-async-small-image.html
+               fast/images/decoding-attribute-dynamic-async-small-image.html
+               fast/images/decoding-attribute-sync-large-image.html
+
+        * html/HTMLAttributeNames.in:
+        * html/HTMLImageElement.cpp:
+        (WebCore::HTMLImageElement::decodingMode const):
+        * html/HTMLImageElement.h:
+        * html/HTMLImageElement.idl:
+        * platform/graphics/BitmapImage.cpp:
+        (WebCore::BitmapImage::draw):
+        (WebCore::BitmapImage::internalStartAnimation):
+        (WebCore::BitmapImage::advanceAnimation):
+        (WebCore::BitmapImage::internalAdvanceAnimation):
+        * platform/graphics/DecodingOptions.h:
+        (WebCore::DecodingOptions::DecodingOptions):
+        (WebCore::DecodingOptions::isAuto const):
+        (WebCore::DecodingOptions::isAsynchronousCompatibleWith const):
+        (WebCore::DecodingOptions::isNone const): Deleted.
+        * platform/graphics/ImageDecoder.h:
+        * platform/graphics/ImageFrame.cpp:
+        (WebCore::ImageFrame::clearImage):
+        * platform/graphics/ImageSource.cpp:
+        (WebCore::ImageSource::frameAtIndexCacheIfNeeded):
+        * platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.h:
+        * platform/graphics/cg/ImageDecoderCG.h:
+        * platform/graphics/win/ImageDecoderDirect2D.h:
+        * platform/image-decoders/ScalableImageDecoder.h:
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::decodingModeForImageDraw const):
+        The element attributes and the document settings should be checked before
+        checking our heuristics. And since the "decoding" attribute is per an image
+        and isLargeImageAsyncDecodingEnabledForTesting() is a global setting, the
+        decoding attribute should be checked first.
+
 2017-12-06  David Quesada  <[email protected]>
 
         [Web App Manifest] Add SPI for applying a manifest to a top-level browsing context

Modified: trunk/Source/WebCore/html/HTMLAttributeNames.in (225615 => 225616)


--- trunk/Source/WebCore/html/HTMLAttributeNames.in	2017-12-07 03:30:08 UTC (rev 225615)
+++ trunk/Source/WebCore/html/HTMLAttributeNames.in	2017-12-07 03:36:03 UTC (rev 225616)
@@ -105,6 +105,7 @@
 data
 datetime
 declare
+decoding
 default
 defer
 dir

Modified: trunk/Source/WebCore/html/HTMLImageElement.cpp (225615 => 225616)


--- trunk/Source/WebCore/html/HTMLImageElement.cpp	2017-12-07 03:30:08 UTC (rev 225615)
+++ trunk/Source/WebCore/html/HTMLImageElement.cpp	2017-12-07 03:36:03 UTC (rev 225616)
@@ -538,6 +538,16 @@
     return m_imageLoader.imageComplete();
 }
 
+DecodingMode HTMLImageElement::decodingMode() const
+{
+    const AtomicString& decodingMode = attributeWithoutSynchronization(decodingAttr);
+    if (equalLettersIgnoringASCIICase(decodingMode, "sync"))
+        return DecodingMode::Synchronous;
+    if (equalLettersIgnoringASCIICase(decodingMode, "async"))
+        return DecodingMode::Asynchronous;
+    return DecodingMode::Auto;
+}
+    
 void HTMLImageElement::decode(Ref<DeferredPromise>&& promise)
 {
     return m_imageLoader.decode(WTFMove(promise));

Modified: trunk/Source/WebCore/html/HTMLImageElement.h (225615 => 225616)


--- trunk/Source/WebCore/html/HTMLImageElement.h	2017-12-07 03:30:08 UTC (rev 225615)
+++ trunk/Source/WebCore/html/HTMLImageElement.h	2017-12-07 03:36:03 UTC (rev 225616)
@@ -23,6 +23,7 @@
 
 #pragma once
 
+#include "DecodingOptions.h"
 #include "FormNamedItem.h"
 #include "GraphicsTypes.h"
 #include "HTMLElement.h"
@@ -79,6 +80,8 @@
 
     WEBCORE_EXPORT bool complete() const;
 
+    DecodingMode decodingMode() const;
+    
     WEBCORE_EXPORT void decode(Ref<DeferredPromise>&&);
 
 #if PLATFORM(IOS)

Modified: trunk/Source/WebCore/html/HTMLImageElement.idl (225615 => 225616)


--- trunk/Source/WebCore/html/HTMLImageElement.idl	2017-12-07 03:30:08 UTC (rev 225615)
+++ trunk/Source/WebCore/html/HTMLImageElement.idl	2017-12-07 03:36:03 UTC (rev 225616)
@@ -40,7 +40,7 @@
     [Reflect] attribute DOMString useMap;
     [Reflect] attribute unsigned long vspace;
     attribute unsigned long width;
-    [Reflect] attribute boolean async;
+    [Reflect] attribute DOMString decoding;
 
     // Extensions
     readonly attribute boolean complete;

Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.cpp (225615 => 225616)


--- trunk/Source/WebCore/platform/graphics/BitmapImage.cpp	2017-12-07 03:30:08 UTC (rev 225615)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.cpp	2017-12-07 03:36:03 UTC (rev 225616)
@@ -218,7 +218,7 @@
         if (m_currentFrameDecodingStatus == DecodingStatus::Decoding)
             result = ImageDrawResult::DidRequestDecoding;
 
-        if (!frameHasDecodedNativeImageCompatibleWithOptionsAtIndex(m_currentFrame, m_currentSubsamplingLevel, DecodingMode::Asynchronous)) {
+        if (!frameHasDecodedNativeImageCompatibleWithOptionsAtIndex(m_currentFrame, m_currentSubsamplingLevel, DecodingOptions(DecodingMode::Asynchronous))) {
             if (m_showDebugBackground)
                 fillWithSolidColor(context, destRect, Color(Color::yellow).colorWithAlpha(0.5), op);
             return result;
@@ -241,7 +241,7 @@
             m_source->destroyIncompleteDecodedData();
         
         bool frameIsCompatible = frameHasDecodedNativeImageCompatibleWithOptionsAtIndex(m_currentFrame, m_currentSubsamplingLevel, DecodingOptions(sizeForDrawing));
-        bool frameIsBeingDecoded = frameIsBeingDecodedAndIsCompatibleWithOptionsAtIndex(m_currentFrame, DecodingMode::Asynchronous);
+        bool frameIsBeingDecoded = frameIsBeingDecodedAndIsCompatibleWithOptionsAtIndex(m_currentFrame, DecodingOptions(DecodingMode::Asynchronous));
         
         if (frameIsCompatible) {
             image = frameImageAtIndex(m_currentFrame);
@@ -394,7 +394,7 @@
 
     // Don't start a new animation until we draw the frame that is currently being decoded.
     size_t nextFrame = (m_currentFrame + 1) % frameCount();
-    if (frameIsBeingDecodedAndIsCompatibleWithOptionsAtIndex(nextFrame, DecodingMode::Asynchronous)) {
+    if (frameIsBeingDecodedAndIsCompatibleWithOptionsAtIndex(nextFrame, DecodingOptions(DecodingMode::Asynchronous))) {
         LOG(Images, "BitmapImage::%s - %p - url: %s [nextFrame = %ld is being decoded]", __FUNCTION__, this, sourceURL().string().utf8().data(), nextFrame);
         return StartAnimationStatus::DecodingActive;
     }
@@ -437,7 +437,7 @@
     // through the callback newFrameNativeImageAvailableAtIndex(). Otherwise, advanceAnimation() will be called
     // when the timer fires and m_currentFrame will be advanced to nextFrame since it is not being decoded.
     if (shouldUseAsyncDecodingForAnimatedImages()) {
-        if (frameHasDecodedNativeImageCompatibleWithOptionsAtIndex(nextFrame, m_currentSubsamplingLevel, { }))
+        if (frameHasDecodedNativeImageCompatibleWithOptionsAtIndex(nextFrame, m_currentSubsamplingLevel, DecodingOptions(std::optional<IntSize>())))
             LOG(Images, "BitmapImage::%s - %p - url: %s [cachedFrameCount = %ld nextFrame = %ld]", __FUNCTION__, this, sourceURL().string().utf8().data(), ++m_cachedFrameCount, nextFrame);
         else {
             m_source->requestFrameAsyncDecodingAtIndex(nextFrame, m_currentSubsamplingLevel);
@@ -472,7 +472,7 @@
 
     // Don't advance to nextFrame unless its decoding has finished or was not required.
     size_t nextFrame = (m_currentFrame + 1) % frameCount();
-    if (!frameIsBeingDecodedAndIsCompatibleWithOptionsAtIndex(nextFrame, DecodingMode::Asynchronous))
+    if (!frameIsBeingDecodedAndIsCompatibleWithOptionsAtIndex(nextFrame, DecodingOptions(DecodingMode::Asynchronous)))
         internalAdvanceAnimation();
     else {
         // Force repaint if showDebugBackground() is on.
@@ -485,7 +485,7 @@
 void BitmapImage::internalAdvanceAnimation()
 {
     m_currentFrame = (m_currentFrame + 1) % frameCount();
-    ASSERT(!frameIsBeingDecodedAndIsCompatibleWithOptionsAtIndex(m_currentFrame, DecodingMode::Asynchronous));
+    ASSERT(!frameIsBeingDecodedAndIsCompatibleWithOptionsAtIndex(m_currentFrame, DecodingOptions(DecodingMode::Asynchronous)));
 
     destroyDecodedDataIfNecessary(false);
 

Modified: trunk/Source/WebCore/platform/graphics/DecodingOptions.h (225615 => 225616)


--- trunk/Source/WebCore/platform/graphics/DecodingOptions.h	2017-12-07 03:30:08 UTC (rev 225615)
+++ trunk/Source/WebCore/platform/graphics/DecodingOptions.h	2017-12-07 03:36:03 UTC (rev 225616)
@@ -32,7 +32,7 @@
 namespace WebCore {
 
 enum class DecodingMode {
-    None,
+    Auto,
     Synchronous,
     Asynchronous
 };
@@ -39,7 +39,7 @@
 
 class DecodingOptions {
 public:
-    DecodingOptions(DecodingMode decodingMode = DecodingMode::None)
+    explicit DecodingOptions(DecodingMode decodingMode = DecodingMode::Auto)
         : m_decodingModeOrSize(decodingMode)
     {
     }
@@ -54,9 +54,9 @@
         return m_decodingModeOrSize == other.m_decodingModeOrSize;
     }
 
-    bool isNone() const
+    bool isAuto() const
     {
-        return hasDecodingMode() && WTF::get<DecodingMode>(m_decodingModeOrSize) == DecodingMode::None;
+        return hasDecodingMode() && WTF::get<DecodingMode>(m_decodingModeOrSize) == DecodingMode::Auto;
     }
     
     bool isSynchronous() const
@@ -71,7 +71,7 @@
 
     bool isAsynchronousCompatibleWith(const DecodingOptions& decodingOptions) const
     {
-        if (isNone() || decodingOptions.isNone())
+        if (isAuto() || decodingOptions.isAuto())
             return false;
 
         // Comparing DecodingOptions with isAsynchronous() should not happen.

Modified: trunk/Source/WebCore/platform/graphics/ImageDecoder.h (225615 => 225616)


--- trunk/Source/WebCore/platform/graphics/ImageDecoder.h	2017-12-07 03:30:08 UTC (rev 225615)
+++ trunk/Source/WebCore/platform/graphics/ImageDecoder.h	2017-12-07 03:36:03 UTC (rev 225616)
@@ -72,7 +72,7 @@
     virtual bool frameAllowSubsamplingAtIndex(size_t) const = 0;
     virtual unsigned frameBytesAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const = 0;
 
-    virtual NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingMode::Synchronous) = 0;
+    virtual NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) = 0;
 
     virtual void setExpectedContentSize(long long) { }
     virtual void setData(SharedBuffer&, bool allDataReceived) = 0;

Modified: trunk/Source/WebCore/platform/graphics/ImageFrame.cpp (225615 => 225616)


--- trunk/Source/WebCore/platform/graphics/ImageFrame.cpp	2017-12-07 03:30:08 UTC (rev 225615)
+++ trunk/Source/WebCore/platform/graphics/ImageFrame.cpp	2017-12-07 03:36:03 UTC (rev 225616)
@@ -97,7 +97,7 @@
 
     clearNativeImageSubimages(m_nativeImage);
     m_nativeImage = nullptr;
-    m_decodingOptions = { };
+    m_decodingOptions = DecodingOptions();
 
     return frameBytes;
 }

Modified: trunk/Source/WebCore/platform/graphics/ImageSource.cpp (225615 => 225616)


--- trunk/Source/WebCore/platform/graphics/ImageSource.cpp	2017-12-07 03:30:08 UTC (rev 225615)
+++ trunk/Source/WebCore/platform/graphics/ImageSource.cpp	2017-12-07 03:36:03 UTC (rev 225616)
@@ -27,23 +27,14 @@
 #include "ImageSource.h"
 
 #include "Image.h"
+#include "ImageDecoder.h"
 #include "ImageObserver.h"
 #include "Logging.h"
 #include "URL.h"
-#include <wtf/SystemTracing.h>
-
-#if USE(CG)
-#include "ImageDecoderCG.h"
-#elif USE(DIRECT2D)
-#include "ImageDecoderDirect2D.h"
-#include <WinCodec.h>
-#else
-#include "ImageDecoder.h"
-#endif
-
 #include <wtf/CheckedArithmetic.h>
 #include <wtf/MainThread.h>
 #include <wtf/RunLoop.h>
+#include <wtf/SystemTracing.h>
 
 namespace WebCore {
 
@@ -406,7 +397,7 @@
 {
     ASSERT(index < m_frames.size());
     ImageFrame& frame = m_frames[index];
-    if (!isDecoderAvailable() || frameIsBeingDecodedAndIsCompatibleWithOptionsAtIndex(index, DecodingMode::Asynchronous))
+    if (!isDecoderAvailable() || frameIsBeingDecodedAndIsCompatibleWithOptionsAtIndex(index, DecodingOptions(DecodingMode::Asynchronous)))
         return frame;
 
     SubsamplingLevel subsamplingLevelValue = subsamplingLevel ? subsamplingLevel.value() : frame.subsamplingLevel();
@@ -426,7 +417,7 @@
         // We have to perform synchronous image decoding in this code.
         NativeImagePtr nativeImage = m_decoder->createFrameImageAtIndex(index, subsamplingLevelValue);
         // Clean the old native image and set a new one.
-        cacheNativeImageAtIndex(WTFMove(nativeImage), index, subsamplingLevelValue, DecodingMode::Synchronous);
+        cacheNativeImageAtIndex(WTFMove(nativeImage), index, subsamplingLevelValue, DecodingOptions(DecodingMode::Synchronous));
         break;
     }
 

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.h (225615 => 225616)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.h	2017-12-07 03:30:08 UTC (rev 225615)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.h	2017-12-07 03:36:03 UTC (rev 225616)
@@ -82,7 +82,7 @@
     bool frameAllowSubsamplingAtIndex(size_t) const final;
     unsigned frameBytesAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const final;
 
-    NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingMode::Synchronous) final;
+    NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) final;
 
     void setExpectedContentSize(long long) final;
     void setData(SharedBuffer&, bool allDataReceived) final;

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h (225615 => 225616)


--- trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h	2017-12-07 03:30:08 UTC (rev 225615)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h	2017-12-07 03:36:03 UTC (rev 225616)
@@ -60,7 +60,7 @@
     bool frameAllowSubsamplingAtIndex(size_t) const final;
     unsigned frameBytesAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const final;
 
-    NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingMode::Synchronous) final;
+    NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) final;
 
     void setData(SharedBuffer&, bool allDataReceived) final;
     bool isAllDataReceived() const final { return m_isAllDataReceived; }

Modified: trunk/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.h (225615 => 225616)


--- trunk/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.h	2017-12-07 03:30:08 UTC (rev 225615)
+++ trunk/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.h	2017-12-07 03:36:03 UTC (rev 225616)
@@ -71,7 +71,7 @@
     bool frameAllowSubsamplingAtIndex(size_t) const final;
     unsigned frameBytesAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const final;
 
-    NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingMode::Synchronous) const final;
+    NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) const final;
 
     void setData(SharedBuffer&, bool allDataReceived) final;
     bool isAllDataReceived() const final { return m_isAllDataReceived; }

Modified: trunk/Source/WebCore/platform/image-decoders/ScalableImageDecoder.h (225615 => 225616)


--- trunk/Source/WebCore/platform/image-decoders/ScalableImageDecoder.h	2017-12-07 03:30:08 UTC (rev 225615)
+++ trunk/Source/WebCore/platform/image-decoders/ScalableImageDecoder.h	2017-12-07 03:36:03 UTC (rev 225616)
@@ -146,7 +146,7 @@
 
     Seconds frameDurationAtIndex(size_t) const final;
 
-    NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingMode::Synchronous) override;
+    NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) override;
 
     void setIgnoreGammaAndColorProfile(bool flag) { m_ignoreGammaAndColorProfile = flag; }
     bool ignoresGammaAndColorProfile() const { return m_ignoreGammaAndColorProfile; }

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (225615 => 225616)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2017-12-07 03:30:08 UTC (rev 225615)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2017-12-07 03:36:03 UTC (rev 225616)
@@ -374,10 +374,13 @@
     if (IOSApplication::isIBooksStorytime())
         return DecodingMode::Synchronous;
 #endif
+    if (is<HTMLImageElement>(element())) {
+        auto decodingMode = downcast<HTMLImageElement>(*element()).decodingMode();
+        if (decodingMode != DecodingMode::Auto)
+            return decodingMode;
+    }
     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