Convert the boolean param of Image::startAnimation() to an enum
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Apr 2014 17:50:57 +0000 (17:50 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Apr 2014 17:50:57 +0000 (17:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=131742

Reviewed by Tim Horton.

Use an enum to make the code more readable.

* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::startAnimation):
* platform/graphics/BitmapImage.h:
* platform/graphics/Image.cpp:
(WebCore::Image::drawTiled):
* platform/graphics/Image.h:
(WebCore::Image::startAnimation):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::startAnimation):
* svg/graphics/SVGImage.h:

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/BitmapImage.cpp
Source/WebCore/platform/graphics/BitmapImage.h
Source/WebCore/platform/graphics/Image.cpp
Source/WebCore/platform/graphics/Image.h
Source/WebCore/svg/graphics/SVGImage.cpp
Source/WebCore/svg/graphics/SVGImage.h

index d617319..f2869f1 100644 (file)
@@ -1,3 +1,23 @@
+2014-04-16  Simon Fraser  <simon.fraser@apple.com>
+
+        Convert the boolean param of Image::startAnimation() to an enum
+        https://bugs.webkit.org/show_bug.cgi?id=131742
+
+        Reviewed by Tim Horton.
+
+        Use an enum to make the code more readable.
+
+        * platform/graphics/BitmapImage.cpp:
+        (WebCore::BitmapImage::startAnimation):
+        * platform/graphics/BitmapImage.h:
+        * platform/graphics/Image.cpp:
+        (WebCore::Image::drawTiled):
+        * platform/graphics/Image.h:
+        (WebCore::Image::startAnimation):
+        * svg/graphics/SVGImage.cpp:
+        (WebCore::SVGImage::startAnimation):
+        * svg/graphics/SVGImage.h:
+
 2014-04-16  David Hyatt  <hyatt@apple.com>
 
         Make sure to skip the RenderMultiColumnFlowThread when resolving percentage heights inside columns against
index fad9843..14b2b54 100644 (file)
@@ -539,7 +539,7 @@ bool BitmapImage::shouldAnimate()
     return (repetitionCount(false) != cAnimationNone && !m_animationFinished && imageObserver());
 }
 
-void BitmapImage::startAnimation(bool catchUpIfNecessary)
+void BitmapImage::startAnimation(CatchUpAnimation catchUpIfNecessary)
 {
     if (m_frameTimer || !shouldAnimate() || frameCount() <= 1)
         return;
@@ -593,7 +593,7 @@ void BitmapImage::startAnimation(bool catchUpIfNecessary)
     if (nextFrame == 0 && m_repetitionsComplete == 0 && m_desiredFrameStartTime < time)
         m_desiredFrameStartTime = time;
 
-    if (!catchUpIfNecessary || time < m_desiredFrameStartTime) {
+    if (catchUpIfNecessary == DoNotCatchUp || time < m_desiredFrameStartTime) {
         // Haven't yet reached time for next frame to start; delay until then.
         m_frameTimer = std::make_unique<Timer<BitmapImage>>(this, &BitmapImage::advanceAnimation);
         m_frameTimer->startOneShot(std::max(m_desiredFrameStartTime - time, 0.));
@@ -636,7 +636,7 @@ void BitmapImage::startAnimation(bool catchUpIfNecessary)
             // situation the best we can do is to simply change frames as fast
             // as possible, so force startAnimation() to set a zero-delay timer
             // and bail out if we're not caught up.
-            startAnimation(false);
+            startAnimation(DoNotCatchUp);
         }
     }
 }
index 2e450a2..307905c 100644 (file)
@@ -272,7 +272,7 @@ protected:
     // Animation.
     int repetitionCount(bool imageKnownToBeComplete);  // |imageKnownToBeComplete| should be set if the caller knows the entire image has been decoded.
     bool shouldAnimate();
-    virtual void startAnimation(bool catchUpIfNecessary = true) override;
+    virtual void startAnimation(CatchUpAnimation = CatchUp) override;
     void advanceAnimation(Timer<BitmapImage>&);
 
     // Function that does the real work of advancing the animation.  When
index 6f755e1..1ec3bab 100644 (file)
@@ -185,7 +185,7 @@ void Image::drawTiled(GraphicsContext* ctxt, const FloatRect& destRect, const Fl
     drawPattern(ctxt, tileRect, patternTransform, oneTileRect.location(), styleColorSpace, op, destRect, blendMode);
 
 #if PLATFORM(IOS)
-    startAnimation(false);
+    startAnimation(DoNotCatchUp);
 #else
     startAnimation();
 #endif
@@ -223,7 +223,7 @@ void Image::drawTiled(GraphicsContext* ctxt, const FloatRect& dstRect, const Flo
     drawPattern(ctxt, srcRect, patternTransform, patternPhase, styleColorSpace, op, dstRect);
 
 #if PLATFORM(IOS)
-    startAnimation(false);
+    startAnimation(DoNotCatchUp);
 #else
     startAnimation();
 #endif
index c3c78c9..61176d8 100644 (file)
@@ -115,7 +115,8 @@ public:
 
     // Animation begins whenever someone draws the image, so startAnimation() is not normally called.
     // It will automatically pause once all observers no longer want to render the image anywhere.
-    virtual void startAnimation(bool /*catchUpIfNecessary*/ = true) { }
+    enum CatchUpAnimation { DoNotCatchUp, CatchUp };
+    virtual void startAnimation(CatchUpAnimation = CatchUp) { }
     virtual void stopAnimation() {}
     virtual void resetAnimation() {}
     
index 15fcc94..8ff3237 100644 (file)
@@ -316,7 +316,7 @@ void SVGImage::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrin
 }
 
 // FIXME: support catchUpIfNecessary.
-void SVGImage::startAnimation(bool /* catchUpIfNecessary */)
+void SVGImage::startAnimation(CatchUpAnimation)
 {
     if (!m_page)
         return;
index 4893daf..727c0c9 100644 (file)
@@ -60,7 +60,7 @@ public:
     virtual bool hasRelativeWidth() const override;
     virtual bool hasRelativeHeight() const override;
 
-    virtual void startAnimation(bool /*catchUpIfNecessary*/ = true) override;
+    virtual void startAnimation(CatchUpAnimation = CatchUp) override;
     virtual void stopAnimation() override;
     virtual void resetAnimation() override;