Bug 1078122 part 2 - Encapsulate mIsRunningOnCompositor in AnimationPlayer; r=dholbert
--- a/dom/animation/AnimationPlayer.h
+++ b/dom/animation/AnimationPlayer.h
@@ -30,19 +30,19 @@ namespace dom {
class AnimationPlayer : public nsWrapperCache
{
protected:
virtual ~AnimationPlayer() { }
public:
explicit AnimationPlayer(AnimationTimeline* aTimeline)
- : mIsRunningOnCompositor(false)
- , mTimeline(aTimeline)
+ : mTimeline(aTimeline)
, mIsPaused(false)
+ , mIsRunningOnCompositor(false)
{
}
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(AnimationPlayer)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(AnimationPlayer)
AnimationTimeline* GetParentObject() const { return mTimeline; }
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
@@ -87,35 +87,38 @@ public:
bool HasCurrentSource() const {
return GetSource() && GetSource()->IsCurrent();
}
bool HasInEffectSource() const {
return GetSource() && GetSource()->IsInEffect();
}
+ void SetIsRunningOnCompositor() { mIsRunningOnCompositor = true; }
+ void ClearIsRunningOnCompositor() { mIsRunningOnCompositor = false; }
+
// Returns true if this animation does not currently need to update
// style on the main thread (e.g. because it is empty, or is
// running on the compositor).
bool CanThrottle() const;
// The beginning of the delay period.
Nullable<TimeDuration> mStartTime; // Timeline timescale
- bool mIsRunningOnCompositor;
nsRefPtr<AnimationTimeline> mTimeline;
nsRefPtr<Animation> mSource;
protected:
void FlushStyle() const;
void MaybePostRestyle() const;
StickyTimeDuration SourceContentEnd() const;
Nullable<TimeDuration> mHoldTime; // Player timescale
bool mIsPaused;
+ bool mIsRunningOnCompositor;
};
} // namespace dom
class CSSAnimationPlayer MOZ_FINAL : public dom::AnimationPlayer
{
public:
explicit CSSAnimationPlayer(dom::AnimationTimeline* aTimeline)
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -407,17 +407,17 @@ AddAnimationsForProperty(nsIFrame* aFram
for (size_t playerIdx = 0; playerIdx < aPlayers.Length(); playerIdx++) {
AnimationPlayer* player = aPlayers[playerIdx];
dom::Animation* anim = player->GetSource();
if (!(anim && anim->HasAnimationOfProperty(aProperty) &&
player->IsRunning())) {
continue;
}
AddAnimationForProperty(aFrame, aProperty, player, aLayer, aData, aPending);
- player->mIsRunningOnCompositor = true;
+ player->SetIsRunningOnCompositor();
}
}
/* static */ void
nsDisplayListBuilder::AddAnimationsAndTransitionsToLayer(Layer* aLayer,
nsDisplayListBuilder* aBuilder,
nsDisplayItem* aItem,
nsIFrame* aFrame,
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -306,17 +306,17 @@ nsAnimationManager::CheckAnimationRule(n
if (oldPlayer->GetSource() && newPlayer->GetSource()) {
Animation* oldAnim = oldPlayer->GetSource();
Animation* newAnim = newPlayer->GetSource();
oldAnim->Timing() = newAnim->Timing();
oldAnim->Properties() = newAnim->Properties();
}
// Reset compositor state so animation will be re-synchronized.
- oldPlayer->mIsRunningOnCompositor = false;
+ oldPlayer->ClearIsRunningOnCompositor();
// Handle changes in play state.
// CSSAnimationPlayer takes care of override behavior so that,
// for example, if the author has called pause(), that will
// override the animation-play-state.
// (We should check newPlayer->IsStylePaused() but that requires
// downcasting to CSSAnimationPlayer and we happen to know that
// newPlayer will only ever be paused by calling PauseFromStyle
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -829,17 +829,17 @@ nsTransitionManager::FlushTransitions(Fl
// to know not to start a new transition for the transition
// from the almost-completed value to the final value.
player->GetSource()->SetIsFinishedTransition();
collection->UpdateAnimationGeneration(mPresContext);
transitionStartedOrEnded = true;
} else if ((computedTiming.mPhase ==
ComputedTiming::AnimationPhase_Active) &&
canThrottleTick &&
- !player->mIsRunningOnCompositor) {
+ !player->IsRunningOnCompositor()) {
// Start a transition with a delay where we should start the
// transition proper.
collection->UpdateAnimationGeneration(mPresContext);
transitionStartedOrEnded = true;
}
}
} while (i != 0);