Title: [113281] trunk/Source/WebCore
Revision
113281
Author
[email protected]
Date
2012-04-04 20:08:10 -0700 (Wed, 04 Apr 2012)

Log Message

[Part 4] We should use CSSPropertyID rather than integers when manipulating CSS property ids.
https://bugs.webkit.org/show_bug.cgi?id=83224

Reviewed by Tony Chang.

CSSPropertyID enum holds all the CSS property ids but many parts of WebKit treat the ids
as integers. While it's not incorrect it is nicer to use the enum as a parameter of
functions manipulating property ids, as we ensure that the value passed will be an
existing value. This patch clean up some remaining part of code.

No new tests : There should be no behavior change in this patch.

* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::collectMatchingRulesForList):
* page/animation/AnimationBase.h:
(WebCore::AnimationBase::affectsProperty):
(WebCore::AnimationBase::isAnimatingProperty):
* page/animation/CompositeAnimation.cpp:
(WebCore::CompositeAnimation::getAnimationForProperty):
(WebCore::CompositeAnimation::overrideImplicitAnimations):
(WebCore::CompositeAnimation::resumeOverriddenImplicitAnimations):
(WebCore::CompositeAnimation::isAnimatingProperty):
* page/animation/CompositeAnimation.h:
(CompositeAnimation):
* page/animation/ImplicitAnimation.cpp:
(WebCore::ImplicitAnimation::affectsProperty):
* page/animation/ImplicitAnimation.h:
(WebCore::ImplicitAnimation::transitionProperty):
(WebCore::ImplicitAnimation::animatingProperty):
(ImplicitAnimation):
* page/animation/KeyframeAnimation.cpp:
(WebCore::KeyframeAnimation::fetchIntervalEndpointsForProperty):
(WebCore::KeyframeAnimation::hasAnimationForProperty):
(WebCore::KeyframeAnimation::overrideAnimations):
(WebCore::KeyframeAnimation::resumeOverriddenAnimations):
(WebCore::KeyframeAnimation::affectsProperty):
* page/animation/KeyframeAnimation.h:
(KeyframeAnimation):
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::transitionPaused):
(WebCore::RenderLayerBacking::transitionFinished):
(WebCore::RenderLayerBacking::graphicsLayerToCSSProperty):
(WebCore::RenderLayerBacking::cssToGraphicsLayerProperty):
* rendering/RenderLayerBacking.h:
(RenderLayerBacking):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (113280 => 113281)


--- trunk/Source/WebCore/ChangeLog	2012-04-05 02:50:46 UTC (rev 113280)
+++ trunk/Source/WebCore/ChangeLog	2012-04-05 03:08:10 UTC (rev 113281)
@@ -1,3 +1,51 @@
+2012-04-04  Alexis Menard  <[email protected]>
+
+        [Part 4] We should use CSSPropertyID rather than integers when manipulating CSS property ids.
+        https://bugs.webkit.org/show_bug.cgi?id=83224
+
+        Reviewed by Tony Chang.
+
+        CSSPropertyID enum holds all the CSS property ids but many parts of WebKit treat the ids
+        as integers. While it's not incorrect it is nicer to use the enum as a parameter of
+        functions manipulating property ids, as we ensure that the value passed will be an
+        existing value. This patch clean up some remaining part of code.
+
+        No new tests : There should be no behavior change in this patch.
+
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::collectMatchingRulesForList):
+        * page/animation/AnimationBase.h:
+        (WebCore::AnimationBase::affectsProperty):
+        (WebCore::AnimationBase::isAnimatingProperty):
+        * page/animation/CompositeAnimation.cpp:
+        (WebCore::CompositeAnimation::getAnimationForProperty):
+        (WebCore::CompositeAnimation::overrideImplicitAnimations):
+        (WebCore::CompositeAnimation::resumeOverriddenImplicitAnimations):
+        (WebCore::CompositeAnimation::isAnimatingProperty):
+        * page/animation/CompositeAnimation.h:
+        (CompositeAnimation):
+        * page/animation/ImplicitAnimation.cpp:
+        (WebCore::ImplicitAnimation::affectsProperty):
+        * page/animation/ImplicitAnimation.h:
+        (WebCore::ImplicitAnimation::transitionProperty):
+        (WebCore::ImplicitAnimation::animatingProperty):
+        (ImplicitAnimation):
+        * page/animation/KeyframeAnimation.cpp:
+        (WebCore::KeyframeAnimation::fetchIntervalEndpointsForProperty):
+        (WebCore::KeyframeAnimation::hasAnimationForProperty):
+        (WebCore::KeyframeAnimation::overrideAnimations):
+        (WebCore::KeyframeAnimation::resumeOverriddenAnimations):
+        (WebCore::KeyframeAnimation::affectsProperty):
+        * page/animation/KeyframeAnimation.h:
+        (KeyframeAnimation):
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::transitionPaused):
+        (WebCore::RenderLayerBacking::transitionFinished):
+        (WebCore::RenderLayerBacking::graphicsLayerToCSSProperty):
+        (WebCore::RenderLayerBacking::cssToGraphicsLayerProperty):
+        * rendering/RenderLayerBacking.h:
+        (RenderLayerBacking):
+
 2012-04-04  Rafael Weinstein  <[email protected]>
 
         [MutationObservers] implement takeRecords()

