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
--- 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_) */