Title: [258817] trunk
Revision
258817
Author
[email protected]
Date
2020-03-21 22:02:55 -0700 (Sat, 21 Mar 2020)

Log Message

An animated PNG plays the frames one time more than the image loopCount
https://bugs.webkit.org/show_bug.cgi?id=205640

Patch by Said Abou-Hallawa <[email protected]> on 2020-03-21
Reviewed by Darin Adler.

Source/WebCore:

Make the repetitionCount calculation for GIFs different from it for other
image formats.

Tests: fast/images/animated-gif-loop-count.html
       fast/images/animated-png-loop-count.html

* platform/graphics/cg/ImageDecoderCG.cpp:
(WebCore::ImageDecoderCG::repetitionCount const):
* platform/graphics/cg/UTIRegistry.cpp:
(WebCore::isGIFImageType):
* platform/graphics/cg/UTIRegistry.h:

LayoutTests:

Refactor the js code to a separate js file. Add two layout tests: one for
animated GIFs and the other for animated PNGs.

* fast/images/animated-gif-loop-count-expected.html: Added.
* fast/images/animated-gif-loop-count.html: Added.
* fast/images/animated-image-loop-count-expected.html: Removed.
* fast/images/animated-image-loop-count.html: Removed.
* fast/images/animated-png-loop-count-expected.html: Added.
* fast/images/animated-png-loop-count.html: Added.
* fast/images/resources/animated-image-loop-count.js: Added.
* fast/images/resources/animated-red-green-blue-repeat-1.png: Added.
* fast/images/resources/animated-red-green-blue-repeat-2.png: Added.
* fast/images/resources/animated-red-green-blue-repeat-infinite.png: Added.
* platform/ios/TestExpectations:
* platform/mac-wk1/TestExpectations:
* platform/win/TestExpectations:

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (258816 => 258817)


--- trunk/LayoutTests/ChangeLog	2020-03-22 04:59:05 UTC (rev 258816)
+++ trunk/LayoutTests/ChangeLog	2020-03-22 05:02:55 UTC (rev 258817)
@@ -1,3 +1,27 @@
+2020-03-21  Said Abou-Hallawa  <[email protected]>
+
+        An animated PNG plays the frames one time more than the image loopCount
+        https://bugs.webkit.org/show_bug.cgi?id=205640
+
+        Reviewed by Darin Adler.
+
+        Refactor the js code to a separate js file. Add two layout tests: one for
+        animated GIFs and the other for animated PNGs.
+
+        * fast/images/animated-gif-loop-count-expected.html: Added.
+        * fast/images/animated-gif-loop-count.html: Added.
+        * fast/images/animated-image-loop-count-expected.html: Removed.
+        * fast/images/animated-image-loop-count.html: Removed.
+        * fast/images/animated-png-loop-count-expected.html: Added.
+        * fast/images/animated-png-loop-count.html: Added.
+        * fast/images/resources/animated-image-loop-count.js: Added.
+        * fast/images/resources/animated-red-green-blue-repeat-1.png: Added.
+        * fast/images/resources/animated-red-green-blue-repeat-2.png: Added.
+        * fast/images/resources/animated-red-green-blue-repeat-infinite.png: Added.
+        * platform/ios/TestExpectations:
+        * platform/mac-wk1/TestExpectations:
+        * platform/win/TestExpectations:
+
 2020-03-21  Jack Lee  <[email protected]>
 
         Nullptr crash in RenderObject::RenderObjectBitfields::isBox when current renderer is the RenderView

Copied: trunk/LayoutTests/fast/images/animated-gif-loop-count-expected.html (from rev 258816, trunk/LayoutTests/fast/images/animated-image-loop-count-expected.html) (0 => 258817)


