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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/svg/as-image/resources/animated-rect-color.svg ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org> 2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org>
3 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
4 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 4 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 275
276 view->paint(context, enclosingIntRect(srcRect)); 276 view->paint(context, enclosingIntRect(srcRect));
277 277
278 if (requiresTransparencyLayer) 278 if (requiresTransparencyLayer)
279 context->endLayer(); 279 context->endLayer();
280 280
281 stateSaver.restore(); 281 stateSaver.restore();
282 282
283 if (imageObserver()) 283 if (imageObserver())
284 imageObserver()->didDraw(this); 284 imageObserver()->didDraw(this);
285
286 // Start any (SMIL) animations if needed. This will restart or continue
287 // animations if preceded by calls to resetAnimation or stopAnimation
288 // respectively.
289 startAnimation();
285 } 290 }
286 291
287 RenderBox* SVGImage::embeddedContentBox() const 292 RenderBox* SVGImage::embeddedContentBox() const
288 { 293 {
289 if (!m_page) 294 if (!m_page)
290 return 0; 295 return 0;
291 LocalFrame* frame = m_page->mainFrame(); 296 LocalFrame* frame = m_page->mainFrame();
292 SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement() ; 297 SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement() ;
293 if (!rootElement) 298 if (!rootElement)
294 return 0; 299 return 0;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 intrinsicRatio = FloatSize(floatValueForLength(intrinsicWidth, 0), float ValueForLength(intrinsicHeight, 0)); 349 intrinsicRatio = FloatSize(floatValueForLength(intrinsicWidth, 0), float ValueForLength(intrinsicHeight, 0));
345 } 350 }
346 351
347 // FIXME: support catchUpIfNecessary. 352 // FIXME: support catchUpIfNecessary.
348 void SVGImage::startAnimation(bool /* catchUpIfNecessary */) 353 void SVGImage::startAnimation(bool /* catchUpIfNecessary */)
349 { 354 {
350 if (!m_page) 355 if (!m_page)
351 return; 356 return;
352 LocalFrame* frame = m_page->mainFrame(); 357 LocalFrame* frame = m_page->mainFrame();
353 SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement() ; 358 SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement() ;
354 if (!rootElement) 359 if (!rootElement || !rootElement->animationsPaused())
355 return; 360 return;
356 rootElement->unpauseAnimations(); 361 rootElement->unpauseAnimations();
357 rootElement->setCurrentTime(0);
358 } 362 }
359 363
360 void SVGImage::stopAnimation() 364 void SVGImage::stopAnimation()
361 { 365 {
362 if (!m_page) 366 if (!m_page)
363 return; 367 return;
364 LocalFrame* frame = m_page->mainFrame(); 368 LocalFrame* frame = m_page->mainFrame();
365 SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement() ; 369 SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement() ;
366 if (!rootElement) 370 if (!rootElement)
367 return; 371 return;
368 rootElement->pauseAnimations(); 372 rootElement->pauseAnimations();
369 } 373 }
370 374
371 void SVGImage::resetAnimation() 375 void SVGImage::resetAnimation()
372 { 376 {
373 stopAnimation(); 377 if (!m_page)
378 return;
379 LocalFrame* frame = m_page->mainFrame();
380 SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement() ;
381 if (!rootElement)
382 return;
383 rootElement->pauseAnimations();
384 rootElement->setCurrentTime(0);
374 } 385 }
375 386
376 bool SVGImage::hasAnimations() const 387 bool SVGImage::hasAnimations() const
377 { 388 {
378 if (!m_page) 389 if (!m_page)
379 return false; 390 return false;
380 LocalFrame* frame = m_page->mainFrame(); 391 LocalFrame* frame = m_page->mainFrame();
381 SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement() ; 392 SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement() ;
382 if (!rootElement) 393 if (!rootElement)
383 return false; 394 return false;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 441
431 return m_page; 442 return m_page;
432 } 443 }
433 444
434 String SVGImage::filenameExtension() const 445 String SVGImage::filenameExtension() const
435 { 446 {
436 return "svg"; 447 return "svg";
437 } 448 }
438 449
439 } 450 }
OLDNEW
« 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