summaryrefslogtreecommitdiff
path: root/Source/WebCore/page/DOMTimer.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2012-10-17 16:21:14 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2012-10-17 16:21:14 +0200
commit8995b83bcbfbb68245f779b64e5517627c6cc6ea (patch)
tree17985605dab9263cc2444bd4d45f189e142cca7c /Source/WebCore/page/DOMTimer.cpp
parentb9c9652036d5e9f1e29c574f40bc73a35c81ace6 (diff)
downloadqtwebkit-8995b83bcbfbb68245f779b64e5517627c6cc6ea.tar.gz
Imported WebKit commit cf4f8fc6f19b0629f51860cb2d4b25e139d07e00 (http://svn.webkit.org/repository/webkit/trunk@131592)
New snapshot that includes the build fixes for Mac OS X 10.6 and earlier as well as the previously cherry-picked changes
Diffstat (limited to 'Source/WebCore/page/DOMTimer.cpp')
-rw-r--r--Source/WebCore/page/DOMTimer.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/Source/WebCore/page/DOMTimer.cpp b/Source/WebCore/page/DOMTimer.cpp
index dad76f58d..7d6831196 100644
--- a/Source/WebCore/page/DOMTimer.cpp
+++ b/Source/WebCore/page/DOMTimer.cpp
@@ -30,7 +30,7 @@
#include "InspectorInstrumentation.h"
#include "ScheduledAction.h"
#include "ScriptExecutionContext.h"
-#include "UserGestureIndicator.h"
+#include <wtf/CurrentTime.h>
#include <wtf/HashSet.h>
#include <wtf/StdLibExtras.h>
@@ -42,6 +42,7 @@ static const int maxIntervalForUserGestureForwarding = 1000; // One second match
static const int maxTimerNestingLevel = 5;
static const double oneMillisecond = 0.001;
double DOMTimer::s_minDefaultTimerInterval = 0.010; // 10 milliseconds
+double DOMTimer::s_defaultTimerAlignmentInterval = 0;
static int timerNestingLevel = 0;
@@ -68,8 +69,9 @@ DOMTimer::DOMTimer(ScriptExecutionContext* context, PassOwnPtr<ScheduledAction>
, m_nestingLevel(timerNestingLevel + 1)
, m_action(action)
, m_originalInterval(interval)
- , m_shouldForwardUserGesture(shouldForwardUserGesture(interval, m_nestingLevel))
{
+ if (shouldForwardUserGesture(interval, m_nestingLevel))
+ m_userGestureToken = UserGestureIndicator::currentToken();
scriptExecutionContext()->addTimeout(m_timeoutId, this);
double intervalMilliseconds = intervalClampedToMinimum(interval, context->minimumTimerInterval());
@@ -116,10 +118,8 @@ void DOMTimer::fired()
ScriptExecutionContext* context = scriptExecutionContext();
timerNestingLevel = m_nestingLevel;
ASSERT(!context->activeDOMObjectsAreSuspended());
- UserGestureIndicator gestureIndicator(m_shouldForwardUserGesture ? DefinitelyProcessingUserGesture : PossiblyProcessingUserGesture);
-
// Only the first execution of a multi-shot timer should get an affirmative user gesture indicator.
- m_shouldForwardUserGesture = false;
+ UserGestureIndicator gestureIndicator(m_userGestureToken.release());
InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireTimer(context, m_timeoutId);
@@ -194,4 +194,19 @@ double DOMTimer::intervalClampedToMinimum(int timeout, double minimumTimerInterv
return intervalMilliseconds;
}
+double DOMTimer::alignedFireTime(double fireTime) const
+{
+ double alignmentInterval = scriptExecutionContext()->timerAlignmentInterval();
+ if (alignmentInterval) {
+ double currentTime = monotonicallyIncreasingTime();
+ if (fireTime <= currentTime)
+ return fireTime;
+
+ double alignedTime = ceil(fireTime / alignmentInterval) * alignmentInterval;
+ return alignedTime;
+ }
+
+ return fireTime;
+}
+
} // namespace WebCore