Modified: trunk/Source/WebCore/css/CSSStyleSelector.cpp (113280 => 113281)


--- trunk/Source/WebCore/css/CSSStyleSelector.cpp	2012-04-05 02:50:46 UTC (rev 113280)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp	2012-04-05 03:08:10 UTC (rev 113281)
@@ -1678,7 +1678,7 @@
     if (StylePropertySet* styleDeclaration = keyframe->properties()) {
         unsigned propertyCount = styleDeclaration->propertyCount();
         for (unsigned i = 0; i < propertyCount; ++i) {
-            int property = styleDeclaration->propertyAt(i).id();
+            CSSPropertyID property = styleDeclaration->propertyAt(i).id();
             // Timing-function within keyframes is special, because it is not animated; it just
             // describes the timing function between this keyframe and the next.
             if (property != CSSPropertyWebkitAnimationTimingFunction)

Modified: trunk/Source/WebCore/page/animation/AnimationBase.h (113280 => 113281)


--- trunk/Source/WebCore/page/animation/AnimationBase.h	2012-04-05 02:50:46 UTC (rev 113280)
+++ trunk/Source/WebCore/page/animation/AnimationBase.h	2012-04-05 03:08:10 UTC (rev 113281)
@@ -153,9 +153,9 @@
     virtual bool overridden() const { return false; }
 
     // Does this animation/transition involve the given property?
-    virtual bool affectsProperty(int /*property*/) const { return false; }
+    virtual bool affectsProperty(CSSPropertyID /*property*/) const { return false; }
 
-    bool isAnimatingProperty(int property, bool acceleratedOnly, bool isRunningNow) const
+    bool isAnimatingProperty(CSSPropertyID property, bool acceleratedOnly, bool isRunningNow) const
     {
         if (acceleratedOnly && !m_isAccelerated)
             return false;

Modified: trunk/Source/WebCore/page/animation/CompositeAnimation.cpp (113280 => 113281)


--- trunk/Source/WebCore/page/animation/CompositeAnimation.cpp	2012-04-05 02:50:46 UTC (rev 113280)
+++ trunk/Source/WebCore/page/animation/CompositeAnimation.cpp	2012-04-05 03:08:10 UTC (rev 113281)
@@ -379,7 +379,7 @@
     return minT;
 }
 
-PassRefPtr<KeyframeAnimation> CompositeAnimation::getAnimationForProperty(int property) const
+PassRefPtr<KeyframeAnimation> CompositeAnimation::getAnimationForProperty(CSSPropertyID property) const
 {
     RefPtr<KeyframeAnimation> retval;
     
@@ -450,7 +450,7 @@
     }
 }
 
-void CompositeAnimation::overrideImplicitAnimations(int property)
+void CompositeAnimation::overrideImplicitAnimations(CSSPropertyID property)
 {
     CSSPropertyTransitionsMap::const_iterator end = m_transitions.end();
     if (!m_transitions.isEmpty()) {
@@ -462,7 +462,7 @@
     }
 }
 
-void CompositeAnimation::resumeOverriddenImplicitAnimations(int property)
+void CompositeAnimation::resumeOverriddenImplicitAnimations(CSSPropertyID property)
 {
     if (!m_transitions.isEmpty()) {
         CSSPropertyTransitionsMap::const_iterator end = m_transitions.end();
@@ -474,7 +474,7 @@
     }
 }
 
-bool CompositeAnimation::isAnimatingProperty(int property, bool acceleratedOnly, bool isRunningNow) const
+bool CompositeAnimation::isAnimatingProperty(CSSPropertyID property, bool acceleratedOnly, bool isRunningNow) const
 {
     if (!m_keyframeAnimations.isEmpty()) {
         m_keyframeAnimations.checkConsistency();

Modified: trunk/Source/WebCore/page/animation/CompositeAnimation.h (113280 => 113281)


--- trunk/Source/WebCore/page/animation/CompositeAnimation.h	2012-04-05 02:50:46 UTC (rev 113280)
+++ trunk/Source/WebCore/page/animation/CompositeAnimation.h	2012-04-05 03:08:10 UTC (rev 113281)
@@ -70,12 +70,12 @@
     bool hasAnimations() const  { return !m_transitions.isEmpty() || !m_keyframeAnimations.isEmpty(); }
 
     void setAnimating(bool);
-    bool isAnimatingProperty(int property, bool acceleratedOnly, bool isRunningNow) const;
+    bool isAnimatingProperty(CSSPropertyID, bool acceleratedOnly, bool isRunningNow) const;
 
-    PassRefPtr<KeyframeAnimation> getAnimationForProperty(int property) const;
+    PassRefPtr<KeyframeAnimation> getAnimationForProperty(CSSPropertyID) const;
 
-    void overrideImplicitAnimations(int property);
-    void resumeOverriddenImplicitAnimations(int property);
+    void overrideImplicitAnimations(CSSPropertyID);
+    void resumeOverriddenImplicitAnimations(CSSPropertyID);
 
     bool pauseAnimationAtTime(const AtomicString& name, double t);
     bool pauseTransitionAtTime(CSSPropertyID, double);

Modified: trunk/Source/WebCore/page/animation/ImplicitAnimation.cpp (113280 => 113281)


--- trunk/Source/WebCore/page/animation/ImplicitAnimation.cpp	2012-04-05 02:50:46 UTC (rev 113280)
+++ trunk/Source/WebCore/page/animation/ImplicitAnimation.cpp	2012-04-05 03:08:10 UTC (rev 113281)
@@ -222,7 +222,7 @@
     updateStateMachine(m_overridden ? AnimationStateInputPauseOverride : AnimationStateInputResumeOverride, -1);
 }
 
-bool ImplicitAnimation::affectsProperty(int property) const
+bool ImplicitAnimation::affectsProperty(CSSPropertyID property) const
 {
     return (m_animatingProperty == property);
 }

Modified: trunk/Source/WebCore/page/animation/ImplicitAnimation.h (113280 => 113281)


--- trunk/Source/WebCore/page/animation/ImplicitAnimation.h	2012-04-05 02:50:46 UTC (rev 113280)
+++ trunk/Source/WebCore/page/animation/ImplicitAnimation.h	2012-04-05 03:08:10 UTC (rev 113281)
@@ -44,8 +44,8 @@
         return adoptRef(new ImplicitAnimation(animation, animatingProperty, renderer, compositeAnimation, fromStyle));
     };
     
-    int transitionProperty() const { return m_transitionProperty; }
-    int animatingProperty() const { return m_animatingProperty; }
+    CSSPropertyID transitionProperty() const { return m_transitionProperty; }
+    CSSPropertyID animatingProperty() const { return m_animatingProperty; }
 
     virtual void onAnimationEnd(double elapsedTime);
     virtual bool startAnimation(double timeOffset);
@@ -59,7 +59,7 @@
     void setOverridden(bool);
     virtual bool overridden() const { return m_overridden; }
 
-    virtual bool affectsProperty(int) const;
+    virtual bool affectsProperty(CSSPropertyID) const;
 
     bool hasStyle() const { return m_fromStyle && m_toStyle; }
 

Modified: trunk/Source/WebCore/page/animation/KeyframeAnimation.cpp (113280 => 113281)


--- trunk/Source/WebCore/page/animation/KeyframeAnimation.cpp	2012-04-05 02:50:46 UTC (rev 113280)
+++ trunk/Source/WebCore/page/animation/KeyframeAnimation.cpp	2012-04-05 03:08:10 UTC (rev 113281)
@@ -81,7 +81,7 @@
     return 0;
 }
 
