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

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

Issue 2005693002: Delay SVGImage animations reset while being updated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #include "platform/graphics/paint/CullRect.h" 56 #include "platform/graphics/paint/CullRect.h"
57 #include "platform/graphics/paint/DrawingRecorder.h" 57 #include "platform/graphics/paint/DrawingRecorder.h"
58 #include "platform/graphics/paint/SkPictureBuilder.h" 58 #include "platform/graphics/paint/SkPictureBuilder.h"
59 #include "third_party/skia/include/core/SkPicture.h" 59 #include "third_party/skia/include/core/SkPicture.h"
60 #include "wtf/PassRefPtr.h" 60 #include "wtf/PassRefPtr.h"
61 61
62 namespace blink { 62 namespace blink {
63 63
64 SVGImage::SVGImage(ImageObserver* observer) 64 SVGImage::SVGImage(ImageObserver* observer)
65 : Image(observer) 65 : Image(observer)
66 , m_updatingAnimations(false)
67 , m_resetAnimationAfterUpdate(false)
66 { 68 {
67 } 69 }
68 70
69 SVGImage::~SVGImage() 71 SVGImage::~SVGImage()
70 { 72 {
71 if (m_page) { 73 if (m_page) {
72 // Store m_page in a local variable, clearing m_page, so that SVGImageCh romeClient knows we're destructed. 74 // Store m_page in a local variable, clearing m_page, so that SVGImageCh romeClient knows we're destructed.
73 Page* currentPage = m_page.release(); 75 Page* currentPage = m_page.release();
74 // Break both the loader and view references to the frame 76 // Break both the loader and view references to the frame
75 currentPage->willBeDestroyed(); 77 currentPage->willBeDestroyed();
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 void SVGImage::stopAnimation() 411 void SVGImage::stopAnimation()
410 { 412 {
411 SVGSVGElement* rootElement = svgRootElement(m_page.get()); 413 SVGSVGElement* rootElement = svgRootElement(m_page.get());
412 if (!rootElement) 414 if (!rootElement)
413 return; 415 return;
414 rootElement->pauseAnimations(); 416 rootElement->pauseAnimations();
415 } 417 }
416 418
417 void SVGImage::resetAnimation() 419 void SVGImage::resetAnimation()
418 { 420 {
421 if (m_updatingAnimations) {
422 m_resetAnimationAfterUpdate = true;
423 return;
424 }
425
419 SVGSVGElement* rootElement = svgRootElement(m_page.get()); 426 SVGSVGElement* rootElement = svgRootElement(m_page.get());
420 if (!rootElement) 427 if (!rootElement)
421 return; 428 return;
422 rootElement->pauseAnimations(); 429 rootElement->pauseAnimations();
423 rootElement->setCurrentTime(0); 430 rootElement->setCurrentTime(0);
424 } 431 }
425 432
426 bool SVGImage::hasAnimations() const 433 bool SVGImage::hasAnimations() const
427 { 434 {
428 SVGSVGElement* rootElement = svgRootElement(m_page.get()); 435 SVGSVGElement* rootElement = svgRootElement(m_page.get());
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 } 541 }
535 542
536 return m_page; 543 return m_page;
537 } 544 }
538 545
539 String SVGImage::filenameExtension() const 546 String SVGImage::filenameExtension() const
540 { 547 {
541 return "svg"; 548 return "svg";
542 } 549 }
543 550
551 void SVGImage::leaveNoResetAnimationScope()
552 {
553 if (!m_updatingAnimations) {
554 DCHECK(!m_resetAnimationAfterUpdate);
555 return;
556 }
557 m_updatingAnimations = false;
558 if (m_resetAnimationAfterUpdate) {
559 m_resetAnimationAfterUpdate = false;
560 resetAnimation();
561 }
562 }
563
564 SVGImage::UpdateAnimationScope::UpdateAnimationScope(SVGImage* image)
565 : m_image(image)
566 , m_imageObserver(m_image->getImageObserver())
567 {
568 m_image->enterNoResetAnimationsScope();
569 }
570
571 SVGImage::UpdateAnimationScope::~UpdateAnimationScope()
572 {
573 m_image->leaveNoResetAnimationScope();
574 }
575
544 } // namespace blink 576 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698