toolkit/devtools/gcli/commands/paintflashing.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 "use strict";
michael@0 6
michael@0 7 const { Cc, Ci, Cu } = require("chrome");
michael@0 8 const TargetFactory = require("resource://gre/modules/devtools/Loader.jsm").devtools.TargetFactory;
michael@0 9
michael@0 10 const Telemetry = require("devtools/shared/telemetry");
michael@0 11 const telemetry = new Telemetry();
michael@0 12
michael@0 13 const EventEmitter = require("devtools/toolkit/event-emitter");
michael@0 14 const eventEmitter = new EventEmitter();
michael@0 15
michael@0 16 const gcli = require("gcli/index");
michael@0 17
michael@0 18 function onPaintFlashingChanged(context) {
michael@0 19 let tab = context.environment.chromeWindow.gBrowser.selectedTab;
michael@0 20 eventEmitter.emit("changed", tab);
michael@0 21 function fireChange() {
michael@0 22 eventEmitter.emit("changed", tab);
michael@0 23 }
michael@0 24 let target = TargetFactory.forTab(tab);
michael@0 25 target.off("navigate", fireChange);
michael@0 26 target.once("navigate", fireChange);
michael@0 27
michael@0 28 let window = context.environment.window;
michael@0 29 let wUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
michael@0 30 .getInterface(Ci.nsIDOMWindowUtils);
michael@0 31 if (wUtils.paintFlashing) {
michael@0 32 telemetry.toolOpened("paintflashing");
michael@0 33 } else {
michael@0 34 telemetry.toolClosed("paintflashing");
michael@0 35 }
michael@0 36 }
michael@0 37
michael@0 38 exports.items = [
michael@0 39 {
michael@0 40 name: "paintflashing",
michael@0 41 description: gcli.lookup("paintflashingDesc")
michael@0 42 },
michael@0 43 {
michael@0 44 name: "paintflashing on",
michael@0 45 description: gcli.lookup("paintflashingOnDesc"),
michael@0 46 manual: gcli.lookup("paintflashingManual"),
michael@0 47 params: [{
michael@0 48 group: "options",
michael@0 49 params: [
michael@0 50 {
michael@0 51 type: "boolean",
michael@0 52 name: "chrome",
michael@0 53 get hidden() gcli.hiddenByChromePref(),
michael@0 54 description: gcli.lookup("paintflashingChromeDesc"),
michael@0 55 }
michael@0 56 ]
michael@0 57 }],
michael@0 58 exec: function(args, context) {
michael@0 59 let window = args.chrome ?
michael@0 60 context.environment.chromeWindow :
michael@0 61 context.environment.window;
michael@0 62
michael@0 63 window.QueryInterface(Ci.nsIInterfaceRequestor)
michael@0 64 .getInterface(Ci.nsIDOMWindowUtils)
michael@0 65 .paintFlashing = true;
michael@0 66 onPaintFlashingChanged(context);
michael@0 67 }
michael@0 68 },
michael@0 69 {
michael@0 70 name: "paintflashing off",
michael@0 71 description: gcli.lookup("paintflashingOffDesc"),
michael@0 72 manual: gcli.lookup("paintflashingManual"),
michael@0 73 params: [{
michael@0 74 group: "options",
michael@0 75 params: [
michael@0 76 {
michael@0 77 type: "boolean",
michael@0 78 name: "chrome",
michael@0 79 get hidden() gcli.hiddenByChromePref(),
michael@0 80 description: gcli.lookup("paintflashingChromeDesc"),
michael@0 81 }
michael@0 82 ]
michael@0 83 }],
michael@0 84 exec: function(args, context) {
michael@0 85 let window = args.chrome ?
michael@0 86 context.environment.chromeWindow :
michael@0 87 context.environment.window;
michael@0 88
michael@0 89 window.QueryInterface(Ci.nsIInterfaceRequestor)
michael@0 90 .getInterface(Ci.nsIDOMWindowUtils)
michael@0 91 .paintFlashing = false;
michael@0 92 onPaintFlashingChanged(context);
michael@0 93 }
michael@0 94 },
michael@0 95 {
michael@0 96 name: "paintflashing toggle",
michael@0 97 hidden: true,
michael@0 98 buttonId: "command-button-paintflashing",
michael@0 99 buttonClass: "command-button command-button-invertable",
michael@0 100 state: {
michael@0 101 isChecked: function(aTarget) {
michael@0 102 if (aTarget.isLocalTab) {
michael@0 103 let window = aTarget.tab.linkedBrowser.contentWindow;
michael@0 104 let wUtils = window.QueryInterface(Ci.nsIInterfaceRequestor).
michael@0 105 getInterface(Ci.nsIDOMWindowUtils);
michael@0 106 return wUtils.paintFlashing;
michael@0 107 } else {
michael@0 108 throw new Error("Unsupported target");
michael@0 109 }
michael@0 110 },
michael@0 111 onChange: function(aTarget, aChangeHandler) {
michael@0 112 eventEmitter.on("changed", aChangeHandler);
michael@0 113 },
michael@0 114 offChange: function(aTarget, aChangeHandler) {
michael@0 115 eventEmitter.off("changed", aChangeHandler);
michael@0 116 },
michael@0 117 },
michael@0 118 tooltipText: gcli.lookup("paintflashingTooltip"),
michael@0 119 description: gcli.lookup("paintflashingToggleDesc"),
michael@0 120 manual: gcli.lookup("paintflashingManual"),
michael@0 121 exec: function(args, context) {
michael@0 122 let window = context.environment.window;
michael@0 123 let wUtils = window.QueryInterface(Ci.nsIInterfaceRequestor).
michael@0 124 getInterface(Ci.nsIDOMWindowUtils);
michael@0 125 wUtils.paintFlashing = !wUtils.paintFlashing;
michael@0 126 onPaintFlashingChanged(context);
michael@0 127 }
michael@0 128 }
michael@0 129 ];

mercurial