Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Unified Diff: third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp

Issue 2247783003: Avoid setting timers from SVGImage::resetAnimation() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/svg/graphics/SVGImage.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp
diff --git a/third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp b/third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp
index 4a867cbebc7687147bff688d227cd4fec048de00..16ee86adf6b44d0c42fd0298fec5f074e340cd22 100644
--- a/third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp
+++ b/third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp
@@ -64,6 +64,7 @@ namespace blink {
SVGImage::SVGImage(ImageObserver* observer)
: Image(observer)
+ , m_hasPendingTimelineRewind(false)
{
}
@@ -352,6 +353,13 @@ void SVGImage::drawInternal(SkCanvas* canvas, const SkPaint& paint, const FloatR
// there may have been a previous url/fragment that needs to be reset.
view->processUrlFragment(url);
+ // 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();
+
SkPictureBuilder imagePicture(dstRect);
{
ClipRecorder clipRecorder(imagePicture.context(), imagePicture, DisplayItem::ClipNodeImage, enclosingIntRect(dstRect));
@@ -397,6 +405,20 @@ LayoutReplaced* SVGImage::embeddedReplacedContent() const
return toLayoutSVGRoot(rootElement->layoutObject());
}
+void SVGImage::scheduleTimelineRewind()
+{
+ m_hasPendingTimelineRewind = true;
+}
+
+void SVGImage::flushPendingTimelineRewind()
+{
+ if (!m_hasPendingTimelineRewind)
+ return;
+ if (SVGSVGElement* rootElement = svgRootElement(m_page.get()))
+ rootElement->setCurrentTime(0);
+ m_hasPendingTimelineRewind = false;
+}
+
// FIXME: support CatchUpAnimation = CatchUp.
void SVGImage::startAnimation(CatchUpAnimation)
{
@@ -424,7 +446,7 @@ void SVGImage::resetAnimation()
return;
m_chromeClient->suspendAnimation();
rootElement->pauseAnimations();
- rootElement->setCurrentTime(0);
+ scheduleTimelineRewind();
}
bool SVGImage::hasAnimations() const
« no previous file with comments | « third_party/WebKit/Source/core/svg/graphics/SVGImage.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698