summaryrefslogtreecommitdiffstats
path: root/dom/animation/Animation.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:53:15 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:53:15 +0000
commit50e4c49ba64ce680143c83b142ae5a7ec30fde54 (patch)
tree269a97c1e612c69c97e0a622db091ba5392965c9 /dom/animation/Animation.cpp
parentAdding debian version 125.0.2-1. (diff)
downloadfirefox-50e4c49ba64ce680143c83b142ae5a7ec30fde54.tar.xz
firefox-50e4c49ba64ce680143c83b142ae5a7ec30fde54.zip
Merging upstream version 125.0.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/animation/Animation.cpp')
-rw-r--r--dom/animation/Animation.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/dom/animation/Animation.cpp b/dom/animation/Animation.cpp
index 6f0fee007c..ad52495e67 100644
--- a/dom/animation/Animation.cpp
+++ b/dom/animation/Animation.cpp
@@ -6,6 +6,7 @@
#include "Animation.h"
+#include "mozilla/Likely.h"
#include "nsIFrame.h"
#include "AnimationUtils.h"
#include "mozAutoDocUpdate.h"
@@ -926,12 +927,13 @@ void Animation::SetCurrentTimeAsDouble(const Nullable<double>& aCurrentTime,
void Animation::Tick(AnimationTimeline::TickState& aTickState) {
if (Pending()) {
- // Finish pending if we can, but make sure we've seen one existing tick, or
- // we've requested to get started via SetPendingReadyTime.
- if (!mPendingReadyTime.IsNull() || mSawTickWhilePending) {
+ if (!mPendingReadyTime.IsNull()) {
TryTriggerNow();
+ } else if (MOZ_LIKELY(mTimeline)) {
+ // Makes sure that we trigger the animation on the next tick but,
+ // importantly, with this tick's timestamp.
+ mPendingReadyTime = mTimeline->GetCurrentTimeAsTimeStamp();
}
- mSawTickWhilePending = true;
}
UpdateTiming(SeekFlag::NoSeek, SyncNotifyFlag::Sync);
@@ -1351,17 +1353,21 @@ void Animation::NotifyEffectTargetUpdated() {
MaybeScheduleReplacementCheck();
}
-static bool EnsurePaintIsScheduled(Document& aDoc) {
+static TimeStamp EnsurePaintIsScheduled(Document& aDoc) {
PresShell* presShell = aDoc.GetPresShell();
if (!presShell) {
- return false;
+ return {};
}
nsIFrame* rootFrame = presShell->GetRootFrame();
if (!rootFrame) {
- return false;
+ return {};
}
rootFrame->SchedulePaintWithoutInvalidatingObservers();
- return rootFrame->PresContext()->RefreshDriver()->IsInRefresh();
+ auto* rd = rootFrame->PresContext()->RefreshDriver();
+ if (!rd->IsInRefresh()) {
+ return {};
+ }
+ return rd->MostRecentRefresh(/* aEnsureTimerStarted = */ false);
}
// https://drafts.csswg.org/web-animations/#play-an-animation
@@ -1453,7 +1459,6 @@ void Animation::PlayNoUpdate(ErrorResult& aRv, LimitBehavior aLimitBehavior) {
mPendingState = PendingState::PlayPending;
mPendingReadyTime = {};
- mSawTickWhilePending = false;
if (Document* doc = GetRenderedDocument()) {
if (HasFiniteTimeline()) {
// Always schedule a task even if we would like to let this animation
@@ -1464,7 +1469,7 @@ void Animation::PlayNoUpdate(ErrorResult& aRv, LimitBehavior aLimitBehavior) {
doc->GetOrCreateScrollTimelineAnimationTracker()->AddPending(*this);
}
// Make sure to try to schedule a tick.
- mSawTickWhilePending = EnsurePaintIsScheduled(*doc);
+ mPendingReadyTime = EnsurePaintIsScheduled(*doc);
}
UpdateTiming(SeekFlag::NoSeek, SyncNotifyFlag::Async);
@@ -1515,14 +1520,12 @@ void Animation::Pause(ErrorResult& aRv) {
mPendingState = PendingState::PausePending;
mPendingReadyTime = {};
- mSawTickWhilePending = false;
-
// See the relevant PlayPending code for comments.
if (Document* doc = GetRenderedDocument()) {
if (HasFiniteTimeline()) {
doc->GetOrCreateScrollTimelineAnimationTracker()->AddPending(*this);
}
- mSawTickWhilePending = EnsurePaintIsScheduled(*doc);
+ mPendingReadyTime = EnsurePaintIsScheduled(*doc);
}
UpdateTiming(SeekFlag::NoSeek, SyncNotifyFlag::Async);