Bug 1343753 - Part 1: Make GetTransitionKeyframes as a local static function. draft
authorBoris Chiou <boris.chiou@gmail.com>
Thu, 09 Mar 2017 13:35:43 +0800
changeset 561123 9a8ba4e4d1206ca43137a103cbc2dc0702855415
parent 561122 e75bcbdc21f47fd845f8f2e45a8967f026e1bf46
child 561124 c94ed972ac65869b4024487df7bec785df447067
push id53643
push userbmo:boris.chiou@gmail.com
push dateWed, 12 Apr 2017 08:51:47 +0000
bugs1343753
milestone55.0a1
Bug 1343753 - Part 1: Make GetTransitionKeyframes as a local static function. GetTransitionKeyframes is a simple helper function, which is only used by ConsiderInitiatingTransition, so let's make it static to reduce the time to revise the header. MozReview-Commit-ID: HlztPxz8sMJ
layout/style/nsTransitionManager.cpp
layout/style/nsTransitionManager.h
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -717,16 +717,54 @@ nsTransitionManager::UpdateTransitions(
       aElementTransitions->Destroy();
       aElementTransitions = nullptr;
     }
   }
 
   return startedAny;
 }
 
+static Keyframe&
+AppendKeyframe(double aOffset,
+               nsCSSPropertyID aProperty,
+               StyleAnimationValue&& aValue,
+               nsTArray<Keyframe>& aKeyframes)
+{
+  Keyframe& frame = *aKeyframes.AppendElement();
+  frame.mOffset.emplace(aOffset);
+  PropertyValuePair& pv = *frame.mPropertyValues.AppendElement();
+  pv.mProperty = aProperty;
+  DebugOnly<bool> uncomputeResult =
+    StyleAnimationValue::UncomputeValue(aProperty, Move(aValue), pv.mValue);
+  MOZ_ASSERT(uncomputeResult,
+             "Unable to get specified value from computed value");
+  return frame;
+}
+
+static nsTArray<Keyframe>
+GetTransitionKeyframes(nsCSSPropertyID aProperty,
+                       nsStyleContext* aStyleContext,
+                       StyleAnimationValue&& aStartValue,
+                       StyleAnimationValue&& aEndValue,
+                       const nsTimingFunction& aTimingFunction)
+{
+  nsTArray<Keyframe> keyframes(2);
+
+  Keyframe& fromFrame = AppendKeyframe(0.0, aProperty, Move(aStartValue),
+                                       keyframes);
+  if (aTimingFunction.mType != nsTimingFunction::Type::Linear) {
+    fromFrame.mTimingFunction.emplace();
+    fromFrame.mTimingFunction->Init(aTimingFunction);
+  }
+
+  AppendKeyframe(1.0, aProperty, Move(aEndValue), keyframes);
+
+  return keyframes;
+}
+
 void
 nsTransitionManager::ConsiderInitiatingTransition(
   nsCSSPropertyID aProperty,
   const StyleTransition& aTransition,
   dom::Element* aElement,
   CSSTransitionCollection*& aElementTransitions,
   nsStyleContext* aOldStyleContext,
   nsStyleContext* aNewStyleContext,
@@ -993,53 +1031,16 @@ nsTransitionManager::ConsiderInitiatingT
   if (effectSet) {
     effectSet->UpdateAnimationGeneration(mPresContext);
   }
 
   *aStartedAny = true;
   aWhichStarted->AddProperty(aProperty);
 }
 
-static Keyframe&
-AppendKeyframe(double aOffset, nsCSSPropertyID aProperty,
-               StyleAnimationValue&& aValue, nsTArray<Keyframe>& aKeyframes)
-{
-  Keyframe& frame = *aKeyframes.AppendElement();
-  frame.mOffset.emplace(aOffset);
-  PropertyValuePair& pv = *frame.mPropertyValues.AppendElement();
-  pv.mProperty = aProperty;
-  DebugOnly<bool> uncomputeResult =
-    StyleAnimationValue::UncomputeValue(aProperty, Move(aValue), pv.mValue);
-  MOZ_ASSERT(uncomputeResult,
-              "Unable to get specified value from computed value");
-  return frame;
-}
-
-nsTArray<Keyframe>
-nsTransitionManager::GetTransitionKeyframes(
-    nsStyleContext* aStyleContext,
-    nsCSSPropertyID aProperty,
-    StyleAnimationValue&& aStartValue,
-    StyleAnimationValue&& aEndValue,
-    const nsTimingFunction& aTimingFunction)
-{
-  nsTArray<Keyframe> keyframes(2);
-
-  Keyframe& fromFrame = AppendKeyframe(0.0, aProperty, Move(aStartValue),
-                                       keyframes);
-  if (aTimingFunction.mType != nsTimingFunction::Type::Linear) {
-    fromFrame.mTimingFunction.emplace();
-    fromFrame.mTimingFunction->Init(aTimingFunction);
-  }
-
-  AppendKeyframe(1.0, aProperty, Move(aEndValue), keyframes);
-
-  return keyframes;
-}
-
 void
 nsTransitionManager::PruneCompletedTransitions(mozilla::dom::Element* aElement,
                                                CSSPseudoElementType aPseudoType,
                                                nsStyleContext* aNewStyleContext)
 {
   CSSTransitionCollection* collection =
     CSSTransitionCollection::GetAnimationCollection(aElement, aPseudoType);
   if (!collection) {
--- a/layout/style/nsTransitionManager.h
+++ b/layout/style/nsTransitionManager.h
@@ -427,22 +427,15 @@ protected:
                                const mozilla::StyleTransition& aTransition,
                                mozilla::dom::Element* aElement,
                                CSSTransitionCollection*& aElementTransitions,
                                nsStyleContext* aOldStyleContext,
                                nsStyleContext* aNewStyleContext,
                                bool* aStartedAny,
                                nsCSSPropertyIDSet* aWhichStarted);
 
-  nsTArray<mozilla::Keyframe> GetTransitionKeyframes(
-    nsStyleContext* aStyleContext,
-    nsCSSPropertyID aProperty,
-    mozilla::StyleAnimationValue&& aStartValue,
-    mozilla::StyleAnimationValue&& aEndValue,
-    const nsTimingFunction& aTimingFunction);
-
   bool mInAnimationOnlyStyleUpdate;
 
   mozilla::DelayedEventDispatcher<mozilla::TransitionEventInfo>
       mEventDispatcher;
 };
 
 #endif /* !defined(nsTransitionManager_h_) */