mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 20:05:49 +00:00
Bug 1232577 part 8 - Move call to PostRestyleForAnimation to EffectCompositor; r=heycam
This patch continues to migrate functionality from AnimationCollection::RequestRestyle to EffectCompositor::RequestRestyle. In order to post the animation restyle from the EffectCompositor, this patch also moves the PostRestyleForAnimation method to EffectCompositor. The GetElementToRestyle method is temporarily duplicated in both EffectCompositor and AnimationCollection however we will remove the version in AnimationCollection later in this patch series.
This commit is contained in:
parent
21108e5e2e
commit
cf26e7b69b
@ -148,10 +148,36 @@ EffectCompositor::RequestRestyle(dom::Element* aElement,
|
||||
elementsToRestyle.Put(key, false);
|
||||
mPresContext->Document()->SetNeedStyleFlush();
|
||||
} else {
|
||||
// Get() returns 0 if the element is not found. It will also return
|
||||
// false if the element is found but does not have a pending restyle.
|
||||
bool hasPendingRestyle = elementsToRestyle.Get(key);
|
||||
if (!hasPendingRestyle) {
|
||||
PostRestyleForAnimation(aElement, aPseudoType, aCascadeLevel);
|
||||
}
|
||||
elementsToRestyle.Put(key, true);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
EffectCompositor::PostRestyleForAnimation(dom::Element* aElement,
|
||||
nsCSSPseudoElements::Type aPseudoType,
|
||||
CascadeLevel aCascadeLevel)
|
||||
{
|
||||
if (!mPresContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
dom::Element* element = GetElementToRestyle(aElement, aPseudoType);
|
||||
if (!element) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsRestyleHint hint = aCascadeLevel == CascadeLevel::Transitions ?
|
||||
eRestyle_CSSTransitions :
|
||||
eRestyle_CSSAnimations;
|
||||
mPresContext->PresShell()->RestyleForAnimation(element, hint);
|
||||
}
|
||||
|
||||
void
|
||||
EffectCompositor::MaybeUpdateAnimationRule(dom::Element* aElement,
|
||||
nsCSSPseudoElements::Type
|
||||
@ -173,6 +199,34 @@ EffectCompositor::MaybeUpdateAnimationRule(dom::Element* aElement,
|
||||
elementsToRestyle.Remove(key);
|
||||
}
|
||||
|
||||
/* static */ dom::Element*
|
||||
EffectCompositor::GetElementToRestyle(dom::Element* aElement,
|
||||
nsCSSPseudoElements::Type aPseudoType)
|
||||
{
|
||||
if (aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement) {
|
||||
return aElement;
|
||||
}
|
||||
|
||||
nsIFrame* primaryFrame = aElement->GetPrimaryFrame();
|
||||
if (!primaryFrame) {
|
||||
return nullptr;
|
||||
}
|
||||
nsIFrame* pseudoFrame;
|
||||
if (aPseudoType == nsCSSPseudoElements::ePseudo_before) {
|
||||
pseudoFrame = nsLayoutUtils::GetBeforeFrame(primaryFrame);
|
||||
} else if (aPseudoType == nsCSSPseudoElements::ePseudo_after) {
|
||||
pseudoFrame = nsLayoutUtils::GetAfterFrame(primaryFrame);
|
||||
} else {
|
||||
NS_NOTREACHED("Should not try to get the element to restyle for a pseudo "
|
||||
"other that :before or :after");
|
||||
return nullptr;
|
||||
}
|
||||
if (!pseudoFrame) {
|
||||
return nullptr;
|
||||
}
|
||||
return pseudoFrame->GetContent()->AsElement();
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
EffectCompositor::HasAnimationsForCompositor(const nsIFrame* aFrame,
|
||||
nsCSSProperty aProperty)
|
||||
|
@ -88,6 +88,14 @@ public:
|
||||
RestyleType aRestyleType,
|
||||
CascadeLevel aCascadeLevel);
|
||||
|
||||
// Schedule an animation restyle. This is called automatically by
|
||||
// RequestRestyle when necessary. However, it is exposed here since we also
|
||||
// need to perform this step when triggering transitions *without* also
|
||||
// invalidating the animation style rule (which RequestRestyle would do).
|
||||
void PostRestyleForAnimation(dom::Element* aElement,
|
||||
nsCSSPseudoElements::Type aPseudoType,
|
||||
CascadeLevel aCascadeLevel);
|
||||
|
||||
// Updates the animation rule stored on the EffectSet for the
|
||||
// specified (pseudo-)element for cascade level |aLevel|.
|
||||
// If the animation rule is not marked as needing an update,
|
||||
@ -151,6 +159,10 @@ private:
|
||||
TimeStamp aRefreshTime,
|
||||
bool& aStyleChanging);
|
||||
|
||||
static dom::Element* GetElementToRestyle(dom::Element* aElement,
|
||||
nsCSSPseudoElements::Type
|
||||
aPseudoType);
|
||||
|
||||
// Get the properties in |aEffectSet| that we are able to animate on the
|
||||
// compositor but which are also specified at a higher level in the cascade
|
||||
// than the animations level in |aStyleContext|.
|
||||
|
@ -501,13 +501,16 @@ AnimationCollection::RequestRestyle(EffectCompositor::RestyleType aRestyleType)
|
||||
|
||||
// Steps for RestyleType::Standard and above:
|
||||
|
||||
// FIXME: The following arrangement now makes absolutely no sense, but
|
||||
// is also harmless and in the interests of making incremental changes
|
||||
// we leave mHasPendingAnimationRestyle here for now and remove it in a
|
||||
// subsequent patch in this series.
|
||||
if (mHasPendingAnimationRestyle) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (aRestyleType >= EffectCompositor::RestyleType::Standard) {
|
||||
mHasPendingAnimationRestyle = true;
|
||||
PostRestyleForAnimation(presContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -234,15 +234,6 @@ public:
|
||||
|
||||
dom::Element* GetElementToRestyle() const;
|
||||
|
||||
void PostRestyleForAnimation(nsPresContext *aPresContext) {
|
||||
dom::Element* element = GetElementToRestyle();
|
||||
if (element) {
|
||||
nsRestyleHint hint = IsForTransitions() ? eRestyle_CSSTransitions
|
||||
: eRestyle_CSSAnimations;
|
||||
aPresContext->PresShell()->RestyleForAnimation(element, hint);
|
||||
}
|
||||
}
|
||||
|
||||
dom::Element *mElement;
|
||||
|
||||
// the atom we use in mElement's prop table (must be a static atom,
|
||||
|
@ -504,7 +504,11 @@ nsTransitionManager::StyleContextChanged(dom::Element *aElement,
|
||||
// The check of collection->mCheckGeneration against the restyle
|
||||
// manager's GetAnimationGeneration() will ensure that we don't go
|
||||
// through the rest of this function again when we do.
|
||||
collection->PostRestyleForAnimation(mPresContext);
|
||||
EffectCompositor::CascadeLevel cascadeLevel =
|
||||
EffectCompositor::CascadeLevel::Transitions;
|
||||
mPresContext->EffectCompositor()->PostRestyleForAnimation(aElement,
|
||||
pseudoType,
|
||||
cascadeLevel);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user