--- trunk/LayoutTests/fast/images/animated-gif-loop-count-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/images/animated-gif-loop-count-expected.html	2020-03-22 05:02:55 UTC (rev 258817)
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<style>
+    .box {
+        width: 100px;
+        height: 100px;
+        display: inline-block;
+    } 
+</style>    
+<body>
+    <div>
+        <p>Frames of a 3-frame animated image with missing loopCount, (repetitionCount = 1):</p>
+        <div class="box" style="background-color: red;"></div>
+        <div class="box" style="background-color: green;"></div>
+        <div class="box" style="background-color: blue;"></div>
+        <div class="box" style="background-color: blue;"></div>
+    </div>
+    <div>
+        <p>Frames of a 3-frame animated image with loopCount = 1, (repetitionCount = 2):</p>
+        <div class="box" style="background-color: red;"></div>
+        <div class="box" style="background-color: green;"></div>
+        <div class="box" style="background-color: blue;"></div>
+        <div class="box" style="background-color: red;"></div>
+        <div class="box" style="background-color: green;"></div>
+        <div class="box" style="background-color: blue;"></div>
+        <div class="box" style="background-color: blue;"></div>
+    </div>
+    <div>
+        <p>Frames of a 3-frame animated image with loopCount = 0, (repetitionCount = infinite):</p>
+        <div class="box" style="background-color: red;"></div>
+        <div class="box" style="background-color: green;"></div>
+        <div class="box" style="background-color: blue;"></div>
+        <div class="box" style="background-color: red;"></div>
+        <div class="box" style="background-color: green;"></div>
+        <div class="box" style="background-color: blue;"></div>
+        <div class="box" style="background-color: red;"></div>
+    </div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/images/animated-gif-loop-count.html (0 => 258817)


--- trunk/LayoutTests/fast/images/animated-gif-loop-count.html	                        (rev 0)
+++ trunk/LayoutTests/fast/images/animated-gif-loop-count.html	2020-03-22 05:02:55 UTC (rev 258817)
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html>
+<style>
+    canvas {
+        width: 100px;
+        height: 100px;
+    }
+</style>
+<script src=""
+<body>
+    <div>
+        <p>Frames of a 3-frame animated image with missing loopCount, (repetitionCount = 1):</p>
+        <canvas id="canvas-1"></canvas>
+        <canvas id="canvas-2"></canvas>
+        <canvas id="canvas-3"></canvas>
+        <canvas id="canvas-4"></canvas>
+    </div>
+    <div>
+        <p>Frames of a 3-frame animated image with loopCount = 1, (repetitionCount = 2):</p>
+        <canvas id="canvas-a"></canvas>
+        <canvas id="canvas-b"></canvas>
+        <canvas id="canvas-c"></canvas>
+        <canvas id="canvas-d"></canvas>
+        <canvas id="canvas-e"></canvas>
+        <canvas id="canvas-f"></canvas>
+        <canvas id="canvas-g"></canvas>
+    </div>
+    <div>
+        <p>Frames of a 3-frame animated image with loopCount = 0, (repetitionCount = infinite):</p>
+        <canvas id="canvas-A"></canvas>
+        <canvas id="canvas-B"></canvas>
+        <canvas id="canvas-C"></canvas>
+        <canvas id="canvas-D"></canvas>
+        <canvas id="canvas-E"></canvas>
+        <canvas id="canvas-F"></canvas>
+        <canvas id="canvas-G"></canvas>
+    </div>
+    <script>
+        (function() {
+            var images = [
+                { src: "resources/animated-red-green-blue-repeat-1.gif", canvasId: '1', frameCount: 4 },
+                { src: "resources/animated-red-green-blue-repeat-2.gif", canvasId: 'a', frameCount: 7 },
+                { src: "resources/animated-red-green-blue-repeat-infinite.gif", canvasId: 'A', frameCount: 7 }
+            ];
+            runTest(images);
+        })();
+    </script>
+</body>
+</html>

Deleted: trunk/LayoutTests/fast/images/animated-image-loop-count-expected.html (258816 => 258817)


