Bug 1375767 - Don't use nsCSSPseudoElements::GetPseudoType() r?birtles
It iterates over all pseudo types if a given element is not pseudo.
We should use IsGeneratedContentContainerForBefore() or
IsGeneratedContentContainerForAfter instead.
MozReview-Commit-ID: 51Jnl4e8M2V
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -520,16 +520,31 @@ PseudoTagAndCorrectElementForAnimation(c
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()) {
+ aElementOrPseudo = aElementOrPseudo->GetParent()->AsElement();
+ return CSSPseudoElementType::after;
+ }
+
+ return CSSPseudoElementType::NotPseudo;
+}
+
bool
Gecko_GetAnimationRule(RawGeckoElementBorrowed aElement,
EffectCompositor::CascadeLevel aCascadeLevel,
RawServoAnimationValueMapBorrowedMut aAnimationValues)
{
MOZ_ASSERT(aElement);
nsIDocument* doc = aElement->GetComposedDoc();
@@ -537,22 +552,18 @@ Gecko_GetAnimationRule(RawGeckoElementBo
return false;
}
nsPresContext* presContext = doc->GetShell()->GetPresContext();
if (!presContext || !presContext->IsDynamic()) {
// For print or print preview, ignore animations.
return false;
}
- nsIAtom* pseudoTag = PseudoTagAndCorrectElementForAnimation(aElement);
-
CSSPseudoElementType pseudoType =
- nsCSSPseudoElements::GetPseudoType(
- pseudoTag,
- nsCSSProps::EnabledState::eIgnoreEnabledState);
+ GetPseudoTypeFromElementForAnimation(aElement);
return presContext->EffectCompositor()
->GetServoAnimationRule(aElement,
pseudoType,
aCascadeLevel,
aAnimationValues);
}
@@ -576,20 +587,18 @@ Gecko_UpdateAnimations(RawGeckoElementBo
return;
}
nsPresContext* presContext = nsContentUtils::GetContextForContent(aElement);
if (!presContext || !presContext->IsDynamic()) {
return;
}
- nsIAtom* pseudoTag = PseudoTagAndCorrectElementForAnimation(aElement);
CSSPseudoElementType pseudoType =
- nsCSSPseudoElements::GetPseudoType(pseudoTag,
- CSSEnabledState::eForAllContent);
+ GetPseudoTypeFromElementForAnimation(aElement);
if (aTasks & UpdateAnimationsTasks::CSSAnimations) {
presContext->AnimationManager()->
UpdateAnimations(const_cast<dom::Element*>(aElement), pseudoType,
aComputedValues);
}
// aComputedValues might be nullptr if the target element is now in a
@@ -624,20 +633,18 @@ Gecko_UpdateAnimations(RawGeckoElementBo
EffectCompositor::RestyleType::Standard,
EffectCompositor::CascadeLevel::Animations);
}
}
bool
Gecko_ElementHasAnimations(RawGeckoElementBorrowed aElement)
{
- nsIAtom* pseudoTag = PseudoTagAndCorrectElementForAnimation(aElement);
CSSPseudoElementType pseudoType =
- nsCSSPseudoElements::GetPseudoType(pseudoTag,
- CSSEnabledState::eForAllContent);
+ GetPseudoTypeFromElementForAnimation(aElement);
return !!EffectSet::GetEffectSet(aElement, pseudoType);
}
bool
Gecko_ElementHasCSSAnimations(RawGeckoElementBorrowed aElement)
{
nsIAtom* pseudoTag = PseudoTagAndCorrectElementForAnimation(aElement);