Skip to content

Commit

Permalink
Fix for timer issue in firefox.
Browse files Browse the repository at this point in the history
Reviewed by me.
  • Loading branch information
Francisco Ryan Tolmasky I committed Dec 10, 2008
1 parent 87f644e commit 2d9d9f3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Foundation/CPRunLoop.j
Expand Up @@ -151,6 +151,7 @@ var CPRunLoopLastNativeRunLoop = 0;
Object _nativeTimersForModes;
CPDate _nextTimerFireDatesForModes;
BOOL _didAddTimer;
CPDate _effectiveDate;

CPArray _orderedPerforms;
}
Expand Down Expand Up @@ -276,7 +277,7 @@ var CPRunLoopLastNativeRunLoop = 0;

_runLoopLock = YES;

var now = [CPDate date],
var now = _effectiveDate ? [_effectiveDate laterDate:[CPDate date]] : [CPDate date],
nextFireDate = nil,
nextTimerFireDate = _nextTimerFireDatesForModes[aMode];

Expand Down Expand Up @@ -348,7 +349,7 @@ var CPRunLoopLastNativeRunLoop = 0;

//initiate a new window.setTimeout if there are any timers
if (_nextTimerFireDatesForModes[aMode] !== nil)
_nativeTimersForModes[aMode] = window.setNativeTimeout(function() { _nativeTimersForModes[aMode] = nil; ++CPRunLoopLastNativeRunLoop; [self limitDateForMode:aMode]; _isNativeTimerRun = NO; }, MAX(0, [nextFireDate timeIntervalSinceNow] * 1000));
_nativeTimersForModes[aMode] = window.setNativeTimeout(function() { _effectiveDate = nextFireDate; _nativeTimersForModes[aMode] = nil; ++CPRunLoopLastNativeRunLoop; [self limitDateForMode:aMode]; _effectiveDate = nil; }, [nextFireDate timeIntervalSinceNow] * 1000);
}

// Run loop performers
Expand Down

0 comments on commit 2d9d9f3

Please sign in to comment.