Bug 1232577 part 14 - Move FlushAnimations to EffectCompositor; r=heycam

This commit is contained in:
Brian Birtles 2016-01-13 07:54:55 +09:00
Родитель c54edbe389
Коммит b65c8d2610
5 изменённых файлов: 28 добавлений и 59 удалений

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

@ -188,6 +188,27 @@ EffectCompositor::PostRestyleForAnimation(dom::Element* aElement,
mPresContext->PresShell()->RestyleForAnimation(element, hint);
}
void
EffectCompositor::PostRestyleForThrottledAnimations()
{
for (size_t i = 0; i < kCascadeLevelCount; i++) {
CascadeLevel cascadeLevel = CascadeLevel(i);
auto& elementSet = mElementsToRestyle[cascadeLevel];
for (auto iter = elementSet.Iter(); !iter.Done(); iter.Next()) {
bool& postedRestyle = iter.Data();
if (postedRestyle) {
continue;
}
PostRestyleForAnimation(iter.Key().mElement,
iter.Key().mPseudoType,
cascadeLevel);
postedRestyle = true;
}
}
}
void
EffectCompositor::MaybeUpdateAnimationRule(dom::Element* aElement,
nsCSSPseudoElements::Type
@ -250,19 +271,6 @@ EffectCompositor::GetElementToRestyle(dom::Element* aElement,
return pseudoFrame->GetContent()->AsElement();
}
bool
EffectCompositor::HasThrottledAnimations(Element* aElement,
nsCSSPseudoElements::Type aPseudoType,
CascadeLevel aCascadeLevel) const
{
auto& elementsToRestyle = mElementsToRestyle[aCascadeLevel];
PseudoElementHashKey key = { aElement, aPseudoType };
bool hasPendingRestyle = false;
return elementsToRestyle.Get(key, &hasPendingRestyle) &&
!hasPendingRestyle;
}
/* static */ bool
EffectCompositor::HasAnimationsForCompositor(const nsIFrame* aFrame,
nsCSSProperty aProperty)

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

@ -96,6 +96,11 @@ public:
nsCSSPseudoElements::Type aPseudoType,
CascadeLevel aCascadeLevel);
// Posts an animation restyle for any elements whose animation style rule
// is out of date but for which an animation restyle has not yet been
// posted because updates on the main thread are throttled.
void PostRestyleForThrottledAnimations();
// 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,
@ -104,11 +109,6 @@ public:
nsCSSPseudoElements::Type aPseudoType,
CascadeLevel aCascadeLevel);
// FIXME: Temporary method until we move FlushAnimations here.
bool HasThrottledAnimations(dom::Element* aElement,
nsCSSPseudoElements::Type aPseudoType,
CascadeLevel aCascadeLevel) const;
static bool HasAnimationsForCompositor(const nsIFrame* aFrame,
nsCSSProperty aProperty);

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

@ -3968,11 +3968,8 @@ PresShell::FlushPendingNotifications(mozilla::ChangesToFlush aFlush)
if (aFlush.mFlushAnimations &&
!mPresContext->StyleUpdateForAllAnimationsIsUpToDate()) {
if (mPresContext->AnimationManager()) {
mPresContext->AnimationManager()->FlushAnimations();
}
if (mPresContext->TransitionManager()) {
mPresContext->TransitionManager()->FlushAnimations();
if (mPresContext->EffectCompositor()) {
mPresContext->EffectCompositor()->PostRestyleForThrottledAnimations();
}
mPresContext->TickLastStyleUpdateForAllAnimations();
}

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

@ -278,38 +278,6 @@ CommonAnimationManager::ExtractComputedValueForTransition(
return result;
}
void
CommonAnimationManager::FlushAnimations()
{
for (AnimationCollection* collection = mElementCollections.getFirst();
collection; collection = collection->getNext()) {
EffectCompositor::CascadeLevel cascadeLevel =
collection->IsForAnimations() ?
EffectCompositor::CascadeLevel::Animations :
EffectCompositor::CascadeLevel::Transitions;
bool hasThrottledAnimations =
mPresContext->EffectCompositor()->HasThrottledAnimations(
collection->mElement,
collection->PseudoElementType(),
cascadeLevel);
if (!hasThrottledAnimations) {
continue;
}
MOZ_ASSERT(collection->mElement->GetComposedDoc() ==
mPresContext->Document(),
"Should not have a transition/animation collection for an "
"element that is not part of the document tree");
mPresContext->EffectCompositor()->RequestRestyle(
collection->mElement,
collection->PseudoElementType(),
EffectCompositor::RestyleType::Standard,
cascadeLevel);
}
}
nsIStyleRule*
CommonAnimationManager::GetAnimationRule(mozilla::dom::Element* aElement,
nsCSSPseudoElements::Type aPseudoType)

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

@ -84,10 +84,6 @@ public:
return false;
}
// Requests a standard restyle on each managed AnimationCollection that has
// an out-of-date animation rule.
void FlushAnimations();
nsIStyleRule* GetAnimationRule(dom::Element* aElement,
nsCSSPseudoElements::Type aPseudoType);