Title: [184148] trunk/Source/WebCore
Revision
184148
Author
[email protected]
Date
2015-05-11 19:39:37 -0700 (Mon, 11 May 2015)

Log Message

Small tidyup in animations code
https://bugs.webkit.org/show_bug.cgi?id=144893

Reviewed by Eric Carlson.

Reading progress(1, 0, 0) in callers of AnimationBase::progress() was confusing,
particularly as the last parameter is a TimingFunction*. Put default values
in the header (with nullptr) and fix the callers. Also fix variable names in
the implementation.

* page/animation/AnimationBase.cpp:
(WebCore::AnimationBase::progress):
* page/animation/AnimationBase.h:
* page/animation/ImplicitAnimation.cpp:
(WebCore::ImplicitAnimation::animate):
(WebCore::ImplicitAnimation::getAnimatedStyle):
(WebCore::ImplicitAnimation::blendPropertyValueInStyle):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (184147 => 184148)


--- trunk/Source/WebCore/ChangeLog	2015-05-12 02:06:54 UTC (rev 184147)
+++ trunk/Source/WebCore/ChangeLog	2015-05-12 02:39:37 UTC (rev 184148)
@@ -1,3 +1,23 @@
+2015-05-11  Simon Fraser  <[email protected]>
+
+        Small tidyup in animations code
+        https://bugs.webkit.org/show_bug.cgi?id=144893
+
+        Reviewed by Eric Carlson.
+
+        Reading progress(1, 0, 0) in callers of AnimationBase::progress() was confusing,
+        particularly as the last parameter is a TimingFunction*. Put default values 
+        in the header (with nullptr) and fix the callers. Also fix variable names in
+        the implementation.
+
+        * page/animation/AnimationBase.cpp:
+        (WebCore::AnimationBase::progress):
+        * page/animation/AnimationBase.h:
+        * page/animation/ImplicitAnimation.cpp:
+        (WebCore::ImplicitAnimation::animate):
+        (WebCore::ImplicitAnimation::getAnimatedStyle):
+        (WebCore::ImplicitAnimation::blendPropertyValueInStyle):
+
 2015-05-11  Gyuyoung Kim  <[email protected]>
 
         Purge PassRefPtr in WebCore/rendering

Modified: trunk/Source/WebCore/page/animation/AnimationBase.cpp (184147 => 184148)


--- trunk/Source/WebCore/page/animation/AnimationBase.cpp	2015-05-12 02:06:54 UTC (rev 184147)
+++ trunk/Source/WebCore/page/animation/AnimationBase.cpp	2015-05-12 02:39:37 UTC (rev 184148)
@@ -613,21 +613,21 @@
     return fractionalTime;
 }
 
