зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1273042 - Part 1: Use StyleContext()->GetPseudoType() to obtain CSSPseudoElementType for the nsIFrame. r=birtles
Before this patch, we could't use EffectSet::GetEffectSet(nsIFrame*) until the target content associated with the nsIFrame has a primary frame since nsLayoutUtils::GetStyleFrame(nsIContent*) needs the primary frame. In this patch, StyleContext()->GetPseudoType() is used for obtaining CSSPseudoElementType instread of content->NodeInfo()->NameAtom(). As a result, we don't need to care about whether the content has a primary frame or not.
This commit is contained in:
Родитель
6b776e8000
Коммит
9e39dd8938
|
@ -519,35 +519,26 @@ EffectCompositor::GetAnimationElementAndPseudoForFrame(const nsIFrame* aFrame)
|
|||
// Always return the same object to benefit from return-value optimization.
|
||||
Maybe<NonOwningAnimationTarget> result;
|
||||
|
||||
CSSPseudoElementType pseudoType =
|
||||
aFrame->StyleContext()->GetPseudoType();
|
||||
|
||||
if (pseudoType != CSSPseudoElementType::NotPseudo &&
|
||||
pseudoType != CSSPseudoElementType::before &&
|
||||
pseudoType != CSSPseudoElementType::after) {
|
||||
return result;
|
||||
}
|
||||
|
||||
nsIContent* content = aFrame->GetContent();
|
||||
if (!content) {
|
||||
return result;
|
||||
}
|
||||
|
||||
CSSPseudoElementType pseudoType = CSSPseudoElementType::NotPseudo;
|
||||
|
||||
if (aFrame->IsGeneratedContentFrame()) {
|
||||
nsIFrame* parent = aFrame->GetParent();
|
||||
if (parent->IsGeneratedContentFrame()) {
|
||||
return result;
|
||||
}
|
||||
nsIAtom* name = content->NodeInfo()->NameAtom();
|
||||
if (name == nsGkAtoms::mozgeneratedcontentbefore) {
|
||||
pseudoType = CSSPseudoElementType::before;
|
||||
} else if (name == nsGkAtoms::mozgeneratedcontentafter) {
|
||||
pseudoType = CSSPseudoElementType::after;
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
if (pseudoType == CSSPseudoElementType::before ||
|
||||
pseudoType == CSSPseudoElementType::after) {
|
||||
content = content->GetParent();
|
||||
if (!content) {
|
||||
return result;
|
||||
}
|
||||
} else {
|
||||
if (nsLayoutUtils::GetStyleFrame(content) != aFrame) {
|
||||
// The effects associated with an element are for its primary frame.
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
if (!content->IsElement()) {
|
||||
|
|
|
@ -49,42 +49,18 @@ EffectSet::GetEffectSet(dom::Element* aElement,
|
|||
/* static */ EffectSet*
|
||||
EffectSet::GetEffectSet(const nsIFrame* aFrame)
|
||||
{
|
||||
nsIContent* content = aFrame->GetContent();
|
||||
if (!content) {
|
||||
Maybe<NonOwningAnimationTarget> target =
|
||||
EffectCompositor::GetAnimationElementAndPseudoForFrame(aFrame);
|
||||
|
||||
if (!target) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsIAtom* propName;
|
||||
if (aFrame->IsGeneratedContentFrame()) {
|
||||
nsIFrame* parent = aFrame->GetParent();
|
||||
if (parent->IsGeneratedContentFrame()) {
|
||||
return nullptr;
|
||||
}
|
||||
nsIAtom* name = content->NodeInfo()->NameAtom();
|
||||
if (name == nsGkAtoms::mozgeneratedcontentbefore) {
|
||||
propName = nsGkAtoms::animationEffectsForBeforeProperty;
|
||||
} else if (name == nsGkAtoms::mozgeneratedcontentafter) {
|
||||
propName = nsGkAtoms::animationEffectsForAfterProperty;
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
content = content->GetParent();
|
||||
if (!content) {
|
||||
return nullptr;
|
||||
}
|
||||
} else {
|
||||
if (nsLayoutUtils::GetStyleFrame(content) != aFrame) {
|
||||
// The effects associated with an element are for its primary frame.
|
||||
return nullptr;
|
||||
}
|
||||
propName = nsGkAtoms::animationEffectsProperty;
|
||||
}
|
||||
|
||||
if (!content->MayHaveAnimations()) {
|
||||
if (!target->mElement->MayHaveAnimations()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return static_cast<EffectSet*>(content->GetProperty(propName));
|
||||
return GetEffectSet(target->mElement, target->mPseudoType);
|
||||
}
|
||||
|
||||
/* static */ EffectSet*
|
||||
|
|
Загрузка…
Ссылка в новой задаче