Commit 8aed5c9e authored by levin@chromium.org's avatar levin@chromium.org

2009-03-20 Mike Belshe <mike@belshe.com>

        Reviewed by Dimitri Glazkov and Dave Hyatt.

        https://bugs.webkit.org/show_bug.cgi?id=24324

        Make the minimum timer configurable for different platforms.

        * page/DOMTimer.cpp:
        (WebCore::DOMTimer::DOMTimer):
        (WebCore::DOMTimer::fired):
        * page/DOMTimer.h:
        (WebCore::DOMTimer::minTimerInterval):
        (WebCore::DOMTimer::setMinTimerInterval):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@41878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 52daba6b
2009-03-20 Mike Belshe <mike@belshe.com>
Reviewed by Dimitri Glazkov and Dave Hyatt.
https://bugs.webkit.org/show_bug.cgi?id=24324
Make the minimum timer configurable for different platforms.
* page/DOMTimer.cpp:
(WebCore::DOMTimer::DOMTimer):
(WebCore::DOMTimer::fired):
* page/DOMTimer.h:
(WebCore::DOMTimer::minTimerInterval):
(WebCore::DOMTimer::setMinTimerInterval):
2009-03-20 Dean McNamee <deanm@chromium.org>
Reviewed by Darin Adler.
......@@ -38,7 +38,7 @@ namespace WebCore {
static const int maxTimerNestingLevel = 5;
static const double oneMillisecond = 0.001;
static const double minTimerInterval = 0.010; // 10 milliseconds
double DOMTimer::s_minTimerInterval = 0.010; // 10 milliseconds
static int timerNestingLevel = 0;
......@@ -64,8 +64,8 @@ DOMTimer::DOMTimer(ScriptExecutionContext* context, ScheduledAction* action, int
// Use a minimum interval of 10 ms to match other browsers, but only once we've
// nested enough to notice that we're repeating.
// Faster timers might be "better", but they're incompatible.
if (intervalMilliseconds < minTimerInterval && m_nestingLevel >= maxTimerNestingLevel)
intervalMilliseconds = minTimerInterval;
if (intervalMilliseconds < s_minTimerInterval && m_nestingLevel >= maxTimerNestingLevel)
intervalMilliseconds = s_minTimerInterval;
if (singleShot)
startOneShot(intervalMilliseconds);
else
......@@ -105,10 +105,10 @@ void DOMTimer::fired()
// Simple case for non-one-shot timers.
if (isActive()) {
if (repeatInterval() && repeatInterval() < minTimerInterval) {
if (repeatInterval() && repeatInterval() < s_minTimerInterval) {
m_nestingLevel++;
if (m_nestingLevel >= maxTimerNestingLevel)
augmentRepeatInterval(minTimerInterval - repeatInterval());
augmentRepeatInterval(s_minTimerInterval - repeatInterval());
}
// No access to member variables after this point, it can delete the timer.
......
......@@ -51,6 +51,12 @@ public:
virtual void suspend();
virtual void resume();
// The lowest allowable timer setting (in seconds, 0.001 == 1 ms).
// Default is 10ms.
// Chromium uses a non-default timeout.
static double minTimerInterval() { return s_minTimerInterval; }
static void setMinTimerInterval(double value) { s_minTimerInterval = value; }
private:
DOMTimer(ScriptExecutionContext*, ScheduledAction*, int timeout, bool singleShot);
virtual void fired();
......@@ -60,6 +66,7 @@ private:
OwnPtr<ScheduledAction> m_action;
double m_nextFireInterval;
double m_repeatInterval;
static double s_minTimerInterval;
};
} // namespace WebCore
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment