1 /* vim: set ts=2 sw=2 sts=2 et tw=80: */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 export class ControllersChild extends JSWindowActorChild {
7 receiveMessage(message) {
8 switch (message.name) {
9 case "ControllerCommands:Do":
10 if (this.docShell && this.docShell.isCommandEnabled(message.data)) {
11 this.docShell.doCommand(message.data);
15 case "ControllerCommands:DoWithParams":
16 var data = message.data;
17 if (this.docShell && this.docShell.isCommandEnabled(data.cmd)) {
18 var params = Cu.createCommandParams();
19 let substituteXY = false;
23 data.cmd == "cmd_lookUpDictionary" &&
26 data.params.x.type == "long" &&
27 data.params.y.type == "long"
30 x = parseInt(data.params.x.value);
31 y = parseInt(data.params.y.value);
34 this.contentWindow.windowUtils.convertFromParentProcessWidgetToLocal(
40 x = Math.round(rect.x);
41 y = Math.round(rect.y);
44 for (var name in data.params) {
45 var value = data.params[name];
46 if (value.type == "long") {
47 if (substituteXY && name === "x") {
48 params.setLongValue(name, x);
49 } else if (substituteXY && name === "y") {
50 params.setLongValue(name, y);
52 params.setLongValue(name, parseInt(value.value));
55 throw Components.Exception("", Cr.NS_ERROR_NOT_IMPLEMENTED);
58 this.docShell.doCommandWithParams(data.cmd, params);