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

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

Issue 1617493002: [DevTools] Initialize DeviceModeView lazily. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 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 /** 5 /**
6 * @constructor 6 * @constructor
7 * @extends {WebInspector.VBox} 7 * @extends {WebInspector.VBox}
8 */ 8 */
9 WebInspector.DeviceModeView = function() 9 WebInspector.DeviceModeView = function()
10 { 10 {
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 /** 1042 /**
1043 * @extends {WebInspector.VBox} 1043 * @extends {WebInspector.VBox}
1044 * @param {!WebInspector.InspectedPagePlaceholder} inspectedPagePlaceholder 1044 * @param {!WebInspector.InspectedPagePlaceholder} inspectedPagePlaceholder
1045 * @constructor 1045 * @constructor
1046 */ 1046 */
1047 WebInspector.DeviceModeView.Wrapper = function(inspectedPagePlaceholder) 1047 WebInspector.DeviceModeView.Wrapper = function(inspectedPagePlaceholder)
1048 { 1048 {
1049 WebInspector.VBox.call(this); 1049 WebInspector.VBox.call(this);
1050 WebInspector.DeviceModeView._wrapperInstance = this; 1050 WebInspector.DeviceModeView._wrapperInstance = this;
1051 this._inspectedPagePlaceholder = inspectedPagePlaceholder; 1051 this._inspectedPagePlaceholder = inspectedPagePlaceholder;
1052 this._deviceModeView = new WebInspector.DeviceModeView(); 1052 /** @type {?WebInspector.DeviceModeView} */
1053 this._deviceModeView = null;
1053 this._toggleDeviceModeAction = WebInspector.actionRegistry.action("emulation .toggle-device-mode"); 1054 this._toggleDeviceModeAction = WebInspector.actionRegistry.action("emulation .toggle-device-mode");
1054 this._showDeviceModeSetting = WebInspector.settings.createSetting("emulation .showDeviceMode", false); 1055 this._showDeviceModeSetting = WebInspector.settings.createSetting("emulation .showDeviceMode", false);
1055 this._showDeviceModeSetting.addChangeListener(this._update.bind(this, false) ); 1056 this._showDeviceModeSetting.addChangeListener(this._update.bind(this, false) );
1056 this._update(true); 1057 this._update(true);
1057 } 1058 }
1058 1059
1059 /** @type {!WebInspector.DeviceModeView.Wrapper} */ 1060 /** @type {!WebInspector.DeviceModeView.Wrapper} */
1060 WebInspector.DeviceModeView._wrapperInstance; 1061 WebInspector.DeviceModeView._wrapperInstance;
1061 1062
1062 WebInspector.DeviceModeView.Wrapper.prototype = { 1063 WebInspector.DeviceModeView.Wrapper.prototype = {
1063 _toggleDeviceMode: function() 1064 _toggleDeviceMode: function()
1064 { 1065 {
1065 this._showDeviceModeSetting.set(!this._showDeviceModeSetting.get()); 1066 this._showDeviceModeSetting.set(!this._showDeviceModeSetting.get());
1066 }, 1067 },
1067 1068
1068 /** 1069 /**
1069 * @param {boolean} force 1070 * @param {boolean} force
1070 */ 1071 */
1071 _update: function(force) 1072 _update: function(force)
1072 { 1073 {
1073 this._toggleDeviceModeAction.setToggled(this._showDeviceModeSetting.get( )); 1074 this._toggleDeviceModeAction.setToggled(this._showDeviceModeSetting.get( ));
1074 if (!force && this._showDeviceModeSetting.get() === this._deviceModeView .isShowing()) 1075 if (!force) {
1075 return; 1076 var showing = this._deviceModeView && this._deviceModeView.isShowing ();
1077 if (this._showDeviceModeSetting.get() === showing)
1078 return;
1079 }
1076 1080
1077 if (this._showDeviceModeSetting.get()) { 1081 if (this._showDeviceModeSetting.get()) {
1082 if (!this._deviceModeView)
1083 this._deviceModeView = new WebInspector.DeviceModeView();
1078 this._deviceModeView.show(this.element); 1084 this._deviceModeView.show(this.element);
1079 this._inspectedPagePlaceholder.clearMinimumSizeAndMargins(); 1085 this._inspectedPagePlaceholder.clearMinimumSizeAndMargins();
1080 this._inspectedPagePlaceholder.show(this._deviceModeView.element); 1086 this._inspectedPagePlaceholder.show(this._deviceModeView.element);
1081 } else { 1087 } else {
1082 this._deviceModeView.detach(); 1088 if (this._deviceModeView)
1089 this._deviceModeView.detach();
1083 this._inspectedPagePlaceholder.restoreMinimumSizeAndMargins(); 1090 this._inspectedPagePlaceholder.restoreMinimumSizeAndMargins();
1084 this._inspectedPagePlaceholder.show(this.element); 1091 this._inspectedPagePlaceholder.show(this.element);
1085 } 1092 }
1086 }, 1093 },
1087 1094
1088 __proto__: WebInspector.VBox.prototype 1095 __proto__: WebInspector.VBox.prototype
1089 } 1096 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698