Bug 1472491: Part 5f - Add ClickHandlerChild actor. r?felipe draft
authorKris Maglione <maglione.k@gmail.com>
Sun, 29 Jul 2018 20:11:22 -0700
changeset 828388 42e0d80a6523b8d623de02a4d96167d815ef4e46
parent 828387 80faf9b2d362403db4b692885bbf5cdcab1b377d
child 828389 1018b95496691ca6cd9d48ef6d09081589515792
push id118679
push usermaglione.k@gmail.com
push dateFri, 10 Aug 2018 21:19:41 +0000
reviewersfelipe
bugs1472491
milestone63.0a1
Bug 1472491: Part 5f - Add ClickHandlerChild actor. r?felipe MozReview-Commit-ID: 881jtz6qDCa
browser/base/content/content.js
browser/components/nsBrowserGlue.js
browser/modules/ClickEventHandler.jsm
browser/modules/ClickHandlerChild.jsm
browser/modules/moz.build
--- a/browser/base/content/content.js
+++ b/browser/base/content/content.js
@@ -25,22 +25,16 @@ XPCOMUtils.defineLazyModuleGetters(this,
   PluginContent: "resource:///modules/PluginContent.jsm",
   FormSubmitObserver: "resource:///modules/FormSubmitObserver.jsm",
   NetErrorContent: "resource:///modules/NetErrorContent.jsm",
   PageMetadata: "resource://gre/modules/PageMetadata.jsm",
   WebNavigationFrames: "resource://gre/modules/WebNavigationFrames.jsm",
   ContextMenuChild: "resource:///modules/ContextMenuChild.jsm",
 });
 
-XPCOMUtils.defineLazyProxy(this, "ClickEventHandler", () => {
-  let tmp = {};
-  ChromeUtils.import("resource:///modules/ClickEventHandler.jsm", tmp);
-  return new tmp.ClickEventHandler(global);
-});
-
 XPCOMUtils.defineLazyGetter(this, "LoginManagerContent", () => {
   let tmp = {};
   ChromeUtils.import("resource://gre/modules/LoginManagerContent.jsm", tmp);
   tmp.LoginManagerContent.setupEventListeners(global);
   return tmp.LoginManagerContent;
 });
 
 XPCOMUtils.defineLazyProxy(this, "formSubmitObserver", () => {
@@ -164,18 +158,16 @@ this.AboutNetAndCertErrorListener = {
       return;
     }
 
     NetErrorContent.handleEvent(global, aEvent);
   },
 };
 AboutNetAndCertErrorListener.init(this);
 
-Services.els.addSystemEventListener(global, "click", ClickEventHandler, true);
-
 new ContentLinkHandler(this);
 ContentMetaHandler.init(this);
 
 var PluginContentStub = {
   EVENTS: [
     "PluginCrashed",
     "PluginOutdated",
     "PluginInstantiated",
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -48,16 +48,26 @@ let ACTORS = {
         "Browser:Reload",
         "MixedContent:ReenableProtection",
         "SwitchDocumentDirection",
         "UpdateCharacterSet",
       ],
     },
   },
 
+  ClickHandler: {
+    module: "resource:///modules/ClickHandler",
+    child: {
+      group: "browsers",
+      events: {
+        "click": {capture: true, mozSystemGroup: true},
+      }
+    },
+  },
+
   ContextMenu: {
     module: "resource:///modules/ContextMenu",
     child: {
       events: {
         "contextmenu": {mozSystemGroup: true},
       },
     },
   },
rename from browser/modules/ClickEventHandler.jsm
rename to browser/modules/ClickHandlerChild.jsm
--- a/browser/modules/ClickEventHandler.jsm
+++ b/browser/modules/ClickHandlerChild.jsm
@@ -1,33 +1,30 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-var EXPORTED_SYMBOLS = ["ClickEventHandler"];
+var EXPORTED_SYMBOLS = ["ClickHandlerChild"];
 
+ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 ChromeUtils.defineModuleGetter(this, "BlockedSiteContent",
                                "resource:///modules/BlockedSiteContent.jsm");
 ChromeUtils.defineModuleGetter(this, "BrowserUtils",
                                "resource://gre/modules/BrowserUtils.jsm");
 ChromeUtils.defineModuleGetter(this, "NetErrorContent",
                                "resource:///modules/NetErrorContent.jsm");
 ChromeUtils.defineModuleGetter(this, "PrivateBrowsingUtils",
                                "resource://gre/modules/PrivateBrowsingUtils.jsm");
 ChromeUtils.defineModuleGetter(this, "WebNavigationFrames",
                                "resource://gre/modules/WebNavigationFrames.jsm");
 
-class ClickEventHandler {
-  constructor(mm) {
-    this.mm = mm;
-  }
-
+class ClickHandlerChild extends ActorChild {
   handleEvent(event) {
     if (!event.isTrusted || event.defaultPrevented || event.button == 2) {
       return;
     }
 
     let originalTarget = event.originalTarget;
     let ownerDoc = originalTarget.ownerDocument;
     if (!ownerDoc) {
--- a/browser/modules/moz.build
+++ b/browser/modules/moz.build
@@ -135,17 +135,17 @@ EXTRA_JS_MODULES += [
     'AboutNewTab.jsm',
     'AboutReaderChild.jsm',
     'AsyncTabSwitcher.jsm',
     'BlockedSiteContent.jsm',
     'BrowserErrorReporter.jsm',
     'BrowserTabChild.jsm',
     'BrowserUsageTelemetry.jsm',
     'BrowserWindowTracker.jsm',
-    'ClickEventHandler.jsm',
+    'ClickHandlerChild.jsm',
     'ContentClick.jsm',
     'ContentCrashHandlers.jsm',
     'ContentLinkHandler.jsm',
     'ContentMetaHandler.jsm',
     'ContentObservers.js',
     'ContentSearch.jsm',
     'ContentSearchChild.jsm',
     'ContentWebRTC.jsm',