Bug 1371664 P2 Make nsGlobalWindow::SetIsBackground() call new TimeoutManager::UpdateBackgroundState(). r=ehsan

This commit is contained in:
Ben Kelly 2017-06-13 18:08:27 -07:00
Родитель 3ea8a7a387
Коммит d959a50dfa
3 изменённых файлов: 17 добавлений и 5 удалений

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

@ -1152,6 +1152,14 @@ TimeoutManager::Thaw()
});
}
void
TimeoutManager::UpdateBackgroundState()
{
if (!IsBackground()) {
ResetTimersForThrottleReduction();
}
}
bool
TimeoutManager::IsTimeoutTracking(uint32_t aTimeoutId)
{

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

@ -77,6 +77,10 @@ public:
void Freeze();
void Thaw();
// This should be called by nsGlobalWindow when the window might have moved
// to the background or foreground.
void UpdateBackgroundState();
// Initialize TimeoutManager before the first time it is accessed.
static void Initialize();

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

@ -10671,13 +10671,16 @@ void nsGlobalWindow::SetIsBackground(bool aIsBackground)
{
MOZ_ASSERT(IsOuterWindow());
bool resetTimers = (!aIsBackground && AsOuter()->IsBackground());
bool changed = aIsBackground != AsOuter()->IsBackground();
SetIsBackgroundInternal(aIsBackground);
nsGlobalWindow* inner = GetCurrentInnerWindowInternal();
if (inner && changed) {
inner->mTimeoutManager->UpdateBackgroundState();
}
if (aIsBackground) {
MOZ_ASSERT(!resetTimers);
// Notify gamepadManager we are at the background window,
// we need to stop vibrate.
if (inner) {
@ -10685,9 +10688,6 @@ void nsGlobalWindow::SetIsBackground(bool aIsBackground)
}
return;
} else if (inner) {
if (resetTimers) {
inner->mTimeoutManager->ResetTimersForThrottleReduction();
}
inner->SyncGamepadState();
}
}