Bug 1543940 - Remove useTopLevelWindow option from DevTools menu/utils.js helper r=ochameau
authorJulian Descottes <jdescottes@mozilla.com>
Wed, 08 May 2019 21:37:01 +0000
changeset 531953 8fa4f7a2ab42ff565a7839bd401273c195f52bd4
parent 531952 6907e6f93141299a40d3824c8cd8de8b00dcc765
child 531954 eea9b4ad1dac0c981e9d4bc11b841b19b58b6d06
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1543940
milestone68.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 1543940 - Remove useTopLevelWindow option from DevTools menu/utils.js helper r=ochameau Depends on D27696 Differential Revision: https://phabricator.services.mozilla.com/D29887
devtools/client/responsive.html/components/DevicePixelRatioMenu.js
devtools/client/responsive.html/components/DeviceSelector.js
devtools/client/responsive.html/components/SettingsMenu.js
devtools/client/responsive.html/components/Toolbar.js
devtools/client/shared/components/menu/utils.js
devtools/client/shared/components/throttling/NetworkThrottlingMenu.js
--- a/devtools/client/responsive.html/components/DevicePixelRatioMenu.js
+++ b/devtools/client/responsive.html/components/DevicePixelRatioMenu.js
@@ -48,17 +48,16 @@ class DevicePixelRatioMenu extends PureC
           selectedPixelRatio === value :
           displayPixelRatio === value,
         click: () => onChangePixelRatio(+value),
       };
     });
 
     showMenu(menuItems, {
       button: event.target,
-      useTopLevelWindow: true,
     });
   }
 
   render() {
     const {
       devices,
       displayPixelRatio,
       selectedDevice,
--- a/devtools/client/responsive.html/components/DeviceSelector.js
+++ b/devtools/client/responsive.html/components/DeviceSelector.js
@@ -68,17 +68,16 @@ class DeviceSelector extends PureCompone
 
     menuItems.push({
       label: getStr("responsive.editDeviceList2"),
       click: () => onUpdateDeviceModal(true, viewportId),
     });
 
     showMenu(menuItems, {
       button: event.target,
-      useTopLevelWindow: true,
     });
   }
 
   render() {
     const {
       devices,
       selectedDevice,
     } = this.props;
--- a/devtools/client/responsive.html/components/SettingsMenu.js
+++ b/devtools/client/responsive.html/components/SettingsMenu.js
@@ -82,17 +82,16 @@ class SettingsMenu extends PureComponent
         click: () => {
           onToggleReloadOnUserAgent();
         },
       },
     ];
 
     showMenu(menuItems, {
       button: event.target,
-      useTopLevelWindow: true,
     });
   }
 
   render() {
     return (
       dom.button({
         id: "settings-button",
         className: "devtools-button",
--- a/devtools/client/responsive.html/components/Toolbar.js
+++ b/devtools/client/responsive.html/components/Toolbar.js
@@ -142,17 +142,16 @@ class Toolbar extends PureComponent {
             onChangePixelRatio,
             selectedDevice,
             selectedPixelRatio,
           }),
           dom.div({ className: "devtools-separator" }),
           NetworkThrottlingMenu({
             networkThrottling,
             onChangeNetworkThrottling,
-            useTopLevelWindow: true,
           }),
           dom.div({ className: "devtools-separator" }),
           this.renderUserAgent(),
           dom.button({
             id: "touch-simulation-button",
             className: "devtools-button" +
                        (touchSimulationEnabled ? " checked" : ""),
             title: (touchSimulationEnabled ?
--- a/devtools/client/shared/components/menu/utils.js
+++ b/devtools/client/shared/components/menu/utils.js
@@ -2,33 +2,28 @@
  * 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";
 
 const Menu = require("devtools/client/framework/menu");
 const MenuItem = require("devtools/client/framework/menu-item");
 
-loader.lazyRequireGetter(this, "getTopLevelWindow", "devtools/client/responsive.html/utils/window", true);
-
 /**
  * Helper function for opening context menu.
  *
  * @param {Array} items
  *        List of menu items.
  * @param {Object} options:
  * @property {Element} button
  *           Button element used to open the menu.
  * @property {Number} screenX
  *           Screen x coordinate of the menu on the screen.
  * @property {Number} screenY
  *           Screen y coordinate of the menu on the screen.
- * @property {Boolean} useTopLevelWindow
- *           Whether or not the top level window needs to be fetched. This option is used
- *           by RDM.
  */
 function showMenu(items, options) {
   if (items.length === 0) {
     return;
   }
 
   // Build the menu object from provided menu items.
   const menu = new Menu();
@@ -59,21 +54,14 @@ function showMenu(items, options) {
   if (options.button) {
     const button = options.button;
     const rect = button.getBoundingClientRect();
     const defaultView = button.ownerDocument.defaultView;
     screenX = rect.left + defaultView.mozInnerScreenX;
     screenY = rect.bottom + defaultView.mozInnerScreenY;
   }
 
-  let doc;
-  if (options.useTopLevelWindow) {
-    doc = getTopLevelWindow(window).document;
-  } else {
-    doc = window.document;
-  }
-
-  menu.popup(screenX, screenY, doc);
+  menu.popup(screenX, screenY, window.document);
 }
 
 module.exports = {
   showMenu,
 };
--- a/devtools/client/shared/components/throttling/NetworkThrottlingMenu.js
+++ b/devtools/client/shared/components/throttling/NetworkThrottlingMenu.js
@@ -23,30 +23,28 @@ loader.lazyRequireGetter(this, "showMenu
  * This component represents selector button that can be used
  * to throttle network bandwidth.
  */
 class NetworkThrottlingMenu extends PureComponent {
   static get propTypes() {
     return {
       networkThrottling: PropTypes.shape(Types.networkThrottling).isRequired,
       onChangeNetworkThrottling: PropTypes.func.isRequired,
-      useTopLevelWindow: PropTypes.bool,
     };
   }
 
   constructor(props) {
     super(props);
     this.onShowThrottlingMenu = this.onShowThrottlingMenu.bind(this);
   }
 
   onShowThrottlingMenu(event) {
     const {
       networkThrottling,
       onChangeNetworkThrottling,
-      useTopLevelWindow,
     } = this.props;
 
     const menuItems = throttlingProfiles.map(profile => {
       return {
         label: profile.id,
         type: "checkbox",
         checked: networkThrottling.enabled && profile.id == networkThrottling.profile,
         click: () => onChangeNetworkThrottling(true, profile.id),