From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- .../client/styleeditor/styleeditor-commands.js | 72 ++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 devtools/client/styleeditor/styleeditor-commands.js (limited to 'devtools/client/styleeditor/styleeditor-commands.js') diff --git a/devtools/client/styleeditor/styleeditor-commands.js b/devtools/client/styleeditor/styleeditor-commands.js new file mode 100644 index 000000000..ded63e499 --- /dev/null +++ b/devtools/client/styleeditor/styleeditor-commands.js @@ -0,0 +1,72 @@ +/* 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/. */ + +/* globals gDevTools */ + +"use strict"; + +const l10n = require("gcli/l10n"); +loader.lazyRequireGetter(this, "gDevTools", + "devtools/client/framework/devtools", true); + +/** + * The `edit` command opens the toolbox to the style editor, with a given + * stylesheet open. + * + * This command is tricky. The 'edit' command uses the toolbox, so it's + * clearly runAt:client, but it uses the 'resource' type which accesses the + * DOM, so it must also be runAt:server. + * + * Our solution is to have the command technically be runAt:server, but to not + * actually do anything other than basically `return args;`, and have the + * converter (all converters are runAt:client) do the actual work of opening + * a toolbox. + * + * For alternative solutions that we considered, see the comment on commit + * 2645af7. + */ +exports.items = [{ + item: "command", + runAt: "server", + name: "edit", + description: l10n.lookup("editDesc"), + manual: l10n.lookup("editManual2"), + params: [ + { + name: "resource", + type: { + name: "resource", + include: "text/css" + }, + description: l10n.lookup("editResourceDesc") + }, + { + name: "line", + defaultValue: 1, + type: { + name: "number", + min: 1, + step: 10 + }, + description: l10n.lookup("editLineToJumpToDesc") + } + ], + returnType: "editArgs", + exec: args => { + return { href: args.resource.name, line: args.line }; + } +}, { + item: "converter", + from: "editArgs", + to: "dom", + exec: function (args, context) { + let target = context.environment.target; + let toolboxOpened = gDevTools.showToolbox(target, "styleeditor"); + return toolboxOpened.then(function (toolbox) { + let styleEditor = toolbox.getCurrentPanel(); + styleEditor.selectStyleSheet(args.href, args.line); + return null; + }); + } +}]; -- cgit v1.2.3