--- trunk/LayoutTests/fast/images/animated-image-loop-count-expected.html	2020-03-22 04:59:05 UTC (rev 258816)
+++ trunk/LayoutTests/fast/images/animated-image-loop-count-expected.html	2020-03-22 05:02:55 UTC (rev 258817)
@@ -1,39 +0,0 @@
-<!DOCTYPE html>
-<html>
-<style>
-    .box {
-        width: 100px;
-        height: 100px;
-        display: inline-block;
-    } 
-</style>    
-<body>
-    <div>
-        <p>Frames of a 3-frame animated image with missing loopCount, (repetitionCount = 1):</p>
-        <div class="box" style="background-color: red;"></div>
-        <div class="box" style="background-color: green;"></div>
-        <div class="box" style="background-color: blue;"></div>
-        <div class="box" style="background-color: blue;"></div>
-    </div>
-    <div>
-        <p>Frames of a 3-frame animated image with loopCount = 1, (repetitionCount = 2):</p>
-        <div class="box" style="background-color: red;"></div>
-        <div class="box" style="background-color: green;"></div>
-        <div class="box" style="background-color: blue;"></div>
-        <div class="box" style="background-color: red;"></div>
-        <div class="box" style="background-color: green;"></div>
-        <div class="box" style="background-color: blue;"></div>
-        <div class="box" style="background-color: blue;"></div>
-    </div>
-    <div>
-        <p>Frames of a 3-frame animated image with loopCount = 0, (repetitionCount = infinite):</p>
-        <div class="box" style="background-color: red;"></div>
-        <div class="box" style="background-color: green;"></div>
-        <div class="box" style="background-color: blue;"></div>
-        <div class="box" style="background-color: red;"></div>
-        <div class="box" style="background-color: green;"></div>
-        <div class="box" style="background-color: blue;"></div>
-        <div class="box" style="background-color: red;"></div>
-    </div>
-</body>
-</html>

Deleted: trunk/LayoutTests/fast/images/animated-image-loop-count.html (258816 => 258817)


--- trunk/LayoutTests/fast/images/animated-image-loop-count.html	2020-03-22 04:59:05 UTC (rev 258816)
+++ trunk/LayoutTests/fast/images/animated-image-loop-count.html	2020-03-22 05:02:55 UTC (rev 258817)
@@ -1,96 +0,0 @@
-<!DOCTYPE html>
-<html>
-<style>
-    canvas {
-        width: 100px;
-        height: 100px;
-    }
-</style>    
-<body>
-    <div>
-        <p>Frames of a 3-frame animated image with missing loopCount, (repetitionCount = 1):</p>
-        <canvas id="canvas-1"></canvas>
-        <canvas id="canvas-2"></canvas>
-        <canvas id="canvas-3"></canvas>
-        <canvas id="canvas-4"></canvas>
-    </div>
-    <div>
-        <p>Frames of a 3-frame animated image with loopCount = 1, (repetitionCount = 2):</p>
-        <canvas id="canvas-a"></canvas>
-        <canvas id="canvas-b"></canvas>
-        <canvas id="canvas-c"></canvas>
-        <canvas id="canvas-d"></canvas>
-        <canvas id="canvas-e"></canvas>
-        <canvas id="canvas-f"></canvas>
-        <canvas id="canvas-g"></canvas>
-    </div>
-    <div>
-        <p>Frames of a 3-frame animated image with loopCount = 0, (repetitionCount = infinite):</p>
-        <canvas id="canvas-A"></canvas>
-        <canvas id="canvas-B"></canvas>
-        <canvas id="canvas-C"></canvas>
-        <canvas id="canvas-D"></canvas>
-        <canvas id="canvas-E"></canvas>
-        <canvas id="canvas-F"></canvas>
-        <canvas id="canvas-G"></canvas>
-    </div>
-    <script>
-        function drawFrame(image, canvasId) {
-            return new Promise((resolve) => {
-                let canvas = document.getElementById("canvas-" + canvasId);
-                let context = canvas.getContext("2d");
-                context.drawImage(image, 0, 0, canvas.width, canvas.height);
-                setTimeout(() => {
-                    resolve(String.fromCharCode(canvasId.charCodeAt() + 1));
-                }, 30);
-            });
-        }
-
-        function drawImage(image, canvasId, frameCount) {
-            let promise = drawFrame(image, canvasId);
-            for (let frame = 1; frame < frameCount; ++frame) {
-                promise = promise.then((canvasId) => {
-                    return drawFrame(image, canvasId);
-                });
-            }
-            return promise;
-        }
-
-        function loadImage(src, canvasId, frameCount) {
-            return new Promise((resolve) => {
-                let image = new Image;
-                image._onload_ = (() => {
-                    drawImage(image, canvasId, frameCount).then(resolve);
-                });
-                image.src = ""
-            });
-        }
-
-        (function() {
-            if (window.internals) {
-                internals.clearMemoryCache();
-                internals.settings.setAnimatedImageDebugCanvasDrawingEnabled(true);
-            }
-
-            if (window.testRunner)
-                testRunner.waitUntilDone();
-
-            var images = [
-                { src: "resources/animated-red-green-blue-repeat-1.gif", canvasId: '1', frameCount: 4 },
-                { src: "resources/animated-red-green-blue-repeat-2.gif", canvasId: 'a', frameCount: 7 },
-                { src: "resources/animated-red-green-blue-repeat-infinite.gif", canvasId: 'A', frameCount: 7 }
-            ];
-
-            var promises = [];
-
-            for (let image of images)
-                promises.push(loadImage(image.src, image.canvasId, image.frameCount));
-            
-            Promise.all(promises).then(() => {
-                if (window.testRunner)
-                    testRunner.notifyDone();
-            });
-        })();
-    </script>
-</body>
-</html>

