Bug 1232577 part 12 - Move the remainder of RequestRestyle from AnimationCollection to EffectCompositor; r=heycam

This also allows us to remove all references to AnimationCollection and the
animation managers from Animation.
This commit is contained in:
Brian Birtles 2016-01-13 07:54:54 +09:00
Родитель 9b8cbf0b17
Коммит 2a70c0a477
10 изменённых файлов: 50 добавлений и 146 удалений

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

@ -11,8 +11,6 @@
#include "mozilla/AutoRestore.h"
#include "mozilla/AsyncEventDispatcher.h" // For AsyncEventDispatcher
#include "mozilla/Maybe.h" // For Maybe
#include "AnimationCommon.h" // For AnimationCollection,
// CommonAnimationManager
#include "nsDOMMutationObserver.h" // For nsAutoAnimationMutationBatch
#include "nsIDocument.h" // For nsIDocument
#include "nsIPresShell.h" // For nsIPresShell
@ -1040,10 +1038,23 @@ Animation::FlushStyle() const
void
Animation::PostUpdate()
{
AnimationCollection* collection = GetCollection();
if (collection) {
collection->RequestRestyle(EffectCompositor::RestyleType::Layer);
nsPresContext* presContext = GetPresContext();
if (!presContext) {
return;
}
Element* targetElement;
nsCSSPseudoElements::Type targetPseudoType;
mEffect->GetTarget(targetElement, targetPseudoType);
if (!targetElement) {
return;
}
presContext->EffectCompositor()
->RequestRestyle(targetElement,
targetPseudoType,
EffectCompositor::RestyleType::Layer,
CascadeLevel());
}
void
@ -1154,27 +1165,6 @@ Animation::GetPresContext() const
return mEffect->GetPresContext();
}
AnimationCollection*
Animation::GetCollection() const
{
CommonAnimationManager* manager = GetAnimationManager();
if (!manager) {
return nullptr;
}
MOZ_ASSERT(mEffect,
"An animation with an animation manager must have an effect");
Element* targetElement;
nsCSSPseudoElements::Type targetPseudoType;
mEffect->GetTarget(targetElement, targetPseudoType);
MOZ_ASSERT(targetElement,
"An animation with an animation manager must have a target");
return manager->GetAnimationCollection(targetElement,
targetPseudoType,
false /* aCreateIfNeeded */);
}
void
Animation::DoFinishNotification(SyncNotifyFlag aSyncNotifyFlag)
{

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

@ -39,9 +39,7 @@ class nsPresContext;
namespace mozilla {
struct AnimationCollection;
class AnimValuesStyleRule;
class CommonAnimationManager;
namespace dom {
@ -313,8 +311,6 @@ public:
void NotifyEffectTimingUpdated();
AnimationCollection* GetCollection() const;
protected:
void SilentlySetCurrentTime(const TimeDuration& aNewCurrentTime);
void SilentlySetPlaybackRate(double aPlaybackRate);
@ -373,7 +369,6 @@ protected:
nsIDocument* GetRenderedDocument() const;
nsPresContext* GetPresContext() const;
virtual CommonAnimationManager* GetAnimationManager() const = 0;
RefPtr<AnimationTimeline> mTimeline;
RefPtr<KeyframeEffectReadOnly> mEffect;

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

@ -11,9 +11,8 @@
#include "mozilla/dom/KeyframeEffect.h" // For KeyframeEffectReadOnly
#include "mozilla/AnimationUtils.h"
#include "mozilla/EffectSet.h"
#include "mozilla/InitializerList.h"
#include "mozilla/LayerAnimationInfo.h"
#include "AnimationCommon.h" // For AnimationCollection
#include "nsAnimationManager.h"
#include "nsComputedDOMStyle.h" // nsComputedDOMStyle::GetPresShellForContent
#include "nsCSSPropertySet.h"
#include "nsCSSProps.h"
@ -21,7 +20,7 @@
#include "nsLayoutUtils.h"
#include "nsRuleNode.h" // For nsRuleNode::ComputePropertiesOverridingAnimation
#include "nsTArray.h"
#include "nsTransitionManager.h"
#include "RestyleManager.h"
using mozilla::dom::Animation;
using mozilla::dom::Element;
@ -156,6 +155,17 @@ EffectCompositor::RequestRestyle(dom::Element* aElement,
}
elementsToRestyle.Put(key, true);
}
if (aRestyleType == RestyleType::Layer) {
// Prompt layers to re-sync their animations.
mPresContext->ClearLastStyleUpdateForAllAnimations();
mPresContext->RestyleManager()->IncrementAnimationGeneration();
EffectSet* effectSet =
EffectSet::GetEffectSet(aElement, aPseudoType);
if (effectSet) {
effectSet->UpdateAnimationGeneration(mPresContext);
}
}
}
void
@ -508,26 +518,14 @@ EffectCompositor::UpdateCascadeResults(EffectSet& aEffectSet,
// layers with the winning animations.
nsPresContext* presContext = GetPresContext(aElement);
if (changed && presContext) {
// We currently unconditionally update both animations and transitions
// even if we could, for example, get away with only updating animations.
// This is a temporary measure until we unify all animation style updating
// under EffectCompositor.
AnimationCollection* animations =
presContext->AnimationManager()->GetAnimationCollection(aElement,
aPseudoType,
false);
/* don't create */
if (animations) {
animations->RequestRestyle(RestyleType::Layer);
}
AnimationCollection* transitions =
presContext->TransitionManager()->GetAnimationCollection(aElement,
aPseudoType,
false);
/* don't create */
if (transitions) {
transitions->RequestRestyle(RestyleType::Layer);
// Update both transitions and animations. We could detect *which* levels
// actually changed and only update them, but that's probably unnecessary.
for (auto level : { CascadeLevel::Animations,
CascadeLevel::Transitions }) {
presContext->EffectCompositor()->RequestRestyle(aElement,
aPseudoType,
RestyleType::Layer,
level);
}
}
}

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

@ -14,7 +14,6 @@
#include "mozilla/FloatingPoint.h"
#include "mozilla/LookAndFeel.h" // For LookAndFeel::GetInt
#include "mozilla/StyleAnimationValue.h"
#include "AnimationCommon.h"
#include "Layers.h" // For Layer
#include "nsCSSParser.h"
#include "nsCSSPropertySet.h"
@ -164,7 +163,7 @@ KeyframeEffectReadOnly::NotifyAnimationTimingUpdated()
}
// Request restyle if necessary.
ComputedTiming computedTiming = GetComputedTiming();
//
// Bug 1235002: We should skip requesting a restyle when mProperties is empty.
// However, currently we don't properly encapsulate mProperties so we can't
// detect when it changes. As a result, if we skip requesting restyles when
@ -176,29 +175,16 @@ KeyframeEffectReadOnly::NotifyAnimationTimingUpdated()
//
// Bug 1216843: When we implement iteration composite modes, we need to
// also detect if the current iteration has changed.
if (computedTiming.mProgress != mProgressOnLastCompose) {
if (mAnimation && GetComputedTiming().mProgress != mProgressOnLastCompose) {
EffectCompositor::RestyleType restyleType =
CanThrottle() ?
EffectCompositor::RestyleType::Throttled :
EffectCompositor::RestyleType::Standard;
// FIXME: This arrangement of calling RequestRestyle on *either* the
// collection or the compositor is temporary while we move this method
// to the compositor.
//
// In the case where we don't have a collection (as is often the case
// when we create animations but haven't yet added them to a collection
// yet) we still need to make sure that the effect ends up in the
// "needs restyle" map in the compositor.
AnimationCollection* collection = GetCollection();
if (collection) {
collection->RequestRestyle(restyleType);
} else if (mAnimation) {
nsPresContext* presContext = GetPresContext();
if (presContext) {
presContext->EffectCompositor()->
RequestRestyle(mTarget, mPseudoType, restyleType,
mAnimation->CascadeLevel());
}
nsPresContext* presContext = GetPresContext();
if (presContext) {
presContext->EffectCompositor()->
RequestRestyle(mTarget, mPseudoType, restyleType,
mAnimation->CascadeLevel());
}
}
}
@ -470,7 +456,7 @@ KeyframeEffectReadOnly::ComposeStyle(RefPtr<AnimValuesStyleRule>& aStyleRule,
"incorrect last to key");
if (aSetProperties.HasProperty(prop.mProperty)) {
// Animations are composed by AnimationCollection by iterating
// Animations are composed by EffectCompositor by iterating
// from the last animation to first. For animations targetting the
// same property, the later one wins. So if this property is already set,
// we should not override it.
@ -2008,12 +1994,6 @@ KeyframeEffectReadOnly::GetPresContext() const
return shell->GetPresContext();
}
AnimationCollection *
KeyframeEffectReadOnly::GetCollection() const
{
return mAnimation ? mAnimation->GetCollection() : nullptr;
}
/* static */ bool
KeyframeEffectReadOnly::IsGeometricProperty(
const nsCSSProperty aProperty)

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

@ -291,7 +291,11 @@ CommonAnimationManager::FlushAnimations()
"Should not have a transition/animation collection for an "
"element that is not part of the document tree");
collection->RequestRestyle(EffectCompositor::RestyleType::Standard);
mPresContext->EffectCompositor()->RequestRestyle(
collection->mElement,
collection->PseudoElementType(),
EffectCompositor::RestyleType::Standard,
cascadeLevel);
}
}
@ -451,42 +455,6 @@ AnimationCollection::EnsureStyleRuleFor()
cascadeLevel);
}
void
AnimationCollection::RequestRestyle(EffectCompositor::RestyleType aRestyleType)
{
MOZ_ASSERT(IsForElement() || IsForBeforePseudo() || IsForAfterPseudo(),
"Unexpected mElementProperty; might restyle too much");
nsPresContext* presContext = mManager->PresContext();
if (!presContext) {
// Pres context will be null after the manager is disconnected.
return;
}
EffectCompositor::CascadeLevel cascadeLevel =
IsForAnimations() ?
EffectCompositor::CascadeLevel::Animations :
EffectCompositor::CascadeLevel::Transitions;
presContext->EffectCompositor()->RequestRestyle(mElement,
PseudoElementType(),
aRestyleType,
cascadeLevel);
// Steps for RestyleType::Layer:
if (aRestyleType == EffectCompositor::RestyleType::Layer) {
// Prompt layers to re-sync their animations.
presContext->ClearLastStyleUpdateForAllAnimations();
presContext->RestyleManager()->IncrementAnimationGeneration();
EffectSet* effectSet =
EffectSet::GetEffectSet(mElement, PseudoElementType());
if (effectSet) {
effectSet->UpdateAnimationGeneration(presContext);
}
}
}
void
AnimationCollection::UpdateCheckGeneration(
nsPresContext* aPresContext)

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