-void KeyframeAnimation::fetchIntervalEndpointsForProperty(int property, const RenderStyle*& fromStyle, const RenderStyle*& toStyle, double& prog) const
+void KeyframeAnimation::fetchIntervalEndpointsForProperty(CSSPropertyID property, const RenderStyle*& fromStyle, const RenderStyle*& toStyle, double& prog) const
 {
     // Find the first key
     double elapsedTime = getElapsedTime();
@@ -229,7 +229,7 @@
     }
 }
 
-bool KeyframeAnimation::hasAnimationForProperty(int property) const
+bool KeyframeAnimation::hasAnimationForProperty(CSSPropertyID property) const
 {
     return m_keyframes.containsProperty(property);
 }
@@ -351,7 +351,7 @@
     // This will override implicit animations that match the properties in the keyframe animation
     HashSet<int>::const_iterator end = m_keyframes.endProperties();
     for (HashSet<int>::const_iterator it = m_keyframes.beginProperties(); it != end; ++it)
-        compositeAnimation()->overrideImplicitAnimations(*it);
+        compositeAnimation()->overrideImplicitAnimations(static_cast<CSSPropertyID>(*it));
 }
 
 void KeyframeAnimation::resumeOverriddenAnimations()
@@ -359,10 +359,10 @@
     // This will resume overridden implicit animations
     HashSet<int>::const_iterator end = m_keyframes.endProperties();
     for (HashSet<int>::const_iterator it = m_keyframes.beginProperties(); it != end; ++it)
