Bug 1348623 - revert changes from bug 1044586 and fix preferences reload bug by changing the event listener, r?smaug draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Mon, 20 Mar 2017 17:16:34 +0000
changeset 501640 78dc5d1b86f5da4479fe31662959653fd3a92475
parent 501522 8d967436d696d1f8e3fb33cf7e3d32a72457ffa6
child 549954 65c51ecba7eb4cf101ba87fb9bda8ed273a5513d
push id50065
push usergijskruitbosch@gmail.com
push dateMon, 20 Mar 2017 18:53:23 +0000
reviewerssmaug
bugs1348623, 1044586
milestone55.0a1
Bug 1348623 - revert changes from bug 1044586 and fix preferences reload bug by changing the event listener, r?smaug 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
@@ -45,20 +45,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
@@ -7926,22 +7926,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);