Copied: trunk/LayoutTests/fast/images/animated-png-loop-count-expected.html (from rev 258816, trunk/LayoutTests/fast/images/animated-image-loop-count-expected.html) (0 => 258817)


--- trunk/LayoutTests/fast/images/animated-png-loop-count-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/images/animated-png-loop-count-expected.html	2020-03-22 05:02:55 UTC (rev 258817)
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<style>
+    .box {
+        width: 100px;
+        height: 100px;
+        display: inline-block;
+    } 
+</style>    
+<body>
+    <div>
+        <p>Frames of a 3-frame animated image with missing loopCount, (repetitionCount = 1):</p>
+        <div class="box" style="background-color: red;"></div>
+        <div class="box" style="background-color: green;"></div>
+        <div class="box" style="background-color: blue;"></div>
+        <div class="box" style="background-color: blue;"></div>
+    </div>
+    <div>
+        <p>Frames of a 3-frame animated image with loopCount = 1, (repetitionCount = 2):</p>
+        <div class="box" style="background-color: red;"></div>
+        <div class="box" style="background-color: green;"></div>
+        <div class="box" style="background-color: blue;"></div>
+        <div class="box" style="background-color: red;"></div>
+        <div class="box" style="background-color: green;"></div>
+        <div class="box" style="background-color: blue;"></div>
+        <div class="box" style="background-color: blue;"></div>
+    </div>
+    <div>
+        <p>Frames of a 3-frame animated image with loopCount = 0, (repetitionCount = infinite):</p>
+        <div class="box" style="background-color: red;"></div>
+        <div class="box" style="background-color: green;"></div>
+        <div class="box" style="background-color: blue;"></div>
+        <div class="box" style="background-color: red;"></div>
+        <div class="box" style="background-color: green;"></div>
+        <div class="box" style="background-color: blue;"></div>
+        <div class="box" style="background-color: red;"></div>
+    </div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/images/animated-png-loop-count.html (0 => 258817)


