Backed out changesets a8ba3f906023 and 59e38d576489 (bug 933483) for causing bug 946726. a=backout
authorRyan VanderMeulen <ryanvm@gmail.com>
Mon, 09 Dec 2013 10:30:24 -0500
changeset 156833 e535d93d88ad82b271ccb1f4295a85247801daf5
parent 156832 93b7820a9edd605b88a60824c86905c57094db94
child 156834 542bf02505d99df98119a00e5807ce8ee81d87af
push id342
push userryanvm@gmail.com
push dateMon, 09 Dec 2013 15:30:32 +0000
reviewersbackout
bugs933483, 946726
milestone26.0
backs outa8ba3f906023fe43f11836940af428ff42a58ef0
59e38d5764894f3ba0fc38396f63ace29b887665
Backed out changesets a8ba3f906023 and 59e38d576489 (bug 933483) for causing bug 946726. a=backout
content/base/src/nsDocument.cpp
dom/base/nsFocusManager.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsPIDOMWindow.h
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -8406,27 +8406,21 @@ static void
 FireOrClearDelayedEvents(nsTArray<nsCOMPtr<nsIDocument> >& aDocuments,
                          bool aFireEvents)
 {
   nsIFocusManager* fm = nsFocusManager::GetFocusManager();
   if (!fm)
     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) {
-        // Only fire events for active documents.
-        bool fire = aFireEvents &&
-                    aDocuments[i]->GetInnerWindow() &&
-                    aDocuments[i]->GetInnerWindow()->IsCurrentInnerWindow();
-        shell->FireOrClearDelayedEvents(fire);
+        shell->FireOrClearDelayedEvents(aFireEvents);
       }
     }
   }
 }
 
 void
 nsDocument::MaybePreLoadImage(nsIURI* uri, const nsAString &aCrossOriginAttr)
 {
--- a/dom/base/nsFocusManager.cpp
+++ b/dom/base/nsFocusManager.cpp
@@ -984,33 +984,26 @@ nsFocusManager::WindowHidden(nsIDOMWindo
 }
 
 NS_IMETHODIMP
 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) {
-      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;
-      }
+  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;
     }
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsFocusManager::FocusPlugin(nsIContent* aContent)
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -7371,18 +7371,20 @@ nsGlobalWindow::EnterModalState()
       }
     }
   }
 
   if (topWin->mModalStateDepth == 0) {
     NS_ASSERTION(!mSuspendedDoc, "Shouldn't have mSuspendedDoc here!");
 
     mSuspendedDoc = topWin->GetExtantDoc();
-    if (mSuspendedDoc) {
+    if (mSuspendedDoc && mSuspendedDoc->EventHandlingSuppressed()) {
       mSuspendedDoc->SuppressEventHandling();
+    } else {
+      mSuspendedDoc = nullptr;
     }
   }
   topWin->mModalStateDepth++;
 }
 
 // static
 void
 nsGlobalWindow::RunPendingTimeoutsRecursive(nsGlobalWindow *aTopWindow,
--- a/dom/base/nsPIDOMWindow.h
+++ b/dom/base/nsPIDOMWindow.h
@@ -313,25 +313,16 @@ public:
     return GetCurrentInnerWindow();
   }
 
   bool IsInnerWindow() const
   {
     return mIsInnerWindow;
   }
 
-  // Returns true if this object has an outer window and it is the current inner
-  // window of that outer. Only call this on inner windows.
-  bool IsCurrentInnerWindow() const
-  {
-    MOZ_ASSERT(IsInnerWindow(),
-               "It doesn't make sense to call this on outer windows.");
-    return mOuterWindow && mOuterWindow->GetCurrentInnerWindow() == this;
-  }
-
   bool IsOuterWindow() const
   {
     return !IsInnerWindow();
   }
 
   virtual bool WouldReuseInnerWindow(nsIDocument *aNewDocument) = 0;
 
   /**