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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/EmulationModel.js

Issue 2839413002: DevTools: add rendering overlay options to command menu (Closed)
Patch Set: ac 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 SDK.EmulationModel = class extends SDK.SDKModel { 5 SDK.EmulationModel = class extends SDK.SDKModel {
6 /** 6 /**
7 * @param {!SDK.Target} target 7 * @param {!SDK.Target} target
8 */ 8 */
9 constructor(target) { 9 constructor(target) {
10 super(target); 10 super(target);
11 this._emulationAgent = target.emulationAgent(); 11 this._emulationAgent = target.emulationAgent();
12 this._pageAgent = target.pageAgent(); 12 this._pageAgent = target.pageAgent();
13 this._deviceOrientationAgent = target.deviceOrientationAgent(); 13 this._deviceOrientationAgent = target.deviceOrientationAgent();
14 this._cssModel = target.model(SDK.CSSModel); 14 this._cssModel = target.model(SDK.CSSModel);
15 this._overlayModel = target.model(SDK.OverlayModel); 15 this._overlayModel = target.model(SDK.OverlayModel);
16 if (this._overlayModel) 16 if (this._overlayModel)
17 this._overlayModel.addEventListener(SDK.OverlayModel.Events.InspectModeWil lBeToggled, this._updateTouch, this); 17 this._overlayModel.addEventListener(SDK.OverlayModel.Events.InspectModeWil lBeToggled, this._updateTouch, this);
18 18
19 var disableJavascriptSetting = Common.settings.moduleSetting('javaScriptDisa bled'); 19 var disableJavascriptSetting = Common.settings.moduleSetting('javaScriptDisa bled');
20 disableJavascriptSetting.addChangeListener( 20 disableJavascriptSetting.addChangeListener(
21 () => this._emulationAgent.setScriptExecutionDisabled(disableJavascriptS etting.get())); 21 () => this._emulationAgent.setScriptExecutionDisabled(disableJavascriptS etting.get()));
22 if (disableJavascriptSetting.get()) 22 if (disableJavascriptSetting.get())
23 this._emulationAgent.setScriptExecutionDisabled(true); 23 this._emulationAgent.setScriptExecutionDisabled(true);
24 24
25 var mediaSetting = Common.moduleSetting('emulatedCSSMedia');
26 mediaSetting.addChangeListener(() => this._emulateCSSMedia(mediaSetting.get( )));
27 if (mediaSetting.get())
28 this._emulateCSSMedia(mediaSetting.get());
29
25 this._touchEnabled = false; 30 this._touchEnabled = false;
26 this._touchMobile = false; 31 this._touchMobile = false;
27 this._customTouchEnabled = false; 32 this._customTouchEnabled = false;
28 this._touchConfiguration = {enabled: false, configuration: 'mobile', scriptI d: ''}; 33 this._touchConfiguration = {enabled: false, configuration: 'mobile', scriptI d: ''};
29 } 34 }
30 35
31 /** 36 /**
32 * @return {boolean} 37 * @return {boolean}
33 */ 38 */
34 supportsDeviceEmulation() { 39 supportsDeviceEmulation() {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 emulateDeviceOrientation(deviceOrientation) { 108 emulateDeviceOrientation(deviceOrientation) {
104 if (deviceOrientation) { 109 if (deviceOrientation) {
105 this._deviceOrientationAgent.setDeviceOrientationOverride( 110 this._deviceOrientationAgent.setDeviceOrientationOverride(
106 deviceOrientation.alpha, deviceOrientation.beta, deviceOrientation.gam ma); 111 deviceOrientation.alpha, deviceOrientation.beta, deviceOrientation.gam ma);
107 } else { 112 } else {
108 this._deviceOrientationAgent.clearDeviceOrientationOverride(); 113 this._deviceOrientationAgent.clearDeviceOrientationOverride();
109 } 114 }
110 } 115 }
111 116
112 /** 117 /**
113 * @param {?string} media 118 * @param {string} media
114 */ 119 */
115 emulateCSSMedia(media) { 120 _emulateCSSMedia(media) {
116 this._emulationAgent.setEmulatedMedia(media || ''); 121 this._emulationAgent.setEmulatedMedia(media);
117 if (this._cssModel) 122 if (this._cssModel)
118 this._cssModel.mediaQueryResultChanged(); 123 this._cssModel.mediaQueryResultChanged();
119 } 124 }
120 125
121 /** 126 /**
122 * @param {number} rate 127 * @param {number} rate
123 */ 128 */
124 setCPUThrottlingRate(rate) { 129 setCPUThrottlingRate(rate) {
125 this._emulationAgent.setCPUThrottlingRate(rate); 130 this._emulationAgent.setCPUThrottlingRate(rate);
126 } 131 }
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 return /^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value); 329 return /^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value);
325 } 330 }
326 331
327 /** 332 /**
328 * @return {string} 333 * @return {string}
329 */ 334 */
330 toSetting() { 335 toSetting() {
331 return JSON.stringify(this); 336 return JSON.stringify(this);
332 } 337 }
333 }; 338 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698