Wed, 31 Dec 2014 06:09:35 +0100
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 gcli = require("gcli/index"); |
michael@0 | 8 | |
michael@0 | 9 | // Fetch TiltManager using the current loader, but don't save a |
michael@0 | 10 | // reference to it, because it might change with a tool reload. |
michael@0 | 11 | // We can clean this up once the command line is loadered. |
michael@0 | 12 | Object.defineProperty(this, "TiltManager", { |
michael@0 | 13 | get: function() { |
michael@0 | 14 | return require("devtools/tilt/tilt").TiltManager; |
michael@0 | 15 | }, |
michael@0 | 16 | enumerable: true |
michael@0 | 17 | }); |
michael@0 | 18 | |
michael@0 | 19 | exports.items = [ |
michael@0 | 20 | { |
michael@0 | 21 | name: 'tilt', |
michael@0 | 22 | description: gcli.lookup("tiltDesc"), |
michael@0 | 23 | manual: gcli.lookup("tiltManual") |
michael@0 | 24 | }, |
michael@0 | 25 | { |
michael@0 | 26 | name: 'tilt open', |
michael@0 | 27 | description: gcli.lookup("tiltOpenDesc"), |
michael@0 | 28 | manual: gcli.lookup("tiltOpenManual"), |
michael@0 | 29 | exec: function(args, context) { |
michael@0 | 30 | let chromeWindow = context.environment.chromeDocument.defaultView; |
michael@0 | 31 | let Tilt = TiltManager.getTiltForBrowser(chromeWindow); |
michael@0 | 32 | if (!Tilt.currentInstance) { |
michael@0 | 33 | Tilt.toggle(); |
michael@0 | 34 | } |
michael@0 | 35 | } |
michael@0 | 36 | }, |
michael@0 | 37 | { |
michael@0 | 38 | name: "tilt toggle", |
michael@0 | 39 | buttonId: "command-button-tilt", |
michael@0 | 40 | buttonClass: "command-button command-button-invertable", |
michael@0 | 41 | tooltipText: gcli.lookup("tiltToggleTooltip"), |
michael@0 | 42 | hidden: true, |
michael@0 | 43 | state: { |
michael@0 | 44 | isChecked: function(aTarget) { |
michael@0 | 45 | let browserWindow = aTarget.tab.ownerDocument.defaultView; |
michael@0 | 46 | return !!TiltManager.getTiltForBrowser(browserWindow).currentInstance; |
michael@0 | 47 | }, |
michael@0 | 48 | onChange: function(aTarget, aChangeHandler) { |
michael@0 | 49 | let browserWindow = aTarget.tab.ownerDocument.defaultView; |
michael@0 | 50 | let tilt = TiltManager.getTiltForBrowser(browserWindow); |
michael@0 | 51 | tilt.on("change", aChangeHandler); |
michael@0 | 52 | }, |
michael@0 | 53 | offChange: function(aTarget, aChangeHandler) { |
michael@0 | 54 | if (aTarget.tab) { |
michael@0 | 55 | let browserWindow = aTarget.tab.ownerDocument.defaultView; |
michael@0 | 56 | let tilt = TiltManager.getTiltForBrowser(browserWindow); |
michael@0 | 57 | tilt.off("change", aChangeHandler); |
michael@0 | 58 | } |
michael@0 | 59 | }, |
michael@0 | 60 | }, |
michael@0 | 61 | exec: function(args, context) { |
michael@0 | 62 | let chromeWindow = context.environment.chromeDocument.defaultView; |
michael@0 | 63 | let Tilt = TiltManager.getTiltForBrowser(chromeWindow); |
michael@0 | 64 | Tilt.toggle(); |
michael@0 | 65 | } |
michael@0 | 66 | }, |
michael@0 | 67 | { |
michael@0 | 68 | name: 'tilt translate', |
michael@0 | 69 | description: gcli.lookup("tiltTranslateDesc"), |
michael@0 | 70 | manual: gcli.lookup("tiltTranslateManual"), |
michael@0 | 71 | params: [ |
michael@0 | 72 | { |
michael@0 | 73 | name: "x", |
michael@0 | 74 | type: "number", |
michael@0 | 75 | defaultValue: 0, |
michael@0 | 76 | description: gcli.lookup("tiltTranslateXDesc"), |
michael@0 | 77 | manual: gcli.lookup("tiltTranslateXManual") |
michael@0 | 78 | }, |
michael@0 | 79 | { |
michael@0 | 80 | name: "y", |
michael@0 | 81 | type: "number", |
michael@0 | 82 | defaultValue: 0, |
michael@0 | 83 | description: gcli.lookup("tiltTranslateYDesc"), |
michael@0 | 84 | manual: gcli.lookup("tiltTranslateYManual") |
michael@0 | 85 | } |
michael@0 | 86 | ], |
michael@0 | 87 | exec: function(args, context) { |
michael@0 | 88 | let chromeWindow = context.environment.chromeDocument.defaultView; |
michael@0 | 89 | let Tilt = TiltManager.getTiltForBrowser(chromeWindow); |
michael@0 | 90 | if (Tilt.currentInstance) { |
michael@0 | 91 | Tilt.currentInstance.controller.arcball.translate([args.x, args.y]); |
michael@0 | 92 | } |
michael@0 | 93 | } |
michael@0 | 94 | }, |
michael@0 | 95 | { |
michael@0 | 96 | name: 'tilt rotate', |
michael@0 | 97 | description: gcli.lookup("tiltRotateDesc"), |
michael@0 | 98 | manual: gcli.lookup("tiltRotateManual"), |
michael@0 | 99 | params: [ |
michael@0 | 100 | { |
michael@0 | 101 | name: "x", |
michael@0 | 102 | type: { name: 'number', min: -360, max: 360, step: 10 }, |
michael@0 | 103 | defaultValue: 0, |
michael@0 | 104 | description: gcli.lookup("tiltRotateXDesc"), |
michael@0 | 105 | manual: gcli.lookup("tiltRotateXManual") |
michael@0 | 106 | }, |
michael@0 | 107 | { |
michael@0 | 108 | name: "y", |
michael@0 | 109 | type: { name: 'number', min: -360, max: 360, step: 10 }, |
michael@0 | 110 | defaultValue: 0, |
michael@0 | 111 | description: gcli.lookup("tiltRotateYDesc"), |
michael@0 | 112 | manual: gcli.lookup("tiltRotateYManual") |
michael@0 | 113 | }, |
michael@0 | 114 | { |
michael@0 | 115 | name: "z", |
michael@0 | 116 | type: { name: 'number', min: -360, max: 360, step: 10 }, |
michael@0 | 117 | defaultValue: 0, |
michael@0 | 118 | description: gcli.lookup("tiltRotateZDesc"), |
michael@0 | 119 | manual: gcli.lookup("tiltRotateZManual") |
michael@0 | 120 | } |
michael@0 | 121 | ], |
michael@0 | 122 | exec: function(args, context) { |
michael@0 | 123 | let chromeWindow = context.environment.chromeDocument.defaultView; |
michael@0 | 124 | let Tilt = TiltManager.getTiltForBrowser(chromeWindow); |
michael@0 | 125 | if (Tilt.currentInstance) { |
michael@0 | 126 | Tilt.currentInstance.controller.arcball.rotate([args.x, args.y, args.z]); |
michael@0 | 127 | } |
michael@0 | 128 | } |
michael@0 | 129 | }, |
michael@0 | 130 | { |
michael@0 | 131 | name: 'tilt zoom', |
michael@0 | 132 | description: gcli.lookup("tiltZoomDesc"), |
michael@0 | 133 | manual: gcli.lookup("tiltZoomManual"), |
michael@0 | 134 | params: [ |
michael@0 | 135 | { |
michael@0 | 136 | name: "zoom", |
michael@0 | 137 | type: { name: 'number' }, |
michael@0 | 138 | description: gcli.lookup("tiltZoomAmountDesc"), |
michael@0 | 139 | manual: gcli.lookup("tiltZoomAmountManual") |
michael@0 | 140 | } |
michael@0 | 141 | ], |
michael@0 | 142 | exec: function(args, context) { |
michael@0 | 143 | let chromeWindow = context.environment.chromeDocument.defaultView; |
michael@0 | 144 | let Tilt = TiltManager.getTiltForBrowser(chromeWindow); |
michael@0 | 145 | |
michael@0 | 146 | if (Tilt.currentInstance) { |
michael@0 | 147 | Tilt.currentInstance.controller.arcball.zoom(-args.zoom); |
michael@0 | 148 | } |
michael@0 | 149 | } |
michael@0 | 150 | }, |
michael@0 | 151 | { |
michael@0 | 152 | name: 'tilt reset', |
michael@0 | 153 | description: gcli.lookup("tiltResetDesc"), |
michael@0 | 154 | manual: gcli.lookup("tiltResetManual"), |
michael@0 | 155 | exec: function(args, context) { |
michael@0 | 156 | let chromeWindow = context.environment.chromeDocument.defaultView; |
michael@0 | 157 | let Tilt = TiltManager.getTiltForBrowser(chromeWindow); |
michael@0 | 158 | |
michael@0 | 159 | if (Tilt.currentInstance) { |
michael@0 | 160 | Tilt.currentInstance.controller.arcball.reset(); |
michael@0 | 161 | } |
michael@0 | 162 | } |
michael@0 | 163 | }, |
michael@0 | 164 | { |
michael@0 | 165 | name: 'tilt close', |
michael@0 | 166 | description: gcli.lookup("tiltCloseDesc"), |
michael@0 | 167 | manual: gcli.lookup("tiltCloseManual"), |
michael@0 | 168 | exec: function(args, context) { |
michael@0 | 169 | let chromeWindow = context.environment.chromeDocument.defaultView; |
michael@0 | 170 | let Tilt = TiltManager.getTiltForBrowser(chromeWindow); |
michael@0 | 171 | |
michael@0 | 172 | Tilt.destroy(Tilt.currentWindowId); |
michael@0 | 173 | } |
michael@0 | 174 | } |
michael@0 | 175 | ]; |