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

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

Issue 190963003: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/svg/graphics/SVGImage.cpp ('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/SVGImageChromeClient.cpp
diff --git a/Source/core/svg/graphics/SVGImageChromeClient.cpp b/Source/core/svg/graphics/SVGImageChromeClient.cpp
index 5c197ba7fcf80d6b68facd3ac5cd9a9aaf87c28e..ecbe952bb0b06272c6d75f7083711d1a385f9fab 100644
--- a/Source/core/svg/graphics/SVGImageChromeClient.cpp
+++ b/Source/core/svg/graphics/SVGImageChromeClient.cpp
@@ -32,9 +32,12 @@
#include "core/frame/FrameView.h"
#include "core/svg/graphics/SVGImage.h"
#include "platform/graphics/ImageObserver.h"
+#include "wtf/CurrentTime.h"
namespace WebCore {
+static const double animationFrameDelay = 0.025;
+
SVGImageChromeClient::SVGImageChromeClient(SVGImage* image)
: m_image(image)
, m_animationTimer(this, &SVGImageChromeClient::animationTimerFired)
@@ -67,7 +70,12 @@ void SVGImageChromeClient::scheduleAnimation()
// approach.
if (m_animationTimer.isActive())
return;
- m_animationTimer.startOneShot(0);
+ // Schedule the 'animation' ASAP if the image does not contain any
+ // animations, but prefer a fixed, jittery, frame-delay if there're any
+ // animations. Checking for pending/active animations could be more
+ // stringent.
+ double fireTime = m_image->hasAnimations() ? animationFrameDelay : 0;
+ m_animationTimer.startOneShot(fireTime);
}
void SVGImageChromeClient::animationTimerFired(Timer<SVGImageChromeClient>*)
@@ -75,7 +83,7 @@ void SVGImageChromeClient::animationTimerFired(Timer<SVGImageChromeClient>*)
// In principle, we should call requestAnimationFrame callbacks here, but
// we know there aren't any because script is forbidden inside SVGImages.
if (m_image) {
- m_image->frameView()->page()->animator().serviceScriptedAnimations(0);
+ m_image->frameView()->page()->animator().serviceScriptedAnimations(currentTime());
m_image->frameView()->updateLayoutAndStyleIfNeededRecursive();
}
}
« 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