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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/emulation/DeviceModeView.js
diff --git a/third_party/WebKit/Source/devtools/front_end/emulation/DeviceModeView.js b/third_party/WebKit/Source/devtools/front_end/emulation/DeviceModeView.js
index 24f99c2c3ba03af1a43cbcb6a88b05720e2fa84f..08ce7c1787043d87da0a9bd02949d4c79b8a5946 100644
--- a/third_party/WebKit/Source/devtools/front_end/emulation/DeviceModeView.js
+++ b/third_party/WebKit/Source/devtools/front_end/emulation/DeviceModeView.js
@@ -1049,7 +1049,8 @@ WebInspector.DeviceModeView.Wrapper = function(inspectedPagePlaceholder)
WebInspector.VBox.call(this);
WebInspector.DeviceModeView._wrapperInstance = this;
this._inspectedPagePlaceholder = inspectedPagePlaceholder;
- this._deviceModeView = new WebInspector.DeviceModeView();
+ /** @type {?WebInspector.DeviceModeView} */
+ this._deviceModeView = null;
this._toggleDeviceModeAction = WebInspector.actionRegistry.action("emulation.toggle-device-mode");
this._showDeviceModeSetting = WebInspector.settings.createSetting("emulation.showDeviceMode", false);
this._showDeviceModeSetting.addChangeListener(this._update.bind(this, false));
@@ -1071,15 +1072,21 @@ WebInspector.DeviceModeView.Wrapper.prototype = {
_update: function(force)
{
this._toggleDeviceModeAction.setToggled(this._showDeviceModeSetting.get());
- if (!force && this._showDeviceModeSetting.get() === this._deviceModeView.isShowing())
- return;
+ if (!force) {
+ var showing = this._deviceModeView && this._deviceModeView.isShowing();
+ if (this._showDeviceModeSetting.get() === showing)
+ return;
+ }
if (this._showDeviceModeSetting.get()) {
+ if (!this._deviceModeView)
+ this._deviceModeView = new WebInspector.DeviceModeView();
this._deviceModeView.show(this.element);
this._inspectedPagePlaceholder.clearMinimumSizeAndMargins();
this._inspectedPagePlaceholder.show(this._deviceModeView.element);
} else {
- this._deviceModeView.detach();
+ if (this._deviceModeView)
+ this._deviceModeView.detach();
this._inspectedPagePlaceholder.restoreMinimumSizeAndMargins();
this._inspectedPagePlaceholder.show(this.element);
}
« 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