From e32635b46b2f2b78eb18c5b195e0bdaf8c7f9b71 Mon Sep 17 00:00:00 2001
From: Simon Hausmann <simon.hausmann@nokia.com>
Date: Wed, 16 Jun 2010 10:22:47 +0200
Subject: Updated WebKit from /home/shausman/src/webkit/trunk to
 qtwebkit/qtwebkit-4.6 ( 7932e8da6bfdeff653c572c22aed879c8c308829 )

Changes in WebKit/qt since the last update:

* https://bugs.webkit.org/show_bug.cgi?id=39857 -- GIFs loop one time too few
---
 src/3rdparty/webkit/VERSION                        |  2 +-
 src/3rdparty/webkit/WebCore/ChangeLog              | 31 ++++++++++++++++++++++
 .../WebCore/platform/graphics/BitmapImage.cpp      |  4 ++-
 .../webkit/WebCore/platform/graphics/ImageSource.h | 17 +++++++++++-
 .../platform/graphics/qt/ImageDecoderQt.cpp        | 18 +------------
 5 files changed, 52 insertions(+), 20 deletions(-)

diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION
index b92486d..4c895fb 100644
--- a/src/3rdparty/webkit/VERSION
+++ b/src/3rdparty/webkit/VERSION
@@ -8,4 +8,4 @@ The commit imported was from the
 
 and has the sha1 checksum
 
-        d8a9d09376a47b92ea49f1a078c392cbfdbc0ed6
+        7932e8da6bfdeff653c572c22aed879c8c308829
diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog
index bf8b745..09b8598 100644
--- a/src/3rdparty/webkit/WebCore/ChangeLog
+++ b/src/3rdparty/webkit/WebCore/ChangeLog
@@ -1,3 +1,34 @@
+2010-05-28  Peter Kasting  <pkasting@google.com>
+
+        Reviewed by Darin Adler.
+
+        https://bugs.webkit.org/show_bug.cgi?id=39857
+        Make GIFs loop the correct number of times.  Previously, everyone looped
+        one time too few for non-infinitely-looping GIFs.
+
+        Modified a Qt manual test to be correct and moved it to the general
+        manual test directory.
+
+        * manual-tests/animated-gif-looping.html: Copied from WebCore/manual-tests/qt/qt-gif-test.html.
+        * manual-tests/qt/qt-10loop-anim.gif: Removed.
+        * manual-tests/qt/qt-anim.gif: Removed.
+        * manual-tests/qt/qt-gif-test.html: Removed.
+        * manual-tests/qt/qt-noanim.gif: Removed.
+        * manual-tests/resources/animated-10x.gif: Copied from WebCore/manual-tests/qt/qt-10loop-anim.gif and modified.
+        * manual-tests/resources/animated-infinite.gif: Copied from WebCore/manual-tests/qt/qt-anim.gif.
+        * manual-tests/resources/non-animated.gif: Copied from WebCore/manual-tests/qt/qt-noanim.gif.
+        * platform/graphics/BitmapImage.cpp:
+        (WebCore::BitmapImage::internalAdvanceAnimation): For a loop count of n, show a total of n + 1 animation cycles.
+        * platform/graphics/ImageSource.h:
+        * platform/graphics/cg/ImageSourceCG.cpp:
+        (WebCore::ImageSource::repetitionCount):
+        * platform/graphics/qt/ImageDecoderQt.cpp:
+        (WebCore::ImageDecoderQt::repetitionCount): Remove translation code now that WebCore matches Qt's internal handling of the loop count.  Qt itself may still have a bug here.
+        * platform/image-decoders/gif/GIFImageDecoder.cpp:
+        (WebCore::GIFImageDecoder::repetitionCount):
+        * platform/image-decoders/gif/GIFImageReader.cpp:
+        (GIFImageReader::read): Translate loop count 0 to "loop infinitely" (by restoring one piece of the Mozilla code we'd removed).
+
 2010-06-08  Kenneth Rohde Christiansen  <kenneth.christiansen@openbossa.org>
 
         Unreviewed Buildbot fix.
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/BitmapImage.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/BitmapImage.cpp
index 32aefc9..4faf19d 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/BitmapImage.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/BitmapImage.cpp
@@ -404,7 +404,9 @@ bool BitmapImage::internalAdvanceAnimation(bool skippingFrames)
         // Get the repetition count again.  If we weren't able to get a
         // repetition count before, we should have decoded the whole image by
         // now, so it should now be available.
-        if (repetitionCount(true) && m_repetitionsComplete >= m_repetitionCount) {
+        // Note that we don't need to special-case cAnimationLoopOnce here
+        // because it is 0 (see comments on its declaration in ImageSource.h).
+        if (repetitionCount(true) != cAnimationLoopInfinite && m_repetitionsComplete > m_repetitionCount) {
             m_animationFinished = true;
             m_desiredFrameStartTime = 0;
             --m_currentFrame;
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/ImageSource.h b/src/3rdparty/webkit/WebCore/platform/graphics/ImageSource.h
index 3559abe..d7b8a64 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/ImageSource.h
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/ImageSource.h
@@ -86,7 +86,22 @@ typedef RefPtr<SharedBitmap> NativeImagePtr;
 #endif
 #endif
 
-const int cAnimationLoopOnce = -1;
+// Right now GIFs are the only recognized image format that supports animation.
+// The animation system and the constants below are designed with this in mind.
+// GIFs have an optional 16-bit unsigned loop count that describes how an
+// animated GIF should be cycled.  If the loop count is absent, the animation
+// cycles once; if it is 0, the animation cycles infinitely; otherwise the
+// animation plays n + 1 cycles (where n is the specified loop count).  If the
+// GIF decoder defaults to cAnimationLoopOnce in the absence of any loop count
+// and translates an explicit "0" loop count to cAnimationLoopInfinite, then we
+// get a couple of nice side effects:
+//   * By making cAnimationLoopOnce be 0, we allow the animation cycling code in
+//     BitmapImage.cpp to avoid special-casing it, and simply treat all
+//     non-negative loop counts identically.
+//   * By making the other two constants negative, we avoid conflicts with any
+//     real loop count values.
+const int cAnimationLoopOnce = 0;
+const int cAnimationLoopInfinite = -1;
 const int cAnimationNone = -2;
 
 class ImageSource : public Noncopyable {
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
index 764b240..53f0c6b 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
@@ -114,24 +114,8 @@ size_t ImageDecoderQt::frameCount()
 
 int ImageDecoderQt::repetitionCount() const
 {
-    if (m_reader && m_reader->supportsAnimation()) {
+    if (m_reader && m_reader->supportsAnimation())
         m_repetitionCount = m_reader->loopCount();
-
-        // Qt and WebCore have a incompatible understanding of
-        // the loop count and we can not completely map everything.
-        //  Qt   |   WebCore          | description
-        //  -1   |     0              | infinite animation
-        //   0   | cAnimationLoopOnce | show every frame once
-        //   n   |     n+1            | Qt returns the # of iterations - 1
-        //  n/a  | cAnimationNone     | show only the first frame
-        if (m_repetitionCount == -1)
-            m_repetitionCount = 0;
-        else if (m_repetitionCount == 0)
-            m_repetitionCount = cAnimationLoopOnce;
-        else
-            ++m_repetitionCount;
-    }
-
     return m_repetitionCount;
 }
 
-- 
cgit v0.12