-        compositeAnimation()->resumeOverriddenImplicitAnimations(*it);
+        compositeAnimation()->resumeOverriddenImplicitAnimations(static_cast<CSSPropertyID>(*it));
 }
 
-bool KeyframeAnimation::affectsProperty(int property) const
+bool KeyframeAnimation::affectsProperty(CSSPropertyID property) const
 {
     return m_keyframes.containsProperty(property);
 }

Modified: trunk/Source/WebCore/page/animation/KeyframeAnimation.h (113280 => 113281)


--- trunk/Source/WebCore/page/animation/KeyframeAnimation.h	2012-04-05 02:50:46 UTC (rev 113280)
+++ trunk/Source/WebCore/page/animation/KeyframeAnimation.h	2012-04-05 03:08:10 UTC (rev 113281)
@@ -53,7 +53,7 @@
     int index() const { return m_index; }
     void setIndex(int i) { m_index = i; }
 
-    bool hasAnimationForProperty(int property) const;
+    bool hasAnimationForProperty(CSSPropertyID) const;
     
     void setUnanimatedStyle(PassRefPtr<RenderStyle> style) { m_unanimatedStyle = style; }
     RenderStyle* unanimatedStyle() const { return m_unanimatedStyle.get(); }
@@ -74,7 +74,7 @@
     bool shouldSendEventForListener(Document::ListenerType inListenerType) const;
     bool sendAnimationEvent(const AtomicString&, double elapsedTime);
 
-    virtual bool affectsProperty(int) const;
+    virtual bool affectsProperty(CSSPropertyID) const;
 
     void validateTransformFunctionList();
 #if ENABLE(CSS_FILTERS)
@@ -86,7 +86,7 @@
     virtual ~KeyframeAnimation();
     
     // Get the styles for the given property surrounding the current animation time and the progress between them.
