Bug 1254418 - Part 1: Support generated-content element for Element.getAnimations. r=birtles

This commit is contained in:
Boris Chiou 2016-03-10 21:50:00 -05:00
Родитель 5e6ba24562
Коммит ee4902f582
1 изменённых файлов: 19 добавлений и 1 удалений

Просмотреть файл

@ -3392,7 +3392,24 @@ Element::GetAnimations(nsTArray<RefPtr<Animation>>& 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<RefPtr<Animation>>());
}
@ -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) {