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
--- 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);