diff --git a/layout/style/ServoBindingList.h b/layout/style/ServoBindingList.h index 66aa1e497353..19f4b57f18bb 100644 --- a/layout/style/ServoBindingList.h +++ b/layout/style/ServoBindingList.h @@ -647,6 +647,14 @@ SERVO_BINDING_FUNC(Servo_StyleSet_GetBaseComputedValuesForElement, ServoStyleContextBorrowed existing_style, const mozilla::ServoElementSnapshotTable* snapshots, mozilla::CSSPseudoElementType pseudo_type) +// Returns computed values for the given element by adding an animation value. +SERVO_BINDING_FUNC(Servo_StyleSet_GetComputedValuesByAddingAnimation, + ServoStyleContextStrong, + RawServoStyleSetBorrowed set, + RawGeckoElementBorrowed element, + ServoStyleContextBorrowed existing_style, + const mozilla::ServoElementSnapshotTable* snapshots, + RawServoAnimationValueBorrowed animation) // For canvas font. SERVO_BINDING_FUNC(Servo_SerializeFontValueForCanvas, void, diff --git a/layout/style/ServoStyleSet.cpp b/layout/style/ServoStyleSet.cpp index 7dd78abc7b5e..4089dfddb19f 100644 --- a/layout/style/ServoStyleSet.cpp +++ b/layout/style/ServoStyleSet.cpp @@ -1239,6 +1239,25 @@ ServoStyleSet::GetBaseContextForElement( aPseudoType).Consume(); } +already_AddRefed +ServoStyleSet::ResolveServoStyleByAddingAnimation( + Element* aElement, + const ServoStyleContext* aStyle, + RawServoAnimationValue* aAnimationValue) +{ + MOZ_RELEASE_ASSERT(!aElement->OwnerDoc()->GetBFCacheEntry(), + "ResolveServoStyleByAddingAniamtion does not support " + "documents in the bfcache"); + + AutoClearStaleData guard(aElement); + return Servo_StyleSet_GetComputedValuesByAddingAnimation( + mRawSet.get(), + aElement, + aStyle, + &Snapshots(), + aAnimationValue).Consume(); +} + already_AddRefed ServoStyleSet::ComputeAnimationValue( Element* aElement, diff --git a/layout/style/ServoStyleSet.h b/layout/style/ServoStyleSet.h index 7fcded6f1ea8..cf4dc903c35f 100644 --- a/layout/style/ServoStyleSet.h +++ b/layout/style/ServoStyleSet.h @@ -392,6 +392,20 @@ public: CSSPseudoElementType aPseudoType, const ServoStyleContext* aStyle); + // Get a style context that represents |aStyle|, but as though + // it additionally matched the rules of the newly added |aAnimaitonaValue|. + // We use this function to temporarily generate a ServoStyleContext for + // calculating the cumulative change hints. + // This must hold: + // The additional rules must be appropriate for the transition + // level of the cascade, which is the highest level of the cascade. + // (This is the case for one current caller, the cover rule used + // for CSS transitions.) + // Note: |aElement| should be the generated element if it is pseudo. + already_AddRefed + ResolveServoStyleByAddingAnimation(dom::Element* aElement, + const ServoStyleContext* aStyle, + RawServoAnimationValue* aAnimationValue); /** * Resolve style for a given declaration block with/without the parent style. * If the parent style is not specified, the document default computed values