-    void fetchIntervalEndpointsForProperty(int property, const RenderStyle*& fromStyle, const RenderStyle*& toStyle, double& progress) const;
+    void fetchIntervalEndpointsForProperty(CSSPropertyID, const RenderStyle*& fromStyle, const RenderStyle*& toStyle, double& progress) const;
 
     // The keyframes that we are blending.
     KeyframeList m_keyframes;

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (113280 => 113281)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2012-04-05 02:50:46 UTC (rev 113280)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2012-04-05 03:08:10 UTC (rev 113281)
@@ -1384,14 +1384,14 @@
 #endif
 }
 
-void RenderLayerBacking::transitionPaused(double timeOffset, int property)
+void RenderLayerBacking::transitionPaused(double timeOffset, CSSPropertyID property)
 {
     AnimatedPropertyID animatedProperty = cssToGraphicsLayerProperty(property);
     if (animatedProperty != AnimatedPropertyInvalid)
         m_graphicsLayer->pauseAnimation(GraphicsLayer::animationNameForTransition(animatedProperty), timeOffset);
 }
 
-void RenderLayerBacking::transitionFinished(int property)
+void RenderLayerBacking::transitionFinished(CSSPropertyID property)
 {
     AnimatedPropertyID animatedProperty = cssToGraphicsLayerProperty(property);
     if (animatedProperty != AnimatedPropertyInvalid)
@@ -1430,9 +1430,9 @@
     m_compositedBounds = bounds;
 
 }
-int RenderLayerBacking::graphicsLayerToCSSProperty(AnimatedPropertyID property)
+CSSPropertyID RenderLayerBacking::graphicsLayerToCSSProperty(AnimatedPropertyID property)
 {
-    int cssProperty = CSSPropertyInvalid;
+    CSSPropertyID cssProperty = CSSPropertyInvalid;
     switch (property) {
         case AnimatedPropertyWebkitTransform:
             cssProperty = CSSPropertyWebkitTransform;
@@ -1456,7 +1456,7 @@
     return cssProperty;
 }
 
-AnimatedPropertyID RenderLayerBacking::cssToGraphicsLayerProperty(int cssProperty)
+AnimatedPropertyID RenderLayerBacking::cssToGraphicsLayerProperty(CSSPropertyID cssProperty)
 {
     switch (cssProperty) {
         case CSSPropertyWebkitTransform:
@@ -1469,7 +1469,9 @@
         case CSSPropertyWebkitFilter:
             return AnimatedPropertyWebkitFilter;
 #endif
-        // It's fine if we see other css properties here; they are just not accelerated.
+        default:
+            // It's fine if we see other css properties here; they are just not accelerated.
+            break;
     }
     return AnimatedPropertyInvalid;
 }

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.h (113280 => 113281)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.h	2012-04-05 02:50:46 UTC (rev 113280)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.h	2012-04-05 03:08:10 UTC (rev 113281)
@@ -106,8 +106,8 @@
 
     // Interface to start, finish, suspend and resume animations and transitions
     bool startTransition(double, CSSPropertyID, const RenderStyle* fromStyle, const RenderStyle* toStyle);
-    void transitionPaused(double timeOffset, int property);
-    void transitionFinished(int property);
+    void transitionPaused(double timeOffset, CSSPropertyID);
+    void transitionFinished(CSSPropertyID);
 
     bool startAnimation(double timeOffset, const Animation* anim, const KeyframeList& keyframes);
     void animationPaused(double timeOffset, const String& name);
@@ -211,8 +211,8 @@
 
     void paintIntoLayer(RenderLayer* rootLayer, GraphicsContext*, const IntRect& paintDirtyRect, PaintBehavior, GraphicsLayerPaintingPhase, RenderObject* paintingRoot);
 
-    static int graphicsLayerToCSSProperty(AnimatedPropertyID);
-    static AnimatedPropertyID cssToGraphicsLayerProperty(int);
+    static CSSPropertyID graphicsLayerToCSSProperty(AnimatedPropertyID);
+    static AnimatedPropertyID cssToGraphicsLayerProperty(CSSPropertyID);
 
 #ifndef NDEBUG
     String nameForLayer() const;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to