diff options
| author | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2013-09-13 12:51:20 +0200 |
|---|---|---|
| committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-19 20:50:05 +0200 |
| commit | d441d6f39bb846989d95bcf5caf387b42414718d (patch) | |
| tree | e367e64a75991c554930278175d403c072de6bb8 /Source/WebCore/dom/ScriptedAnimationController.cpp | |
| parent | 0060b2994c07842f4c59de64b5e3e430525c4b90 (diff) | |
| download | qtwebkit-d441d6f39bb846989d95bcf5caf387b42414718d.tar.gz | |
Import Qt5x2 branch of QtWebkit for Qt 5.2
Importing a new snapshot of webkit.
Change-Id: I2d01ad12cdc8af8cb015387641120a9d7ea5f10c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Source/WebCore/dom/ScriptedAnimationController.cpp')
| -rw-r--r-- | Source/WebCore/dom/ScriptedAnimationController.cpp | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/Source/WebCore/dom/ScriptedAnimationController.cpp b/Source/WebCore/dom/ScriptedAnimationController.cpp index afa131b1a..7ed17701a 100644 --- a/Source/WebCore/dom/ScriptedAnimationController.cpp +++ b/Source/WebCore/dom/ScriptedAnimationController.cpp @@ -43,6 +43,7 @@ using namespace std; // Allow a little more than 60fps to make sure we can at least hit that frame rate. #define MinimumAnimationInterval 0.015 +#define MinimumThrottledAnimationInterval 10 #endif namespace WebCore { @@ -55,7 +56,8 @@ ScriptedAnimationController::ScriptedAnimationController(Document* document, Pla , m_animationTimer(this, &ScriptedAnimationController::animationTimerFired) , m_lastAnimationFrameTimeMonotonic(0) #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) - , m_useTimer(false) + , m_isUsingTimer(false) + , m_isThrottled(false) #endif #endif { @@ -82,6 +84,20 @@ void ScriptedAnimationController::resume() scheduleAnimation(); } +void ScriptedAnimationController::setThrottled(bool isThrottled) +{ +#if USE(REQUEST_ANIMATION_FRAME_TIMER) && USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) + if (m_isThrottled == isThrottled) + return; + + m_isThrottled = isThrottled; + if (m_animationTimer.isActive()) { + m_animationTimer.stop(); + scheduleAnimation(); + } +#endif +} + ScriptedAnimationController::CallbackId ScriptedAnimationController::registerCallback(PassRefPtr<RequestAnimationFrameCallback> callback) { ScriptedAnimationController::CallbackId id = ++m_nextCallbackId; @@ -167,17 +183,23 @@ void ScriptedAnimationController::scheduleAnimation() #if USE(REQUEST_ANIMATION_FRAME_TIMER) #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) - if (!m_useTimer) { + if (!m_isUsingTimer && !m_isThrottled) { if (DisplayRefreshMonitorManager::sharedManager()->scheduleAnimation(this)) return; - m_useTimer = true; + m_isUsingTimer = true; } #endif if (m_animationTimer.isActive()) return; - double scheduleDelay = max<double>(MinimumAnimationInterval - (monotonicallyIncreasingTime() - m_lastAnimationFrameTimeMonotonic), 0); + double animationInterval = MinimumAnimationInterval; +#if USE(REQUEST_ANIMATION_FRAME_TIMER) && USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) + if (m_isThrottled) + animationInterval = MinimumThrottledAnimationInterval; +#endif + + double scheduleDelay = max<double>(animationInterval - (monotonicallyIncreasingTime() - m_lastAnimationFrameTimeMonotonic), 0); m_animationTimer.startOneShot(scheduleDelay); #else if (FrameView* frameView = m_document->view()) |