-double AnimationBase::progress(double scale, double offset, const TimingFunction* tf) const
+double AnimationBase::progress(double scale, double offset, const TimingFunction* timingFunction) const
 {
     if (preActive())
         return 0;
 
     double elapsedTime = getElapsedTime();
 
-    double dur = m_animation->duration();
+    double duration = m_animation->duration();
     if (m_animation->iterationCount() > 0)
-        dur *= m_animation->iterationCount();
+        duration *= m_animation->iterationCount();
 
     if (postActive() || !m_animation->duration())
         return 1.0;
 
-    if (m_animation->iterationCount() > 0 && elapsedTime >= dur) {
+    if (m_animation->iterationCount() > 0 && elapsedTime >= duration) {
         const int integralIterationCount = static_cast<int>(m_animation->iterationCount());
         const bool iterationCountHasFractional = m_animation->iterationCount() - integralIterationCount;
         return (integralIterationCount % 2 || iterationCountHasFractional) ? 1.0 : 0.0;
@@ -635,16 +635,16 @@
 
     const double fractionalTime = this->fractionalTime(scale, elapsedTime, offset);
 
-    if (!tf)
-        tf = m_animation->timingFunction().get();
+    if (!timingFunction)
+        timingFunction = m_animation->timingFunction().get();
 
-    switch (tf->type()) {
+    switch (timingFunction->type()) {
     case TimingFunction::CubicBezierFunction: {
-        const CubicBezierTimingFunction* function = static_cast<const CubicBezierTimingFunction*>(tf);
+        const CubicBezierTimingFunction* function = static_cast<const CubicBezierTimingFunction*>(timingFunction);
         return solveCubicBezierFunction(function->x1(), function->y1(), function->x2(), function->y2(), fractionalTime, m_animation->duration());
     }
     case TimingFunction::StepsFunction: {
-        const StepsTimingFunction* stepsTimingFunction = static_cast<const StepsTimingFunction*>(tf);
+        const StepsTimingFunction* stepsTimingFunction = static_cast<const StepsTimingFunction*>(timingFunction);
         return solveStepsFunction(stepsTimingFunction->numberOfSteps(), stepsTimingFunction->stepAtStart(), fractionalTime);
     }
     case TimingFunction::LinearFunction:

Modified: trunk/Source/WebCore/page/animation/AnimationBase.h (184147 => 184148)


--- trunk/Source/WebCore/page/animation/AnimationBase.h	2015-05-12 02:06:54 UTC (rev 184147)
+++ trunk/Source/WebCore/page/animation/AnimationBase.h	2015-05-12 02:39:37 UTC (rev 184148)
@@ -133,7 +133,7 @@
 
     virtual double timeToNextService();
 
-    double progress(double scale, double offset, const TimingFunction*) const;
+    double progress(double scale = 1, double offset = 0, const TimingFunction* = nullptr) const;
 
     // Returns true if the animation state changed.
     virtual bool animate(CompositeAnimation*, RenderElement*, const RenderStyle* /*currentStyle*/, RenderStyle* /*targetStyle*/, RefPtr<RenderStyle>& /*animatedStyle*/) = 0;

Modified: trunk/Source/WebCore/page/animation/ImplicitAnimation.cpp (184147 => 184148)


--- trunk/Source/WebCore/page/animation/ImplicitAnimation.cpp	2015-05-12 02:06:54 UTC (rev 184147)
+++ trunk/Source/WebCore/page/animation/ImplicitAnimation.cpp	2015-05-12 02:39:37 UTC (rev 184148)
@@ -78,7 +78,7 @@
     if (!animatedStyle)
         animatedStyle = RenderStyle::clone(targetStyle);
 
-    bool needsAnim = CSSPropertyAnimation::blendProperties(this, m_animatingProperty, animatedStyle.get(), m_fromStyle.get(), m_toStyle.get(), progress(1, 0, 0));
+    bool needsAnim = CSSPropertyAnimation::blendProperties(this, m_animatingProperty, animatedStyle.get(), m_fromStyle.get(), m_toStyle.get(), progress());
     // FIXME: we also need to detect cases where we have to software animate for other reasons,
     // such as a child using inheriting the transform. https://bugs.webkit.org/show_bug.cgi?id=23902
     if (!needsAnim) {
@@ -100,7 +100,7 @@
     if (!animatedStyle)
         animatedStyle = RenderStyle::clone(m_toStyle.get());
 
-    CSSPropertyAnimation::blendProperties(this, m_animatingProperty, animatedStyle.get(), m_fromStyle.get(), m_toStyle.get(), progress(1, 0, 0));
+    CSSPropertyAnimation::blendProperties(this, m_animatingProperty, animatedStyle.get(), m_fromStyle.get(), m_toStyle.get(), progress());
 }
 
 bool ImplicitAnimation::computeExtentOfTransformAnimation(LayoutRect& bounds) const
@@ -252,7 +252,7 @@
     if (!m_toStyle)
         return;
         
-    CSSPropertyAnimation::blendProperties(this, prop, currentStyle, m_fromStyle.get(), m_toStyle.get(), progress(1, 0, 0));
+    CSSPropertyAnimation::blendProperties(this, prop, currentStyle, m_fromStyle.get(), m_toStyle.get(), progress());
 }
 
 void ImplicitAnimation::validateTransformFunctionList()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to