@ -12,7 +12,6 @@
#include "nsCSSProperty.h"
#include "nsDisplayList.h" // For nsDisplayItem::Type
#include "mozilla/AnimationComparator.h"
#include "mozilla/EffectCompositor.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/LinkedList.h"
#include "mozilla/MemoryReporting.h"
@ -171,8 +170,6 @@ struct AnimationCollection : public LinkedListElement<AnimationCollection>
void EnsureStyleRuleFor();
void RequestRestyle(EffectCompositor::RestyleType aRestyleType);
public:
// True if this animation can be performed on the compositor thread.
//

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

@ -277,17 +277,6 @@ CSSAnimation::QueueEvents()
this));
}
CommonAnimationManager*
CSSAnimation::GetAnimationManager() const
{
nsPresContext* context = GetPresContext();
if (!context) {
return nullptr;
}
return context->AnimationManager();
}
void
CSSAnimation::UpdateTiming(SeekFlag aSeekFlag, SyncNotifyFlag aSyncNotifyFlag)
{

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

@ -163,7 +163,6 @@ protected:
}
// Animation overrides
CommonAnimationManager* GetAnimationManager() const override;
void UpdateTiming(SeekFlag aSeekFlag,
SyncNotifyFlag aSyncNotifyFlag) override;

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

@ -103,17 +103,6 @@ CSSTransition::PlayFromJS(ErrorResult& aRv)
Animation::PlayFromJS(aRv);
}
CommonAnimationManager*
CSSTransition::GetAnimationManager() const
{
nsPresContext* context = GetPresContext();
if (!context) {
return nullptr;
}
return context->TransitionManager();
}
void
CSSTransition::UpdateTiming(SeekFlag aSeekFlag, SyncNotifyFlag aSyncNotifyFlag)
{

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

@ -172,7 +172,6 @@ protected:
}
// Animation overrides
CommonAnimationManager* GetAnimationManager() const override;
void UpdateTiming(SeekFlag aSeekFlag,
SyncNotifyFlag aSyncNotifyFlag) override;