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

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

Issue 2466123002: DevTools: reformat front-end code to match chromium style. (Closed)
Patch Set: all done Created 4 years, 1 month 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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
5 /** 4 /**
6 * @extends {WebInspector.VBox} 5 * @unrestricted
7 * @param {!WebInspector.InspectedPagePlaceholder} inspectedPagePlaceholder
8 * @constructor
9 */ 6 */
10 WebInspector.DeviceModeWrapper = function(inspectedPagePlaceholder) 7 WebInspector.DeviceModeWrapper = class extends WebInspector.VBox {
11 { 8 /**
12 WebInspector.VBox.call(this); 9 * @param {!WebInspector.InspectedPagePlaceholder} inspectedPagePlaceholder
10 */
11 constructor(inspectedPagePlaceholder) {
12 super();
13 WebInspector.DeviceModeView._wrapperInstance = this; 13 WebInspector.DeviceModeView._wrapperInstance = this;
14 this._inspectedPagePlaceholder = inspectedPagePlaceholder; 14 this._inspectedPagePlaceholder = inspectedPagePlaceholder;
15 /** @type {?WebInspector.DeviceModeView} */ 15 /** @type {?WebInspector.DeviceModeView} */
16 this._deviceModeView = null; 16 this._deviceModeView = null;
17 this._toggleDeviceModeAction = WebInspector.actionRegistry.action("emulation .toggle-device-mode"); 17 this._toggleDeviceModeAction = WebInspector.actionRegistry.action('emulation .toggle-device-mode');
18 this._showDeviceModeSetting = WebInspector.settings.createSetting("emulation .showDeviceMode", false); 18 this._showDeviceModeSetting = WebInspector.settings.createSetting('emulation .showDeviceMode', false);
19 this._showDeviceModeSetting.addChangeListener(this._update.bind(this, false) ); 19 this._showDeviceModeSetting.addChangeListener(this._update.bind(this, false) );
20 this._update(true); 20 this._update(true);
21 }
22
23 _toggleDeviceMode() {
24 this._showDeviceModeSetting.set(!this._showDeviceModeSetting.get());
25 }
26
27 /**
28 * @return {boolean}
29 */
30 _captureScreenshot() {
31 if (!this._deviceModeView)
32 return false;
33 this._deviceModeView.captureScreenshot();
34 return true;
35 }
36
37 /**
38 * @param {boolean} force
39 */
40 _update(force) {
41 this._toggleDeviceModeAction.setToggled(this._showDeviceModeSetting.get());
42 if (!force) {
43 var showing = this._deviceModeView && this._deviceModeView.isShowing();
44 if (this._showDeviceModeSetting.get() === showing)
45 return;
46 }
47
48 if (this._showDeviceModeSetting.get()) {
49 if (!this._deviceModeView)
50 this._deviceModeView = new WebInspector.DeviceModeView();
51 this._deviceModeView.show(this.element);
52 this._inspectedPagePlaceholder.clearMinimumSizeAndMargins();
53 this._inspectedPagePlaceholder.show(this._deviceModeView.element);
54 } else {
55 if (this._deviceModeView)
56 this._deviceModeView.detach();
57 this._inspectedPagePlaceholder.restoreMinimumSizeAndMargins();
58 this._inspectedPagePlaceholder.show(this.element);
59 }
60 }
21 }; 61 };
22 62
23 /** @type {!WebInspector.DeviceModeWrapper} */ 63 /** @type {!WebInspector.DeviceModeWrapper} */
24 WebInspector.DeviceModeView._wrapperInstance; 64 WebInspector.DeviceModeView._wrapperInstance;
25 65
26 WebInspector.DeviceModeWrapper.prototype = { 66 /**
27 _toggleDeviceMode: function() 67 * @implements {WebInspector.ActionDelegate}
28 { 68 * @unrestricted
29 this._showDeviceModeSetting.set(!this._showDeviceModeSetting.get()); 69 */
30 }, 70 WebInspector.DeviceModeWrapper.ActionDelegate = class {
31 71 /**
32 /** 72 * @override
33 * @return {boolean} 73 * @param {!WebInspector.Context} context
34 */ 74 * @param {string} actionId
35 _captureScreenshot: function() 75 * @return {boolean}
36 { 76 */
37 if (!this._deviceModeView) 77 handleAction(context, actionId) {
38 return false; 78 if (WebInspector.DeviceModeView._wrapperInstance) {
39 this._deviceModeView.captureScreenshot(); 79 if (actionId === 'emulation.toggle-device-mode') {
80 WebInspector.DeviceModeView._wrapperInstance._toggleDeviceMode();
40 return true; 81 return true;
41 }, 82 }
42 83 if (actionId === 'emulation.capture-screenshot')
43 /** 84 return WebInspector.DeviceModeView._wrapperInstance._captureScreenshot() ;
44 * @param {boolean} force 85 }
45 */ 86 return false;
46 _update: function(force) 87 }
47 {
48 this._toggleDeviceModeAction.setToggled(this._showDeviceModeSetting.get( ));
49 if (!force) {
50 var showing = this._deviceModeView && this._deviceModeView.isShowing ();
51 if (this._showDeviceModeSetting.get() === showing)
52 return;
53 }
54
55 if (this._showDeviceModeSetting.get()) {
56 if (!this._deviceModeView)
57 this._deviceModeView = new WebInspector.DeviceModeView();
58 this._deviceModeView.show(this.element);
59 this._inspectedPagePlaceholder.clearMinimumSizeAndMargins();
60 this._inspectedPagePlaceholder.show(this._deviceModeView.element);
61 } else {
62 if (this._deviceModeView)
63 this._deviceModeView.detach();
64 this._inspectedPagePlaceholder.restoreMinimumSizeAndMargins();
65 this._inspectedPagePlaceholder.show(this.element);
66 }
67 },
68
69 __proto__: WebInspector.VBox.prototype
70 }; 88 };
71
72 /**
73 * @constructor
74 * @implements {WebInspector.ActionDelegate}
75 */
76 WebInspector.DeviceModeWrapper.ActionDelegate = function()
77 {
78 };
79
80 WebInspector.DeviceModeWrapper.ActionDelegate.prototype = {
81 /**
82 * @override
83 * @param {!WebInspector.Context} context
84 * @param {string} actionId
85 * @return {boolean}
86 */
87 handleAction: function(context, actionId)
88 {
89 if (WebInspector.DeviceModeView._wrapperInstance) {
90 if (actionId === "emulation.toggle-device-mode") {
91 WebInspector.DeviceModeView._wrapperInstance._toggleDeviceMode() ;
92 return true;
93 }
94 if (actionId === "emulation.capture-screenshot")
95 return WebInspector.DeviceModeView._wrapperInstance._captureScre enshot();
96 }
97 return false;
98 }
99 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698