Bug 1274146 part 1 - Use Services.els instead of loading event listener service manually. r?gijs draft
authorXidorn Quan <me@upsuper.org>
Fri, 20 May 2016 10:57:12 +1000
changeset 369048 2a62afde538e826d58b7d0118fba18aa376dabf2
parent 369047 5a751abd6841ea0107e2cb39fefbc1a673669044
child 369049 cba00d196afa272e8a05b0c3d9442d97d63b1b72
push id18714
push userxquan@mozilla.com
push dateFri, 20 May 2016 04:53:04 +0000
reviewersgijs
bugs1274146
milestone49.0a1
Bug 1274146 part 1 - Use Services.els instead of loading event listener service manually. r?gijs MozReview-Commit-ID: 7eqVOM9Zn5p
browser/base/content/content.js
--- a/browser/base/content/content.js
+++ b/browser/base/content/content.js
@@ -76,17 +76,17 @@ addEventListener("pageshow", function(ev
 });
 addEventListener("DOMAutoComplete", function(event) {
   LoginManagerContent.onUsernameInput(event);
 });
 addEventListener("blur", function(event) {
   LoginManagerContent.onUsernameInput(event);
 });
 
-var handleContentContextMenu = function (event) {
+Services.els.addSystemEventListener(global, "contextmenu", function(event) {
   let defaultPrevented = event.defaultPrevented;
   if (!Services.prefs.getBoolPref("dom.event.contextmenu.enabled")) {
     let plugin = null;
     try {
       plugin = event.target.QueryInterface(Ci.nsIObjectLoadingContent);
     } catch (e) {}
     if (plugin && plugin.displayedType == Ci.nsIObjectLoadingContent.TYPE_PLUGIN) {
       // Don't open a context menu for plugins.
@@ -204,21 +204,17 @@ var handleContentContextMenu = function 
       contentType: contentType,
       contentDisposition: contentDisposition,
       selectionInfo: selectionInfo,
       disableSetDesktopBackground: disableSetDesktopBg,
       loginFillInfo,
       parentAllowsMixedContent,
     };
   }
-}
-
-Cc["@mozilla.org/eventlistenerservice;1"]
-  .getService(Ci.nsIEventListenerService)
-  .addSystemEventListener(global, "contextmenu", handleContentContextMenu, false);
+}, false);
 
 // Values for telemtery bins: see TLS_ERROR_REPORT_UI in Histograms.json
 const TLS_ERROR_REPORT_TELEMETRY_UI_SHOWN = 0;
 const TLS_ERROR_REPORT_TELEMETRY_EXPANDED = 1;
 const TLS_ERROR_REPORT_TELEMETRY_SUCCESS  = 6;
 const TLS_ERROR_REPORT_TELEMETRY_FAILURE  = 7;
 
 const SEC_ERROR_BASE          = Ci.nsINSSErrorsService.NSS_SEC_ERROR_BASE;
@@ -403,19 +399,17 @@ var AboutNetAndCertErrorListener = {
   }
 }
 
 AboutNetAndCertErrorListener.init(this);
 
 
 var ClickEventHandler = {
   init: function init() {
-    Cc["@mozilla.org/eventlistenerservice;1"]
-      .getService(Ci.nsIEventListenerService)
-      .addSystemEventListener(global, "click", this, true);
+    Services.els.addSystemEventListener(global, "click", this, true);
   },
 
   handleEvent: function(event) {
     if (!event.isTrusted || event.defaultPrevented || event.button == 2) {
       return;
     }
 
     let originalTarget = event.originalTarget;