--- trunk/LayoutTests/fast/images/animated-png-loop-count.html	                        (rev 0)
+++ trunk/LayoutTests/fast/images/animated-png-loop-count.html	2020-03-22 05:02:55 UTC (rev 258817)
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html>
+<style>
+    canvas {
+        width: 100px;
+        height: 100px;
+    }
+</style>
+<script src=""
+<body>
+    <div>
+        <p>Frames of a 3-frame animated image with missing loopCount, (repetitionCount = 1):</p>
+        <canvas id="canvas-1"></canvas>
+        <canvas id="canvas-2"></canvas>
+        <canvas id="canvas-3"></canvas>
+        <canvas id="canvas-4"></canvas>
+    </div>
+    <div>
+        <p>Frames of a 3-frame animated image with loopCount = 1, (repetitionCount = 2):</p>
+        <canvas id="canvas-a"></canvas>
+        <canvas id="canvas-b"></canvas>
+        <canvas id="canvas-c"></canvas>
+        <canvas id="canvas-d"></canvas>
+        <canvas id="canvas-e"></canvas>
+        <canvas id="canvas-f"></canvas>
+        <canvas id="canvas-g"></canvas>
+    </div>
+    <div>
+        <p>Frames of a 3-frame animated image with loopCount = 0, (repetitionCount = infinite):</p>
+        <canvas id="canvas-A"></canvas>
+        <canvas id="canvas-B"></canvas>
+        <canvas id="canvas-C"></canvas>
+        <canvas id="canvas-D"></canvas>
+        <canvas id="canvas-E"></canvas>
+        <canvas id="canvas-F"></canvas>
+        <canvas id="canvas-G"></canvas>
+    </div>
+    <script>
+        (function() {
+            var images = [
+                { src: "resources/animated-red-green-blue-repeat-1.png", canvasId: '1', frameCount: 4 },
+                { src: "resources/animated-red-green-blue-repeat-2.png", canvasId: 'a', frameCount: 7 },
+                { src: "resources/animated-red-green-blue-repeat-infinite.png", canvasId: 'A', frameCount: 7 }
+            ];
+            runTest(images);
+        })();
+    </script>
+</body>
+</html>

Added: trunk/LayoutTests/fast/images/resources/animated-image-loop-count.js (0 => 258817)


--- trunk/LayoutTests/fast/images/resources/animated-image-loop-count.js	                        (rev 0)
+++ trunk/LayoutTests/fast/images/resources/animated-image-loop-count.js	2020-03-22 05:02:55 UTC (rev 258817)
@@ -0,0 +1,50 @@
+function drawFrame(image, canvasId) {
+    return new Promise((resolve) => {
+        let canvas = document.getElementById("canvas-" + canvasId);
+        let context = canvas.getContext("2d");
+        context.drawImage(image, 0, 0, canvas.width, canvas.height);
+        setTimeout(() => {
+            resolve(String.fromCharCode(canvasId.charCodeAt() + 1));
+        }, 30);
+    });
+}
+
+function drawImage(image, canvasId, frameCount) {
+    let promise = drawFrame(image, canvasId);
+    for (let frame = 1; frame < frameCount; ++frame) {
+        promise = promise.then((canvasId) => {
+            return drawFrame(image, canvasId);
+        });
+    }
+    return promise;
+}
+
+function loadImage(src, canvasId, frameCount) {
+    return new Promise((resolve) => {
+        let image = new Image;
+        image._onload_ = (() => {
+            drawImage(image, canvasId, frameCount).then(resolve);
+        });
+        image.src = ""
+    });
+}
+
+function runTest(images) {
+    if (window.internals) {
+        internals.clearMemoryCache();
+        internals.settings.setAnimatedImageDebugCanvasDrawingEnabled(true);
+    }
+
+    if (window.testRunner)
+        testRunner.waitUntilDone();
+
+    var promises = [];
+
+    for (let image of images)
+        promises.push(loadImage(image.src, image.canvasId, image.frameCount));
+            
+    Promise.all(promises).then(() => {
+        if (window.testRunner)
+            testRunner.notifyDone();
+    });
+}

Added: trunk/LayoutTests/fast/images/resources/animated-red-green-blue-repeat-1.png


(Binary files differ)
Index: trunk/LayoutTests/fast/images/resources/animated-red-green-blue-repeat-1.png =================================================================== --- trunk/LayoutTests/fast/images/resources/animated-red-green-blue-repeat-1.png 2020-03-22 04:59:05 UTC (rev 258816) +++ trunk/LayoutTests/fast/images/resources/animated-red-green-blue-repeat-1.png 2020-03-22 05:02:55 UTC (rev 258817) Property changes on: trunk/LayoutTests/fast/images/resources/animated-red-green-blue-repeat-1.png ___________________________________________________________________

Added: svn:mime-type

+image/png \ No newline at end of property

Added: trunk/LayoutTests/fast/images/resources/animated-red-green-blue-repeat-2.png


