<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[210951] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/210951">210951</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2017-01-19 19:56:20 -0800 (Thu, 19 Jan 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>REGRESSION(<a href="http://trac.webkit.org/projects/webkit/changeset/206156">r206156</a>): Animated images are repeated one extra iteration than the value which is saved in the image file
https://bugs.webkit.org/show_bug.cgi?id=167174
Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2017-01-19
Reviewed by Simon Fraser.
Source/WebCore:
Before <a href="http://trac.webkit.org/projects/webkit/changeset/206156">r206156</a>, BitmapImage::repetitionCount() used to return zero for
the case loopCount = 1, -1 for loopCount = Infinity and loopCount for
all other cases. Having repetitionCount() return zero for loopCount = 1
makes the condition if (++m_repetitionsComplete > repetitionCount())
break the animation loop after one iteration. But it was wrong for all
loopCount > 1. It was causing an extra iteration to be played for the
animated image. After <a href="http://trac.webkit.org/projects/webkit/changeset/206156">r206156</a>, BitmapImage::repetitionCount() returns
loopCount for all cases loopCount != Infinity. Keeping the same condition
causes the extra iteration to be played even for loopCount = 1.
Test: fast/images/animated-image-loop-count.html
* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::internalStartAnimation):
LayoutTests:
* fast/images/animated-image-loop-count-expected.html: Added.
* fast/images/animated-image-loop-count.html: Added.
* fast/images/resources/animated-red-green-blue-repeat-1.gif: Added.
* fast/images/resources/animated-red-green-blue-repeat-2.gif: Added.
Ensure the animated image stops animating after loopCount iterations.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsBitmapImagecpp">trunk/Source/WebCore/platform/graphics/BitmapImage.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastimagesanimatedimageloopcountexpectedhtml">trunk/LayoutTests/fast/images/animated-image-loop-count-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastimagesanimatedimageloopcounthtml">trunk/LayoutTests/fast/images/animated-image-loop-count.html</a></li>
<li><a href="#trunkLayoutTestsfastimagesresourcesanimatedredgreenbluerepeat1gif">trunk/LayoutTests/fast/images/resources/animated-red-green-blue-repeat-1.gif</a></li>
<li><a href="#trunkLayoutTestsfastimagesresourcesanimatedredgreenbluerepeat2gif">trunk/LayoutTests/fast/images/resources/animated-red-green-blue-repeat-2.gif</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (210950 => 210951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-01-20 03:49:37 UTC (rev 210950)
+++ trunk/LayoutTests/ChangeLog        2017-01-20 03:56:20 UTC (rev 210951)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2017-01-19 Said Abou-Hallawa <sabouhallawa@apple.com>
+
+ REGRESSION(r206156): Animated images are repeated one extra iteration than the value which is saved in the image file
+ https://bugs.webkit.org/show_bug.cgi?id=167174
+
+ Reviewed by Simon Fraser.
+
+ * fast/images/animated-image-loop-count-expected.html: Added.
+ * fast/images/animated-image-loop-count.html: Added.
+ * fast/images/resources/animated-red-green-blue-repeat-1.gif: Added.
+ * fast/images/resources/animated-red-green-blue-repeat-2.gif: Added.
+ Ensure the animated image stops animating after loopCount iterations.
+
</ins><span class="cx"> 2017-01-19 Zalan Bujtas <zalan@apple.com>
</span><span class="cx">
</span><span class="cx"> Simple line layout: Extend coverage for justified content.
</span></span></pre></div>
<a id="trunkLayoutTestsfastimagesanimatedimageloopcountexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/images/animated-image-loop-count-expected.html (0 => 210951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/images/animated-image-loop-count-expected.html         (rev 0)
+++ trunk/LayoutTests/fast/images/animated-image-loop-count-expected.html        2017-01-20 03:56:20 UTC (rev 210951)
</span><span class="lines">@@ -0,0 +1,29 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<style>
+ .box {
+ width: 100px;
+ height: 100px;
+ display: inline-block;
+ }
+</style>
+<body>
+ <div>
+ <p>Frames of a 3-frame animated image with loopCount = 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 = 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>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastimagesanimatedimageloopcounthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/images/animated-image-loop-count.html (0 => 210951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/images/animated-image-loop-count.html         (rev 0)
+++ trunk/LayoutTests/fast/images/animated-image-loop-count.html        2017-01-20 03:56:20 UTC (rev 210951)
</span><span class="lines">@@ -0,0 +1,80 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<style>
+ canvas {
+ width: 100px;
+ height: 100px;
+ }
+</style>
+<body>
+ <div>
+ <p>Frames of a 3-frame animated image with loopCount = 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 = 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>
+ <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 = src;
+ });
+ }
+
+ (function() {
+ 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 }
+ ];
+
+ 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>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastimagesresourcesanimatedredgreenbluerepeat1gif"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/images/resources/animated-red-green-blue-repeat-1.gif (0 => 210951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/images/resources/animated-red-green-blue-repeat-1.gif         (rev 0)
+++ trunk/LayoutTests/fast/images/resources/animated-red-green-blue-repeat-1.gif        2017-01-20 03:56:20 UTC (rev 210951)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+GIF89add\xF0\xFF!\xF9!\xFFImageMagick+gamma=0.45455,dds\x84\x8F\xA9\xCB\xED\xA3\x9C\xB4ڋ\xB3\xFB\x86\xE2H\x96扦\xEAʶ\xEE\xC7\xF2L\xD7\xF6\x8D\xE7\xFA\xCE\xF7\xFE
+\x87Ģ\xF1\x88L*\x97̦\xF3        \x8DJ\xA7Ԫ\xF5\x8A\xCDj\xB7ܮ\xF7\x8B\xC7\xE4\xB2\xF9\x8CN\xAB\xD7\xEC\xB6\xFB+\x8F\xCB\xE7\xF4\xBA\xFD\x8E\xCF\xEB\xF7\xFC\xBE\xFF(8HXhx\x88\x98\xA8\xB8\xC8\xD8\xE8\xF8iX!\xF9!\xFFImageMagick+gamma=0.45455,dd\x80\x80s\x84\x8F\xA9\xCB\xED\xA3\x9C\xB4ڋ\xB3\xFB\x86\xE2H\x96扦\xEAʶ\xEE\xC7\xF2L\xD7\xF6\x8D\xE7\xFA\xCE\xF7\xFE
+\x87Ģ\xF1\x88L*\x97̦\xF3        \x8DJ\xA7Ԫ\xF5\x8A\xCDj\xB7ܮ\xF7\x8B\xC7\xE4\xB2\xF9\x8CN\xAB\xD7\xEC\xB6\xFB+\x8F\xCB\xE7\xF4\xBA\xFD\x8E\xCF\xEB\xF7\xFC\xBE\xFF(8HXhx\x88\x98\xA8\xB8\xC8\xD8\xE8\xF8iX!\xF9!\xFFImageMagick+gamma=0.45455,dd\x80\xFFs\x84\x8F\xA9\xCB\xED\xA3\x9C\xB4ڋ\xB3\xFB\x86\xE2H\x96扦\xEAʶ\xEE\xC7\xF2L\xD7\xF6\x8D\xE7\xFA\xCE\xF7\xFE
+\x87Ģ\xF1\x88L*\x97̦\xF3        \x8DJ\xA7Ԫ\xF5\x8A\xCDj\xB7ܮ\xF7\x8B\xC7\xE4\xB2\xF9\x8CN\xAB\xD7\xEC\xB6\xFB+\x8F\xCB\xE7\xF4\xBA\xFD\x8E\xCF\xEB\xF7\xFC\xBE\xFF(8HXhx\x88\x98\xA8\xB8\xC8\xD8\xE8\xF8iX;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsfastimagesresourcesanimatedredgreenbluerepeat2gif"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/images/resources/animated-red-green-blue-repeat-2.gif (0 => 210951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/images/resources/animated-red-green-blue-repeat-2.gif         (rev 0)
+++ trunk/LayoutTests/fast/images/resources/animated-red-green-blue-repeat-2.gif        2017-01-20 03:56:20 UTC (rev 210951)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+GIF89add\xF0\xFF!\xF9!\xFFNETSCAPE2.0!\xFFImageMagick+gamma=0.45455,dds\x84\x8F\xA9\xCB\xED\xA3\x9C\xB4ڋ\xB3\xFB\x86\xE2H\x96扦\xEAʶ\xEE\xC7\xF2L\xD7\xF6\x8D\xE7\xFA\xCE\xF7\xFE
+\x87Ģ\xF1\x88L*\x97̦\xF3        \x8DJ\xA7Ԫ\xF5\x8A\xCDj\xB7ܮ\xF7\x8B\xC7\xE4\xB2\xF9\x8CN\xAB\xD7\xEC\xB6\xFB+\x8F\xCB\xE7\xF4\xBA\xFD\x8E\xCF\xEB\xF7\xFC\xBE\xFF(8HXhx\x88\x98\xA8\xB8\xC8\xD8\xE8\xF8iX!\xF9!\xFFImageMagick+gamma=0.45455,dd\x80\x80s\x84\x8F\xA9\xCB\xED\xA3\x9C\xB4ڋ\xB3\xFB\x86\xE2H\x96扦\xEAʶ\xEE\xC7\xF2L\xD7\xF6\x8D\xE7\xFA\xCE\xF7\xFE
+\x87Ģ\xF1\x88L*\x97̦\xF3        \x8DJ\xA7Ԫ\xF5\x8A\xCDj\xB7ܮ\xF7\x8B\xC7\xE4\xB2\xF9\x8CN\xAB\xD7\xEC\xB6\xFB+\x8F\xCB\xE7\xF4\xBA\xFD\x8E\xCF\xEB\xF7\xFC\xBE\xFF(8HXhx\x88\x98\xA8\xB8\xC8\xD8\xE8\xF8iX!\xF9!\xFFImageMagick+gamma=0.45455,dd\x80\xFFs\x84\x8F\xA9\xCB\xED\xA3\x9C\xB4ڋ\xB3\xFB\x86\xE2H\x96扦\xEAʶ\xEE\xC7\xF2L\xD7\xF6\x8D\xE7\xFA\xCE\xF7\xFE
+\x87Ģ\xF1\x88L*\x97̦\xF3        \x8DJ\xA7Ԫ\xF5\x8A\xCDj\xB7ܮ\xF7\x8B\xC7\xE4\xB2\xF9\x8CN\xAB\xD7\xEC\xB6\xFB+\x8F\xCB\xE7\xF4\xBA\xFD\x8E\xCF\xEB\xF7\xFC\xBE\xFF(8HXhx\x88\x98\xA8\xB8\xC8\xD8\xE8\xF8iX;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (210950 => 210951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-01-20 03:49:37 UTC (rev 210950)
+++ trunk/Source/WebCore/ChangeLog        2017-01-20 03:56:20 UTC (rev 210951)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2017-01-19 Said Abou-Hallawa <sabouhallawa@apple.com>
+
+ REGRESSION(r206156): Animated images are repeated one extra iteration than the value which is saved in the image file
+ https://bugs.webkit.org/show_bug.cgi?id=167174
+
+ Reviewed by Simon Fraser.
+
+ Before r206156, BitmapImage::repetitionCount() used to return zero for
+ the case loopCount = 1, -1 for loopCount = Infinity and loopCount for
+ all other cases. Having repetitionCount() return zero for loopCount = 1
+ makes the condition if (++m_repetitionsComplete > repetitionCount())
+ break the animation loop after one iteration. But it was wrong for all
+ loopCount > 1. It was causing an extra iteration to be played for the
+ animated image. After r206156, BitmapImage::repetitionCount() returns
+ loopCount for all cases loopCount != Infinity. Keeping the same condition
+ causes the extra iteration to be played even for loopCount = 1.
+
+ Test: fast/images/animated-image-loop-count.html
+
+ * platform/graphics/BitmapImage.cpp:
+ (WebCore::BitmapImage::internalStartAnimation):
+
</ins><span class="cx"> 2017-01-19 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><span class="cx"> iterable<> should be enabled on WK1
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsBitmapImagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.cpp (210950 => 210951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/BitmapImage.cpp        2017-01-20 03:49:37 UTC (rev 210950)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.cpp        2017-01-20 03:56:20 UTC (rev 210951)
</span><span class="lines">@@ -251,7 +251,7 @@
</span><span class="cx"> ++m_repetitionsComplete;
</span><span class="cx">
</span><span class="cx"> // Check for the end of animation.
</span><del>- if (repetitionCount() != RepetitionCountInfinite && m_repetitionsComplete > repetitionCount()) {
</del><ins>+ if (repetitionCount() != RepetitionCountInfinite && m_repetitionsComplete >= repetitionCount()) {
</ins><span class="cx"> m_animationFinished = true;
</span><span class="cx"> destroyDecodedDataIfNecessary(false);
</span><span class="cx"> return StartAnimationResult::CannotStart;
</span></span></pre>
</div>
</div>
</body>
</html>