From ee4902f58238181810d6aaf9345c28c4411118b8 Mon Sep 17 00:00:00 2001 From: Boris Chiou Date: Thu, 10 Mar 2016 21:50:00 -0500 Subject: [PATCH] Bug 1254418 - Part 1: Support generated-content element for Element.getAnimations. r=birtles --- dom/base/Element.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index c6b68bbaf325..2bb7fb584d99 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -3392,7 +3392,24 @@ Element::GetAnimations(nsTArray>& aAnimations) doc->FlushPendingNotifications(Flush_Style); } - GetAnimationsUnsorted(this, CSSPseudoElementType::NotPseudo, aAnimations); + Element* elem = this; + CSSPseudoElementType pseudoType = CSSPseudoElementType::NotPseudo; + // For animations on generated-content elements, the animations are stored + // on the parent element. + nsIAtom* name = NodeInfo()->NameAtom(); + if (name == nsGkAtoms::mozgeneratedcontentbefore) { + elem = GetParentElement(); + pseudoType = CSSPseudoElementType::before; + } else if (name == nsGkAtoms::mozgeneratedcontentafter) { + elem = GetParentElement(); + pseudoType = CSSPseudoElementType::after; + } + + if (!elem) { + return; + } + + GetAnimationsUnsorted(elem, pseudoType, aAnimations); aAnimations.Sort(AnimationPtrComparator>()); } @@ -3405,6 +3422,7 @@ Element::GetAnimationsUnsorted(Element* aElement, aPseudoType == CSSPseudoElementType::after || aPseudoType == CSSPseudoElementType::before, "Unsupported pseudo type"); + MOZ_ASSERT(aElement, "Null element"); EffectSet* effects = EffectSet::GetEffectSet(aElement, aPseudoType); if (!effects) {