Bug 933483 - Don't fire events (and especially request animation frame events) when we're in a modal dialog. r=smaug

This commit is contained in:
Blake Kaplan 2013-12-16 08:37:34 -05:00
parent a8015cda79
commit 970a3de618
3 changed files with 29 additions and 14 deletions

View File

@ -8565,11 +8565,17 @@ FireOrClearDelayedEvents(nsTArray<nsCOMPtr<nsIDocument> >& aDocuments,
return;
for (uint32_t i = 0; i < aDocuments.Length(); ++i) {
// NB: Don't bother trying to fire delayed events on documents that were
// closed before this event ran.
if (!aDocuments[i]->EventHandlingSuppressed()) {
fm->FireDelayedEvents(aDocuments[i]);
nsCOMPtr<nsIPresShell> shell = aDocuments[i]->GetShell();
if (shell) {
shell->FireOrClearDelayedEvents(aFireEvents);
// Only fire events for active documents.
bool fire = aFireEvents &&
aDocuments[i]->GetInnerWindow() &&
aDocuments[i]->GetInnerWindow()->IsCurrentInnerWindow();
shell->FireOrClearDelayedEvents(fire);
}
}
}

View File

@ -992,16 +992,23 @@ nsFocusManager::FireDelayedEvents(nsIDocument* aDocument)
NS_ENSURE_ARG(aDocument);
// fire any delayed focus and blur events in the same order that they were added
for (uint32_t i = 0; i < mDelayedBlurFocusEvents.Length(); i++)
{
if (mDelayedBlurFocusEvents[i].mDocument == aDocument &&
!aDocument->EventHandlingSuppressed()) {
uint32_t type = mDelayedBlurFocusEvents[i].mType;
nsCOMPtr<EventTarget> target = mDelayedBlurFocusEvents[i].mTarget;
nsCOMPtr<nsIPresShell> presShell = mDelayedBlurFocusEvents[i].mPresShell;
mDelayedBlurFocusEvents.RemoveElementAt(i);
SendFocusOrBlurEvent(type, presShell, aDocument, target, 0, false);
--i;
for (uint32_t i = 0; i < mDelayedBlurFocusEvents.Length(); i++) {
if (mDelayedBlurFocusEvents[i].mDocument == aDocument) {
if (!aDocument->GetInnerWindow() ||
!aDocument->GetInnerWindow()->IsCurrentInnerWindow()) {
// If the document was navigated away from or is defunct, don't bother
// firing events on it. Note the symmetry between this condition and
// the similar one in nsDocument.cpp:FireOrClearDelayedEvents.
mDelayedBlurFocusEvents.RemoveElementAt(i);
--i;
} else if (!aDocument->EventHandlingSuppressed()) {
uint32_t type = mDelayedBlurFocusEvents[i].mType;
nsCOMPtr<EventTarget> target = mDelayedBlurFocusEvents[i].mTarget;
nsCOMPtr<nsIPresShell> presShell = mDelayedBlurFocusEvents[i].mPresShell;
mDelayedBlurFocusEvents.RemoveElementAt(i);
SendFocusOrBlurEvent(type, presShell, aDocument, target, 0, false);
--i;
}
}
}

View File

@ -1534,6 +1534,10 @@ nsGlobalWindow::FreeInnerObjects()
mDocumentPrincipal = mDoc->NodePrincipal();
mDocumentURI = mDoc->GetDocumentURI();
mDocBaseURI = mDoc->GetDocBaseURI();
if (mDoc->EventHandlingSuppressed()) {
mDoc->UnsuppressEventHandlingAndFireEvents(false);
}
}
// Remove our reference to the document and the document principal.
@ -8182,10 +8186,8 @@ nsGlobalWindow::EnterModalState()
NS_ASSERTION(!mSuspendedDoc, "Shouldn't have mSuspendedDoc here!");
mSuspendedDoc = topWin->GetExtantDoc();
if (mSuspendedDoc && mSuspendedDoc->EventHandlingSuppressed()) {
if (mSuspendedDoc) {
mSuspendedDoc->SuppressEventHandling();
} else {
mSuspendedDoc = nullptr;
}
}
topWin->mModalStateDepth++;