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); |
} |