Bug 1375767 - Pass CSSPseudoElementType to GetAnimationCollection() directly. r?birtles
MozReview-Commit-ID: DcsbYE9VY5b
--- 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;
}