Bug 1921553 - Use PseudoStyleRequest in Element::GetAnimationsWithoutFlush(). r=view-transitions-reviewers,layout-reviewers,emilio
We will support `getAnimations()` for view transitions. For now just use `PseudoStyleRequest` for consistency. Differential Revision: https://phabricator.services.mozilla.com/D228244
This commit is contained in:
@@ -3878,62 +3878,15 @@ void Element::GetAnimations(const GetAnimationsOptions& aOptions,
|
||||
GetAnimationsWithoutFlush(aOptions, aAnimations);
|
||||
}
|
||||
|
||||
void Element::GetAnimationsWithoutFlush(
|
||||
const GetAnimationsOptions& aOptions,
|
||||
nsTArray<RefPtr<Animation>>& aAnimations) {
|
||||
Element* elem = this;
|
||||
PseudoStyleType pseudoType = PseudoStyleType::NotPseudo;
|
||||
// For animations on generated-content elements, the animations are stored
|
||||
// on the parent element.
|
||||
if (IsGeneratedContentContainerForBefore()) {
|
||||
elem = GetParentElement();
|
||||
pseudoType = PseudoStyleType::before;
|
||||
} else if (IsGeneratedContentContainerForAfter()) {
|
||||
elem = GetParentElement();
|
||||
pseudoType = PseudoStyleType::after;
|
||||
} else if (IsGeneratedContentContainerForMarker()) {
|
||||
elem = GetParentElement();
|
||||
pseudoType = PseudoStyleType::marker;
|
||||
}
|
||||
|
||||
if (!elem) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!aOptions.mSubtree ||
|
||||
AnimationUtils::IsSupportedPseudoForAnimations(pseudoType)) {
|
||||
GetAnimationsUnsorted(elem, pseudoType, aAnimations);
|
||||
} else {
|
||||
for (nsIContent* node = this; node; node = node->GetNextNode(this)) {
|
||||
if (!node->IsElement()) {
|
||||
continue;
|
||||
}
|
||||
Element* element = node->AsElement();
|
||||
Element::GetAnimationsUnsorted(element, PseudoStyleType::NotPseudo,
|
||||
aAnimations);
|
||||
Element::GetAnimationsUnsorted(element, PseudoStyleType::before,
|
||||
aAnimations);
|
||||
Element::GetAnimationsUnsorted(element, PseudoStyleType::after,
|
||||
aAnimations);
|
||||
Element::GetAnimationsUnsorted(element, PseudoStyleType::marker,
|
||||
aAnimations);
|
||||
}
|
||||
}
|
||||
aAnimations.Sort(AnimationPtrComparator<RefPtr<Animation>>());
|
||||
}
|
||||
|
||||
/* static */
|
||||
void Element::GetAnimationsUnsorted(Element* aElement,
|
||||
PseudoStyleType aPseudoType,
|
||||
nsTArray<RefPtr<Animation>>& aAnimations) {
|
||||
MOZ_ASSERT(aPseudoType == PseudoStyleType::NotPseudo ||
|
||||
AnimationUtils::IsSupportedPseudoForAnimations(aPseudoType),
|
||||
static void GetAnimationsUnsorted(Element* aElement,
|
||||
const PseudoStyleRequest& aPseudoRequest,
|
||||
nsTArray<RefPtr<Animation>>& aAnimations) {
|
||||
MOZ_ASSERT(aPseudoRequest.IsNotPseudo() ||
|
||||
AnimationUtils::IsSupportedPseudoForAnimations(aPseudoRequest),
|
||||
"Unsupported pseudo type");
|
||||
MOZ_ASSERT(aElement, "Null element");
|
||||
|
||||
// FIXME: Bug 1921109. Support getAnimations() for view transitions.
|
||||
EffectSet* effects =
|
||||
EffectSet::Get(aElement, PseudoStyleRequest(aPseudoType));
|
||||
EffectSet* effects = EffectSet::Get(aElement, aPseudoRequest);
|
||||
if (!effects) {
|
||||
return;
|
||||
}
|
||||
@@ -3951,6 +3904,48 @@ void Element::GetAnimationsUnsorted(Element* aElement,
|
||||
}
|
||||
}
|
||||
|
||||
void Element::GetAnimationsWithoutFlush(
|
||||
const GetAnimationsOptions& aOptions,
|
||||
nsTArray<RefPtr<Animation>>& aAnimations) {
|
||||
Element* elem = this;
|
||||
// FIXME: Bug 1921109. Support getAnimations() for view transitions.
|
||||
PseudoStyleRequest pseudoRequest;
|
||||
// For animations on generated-content elements, the animations are stored
|
||||
// on the parent element.
|
||||
if (IsGeneratedContentContainerForBefore()) {
|
||||
elem = GetParentElement();
|
||||
pseudoRequest.mType = PseudoStyleType::before;
|
||||
} else if (IsGeneratedContentContainerForAfter()) {
|
||||
elem = GetParentElement();
|
||||
pseudoRequest.mType = PseudoStyleType::after;
|
||||
} else if (IsGeneratedContentContainerForMarker()) {
|
||||
elem = GetParentElement();
|
||||
pseudoRequest.mType = PseudoStyleType::marker;
|
||||
}
|
||||
|
||||
if (!elem) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!aOptions.mSubtree ||
|
||||
AnimationUtils::IsSupportedPseudoForAnimations(pseudoRequest)) {
|
||||
GetAnimationsUnsorted(elem, pseudoRequest, aAnimations);
|
||||
} else {
|
||||
for (nsIContent* node = this; node; node = node->GetNextNode(this)) {
|
||||
if (!node->IsElement()) {
|
||||
continue;
|
||||
}
|
||||
Element* element = node->AsElement();
|
||||
GetAnimationsUnsorted(element, PseudoStyleRequest::NotPseudo(),
|
||||
aAnimations);
|
||||
GetAnimationsUnsorted(element, PseudoStyleRequest::Before(), aAnimations);
|
||||
GetAnimationsUnsorted(element, PseudoStyleRequest::After(), aAnimations);
|
||||
GetAnimationsUnsorted(element, PseudoStyleRequest::Marker(), aAnimations);
|
||||
}
|
||||
}
|
||||
aAnimations.Sort(AnimationPtrComparator<RefPtr<Animation>>());
|
||||
}
|
||||
|
||||
void Element::CloneAnimationsFrom(const Element& aOther) {
|
||||
AnimationTimeline* const timeline = OwnerDoc()->Timeline();
|
||||
MOZ_ASSERT(timeline, "Timeline has not been set on the document yet");
|
||||
|
||||
@@ -1580,10 +1580,6 @@ class Element : public FragmentOrElement {
|
||||
void GetAnimationsWithoutFlush(const GetAnimationsOptions& aOptions,
|
||||
nsTArray<RefPtr<Animation>>& aAnimations);
|
||||
|
||||
static void GetAnimationsUnsorted(Element* aElement,
|
||||
PseudoStyleType aPseudoType,
|
||||
nsTArray<RefPtr<Animation>>& aAnimations);
|
||||
|
||||
void CloneAnimationsFrom(const Element& aOther);
|
||||
|
||||
virtual void GetInnerHTML(nsAString& aInnerHTML, OOMReporter& aError);
|
||||
|
||||
Reference in New Issue
Block a user