Bug 641198 - Restart loop-once animations. r=joe
authorAlon Zakai <azakai@mozilla.com>
Thu, 31 Mar 2011 14:05:31 -0700
changeset 64529 be4ecb32b875a8731f5e9e51bfe35f1f9038ad5d
parent 64528 36242c02cfc43def17fe14a3bdb999de84356d3b
child 64530 c0564f7efcb94e15d8f8d1be33cbc95cbc61d270
push id19359
push userazakai@mozilla.com
push dateThu, 31 Mar 2011 21:07:41 +0000
treeherdermozilla-central@c0564f7efcb9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjoe
bugs641198
milestone2.2a1pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 641198 - Restart loop-once animations. r=joe
modules/libpr0n/src/RasterImage.cpp
modules/libpr0n/test/reftest/gif/animation1a.gif
modules/libpr0n/test/reftest/gif/animation2a-finalframe.gif
modules/libpr0n/test/reftest/gif/animation2a.gif
modules/libpr0n/test/reftest/gif/reftest.list
modules/libpr0n/test/reftest/gif/test_bug641198.html
--- a/modules/libpr0n/src/RasterImage.cpp
+++ b/modules/libpr0n/src/RasterImage.cpp
@@ -1166,32 +1166,39 @@ RasterImage::ResetAnimation()
 {
   if (mError)
     return NS_ERROR_FAILURE;
 
   if (mAnimationMode == kDontAnimMode || 
       !mAnim || mAnim->currentAnimationFrameIndex == 0)
     return NS_OK;
 
+  mAnimationFinished = PR_FALSE;
+
   if (mAnimating)
     StopAnimation();
 
   mAnim->lastCompositedFrameIndex = -1;
   mAnim->currentAnimationFrameIndex = 0;
 
   // Note - We probably want to kick off a redecode somewhere around here when
   // we fix bug 500402.
 
   // Update display if we were animating before
   nsCOMPtr<imgIContainerObserver> observer(do_QueryReferent(mObserver));
   if (mAnimating && observer)
     observer->FrameChanged(this, &(mAnim->firstFrameRefreshArea));
 
-  if (ShouldAnimate())
+  if (ShouldAnimate()) {
     StartAnimation();
+    // The animation may not have been running before, if mAnimationFinished
+    // was false (before we changed it to true in this function). So, mark the
+    // animation as running.
+    mAnimating = PR_TRUE;
+  }
 
   return NS_OK;
 }
 
 void
 RasterImage::SetLoopCount(PRInt32 aLoopCount)
 {
   if (mError)
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..d328276545b0611a2e4fca12d567019d168162b6
GIT binary patch
literal 167
zc${<hbhEHb)L_tHSjfciU-JL|FF*_eivI+ii&7IyQd1PlGfOfQ+&z5*7!-f9uyQdl
zGUzY>0Z0=AlX^@4%F}Q87th&pt9$dkJ-_+e9(hcA*17D}scrALkAL#H{;l`<uXD<*
RAia!SKyAo+dx+F)4FI6}N%{Z)
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..8d9c4aaf7d004f93464f5706b30aa7b0e790d269
GIT binary patch
literal 107
zc${<hbhEHb)L_tHSjfa6sr6rbBl~|aQ2Zz8T$GwvlA5AWo>`Ki;O^-gz@Ye(h0%zC
zkwJ$62tb+`nABVPSDt>$zj)4;Tiu)Q?fK2$_Q+$}v(9C&PHlU~ef*Qp^>4k;f1Oii
HWv~VSYMd=3
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..07abf8d986870f854c9e901f2a5d8acd626f3434
GIT binary patch
literal 167
zc${<hbhEHb)L_tHSjfa6sr6rbBl~|aQ2Zz8T$GwvlA5AWo>`Ki;O^-gz@Ye(g^`Pa
zfk6j|89<sCnACgvSDt>$zj)4;Tiu)Q?fK2$_Q+$}v(9C&PHlU~ef*Qp^>4k;f1Oii
Oh3aKQ(c40#UTXkxyhr!|
--- a/modules/libpr0n/test/reftest/gif/reftest.list
+++ b/modules/libpr0n/test/reftest/gif/reftest.list
@@ -10,8 +10,12 @@
 
 # a GIF file with a background smaller than the size of the canvas
 == small-background-size.gif small-background-size-ref.gif
 == small-background-size-2.gif small-background-size-2-ref.gif
 
 # a transparent gif that disposes previous frames with clear; we must properly
 # clear each frame to pass.
 random == delaytest.html?transparent-animation.gif transparent-animation-finalframe.gif # incorrect timing dependence (bug 558678)
+
+# test for bug 641198
+== test_bug641198.html animation2a-finalframe.gif
+
new file mode 100644
--- /dev/null
+++ b/modules/libpr0n/test/reftest/gif/test_bug641198.html
@@ -0,0 +1,52 @@
+<!DOCTYPE HTML>
+<html class="reftest-wait">
+<head>
+<title>Test for bug 641198</title>
+<style type="text/css" media=screen>
+   a.animated1 {
+      display: block;
+      width: 212px;
+      height: 237px;
+      background: url("animation1a.gif") no-repeat 0 0;
+   }
+
+   a.animated1 span {
+      position: absolute;
+      top: -999em;
+   }
+
+   a.animated2 {
+      display: block;
+      width: 212px;
+      height: 237px;
+      background: url("animation2a.gif") no-repeat 0 0;
+   }
+
+   a.animated2 span {
+      position: absolute;
+      top: -999em;
+   }
+</style>
+</head>
+<body onload="doTimeout()">
+
+<a id="animated" href="#" title="Animated"><span>Animated</span></a>
+
+<script>
+// We check whether changing the class will lead to the animation being
+// run from the beginning, even if the animation was already shown
+// before.
+var counter = 0;
+function doTimeout() {
+  if (counter == 4) {
+    document.documentElement.className = '';
+  } else {
+    document.getElementById("animated").setAttribute("class", "animated" + ((counter % 2)+1));
+    setTimeout(doTimeout, counter == 3 ? 500 : 250); // Wait a bit more for the last one, to prevent oranges
+  }
+  counter++;
+}
+</script>
+</body>
+</html>
+