Commit 147a2ee7 authored by Edvard Thörnros's avatar Edvard Thörnros Committed by Commit Bot

Sync SMIL timeline when inserting into document

SMILTimeContainer::Elapsed() could return a negative time, this
should not be possible anymore. Since if you now reinsert
the SVG, it should resync.

Nothing else should have changed.

Bug: 996196
Change-Id: Id75b1604b8a087c5c046f842273cd8355075cb56
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1763420
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Reviewed-by: default avatarFredrik Söderquist <fs@opera.com>
Auto-Submit: Edvard Thörnros <edvardt@opera.com>
Cr-Commit-Position: refs/heads/master@{#689016}
parent 70f5df8a
......@@ -257,6 +257,17 @@ void SMILTimeContainer::SetElapsed(double elapsed) {
UpdateAnimationsAndScheduleFrameIfNeeded(elapsed, true);
}
void SMILTimeContainer::ResetReferenceTime() {
DCHECK(IsStarted());
if (!GetDocument().IsActive())
return;
if (!HandleAnimationPolicy(kRestartOnceTimerIfNotPaused))
return;
SynchronizeToDocumentTimeline();
}
void SMILTimeContainer::ScheduleAnimationFrame(double delay_time) {
DCHECK(std::isfinite(delay_time));
DCHECK(IsTimelineRunning());
......
......@@ -76,6 +76,8 @@ class SMILTimeContainer : public GarbageCollectedFinalized<SMILTimeContainer> {
void Trace(blink::Visitor*);
void ResetReferenceTime();
private:
enum FrameSchedulingState {
// No frame scheduled.
......
......@@ -520,9 +520,12 @@ Node::InsertionNotificationRequest SVGSVGElement::InsertedInto(
// the load event, but if we miss that train (deferred programmatic
// element insertion for example) we need to initialize the time container
// here.
if (!GetDocument().Parsing() && GetDocument().LoadEventFinished() &&
!TimeContainer()->IsStarted())
TimeContainer()->Start();
if (!GetDocument().Parsing() && GetDocument().LoadEventFinished()) {
if (!TimeContainer()->IsStarted())
TimeContainer()->Start();
else
TimeContainer()->ResetReferenceTime();
}
}
return SVGGraphicsElement::InsertedInto(root_parent);
}
......
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