Bug 1341372 - Part 2: Add one FFI for TElement::has_css_transitions. draft
authorBoris Chiou <boris.chiou@gmail.com>
Mon, 17 Apr 2017 14:24:33 +0800
changeset 563573 5ed611a3ef6e898c046bb52a6bf4f17fb5d7420e
parent 563572 a1448beee892e749d5d6b9f01ac3afcfb6b1171e
child 563574 4c5042d1a0a6209f62e2eda99c9317c5da0f75ed
push id54353
push userbmo:boris.chiou@gmail.com
push dateMon, 17 Apr 2017 09:07:14 +0000
bugs1341372
milestone55.0a1
Bug 1341372 - Part 2: Add one FFI for TElement::has_css_transitions. Add one FFI, Gecko_ElementHasCSSTransitions, to check if there is any transition in CSSTransitionCollection. This will be used to check if we need to update transition and if we should compute the after-change style. MozReview-Commit-ID: 7xP4SdxNp7g
layout/style/ServoBindings.cpp
layout/style/ServoBindings.h
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -522,16 +522,34 @@ Gecko_ElementHasCSSAnimations(RawGeckoEl
                                        CSSEnabledState::eForAllContent);
   nsAnimationManager::CSSAnimationCollection* collection =
     nsAnimationManager::CSSAnimationCollection
                       ::GetAnimationCollection(aElement, pseudoType);
 
   return collection && !collection->mAnimations.IsEmpty();
 }
 
+bool
+Gecko_ElementHasCSSTransitions(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.IsEmpty();
+}
+
 double
 Gecko_GetProgressFromComputedTiming(RawGeckoComputedTimingBorrowed aComputedTiming)
 {
   return aComputedTiming->mProgress.Value();
 }
 
 double
 Gecko_GetPositionInSegment(RawGeckoAnimationPropertySegmentBorrowed aSegment,
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -200,16 +200,18 @@ void Gecko_UpdateAnimations(RawGeckoElem
                             ServoComputedValuesBorrowedOrNull aOldComputedValues,
                             ServoComputedValuesBorrowedOrNull aComputedValues,
                             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);
 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>.