Bug 1371787 P3 Move some Timeout initialization earlier. r=ehsan

This commit is contained in:
Ben Kelly
2017-06-15 17:30:47 -07:00
parent e92b8bfdb1
commit ff37f2bc4c

View File

@@ -369,11 +369,15 @@ TimeoutManager::SetTimeout(nsITimeoutHandler* aHandler,
}
RefPtr<Timeout> timeout = new Timeout();
timeout->mWindow = &mWindow;
timeout->mIsInterval = aIsInterval;
timeout->mInterval = interval;
timeout->mScriptHandler = aHandler;
timeout->mReason = aReason;
// No popups from timeouts by default
timeout->mPopupState = openAbused;
switch (gTimeoutBucketingStrategy) {
default:
case TRACKING_SEPARATE_TIMEOUT_BUCKETING_STRATEGY: {
@@ -411,8 +415,12 @@ TimeoutManager::SetTimeout(nsITimeoutHandler* aHandler,
break;
}
// Now clamp the actual interval we will use for the timer based on
uint32_t nestingLevel = sNestingLevel + 1;
if (!aIsInterval) {
timeout->mNestingLevel = nestingLevel;
}
// Now clamp the actual interval we will use for the timer based on
uint32_t realInterval = interval;
if (aIsInterval || nestingLevel >= DOM_CLAMP_TIMEOUT_NESTING_LEVEL ||
timeout->mIsTracking) {
@@ -422,8 +430,6 @@ TimeoutManager::SetTimeout(nsITimeoutHandler* aHandler,
uint32_t(DOMMinTimeoutValue(timeout->mIsTracking)));
}
timeout->mWindow = &mWindow;
TimeDuration delta = TimeDuration::FromMilliseconds(realInterval);
timeout->SetWhenOrTimeRemaining(TimeStamp::Now(), delta);
@@ -436,13 +442,6 @@ TimeoutManager::SetTimeout(nsITimeoutHandler* aHandler,
}
}
if (!aIsInterval) {
timeout->mNestingLevel = nestingLevel;
}
// No popups from timeouts by default
timeout->mPopupState = openAbused;
if (gRunningTimeoutDepth == 0 &&
mWindow.GetPopupControlState() < openAbused) {
// This timeout is *not* set from another timeout and it's set