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

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

Issue 206033005: Rewind the timeline for SVG-in-<img> when resetAnimation() is called (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Reduce timeouts some more. Created 6 years, 9 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 | « LayoutTests/svg/as-image/resources/animated-rect-color.svg ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/graphics/SVGImage.cpp
diff --git a/Source/core/svg/graphics/SVGImage.cpp b/Source/core/svg/graphics/SVGImage.cpp
index 50112683e71a9d0dd6f2553cb5ca3a8d7de991af..136d923c531bc7daccf949761a0e53e128bc5c59 100644
--- a/Source/core/svg/graphics/SVGImage.cpp
+++ b/Source/core/svg/graphics/SVGImage.cpp
@@ -282,6 +282,11 @@ void SVGImage::draw(GraphicsContext* context, const FloatRect& dstRect, const Fl
if (imageObserver())
imageObserver()->didDraw(this);
+
+ // Start any (SMIL) animations if needed. This will restart or continue
+ // animations if preceded by calls to resetAnimation or stopAnimation
+ // respectively.
+ startAnimation();
}
RenderBox* SVGImage::embeddedContentBox() const
@@ -351,10 +356,9 @@ void SVGImage::startAnimation(bool /* catchUpIfNecessary */)
return;
LocalFrame* frame = m_page->mainFrame();
SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement();
- if (!rootElement)
+ if (!rootElement || !rootElement->animationsPaused())
return;
rootElement->unpauseAnimations();
- rootElement->setCurrentTime(0);
}
void SVGImage::stopAnimation()
@@ -370,7 +374,14 @@ void SVGImage::stopAnimation()
void SVGImage::resetAnimation()
{
- stopAnimation();
+ if (!m_page)
+ return;
+ LocalFrame* frame = m_page->mainFrame();
+ SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement();
+ if (!rootElement)
+ return;
+ rootElement->pauseAnimations();
+ rootElement->setCurrentTime(0);
}
bool SVGImage::hasAnimations() const
« no previous file with comments | « LayoutTests/svg/as-image/resources/animated-rect-color.svg ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698