Bug 1178662 part 3 - Separate SetTimeline function in order to call from style. r?birtles
MozReview-Commit-ID: 9KbsbPuAMW7
--- a/dom/animation/Animation.cpp
+++ b/dom/animation/Animation.cpp
@@ -108,17 +108,17 @@ Animation::Constructor(const GlobalObjec
AnimationUtils::GetCurrentRealmDocument(aGlobal.Context());
if (!document) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
timeline = document->Timeline();
}
- animation->SetTimeline(timeline);
+ animation->SetTimelineNoUpdate(timeline);
animation->SetEffect(aEffect);
return animation.forget();
}
void
Animation::SetId(const nsAString& aId)
{
@@ -146,32 +146,36 @@ Animation::SetEffect(KeyframeEffectReadO
}
UpdateTiming(SeekFlag::NoSeek, SyncNotifyFlag::Async);
}
void
Animation::SetTimeline(AnimationTimeline* aTimeline)
{
+ SetTimelineNoUpdate(aTimeline);
+ PostUpdate();
+}
+
+void
+Animation::SetTimelineNoUpdate(AnimationTimeline* aTimeline)
+{
if (mTimeline == aTimeline) {
return;
}
if (mTimeline) {
mTimeline->NotifyAnimationUpdated(*this);
}
mTimeline = aTimeline;
// FIXME(spec): Once we implement the seeking defined in the spec
// surely this should be SeekFlag::DidSeek but the spec says otherwise.
UpdateTiming(SeekFlag::NoSeek, SyncNotifyFlag::Async);
-
- // FIXME: When we expose this method to script we'll need to call PostUpdate
- // (but *not* when this method gets called from style).
}
// https://w3c.github.io/web-animations/#set-the-animation-start-time
void
Animation::SetStartTime(const Nullable<TimeDuration>& aNewStartTime)
{
if (aNewStartTime == mStartTime) {
return;
--- a/dom/animation/Animation.h
+++ b/dom/animation/Animation.h
@@ -140,16 +140,17 @@ public:
* in future we will likely have to flush style in
* CSSAnimation::PauseFromJS so we leave it for now.
*/
void PauseFromJS(ErrorResult& aRv) { Pause(aRv); }
// Wrapper functions for Animation DOM methods when called from style.
virtual void CancelFromStyle() { CancelNoUpdate(); }
+ void SetTimelineNoUpdate(AnimationTimeline* aTimeline);
virtual void Tick();
bool NeedsTicks() const
{
AnimationPlayState playState = PlayState();
return playState == AnimationPlayState::Running ||
playState == AnimationPlayState::Pending;
}
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -644,17 +644,17 @@ CSSAnimationBuilder::Build(nsPresContext
effect->SetKeyframes(Move(keyframes), mStyleContext);
RefPtr<CSSAnimation> animation =
new CSSAnimation(aPresContext->Document()->GetScopeObject(),
aSrc.GetName());
animation->SetOwningElement(
OwningElementRef(*mTarget, mStyleContext->GetPseudoType()));
- animation->SetTimeline(mTimeline);
+ animation->SetTimelineNoUpdate(mTimeline);
animation->SetEffect(effect);
if (isStylePaused) {
animation->PauseFromStyle();
} else {
animation->PlayFromStyle();
}
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -761,17 +761,17 @@ nsTransitionManager::ConsiderStartingTra
MOZ_ASSERT(mPresContext->RestyleManager()->IsGecko(),
"ServoRestyleManager should not use nsTransitionManager "
"for transitions");
RefPtr<CSSTransition> animation =
new CSSTransition(mPresContext->Document()->GetScopeObject());
animation->SetOwningElement(
OwningElementRef(*aElement, aNewStyleContext->GetPseudoType()));
- animation->SetTimeline(timeline);
+ animation->SetTimelineNoUpdate(timeline);
animation->SetCreationSequence(
mPresContext->RestyleManager()->AsGecko()->GetAnimationGeneration());
// The order of the following two calls is important since PlayFromStyle
// will add the animation to the PendingAnimationTracker of its effect's
// document. When we come to make effect writeable (bug 1049975) we should
// remove this dependency.
animation->SetEffect(pt);
animation->PlayFromStyle();