Bug 528208. Measure interval delays from start of callback to start of callback, not from end of callback to start of callback. r=peterv

This commit is contained in:
Boris Zbarsky 2009-11-12 16:50:38 -05:00
Родитель 1e41151583
Коммит 2fe601a83b
1 изменённых файлов: 18 добавлений и 12 удалений

Просмотреть файл

@ -8099,14 +8099,21 @@ nsGlobalWindow::RunTimeout(nsTimeout *aTimeout)
// If we have a regular interval timer, we re-schedule the
// timeout, accounting for clock drift.
if (timeout->mInterval) {
// Compute time to next timeout for interval timer. If we're
// running pending timeouts because they've been temporarily
// disabled (!aTimeout), set the next interval to be relative to
// "now", and not to when the timeout that was pending should
// have fired.
// Also check if the next interval timeout is overdue. If so,
// then restart the interval from now.
// Compute time to next timeout for interval timer.
PRTime nextInterval = (PRTime)timeout->mInterval * PR_USEC_PER_MSEC;
// Make sure nextInterval is at least DOM_MIN_TIMEOUT_VALUE.
// Note: We must cast the rhs expression to PRTime to work
// around what looks like a compiler bug on x86_64.
if (nextInterval < (PRTime)(DOM_MIN_TIMEOUT_VALUE * PR_USEC_PER_MSEC)) {
nextInterval = DOM_MIN_TIMEOUT_VALUE * PR_USEC_PER_MSEC;
}
// If we're running pending timeouts because they've been temporarily
// disabled (!aTimeout), set the next interval to be relative to "now",
// and not to when the timeout that was pending should have fired. Also
// check if the next interval timeout is overdue. If so, then restart
// the interval from now.
if (!aTimeout || nextInterval + timeout->mWhen <= now)
nextInterval += now;
else
@ -8114,11 +8121,10 @@ nsGlobalWindow::RunTimeout(nsTimeout *aTimeout)
PRTime delay = nextInterval - PR_Now();
// Make sure the delay is at least DOM_MIN_TIMEOUT_VALUE.
// Note: We must cast the rhs expression to PRTime to work
// around what looks like a compiler bug on x86_64.
if (delay < (PRTime)(DOM_MIN_TIMEOUT_VALUE * PR_USEC_PER_MSEC)) {
delay = DOM_MIN_TIMEOUT_VALUE * PR_USEC_PER_MSEC;
// And make sure delay is nonnegative; that might happen if the timer
// thread is firing our timers somewhat early.
if (delay < 0) {
delay = 0;
}
if (timeout->mTimer) {