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

Side by Side Diff: Source/core/svg/graphics/SVGImageChromeClient.cpp

Issue 188903003: Revert "Drive SVG Animations via requestAnimationFrame" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 | « Source/core/svg/graphics/SVGImage.cpp ('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) 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 14 matching lines...) Expand all
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "config.h" 29 #include "config.h"
30 #include "core/svg/graphics/SVGImageChromeClient.h" 30 #include "core/svg/graphics/SVGImageChromeClient.h"
31 31
32 #include "core/frame/FrameView.h" 32 #include "core/frame/FrameView.h"
33 #include "core/svg/graphics/SVGImage.h" 33 #include "core/svg/graphics/SVGImage.h"
34 #include "platform/graphics/ImageObserver.h" 34 #include "platform/graphics/ImageObserver.h"
35 #include "wtf/CurrentTime.h"
36 35
37 namespace WebCore { 36 namespace WebCore {
38 37
39 static const double animationFrameDelay = 0.025;
40
41 SVGImageChromeClient::SVGImageChromeClient(SVGImage* image) 38 SVGImageChromeClient::SVGImageChromeClient(SVGImage* image)
42 : m_image(image) 39 : m_image(image)
43 , m_animationTimer(this, &SVGImageChromeClient::animationTimerFired) 40 , m_animationTimer(this, &SVGImageChromeClient::animationTimerFired)
44 { 41 {
45 } 42 }
46 43
47 bool SVGImageChromeClient::isSVGImageChromeClient() const 44 bool SVGImageChromeClient::isSVGImageChromeClient() const
48 { 45 {
49 return true; 46 return true;
50 } 47 }
(...skipping 12 matching lines...) Expand all
63 60
64 void SVGImageChromeClient::scheduleAnimation() 61 void SVGImageChromeClient::scheduleAnimation()
65 { 62 {
66 // Because a single SVGImage can be shared by multiple pages, we can't key 63 // Because a single SVGImage can be shared by multiple pages, we can't key
67 // our svg image layout on the page's real animation frame. Therefore, we 64 // our svg image layout on the page's real animation frame. Therefore, we
68 // run this fake animation timer to trigger layout in SVGImages. The name, 65 // run this fake animation timer to trigger layout in SVGImages. The name,
69 // "animationTimer", is to match the new requestAnimationFrame-based layout 66 // "animationTimer", is to match the new requestAnimationFrame-based layout
70 // approach. 67 // approach.
71 if (m_animationTimer.isActive()) 68 if (m_animationTimer.isActive())
72 return; 69 return;
73 // Schedule the 'animation' ASAP if the image does not contain any 70 m_animationTimer.startOneShot(0);
74 // animations, but prefer a fixed, jittery, frame-delay if there're any
75 // animations. Checking for pending/active animations could be more
76 // stringent.
77 double fireTime = m_image->hasAnimations() ? animationFrameDelay : 0;
78 m_animationTimer.startOneShot(fireTime);
79 } 71 }
80 72
81 void SVGImageChromeClient::animationTimerFired(Timer<SVGImageChromeClient>*) 73 void SVGImageChromeClient::animationTimerFired(Timer<SVGImageChromeClient>*)
82 { 74 {
83 // In principle, we should call requestAnimationFrame callbacks here, but 75 // In principle, we should call requestAnimationFrame callbacks here, but
84 // we know there aren't any because script is forbidden inside SVGImages. 76 // we know there aren't any because script is forbidden inside SVGImages.
85 if (m_image) { 77 if (m_image) {
86 m_image->frameView()->page()->animator().serviceScriptedAnimations(curre ntTime()); 78 m_image->frameView()->page()->animator().serviceScriptedAnimations(0);
87 m_image->frameView()->updateLayoutAndStyleIfNeededRecursive(); 79 m_image->frameView()->updateLayoutAndStyleIfNeededRecursive();
88 } 80 }
89 } 81 }
90 82
91 } 83 }
OLDNEW
« no previous file with comments | « Source/core/svg/graphics/SVGImage.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698