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

Simplify SVGImage::ResetAnimation

Now that SVGSVGElement::setCurrentTime(...) (or more specifically
SMILTimeContainer::SetElapsed) no longer trigger further updates when
the time container is paused, we can remove the "pending timeline
rewind" workaround.
When doing this also take the opportunity to fold CanScheduleFrame(...)
in SMILTimeContainer into its only caller and simplify a little bit.

Bug: 998526
Change-Id: I9ff3de1e8c4b28284bbf3ed27d128206ea7ee857
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1976410Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#726808}
parent fd291ef1
...@@ -397,16 +397,6 @@ void SMILTimeContainer::ServiceAnimations() { ...@@ -397,16 +397,6 @@ void SMILTimeContainer::ServiceAnimations() {
UpdateAnimationsAndScheduleFrameIfNeeded(Elapsed()); UpdateAnimationsAndScheduleFrameIfNeeded(Elapsed());
} }
bool SMILTimeContainer::CanScheduleFrame(SMILTime earliest_fire_time) const {
// If there's synchronization pending (most likely due to syncbases), then
// let that complete first before attempting to schedule a frame.
if (HasPendingSynchronization())
return false;
if (!IsTimelineRunning())
return false;
return earliest_fire_time.IsFinite();
}
void SMILTimeContainer::UpdateAnimationsAndScheduleFrameIfNeeded( void SMILTimeContainer::UpdateAnimationsAndScheduleFrameIfNeeded(
SMILTime elapsed) { SMILTime elapsed) {
DCHECK(GetDocument().IsActive()); DCHECK(GetDocument().IsActive());
...@@ -414,11 +404,13 @@ void SMILTimeContainer::UpdateAnimationsAndScheduleFrameIfNeeded( ...@@ -414,11 +404,13 @@ void SMILTimeContainer::UpdateAnimationsAndScheduleFrameIfNeeded(
UpdateAnimationTimings(elapsed); UpdateAnimationTimings(elapsed);
ApplyTimedEffects(elapsed); ApplyTimedEffects(elapsed);
SMILTime next_progress_time = NextProgressTime(elapsed);
DCHECK(!wakeup_timer_.IsActive()); DCHECK(!wakeup_timer_.IsActive());
DCHECK(!HasPendingSynchronization());
if (!CanScheduleFrame(next_progress_time)) if (!IsTimelineRunning())
return;
SMILTime next_progress_time = NextProgressTime(elapsed);
if (!next_progress_time.IsFinite())
return; return;
SMILTime delay_time = next_progress_time - elapsed; SMILTime delay_time = next_progress_time - elapsed;
DCHECK(delay_time.IsFinite()); DCHECK(delay_time.IsFinite());
......
...@@ -106,7 +106,6 @@ class SMILTimeContainer final : public GarbageCollected<SMILTimeContainer> { ...@@ -106,7 +106,6 @@ class SMILTimeContainer final : public GarbageCollected<SMILTimeContainer> {
void AnimationPolicyTimerFired(TimerBase*); void AnimationPolicyTimerFired(TimerBase*);
ImageAnimationPolicy AnimationPolicy() const; ImageAnimationPolicy AnimationPolicy() const;
bool HandleAnimationPolicy(AnimationPolicyOnceAction); bool HandleAnimationPolicy(AnimationPolicyOnceAction);
bool CanScheduleFrame(SMILTime earliest_fire_time) const;
void UpdateAnimationsAndScheduleFrameIfNeeded(SMILTime elapsed); void UpdateAnimationsAndScheduleFrameIfNeeded(SMILTime elapsed);
void ResetIntervals(); void ResetIntervals();
void UpdateIntervals(SMILTime presentation_time); void UpdateIntervals(SMILTime presentation_time);
......
...@@ -99,8 +99,7 @@ class SVGImage::SVGImageLocalFrameClient : public EmptyLocalFrameClient { ...@@ -99,8 +99,7 @@ class SVGImage::SVGImageLocalFrameClient : public EmptyLocalFrameClient {
SVGImage::SVGImage(ImageObserver* observer, bool is_multipart) SVGImage::SVGImage(ImageObserver* observer, bool is_multipart)
: Image(observer, is_multipart), : Image(observer, is_multipart),
paint_controller_(std::make_unique<PaintController>()), paint_controller_(std::make_unique<PaintController>()) {}
has_pending_timeline_rewind_(false) {}
SVGImage::~SVGImage() { SVGImage::~SVGImage() {
if (frame_client_) if (frame_client_)
...@@ -516,13 +515,6 @@ sk_sp<PaintRecord> SVGImage::PaintRecordForCurrentFrame(const KURL& url) { ...@@ -516,13 +515,6 @@ sk_sp<PaintRecord> SVGImage::PaintRecordForCurrentFrame(const KURL& url) {
// there may have been a previous url/fragment that needs to be reset. // there may have been a previous url/fragment that needs to be reset.
view->ProcessUrlFragment(url, /*same_document_navigation=*/false); view->ProcessUrlFragment(url, /*same_document_navigation=*/false);
// If the image was reset, we need to rewind the timeline back to 0. This
// needs to be done before painting, or else we wouldn't get the correct
// reset semantics (we'd paint the "last" frame rather than the one at
// time=0.) The reason we do this here and not in resetAnimation() is to
// avoid setting timers from the latter.
FlushPendingTimelineRewind();
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) { if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) {
view->UpdateAllLifecyclePhases( view->UpdateAllLifecyclePhases(
DocumentLifecycle::LifecycleUpdateReason::kOther); DocumentLifecycle::LifecycleUpdateReason::kOther);
...@@ -565,18 +557,6 @@ void SVGImage::DrawInternal(cc::PaintCanvas* canvas, ...@@ -565,18 +557,6 @@ void SVGImage::DrawInternal(cc::PaintCanvas* canvas,
StartAnimation(); StartAnimation();
} }
void SVGImage::ScheduleTimelineRewind() {
has_pending_timeline_rewind_ = true;
}
void SVGImage::FlushPendingTimelineRewind() {
if (!has_pending_timeline_rewind_)
return;
if (SVGSVGElement* root_element = SvgRootElement(page_.Get()))
root_element->setCurrentTime(0);
has_pending_timeline_rewind_ = false;
}
void SVGImage::StartAnimation() { void SVGImage::StartAnimation() {
SVGSVGElement* root_element = SvgRootElement(page_.Get()); SVGSVGElement* root_element = SvgRootElement(page_.Get());
if (!root_element) if (!root_element)
...@@ -600,7 +580,7 @@ void SVGImage::ResetAnimation() { ...@@ -600,7 +580,7 @@ void SVGImage::ResetAnimation() {
return; return;
chrome_client_->SuspendAnimation(); chrome_client_->SuspendAnimation();
root_element->pauseAnimations(); root_element->pauseAnimations();
ScheduleTimelineRewind(); root_element->setCurrentTime(0);
} }
void SVGImage::RestoreAnimation() { void SVGImage::RestoreAnimation() {
......
...@@ -210,8 +210,6 @@ class CORE_EXPORT SVGImage final : public Image { ...@@ -210,8 +210,6 @@ class CORE_EXPORT SVGImage final : public Image {
const KURL&); const KURL&);
void StopAnimation(); void StopAnimation();
void ScheduleTimelineRewind();
void FlushPendingTimelineRewind();
Page* GetPageForTesting() { return page_; } Page* GetPageForTesting() { return page_; }
void LoadCompleted(); void LoadCompleted();
...@@ -227,9 +225,8 @@ class CORE_EXPORT SVGImage final : public Image { ...@@ -227,9 +225,8 @@ class CORE_EXPORT SVGImage final : public Image {
// object size, which in turn depends on the container. One SVGImage may // object size, which in turn depends on the container. One SVGImage may
// belong to multiple containers so the final image size can't be known in // belong to multiple containers so the final image size can't be known in
// SVGImage. SVGImageForContainer carries the final image size, also called // SVGImage. SVGImageForContainer carries the final image size, also called
// the "concrete object size". For more, see: SVGImageForContainer.h // the "concrete object size". For more, see svg_image_for_container.h.
LayoutSize intrinsic_size_; LayoutSize intrinsic_size_;
bool has_pending_timeline_rewind_;
enum LoadState { enum LoadState {
kDataChangedNotStarted, kDataChangedNotStarted,
......
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