From 49c743f7f54f9352888b7f85b705f62ea88a6b7b Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Tue, 26 Sep 2017 18:49:54 -0500 Subject: [PATCH] Bug 1305777 - Remove old RDM. r=ochameau MozReview-Commit-ID: gOvvF9bcDT --HG-- extra : rebase_source : 1a0773629ad429e6c485df4c2bf0348504a2c9c5 --- .eslintignore | 1 - browser/base/content/browser.css | 23 - devtools/client/jar.mn | 13 - .../locales/en-US/responsiveUI.properties | 78 - devtools/client/moz.build | 1 - devtools/client/preferences/devtools.js | 3 - devtools/client/responsivedesign/moz.build | 12 - .../responsivedesign/responsivedesign-old.js | 1313 ----------------- .../client/responsivedesign/test/.eslintrc.js | 10 - .../client/responsivedesign/test/browser.ini | 22 - .../test/browser_responsive_cmd.js | 137 -- .../test/browser_responsive_devicewidth.js | 68 - .../test/browser_responsivecomputedview.js | 67 - .../test/browser_responsiveruleview.js | 95 -- .../test/browser_responsiveui.js | 250 ---- .../browser_responsiveui_customuseragent.js | 56 - .../test/browser_responsiveui_touch.js | 148 -- .../test/browser_responsiveui_window_close.js | 25 - .../browser_responsiveuiaddcustompreset.js | 121 -- devtools/client/responsivedesign/test/head.js | 302 ---- .../client/responsivedesign/test/touch.html | 88 -- devtools/client/themes/devtools-browser.css | 1 - .../responsive-horizontal-resizer.png | Bin 102 -> 0 bytes .../responsive-horizontal-resizer@2x.png | Bin 129 -> 0 bytes .../responsivemode/responsive-se-resizer.png | Bin 129 -> 0 bytes .../responsive-se-resizer@2x.png | Bin 205 -> 0 bytes .../responsive-vertical-resizer.png | Bin 105 -> 0 bytes .../responsive-vertical-resizer@2x.png | Bin 141 -> 0 bytes .../responsivemode/responsiveui-home.png | Bin 276 -> 0 bytes .../responsivemode/responsiveui-rotate.png | Bin 245 -> 0 bytes .../responsivemode/responsiveui-rotate@2x.png | Bin 438 -> 0 bytes .../responsiveui-screenshot.png | Bin 303 -> 0 bytes .../responsiveui-screenshot@2x.png | Bin 531 -> 0 bytes .../responsivemode/responsiveui-touch.png | Bin 470 -> 0 bytes .../responsivemode/responsiveui-touch@2x.png | Bin 927 -> 0 bytes devtools/client/themes/moz.build | 1 - devtools/client/themes/responsivedesign.css | 355 ----- 37 files changed, 3190 deletions(-) delete mode 100644 devtools/client/locales/en-US/responsiveUI.properties delete mode 100644 devtools/client/responsivedesign/moz.build delete mode 100644 devtools/client/responsivedesign/responsivedesign-old.js delete mode 100644 devtools/client/responsivedesign/test/.eslintrc.js delete mode 100644 devtools/client/responsivedesign/test/browser.ini delete mode 100644 devtools/client/responsivedesign/test/browser_responsive_cmd.js delete mode 100644 devtools/client/responsivedesign/test/browser_responsive_devicewidth.js delete mode 100644 devtools/client/responsivedesign/test/browser_responsivecomputedview.js delete mode 100644 devtools/client/responsivedesign/test/browser_responsiveruleview.js delete mode 100644 devtools/client/responsivedesign/test/browser_responsiveui.js delete mode 100644 devtools/client/responsivedesign/test/browser_responsiveui_customuseragent.js delete mode 100644 devtools/client/responsivedesign/test/browser_responsiveui_touch.js delete mode 100644 devtools/client/responsivedesign/test/browser_responsiveui_window_close.js delete mode 100644 devtools/client/responsivedesign/test/browser_responsiveuiaddcustompreset.js delete mode 100644 devtools/client/responsivedesign/test/head.js delete mode 100644 devtools/client/responsivedesign/test/touch.html delete mode 100644 devtools/client/themes/images/responsivemode/responsive-horizontal-resizer.png delete mode 100644 devtools/client/themes/images/responsivemode/responsive-horizontal-resizer@2x.png delete mode 100644 devtools/client/themes/images/responsivemode/responsive-se-resizer.png delete mode 100644 devtools/client/themes/images/responsivemode/responsive-se-resizer@2x.png delete mode 100644 devtools/client/themes/images/responsivemode/responsive-vertical-resizer.png delete mode 100644 devtools/client/themes/images/responsivemode/responsive-vertical-resizer@2x.png delete mode 100644 devtools/client/themes/images/responsivemode/responsiveui-home.png delete mode 100644 devtools/client/themes/images/responsivemode/responsiveui-rotate.png delete mode 100644 devtools/client/themes/images/responsivemode/responsiveui-rotate@2x.png delete mode 100644 devtools/client/themes/images/responsivemode/responsiveui-screenshot.png delete mode 100644 devtools/client/themes/images/responsivemode/responsiveui-screenshot@2x.png delete mode 100644 devtools/client/themes/images/responsivemode/responsiveui-touch.png delete mode 100644 devtools/client/themes/images/responsivemode/responsiveui-touch@2x.png delete mode 100644 devtools/client/themes/responsivedesign.css diff --git a/.eslintignore b/.eslintignore index 5a4f049b644d..603100967fef 100644 --- a/.eslintignore +++ b/.eslintignore @@ -96,7 +96,6 @@ devtools/client/memory/test/chrome/*.html devtools/client/performance/components/test/test_jit_optimizations_01.html devtools/client/projecteditor/** devtools/client/responsive.html/test/browser/touch.html -devtools/client/responsivedesign/** devtools/client/scratchpad/** devtools/client/shadereditor/** devtools/client/shared/*.jsm diff --git a/browser/base/content/browser.css b/browser/base/content/browser.css index a5d554b1e200..b156da1b3d23 100644 --- a/browser/base/content/browser.css +++ b/browser/base/content/browser.css @@ -1094,29 +1094,6 @@ html|*#gcli-output-frame, -moz-box-pack: center; } -/* Responsive Mode */ - -.browserContainer[responsivemode] { - overflow: auto; -} - -.devtools-responsiveui-toolbar:-moz-locale-dir(rtl) { - -moz-box-pack: end; -} - -.browserStack[responsivemode] { - transition-duration: 200ms; - transition-timing-function: linear; -} - -.browserStack[responsivemode] { - transition-property: min-width, max-width, min-height, max-height; -} - -.browserStack[responsivemode][notransition] { - transition: none; -} - /* Translation */ notification[value="translation"] { -moz-binding: url("chrome://browser/content/translation-infobar.xml#translationbar"); diff --git a/devtools/client/jar.mn b/devtools/client/jar.mn index 99541366a85e..da85d4ca0319 100644 --- a/devtools/client/jar.mn +++ b/devtools/client/jar.mn @@ -187,19 +187,6 @@ devtools.jar: skin/images/debugger-toggleBreakpoints.svg (themes/images/debugger-toggleBreakpoints.svg) skin/images/tracer-icon.png (themes/images/tracer-icon.png) skin/images/tracer-icon@2x.png (themes/images/tracer-icon@2x.png) - skin/images/responsivemode/responsive-se-resizer.png (themes/images/responsivemode/responsive-se-resizer.png) - skin/images/responsivemode/responsive-se-resizer@2x.png (themes/images/responsivemode/responsive-se-resizer@2x.png) - skin/images/responsivemode/responsive-vertical-resizer.png (themes/images/responsivemode/responsive-vertical-resizer.png) - skin/images/responsivemode/responsive-vertical-resizer@2x.png (themes/images/responsivemode/responsive-vertical-resizer@2x.png) - skin/images/responsivemode/responsive-horizontal-resizer.png (themes/images/responsivemode/responsive-horizontal-resizer.png) - skin/images/responsivemode/responsive-horizontal-resizer@2x.png (themes/images/responsivemode/responsive-horizontal-resizer@2x.png) - skin/images/responsivemode/responsiveui-rotate.png (themes/images/responsivemode/responsiveui-rotate.png) - skin/images/responsivemode/responsiveui-rotate@2x.png (themes/images/responsivemode/responsiveui-rotate@2x.png) - skin/images/responsivemode/responsiveui-touch.png (themes/images/responsivemode/responsiveui-touch.png) - skin/images/responsivemode/responsiveui-touch@2x.png (themes/images/responsivemode/responsiveui-touch@2x.png) - skin/images/responsivemode/responsiveui-screenshot.png (themes/images/responsivemode/responsiveui-screenshot.png) - skin/images/responsivemode/responsiveui-screenshot@2x.png (themes/images/responsivemode/responsiveui-screenshot@2x.png) - skin/images/responsivemode/responsiveui-home.png (themes/images/responsivemode/responsiveui-home.png) skin/images/toggle-tools.png (themes/images/toggle-tools.png) skin/images/toggle-tools@2x.png (themes/images/toggle-tools@2x.png) skin/images/dock-bottom.svg (themes/images/dock-bottom.svg) diff --git a/devtools/client/locales/en-US/responsiveUI.properties b/devtools/client/locales/en-US/responsiveUI.properties deleted file mode 100644 index b4144e67d891..000000000000 --- a/devtools/client/locales/en-US/responsiveUI.properties +++ /dev/null @@ -1,78 +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/. - -# LOCALIZATION NOTE These strings are used inside the Responsive Mode -# which is available from the Web Developer sub-menu -> 'Responsive Mode'. -# -# The correct localization of this file might be to keep it in -# English, or another language commonly spoken among web developers. -# You want to make that choice consistent across the developer tools. -# A good criteria is the language in which you'd find the best -# documentation on web development on the web. - -# LOCALIZATION NOTE (responsiveUI.rotate2): tooltip of the rotate button. -responsiveUI.rotate2=Rotate - -# LOCALIZATION NOTE (responsiveUI.screenshot): tooltip of the screenshot button. -responsiveUI.screenshot=Screenshot - -# LOCALIZATION NOTE (responsiveUI.userAgentPlaceholder): placeholder for the user agent input. -responsiveUI.userAgentPlaceholder=Custom User Agent - -# LOCALIZATION NOTE (responsiveUI.screenshotGeneratedFilename): The auto generated filename. -# The first argument (%1$S) is the date string in yyyy-mm-dd format and the second -# argument (%2$S) is the time string in HH.MM.SS format. -responsiveUI.screenshotGeneratedFilename=Screen Shot %1$S at %2$S - -# LOCALIZATION NOTE (responsiveUI.touch): tooltip of the touch button. -responsiveUI.touch=Simulate touch events (page reload might be needed) - -# LOCALIZATION NOTE (responsiveUI.addPreset): label of the add preset button. -responsiveUI.addPreset=Add Preset - -# LOCALIZATION NOTE (responsiveUI.removePreset): label of the remove preset button. -responsiveUI.removePreset=Remove Preset - -# LOCALIZATION NOTE (responsiveUI.customResolution): label of the first item -# in the menulist at the beginning of the toolbar. For %S is replace with the -# current size of the page. For example: "400x600". -responsiveUI.customResolution=%S (custom) - -# LOCALIZATION NOTE (responsiveUI.namedResolution): label of custom items with a name -# in the menulist of the toolbar. -# For example: "320x480 (phone)". -responsiveUI.namedResolution=%S (%S) - -# LOCALIZATION NOTE (responsiveUI.customNamePromptTitle1): prompt title when asking -# the user to specify a name for a new custom preset. -responsiveUI.customNamePromptTitle1=Responsive Design Mode - -# LOCALIZATION NOTE (responsiveUI.close1): tooltip text of the close button. -responsiveUI.close1=Leave Responsive Design Mode - -# LOCALIZATION NOTE (responsiveUI.customNamePromptMsg): prompt message when asking -# the user to specify a name for a new custom preset. -responsiveUI.customNamePromptMsg=Give a name to the %Sx%S preset - -# LOCALIZATION NOTE (responsiveUI.resizer): tooltip showed when -# overring the resizers. -responsiveUI.resizerTooltip=Use the Control key for more precision. Use Shift key for rounded sizes. - -# LOCALIZATION NOTE (responsiveUI.needReload): notification that appears -# when touch events are enabled -responsiveUI.needReload=If touch event listeners have been added earlier, the page needs to be reloaded. -responsiveUI.notificationReload=Reload -responsiveUI.notificationReload_accesskey=R -responsiveUI.dontShowReloadNotification=Never show again -responsiveUI.dontShowReloadNotification_accesskey=N - -# LOCALIZATION NOTE (responsiveUI.newVersionUserDisabled): notification that appears -# when old RDM is displayed because the user has disabled new RDM. -responsiveUI.newVersionUserDisabled=A new version of Responsive Design Mode is available, but it appears to be disabled. Please enable it and provide feedback, as this version will be removed. -# LOCALIZATION NOTE (responsiveUI.newVersionE10sDisabled): notification that appears -# when old RDM is displayed because e10s is disabled. -responsiveUI.newVersionE10sDisabled=A new version of Responsive Design Mode is available, but it requires multi-process mode, which is currently disabled. Please enable it and provide feedback, as this version will be removed. -# LOCALIZATION NOTE (responsiveUI.newVersionEnableAndRestart): button text in notification -# to enable new RDM itself or e10s as a prerequisite for new RDM. -responsiveUI.newVersionEnableAndRestart=Enable and Restart \ No newline at end of file diff --git a/devtools/client/moz.build b/devtools/client/moz.build index d33f504570dc..bd2cf8233a3a 100644 --- a/devtools/client/moz.build +++ b/devtools/client/moz.build @@ -22,7 +22,6 @@ DIRS += [ 'performance', 'preferences', 'responsive.html', - 'responsivedesign', 'scratchpad', 'shadereditor', 'shared', diff --git a/devtools/client/preferences/devtools.js b/devtools/client/preferences/devtools.js index c077314432af..c076e9c64e08 100644 --- a/devtools/client/preferences/devtools.js +++ b/devtools/client/preferences/devtools.js @@ -100,9 +100,6 @@ pref("devtools.markup.collapseAttributeLength", 120); // DevTools default color unit pref("devtools.defaultColorUnit", "authored"); -// Enable the Responsive UI tool -pref("devtools.responsiveUI.no-reload-notification", false); - // Enable the Memory tools pref("devtools.memory.enabled", true); diff --git a/devtools/client/responsivedesign/moz.build b/devtools/client/responsivedesign/moz.build deleted file mode 100644 index af97f65716cc..000000000000 --- a/devtools/client/responsivedesign/moz.build +++ /dev/null @@ -1,12 +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/. - -BROWSER_CHROME_MANIFESTS += ['test/browser.ini'] - -DevToolsModules( - 'responsivedesign-old.js', -) - -with Files('**'): - BUG_COMPONENT = ('Firefox', 'Developer Tools: Responsive Design Mode') diff --git a/devtools/client/responsivedesign/responsivedesign-old.js b/devtools/client/responsivedesign/responsivedesign-old.js deleted file mode 100644 index 414102ca10a2..000000000000 --- a/devtools/client/responsivedesign/responsivedesign-old.js +++ /dev/null @@ -1,1313 +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"; - -const { LocalizationHelper } = require("devtools/shared/l10n"); -const { Task } = require("devtools/shared/task"); -const Services = require("Services"); -const EventEmitter = require("devtools/shared/old-event-emitter"); - -loader.lazyImporter(this, "SystemAppProxy", - "resource://gre/modules/SystemAppProxy.jsm"); -loader.lazyImporter(this, "BrowserUtils", - "resource://gre/modules/BrowserUtils.jsm"); -loader.lazyRequireGetter(this, "Telemetry", "devtools/client/shared/telemetry"); -loader.lazyRequireGetter(this, "showDoorhanger", - "devtools/client/shared/doorhanger", true); -loader.lazyRequireGetter(this, "gDevToolsBrowser", - "devtools/client/framework/devtools-browser", true); -loader.lazyRequireGetter(this, "TouchEventSimulator", - "devtools/shared/touch/simulator", true); -loader.lazyRequireGetter(this, "flags", - "devtools/shared/flags"); -loader.lazyRequireGetter(this, "EmulationFront", - "devtools/shared/fronts/emulation", true); -loader.lazyRequireGetter(this, "DebuggerClient", - "devtools/shared/client/main", true); -loader.lazyRequireGetter(this, "DebuggerServer", - "devtools/server/main", true); -loader.lazyRequireGetter(this, "system", "devtools/shared/system"); - -const NEW_RDM_ENABLED = "devtools.responsive.html.enabled"; - -const MIN_WIDTH = 50; -const MIN_HEIGHT = 50; - -const MAX_WIDTH = 10000; -const MAX_HEIGHT = 10000; - -const SLOW_RATIO = 6; -const ROUND_RATIO = 10; - -const INPUT_PARSER = /(\d+)[^\d]+(\d+)/; - -const SHARED_L10N = new LocalizationHelper("devtools/client/locales/shared.properties"); - -function debug(msg) { - // dump(`RDM UI: ${msg}\n`); -} - -var ActiveTabs = new Map(); - -var ResponsiveUIManager = { - /** - * Check if the a tab is in a responsive mode. - * Leave the responsive mode if active, - * active the responsive mode if not active. - * - * @param window the main window. - * @param tab the tab targeted. - */ - toggle: function (window, tab) { - if (this.isActiveForTab(tab)) { - ActiveTabs.get(tab).close(); - } else { - this.openIfNeeded(window, tab); - } - }, - - /** - * Launches the responsive mode. - * - * @param window the main window. - * @param tab the tab targeted. - * @returns {ResponsiveUI} the instance of ResponsiveUI for the current tab. - */ - openIfNeeded: Task.async(function* (window, tab) { - let ui; - if (!this.isActiveForTab(tab)) { - ui = new ResponsiveUI(window, tab); - yield ui.inited; - } else { - ui = this.getResponsiveUIForTab(tab); - } - return ui; - }), - - /** - * Returns true if responsive view is active for the provided tab. - * - * @param tab the tab targeted. - */ - isActiveForTab: function (tab) { - return ActiveTabs.has(tab); - }, - - /** - * Return the responsive UI controller for a tab. - */ - getResponsiveUIForTab: function (tab) { - return ActiveTabs.get(tab); - }, - - /** - * Handle gcli commands. - * - * @param window the browser window. - * @param tab the tab targeted. - * @param command the command name. - * @param args command arguments. - */ - handleGcliCommand: Task.async(function* (window, tab, command, args) { - switch (command) { - case "resize to": - let ui = yield this.openIfNeeded(window, tab); - ui.setViewportSize(args); - break; - case "resize on": - this.openIfNeeded(window, tab); - break; - case "resize off": - if (this.isActiveForTab(tab)) { - yield ActiveTabs.get(tab).close(); - } - break; - case "resize toggle": - this.toggle(window, tab); - break; - default: - } - }) -}; - -EventEmitter.decorate(ResponsiveUIManager); -exports.ResponsiveUIManager = ResponsiveUIManager; - -var defaultPresets = [ - // Phones - {key: "320x480", width: 320, height: 480}, // iPhone, B2G, with - {key: "360x640", width: 360, height: 640}, // Android 4, phones, with - - // Tablets - {key: "768x1024", width: 768, height: 1024}, // iPad, with - {key: "800x1280", width: 800, height: 1280}, // Android 4, Tablet, with - - // Default width for mobile browsers, no - {key: "980x1280", width: 980, height: 1280}, - - // Computer - {key: "1280x600", width: 1280, height: 600}, - {key: "1920x900", width: 1920, height: 900}, -]; - -function ResponsiveUI(window, tab) { - this.mainWindow = window; - this.tab = tab; - this.mm = this.tab.linkedBrowser.messageManager; - this.tabContainer = window.gBrowser.tabContainer; - this.browser = tab.linkedBrowser; - this.chromeDoc = window.document; - this.container = window.gBrowser.getBrowserContainer(this.browser); - this.stack = this.container.querySelector(".browserStack"); - this._telemetry = new Telemetry(); - - // Let's bind some callbacks. - this.boundPresetSelected = this.presetSelected.bind(this); - this.boundHandleManualInput = this.handleManualInput.bind(this); - this.boundAddPreset = this.addPreset.bind(this); - this.boundRemovePreset = this.removePreset.bind(this); - this.boundRotate = this.rotate.bind(this); - this.boundScreenshot = () => this.screenshot(); - this.boundTouch = this.toggleTouch.bind(this); - this.boundClose = this.close.bind(this); - this.boundStartResizing = this.startResizing.bind(this); - this.boundStopResizing = this.stopResizing.bind(this); - this.boundOnDrag = this.onDrag.bind(this); - this.boundChangeUA = this.changeUA.bind(this); - this.boundOnContentResize = this.onContentResize.bind(this); - - this.mm.addMessageListener("ResponsiveMode:OnContentResize", - this.boundOnContentResize); - - // We must be ready to handle window or tab close now that we have saved - // ourselves in ActiveTabs. Otherwise we risk leaking the window. - this.mainWindow.addEventListener("unload", this); - this.tab.addEventListener("TabClose", this); - this.tabContainer.addEventListener("TabSelect", this); - - ActiveTabs.set(this.tab, this); - - this.inited = this.init(); -} - -ResponsiveUI.prototype = { - _transitionsEnabled: true, - get transitionsEnabled() { - return this._transitionsEnabled; - }, - set transitionsEnabled(value) { - this._transitionsEnabled = value; - if (value && !this._resizing && this.stack.hasAttribute("responsivemode")) { - this.stack.removeAttribute("notransition"); - } else if (!value) { - this.stack.setAttribute("notransition", "true"); - } - }, - - init: Task.async(function* () { - debug("INIT BEGINS"); - let ready = this.waitForMessage("ResponsiveMode:ChildScriptReady"); - this.mm.loadFrameScript("resource://devtools/client/responsive.html/browser/content.js", true); - yield ready; - - yield gDevToolsBrowser.loadBrowserStyleSheet(this.mainWindow); - - let requiresFloatingScrollbars = - !this.mainWindow.matchMedia("(-moz-overlay-scrollbars)").matches; - let started = this.waitForMessage("ResponsiveMode:Start:Done"); - debug("SEND START"); - this.mm.sendAsyncMessage("ResponsiveMode:Start", { - requiresFloatingScrollbars, - // Tests expect events on resize to yield on various size changes - notifyOnResize: flags.testing, - }); - yield started; - - // Load Presets - this.loadPresets(); - - // Setup the UI - this.container.setAttribute("responsivemode", "true"); - this.stack.setAttribute("responsivemode", "true"); - this.buildUI(); - this.checkMenus(); - - // Rotate the responsive mode if needed - try { - if (Services.prefs.getBoolPref("devtools.responsiveUI.rotate")) { - this.rotate(); - } - } catch (e) { - // There is no default value defined, so errors are expected. - } - - // Touch events support - this.touchEnableBefore = false; - this.touchEventSimulator = new TouchEventSimulator(this.browser); - - yield this.connectToServer(); - this.userAgentInput.hidden = false; - - // Hook to display promotional Developer Edition doorhanger. - // Only displayed once. - showDoorhanger({ - window: this.mainWindow, - type: "deveditionpromo", - anchor: this.chromeDoc.querySelector("#content") - }); - - this.showNewUINotification(); - - // Notify that responsive mode is on. - this._telemetry.toolOpened("responsive"); - ResponsiveUIManager.emit("on", { tab: this.tab }); - }), - - connectToServer: Task.async(function* () { - if (!DebuggerServer.initialized) { - DebuggerServer.init(); - DebuggerServer.addBrowserActors(); - } - this.client = new DebuggerClient(DebuggerServer.connectPipe()); - yield this.client.connect(); - let { tab } = yield this.client.getTab(); - yield this.client.attachTab(tab.actor); - this.emulationFront = EmulationFront(this.client, tab); - }), - - loadPresets: function () { - // Try to load presets from prefs - let presets = defaultPresets; - if (Services.prefs.prefHasUserValue("devtools.responsiveUI.presets")) { - try { - presets = JSON.parse(Services.prefs.getCharPref("devtools.responsiveUI.presets")); - } catch (e) { - // User pref is malformated. - console.error("Could not parse pref `devtools.responsiveUI.presets`: " + e); - } - } - - this.customPreset = { key: "custom", custom: true }; - - if (Array.isArray(presets)) { - this.presets = [this.customPreset].concat(presets); - } else { - console.error("Presets value (devtools.responsiveUI.presets) is malformated."); - this.presets = [this.customPreset]; - } - - try { - let width = Services.prefs.getIntPref("devtools.responsiveUI.customWidth"); - let height = Services.prefs.getIntPref("devtools.responsiveUI.customHeight"); - this.customPreset.width = Math.min(MAX_WIDTH, width); - this.customPreset.height = Math.min(MAX_HEIGHT, height); - - this.currentPresetKey = - Services.prefs.getCharPref("devtools.responsiveUI.currentPreset"); - } catch (e) { - // Default size. The first preset (custom) is the one that will be used. - let bbox = this.stack.getBoundingClientRect(); - - this.customPreset.width = bbox.width - 40; // horizontal padding of the container - this.customPreset.height = bbox.height - 80; // vertical padding + toolbar height - - this.currentPresetKey = this.presets[1].key; // most common preset - } - }, - - /** - * Destroy the nodes. Remove listeners. Reset the style. - */ - close: Task.async(function* () { - debug("CLOSE BEGINS"); - if (this.closing) { - debug("ALREADY CLOSING, ABORT"); - return; - } - this.closing = true; - - // If we're closing very fast (in tests), ensure init has finished. - debug("CLOSE: WAIT ON INITED"); - yield this.inited; - debug("CLOSE: INITED DONE"); - - this.unCheckMenus(); - // Reset style of the stack. - debug(`CURRENT SIZE: ${this.stack.getAttribute("style")}`); - let style = "max-width: none;" + - "min-width: 0;" + - "max-height: none;" + - "min-height: 0;"; - debug("RESET STACK SIZE"); - this.stack.setAttribute("style", style); - - // Wait for resize message before stopping in the child when testing, - // but only if we should expect to still get a message. - if (flags.testing && this.tab.linkedBrowser.messageManager) { - debug("CLOSE: WAIT ON CONTENT RESIZE"); - yield this.waitForMessage("ResponsiveMode:OnContentResize"); - debug("CLOSE: CONTENT RESIZE DONE"); - } - - if (this.isResizing) { - this.stopResizing(); - } - - // Remove listeners. - this.menulist.removeEventListener("select", this.boundPresetSelected, true); - this.menulist.removeEventListener("change", this.boundHandleManualInput, true); - this.mainWindow.removeEventListener("unload", this); - this.tab.removeEventListener("TabClose", this); - this.tabContainer.removeEventListener("TabSelect", this); - this.rotatebutton.removeEventListener("command", this.boundRotate, true); - this.screenshotbutton.removeEventListener("command", this.boundScreenshot, true); - this.closebutton.removeEventListener("command", this.boundClose, true); - this.addbutton.removeEventListener("command", this.boundAddPreset, true); - this.removebutton.removeEventListener("command", this.boundRemovePreset, true); - this.touchbutton.removeEventListener("command", this.boundTouch, true); - this.userAgentInput.removeEventListener("blur", this.boundChangeUA, true); - - // Removed elements. - this.container.removeChild(this.toolbar); - if (this.bottomToolbar) { - this.bottomToolbar.remove(); - delete this.bottomToolbar; - } - this.stack.removeChild(this.resizer); - this.stack.removeChild(this.resizeBarV); - this.stack.removeChild(this.resizeBarH); - - this.stack.classList.remove("fxos-mode"); - - // Unset the responsive mode. - this.container.removeAttribute("responsivemode"); - this.stack.removeAttribute("responsivemode"); - - ActiveTabs.delete(this.tab); - if (this.touchEventSimulator) { - this.touchEventSimulator.stop(); - } - - debug("CLOSE: WAIT ON CLIENT CLOSE"); - yield this.client.close(); - debug("CLOSE: CLIENT CLOSE DONE"); - this.client = this.emulationFront = null; - - this._telemetry.toolClosed("responsive"); - - if (this.tab.linkedBrowser && this.tab.linkedBrowser.messageManager) { - let stopped = this.waitForMessage("ResponsiveMode:Stop:Done"); - this.tab.linkedBrowser.messageManager.sendAsyncMessage("ResponsiveMode:Stop"); - debug("CLOSE: WAIT ON STOP"); - yield stopped; - debug("CLOSE: STOP DONE"); - } - - this.hideNewUINotification(); - - debug("CLOSE: DONE, EMIT OFF"); - this.inited = null; - ResponsiveUIManager.emit("off", { tab: this.tab }); - }), - - waitForMessage(message) { - return new Promise(resolve => { - let listener = () => { - this.mm.removeMessageListener(message, listener); - resolve(); - }; - this.mm.addMessageListener(message, listener); - }); - }, - - /** - * Emit an event when the content has been resized. Only used in tests. - */ - onContentResize: function (msg) { - ResponsiveUIManager.emit("content-resize", { - tab: this.tab, - width: msg.data.width, - height: msg.data.height, - }); - }, - - /** - * Handle events - */ - handleEvent: function (event) { - switch (event.type) { - case "TabClose": - case "unload": - this.close(); - break; - case "TabSelect": - if (this.tab.selected) { - this.checkMenus(); - } else if (!this.mainWindow.gBrowser.selectedTab.responsiveUI) { - this.unCheckMenus(); - } - break; - } - }, - - getViewportBrowser() { - return this.browser; - }, - - /** - * Check the menu items. - */ - checkMenus: function () { - this.chromeDoc.getElementById("menu_responsiveUI").setAttribute("checked", "true"); - }, - - /** - * Uncheck the menu items. - */ - unCheckMenus: function () { - let el = this.chromeDoc.getElementById("menu_responsiveUI"); - if (el) { - el.setAttribute("checked", "false"); - } - }, - - /** - * Build the toolbar and the resizers. - * - * From tabbrowser.xml - * - * // presets - * // rotate - * // screenshot - * // close - * - * From tabbrowser.xml - * - * - * - * - * // Additional button in FxOS mode: - *