Bug 1492950 - Get browser-fullZoom.js and ZoomUI.jsm off of getBrowserForDocument. r=florian
authorMike Conley <mconley@mozilla.com>
Tue, 02 Oct 2018 17:51:11 +0000
changeset 487586 9bb5657e614c806a361bafd35d94eced2611cd66
parent 487585 bb9fc6495914b7176ce399f76df39caf2ba78472
child 487587 bd55b04144dccce7c1875c165e3306ab86a743b6
push id246
push userfmarier@mozilla.com
push dateSat, 13 Oct 2018 00:15:40 +0000
reviewersflorian
bugs1492950
milestone64.0a1
Bug 1492950 - Get browser-fullZoom.js and ZoomUI.jsm off of getBrowserForDocument. r=florian Depends on D6710 Differential Revision: https://phabricator.services.mozilla.com/D6711
browser/base/content/browser-fullZoom.js
browser/modules/ZoomUI.jsm
--- a/browser/base/content/browser-fullZoom.js
+++ b/browser/base/content/browser-fullZoom.js
@@ -452,18 +452,19 @@ var FullZoom = {
     const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
     if (target instanceof window.XULElement &&
         target.localName == "browser" &&
         target.namespaceURI == XUL_NS)
       return target;
 
     // With in-process content browsers, the event's target is the content
     // document.
-    if (target.nodeType == Node.DOCUMENT_NODE)
-      return gBrowser.getBrowserForDocument(target);
+    if (target.nodeType == Node.DOCUMENT_NODE) {
+      return target.ownerGlobal.docShell.chromeEventHandler;
+    }
 
     throw new Error("Unexpected ZoomChangeUsingMouseWheel event source");
   },
 
   /**
    * Increments the zoom change token for the given browser so that pending
    * async operations know that it may be unsafe to access they zoom when they
    * finish.
--- a/browser/modules/ZoomUI.jsm
+++ b/browser/modules/ZoomUI.jsm
@@ -37,25 +37,24 @@ function onEndSwapDocShells(event) {
   updateZoomUI(event.originalTarget);
 }
 
 function onZoomChange(event) {
   let browser;
   if (event.target.nodeType == event.target.DOCUMENT_NODE) {
     // In non-e10s, the event is dispatched on the contentDocument
     // so we need to jump through some hoops to get to the <xul:browser>.
-    let gBrowser = event.currentTarget.gBrowser;
     let topDoc = event.target.defaultView.top.document;
     if (!topDoc.documentElement) {
       // In some events, such as loading synthetic documents, the
-      // documentElement will be null and getBrowserForDocument will
-      // return null.
+      // documentElement will be null and we won't be able to find
+      // an associated browser.
       return;
     }
-    browser = gBrowser.getBrowserForDocument(topDoc);
+    browser = topDoc.ownerGlobal.docShell.chromeEventHandler;
   } else {
     browser = event.originalTarget;
   }
   updateZoomUI(browser, true);
 }
 
 /**
  * Updates zoom controls.