Bug 1527049 - Remove ScrollbarSampler.jsm. r=jaws
authorFelipe Gomes <felipc@gmail.com>
Mon, 11 Feb 2019 20:54:08 +0000
changeset 458570 1373e4746bcaa6578f51541143d9b7c44ee45988
parent 458569 7a4f96a4d71cfc6a03d79ad5e673a4722841e74d
child 458571 787a2598c88f6033f3379e45fefea11422899276
push id77918
push userjwein@mozilla.com
push dateMon, 11 Feb 2019 20:54:42 +0000
treeherderautoland@1373e4746bca [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1527049
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1527049 - Remove ScrollbarSampler.jsm. r=jaws This module is no longer used. Differential Revision: https://phabricator.services.mozilla.com/D19404
browser/components/customizableui/ScrollbarSampler.jsm
browser/components/customizableui/content/panelUI.js
browser/components/customizableui/moz.build
deleted file mode 100644
--- a/browser/components/customizableui/ScrollbarSampler.jsm
+++ /dev/null
@@ -1,60 +0,0 @@
-/* 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/. */
-
-"use strict";
-
-var EXPORTED_SYMBOLS = ["ScrollbarSampler"];
-
-const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var gSystemScrollbarWidth = null;
-
-var ScrollbarSampler = {
-  getSystemScrollbarWidth() {
-    if (gSystemScrollbarWidth !== null) {
-      return Promise.resolve(gSystemScrollbarWidth);
-    }
-
-    return new Promise(resolve => {
-      this._sampleSystemScrollbarWidth().then(function(systemScrollbarWidth) {
-        gSystemScrollbarWidth = systemScrollbarWidth;
-        resolve(gSystemScrollbarWidth);
-      });
-    });
-  },
-
-  resetSystemScrollbarWidth() {
-    gSystemScrollbarWidth = null;
-  },
-
-  _sampleSystemScrollbarWidth() {
-    let hwin = Services.appShell.hiddenDOMWindow;
-    let hdoc = hwin.document.documentElement;
-    let iframe = hwin.document.createElementNS("http://www.w3.org/1999/xhtml",
-                                               "html:iframe");
-    iframe.setAttribute("srcdoc", '<body style="overflow-y: scroll"></body>');
-    hdoc.appendChild(iframe);
-
-    let cwindow = iframe.contentWindow;
-    let utils = cwindow.windowUtils;
-
-    return new Promise(resolve => {
-      cwindow.addEventListener("load", function(aEvent) {
-        let sbWidth = {};
-        try {
-          utils.getScrollbarSize(true, sbWidth, {});
-        } catch (e) {
-          Cu.reportError("Could not sample scrollbar size: " + e + " -- " +
-                         e.stack);
-          sbWidth.value = 0;
-        }
-        // Minimum width of 10 so that we have enough padding:
-        sbWidth.value = Math.max(sbWidth.value, 10);
-        resolve(sbWidth.value);
-        iframe.remove();
-      }, {once: true});
-    });
-  },
-};
-Object.freeze(this.ScrollbarSampler);
--- a/browser/components/customizableui/content/panelUI.js
+++ b/browser/components/customizableui/content/panelUI.js
@@ -3,18 +3,16 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 ChromeUtils.defineModuleGetter(this, "AppMenuNotifications",
                                "resource://gre/modules/AppMenuNotifications.jsm");
 ChromeUtils.defineModuleGetter(this, "NewTabUtils",
                                "resource://gre/modules/NewTabUtils.jsm");
 ChromeUtils.defineModuleGetter(this, "PanelMultiView",
                                "resource:///modules/PanelMultiView.jsm");
-ChromeUtils.defineModuleGetter(this, "ScrollbarSampler",
-                               "resource:///modules/ScrollbarSampler.jsm");
 
 /**
  * Maintains the state and dispatches events for the main menu panel.
  */
 
 const PanelUI = {
   /** Panel events that we listen for. **/
   get kEvents() {
@@ -44,17 +42,16 @@ const PanelUI = {
   _initialized: false,
   _notifications: null,
 
   init() {
     this._initElements();
 
     this.menuButton.addEventListener("mousedown", this);
     this.menuButton.addEventListener("keypress", this);
-    this._overlayScrollListenerBoundFn = this._overlayScrollListener.bind(this);
 
     Services.obs.addObserver(this, "fullscreen-nav-toolbox");
     Services.obs.addObserver(this, "appMenu-notifications");
 
     XPCOMUtils.defineLazyPreferenceGetter(this, "autoHideToolbarInFullScreen",
       "browser.fullscreen.autohide", false, (pref, previousValue, newValue) => {
         // On OSX, or with autohide preffed off, MozDOMFullscreen is the only
         // event we care about, since fullscreen should behave just like non
@@ -83,17 +80,16 @@ const PanelUI = {
 
     XPCOMUtils.defineLazyPreferenceGetter(this, "libraryRecentHighlightsEnabled",
       "browser.library.activity-stream.enabled", false, (pref, previousValue, newValue) => {
         if (!newValue)
           this.clearLibraryRecentHighlights();
       });
 
     window.addEventListener("activate", this);
-    window.matchMedia("(-moz-overlay-scrollbars)").addListener(this._overlayScrollListenerBoundFn);
     CustomizableUI.addListener(this);
 
     for (let event of this.kEvents) {
       this.notificationPanel.addEventListener(event, this);
     }
 
     // We do this sync on init because in order to have the overflow button show up
     // we need to know whether anything is in the permanent panel area.
@@ -154,19 +150,17 @@ const PanelUI = {
     Services.obs.removeObserver(this, "appMenu-notifications");
 
     window.removeEventListener("MozDOMFullscreen:Entered", this);
     window.removeEventListener("MozDOMFullscreen:Exited", this);
     window.removeEventListener("fullscreen", this);
     window.removeEventListener("activate", this);
     this.menuButton.removeEventListener("mousedown", this);
     this.menuButton.removeEventListener("keypress", this);
-    window.matchMedia("(-moz-overlay-scrollbars)").removeListener(this._overlayScrollListenerBoundFn);
     CustomizableUI.removeListener(this);
-    this._overlayScrollListenerBoundFn = null;
     this.libraryView.removeEventListener("ViewShowing", this);
   },
 
   /**
    * Opens the menu panel if it's closed, or closes it if it's
    * open.
    *
    * @param aEvent the event that triggers the toggle.
@@ -669,22 +663,16 @@ const PanelUI = {
 
     let key = document.getElementById("key_quitApplication");
     stringArgs.push(ShortcutUtils.prettifyShortcut(key));
     let tooltipString = CustomizableUI.getLocalizedProperty({x: tooltipId}, "x", stringArgs);
     let quitButton = document.getElementById("PanelUI-quit");
     quitButton.setAttribute("tooltiptext", tooltipString);
   },
 
-  _overlayScrollListenerBoundFn: null,
-  _overlayScrollListener(aMQL) {
-    ScrollbarSampler.resetSystemScrollbarWidth();
-    this._scrollWidth = null;
-  },
-
   _hidePopup() {
     if (this.isNotificationPanelOpen) {
       this.notificationPanel.hidePopup();
     }
   },
 
   _updateNotifications(notificationsChanged) {
     let notifications = this._notifications;
--- a/browser/components/customizableui/moz.build
+++ b/browser/components/customizableui/moz.build
@@ -15,14 +15,13 @@ TESTING_JS_MODULES += [
 ]
 
 EXTRA_JS_MODULES += [
     'CustomizableUI.jsm',
     'CustomizableWidgets.jsm',
     'CustomizeMode.jsm',
     'DragPositionManager.jsm',
     'PanelMultiView.jsm',
-    'ScrollbarSampler.jsm',
     'SearchWidgetTracker.jsm',
 ]
 
 with Files('**'):
     BUG_COMPONENT = ('Firefox', 'Toolbars and Customization')