[GTK+] PNG animations that should run once are not played at all
authormagomez@igalia.com <magomez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Apr 2017 10:09:11 +0000 (10:09 +0000)
committermagomez@igalia.com <magomez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Apr 2017 10:09:11 +0000 (10:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=170499

Reviewed by Carlos Garcia Campos.

The repetition count reported bu the PNGImageDecoder is wrong. It's returning m_playCount - 1, which
means 0 for the animations that need to be played once. Change it to return an appropriate value.

Covered by existent tests.

* platform/image-decoders/png/PNGImageDecoder.cpp:
(WebCore::PNGImageDecoder::repetitionCount):
* platform/image-decoders/png/PNGImageDecoder.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214939 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
Source/WebCore/platform/image-decoders/png/PNGImageDecoder.h

index 6bcde07..3670759 100644 (file)
@@ -1,3 +1,19 @@
+2017-04-05  Miguel Gomez  <magomez@igalia.com>
+
+        [GTK+] PNG animations that should run once are not played at all
+        https://bugs.webkit.org/show_bug.cgi?id=170499
+
+        Reviewed by Carlos Garcia Campos.
+
+        The repetition count reported bu the PNGImageDecoder is wrong. It's returning m_playCount - 1, which
+        means 0 for the animations that need to be played once. Change it to return an appropriate value.
+
+        Covered by existent tests.
+
+        * platform/image-decoders/png/PNGImageDecoder.cpp:
+        (WebCore::PNGImageDecoder::repetitionCount):
+        * platform/image-decoders/png/PNGImageDecoder.h:
+
 2017-04-05  Andy Estes  <aestes@apple.com>
 
         REGRESSION (r202472): Data Detection overwrites existing links in detected ranges
index 1c53b2d..0abcaf2 100644 (file)
@@ -227,6 +227,18 @@ PNGImageDecoder::~PNGImageDecoder()
 {
 }
 
+#if ENABLE(APNG)
+RepetitionCount PNGImageDecoder::repetitionCount() const
+{
+    // APNG format uses 0 to indicate that an animation must play indefinitely. But
+    // the RepetitionCount enumeration uses RepetitionCountInfinite, so we need to adapt this.
+    if (!m_playCount)
+        return RepetitionCountInfinite;
+
+    return m_playCount;
+}
+#endif
+
 bool PNGImageDecoder::isSizeAvailable()
 {
     if (!ImageDecoder::isSizeAvailable())
index 113ff2e..fee08f5 100644 (file)
@@ -44,7 +44,7 @@ namespace WebCore {
         String filenameExtension() const override { return "png"; }
 #if ENABLE(APNG)
         size_t frameCount() const override { return m_frameCount; }
-        RepetitionCount repetitionCount() const override { return m_playCount-1; }
+        RepetitionCount repetitionCount() const override;
 #endif
         bool isSizeAvailable() override;
         bool setSize(const IntSize&) override;