Bug 1375767 - Pass CSSPseudoElementType to GetAnimationCollection() directly. r?birtles draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Fri, 23 Jun 2017 17:05:42 +0900
changeset 599498 61c092f78dbd990292ceb9cab2d6d896f2150c2e
parent 599497 5d8f173a0a17bad7154869d9746eab1d09976e00
child 634799 af0b7304d9033225469b726b0ce05d944262d671
push id65549
push userhikezoe@mozilla.com
push dateFri, 23 Jun 2017 08:09:20 +0000
reviewersbirtles
bugs1375767
milestone56.0a1
Bug 1375767 - Pass CSSPseudoElementType to GetAnimationCollection() directly. r?birtles MozReview-Commit-ID: DcsbYE9VY5b
layout/style/AnimationCollection.cpp
layout/style/AnimationCollection.h
layout/style/ServoBindings.cpp
--- a/layout/style/AnimationCollection.cpp
+++ b/layout/style/AnimationCollection.cpp
@@ -56,35 +56,16 @@ AnimationCollection<AnimationType>::GetA
   return
     static_cast<AnimationCollection<AnimationType>*>(aElement->
                                                      GetProperty(propName));
 }
 
 template <class AnimationType>
 /* static */ AnimationCollection<AnimationType>*
 AnimationCollection<AnimationType>::GetAnimationCollection(
-  const dom::Element *aElement,
-  nsIAtom* aPseudoTagOrNull)
-{
-  MOZ_ASSERT(!aPseudoTagOrNull ||
-             aPseudoTagOrNull == nsCSSPseudoElements::before ||
-             aPseudoTagOrNull == nsCSSPseudoElements::after);
-
-  CSSPseudoElementType pseudoType = CSSPseudoElementType::NotPseudo;
-  if (aPseudoTagOrNull) {
-    pseudoType = aPseudoTagOrNull == nsCSSPseudoElements::before
-                 ? CSSPseudoElementType::before
-                 : CSSPseudoElementType::after;
-  }
-  return GetAnimationCollection(aElement, pseudoType);
-}
-
-template <class AnimationType>
-/* static */ AnimationCollection<AnimationType>*
-AnimationCollection<AnimationType>::GetAnimationCollection(
   const nsIFrame* aFrame)
 {
   Maybe<NonOwningAnimationTarget> pseudoElement =
     EffectCompositor::GetAnimationElementAndPseudoForFrame(aFrame);
   if (!pseudoElement) {
     return nullptr;
   }
 
--- a/layout/style/AnimationCollection.h
+++ b/layout/style/AnimationCollection.h
@@ -65,22 +65,16 @@ public:
                            void *aPropertyValue, void *aData);
 
   // Get the collection of animations for the given |aElement| and
   // |aPseudoType|.
   static AnimationCollection<AnimationType>*
     GetAnimationCollection(const dom::Element* aElement,
                            CSSPseudoElementType aPseudoType);
 
-  // Get the collection of animations for the given |aElement| and
-  // |aPseudoTagOrNull|.
-  static AnimationCollection<AnimationType>*
-    GetAnimationCollection(const dom::Element* aElement,
-                           nsIAtom* aPseudoTagOrNull);
-
   // Given the frame |aFrame| with possibly animated content, finds its
   // associated collection of animations. If |aFrame| is a generated content
   // frame, this function may examine the parent frame to search for such
   // animations.
   static AnimationCollection<AnimationType>* GetAnimationCollection(
     const nsIFrame* aFrame);
 
   // Get the collection of animations for the given |aElement| and
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -505,31 +505,16 @@ Gecko_GetActiveLinkAttrDeclarationBlock(
   nsHTMLStyleSheet* sheet = aElement->OwnerDoc()->GetAttributeStyleSheet();
   if (!sheet) {
     return nullptr;
   }
 
   return AsRefRawStrong(sheet->GetServoActiveLinkDecl());
 }
 