(Binary files differ)
Index: trunk/LayoutTests/fast/images/resources/animated-red-green-blue-repeat-2.png =================================================================== --- trunk/LayoutTests/fast/images/resources/animated-red-green-blue-repeat-2.png 2020-03-22 04:59:05 UTC (rev 258816) +++ trunk/LayoutTests/fast/images/resources/animated-red-green-blue-repeat-2.png 2020-03-22 05:02:55 UTC (rev 258817) Property changes on: trunk/LayoutTests/fast/images/resources/animated-red-green-blue-repeat-2.png ___________________________________________________________________

Added: svn:mime-type

+image/png \ No newline at end of property

Added: trunk/LayoutTests/fast/images/resources/animated-red-green-blue-repeat-infinite.png


(Binary files differ)
Index: trunk/LayoutTests/fast/images/resources/animated-red-green-blue-repeat-infinite.png =================================================================== --- trunk/LayoutTests/fast/images/resources/animated-red-green-blue-repeat-infinite.png 2020-03-22 04:59:05 UTC (rev 258816) +++ trunk/LayoutTests/fast/images/resources/animated-red-green-blue-repeat-infinite.png 2020-03-22 05:02:55 UTC (rev 258817) Property changes on: trunk/LayoutTests/fast/images/resources/animated-red-green-blue-repeat-infinite.png ___________________________________________________________________

Added: svn:mime-type

+image/png \ No newline at end of property

Modified: trunk/LayoutTests/platform/ios/TestExpectations (258816 => 258817)


--- trunk/LayoutTests/platform/ios/TestExpectations	2020-03-22 04:59:05 UTC (rev 258816)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2020-03-22 05:02:55 UTC (rev 258817)
@@ -2804,7 +2804,8 @@
 fast/images/slower-animation-than-decoding-image.html [ Failure ]
 fast/images/slower-decoding-than-animation-image.html [ Failure ]
 fast/images/reset-image-animation.html [ Failure ]
-fast/images/animated-image-loop-count.html [ ImageOnlyFailure ]
+fast/images/animated-gif-loop-count.html [ ImageOnlyFailure ]
+fast/images/animated-png-loop-count.html [ ImageOnlyFailure ]
 fast/images/animated-image-different-dest-size.html [ ImageOnlyFailure ]
 
 # <rdar://problem/32659595> iOS 11: LayoutTest fast/text/international/system-language/arabic-glyph-cache-fill-combine.html is failing

Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (258816 => 258817)


--- trunk/LayoutTests/platform/mac-wk1/TestExpectations	2020-03-22 04:59:05 UTC (rev 258816)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations	2020-03-22 05:02:55 UTC (rev 258817)
@@ -783,7 +783,8 @@
 
 webkit.org/b/186406 [ Mojave+ ] compositing/iframes/display-none-subframe.html [ Pass Failure ]
 
-webkit.org/b/190383 fast/images/animated-image-loop-count.html [ Pass ImageOnlyFailure ]
+webkit.org/b/190383 fast/images/animated-gif-loop-count.html [ Pass ImageOnlyFailure ]
+webkit.org/b/190383 fast/images/animated-png-loop-count.html [ Pass ImageOnlyFailure ]
 webkit.org/b/190383 fast/images/animated-image-different-dest-size.html [ Pass ImageOnlyFailure ]
 
 webkit.org/b/191639 imported/blink/compositing/squashing/squashing-into-ancestor-painted-layer.html [ Pass ImageOnlyFailure ]

Modified: trunk/LayoutTests/platform/win/TestExpectations (258816 => 258817)


--- trunk/LayoutTests/platform/win/TestExpectations	2020-03-22 04:59:05 UTC (rev 258816)
+++ trunk/LayoutTests/platform/win/TestExpectations	2020-03-22 05:02:55 UTC (rev 258817)
@@ -412,7 +412,7 @@
 # Pre-HMTL5 parser quirks only apply to the mac port for now.
 fast/parser/pre-html5-parser-quirks.html [ Skip ]
 
-# Requires WebP support.
+# Requires APNG and WebP support.
 fast/canvas/canvas-toDataURL-webp.html [ Skip ]
 fast/images/webp-image-decoding.html [ Skip ]
 fast/images/webp-color-profile-lossless.html [ Skip ]
