mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1239437 - Delegate to empty, new responsive UI tool if enabled. r=pbrosset
This commit is contained in:
parent
85b15a21a0
commit
555e6c8195
@ -23,6 +23,7 @@ DIRS += [
|
||||
'preferences',
|
||||
'projecteditor',
|
||||
'promisedebugger',
|
||||
'responsive.html',
|
||||
'responsivedesign',
|
||||
'scratchpad',
|
||||
'shadereditor',
|
||||
|
@ -327,3 +327,7 @@ pref("devtools.telemetry.tools.opened.version", "{}");
|
||||
#else
|
||||
pref("devtools.jsonview.enabled", false);
|
||||
#endif
|
||||
|
||||
// Disable the HTML responsive design tool by default. Currently disabled until
|
||||
// ready to replace the legacy XUL version.
|
||||
pref("devtools.responsive.html.enabled", false);
|
||||
|
115
devtools/client/responsive.html/manager.js
Normal file
115
devtools/client/responsive.html/manager.js
Normal file
@ -0,0 +1,115 @@
|
||||
/* 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 promise = require("promise");
|
||||
const EventEmitter = require("devtools/shared/event-emitter");
|
||||
|
||||
/**
|
||||
* ResponsiveUIManager is the external API for the browser UI, etc. to use when
|
||||
* opening and closing the responsive UI.
|
||||
*
|
||||
* While the HTML UI is in an experimental stage, the older ResponsiveUIManager
|
||||
* from devtools/client/responsivedesign/responsivedesign.jsm delegates to this
|
||||
* object when the pref "devtools.responsive.html.enabled" is true.
|
||||
*/
|
||||
exports.ResponsiveUIManager = {
|
||||
activeTabs: new Map(),
|
||||
|
||||
/**
|
||||
* Toggle the responsive UI for a tab.
|
||||
*
|
||||
* @param window
|
||||
* The main browser chrome window.
|
||||
* @param tab
|
||||
* The browser tab.
|
||||
* @return Promise
|
||||
* Resolved when the toggling has completed.
|
||||
*/
|
||||
toggle(window, tab) {
|
||||
if (this.isActiveForTab(tab)) {
|
||||
this.activeTabs.get(tab).close();
|
||||
} else {
|
||||
this.runIfNeeded(window, tab);
|
||||
}
|
||||
// TODO: Becomes a more interesting value in a later patch
|
||||
return promise.resolve();
|
||||
},
|
||||
|
||||
/**
|
||||
* Launches the responsive UI.
|
||||
*
|
||||
* @param window
|
||||
* The main browser chrome window.
|
||||
* @param tab
|
||||
* The browser tab.
|
||||
*/
|
||||
runIfNeeded(window, tab) {
|
||||
if (!this.isActiveForTab(tab)) {
|
||||
// TODO: Unimplemented
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns true if responsive UI is active for a given tab.
|
||||
*
|
||||
* @param tab
|
||||
* The browser tab.
|
||||
* @return boolean
|
||||
*/
|
||||
isActiveForTab(tab) {
|
||||
return this.activeTabs.has(tab);
|
||||
},
|
||||
|
||||
/**
|
||||
* Return the responsive UI controller for a tab.
|
||||
*
|
||||
* @param tab
|
||||
* The browser tab.
|
||||
* @return TODO: Some object!
|
||||
*/
|
||||
getResponsiveUIForTab(tab) {
|
||||
return this.activeTabs.get(tab);
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle GCLI commands.
|
||||
*
|
||||
* @param window
|
||||
* The main browser chrome window.
|
||||
* @param tab
|
||||
* The browser tab.
|
||||
* @param command
|
||||
* The GCLI command name.
|
||||
* @param args
|
||||
* The GCLI command arguments.
|
||||
*/
|
||||
handleGcliCommand: function(window, tab, command, args) {
|
||||
switch (command) {
|
||||
case "resize to":
|
||||
this.runIfNeeded(window, tab);
|
||||
// TODO: Probably the wrong API
|
||||
this.activeTabs.get(tab).setSize(args.width, args.height);
|
||||
break;
|
||||
case "resize on":
|
||||
this.runIfNeeded(window, tab);
|
||||
break;
|
||||
case "resize off":
|
||||
if (this.isActiveForTab(tab)) {
|
||||
// TODO: Probably the wrong API
|
||||
this.activeTabs.get(tab).close();
|
||||
}
|
||||
break;
|
||||
case "resize toggle":
|
||||
this.toggle(window, tab);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// GCLI commands in ../responsivedesign/resize-commands.js listen for events
|
||||
// from this object to know when the UI for a tab has opened or closed.
|
||||
EventEmitter.decorate(exports.ResponsiveUIManager);
|
9
devtools/client/responsive.html/moz.build
Normal file
9
devtools/client/responsive.html/moz.build
Normal file
@ -0,0 +1,9 @@
|
||||
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# 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/.
|
||||
|
||||
DevToolsModules(
|
||||
'manager.js',
|
||||
)
|
@ -39,7 +39,7 @@ const SHARED_L10N = new ViewHelpers.L10N("chrome://devtools/locale/shared.proper
|
||||
|
||||
var ActiveTabs = new Map();
|
||||
|
||||
this.ResponsiveUIManager = {
|
||||
var Manager = {
|
||||
/**
|
||||
* Check if the a tab is in a responsive mode.
|
||||
* Leave the responsive mode if active,
|
||||
@ -113,7 +113,18 @@ this.ResponsiveUIManager = {
|
||||
}
|
||||
}
|
||||
|
||||
EventEmitter.decorate(ResponsiveUIManager);
|
||||
EventEmitter.decorate(Manager);
|
||||
|
||||
// If the experimental HTML UI is enabled, delegate the ResponsiveUIManager API
|
||||
// over to that tool instead. Performing this delegation here allows us to
|
||||
// contain the pref check to a single place.
|
||||
if (Services.prefs.getBoolPref("devtools.responsive.html.enabled")) {
|
||||
let { ResponsiveUIManager } =
|
||||
require("devtools/client/responsive.html/manager");
|
||||
this.ResponsiveUIManager = ResponsiveUIManager;
|
||||
} else {
|
||||
this.ResponsiveUIManager = Manager;
|
||||
}
|
||||
|
||||
var presets = [
|
||||
// Phones
|
||||
|
Loading…
Reference in New Issue
Block a user