Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/emulation/SensorsView.js

Issue 2843763004: [DevTools] Introduce EmulationModel which will encapsulate emulation (Closed)
Patch Set: +throttling Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 /** 4 /**
5 * @unrestricted 5 * @unrestricted
6 */ 6 */
7 Emulation.SensorsView = class extends UI.VBox { 7 Emulation.SensorsView = class extends UI.VBox {
8 constructor() { 8 constructor() {
9 super(true); 9 super(true);
10 this.registerRequiredCSS('emulation/sensors.css'); 10 this.registerRequiredCSS('emulation/sensors.css');
11 this.contentElement.classList.add('sensors-view'); 11 this.contentElement.classList.add('sensors-view');
12 12
13 this._geolocationSetting = Common.settings.createSetting('emulation.geolocat ionOverride', ''); 13 this._geolocationSetting = Common.settings.createSetting('emulation.geolocat ionOverride', '');
14 this._geolocation = Emulation.Geolocation.parseSetting(this._geolocationSett ing.get()); 14 this._geolocation = SDK.EmulationModel.Geolocation.parseSetting(this._geoloc ationSetting.get());
15 this._geolocationOverrideEnabled = false; 15 this._geolocationOverrideEnabled = false;
16 this._createGeolocationSection(this._geolocation); 16 this._createGeolocationSection(this._geolocation);
17 17
18 this.contentElement.createChild('div').classList.add('panel-section-separato r'); 18 this.contentElement.createChild('div').classList.add('panel-section-separato r');
19 19
20 this._deviceOrientationSetting = Common.settings.createSetting('emulation.de viceOrientationOverride', ''); 20 this._deviceOrientationSetting = Common.settings.createSetting('emulation.de viceOrientationOverride', '');
21 this._deviceOrientation = Emulation.DeviceOrientation.parseSetting(this._dev iceOrientationSetting.get()); 21 this._deviceOrientation = SDK.EmulationModel.DeviceOrientation.parseSetting( this._deviceOrientationSetting.get());
22 this._deviceOrientationOverrideEnabled = false; 22 this._deviceOrientationOverrideEnabled = false;
23 this._createDeviceOrientationSection(); 23 this._createDeviceOrientationSection();
24 24
25 this.contentElement.createChild('div').classList.add('panel-section-separato r'); 25 this.contentElement.createChild('div').classList.add('panel-section-separato r');
26 26
27 this._appendTouchControl(); 27 this._appendTouchControl();
28 } 28 }
29 29
30 /** 30 /**
31 * @return {!Emulation.SensorsView} 31 * @return {!Emulation.SensorsView}
32 */ 32 */
33 static instance() { 33 static instance() {
34 if (!Emulation.SensorsView._instanceObject) 34 if (!Emulation.SensorsView._instanceObject)
35 Emulation.SensorsView._instanceObject = new Emulation.SensorsView(); 35 Emulation.SensorsView._instanceObject = new Emulation.SensorsView();
36 return Emulation.SensorsView._instanceObject; 36 return Emulation.SensorsView._instanceObject;
37 } 37 }
38 38
39 /** 39 /**
40 * @param {!Emulation.Geolocation} geolocation 40 * @param {!SDK.EmulationModel.Geolocation} geolocation
41 */ 41 */
42 _createGeolocationSection(geolocation) { 42 _createGeolocationSection(geolocation) {
43 var geogroup = this.contentElement.createChild('section', 'sensors-group'); 43 var geogroup = this.contentElement.createChild('section', 'sensors-group');
44 geogroup.createChild('div', 'sensors-group-title').textContent = Common.UISt ring('Geolocation'); 44 geogroup.createChild('div', 'sensors-group-title').textContent = Common.UISt ring('Geolocation');
45 var fields = geogroup.createChild('div', 'geo-fields'); 45 var fields = geogroup.createChild('div', 'geo-fields');
46 46
47 const noOverrideOption = { 47 const noOverrideOption = {
48 title: Common.UIString('No override'), 48 title: Common.UIString('No override'),
49 location: Emulation.SensorsView.NonPresetOptions.NoOverride 49 location: Emulation.SensorsView.NonPresetOptions.NoOverride
50 }; 50 };
(...skipping 22 matching lines...) Expand all
73 this._fieldsetElement.disabled = !this._geolocationOverrideEnabled; 73 this._fieldsetElement.disabled = !this._geolocationOverrideEnabled;
74 this._fieldsetElement.id = 'geolocation-override-section'; 74 this._fieldsetElement.id = 'geolocation-override-section';
75 75
76 var latitudeGroup = this._fieldsetElement.createChild('div', 'latlong-group' ); 76 var latitudeGroup = this._fieldsetElement.createChild('div', 'latlong-group' );
77 var longitudeGroup = this._fieldsetElement.createChild('div', 'latlong-group '); 77 var longitudeGroup = this._fieldsetElement.createChild('div', 'latlong-group ');
78 78
79 this._latitudeInput = latitudeGroup.createChild('input'); 79 this._latitudeInput = latitudeGroup.createChild('input');
80 this._latitudeInput.setAttribute('type', 'number'); 80 this._latitudeInput.setAttribute('type', 'number');
81 this._latitudeInput.value = 0; 81 this._latitudeInput.value = 0;
82 this._latitudeSetter = UI.bindInput( 82 this._latitudeSetter = UI.bindInput(
83 this._latitudeInput, this._applyGeolocationUserInput.bind(this), Emulati on.Geolocation.latitudeValidator, true); 83 this._latitudeInput, this._applyGeolocationUserInput.bind(this),
84 SDK.EmulationModel.Geolocation.latitudeValidator, true);
84 this._latitudeSetter(String(geolocation.latitude)); 85 this._latitudeSetter(String(geolocation.latitude));
85 86
86 this._longitudeInput = longitudeGroup.createChild('input'); 87 this._longitudeInput = longitudeGroup.createChild('input');
87 this._longitudeInput.setAttribute('type', 'number'); 88 this._longitudeInput.setAttribute('type', 'number');
88 this._longitudeInput.value = 0; 89 this._longitudeInput.value = 0;
89 this._longitudeSetter = UI.bindInput( 90 this._longitudeSetter = UI.bindInput(
90 this._longitudeInput, this._applyGeolocationUserInput.bind(this), Emulat ion.Geolocation.longitudeValidator, 91 this._longitudeInput, this._applyGeolocationUserInput.bind(this),
91 true); 92 SDK.EmulationModel.Geolocation.longitudeValidator, true);
92 this._longitudeSetter(String(geolocation.longitude)); 93 this._longitudeSetter(String(geolocation.longitude));
93 94
94 latitudeGroup.createChild('div', 'latlong-title').textContent = Common.UIStr ing('Latitude'); 95 latitudeGroup.createChild('div', 'latlong-title').textContent = Common.UIStr ing('Latitude');
95 longitudeGroup.createChild('div', 'latlong-title').textContent = Common.UISt ring('Longitude'); 96 longitudeGroup.createChild('div', 'latlong-title').textContent = Common.UISt ring('Longitude');
96 } 97 }
97 98
98 _geolocationSelectChanged() { 99 _geolocationSelectChanged() {
99 this._fieldsetElement.disabled = false; 100 this._fieldsetElement.disabled = false;
100 var value = this._locationSelectElement.options[this._locationSelectElement. selectedIndex].value; 101 var value = this._locationSelectElement.options[this._locationSelectElement. selectedIndex].value;
101 if (value === Emulation.SensorsView.NonPresetOptions.NoOverride) { 102 if (value === Emulation.SensorsView.NonPresetOptions.NoOverride) {
102 this._geolocationOverrideEnabled = false; 103 this._geolocationOverrideEnabled = false;
103 this._fieldsetElement.disabled = true; 104 this._fieldsetElement.disabled = true;
104 } else if (value === Emulation.SensorsView.NonPresetOptions.Custom) { 105 } else if (value === Emulation.SensorsView.NonPresetOptions.Custom) {
105 this._geolocationOverrideEnabled = true; 106 this._geolocationOverrideEnabled = true;
106 } else if (value === Emulation.SensorsView.NonPresetOptions.Unavailable) { 107 } else if (value === Emulation.SensorsView.NonPresetOptions.Unavailable) {
107 this._geolocationOverrideEnabled = true; 108 this._geolocationOverrideEnabled = true;
108 this._geolocation = new Emulation.Geolocation(0, 0, true); 109 this._geolocation = new SDK.EmulationModel.Geolocation(0, 0, true);
109 } else { 110 } else {
110 this._geolocationOverrideEnabled = true; 111 this._geolocationOverrideEnabled = true;
111 var coordinates = JSON.parse(value); 112 var coordinates = JSON.parse(value);
112 this._geolocation = new Emulation.Geolocation(coordinates[0], coordinates[ 1], false); 113 this._geolocation = new SDK.EmulationModel.Geolocation(coordinates[0], coo rdinates[1], false);
113 this._latitudeSetter(coordinates[0]); 114 this._latitudeSetter(coordinates[0]);
114 this._longitudeSetter(coordinates[1]); 115 this._longitudeSetter(coordinates[1]);
115 } 116 }
116 117
117 this._applyGeolocation(); 118 this._applyGeolocation();
118 if (value === Emulation.SensorsView.NonPresetOptions.Custom) 119 if (value === Emulation.SensorsView.NonPresetOptions.Custom)
119 this._latitudeInput.focus(); 120 this._latitudeInput.focus();
120 } 121 }
121 122
122 _applyGeolocationUserInput() { 123 _applyGeolocationUserInput() {
123 var geolocation = 124 var geolocation = SDK.EmulationModel.Geolocation.parseUserInput(
124 Emulation.Geolocation.parseUserInput(this._latitudeInput.value.trim(), t his._longitudeInput.value.trim(), ''); 125 this._latitudeInput.value.trim(), this._longitudeInput.value.trim(), '') ;
125 if (!geolocation) 126 if (!geolocation)
126 return; 127 return;
127 128
128 this._setSelectElementLabel(this._locationSelectElement, Emulation.SensorsVi ew.NonPresetOptions.Custom); 129 this._setSelectElementLabel(this._locationSelectElement, Emulation.SensorsVi ew.NonPresetOptions.Custom);
129 this._geolocation = geolocation; 130 this._geolocation = geolocation;
130 this._applyGeolocation(); 131 this._applyGeolocation();
131 } 132 }
132 133
133 _applyGeolocation() { 134 _applyGeolocation() {
134 if (this._geolocationOverrideEnabled) { 135 if (this._geolocationOverrideEnabled)
135 this._geolocationSetting.set(this._geolocation.toSetting()); 136 this._geolocationSetting.set(this._geolocation.toSetting());
136 this._geolocation.apply(); 137 for (var emulationModel of SDK.targetManager.models(SDK.EmulationModel))
137 } else { 138 emulationModel.emulateGeolocation(this._geolocationOverrideEnabled ? this. _geolocation : null);
138 this._geolocation.clear();
139 }
140 } 139 }
141 140
142 _createDeviceOrientationSection() { 141 _createDeviceOrientationSection() {
143 var orientationGroup = this.contentElement.createChild('section', 'sensors-g roup'); 142 var orientationGroup = this.contentElement.createChild('section', 'sensors-g roup');
144 orientationGroup.createChild('div', 'sensors-group-title').textContent = Com mon.UIString('Orientation'); 143 orientationGroup.createChild('div', 'sensors-group-title').textContent = Com mon.UIString('Orientation');
145 var orientationContent = orientationGroup.createChild('div', 'orientation-co ntent'); 144 var orientationContent = orientationGroup.createChild('div', 'orientation-co ntent');
146 var fields = orientationContent.createChild('div', 'orientation-fields'); 145 var fields = orientationContent.createChild('div', 'orientation-fields');
147 146
148 const orientationOffOption = { 147 const orientationOffOption = {
149 title: Common.UIString('Off'), 148 title: Common.UIString('Off'),
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 212
214 if (value === Emulation.SensorsView.NonPresetOptions.NoOverride) { 213 if (value === Emulation.SensorsView.NonPresetOptions.NoOverride) {
215 this._deviceOrientationOverrideEnabled = false; 214 this._deviceOrientationOverrideEnabled = false;
216 this._enableOrientationFields(true); 215 this._enableOrientationFields(true);
217 } else if (value === Emulation.SensorsView.NonPresetOptions.Custom) { 216 } else if (value === Emulation.SensorsView.NonPresetOptions.Custom) {
218 this._deviceOrientationOverrideEnabled = true; 217 this._deviceOrientationOverrideEnabled = true;
219 this._alphaElement.focus(); 218 this._alphaElement.focus();
220 } else { 219 } else {
221 var parsedValue = JSON.parse(value); 220 var parsedValue = JSON.parse(value);
222 this._deviceOrientationOverrideEnabled = true; 221 this._deviceOrientationOverrideEnabled = true;
223 this._deviceOrientation = new Emulation.DeviceOrientation(parsedValue[0], parsedValue[1], parsedValue[2]); 222 this._deviceOrientation =
223 new SDK.EmulationModel.DeviceOrientation(parsedValue[0], parsedValue[1 ], parsedValue[2]);
224 this._setDeviceOrientation( 224 this._setDeviceOrientation(
225 this._deviceOrientation, Emulation.SensorsView.DeviceOrientationModifi cationSource.SelectPreset); 225 this._deviceOrientation, Emulation.SensorsView.DeviceOrientationModifi cationSource.SelectPreset);
226 } 226 }
227 } 227 }
228 228
229 _applyDeviceOrientation() { 229 _applyDeviceOrientation() {
230 if (this._deviceOrientationOverrideEnabled) { 230 if (this._deviceOrientationOverrideEnabled)
231 this._deviceOrientationSetting.set(this._deviceOrientation.toSetting()); 231 this._deviceOrientationSetting.set(this._deviceOrientation.toSetting());
232 this._deviceOrientation.apply(); 232 for (var emulationModel of SDK.targetManager.models(SDK.EmulationModel))
233 } else { 233 emulationModel.emulateDeviceOrientation(this._deviceOrientationOverrideEna bled ? this._deviceOrientation : null);
234 this._deviceOrientation.clear();
235 }
236 } 234 }
237 235
238 /** 236 /**
239 * @param {!Element} selectElement 237 * @param {!Element} selectElement
240 * @param {string} labelValue 238 * @param {string} labelValue
241 */ 239 */
242 _setSelectElementLabel(selectElement, labelValue) { 240 _setSelectElementLabel(selectElement, labelValue) {
243 var optionValues = Array.prototype.map.call(selectElement.options, x => x.va lue); 241 var optionValues = Array.prototype.map.call(selectElement.options, x => x.va lue);
244 selectElement.selectedIndex = optionValues.indexOf(labelValue); 242 selectElement.selectedIndex = optionValues.indexOf(labelValue);
245 } 243 }
246 244
247 _applyDeviceOrientationUserInput() { 245 _applyDeviceOrientationUserInput() {
248 this._setDeviceOrientation( 246 this._setDeviceOrientation(
249 Emulation.DeviceOrientation.parseUserInput( 247 SDK.EmulationModel.DeviceOrientation.parseUserInput(
250 this._alphaElement.value.trim(), this._betaElement.value.trim(), thi s._gammaElement.value.trim()), 248 this._alphaElement.value.trim(), this._betaElement.value.trim(), thi s._gammaElement.value.trim()),
251 Emulation.SensorsView.DeviceOrientationModificationSource.UserInput); 249 Emulation.SensorsView.DeviceOrientationModificationSource.UserInput);
252 this._setSelectElementLabel(this._orientationSelectElement, Emulation.Sensor sView.NonPresetOptions.Custom); 250 this._setSelectElementLabel(this._orientationSelectElement, Emulation.Sensor sView.NonPresetOptions.Custom);
253 } 251 }
254 252
255 _resetDeviceOrientation() { 253 _resetDeviceOrientation() {
256 this._setDeviceOrientation( 254 this._setDeviceOrientation(
257 new Emulation.DeviceOrientation(0, 90, 0), 255 new SDK.EmulationModel.DeviceOrientation(0, 90, 0),
258 Emulation.SensorsView.DeviceOrientationModificationSource.ResetButton); 256 Emulation.SensorsView.DeviceOrientationModificationSource.ResetButton);
259 this._setSelectElementLabel(this._orientationSelectElement, '[0, 90, 0]'); 257 this._setSelectElementLabel(this._orientationSelectElement, '[0, 90, 0]');
260 } 258 }
261 259
262 /** 260 /**
263 * @param {?Emulation.DeviceOrientation} deviceOrientation 261 * @param {?SDK.EmulationModel.DeviceOrientation} deviceOrientation
264 * @param {!Emulation.SensorsView.DeviceOrientationModificationSource} modific ationSource 262 * @param {!Emulation.SensorsView.DeviceOrientationModificationSource} modific ationSource
265 */ 263 */
266 _setDeviceOrientation(deviceOrientation, modificationSource) { 264 _setDeviceOrientation(deviceOrientation, modificationSource) {
267 if (!deviceOrientation) 265 if (!deviceOrientation)
268 return; 266 return;
269 267
270 /** 268 /**
271 * @param {number} angle 269 * @param {number} angle
272 * @return {number} 270 * @return {number}
273 */ 271 */
(...skipping 19 matching lines...) Expand all
293 * @param {!Element} input 291 * @param {!Element} input
294 * @param {string} label 292 * @param {string} label
295 * @return {function(string)} 293 * @return {function(string)}
296 */ 294 */
297 _createAxisInput(parentElement, input, label) { 295 _createAxisInput(parentElement, input, label) {
298 var div = parentElement.createChild('div', 'orientation-axis-input-container '); 296 var div = parentElement.createChild('div', 'orientation-axis-input-container ');
299 div.appendChild(input); 297 div.appendChild(input);
300 div.createTextChild(label); 298 div.createTextChild(label);
301 input.type = 'number'; 299 input.type = 'number';
302 return UI.bindInput( 300 return UI.bindInput(
303 input, this._applyDeviceOrientationUserInput.bind(this), Emulation.Devic eOrientation.validator, true); 301 input, this._applyDeviceOrientationUserInput.bind(this), SDK.EmulationMo del.DeviceOrientation.validator, true);
304 } 302 }
305 303
306 /** 304 /**
307 * @param {!Emulation.DeviceOrientation} deviceOrientation 305 * @param {!SDK.EmulationModel.DeviceOrientation} deviceOrientation
308 * @return {!Element} 306 * @return {!Element}
309 */ 307 */
310 _createDeviceOrientationOverrideElement(deviceOrientation) { 308 _createDeviceOrientationOverrideElement(deviceOrientation) {
311 var fieldsetElement = createElement('fieldset'); 309 var fieldsetElement = createElement('fieldset');
312 fieldsetElement.classList.add('device-orientation-override-section'); 310 fieldsetElement.classList.add('device-orientation-override-section');
313 var cellElement = fieldsetElement.createChild('td', 'orientation-inputs-cell '); 311 var cellElement = fieldsetElement.createChild('td', 'orientation-inputs-cell ');
314 312
315 this._alphaElement = createElement('input'); 313 this._alphaElement = createElement('input');
316 this._alphaSetter = this._createAxisInput(cellElement, this._alphaElement, C ommon.UIString('\u03B1 (alpha)')); 314 this._alphaSetter = this._createAxisInput(cellElement, this._alphaElement, C ommon.UIString('\u03B1 (alpha)'));
317 this._alphaSetter(String(deviceOrientation.alpha)); 315 this._alphaSetter(String(deviceOrientation.alpha));
318 316
319 this._betaElement = createElement('input'); 317 this._betaElement = createElement('input');
320 this._betaSetter = this._createAxisInput(cellElement, this._betaElement, Com mon.UIString('\u03B2 (beta)')); 318 this._betaSetter = this._createAxisInput(cellElement, this._betaElement, Com mon.UIString('\u03B2 (beta)'));
321 this._betaSetter(String(deviceOrientation.beta)); 319 this._betaSetter(String(deviceOrientation.beta));
322 320
323 this._gammaElement = createElement('input'); 321 this._gammaElement = createElement('input');
324 this._gammaSetter = this._createAxisInput(cellElement, this._gammaElement, C ommon.UIString('\u03B3 (gamma)')); 322 this._gammaSetter = this._createAxisInput(cellElement, this._gammaElement, C ommon.UIString('\u03B3 (gamma)'));
325 this._gammaSetter(String(deviceOrientation.gamma)); 323 this._gammaSetter(String(deviceOrientation.gamma));
326 324
327 cellElement.appendChild(UI.createTextButton( 325 cellElement.appendChild(UI.createTextButton(
328 Common.UIString('Reset'), this._resetDeviceOrientation.bind(this), 'orie ntation-reset-button')); 326 Common.UIString('Reset'), this._resetDeviceOrientation.bind(this), 'orie ntation-reset-button'));
329 return fieldsetElement; 327 return fieldsetElement;
330 } 328 }
331 329
332 /** 330 /**
333 * @param {!Emulation.DeviceOrientation} deviceOrientation 331 * @param {!SDK.EmulationModel.DeviceOrientation} deviceOrientation
334 * @param {boolean} animate 332 * @param {boolean} animate
335 */ 333 */
336 _setBoxOrientation(deviceOrientation, animate) { 334 _setBoxOrientation(deviceOrientation, animate) {
337 if (animate) 335 if (animate)
338 this._stageElement.classList.add('is-animating'); 336 this._stageElement.classList.add('is-animating');
339 else 337 else
340 this._stageElement.classList.remove('is-animating'); 338 this._stageElement.classList.remove('is-animating');
341 339
342 // The CSS transform should not depend on matrix3d, which does not interpola te well. 340 // The CSS transform should not depend on matrix3d, which does not interpola te well.
343 var matrix = new WebKitCSSMatrix(); 341 var matrix = new WebKitCSSMatrix();
(...skipping 24 matching lines...) Expand all
368 366
369 // The mouse movement vectors occur in the screen space, which is offset by 90 degrees from 367 // The mouse movement vectors occur in the screen space, which is offset by 90 degrees from
370 // the actual device orientation. 368 // the actual device orientation.
371 var currentMatrix = new WebKitCSSMatrix(); 369 var currentMatrix = new WebKitCSSMatrix();
372 currentMatrix = currentMatrix.rotate(-90, 0, 0) 370 currentMatrix = currentMatrix.rotate(-90, 0, 0)
373 .rotateAxisAngle(axis.x, axis.y, axis.z, angle) 371 .rotateAxisAngle(axis.x, axis.y, axis.z, angle)
374 .rotate(90, 0, 0) 372 .rotate(90, 0, 0)
375 .multiply(this._originalBoxMatrix); 373 .multiply(this._originalBoxMatrix);
376 374
377 var eulerAngles = UI.Geometry.EulerAngles.fromRotationMatrix(currentMatrix); 375 var eulerAngles = UI.Geometry.EulerAngles.fromRotationMatrix(currentMatrix);
378 var newOrientation = new Emulation.DeviceOrientation(-eulerAngles.alpha, -eu lerAngles.beta, eulerAngles.gamma); 376 var newOrientation =
377 new SDK.EmulationModel.DeviceOrientation(-eulerAngles.alpha, -eulerAngle s.beta, eulerAngles.gamma);
379 this._setDeviceOrientation(newOrientation, Emulation.SensorsView.DeviceOrien tationModificationSource.UserDrag); 378 this._setDeviceOrientation(newOrientation, Emulation.SensorsView.DeviceOrien tationModificationSource.UserDrag);
380 this._setSelectElementLabel(this._orientationSelectElement, Emulation.Sensor sView.NonPresetOptions.Custom); 379 this._setSelectElementLabel(this._orientationSelectElement, Emulation.Sensor sView.NonPresetOptions.Custom);
381 return false; 380 return false;
382 } 381 }
383 382
384 /** 383 /**
385 * @param {!MouseEvent} event 384 * @param {!MouseEvent} event
386 * @return {boolean} 385 * @return {boolean}
387 */ 386 */
388 _onBoxDragStart(event) { 387 _onBoxDragStart(event) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 var title = groupElement.createChild('div', 'sensors-group-title'); 420 var title = groupElement.createChild('div', 'sensors-group-title');
422 var fieldsElement = groupElement.createChild('div', 'sensors-group-fields'); 421 var fieldsElement = groupElement.createChild('div', 'sensors-group-fields');
423 422
424 title.textContent = Common.UIString('Touch'); 423 title.textContent = Common.UIString('Touch');
425 var select = fieldsElement.createChild('select', 'chrome-select'); 424 var select = fieldsElement.createChild('select', 'chrome-select');
426 select.appendChild(new Option(Common.UIString('Device-based'), 'auto')); 425 select.appendChild(new Option(Common.UIString('Device-based'), 'auto'));
427 select.appendChild(new Option(Common.UIString('Force enabled'), 'enabled')); 426 select.appendChild(new Option(Common.UIString('Force enabled'), 'enabled'));
428 select.addEventListener('change', applyTouch, false); 427 select.addEventListener('change', applyTouch, false);
429 428
430 function applyTouch() { 429 function applyTouch() {
431 Emulation.MultitargetTouchModel.instance().setCustomTouchEnabled(select.va lue === 'enabled'); 430 for (var emulationModel of SDK.targetManager.models(SDK.EmulationModel))
431 emulationModel.overrideEmulateTouch(select.value === 'enabled');
432 } 432 }
433 } 433 }
434 }; 434 };
435 435
436 /** @enum {string} */ 436 /** @enum {string} */
437 Emulation.SensorsView.DeviceOrientationModificationSource = { 437 Emulation.SensorsView.DeviceOrientationModificationSource = {
438 UserInput: 'userInput', 438 UserInput: 'userInput',
439 UserDrag: 'userDrag', 439 UserDrag: 'userDrag',
440 ResetButton: 'resetButton', 440 ResetButton: 'resetButton',
441 SelectPreset: 'selectPreset' 441 SelectPreset: 'selectPreset'
(...skipping 23 matching lines...) Expand all
465 ] 465 ]
466 }, 466 },
467 { 467 {
468 title: 'Error', 468 title: 'Error',
469 value: [ 469 value: [
470 {title: Common.UIString('Location unavailable'), location: Emulation.Senso rsView.NonPresetOptions.Unavailable} 470 {title: Common.UIString('Location unavailable'), location: Emulation.Senso rsView.NonPresetOptions.Unavailable}
471 ] 471 ]
472 } 472 }
473 ]; 473 ];
474 474
475 /** @type {!Array.<{title: string, value: !Array.<{title: string, orientation: ! Emulation.DeviceOrientation}>}>} */ 475 /** @type {!Array.<{title: string, value: !Array.<{title: string, orientation: s tring}>}>} */
476 Emulation.SensorsView.PresetOrientations = [{ 476 Emulation.SensorsView.PresetOrientations = [{
477 title: 'Presets', 477 title: 'Presets',
478 value: [ 478 value: [
479 {title: Common.UIString('Portrait'), orientation: '[0, 90, 0]'}, 479 {title: Common.UIString('Portrait'), orientation: '[0, 90, 0]'},
480 {title: Common.UIString('Portrait upside down'), orientation: '[180, -90, 0] '}, 480 {title: Common.UIString('Portrait upside down'), orientation: '[180, -90, 0] '},
481 {title: Common.UIString('Landscape left'), orientation: '[0, 90, -90]'}, 481 {title: Common.UIString('Landscape left'), orientation: '[0, 90, -90]'},
482 {title: Common.UIString('Landscape right'), orientation: '[0, 90, 90]'}, 482 {title: Common.UIString('Landscape right'), orientation: '[0, 90, 90]'},
483 {title: Common.UIString('Display up'), orientation: '[0, 0, 0]'}, 483 {title: Common.UIString('Display up'), orientation: '[0, 0, 0]'},
484 {title: Common.UIString('Display down'), orientation: '[0, 180, 0]'} 484 {title: Common.UIString('Display down'), orientation: '[0, 180, 0]'}
485 ] 485 ]
(...skipping 11 matching lines...) Expand all
497 * @param {string} actionId 497 * @param {string} actionId
498 * @return {boolean} 498 * @return {boolean}
499 */ 499 */
500 handleAction(context, actionId) { 500 handleAction(context, actionId) {
501 UI.viewManager.showView('sensors'); 501 UI.viewManager.showView('sensors');
502 return true; 502 return true;
503 } 503 }
504 }; 504 };
505 505
506 Emulation.SensorsView.ShiftDragOrientationSpeed = 16; 506 Emulation.SensorsView.ShiftDragOrientationSpeed = 16;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698