@@ -421,6 +421,7 @@
 http/tests/images/webp-partial-load.html [ Skip ]
 http/tests/images/webp-progressive-load.html [ Skip ]
 fast/images/animated-webp-expected.html [ Skip ]
+fast/images/animated-png-loop-count.html [ Skip ]
 
 # TODO The following tests requires the DRT's dumpUserGestureInFrameLoadCallbacks
 # method. But that method is not implemented in win port since win port can't

Modified: trunk/Source/WebCore/ChangeLog (258816 => 258817)


--- trunk/Source/WebCore/ChangeLog	2020-03-22 04:59:05 UTC (rev 258816)
+++ trunk/Source/WebCore/ChangeLog	2020-03-22 05:02:55 UTC (rev 258817)
@@ -1,3 +1,22 @@
+2020-03-21  Said Abou-Hallawa  <[email protected]>
+
+        An animated PNG plays the frames one time more than the image loopCount
+        https://bugs.webkit.org/show_bug.cgi?id=205640
+
+        Reviewed by Darin Adler.
+
+        Make the repetitionCount calculation for GIFs different from it for other
+        image formats.
+
+        Tests: fast/images/animated-gif-loop-count.html
+               fast/images/animated-png-loop-count.html
+
+        * platform/graphics/cg/ImageDecoderCG.cpp:
+        (WebCore::ImageDecoderCG::repetitionCount const):
+        * platform/graphics/cg/UTIRegistry.cpp:
+        (WebCore::isGIFImageType):
+        * platform/graphics/cg/UTIRegistry.h:
+
 2020-03-21  Jack Lee  <[email protected]>
 
         Nullptr crash in RenderObject::RenderObjectBitfields::isBox when current renderer is the RenderView

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp (258816 => 258817)


--- trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp	2020-03-22 04:59:05 UTC (rev 258816)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp	2020-03-22 05:02:55 UTC (rev 258817)
@@ -291,9 +291,15 @@
     CFNumberGetValue(num, kCFNumberIntType, &loopCount);
 
     // A property with value 0 means loop forever.
-    // For loopCount > 0, the specs is not clear about it. But it looks the meaning
+    if (!loopCount)
+        return RepetitionCountInfinite;
+
+    if (!isGIFImageType(uti()))
+        return loopCount;
+
+    // For GIF and loopCount > 0, the specs is not clear about it. But it looks the meaning
     // is: play once + loop loopCount which is equivalent to play loopCount + 1.
-    return loopCount ? loopCount + 1 : RepetitionCountInfinite;
+    return loopCount + 1;
 }
 
 Optional<IntPoint> ImageDecoderCG::hotSpot() const

Modified: trunk/Source/WebCore/platform/graphics/cg/UTIRegistry.cpp (258816 => 258817)


--- trunk/Source/WebCore/platform/graphics/cg/UTIRegistry.cpp	2020-03-22 04:59:05 UTC (rev 258816)
+++ trunk/Source/WebCore/platform/graphics/cg/UTIRegistry.cpp	2020-03-22 05:02:55 UTC (rev 258817)
@@ -102,6 +102,11 @@
     return defaultSupportedImageTypes().contains(imageType) || additionalSupportedImageTypes().contains(imageType);
 }
 
+bool isGIFImageType(StringView imageType)
+{
+    return imageType == "com.compuserve.gif";
 }
 
+}
+
 #endif

Modified: trunk/Source/WebCore/platform/graphics/cg/UTIRegistry.h (258816 => 258817)


--- trunk/Source/WebCore/platform/graphics/cg/UTIRegistry.h	2020-03-22 04:59:05 UTC (rev 258816)
+++ trunk/Source/WebCore/platform/graphics/cg/UTIRegistry.h	2020-03-22 05:02:55 UTC (rev 258817)
@@ -35,5 +35,6 @@
 WEBCORE_EXPORT void setAdditionalSupportedImageTypes(const Vector<String>&);
 WEBCORE_EXPORT void setAdditionalSupportedImageTypesForTesting(const String&);
 bool isSupportedImageType(const String&);
+bool isGIFImageType(StringView);
 
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to