зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1057129 patch 1 - Make AddStyleUpdatesTo handle pseudo-elements. r=birtles
This (like patch 2) posts restyles directly to the pseudo-element content nodes, which is a new thing. This isn't needed right now since AddStyleUpdatesTo is currently only used when updating main-thread-suppressed animations running on the compositor. However, it will be needed once we depend on AddStyleUpdatesTo for bug 960465. And it will have an effect now since AddStyleUpdatesTo actually adds all animations rather than only the ones that are suppressed from running on the main thread.
This commit is contained in:
Родитель
f96287c656
Коммит
26e0764f33
|
@ -176,17 +176,12 @@ CommonAnimationManager::AddStyleUpdatesTo(RestyleTracker& aTracker)
|
|||
static_cast<AnimationPlayerCollection*>(next);
|
||||
next = PR_NEXT_LINK(next);
|
||||
|
||||
if (!collection->IsForElement()) {
|
||||
// We don't support compositor-driven animation of :before/:after
|
||||
// transitions or animations, so at least skip those.
|
||||
// FIXME: We'll need to handle this before using this for the
|
||||
// transitions redesign.
|
||||
continue;
|
||||
dom::Element* elementToRestyle = collection->GetElementToRestyle();
|
||||
if (elementToRestyle) {
|
||||
nsRestyleHint rshint = collection->IsForTransitions()
|
||||
? eRestyle_CSSTransitions : eRestyle_CSSAnimations;
|
||||
aTracker.AddPendingRestyle(elementToRestyle, rshint, nsChangeHint(0));
|
||||
}
|
||||
|
||||
nsRestyleHint rshint = collection->IsForTransitions()
|
||||
? eRestyle_CSSTransitions : eRestyle_CSSAnimations;
|
||||
aTracker.AddPendingRestyle(collection->mElement, rshint, nsChangeHint(0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -413,6 +408,32 @@ AnimationPlayerCollection::HasAnimationOfProperty(
|
|||
return false;
|
||||
}
|
||||
|
||||
mozilla::dom::Element*
|
||||
AnimationPlayerCollection::GetElementToRestyle() const
|
||||
{
|
||||
if (IsForElement()) {
|
||||
return mElement;
|
||||
}
|
||||
|
||||
nsIFrame* primaryFrame = mElement->GetPrimaryFrame();
|
||||
if (!primaryFrame) {
|
||||
return nullptr;
|
||||
}
|
||||
nsIFrame* pseudoFrame;
|
||||
if (IsForBeforePseudo()) {
|
||||
pseudoFrame = nsLayoutUtils::GetBeforeFrame(primaryFrame);
|
||||
} else if (IsForAfterPseudo()) {
|
||||
pseudoFrame = nsLayoutUtils::GetAfterFrame(primaryFrame);
|
||||
} else {
|
||||
MOZ_ASSERT(false, "unknown mElementProperty");
|
||||
return nullptr;
|
||||
}
|
||||
if (!pseudoFrame) {
|
||||
return nullptr;
|
||||
}
|
||||
return pseudoFrame->GetContent()->AsElement();
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
AnimationPlayerCollection::LogAsyncAnimationFailure(nsCString& aMessage,
|
||||
const nsIContent* aContent)
|
||||
|
|
|
@ -230,6 +230,16 @@ struct AnimationPlayerCollection : public PRCList
|
|||
mElementProperty == nsGkAtoms::transitionsProperty;
|
||||
}
|
||||
|
||||
bool IsForBeforePseudo() const {
|
||||
return mElementProperty == nsGkAtoms::animationsOfBeforeProperty ||
|
||||
mElementProperty == nsGkAtoms::transitionsOfBeforeProperty;
|
||||
}
|
||||
|
||||
bool IsForAfterPseudo() const {
|
||||
return mElementProperty == nsGkAtoms::animationsOfAfterProperty ||
|
||||
mElementProperty == nsGkAtoms::transitionsOfAfterProperty;
|
||||
}
|
||||
|
||||
bool IsForTransitions() const {
|
||||
return mElementProperty == nsGkAtoms::transitionsProperty ||
|
||||
mElementProperty == nsGkAtoms::transitionsOfBeforeProperty ||
|
||||
|
@ -246,14 +256,15 @@ struct AnimationPlayerCollection : public PRCList
|
|||
{
|
||||
if (IsForElement()) {
|
||||
return EmptyString();
|
||||
} else if (mElementProperty == nsGkAtoms::animationsOfBeforeProperty ||
|
||||
mElementProperty == nsGkAtoms::transitionsOfBeforeProperty) {
|
||||
} else if (IsForBeforePseudo()) {
|
||||
return NS_LITERAL_STRING("::before");
|
||||
} else {
|
||||
return NS_LITERAL_STRING("::after");
|
||||
}
|
||||
}
|
||||
|
||||
mozilla::dom::Element* GetElementToRestyle() const;
|
||||
|
||||
void PostRestyleForAnimation(nsPresContext *aPresContext) {
|
||||
nsRestyleHint styleHint = IsForElement() ? eRestyle_Self : eRestyle_Subtree;
|
||||
aPresContext->PresShell()->RestyleForAnimation(mElement, styleHint);
|
||||
|
|
Загрузка…
Ссылка в новой задаче