Bug 1348623 - revert changes from bug 1044586 and fix preferences reload bug by changing the event listener, r=smaug a=gchang
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Mon, 20 Mar 2017 17:16:34 +0000
changeset 379205 bed11cd3bc3f90197709c7044b70658e4fe20ad8
parent 379204 b77b28b506bf75f4c6a3759ec63fa6351c4ff021
child 379206 33a1b844b718848bee35a015730dce344b85593f
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, gchang
bugs1348623, 1044586
milestone53.0
Bug 1348623 - revert changes from bug 1044586 and fix preferences reload bug by changing the event listener, r=smaug a=gchang In bug 1044586 we changed nsDocument::GetEventTargetParent such that events for a document were not sent to its parent window if the inner window for the document wasn't the current inner window. Unfortunately it seems this means event listeners on the window sometimes miss user input events (mousedown etc.) when user input takes place before the first paint of a new document that's loading. In order to fix this, this patch backs out the changes from bug 1044586. This reintroduces the issue we had before with the preference window, where reloading the preferences quickly meant that its listeners (attached to the window) got confused by DOMContentLoaded events from a previously loaded document. Instead of the broad fix to nsDocument::GetEventTargetParent, this patch simply changes the event listeners from the preferences code to be attached to the document instead of the window, thus ensuring they only get notified for events relating to their own document. MozReview-Commit-ID: 9DImyNst9fS
browser/components/preferences/in-content/preferences.js
dom/base/nsDocument.cpp
--- a/browser/components/preferences/in-content/preferences.js
+++ b/browser/components/preferences/in-content/preferences.js
@@ -44,20 +44,17 @@ function register_module(categoryName, c
     inited: false,
     init() {
       categoryObject.init();
       this.inited = true;
     }
   });
 }
 
-addEventListener("DOMContentLoaded", function onLoad() {
-  removeEventListener("DOMContentLoaded", onLoad);
-  init_all();
-});
+document.addEventListener("DOMContentLoaded", init_all, {once: true});
 
 function init_all() {
   document.documentElement.instantApply = true;
 
   gSubDialog.init();
   register_module("paneGeneral", gMainPane);
   register_module("paneSearch", gSearchPane);
   register_module("panePrivacy", gPrivacyPane);
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -7732,22 +7732,19 @@ nsDocument::GetEventTargetParent(EventCh
 {
   aVisitor.mCanHandle = true;
    // FIXME! This is a hack to make middle mouse paste working also in Editor.
    // Bug 329119
   aVisitor.mForceContentDispatch = true;
 
   // Load events must not propagate to |window| object, see bug 335251.
   if (aVisitor.mEvent->mMessage != eLoad) {
-    nsPIDOMWindowInner* innerWindow = GetInnerWindow();
-    if (innerWindow && innerWindow->IsCurrentInnerWindow()) {
-      nsGlobalWindow* window = nsGlobalWindow::Cast(GetWindow());
-      aVisitor.mParentTarget =
-        window ? window->GetTargetForEventTargetChain() : nullptr;
-    }
+    nsGlobalWindow* window = nsGlobalWindow::Cast(GetWindow());
+    aVisitor.mParentTarget =
+      window ? window->GetTargetForEventTargetChain() : nullptr;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocument::CreateEvent(const nsAString& aEventType, nsIDOMEvent** aReturn)
 {
   NS_ENSURE_ARG_POINTER(aReturn);