Commit ef5184e1 authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

Block SMILTimeContainer updates when we're updating intervals

This adds a |is_updating_intervals_| flag to SMILTimeContainer, and sets
it in UpdateIntervals() and when calling Reset() on the sandwiches.
When this flag is true SMILTimeContainer::ScheduleIntervalUpdate() will
not schedule an update since UpdateIntervals() (in both cases) will
handle the update.
This should allow getting rid of the SVGImage::ScheduleTimelineRewind()
hack.

Bug: 998526
Change-Id: Iad31f2684db40dc71f254d7d19f57a4538272a5d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1841332
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703245}
parent 41700f35
......@@ -68,6 +68,7 @@ SMILTimeContainer::SMILTimeContainer(SVGSVGElement& owner)
paused_(false),
document_order_indexes_dirty_(false),
intervals_dirty_(true),
is_updating_intervals_(false),
wakeup_timer_(
owner.GetDocument().GetTaskRunner(TaskType::kInternalDefault),
this,
......@@ -141,6 +142,11 @@ bool SMILTimeContainer::HasPendingSynchronization() const {
}
void SMILTimeContainer::ScheduleIntervalUpdate() {
// We're inside a call to UpdateIntervals() (or resetting the timeline), so
// we don't need to request an update - that will happen after the regular
// update has finished (if needed).
if (is_updating_intervals_)
return;
if (!IsStarted())
return;
// Schedule UpdateAnimations...() to be called asynchronously so multiple
......@@ -270,6 +276,8 @@ void SMILTimeContainer::SetElapsed(SMILTime elapsed) {
SynchronizeToDocumentTimeline();
{
base::AutoReset<bool> updating_intervals_scope(&is_updating_intervals_,
true);
ScheduledAnimationsMutationsForbidden scope(this);
for (auto& sandwich : scheduled_animations_.Values())
sandwich->Reset();
......@@ -427,6 +435,7 @@ bool SMILTimeContainer::CanScheduleFrame(SMILTime earliest_fire_time) const {
void SMILTimeContainer::UpdateAnimationsAndScheduleFrameIfNeeded(
SMILTime elapsed) {
DCHECK(GetDocument().IsActive());
DCHECK(!wakeup_timer_.IsActive());
UpdateAnimationTimings(elapsed);
ApplyAnimationValues(elapsed);
......@@ -438,6 +447,7 @@ void SMILTimeContainer::UpdateAnimationsAndScheduleFrameIfNeeded(
if (next_progress_time <= elapsed)
break;
}
DCHECK(!wakeup_timer_.IsActive());
if (!CanScheduleFrame(next_progress_time))
return;
......@@ -475,6 +485,8 @@ void SMILTimeContainer::RemoveUnusedKeys() {
void SMILTimeContainer::UpdateIntervals(SMILTime document_time) {
DCHECK(document_time.IsFinite());
DCHECK_GE(document_time, SMILTime());
base::AutoReset<bool> updating_intervals_scope(&is_updating_intervals_, true);
do {
intervals_dirty_ = false;
......
......@@ -139,11 +139,12 @@ class SMILTimeContainer final : public GarbageCollected<SMILTimeContainer> {
base::TimeDelta reference_time_;
FrameSchedulingState frame_scheduling_state_;
bool started_; // The timeline has been started.
bool paused_; // The timeline is paused.
bool started_ : 1; // The timeline has been started.
bool paused_ : 1; // The timeline is paused.
bool document_order_indexes_dirty_;
bool intervals_dirty_;
bool document_order_indexes_dirty_ : 1;
bool intervals_dirty_ : 1;
bool is_updating_intervals_;
TaskRunnerTimer<SMILTimeContainer> wakeup_timer_;
TaskRunnerTimer<SMILTimeContainer> animation_policy_once_timer_;
......@@ -167,6 +168,7 @@ class SMILTimeContainer final : public GarbageCollected<SMILTimeContainer> {
#endif
}
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_SVG_ANIMATION_SMIL_TIME_CONTAINER_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment