| 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.turnIntoSelect(95); | 398 this._deviceSelectItem.turnIntoSelect(95); |
| 396 toolbar.appendToolbarItem(this._deviceSelectItem); | 399 toolbar.appendToolbarItem(this._deviceSelectItem); |
| 397 }, | 400 }, |
| 398 | 401 |
| 399 /** | 402 /** |
| 400 * @param {!WebInspector.Toolbar} toolbar | 403 * @param {!WebInspector.Toolbar} toolbar |
| 401 */ | 404 */ |
| 402 _fillMainToolbar: function(toolbar) | 405 _fillMainToolbar: function(toolbar) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 432 { | 435 { |
| 433 return !value ? "" : WebInspector.DeviceModeModel.deviceSizeValidato
r(value); | 436 return !value ? "" : WebInspector.DeviceModeModel.deviceSizeValidato
r(value); |
| 434 } | 437 } |
| 435 }, | 438 }, |
| 436 | 439 |
| 437 /** | 440 /** |
| 438 * @param {!WebInspector.Toolbar} toolbar | 441 * @param {!WebInspector.Toolbar} toolbar |
| 439 */ | 442 */ |
| 440 _fillRightToolbar: function(toolbar) | 443 _fillRightToolbar: function(toolbar) |
| 441 { | 444 { |
| 445 toolbar.appendToolbarItem(this._wrapToolbarItem(createElementWithClass("
div", "device-mode-empty-toolbar-element"))); |
| 442 this._scaleItem = new WebInspector.ToolbarMenuButton(this._appendScaleMe
nuItems.bind(this)); | 446 this._scaleItem = new WebInspector.ToolbarMenuButton(this._appendScaleMe
nuItems.bind(this)); |
| 443 this._scaleItem.setTitle(WebInspector.UIString("Zoom")); | 447 this._scaleItem.setTitle(WebInspector.UIString("Zoom")); |
| 444 this._scaleItem.setGlyph(""); | 448 this._scaleItem.setGlyph(""); |
| 445 this._scaleItem.turnIntoSelect(); | 449 this._scaleItem.turnIntoSelect(); |
| 446 toolbar.appendToolbarItem(this._scaleItem); | 450 toolbar.appendToolbarItem(this._scaleItem); |
| 447 }, | 451 }, |
| 448 | 452 |
| 449 /** | 453 /** |
| 450 * @param {!WebInspector.Toolbar} toolbar | 454 * @param {!WebInspector.Toolbar} toolbar |
| 451 */ | 455 */ |
| 452 _fillModeToolbar: function(toolbar) | 456 _fillModeToolbar: function(toolbar) |
| 453 { | 457 { |
| 458 toolbar.appendToolbarItem(this._wrapToolbarItem(createElementWithClass("
div", "device-mode-empty-toolbar-element"))); |
| 454 this._modeButton = new WebInspector.ToolbarButton("", "rotate-screen-too
lbar-item"); | 459 this._modeButton = new WebInspector.ToolbarButton("", "rotate-screen-too
lbar-item"); |
| 455 this._modeButton.addEventListener("click", this._modeMenuClicked, this); | 460 this._modeButton.addEventListener("click", this._modeMenuClicked, this); |
| 456 toolbar.appendToolbarItem(this._modeButton); | 461 toolbar.appendToolbarItem(this._modeButton); |
| 457 }, | 462 }, |
| 458 | 463 |
| 459 /** | 464 /** |
| 460 * @param {!WebInspector.Toolbar} toolbar | 465 * @param {!WebInspector.Toolbar} toolbar |
| 461 */ | 466 */ |
| 462 _fillOptionsToolbar: function(toolbar) | 467 _fillOptionsToolbar: function(toolbar) |
| 463 { | 468 { |
| 464 this._uaItem = new WebInspector.ToolbarText(); | 469 this._uaItem = new WebInspector.ToolbarText(); |
| 465 this._uaItem.setVisible(false); | 470 this._uaItem.setVisible(false); |
| 466 this._uaItem.setTitle(WebInspector.UIString("User agent type")); | 471 this._uaItem.setTitle(WebInspector.UIString("User agent type")); |
| 467 toolbar.appendToolbarItem(this._uaItem); | 472 toolbar.appendToolbarItem(this._uaItem); |
| 468 | 473 |
| 469 this._deviceScaleItem = new WebInspector.ToolbarText(); | 474 this._deviceScaleItem = new WebInspector.ToolbarText(); |
| 470 this._deviceScaleItem.setVisible(false); | 475 this._deviceScaleItem.setVisible(false); |
| 471 this._deviceScaleItem.setTitle(WebInspector.UIString("Device pixel ratio
")); | 476 this._deviceScaleItem.setTitle(WebInspector.UIString("Device pixel ratio
")); |
| 472 toolbar.appendToolbarItem(this._deviceScaleItem); | 477 toolbar.appendToolbarItem(this._deviceScaleItem); |
| 473 | 478 |
| 474 var moreOptionsButton = new WebInspector.ToolbarMenuButton(this._appendO
ptionsMenuItems.bind(this)); | 479 var moreOptionsButton = new WebInspector.ToolbarMenuButton(this._appendO
ptionsMenuItems.bind(this)); |
| 475 moreOptionsButton.setTitle(WebInspector.UIString("More options")); | 480 moreOptionsButton.setTitle(WebInspector.UIString("More options")); |
| 476 toolbar.appendToolbarItem(moreOptionsButton); | 481 toolbar.appendToolbarItem(moreOptionsButton); |
| 482 |
| 483 toolbar.appendToolbarItem(this._wrapToolbarItem(createElementWithClass("
div", "device-mode-empty-toolbar-element"))); |
| 477 }, | 484 }, |
| 478 | 485 |
| 479 | 486 |
| 480 /** | 487 /** |
| 481 * @param {!Element} input | 488 * @param {!Element} input |
| 482 * @param {function(number)} apply | 489 * @param {function(number)} apply |
| 483 * @param {function(string):?string} validate | 490 * @param {function(string):?string} validate |
| 484 * @return {function(number)} | 491 * @return {function(number)} |
| 485 */ | 492 */ |
| 486 _bindInput: function(input, apply, validate) | 493 _bindInput: function(input, apply, validate) |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 /** | 811 /** |
| 805 * @return {!Element} | 812 * @return {!Element} |
| 806 */ | 813 */ |
| 807 element: function() | 814 element: function() |
| 808 { | 815 { |
| 809 return this._element; | 816 return this._element; |
| 810 }, | 817 }, |
| 811 | 818 |
| 812 update: function() | 819 update: function() |
| 813 { | 820 { |
| 814 var updatePersistence = false; | |
| 815 | |
| 816 if (this._model.type() !== this._cachedModelType) { | 821 if (this._model.type() !== this._cachedModelType) { |
| 817 this._previousModelType = this._cachedModelType; | |
| 818 this._cachedModelType = this._model.type(); | 822 this._cachedModelType = this._model.type(); |
| 819 this._widthInput.disabled = this._model.type() !== WebInspector.Devi
ceModeModel.Type.Responsive; | 823 this._widthInput.disabled = this._model.type() !== WebInspector.Devi
ceModeModel.Type.Responsive; |
| 820 this._heightInput.disabled = this._model.type() !== WebInspector.Dev
iceModeModel.Type.Responsive; | 824 this._heightInput.disabled = this._model.type() !== WebInspector.Dev
iceModeModel.Type.Responsive; |
| 821 updatePersistence = true; | |
| 822 } | 825 } |
| 823 | 826 |
| 824 var size = this._model.appliedDeviceSize(); | 827 var size = this._model.appliedDeviceSize(); |
| 825 this._updateHeightInput(this._model.type() === WebInspector.DeviceModeMo
del.Type.Responsive && this._model.isFullHeight() ? 0 : size.height); | 828 this._updateHeightInput(this._model.type() === WebInspector.DeviceModeMo
del.Type.Responsive && this._model.isFullHeight() ? 0 : size.height); |
| 826 this._updateWidthInput(size.width); | 829 this._updateWidthInput(size.width); |
| 827 this._heightInput.placeholder = size.height; | 830 this._heightInput.placeholder = size.height; |
| 828 | 831 |
| 829 if (this._model.scale() !== this._cachedScale) { | 832 if (this._model.scale() !== this._cachedScale) { |
| 830 this._scaleItem.setText(WebInspector.UIString("%.0f%%", this._model.
scale() * 100)); | 833 this._scaleItem.setText(WebInspector.UIString("%.0f%%", this._model.
scale() * 100)); |
| 831 this._scaleItem.setState(this._model.scale() === 1 ? "off" : "on"); | 834 this._scaleItem.setState(this._model.scale() === 1 ? "off" : "on"); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 855 | 858 |
| 856 if (this._model.device() !== this._cachedModelDevice) { | 859 if (this._model.device() !== this._cachedModelDevice) { |
| 857 var device = this._model.device(); | 860 var device = this._model.device(); |
| 858 this._modeButton.setVisible(!!device); | 861 this._modeButton.setVisible(!!device); |
| 859 if (device) { | 862 if (device) { |
| 860 var modeCount = device ? device.modes.length : 0; | 863 var modeCount = device ? device.modes.length : 0; |
| 861 this._modeButton.setEnabled(modeCount >= 2); | 864 this._modeButton.setEnabled(modeCount >= 2); |
| 862 this._modeButton.setTitle(modeCount === 2 ? WebInspector.UIStrin
g("Rotate") : WebInspector.UIString("Screen options")); | 865 this._modeButton.setTitle(modeCount === 2 ? WebInspector.UIStrin
g("Rotate") : WebInspector.UIString("Screen options")); |
| 863 } | 866 } |
| 864 this._cachedModelDevice = device; | 867 this._cachedModelDevice = device; |
| 865 updatePersistence = true; | |
| 866 } | 868 } |
| 867 | 869 |
| 868 if (this._model.type() === WebInspector.DeviceModeModel.Type.Device) { | 870 if (this._model.type() === WebInspector.DeviceModeModel.Type.Device) |
| 869 this._lastDevice = this._model.device(); | |
| 870 this._lastMode.set(/** @type {!WebInspector.EmulatedDevice} */ (this
._model.device()), /** @type {!WebInspector.EmulatedDevice.Mode} */ (this._model
.mode())); | 871 this._lastMode.set(/** @type {!WebInspector.EmulatedDevice} */ (this
._model.device()), /** @type {!WebInspector.EmulatedDevice.Mode} */ (this._model
.mode())); |
| 871 } | |
| 872 | 872 |
| 873 if (this._model.mode() !== this._cachedModelMode) { | 873 if (this._model.mode() !== this._cachedModelMode && this._model.type() !
== WebInspector.DeviceModeModel.Type.None) { |
| 874 this._cachedModelMode = this._model.mode(); | 874 this._cachedModelMode = this._model.mode(); |
| 875 updatePersistence = true; | |
| 876 } | |
| 877 | |
| 878 if (updatePersistence && this._cachedModelType !== WebInspector.DeviceMo
deModel.Type.None) { | |
| 879 var value = this._persistenceSetting.get(); | 875 var value = this._persistenceSetting.get(); |
| 880 value.type = this._cachedModelType; | 876 if (this._model.device()) { |
| 881 if (this._cachedModelDevice) { | 877 value.device = this._model.device().title; |
| 882 value.device = this._cachedModelDevice.title; | 878 value.orientation = this._model.mode() ? this._model.mode().orie
ntation : ""; |
| 883 value.orientation = this._cachedModelMode ? this._cachedModelMod
e.orientation : ""; | 879 value.mode = this._model.mode() ? this._model.mode().title : ""; |
| 884 value.mode = this._cachedModelMode ? this._cachedModelMode.title
: ""; | 880 } else { |
| 881 value.device = ""; |
| 882 value.orientation = ""; |
| 883 value.mode = ""; |
| 885 } | 884 } |
| 886 this._persistenceSetting.set(value); | 885 this._persistenceSetting.set(value); |
| 887 } | 886 } |
| 888 }, | 887 }, |
| 889 | 888 |
| 890 restore: function() | 889 restore: function() |
| 891 { | 890 { |
| 892 if (this._restored) | |
| 893 return; | |
| 894 this._restored = true; | |
| 895 | |
| 896 for (var device of this._allDevices()) { | 891 for (var device of this._allDevices()) { |
| 897 if (device.title === this._persistenceSetting.get().device) { | 892 if (device.title === this._persistenceSetting.get().device) { |
| 898 this._lastDevice = device; | |
| 899 for (var mode of device.modes) { | 893 for (var mode of device.modes) { |
| 900 if (mode.orientation === this._persistenceSetting.get().orie
ntation && mode.title === this._persistenceSetting.get().mode) | 894 if (mode.orientation === this._persistenceSetting.get().orie
ntation && mode.title === this._persistenceSetting.get().mode) { |
| 901 this._lastMode.set(device, mode); | 895 this._lastMode.set(device, mode); |
| 896 this._emulateDevice(device); |
| 897 return; |
| 898 } |
| 902 } | 899 } |
| 903 } | 900 } |
| 904 } | 901 } |
| 905 | 902 |
| 906 this._applyType(/** @type {!WebInspector.DeviceModeModel.Type} */ (this.
_persistenceSetting.get().type)); | 903 this._model.emulate(WebInspector.DeviceModeModel.Type.Responsive, null,
null); |
| 907 }, | |
| 908 | |
| 909 toggleDeviceMode: function() | |
| 910 { | |
| 911 this._applyType(this._model.type() === WebInspector.DeviceModeModel.Type
.None ? (this._previousModelType || WebInspector.DeviceModeModel.Type.Responsive
) : WebInspector.DeviceModeModel.Type.None); | |
| 912 }, | |
| 913 | |
| 914 /** | |
| 915 * @param {!WebInspector.DeviceModeModel.Type} type | |
| 916 */ | |
| 917 _applyType: function(type) | |
| 918 { | |
| 919 if (type === WebInspector.DeviceModeModel.Type.Responsive) | |
| 920 this._model.emulate(WebInspector.DeviceModeModel.Type.Responsive, nu
ll, null); | |
| 921 else if (type === WebInspector.DeviceModeModel.Type.Device) | |
| 922 this._emulateDevice(this._lastDevice || this._allDevices()[0] || Web
Inspector.emulatedDevicesList.standard()[0]); | |
| 923 else | |
| 924 this._model.emulate(WebInspector.DeviceModeModel.Type.None, null, nu
ll); | |
| 925 } | 904 } |
| 926 } | 905 } |
| 927 | 906 |
| 928 /** | 907 /** |
| 929 * @constructor | 908 * @constructor |
| 930 * @extends {WebInspector.VBox} | 909 * @extends {WebInspector.VBox} |
| 931 * @param {boolean} horizontal | 910 * @param {boolean} horizontal |
| 932 * @param {function(number)} applyCallback | 911 * @param {function(number)} applyCallback |
| 933 */ | 912 */ |
| 934 WebInspector.DeviceModeView.Ruler = function(horizontal, applyCallback) | 913 WebInspector.DeviceModeView.Ruler = function(horizontal, applyCallback) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 this._renderedScale = this._scale; | 960 this._renderedScale = this._scale; |
| 982 this._renderedZoomFactor = zoomFactor; | 961 this._renderedZoomFactor = zoomFactor; |
| 983 } | 962 } |
| 984 | 963 |
| 985 var dipSize = size * zoomFactor / this._scale; | 964 var dipSize = size * zoomFactor / this._scale; |
| 986 var count = Math.ceil(dipSize / 5); | 965 var count = Math.ceil(dipSize / 5); |
| 987 var step = 1; | 966 var step = 1; |
| 988 if (this._scale < 0.8) | 967 if (this._scale < 0.8) |
| 989 step = 2; | 968 step = 2; |
| 990 if (this._scale < 0.6) | 969 if (this._scale < 0.6) |
| 991 step = 5; | 970 step = 4; |
| 992 if (this._scale < 0.5) | 971 if (this._scale < 0.4) |
| 993 step = 20; | 972 step = 8; |
| 994 | 973 |
| 995 for (var i = count; i < this._count; i++) { | 974 for (var i = count; i < this._count; i++) { |
| 996 if (!(i % step)) | 975 if (!(i % step)) |
| 997 this._contentElement.lastChild.remove(); | 976 this._contentElement.lastChild.remove(); |
| 998 } | 977 } |
| 999 | 978 |
| 1000 for (var i = this._count; i < count; i++) { | 979 for (var i = this._count; i < count; i++) { |
| 1001 if (i % step) | 980 if (i % step) |
| 1002 continue; | 981 continue; |
| 1003 var marker = this._contentElement.createChild("div", "device-mode-ru
ler-marker"); | 982 var marker = this._contentElement.createChild("div", "device-mode-ru
ler-marker"); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1097 | 1076 |
| 1098 if (this._showDeviceModeSetting.get()) { | 1077 if (this._showDeviceModeSetting.get()) { |
| 1099 this._deviceModeView.show(this.element); | 1078 this._deviceModeView.show(this.element); |
| 1100 this._inspectedPagePlaceholder.clearMinimumSizeAndMargins(); | 1079 this._inspectedPagePlaceholder.clearMinimumSizeAndMargins(); |
| 1101 this._inspectedPagePlaceholder.show(this._deviceModeView.element); | 1080 this._inspectedPagePlaceholder.show(this._deviceModeView.element); |
| 1102 } else { | 1081 } else { |
| 1103 this._deviceModeView.detach(); | 1082 this._deviceModeView.detach(); |
| 1104 this._inspectedPagePlaceholder.restoreMinimumSizeAndMargins(); | 1083 this._inspectedPagePlaceholder.restoreMinimumSizeAndMargins(); |
| 1105 this._inspectedPagePlaceholder.show(this.element); | 1084 this._inspectedPagePlaceholder.show(this.element); |
| 1106 } | 1085 } |
| 1107 this._deviceModeView.toggleDeviceMode(); | |
| 1108 }, | 1086 }, |
| 1109 | 1087 |
| 1110 __proto__: WebInspector.VBox.prototype | 1088 __proto__: WebInspector.VBox.prototype |
| 1111 } | 1089 } |
| OLD | NEW |