Bug 1341372 - Part 3: Add FFIs for Triggering transitions.
We add these FFIs for retrieving the existing transitions, so we can
reduce the false alarms of triggering transitions from Servo:
1. Gecko_ElementTransitions_Length
2. Gecko_ElementTransitions_PropertyAt
3. Gecko_ElementTransitions_EndValueAt
MozReview-Commit-ID: 9eLd8fxmNd9
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -540,16 +540,81 @@ Gecko_ElementHasCSSTransitions(RawGeckoE
CSSEnabledState::eForAllContent);
nsTransitionManager::CSSTransitionCollection* collection =
nsTransitionManager::CSSTransitionCollection
::GetAnimationCollection(aElement, pseudoType);
return collection && !collection->mAnimations.IsEmpty();
}
+size_t
+Gecko_ElementTransitions_Length(RawGeckoElementBorrowed aElement,
+ nsIAtom* aPseudoTagOrNull)
+{
+ MOZ_ASSERT(!aPseudoTagOrNull ||
+ aPseudoTagOrNull == nsCSSPseudoElements::before ||
+ aPseudoTagOrNull == nsCSSPseudoElements::after);
+
+ CSSPseudoElementType pseudoType =
+ nsCSSPseudoElements::GetPseudoType(aPseudoTagOrNull,
+ CSSEnabledState::eForAllContent);
+ nsTransitionManager::CSSTransitionCollection* collection =
+ nsTransitionManager::CSSTransitionCollection
+ ::GetAnimationCollection(aElement, pseudoType);
+
+ return collection ? collection->mAnimations.Length() : 0;
+}
+
+static CSSTransition*
+GetCurrentTransitionAt(RawGeckoElementBorrowed aElement,
+ nsIAtom* aPseudoTagOrNull,
+ size_t aIndex)
+{
+ MOZ_ASSERT(!aPseudoTagOrNull ||
+ aPseudoTagOrNull == nsCSSPseudoElements::before ||
+ aPseudoTagOrNull == nsCSSPseudoElements::after);
+
+ CSSPseudoElementType pseudoType =
+ nsCSSPseudoElements::GetPseudoType(aPseudoTagOrNull,
+ CSSEnabledState::eForAllContent);
+ nsTransitionManager::CSSTransitionCollection* collection =
+ nsTransitionManager::CSSTransitionCollection
+ ::GetAnimationCollection(aElement, pseudoType);
+ if (!collection) {
+ return nullptr;
+ }
+ nsTArray<RefPtr<CSSTransition>>& transitions = collection->mAnimations;
+ return aIndex < transitions.Length()
+ ? transitions[aIndex].get()
+ : nullptr;
+}
+
+nsCSSPropertyID
+Gecko_ElementTransitions_PropertyAt(RawGeckoElementBorrowed aElement,
+ nsIAtom* aPseudoTagOrNull,
+ size_t aIndex)
+{
+ CSSTransition* transition = GetCurrentTransitionAt(aElement,
+ aPseudoTagOrNull,
+ aIndex);
+ return transition ? transition->TransitionProperty()
+ : nsCSSPropertyID::eCSSProperty_UNKNOWN;
+}
+
+RawServoAnimationValueBorrowedOrNull
+Gecko_ElementTransitions_EndValueAt(RawGeckoElementBorrowed aElement,
+ nsIAtom* aPseudoTagOrNull,
+ size_t aIndex)
+{
+ CSSTransition* transition = GetCurrentTransitionAt(aElement,
+ aPseudoTagOrNull,
+ aIndex);
+ return transition ? transition->ToValue().mServo.get() : nullptr;
+}
+
double
Gecko_GetProgressFromComputedTiming(RawGeckoComputedTimingBorrowed aComputedTiming)
{
return aComputedTiming->mProgress.Value();
}
double
Gecko_GetPositionInSegment(RawGeckoAnimationPropertySegmentBorrowed aSegment,
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -202,16 +202,26 @@ void Gecko_UpdateAnimations(RawGeckoElem
ServoComputedValuesBorrowedOrNull aParentComputedValues,
mozilla::UpdateAnimationsTasks aTaskBits);
bool Gecko_ElementHasAnimations(RawGeckoElementBorrowed aElement,
nsIAtom* aPseudoTagOrNull);
bool Gecko_ElementHasCSSAnimations(RawGeckoElementBorrowed aElement,
nsIAtom* aPseudoTagOrNull);
bool Gecko_ElementHasCSSTransitions(RawGeckoElementBorrowed aElement,
nsIAtom* aPseudoTagOrNull);
+size_t Gecko_ElementTransitions_Length(RawGeckoElementBorrowed aElement,
+ nsIAtom* aPseudoTagOrNull);
+nsCSSPropertyID Gecko_ElementTransitions_PropertyAt(
+ RawGeckoElementBorrowed aElement,
+ nsIAtom* aPseudoTagOrNull,
+ size_t aIndex);
+RawServoAnimationValueBorrowedOrNull Gecko_ElementTransitions_EndValueAt(
+ RawGeckoElementBorrowed aElement,
+ nsIAtom* aPseudoTagOrNull,
+ size_t aIndex);
double Gecko_GetProgressFromComputedTiming(RawGeckoComputedTimingBorrowed aComputedTiming);
double Gecko_GetPositionInSegment(
RawGeckoAnimationPropertySegmentBorrowed aSegment,
double aProgress,
mozilla::ComputedTimingFunction::BeforeFlag aBeforeFlag);
// Get servo's AnimationValue for |aProperty| from the cached base style
// |aBaseStyles|.
// |aBaseStyles| is nsRefPtrHashtable<nsUint32HashKey, RawServoAnimationValue>.