Clean up "has non-zero begin time" terminology in animations
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 May 2014 16:35:00 +0000 (16:35 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 May 2014 16:35:00 +0000 (16:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=132942

Reviewed by Tim Horton.

Change the "non-zero beginTime" terminology in the platform CA animations
code to "explicit beginTime": this flag really means that we explicitly set
the beginTime of the animation, rather than let CA set the beginTime when
committing the animation. This flag is used for animations with negative
delay, and when pausing.

Source/WebCore:

The WKNonZeroBeginTimeFlag key was spread across PlatformCALayerMac and PlatformCAAnimationMac,
so hide it behind getter/setter functions.

Remove lots of m_layer.get() in PlatformCAAnimationMac.

* platform/graphics/ca/mac/PlatformCAAnimationMac.h:
* platform/graphics/ca/mac/PlatformCAAnimationMac.mm:
(WebCore::hasExplicitBeginTime):
(WebCore::setHasExplicitBeginTime):
(PlatformCAAnimationMac::copy):
(PlatformCAAnimationMac::keyPath):
(PlatformCAAnimationMac::beginTime):
(PlatformCAAnimationMac::setBeginTime):
(PlatformCAAnimationMac::duration):
(PlatformCAAnimationMac::setDuration):
(PlatformCAAnimationMac::speed):
(PlatformCAAnimationMac::setSpeed):
(PlatformCAAnimationMac::timeOffset):
(PlatformCAAnimationMac::setTimeOffset):
(PlatformCAAnimationMac::repeatCount):
(PlatformCAAnimationMac::setRepeatCount):
(PlatformCAAnimationMac::autoreverses):
(PlatformCAAnimationMac::setAutoreverses):
(PlatformCAAnimationMac::fillMode):
(PlatformCAAnimationMac::setFillMode):
(PlatformCAAnimationMac::setTimingFunction):
(PlatformCAAnimationMac::copyTimingFunctionFrom):
(PlatformCAAnimationMac::isRemovedOnCompletion):
(PlatformCAAnimationMac::setRemovedOnCompletion):
(PlatformCAAnimationMac::isAdditive):
(PlatformCAAnimationMac::setAdditive):
(PlatformCAAnimationMac::valueFunction):
(PlatformCAAnimationMac::setValueFunction):
(hasNonZeroBeginTimeFlag): Deleted.
(setNonZeroBeginTimeFlag): Deleted.
* platform/graphics/ca/mac/PlatformCALayerMac.mm:
(-[WebAnimationDelegate animationDidStart:]):

Source/WebKit2:

* Shared/mac/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTextStream::operator<<):
* WebProcess/WebPage/mac/PlatformCAAnimationRemote.h:
* WebProcess/WebPage/mac/PlatformCAAnimationRemote.mm:
(-[WKAnimationDelegate animationDidStart:]):
(WebKit::PlatformCAAnimationRemote::Properties::encode):
(WebKit::PlatformCAAnimationRemote::Properties::decode):
(WebKit::PlatformCAAnimationRemote::setBeginTime):
(WebKit::addAnimationToLayer):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/ca/mac/PlatformCAAnimationMac.h
Source/WebCore/platform/graphics/ca/mac/PlatformCAAnimationMac.mm
Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm
Source/WebKit2/WebProcess/WebPage/mac/PlatformCAAnimationRemote.h
Source/WebKit2/WebProcess/WebPage/mac/PlatformCAAnimationRemote.mm

index 375a0ff..92b277c 100644 (file)
@@ -1,3 +1,54 @@
+2014-05-14  Simon Fraser  <simon.fraser@apple.com>
+
+        Clean up "has non-zero begin time" terminology in animations
+        https://bugs.webkit.org/show_bug.cgi?id=132942
+
+        Reviewed by Tim Horton.
+
+        Change the "non-zero beginTime" terminology in the platform CA animations
+        code to "explicit beginTime": this flag really means that we explicitly set
+        the beginTime of the animation, rather than let CA set the beginTime when
+        committing the animation. This flag is used for animations with negative
+        delay, and when pausing.
+        
+        The WKNonZeroBeginTimeFlag key was spread across PlatformCALayerMac and PlatformCAAnimationMac,
+        so hide it behind getter/setter functions.
+        
+        Remove lots of m_layer.get() in PlatformCAAnimationMac.
+
+        * platform/graphics/ca/mac/PlatformCAAnimationMac.h:
+        * platform/graphics/ca/mac/PlatformCAAnimationMac.mm:
+        (WebCore::hasExplicitBeginTime):
+        (WebCore::setHasExplicitBeginTime):
+        (PlatformCAAnimationMac::copy):
+        (PlatformCAAnimationMac::keyPath):
+        (PlatformCAAnimationMac::beginTime):
+        (PlatformCAAnimationMac::setBeginTime):
+        (PlatformCAAnimationMac::duration):
+        (PlatformCAAnimationMac::setDuration):
+        (PlatformCAAnimationMac::speed):
+        (PlatformCAAnimationMac::setSpeed):
+        (PlatformCAAnimationMac::timeOffset):
+        (PlatformCAAnimationMac::setTimeOffset):
+        (PlatformCAAnimationMac::repeatCount):
+        (PlatformCAAnimationMac::setRepeatCount):
+        (PlatformCAAnimationMac::autoreverses):
+        (PlatformCAAnimationMac::setAutoreverses):
+        (PlatformCAAnimationMac::fillMode):
+        (PlatformCAAnimationMac::setFillMode):
+        (PlatformCAAnimationMac::setTimingFunction):
+        (PlatformCAAnimationMac::copyTimingFunctionFrom):
+        (PlatformCAAnimationMac::isRemovedOnCompletion):
+        (PlatformCAAnimationMac::setRemovedOnCompletion):
+        (PlatformCAAnimationMac::isAdditive):
+        (PlatformCAAnimationMac::setAdditive):
+        (PlatformCAAnimationMac::valueFunction):
+        (PlatformCAAnimationMac::setValueFunction):
+        (hasNonZeroBeginTimeFlag): Deleted.
+        (setNonZeroBeginTimeFlag): Deleted.
+        * platform/graphics/ca/mac/PlatformCALayerMac.mm:
+        (-[WebAnimationDelegate animationDidStart:]):
+
 2014-05-15  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Compile all installed resources as GResources
index 16eb4e8..eca84f0 100644 (file)
@@ -31,6 +31,7 @@
 #include <wtf/RetainPtr.h>
 
 OBJC_CLASS CAMediaTimingFunction;
+OBJC_CLASS CAAnimation;
 OBJC_CLASS CAPropertyAnimation;
 OBJC_CLASS NSString;
 
@@ -42,6 +43,9 @@ NSString* toCAFillModeType(PlatformCAAnimation::FillModeType);
 NSString* toCAValueFunctionType(PlatformCAAnimation::ValueFunctionType);
 CAMediaTimingFunction* toCAMediaTimingFunction(const TimingFunction*, bool reverse);
 
+bool hasExplicitBeginTime(CAAnimation *);
+void setHasExplicitBeginTime(CAAnimation *, bool);
+
 class PlatformCAAnimationMac final : public PlatformCAAnimation {
 public:
     static PassRefPtr<PlatformCAAnimation> create(AnimationType, const String& keyPath);
index 2ea286a..f71119e 100644 (file)
 
 using namespace WebCore;
 
-// This value must be the same as in PlatformCALayerMac.mm
-static NSString * const WKNonZeroBeginTimeFlag = @"WKPlatformCAAnimationNonZeroBeginTimeFlag";
+static NSString * const WKExplicitBeginTimeFlag = @"WKPlatformCAAnimationExplicitBeginTimeFlag";
 
-static bool hasNonZeroBeginTimeFlag(const PlatformCAAnimation* animation)
+bool WebCore::hasExplicitBeginTime(CAAnimation *animation)
 {
-    return [[toPlatformCAAnimationMac(animation)->platformAnimation() valueForKey:WKNonZeroBeginTimeFlag] boolValue];
+    return [[animation valueForKey:WKExplicitBeginTimeFlag] boolValue];
 }
 
-static void setNonZeroBeginTimeFlag(PlatformCAAnimation* animation, bool value)
+void WebCore::setHasExplicitBeginTime(CAAnimation *animation, bool value)
 {
-    [toPlatformCAAnimationMac(animation)->platformAnimation() setValue:[NSNumber numberWithBool:value] forKey:WKNonZeroBeginTimeFlag];
+    [animation setValue:[NSNumber numberWithBool:value] forKey:WKExplicitBeginTimeFlag];
 }
     
 NSString* WebCore::toCAFillModeType(PlatformCAAnimation::FillModeType type)
@@ -203,7 +202,7 @@ PassRefPtr<PlatformCAAnimation> PlatformCAAnimationMac::copy() const
     animation->copyTimingFunctionFrom(this);
     animation->setValueFunction(valueFunction());
 
-    setNonZeroBeginTimeFlag(animation.get(), hasNonZeroBeginTimeFlag(this));
+    setHasExplicitBeginTime(toPlatformCAAnimationMac(animation.get())->platformAnimation(), hasExplicitBeginTime(platformAnimation()));
     
     // Copy the specific Basic or Keyframe values
     if (animationType() == Keyframe) {
@@ -225,125 +224,125 @@ PlatformAnimationRef PlatformCAAnimationMac::platformAnimation() const
 
 String PlatformCAAnimationMac::keyPath() const
 {
-    return [m_animation.get() keyPath];
+    return [m_animation keyPath];
 }
 
 CFTimeInterval PlatformCAAnimationMac::beginTime() const
 {
-    return [m_animation.get() beginTime];
+    return [m_animation beginTime];
 }
 
 void PlatformCAAnimationMac::setBeginTime(CFTimeInterval value)
 {
-    [m_animation.get() setBeginTime:value];
+    [m_animation setBeginTime:value];
     
     // Also set a flag to tell us if we've passed in a 0 value. 
     // The flag is needed because later beginTime will get changed
     // to the time at which it fired and we need to know whether
     // or not it was 0 to begin with.
     if (value)
-        setNonZeroBeginTimeFlag(this, true);
+        setHasExplicitBeginTime(m_animation.get(), true);
 }
 
 CFTimeInterval PlatformCAAnimationMac::duration() const
 {
-    return [m_animation.get() duration];
+    return [m_animation duration];
 }
 
 void PlatformCAAnimationMac::setDuration(CFTimeInterval value)
 {
-    [m_animation.get() setDuration:value];
+    [m_animation setDuration:value];
 }
 
 float PlatformCAAnimationMac::speed() const
 {
-    return [m_animation.get() speed];
+    return [m_animation speed];
 }
 
 void PlatformCAAnimationMac::setSpeed(float value)
 {
-    [m_animation.get() setSpeed:value];
+    [m_animation setSpeed:value];
 }
 
 CFTimeInterval PlatformCAAnimationMac::timeOffset() const
 {
-    return [m_animation.get() timeOffset];
+    return [m_animation timeOffset];
 }
 
 void PlatformCAAnimationMac::setTimeOffset(CFTimeInterval value)
 {
-    [m_animation.get() setTimeOffset:value];
+    [m_animation setTimeOffset:value];
 }
 
 float PlatformCAAnimationMac::repeatCount() const
 {
-    return [m_animation.get() repeatCount];
+    return [m_animation repeatCount];
 }
 
 void PlatformCAAnimationMac::setRepeatCount(float value)
 {
-    [m_animation.get() setRepeatCount:value];
+    [m_animation setRepeatCount:value];
 }
 
 bool PlatformCAAnimationMac::autoreverses() const
 {
-    return [m_animation.get() autoreverses];
+    return [m_animation autoreverses];
 }
 
 void PlatformCAAnimationMac::setAutoreverses(bool value)
 {
-    [m_animation.get() setAutoreverses:value];
+    [m_animation setAutoreverses:value];
 }
 
 PlatformCAAnimation::FillModeType PlatformCAAnimationMac::fillMode() const
 {
-    return fromCAFillModeType([m_animation.get() fillMode]);
+    return fromCAFillModeType([m_animation fillMode]);
 }
 
 void PlatformCAAnimationMac::setFillMode(FillModeType value)
 {
-    [m_animation.get() setFillMode:toCAFillModeType(value)];
+    [m_animation setFillMode:toCAFillModeType(value)];
 }
 
 void PlatformCAAnimationMac::setTimingFunction(const TimingFunction* value, bool reverse)
 {
-    [m_animation.get() setTimingFunction:toCAMediaTimingFunction(value, reverse)];
+    [m_animation setTimingFunction:toCAMediaTimingFunction(value, reverse)];
 }
 
 void PlatformCAAnimationMac::copyTimingFunctionFrom(const PlatformCAAnimation* value)
 {
-    [m_animation.get() setTimingFunction:[toPlatformCAAnimationMac(value)->m_animation.get() timingFunction]];
+    [m_animation setTimingFunction:[toPlatformCAAnimationMac(value)->m_animation.get() timingFunction]];
 }
 
 bool PlatformCAAnimationMac::isRemovedOnCompletion() const
 {
-    return [m_animation.get() isRemovedOnCompletion];
+    return [m_animation isRemovedOnCompletion];
 }
 
 void PlatformCAAnimationMac::setRemovedOnCompletion(bool value)
 {
-    [m_animation.get() setRemovedOnCompletion:value];
+    [m_animation setRemovedOnCompletion:value];
 }
 
 bool PlatformCAAnimationMac::isAdditive() const
 {
-    return [m_animation.get() isAdditive];
+    return [m_animation isAdditive];
 }
 
 void PlatformCAAnimationMac::setAdditive(bool value)
 {
-    [m_animation.get() setAdditive:value];
+    [m_animation setAdditive:value];
 }
 
 PlatformCAAnimation::ValueFunctionType PlatformCAAnimationMac::valueFunction() const
 {
-    CAValueFunction* vf = [m_animation.get() valueFunction];
+    CAValueFunction* vf = [m_animation valueFunction];
     return fromCAValueFunctionType([vf name]);
 }
 
 void PlatformCAAnimationMac::setValueFunction(ValueFunctionType value)
 {
-    [m_animation.get() setValueFunction:[CAValueFunction functionWithName:toCAValueFunctionType(value)]];
+    [m_animation setValueFunction:[CAValueFunction functionWithName:toCAValueFunctionType(value)]];
 }
 
 void PlatformCAAnimationMac::setFromValue(float value)
index 40580d9..ab518ce 100644 (file)
@@ -86,9 +86,6 @@ PlatformCALayer* PlatformCALayer::platformCALayer(void* platformLayer)
     return platformCALayer;
 }
 
-// This value must be the same as in PlatformCAAnimationMac.mm
-static NSString * const WKNonZeroBeginTimeFlag = @"WKPlatformCAAnimationNonZeroBeginTimeFlag";
-
 static double mediaTimeToCurrentTime(CFTimeInterval t)
 {
     return monotonicallyIncreasingTime() + t - CACurrentMediaTime();
@@ -111,11 +108,8 @@ static double mediaTimeToCurrentTime(CFTimeInterval t)
 #if PLATFORM(IOS)
     WebThreadLock();
 #endif
-    // hasNonZeroBeginTime is stored in a key in the animation
-    bool hasNonZeroBeginTime = [[animation valueForKey:WKNonZeroBeginTimeFlag] boolValue];
     CFTimeInterval startTime;
-
-    if (hasNonZeroBeginTime) {
+    if (hasExplicitBeginTime(animation)) {
         // We don't know what time CA used to commit the animation, so just use the current time
         // (even though this will be slightly off).
         startTime = mediaTimeToCurrentTime(CACurrentMediaTime());
index d57e162..e53f4bd 100644 (file)
@@ -1,3 +1,26 @@
+2014-05-14  Simon Fraser  <simon.fraser@apple.com>
+
+        Clean up "has non-zero begin time" terminology in animations
+        https://bugs.webkit.org/show_bug.cgi?id=132942
+
+        Reviewed by Tim Horton.
+
+        Change the "non-zero beginTime" terminology in the platform CA animations
+        code to "explicit beginTime": this flag really means that we explicitly set
+        the beginTime of the animation, rather than let CA set the beginTime when
+        committing the animation. This flag is used for animations with negative
+        delay, and when pausing.
+
+        * Shared/mac/RemoteLayerTreeTransaction.mm:
+        (WebKit::RemoteLayerTreeTextStream::operator<<):
+        * WebProcess/WebPage/mac/PlatformCAAnimationRemote.h:
+        * WebProcess/WebPage/mac/PlatformCAAnimationRemote.mm:
+        (-[WKAnimationDelegate animationDidStart:]):
+        (WebKit::PlatformCAAnimationRemote::Properties::encode):
+        (WebKit::PlatformCAAnimationRemote::Properties::decode):
+        (WebKit::PlatformCAAnimationRemote::setBeginTime):
+        (WebKit::addAnimationToLayer):
+
 2014-05-15  Tim Horton  <timothy_horton@apple.com>
 
         [iOS] Incremental updates during scroll-to-top shouldn’t count as “stable” updates
index d57ffe4..1b87ae4 100644 (file)
@@ -885,8 +885,8 @@ RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(const PlatformC
     if (animation.reverseTimingFunctions)
         dumpProperty(ts, "reverseTimingFunctions", animation.reverseTimingFunctions);
 
-    if (animation.hasNonZeroBeginTime)
-        dumpProperty(ts, "hasNonZeroBeginTime", animation.hasNonZeroBeginTime);
+    if (animation.hasExplicitBeginTime)
+        dumpProperty(ts, "hasExplicitBeginTime", animation.hasExplicitBeginTime);
 
     ts << "\n";
     ts.increaseIndent();
index 877a3e9..fc31ff0 100644 (file)
@@ -254,7 +254,7 @@ public:
             , removedOnCompletion(true)
             , additive(false)
             , reverseTimingFunctions(false)
-            , hasNonZeroBeginTime(false)
+            , hasExplicitBeginTime(false)
         {
         }
 
@@ -277,7 +277,7 @@ public:
         bool removedOnCompletion;
         bool additive;
         bool reverseTimingFunctions;
-        bool hasNonZeroBeginTime;
+        bool hasExplicitBeginTime;
 
         // For basic animations, these vectors have two entries. For keyframe animations, two or more.
         // timingFunctions has n-1 entries.
index 1a428b4..2de8154 100644 (file)
@@ -46,7 +46,7 @@ static double mediaTimeToCurrentTime(CFTimeInterval t)
     return monotonicallyIncreasingTime() + t - CACurrentMediaTime();
 }
 
-static NSString * const WKNonZeroBeginTimeFlag = @"WKPlatformCAAnimationNonZeroBeginTimeFlag";
+static NSString * const WKExplicitBeginTimeFlag = @"WKPlatformCAAnimationExplicitBeginTimeFlag";
 
 @interface WKAnimationDelegate : NSObject {
     GraphicsLayer::PlatformLayerID _layerID;
@@ -69,10 +69,10 @@ static NSString * const WKNonZeroBeginTimeFlag = @"WKPlatformCAAnimationNonZeroB
 
 - (void)animationDidStart:(CAAnimation *)animation
 {
-    bool hasNonZeroBeginTime = [[animation valueForKey:WKNonZeroBeginTimeFlag] boolValue];
+    bool hasExplicitBeginTime = [[animation valueForKey:WKExplicitBeginTimeFlag] boolValue];
     CFTimeInterval startTime;
 
-    if (hasNonZeroBeginTime) {
+    if (hasExplicitBeginTime) {
         // We don't know what time CA used to commit the animation, so just use the current time
         // (even though this will be slightly off).
         startTime = mediaTimeToCurrentTime(CACurrentMediaTime());
@@ -157,7 +157,7 @@ void PlatformCAAnimationRemote::Properties::encode(IPC::ArgumentEncoder& encoder
     encoder << removedOnCompletion;
     encoder << additive;
     encoder << reverseTimingFunctions;
-    encoder << hasNonZeroBeginTime;
+    encoder << hasExplicitBeginTime;
     
     encoder << keyValues;
     encoder << keyTimes;
@@ -221,7 +221,7 @@ bool PlatformCAAnimationRemote::Properties::decode(IPC::ArgumentDecoder& decoder
     if (!decoder.decode(properties.reverseTimingFunctions))
         return false;
 
-    if (!decoder.decode(properties.hasNonZeroBeginTime))
+    if (!decoder.decode(properties.hasExplicitBeginTime))
         return false;
 
     if (!decoder.decode(properties.keyValues))
@@ -308,7 +308,7 @@ void PlatformCAAnimationRemote::setBeginTime(CFTimeInterval value)
     // to the time at which it fired and we need to know whether
     // or not it was 0 to begin with.
     if (value)
-        m_properties.hasNonZeroBeginTime = value;
+        m_properties.hasExplicitBeginTime = value;
 }
 
 CFTimeInterval PlatformCAAnimationRemote::duration() const
@@ -718,8 +718,8 @@ static void addAnimationToLayer(CALayer *layer, RemoteLayerTreeHost* layerTreeHo
     if (properties.valueFunction != PlatformCAAnimation::NoValueFunction)
         [caAnimation setValueFunction:[CAValueFunction functionWithName:toCAValueFunctionType(properties.valueFunction)]];
     
-    if (properties.hasNonZeroBeginTime)
-        [caAnimation.get()  setValue:@YES forKey:WKNonZeroBeginTimeFlag];
+    if (properties.hasExplicitBeginTime)
+        [caAnimation.get()  setValue:@YES forKey:WKExplicitBeginTimeFlag];
     
     if (layerTreeHost) {
         GraphicsLayer::PlatformLayerID layerID = RemoteLayerTreeHost::layerID(layer);