зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1593222: part 10) Move `Animation*` methods to `MutationObservers`. r=smaug
Depends on D51825 Differential Revision: https://phabricator.services.mozilla.com/D51826 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
ba0285f534
Коммит
4807f484fc
|
@ -121,7 +121,7 @@ void Animation::SetId(const nsAString& aId) {
|
|||
return;
|
||||
}
|
||||
mId = aId;
|
||||
nsNodeUtils::AnimationChanged(this);
|
||||
MutationObservers::NotifyAnimationChanged(this);
|
||||
}
|
||||
|
||||
void Animation::SetEffect(AnimationEffect* aEffect) {
|
||||
|
@ -144,7 +144,7 @@ void Animation::SetEffectNoUpdate(AnimationEffect* aEffect) {
|
|||
// We need to notify observers now because once we set mEffect to null
|
||||
// we won't be able to find the target element to notify.
|
||||
if (mIsRelevant) {
|
||||
nsNodeUtils::AnimationRemoved(this);
|
||||
MutationObservers::NotifyAnimationRemoved(this);
|
||||
}
|
||||
|
||||
// Break links with the old effect and then drop it.
|
||||
|
@ -175,7 +175,7 @@ void Animation::SetEffectNoUpdate(AnimationEffect* aEffect) {
|
|||
// If the target is different, the change notification will be ignored by
|
||||
// AutoMutationBatchForAnimation.
|
||||
if (wasRelevant && mIsRelevant) {
|
||||
nsNodeUtils::AnimationChanged(this);
|
||||
MutationObservers::NotifyAnimationChanged(this);
|
||||
}
|
||||
|
||||
ReschedulePendingTasks();
|
||||
|
@ -261,7 +261,7 @@ void Animation::SetStartTime(const Nullable<TimeDuration>& aNewStartTime) {
|
|||
|
||||
UpdateTiming(SeekFlag::DidSeek, SyncNotifyFlag::Async);
|
||||
if (IsRelevant()) {
|
||||
nsNodeUtils::AnimationChanged(this);
|
||||
MutationObservers::NotifyAnimationChanged(this);
|
||||
}
|
||||
PostUpdate();
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ void Animation::SetCurrentTime(const TimeDuration& aSeekTime) {
|
|||
|
||||
UpdateTiming(SeekFlag::DidSeek, SyncNotifyFlag::Async);
|
||||
if (IsRelevant()) {
|
||||
nsNodeUtils::AnimationChanged(this);
|
||||
MutationObservers::NotifyAnimationChanged(this);
|
||||
}
|
||||
PostUpdate();
|
||||
}
|
||||
|
@ -346,7 +346,7 @@ void Animation::SetPlaybackRate(double aPlaybackRate) {
|
|||
// - update the playback rate on animations on layers.
|
||||
UpdateTiming(SeekFlag::DidSeek, SyncNotifyFlag::Async);
|
||||
if (IsRelevant()) {
|
||||
nsNodeUtils::AnimationChanged(this);
|
||||
MutationObservers::NotifyAnimationChanged(this);
|
||||
}
|
||||
PostUpdate();
|
||||
}
|
||||
|
@ -391,7 +391,7 @@ void Animation::UpdatePlaybackRate(double aPlaybackRate) {
|
|||
// All we need to do is update observers so that, e.g. DevTools, report the
|
||||
// right information.
|
||||
if (IsRelevant()) {
|
||||
nsNodeUtils::AnimationChanged(this);
|
||||
MutationObservers::NotifyAnimationChanged(this);
|
||||
}
|
||||
} else if (playState == AnimationPlayState::Finished) {
|
||||
MOZ_ASSERT(mTimeline && !mTimeline->GetCurrentTimeAsDuration().IsNull(),
|
||||
|
@ -419,7 +419,7 @@ void Animation::UpdatePlaybackRate(double aPlaybackRate) {
|
|||
// timing.
|
||||
UpdateTiming(SeekFlag::NoSeek, SyncNotifyFlag::Async);
|
||||
if (IsRelevant()) {
|
||||
nsNodeUtils::AnimationChanged(this);
|
||||
MutationObservers::NotifyAnimationChanged(this);
|
||||
}
|
||||
PostUpdate();
|
||||
} else {
|
||||
|
@ -570,7 +570,7 @@ void Animation::Finish(ErrorResult& aRv) {
|
|||
}
|
||||
UpdateTiming(SeekFlag::DidSeek, SyncNotifyFlag::Sync);
|
||||
if (didChange && IsRelevant()) {
|
||||
nsNodeUtils::AnimationChanged(this);
|
||||
MutationObservers::NotifyAnimationChanged(this);
|
||||
}
|
||||
PostUpdate();
|
||||
}
|
||||
|
@ -982,9 +982,9 @@ void Animation::UpdateRelevance() {
|
|||
|
||||
// Notify animation observers.
|
||||
if (wasRelevant && !mIsRelevant) {
|
||||
nsNodeUtils::AnimationRemoved(this);
|
||||
MutationObservers::NotifyAnimationRemoved(this);
|
||||
} else if (!wasRelevant && mIsRelevant) {
|
||||
nsNodeUtils::AnimationAdded(this);
|
||||
MutationObservers::NotifyAnimationAdded(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1357,7 +1357,7 @@ void Animation::PlayNoUpdate(ErrorResult& aRv, LimitBehavior aLimitBehavior) {
|
|||
|
||||
UpdateTiming(SeekFlag::NoSeek, SyncNotifyFlag::Async);
|
||||
if (IsRelevant()) {
|
||||
nsNodeUtils::AnimationChanged(this);
|
||||
MutationObservers::NotifyAnimationChanged(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1405,7 +1405,7 @@ void Animation::Pause(ErrorResult& aRv) {
|
|||
|
||||
UpdateTiming(SeekFlag::NoSeek, SyncNotifyFlag::Async);
|
||||
if (IsRelevant()) {
|
||||
nsNodeUtils::AnimationChanged(this);
|
||||
MutationObservers::NotifyAnimationChanged(this);
|
||||
}
|
||||
|
||||
PostUpdate();
|
||||
|
@ -1453,7 +1453,7 @@ void Animation::ResumeAt(const TimeDuration& aReadyTime) {
|
|||
// If we had a pending playback rate, we will have now applied it so we need
|
||||
// to notify observers.
|
||||
if (hadPendingPlaybackRate && IsRelevant()) {
|
||||
nsNodeUtils::AnimationChanged(this);
|
||||
MutationObservers::NotifyAnimationChanged(this);
|
||||
}
|
||||
|
||||
if (mReady) {
|
||||
|
|
|
@ -79,7 +79,7 @@ void AnimationEffect::SetSpecifiedTiming(TimingParams&& aTiming) {
|
|||
mAnimation->NotifyEffectTimingUpdated();
|
||||
|
||||
if (mAnimation->IsRelevant()) {
|
||||
nsNodeUtils::AnimationChanged(mAnimation);
|
||||
MutationObservers::NotifyAnimationChanged(mAnimation);
|
||||
}
|
||||
|
||||
if (AsKeyframeEffect()) {
|
||||
|
|
|
@ -109,7 +109,7 @@ void KeyframeEffect::SetIterationComposite(
|
|||
}
|
||||
|
||||
if (mAnimation && mAnimation->IsRelevant()) {
|
||||
nsNodeUtils::AnimationChanged(mAnimation);
|
||||
MutationObservers::NotifyAnimationChanged(mAnimation);
|
||||
}
|
||||
|
||||
mEffectOptions.mIterationComposite = aIterationComposite;
|
||||
|
@ -128,7 +128,7 @@ void KeyframeEffect::SetComposite(const CompositeOperation& aComposite) {
|
|||
mEffectOptions.mComposite = aComposite;
|
||||
|
||||
if (mAnimation && mAnimation->IsRelevant()) {
|
||||
nsNodeUtils::AnimationChanged(mAnimation);
|
||||
MutationObservers::NotifyAnimationChanged(mAnimation);
|
||||
}
|
||||
|
||||
if (mTarget) {
|
||||
|
@ -149,7 +149,7 @@ void KeyframeEffect::NotifySpecifiedTimingUpdated() {
|
|||
mAnimation->NotifyEffectTimingUpdated();
|
||||
|
||||
if (mAnimation->IsRelevant()) {
|
||||
nsNodeUtils::AnimationChanged(mAnimation);
|
||||
MutationObservers::NotifyAnimationChanged(mAnimation);
|
||||
}
|
||||
|
||||
RequestRestyle(EffectCompositor::RestyleType::Layer);
|
||||
|
@ -242,7 +242,7 @@ void KeyframeEffect::SetKeyframes(nsTArray<Keyframe>&& aKeyframes,
|
|||
KeyframeUtils::DistributeKeyframes(mKeyframes);
|
||||
|
||||
if (mAnimation && mAnimation->IsRelevant()) {
|
||||
nsNodeUtils::AnimationChanged(mAnimation);
|
||||
MutationObservers::NotifyAnimationChanged(mAnimation);
|
||||
}
|
||||
|
||||
// We need to call UpdateProperties() unless the target element doesn't have
|
||||
|
@ -986,7 +986,7 @@ void KeyframeEffect::SetTarget(
|
|||
|
||||
nsAutoAnimationMutationBatch mb(mTarget->mElement->OwnerDoc());
|
||||
if (mAnimation) {
|
||||
nsNodeUtils::AnimationRemoved(mAnimation);
|
||||
MutationObservers::NotifyAnimationRemoved(mAnimation);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1003,7 +1003,7 @@ void KeyframeEffect::SetTarget(
|
|||
|
||||
nsAutoAnimationMutationBatch mb(mTarget->mElement->OwnerDoc());
|
||||
if (mAnimation) {
|
||||
nsNodeUtils::AnimationAdded(mAnimation);
|
||||
MutationObservers::NotifyAnimationAdded(mAnimation);
|
||||
mAnimation->ReschedulePendingTasks();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -226,7 +226,7 @@ void MutationObservers::NotifyContentRemoved(nsINode* aContainer,
|
|||
}
|
||||
} // namespace mozilla
|
||||
|
||||
void nsNodeUtils::AnimationMutated(
|
||||
void MutationObservers::NotifyAnimationMutated(
|
||||
dom::Animation* aAnimation, AnimationMutationType aMutatedType) {
|
||||
MOZ_ASSERT(aAnimation);
|
||||
|
||||
|
@ -256,15 +256,14 @@ void nsNodeUtils::AnimationMutated(
|
|||
}
|
||||
}
|
||||
|
||||
void nsNodeUtils::AnimationAdded(dom::Animation* aAnimation) {
|
||||
AnimationMutated(aAnimation, AnimationMutationType::Added);
|
||||
void MutationObservers::NotifyAnimationAdded(dom::Animation* aAnimation) {
|
||||
NotifyAnimationMutated(aAnimation, AnimationMutationType::Added);
|
||||
}
|
||||
|
||||
void nsNodeUtils::AnimationChanged(dom::Animation* aAnimation) {
|
||||
AnimationMutated(aAnimation, AnimationMutationType::Changed);
|
||||
void MutationObservers::NotifyAnimationChanged(dom::Animation* aAnimation) {
|
||||
NotifyAnimationMutated(aAnimation, AnimationMutationType::Changed);
|
||||
}
|
||||
|
||||
void nsNodeUtils::AnimationRemoved(dom::Animation* aAnimation) {
|
||||
AnimationMutated(aAnimation, AnimationMutationType::Removed);
|
||||
void MutationObservers::NotifyAnimationRemoved(dom::Animation* aAnimation) {
|
||||
NotifyAnimationMutated(aAnimation, AnimationMutationType::Removed);
|
||||
}
|
||||
|
||||
|
|
|
@ -128,19 +128,14 @@ class MutationObservers {
|
|||
ParentChainChanged, (aContent));
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
class nsNodeUtils {
|
||||
public:
|
||||
/**
|
||||
* Notify that an animation is added/changed/removed.
|
||||
* @param aAnimation The animation we added/changed/removed.
|
||||
*/
|
||||
static void AnimationAdded(mozilla::dom::Animation* aAnimation);
|
||||
static void AnimationChanged(mozilla::dom::Animation* aAnimation);
|
||||
static void AnimationRemoved(mozilla::dom::Animation* aAnimation);
|
||||
static void NotifyAnimationAdded(mozilla::dom::Animation* aAnimation);
|
||||
static void NotifyAnimationChanged(mozilla::dom::Animation* aAnimation);
|
||||
static void NotifyAnimationRemoved(mozilla::dom::Animation* aAnimation);
|
||||
|
||||
private:
|
||||
enum class AnimationMutationType { Added, Changed, Removed };
|
||||
|
@ -150,8 +145,11 @@ class nsNodeUtils {
|
|||
* @param aMutationType The mutation type of this animation. It could be
|
||||
* Added, Changed, or Removed.
|
||||
*/
|
||||
static void AnimationMutated(mozilla::dom::Animation* aAnimation,
|
||||
AnimationMutationType aMutatedType);
|
||||
static void NotifyAnimationMutated(mozilla::dom::Animation* aAnimation,
|
||||
AnimationMutationType aMutatedType);
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // nsNodeUtils_h___
|
||||
|
|
|
@ -416,7 +416,7 @@ static void UpdateOldAnimationPropertiesWithNew(
|
|||
// animation to become irrelevant so only add a changed record if
|
||||
// the animation is still relevant.
|
||||
if (animationChanged && aOld.IsRelevant()) {
|
||||
nsNodeUtils::AnimationChanged(&aOld);
|
||||
MutationObservers::NotifyAnimationChanged(&aOld);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ class CSSAnimation final : public Animation {
|
|||
void SetAnimationIndex(uint64_t aIndex) {
|
||||
MOZ_ASSERT(IsTiedToMarkup());
|
||||
if (IsRelevant() && mAnimationIndex != aIndex) {
|
||||
nsNodeUtils::AnimationChanged(this);
|
||||
MutationObservers::NotifyAnimationChanged(this);
|
||||
PostUpdate();
|
||||
}
|
||||
mAnimationIndex = aIndex;
|
||||
|
|
Загрузка…
Ссылка в новой задаче