-static nsIAtom*
-PseudoTagAndCorrectElementForAnimation(const Element*& aElementOrPseudo) {
-  if (aElementOrPseudo->IsGeneratedContentContainerForBefore()) {
-    aElementOrPseudo = aElementOrPseudo->GetParent()->AsElement();
-    return nsCSSPseudoElements::before;
-  }
-
-  if (aElementOrPseudo->IsGeneratedContentContainerForAfter()) {
-    aElementOrPseudo = aElementOrPseudo->GetParent()->AsElement();
-    return nsCSSPseudoElements::after;
-  }
-
-  return nullptr;
-}
-
 static CSSPseudoElementType
 GetPseudoTypeFromElementForAnimation(const Element*& aElementOrPseudo) {
   if (aElementOrPseudo->IsGeneratedContentContainerForBefore()) {
     aElementOrPseudo = aElementOrPseudo->GetParent()->AsElement();
     return CSSPseudoElementType::before;
   }
 
   if (aElementOrPseudo->IsGeneratedContentContainerForAfter()) {
@@ -642,53 +627,57 @@ Gecko_ElementHasAnimations(RawGeckoEleme
     GetPseudoTypeFromElementForAnimation(aElement);
 
   return !!EffectSet::GetEffectSet(aElement, pseudoType);
 }
 
 bool
 Gecko_ElementHasCSSAnimations(RawGeckoElementBorrowed aElement)
 {
-  nsIAtom* pseudoTag = PseudoTagAndCorrectElementForAnimation(aElement);
+  CSSPseudoElementType pseudoType =
+    GetPseudoTypeFromElementForAnimation(aElement);
   nsAnimationManager::CSSAnimationCollection* collection =
     nsAnimationManager::CSSAnimationCollection
-                      ::GetAnimationCollection(aElement, pseudoTag);
+                      ::GetAnimationCollection(aElement, pseudoType);
 
   return collection && !collection->mAnimations.IsEmpty();
 }
 
 bool
 Gecko_ElementHasCSSTransitions(RawGeckoElementBorrowed aElement)
 {
-  nsIAtom* pseudoTag = PseudoTagAndCorrectElementForAnimation(aElement);
+  CSSPseudoElementType pseudoType =
+    GetPseudoTypeFromElementForAnimation(aElement);
   nsTransitionManager::CSSTransitionCollection* collection =
     nsTransitionManager::CSSTransitionCollection
-                       ::GetAnimationCollection(aElement, pseudoTag);
+                       ::GetAnimationCollection(aElement, pseudoType);
 
   return collection && !collection->mAnimations.IsEmpty();
 }
 
 size_t
 Gecko_ElementTransitions_Length(RawGeckoElementBorrowed aElement)
 {
-  nsIAtom* pseudoTag = PseudoTagAndCorrectElementForAnimation(aElement);
+  CSSPseudoElementType pseudoType =
+    GetPseudoTypeFromElementForAnimation(aElement);
   nsTransitionManager::CSSTransitionCollection* collection =
     nsTransitionManager::CSSTransitionCollection
-                       ::GetAnimationCollection(aElement, pseudoTag);
+                       ::GetAnimationCollection(aElement, pseudoType);
 
   return collection ? collection->mAnimations.Length() : 0;
 }
 
 static CSSTransition*
 GetCurrentTransitionAt(RawGeckoElementBorrowed aElement, size_t aIndex)
 {
-  nsIAtom* pseudoTag = PseudoTagAndCorrectElementForAnimation(aElement);
+  CSSPseudoElementType pseudoType =
+    GetPseudoTypeFromElementForAnimation(aElement);
   nsTransitionManager::CSSTransitionCollection* collection =
     nsTransitionManager::CSSTransitionCollection
-                       ::GetAnimationCollection(aElement, pseudoTag);
+                       ::GetAnimationCollection(aElement, pseudoType);
   if (!collection) {
     return nullptr;
   }
   nsTArray<RefPtr<CSSTransition>>& transitions = collection->mAnimations;
   return aIndex < transitions.Length()
          ? transitions[aIndex].get()
          : nullptr;
 }