| OLD | NEW |
| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 var cssOffsetY = event.data.currentY - event.data.startY; | 145 var cssOffsetY = event.data.currentY - event.data.startY; |
| 146 if (this._slowPositionStart) { | 146 if (this._slowPositionStart) { |
| 147 cssOffsetX = (event.data.currentX - this._slowPositionStart.x) / 10
+ this._slowPositionStart.x - event.data.startX; | 147 cssOffsetX = (event.data.currentX - this._slowPositionStart.x) / 10
+ this._slowPositionStart.x - event.data.startX; |
| 148 cssOffsetY = (event.data.currentY - this._slowPositionStart.y) / 10
+ this._slowPositionStart.y - event.data.startY; | 148 cssOffsetY = (event.data.currentY - this._slowPositionStart.y) / 10
+ this._slowPositionStart.y - event.data.startY; |
| 149 } | 149 } |
| 150 | 150 |
| 151 if (width) { | 151 if (width) { |
| 152 var dipOffsetX = cssOffsetX * WebInspector.zoomManager.zoomFactor(); | 152 var dipOffsetX = cssOffsetX * WebInspector.zoomManager.zoomFactor(); |
| 153 var newWidth = this._resizeStart.width + dipOffsetX * 2; | 153 var newWidth = this._resizeStart.width + dipOffsetX * 2; |
| 154 newWidth = Math.round(newWidth / this._model.scale()); | 154 newWidth = Math.round(newWidth / this._model.scale()); |
| 155 this._model.setWidth(newWidth); | 155 if (newWidth >= WebInspector.DeviceModeModel.MinDeviceSize && newWid
th <= WebInspector.DeviceModeModel.MaxDeviceSize) |
| 156 this._model.setWidth(newWidth); |
| 156 } | 157 } |
| 157 | 158 |
| 158 if (height) { | 159 if (height) { |
| 159 var dipOffsetY = cssOffsetY * WebInspector.zoomManager.zoomFactor(); | 160 var dipOffsetY = cssOffsetY * WebInspector.zoomManager.zoomFactor(); |
| 160 var newHeight = this._resizeStart.height + dipOffsetY; | 161 var newHeight = this._resizeStart.height + dipOffsetY; |
| 161 newHeight = Math.round(newHeight / this._model.scale()); | 162 newHeight = Math.round(newHeight / this._model.scale()); |
| 162 this._model.setHeight(newHeight); | 163 if (newHeight >= WebInspector.DeviceModeModel.MinDeviceSize && newHe
ight <= WebInspector.DeviceModeModel.MaxDeviceSize) |
| 164 this._model.setHeight(newHeight); |
| 163 } | 165 } |
| 164 }, | 166 }, |
| 165 | 167 |
| 166 /** | 168 /** |
| 167 * @param {!WebInspector.Event} event | 169 * @param {!WebInspector.Event} event |
| 168 */ | 170 */ |
| 169 _onResizeEnd: function(event) | 171 _onResizeEnd: function(event) |
| 170 { | 172 { |
| 171 delete this._resizeStart; | 173 delete this._resizeStart; |
| 172 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.Res
izedViewInResponsiveMode); | 174 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.Res
izedViewInResponsiveMode); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 this._measureHandles(); | 328 this._measureHandles(); |
| 327 this._mediaInspector.setEnabled(true); | 329 this._mediaInspector.setEnabled(true); |
| 328 this._toolbar.restore(); | 330 this._toolbar.restore(); |
| 329 }, | 331 }, |
| 330 | 332 |
| 331 /** | 333 /** |
| 332 * @override | 334 * @override |
| 333 */ | 335 */ |
| 334 willHide: function() | 336 willHide: function() |
| 335 { | 337 { |
| 338 this._model.emulate(WebInspector.DeviceModeModel.Type.None, null, null); |
| 336 this._mediaInspector.setEnabled(false); | 339 this._mediaInspector.setEnabled(false); |
| 337 }, | 340 }, |
| 338 | 341 |
| 339 __proto__: WebInspector.VBox.prototype | 342 __proto__: WebInspector.VBox.prototype |
| 340 } | 343 } |
| 341 | 344 |
| 342 /** | 345 /** |
| 343 * @param {!WebInspector.DeviceModeModel} model | 346 * @param {!WebInspector.DeviceModeModel} model |
| 344 * @param {!WebInspector.Setting} showMediaInspectorSetting | 347 * @param {!WebInspector.Setting} showMediaInspectorSetting |
| 345 * @param {!WebInspector.Setting} showRulersSetting | 348 * @param {!WebInspector.Setting} showRulersSetting |
| 346 * @constructor | 349 * @constructor |
| 347 */ | 350 */ |
| 348 WebInspector.DeviceModeView.Toolbar = function(model, showMediaInspectorSetting,
showRulersSetting) | 351 WebInspector.DeviceModeView.Toolbar = function(model, showMediaInspectorSetting,
showRulersSetting) |
| 349 { | 352 { |
| 350 this._model = model; | 353 this._model = model; |
| 351 this._showMediaInspectorSetting = showMediaInspectorSetting; | 354 this._showMediaInspectorSetting = showMediaInspectorSetting; |
| 352 this._showRulersSetting = showRulersSetting; | 355 this._showRulersSetting = showRulersSetting; |
| 353 /** @type {!Map<!WebInspector.EmulatedDevice, !WebInspector.EmulatedDevice.M
ode>} */ | 356 /** @type {!Map<!WebInspector.EmulatedDevice, !WebInspector.EmulatedDevice.M
ode>} */ |
| 354 this._lastMode = new Map(); | 357 this._lastMode = new Map(); |
| 355 /** @type {?WebInspector.EmulatedDevice} */ | |
| 356 this._lastDevice = null; | |
| 357 | 358 |
| 358 this._element = createElementWithClass("div", "device-mode-toolbar"); | 359 this._element = createElementWithClass("div", "device-mode-toolbar"); |
| 359 | 360 |
| 360 var leftContainer = this._element.createChild("div", "device-mode-toolbar-sp
acer"); | 361 var leftContainer = this._element.createChild("div", "device-mode-toolbar-sp
acer"); |
| 361 leftContainer.createChild("div", "device-mode-toolbar-spacer"); | 362 leftContainer.createChild("div", "device-mode-toolbar-spacer"); |
| 362 var leftToolbar = new WebInspector.Toolbar("", leftContainer); | 363 var leftToolbar = new WebInspector.Toolbar("", leftContainer); |
| 363 leftToolbar.makeWrappable(); | 364 leftToolbar.makeWrappable(); |
| 364 this._fillLeftToolbar(leftToolbar); | 365 this._fillLeftToolbar(leftToolbar); |
| 365 | 366 |
| 366 var mainToolbar = new WebInspector.Toolbar("", this._element); | 367 var mainToolbar = new WebInspector.Toolbar("", this._element); |
| 367 mainToolbar.makeWrappable(); | 368 mainToolbar.makeWrappable(); |
| 368 this._fillMainToolbar(mainToolbar); | 369 this._fillMainToolbar(mainToolbar); |
| 369 | 370 |
| 370 var rightContainer = this._element.createChild("div", "device-mode-toolbar-s
pacer"); | 371 var rightContainer = this._element.createChild("div", "device-mode-toolbar-s
pacer"); |
| 371 var rightToolbar = new WebInspector.Toolbar("", rightContainer); | 372 var rightToolbar = new WebInspector.Toolbar("device-mode-toolbar-fixed-size"
, rightContainer); |
| 373 rightToolbar.makeWrappable(); |
| 372 this._fillRightToolbar(rightToolbar); | 374 this._fillRightToolbar(rightToolbar); |
| 373 var modeToolbar = new WebInspector.Toolbar("", rightContainer); | 375 var modeToolbar = new WebInspector.Toolbar("device-mode-toolbar-fixed-size",
rightContainer); |
| 376 modeToolbar.makeWrappable(); |
| 374 this._fillModeToolbar(modeToolbar); | 377 this._fillModeToolbar(modeToolbar); |
| 375 rightContainer.createChild("div", "device-mode-toolbar-spacer"); | 378 rightContainer.createChild("div", "device-mode-toolbar-spacer"); |
| 376 var optionsToolbar = new WebInspector.Toolbar("", rightContainer); | 379 var optionsToolbar = new WebInspector.Toolbar("", rightContainer); |
| 377 optionsToolbar.makeWrappable(true); | 380 optionsToolbar.makeWrappable(true); |
| 378 this._fillOptionsToolbar(optionsToolbar); | 381 this._fillOptionsToolbar(optionsToolbar); |
| 379 | 382 |
| 380 WebInspector.emulatedDevicesList.addEventListener(WebInspector.EmulatedDevic
esList.Events.CustomDevicesUpdated, this._deviceListChanged, this); | 383 WebInspector.emulatedDevicesList.addEventListener(WebInspector.EmulatedDevic
esList.Events.CustomDevicesUpdated, this._deviceListChanged, this); |
| 381 WebInspector.emulatedDevicesList.addEventListener(WebInspector.EmulatedDevic
esList.Events.StandardDevicesUpdated, this._deviceListChanged, this); | 384 WebInspector.emulatedDevicesList.addEventListener(WebInspector.EmulatedDevic
esList.Events.StandardDevicesUpdated, this._deviceListChanged, this); |
| 382 | 385 |
| 383 this._persistenceSetting = WebInspector.settings.createSetting("emulation.de
viceModeViewPersistence", {type: WebInspector.DeviceModeModel.Type.Responsive, d
evice: "", orientation: "", mode: ""}); | 386 this._persistenceSetting = WebInspector.settings.createSetting("emulation.de
viceModeValue", {device: "", orientation: "", mode: ""}); |
| 384 this._restored = false; | |
| 385 } | 387 } |
| 386 | 388 |
| 387 WebInspector.DeviceModeView.Toolbar.prototype = { | 389 WebInspector.DeviceModeView.Toolbar.prototype = { |
| 388 /** | 390 /** |
| 389 * @param {!WebInspector.Toolbar} toolbar | 391 * @param {!WebInspector.Toolbar} toolbar |
| 390 */ | 392 */ |
| 391 _fillLeftToolbar: function(toolbar) | 393 _fillLeftToolbar: function(toolbar) |
| 392 { | 394 { |
| 395 toolbar.appendToolbarItem(this._wrapToolbarItem(createElementWithClass("
div", "device-mode-empty-toolbar-element"))); |
| 393 this._deviceSelectItem = new WebInspector.ToolbarMenuButton(this._append
DeviceMenuItems.bind(this)); | 396 this._deviceSelectItem = new WebInspector.ToolbarMenuButton(this._append
DeviceMenuItems.bind(this)); |
| 394 this._deviceSelectItem.setGlyph(""); | 397 this._deviceSelectItem.setGlyph(""); |
| 395 this._deviceSelectItem.setBold(false); | 398 this._deviceSelectItem.setBold(false); |
| 396 this._deviceSelectItem.turnIntoSelect(95); | 399 this._deviceSelectItem.turnIntoSelect(95); |
| 397 toolbar.appendToolbarItem(this._deviceSelectItem); | 400 toolbar.appendToolbarItem(this._deviceSelectItem); |
| 398 }, | 401 }, |
| 399 | 402 |
| 400 /** | 403 /** |
| 401 * @param {!WebInspector.Toolbar} toolbar | 404 * @param {!WebInspector.Toolbar} toolbar |
| 402 */ | 405 */ |
| (...skipping 30 matching lines...) Expand all Loading... |
| 433 { | 436 { |
| 434 return !value ? "" : WebInspector.DeviceModeModel.deviceSizeValidato
r(value); | 437 return !value ? "" : WebInspector.DeviceModeModel.deviceSizeValidato
r(value); |
| 435 } | 438 } |
| 436 }, | 439 }, |
| 437 | 440 |
| 438 /** | 441 /** |
| 439 * @param {!WebInspector.Toolbar} toolbar | 442 * @param {!WebInspector.Toolbar} toolbar |
| 440 */ | 443 */ |
| 441 _fillRightToolbar: function(toolbar) | 444 _fillRightToolbar: function(toolbar) |
| 442 { | 445 { |
| 446 toolbar.appendToolbarItem(this._wrapToolbarItem(createElementWithClass("
div", "device-mode-empty-toolbar-element"))); |
| 443 this._scaleItem = new WebInspector.ToolbarMenuButton(this._appendScaleMe
nuItems.bind(this)); | 447 this._scaleItem = new WebInspector.ToolbarMenuButton(this._appendScaleMe
nuItems.bind(this)); |
| 444 this._scaleItem.setTitle(WebInspector.UIString("Zoom")); | 448 this._scaleItem.setTitle(WebInspector.UIString("Zoom")); |
| 445 this._scaleItem.setGlyph(""); | 449 this._scaleItem.setGlyph(""); |
| 446 this._scaleItem.setBold(false); | 450 this._scaleItem.setBold(false); |
| 447 this._scaleItem.turnIntoSelect(); | 451 this._scaleItem.turnIntoSelect(); |
| 448 toolbar.appendToolbarItem(this._scaleItem); | 452 toolbar.appendToolbarItem(this._scaleItem); |
| 449 }, | 453 }, |
| 450 | 454 |
| 451 /** | 455 /** |
| 452 * @param {!WebInspector.Toolbar} toolbar | 456 * @param {!WebInspector.Toolbar} toolbar |
| 453 */ | 457 */ |
| 454 _fillModeToolbar: function(toolbar) | 458 _fillModeToolbar: function(toolbar) |
| 455 { | 459 { |
| 460 toolbar.appendToolbarItem(this._wrapToolbarItem(createElementWithClass("
div", "device-mode-empty-toolbar-element"))); |
| 456 this._modeButton = new WebInspector.ToolbarButton("", "rotate-screen-too
lbar-item"); | 461 this._modeButton = new WebInspector.ToolbarButton("", "rotate-screen-too
lbar-item"); |
| 457 this._modeButton.addEventListener("click", this._modeMenuClicked, this); | 462 this._modeButton.addEventListener("click", this._modeMenuClicked, this); |
| 458 toolbar.appendToolbarItem(this._modeButton); | 463 toolbar.appendToolbarItem(this._modeButton); |
| 459 }, | 464 }, |
| 460 | 465 |
| 461 /** | 466 /** |
| 462 * @param {!WebInspector.Toolbar} toolbar | 467 * @param {!WebInspector.Toolbar} toolbar |
| 463 */ | 468 */ |
| 464 _fillOptionsToolbar: function(toolbar) | 469 _fillOptionsToolbar: function(toolbar) |
| 465 { | 470 { |
| 466 this._uaItem = new WebInspector.ToolbarLabel(); | 471 this._uaItem = new WebInspector.ToolbarLabel(); |
| 467 this._uaItem.setVisible(false); | 472 this._uaItem.setVisible(false); |
| 468 this._uaItem.setTitle(WebInspector.UIString("User agent type")); | 473 this._uaItem.setTitle(WebInspector.UIString("User agent type")); |
| 469 toolbar.appendToolbarItem(this._uaItem); | 474 toolbar.appendToolbarItem(this._uaItem); |
| 470 | 475 |
| 471 this._deviceScaleItem = new WebInspector.ToolbarLabel(); | 476 this._deviceScaleItem = new WebInspector.ToolbarLabel(); |
| 472 this._deviceScaleItem.setVisible(false); | 477 this._deviceScaleItem.setVisible(false); |
| 473 this._deviceScaleItem.setTitle(WebInspector.UIString("Device pixel ratio
")); | 478 this._deviceScaleItem.setTitle(WebInspector.UIString("Device pixel ratio
")); |
| 474 toolbar.appendToolbarItem(this._deviceScaleItem); | 479 toolbar.appendToolbarItem(this._deviceScaleItem); |
| 475 | 480 |
| 476 var moreOptionsButton = new WebInspector.ToolbarMenuButton(this._appendO
ptionsMenuItems.bind(this)); | 481 var moreOptionsButton = new WebInspector.ToolbarMenuButton(this._appendO
ptionsMenuItems.bind(this)); |
| 477 moreOptionsButton.setTitle(WebInspector.UIString("More options")); | 482 moreOptionsButton.setTitle(WebInspector.UIString("More options")); |
| 478 toolbar.appendToolbarItem(moreOptionsButton); | 483 toolbar.appendToolbarItem(moreOptionsButton); |
| 484 |
| 485 toolbar.appendToolbarItem(this._wrapToolbarItem(createElementWithClass("
div", "device-mode-empty-toolbar-element"))); |
| 479 }, | 486 }, |
| 480 | 487 |
| 481 | 488 |
| 482 /** | 489 /** |
| 483 * @param {!Element} input | 490 * @param {!Element} input |
| 484 * @param {function(number)} apply | 491 * @param {function(number)} apply |
| 485 * @param {function(string):?string} validate | 492 * @param {function(string):?string} validate |
| 486 * @return {function(number)} | 493 * @return {function(number)} |
| 487 */ | 494 */ |
| 488 _bindInput: function(input, apply, validate) | 495 _bindInput: function(input, apply, validate) |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 /** | 813 /** |
| 807 * @return {!Element} | 814 * @return {!Element} |
| 808 */ | 815 */ |
| 809 element: function() | 816 element: function() |
| 810 { | 817 { |
| 811 return this._element; | 818 return this._element; |
| 812 }, | 819 }, |
| 813 | 820 |
| 814 update: function() | 821 update: function() |
| 815 { | 822 { |
| 816 var updatePersistence = false; | |
| 817 | |
| 818 if (this._model.type() !== this._cachedModelType) { | 823 if (this._model.type() !== this._cachedModelType) { |
| 819 this._previousModelType = this._cachedModelType; | |
| 820 this._cachedModelType = this._model.type(); | 824 this._cachedModelType = this._model.type(); |
| 821 this._widthInput.disabled = this._model.type() !== WebInspector.Devi
ceModeModel.Type.Responsive; | 825 this._widthInput.disabled = this._model.type() !== WebInspector.Devi
ceModeModel.Type.Responsive; |
| 822 this._heightInput.disabled = this._model.type() !== WebInspector.Dev
iceModeModel.Type.Responsive; | 826 this._heightInput.disabled = this._model.type() !== WebInspector.Dev
iceModeModel.Type.Responsive; |
| 823 updatePersistence = true; | |
| 824 } | 827 } |
| 825 | 828 |
| 826 var size = this._model.appliedDeviceSize(); | 829 var size = this._model.appliedDeviceSize(); |
| 827 this._updateHeightInput(this._model.type() === WebInspector.DeviceModeMo
del.Type.Responsive && this._model.isFullHeight() ? 0 : size.height); | 830 this._updateHeightInput(this._model.type() === WebInspector.DeviceModeMo
del.Type.Responsive && this._model.isFullHeight() ? 0 : size.height); |
| 828 this._updateWidthInput(size.width); | 831 this._updateWidthInput(size.width); |
| 829 this._heightInput.placeholder = size.height; | 832 this._heightInput.placeholder = size.height; |
| 830 | 833 |
| 831 if (this._model.scale() !== this._cachedScale) { | 834 if (this._model.scale() !== this._cachedScale) { |
| 832 this._scaleItem.setText(WebInspector.UIString("%.0f%%", this._model.
scale() * 100)); | 835 this._scaleItem.setText(WebInspector.UIString("%.0f%%", this._model.
scale() * 100)); |
| 833 this._scaleItem.setState(this._model.scale() === 1 ? "off" : "on"); | 836 this._scaleItem.setState(this._model.scale() === 1 ? "off" : "on"); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 857 | 860 |
| 858 if (this._model.device() !== this._cachedModelDevice) { | 861 if (this._model.device() !== this._cachedModelDevice) { |
| 859 var device = this._model.device(); | 862 var device = this._model.device(); |
| 860 this._modeButton.setVisible(!!device); | 863 this._modeButton.setVisible(!!device); |
| 861 if (device) { | 864 if (device) { |
| 862 var modeCount = device ? device.modes.length : 0; | 865 var modeCount = device ? device.modes.length : 0; |
| 863 this._modeButton.setEnabled(modeCount >= 2); | 866 this._modeButton.setEnabled(modeCount >= 2); |
| 864 this._modeButton.setTitle(modeCount === 2 ? WebInspector.UIStrin
g("Rotate") : WebInspector.UIString("Screen options")); | 867 this._modeButton.setTitle(modeCount === 2 ? WebInspector.UIStrin
g("Rotate") : WebInspector.UIString("Screen options")); |
| 865 } | 868 } |
| 866 this._cachedModelDevice = device; | 869 this._cachedModelDevice = device; |
| 867 updatePersistence = true; | |
| 868 } | 870 } |
| 869 | 871 |
| 870 if (this._model.type() === WebInspector.DeviceModeModel.Type.Device) { | 872 if (this._model.type() === WebInspector.DeviceModeModel.Type.Device) |
| 871 this._lastDevice = this._model.device(); | |
| 872 this._lastMode.set(/** @type {!WebInspector.EmulatedDevice} */ (this
._model.device()), /** @type {!WebInspector.EmulatedDevice.Mode} */ (this._model
.mode())); | 873 this._lastMode.set(/** @type {!WebInspector.EmulatedDevice} */ (this
._model.device()), /** @type {!WebInspector.EmulatedDevice.Mode} */ (this._model
.mode())); |
| 873 } | |
| 874 | 874 |
| 875 if (this._model.mode() !== this._cachedModelMode) { | 875 if (this._model.mode() !== this._cachedModelMode && this._model.type() !
== WebInspector.DeviceModeModel.Type.None) { |
| 876 this._cachedModelMode = this._model.mode(); | 876 this._cachedModelMode = this._model.mode(); |
| 877 updatePersistence = true; | |
| 878 } | |
| 879 | |
| 880 if (updatePersistence && this._cachedModelType !== WebInspector.DeviceMo
deModel.Type.None) { | |
| 881 var value = this._persistenceSetting.get(); | 877 var value = this._persistenceSetting.get(); |
| 882 value.type = this._cachedModelType; | 878 if (this._model.device()) { |
| 883 if (this._cachedModelDevice) { | 879 value.device = this._model.device().title; |
| 884 value.device = this._cachedModelDevice.title; | 880 value.orientation = this._model.mode() ? this._model.mode().orie
ntation : ""; |
| 885 value.orientation = this._cachedModelMode ? this._cachedModelMod
e.orientation : ""; | 881 value.mode = this._model.mode() ? this._model.mode().title : ""; |
| 886 value.mode = this._cachedModelMode ? this._cachedModelMode.title
: ""; | 882 } else { |
| 883 value.device = ""; |
| 884 value.orientation = ""; |
| 885 value.mode = ""; |
| 887 } | 886 } |
| 888 this._persistenceSetting.set(value); | 887 this._persistenceSetting.set(value); |
| 889 } | 888 } |
| 890 }, | 889 }, |
| 891 | 890 |
| 892 restore: function() | 891 restore: function() |
| 893 { | 892 { |
| 894 if (this._restored) | |
| 895 return; | |
| 896 this._restored = true; | |
| 897 | |
| 898 for (var device of this._allDevices()) { | 893 for (var device of this._allDevices()) { |
| 899 if (device.title === this._persistenceSetting.get().device) { | 894 if (device.title === this._persistenceSetting.get().device) { |
| 900 this._lastDevice = device; | |
| 901 for (var mode of device.modes) { | 895 for (var mode of device.modes) { |
| 902 if (mode.orientation === this._persistenceSetting.get().orie
ntation && mode.title === this._persistenceSetting.get().mode) | 896 if (mode.orientation === this._persistenceSetting.get().orie
ntation && mode.title === this._persistenceSetting.get().mode) { |
| 903 this._lastMode.set(device, mode); | 897 this._lastMode.set(device, mode); |
| 898 this._emulateDevice(device); |
| 899 return; |
| 900 } |
| 904 } | 901 } |
| 905 } | 902 } |
| 906 } | 903 } |
| 907 | 904 |
| 908 this._applyType(/** @type {!WebInspector.DeviceModeModel.Type} */ (this.
_persistenceSetting.get().type)); | 905 this._model.emulate(WebInspector.DeviceModeModel.Type.Responsive, null,
null); |
| 909 }, | |
| 910 | |
| 911 toggleDeviceMode: function() | |
| 912 { | |
| 913 this._applyType(this._model.type() === WebInspector.DeviceModeModel.Type
.None ? (this._previousModelType || WebInspector.DeviceModeModel.Type.Responsive
) : WebInspector.DeviceModeModel.Type.None); | |
| 914 }, | |
| 915 | |
| 916 /** | |
| 917 * @param {!WebInspector.DeviceModeModel.Type} type | |
| 918 */ | |
| 919 _applyType: function(type) | |
| 920 { | |
| 921 if (type === WebInspector.DeviceModeModel.Type.Responsive) | |
| 922 this._model.emulate(WebInspector.DeviceModeModel.Type.Responsive, nu
ll, null); | |
| 923 else if (type === WebInspector.DeviceModeModel.Type.Device) | |
| 924 this._emulateDevice(this._lastDevice || this._allDevices()[0] || Web
Inspector.emulatedDevicesList.standard()[0]); | |
| 925 else | |
| 926 this._model.emulate(WebInspector.DeviceModeModel.Type.None, null, nu
ll); | |
| 927 } | 906 } |
| 928 } | 907 } |
| 929 | 908 |
| 930 /** | 909 /** |
| 931 * @constructor | 910 * @constructor |
| 932 * @extends {WebInspector.VBox} | 911 * @extends {WebInspector.VBox} |
| 933 * @param {boolean} horizontal | 912 * @param {boolean} horizontal |
| 934 * @param {function(number)} applyCallback | 913 * @param {function(number)} applyCallback |
| 935 */ | 914 */ |
| 936 WebInspector.DeviceModeView.Ruler = function(horizontal, applyCallback) | 915 WebInspector.DeviceModeView.Ruler = function(horizontal, applyCallback) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 this._renderedScale = this._scale; | 962 this._renderedScale = this._scale; |
| 984 this._renderedZoomFactor = zoomFactor; | 963 this._renderedZoomFactor = zoomFactor; |
| 985 } | 964 } |
| 986 | 965 |
| 987 var dipSize = size * zoomFactor / this._scale; | 966 var dipSize = size * zoomFactor / this._scale; |
| 988 var count = Math.ceil(dipSize / 5); | 967 var count = Math.ceil(dipSize / 5); |
| 989 var step = 1; | 968 var step = 1; |
| 990 if (this._scale < 0.8) | 969 if (this._scale < 0.8) |
| 991 step = 2; | 970 step = 2; |
| 992 if (this._scale < 0.6) | 971 if (this._scale < 0.6) |
| 993 step = 5; | 972 step = 4; |
| 994 if (this._scale < 0.5) | 973 if (this._scale < 0.4) |
| 995 step = 20; | 974 step = 8; |
| 996 | 975 |
| 997 for (var i = count; i < this._count; i++) { | 976 for (var i = count; i < this._count; i++) { |
| 998 if (!(i % step)) | 977 if (!(i % step)) |
| 999 this._contentElement.lastChild.remove(); | 978 this._contentElement.lastChild.remove(); |
| 1000 } | 979 } |
| 1001 | 980 |
| 1002 for (var i = this._count; i < count; i++) { | 981 for (var i = this._count; i < count; i++) { |
| 1003 if (i % step) | 982 if (i % step) |
| 1004 continue; | 983 continue; |
| 1005 var marker = this._contentElement.createChild("div", "device-mode-ru
ler-marker"); | 984 var marker = this._contentElement.createChild("div", "device-mode-ru
ler-marker"); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 | 1078 |
| 1100 if (this._showDeviceModeSetting.get()) { | 1079 if (this._showDeviceModeSetting.get()) { |
| 1101 this._deviceModeView.show(this.element); | 1080 this._deviceModeView.show(this.element); |
| 1102 this._inspectedPagePlaceholder.clearMinimumSizeAndMargins(); | 1081 this._inspectedPagePlaceholder.clearMinimumSizeAndMargins(); |
| 1103 this._inspectedPagePlaceholder.show(this._deviceModeView.element); | 1082 this._inspectedPagePlaceholder.show(this._deviceModeView.element); |
| 1104 } else { | 1083 } else { |
| 1105 this._deviceModeView.detach(); | 1084 this._deviceModeView.detach(); |
| 1106 this._inspectedPagePlaceholder.restoreMinimumSizeAndMargins(); | 1085 this._inspectedPagePlaceholder.restoreMinimumSizeAndMargins(); |
| 1107 this._inspectedPagePlaceholder.show(this.element); | 1086 this._inspectedPagePlaceholder.show(this.element); |
| 1108 } | 1087 } |
| 1109 this._deviceModeView.toggleDeviceMode(); | |
| 1110 }, | 1088 }, |
| 1111 | 1089 |
| 1112 __proto__: WebInspector.VBox.prototype | 1090 __proto__: WebInspector.VBox.prototype |
| 1113 } | 1091 } |
| OLD | NEW |