REGRESSION(r206156): Animated images are repeated one extra iteration than the value...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Jan 2017 03:56:20 +0000 (03:56 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Jan 2017 03:56:20 +0000 (03:56 +0000)
commite8f8d6f5c85a7b9bbc0a224f9c33e216bfbd53ed
treef77e4b1d225137804132fbbe95d56ec4b81bc7e5
parent526b413b8b98c4ddd43f2b42c49a17fd11ae233e
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

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2017-01-19
Reviewed by Simon Fraser.

Source/WebCore:

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):

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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210951 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/images/animated-image-loop-count-expected.html [new file with mode: 0644]
LayoutTests/fast/images/animated-image-loop-count.html [new file with mode: 0644]
LayoutTests/fast/images/resources/animated-red-green-blue-repeat-1.gif [new file with mode: 0644]
LayoutTests/fast/images/resources/animated-red-green-blue-repeat-2.gif [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/BitmapImage.cpp