| 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 { |
| 11 WebInspector.VBox.call(this, true); | 11 WebInspector.VBox.call(this, true); |
| 12 this.setMinimumSize(150, 150); | 12 this.setMinimumSize(150, 150); |
| 13 this.element.classList.add("device-mode-view"); | 13 this.element.classList.add("device-mode-view"); |
| 14 this.registerRequiredCSS("emulation/deviceModeView.css"); | 14 this.registerRequiredCSS("emulation/deviceModeView.css"); |
| 15 WebInspector.Tooltip.addNativeOverrideContainer(this.contentElement); | 15 WebInspector.Tooltip.addNativeOverrideContainer(this.contentElement); |
| 16 | 16 |
| 17 this._model = new WebInspector.DeviceModeModel(this._updateUI.bind(this)); | 17 this._model = new WebInspector.DeviceModeModel(this._updateUI.bind(this)); |
| 18 this._mediaInspector = new WebInspector.MediaQueryInspector(this._model.widt
hSetting()); | 18 this._mediaInspector = new WebInspector.MediaQueryInspector(this._model.widt
hSetting()); |
| 19 // TODO(dgozman): remove CountUpdated event. | 19 // TODO(dgozman): remove CountUpdated event. |
| 20 this._showMediaInspectorSetting = WebInspector.settings.createSetting("showM
ediaQueryInspector", false); | 20 this._showMediaInspectorSetting = WebInspector.settings.createSetting("showM
ediaQueryInspector", false); |
| 21 this._showMediaInspectorSetting.addChangeListener(this._updateUI, this); | 21 this._showMediaInspectorSetting.addChangeListener(this._updateUI, this); |
| 22 this._showRulersSetting = WebInspector.settings.createSetting("emulation.sho
wRulers", false); | 22 this._showRulersSetting = WebInspector.settings.createSetting("emulation.sho
wRulers", false); |
| 23 this._showRulersSetting.addChangeListener(this._updateUI, this); | 23 this._showRulersSetting.addChangeListener(this._updateUI, this); |
| 24 | 24 |
| 25 this._topRuler = new WebInspector.DeviceModeView.Ruler(true, this._model.wid
thSetting().set.bind(this._model.widthSetting())); | 25 this._topRuler = new WebInspector.DeviceModeView.Ruler(true, this._model.wid
thSetting().set.bind(this._model.widthSetting())); |
| 26 this._topRuler.element.classList.add("device-mode-ruler-top"); | 26 this._topRuler.element.classList.add("device-mode-ruler-top"); |
| 27 this._leftRuler = new WebInspector.DeviceModeView.Ruler(false, this._model.h
eightSetting().set.bind(this._model.heightSetting())); | 27 this._leftRuler = new WebInspector.DeviceModeView.Ruler(false, this._model.h
eightSetting().set.bind(this._model.heightSetting())); |
| 28 this._leftRuler.element.classList.add("device-mode-ruler-left"); | 28 this._leftRuler.element.classList.add("device-mode-ruler-left"); |
| 29 this._createUI(); | 29 this._createUI(); |
| 30 WebInspector.zoomManager.addEventListener(WebInspector.ZoomManager.Events.Zo
omChanged, this._updateUI, this); | 30 WebInspector.zoomManager.addEventListener(WebInspector.ZoomManager.Events.Zo
omChanged, this._zoomChanged, this); |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 WebInspector.DeviceModeView.prototype = { | 33 WebInspector.DeviceModeView.prototype = { |
| 34 _createUI: function() | 34 _createUI: function() |
| 35 { | 35 { |
| 36 this._toolbar = new WebInspector.DeviceModeView.Toolbar(this._model, thi
s._showMediaInspectorSetting, this._showRulersSetting); | 36 this._toolbar = new WebInspector.DeviceModeView.Toolbar(this._model, thi
s._showMediaInspectorSetting, this._showRulersSetting); |
| 37 this.contentElement.appendChild(this._toolbar.element()); | 37 this.contentElement.appendChild(this._toolbar.element()); |
| 38 | 38 |
| 39 this._contentClip = this.contentElement.createChild("div", "device-mode-
content-clip vbox"); | 39 this._contentClip = this.contentElement.createChild("div", "device-mode-
content-clip vbox"); |
| 40 this._mediaInspectorContainer = this._contentClip.createChild("div", "de
vice-mode-media-container"); | 40 this._mediaInspectorContainer = this._contentClip.createChild("div", "de
vice-mode-media-container"); |
| 41 this._contentArea = this._contentClip.createChild("div", "device-mode-co
ntent-area"); | 41 this._contentArea = this._contentClip.createChild("div", "device-mode-co
ntent-area"); |
| 42 | 42 |
| 43 this._screenArea = this._contentArea.createChild("div", "device-mode-scr
een-area"); | 43 this._screenArea = this._contentArea.createChild("div", "device-mode-scr
een-area"); |
| 44 this._screenImage = this._screenArea.createChild("img", "device-mode-scr
een-image hidden"); | 44 this._screenImage = this._screenArea.createChild("img", "device-mode-scr
een-image hidden"); |
| 45 this._screenImage.addEventListener("load", this._onScreenImageLoaded.bin
d(this, true), false); | 45 this._screenImage.addEventListener("load", this._onScreenImageLoaded.bin
d(this, true), false); |
| 46 this._screenImage.addEventListener("error", this._onScreenImageLoaded.bi
nd(this, false), false); | 46 this._screenImage.addEventListener("error", this._onScreenImageLoaded.bi
nd(this, false), false); |
| 47 | 47 |
| 48 this._cornerResizerElement = this._screenArea.createChild("div", "device
-mode-resizer device-mode-corner-resizer"); | 48 this._cornerResizerElement = this._screenArea.createChild("div", "device
-mode-resizer device-mode-corner-resizer"); |
| 49 this._cornerResizerElement.createChild("div", ""); | 49 this._cornerResizerElement.createChild("div", ""); |
| 50 this._createResizer(this._cornerResizerElement, true, true); | 50 this._createResizer(this._cornerResizerElement, true, true); |
| 51 | 51 |
| 52 this._widthResizerElement = this._screenArea.createChild("div", "device-
mode-resizer device-mode-width-resizer"); | 52 this._widthResizerElement = this._screenArea.createChild("div", "device-
mode-resizer device-mode-width-resizer"); |
| 53 this._widthResizerElement.createChild("div", ""); | 53 this._widthResizerElement.createChild("div", ""); |
| 54 this._createResizer(this._widthResizerElement, true, false); | 54 this._createResizer(this._widthResizerElement, true, false); |
| 55 | 55 |
| 56 this._heightResizerElement = this._screenArea.createChild("div", "device
-mode-resizer device-mode-height-resizer"); | 56 this._heightResizerElement = this._screenArea.createChild("div", "device
-mode-resizer device-mode-height-resizer"); |
| 57 this._heightResizerElement.createChild("div", ""); | 57 this._heightResizerElement.createChild("div", ""); |
| 58 this._createResizer(this._heightResizerElement, false, true); | 58 this._createResizer(this._heightResizerElement, false, true); |
| 59 this._heightResizerElement.addEventListener("dblclick", this._model.heig
htSetting().set.bind(this._model.heightSetting(), 0), false); | 59 this._heightResizerElement.addEventListener("dblclick", this._model.heig
htSetting().set.bind(this._model.heightSetting(), 0), false); |
| 60 this._heightResizerElement.title = WebInspector.UIString("Double-click f
or full height"); |
| 60 | 61 |
| 61 this._pageArea = this._screenArea.createChild("div", "device-mode-page-a
rea"); | 62 this._pageArea = this._screenArea.createChild("div", "device-mode-page-a
rea"); |
| 62 this._pageArea.createChild("content"); | 63 this._pageArea.createChild("content"); |
| 63 }, | 64 }, |
| 64 | 65 |
| 65 toggleDeviceMode: function() | 66 toggleDeviceMode: function() |
| 66 { | 67 { |
| 67 this._toolbar.toggleDeviceMode(); | 68 this._toolbar.toggleDeviceMode(); |
| 68 }, | 69 }, |
| 69 | 70 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 */ | 249 */ |
| 249 _onScreenImageLoaded: function(success) | 250 _onScreenImageLoaded: function(success) |
| 250 { | 251 { |
| 251 this._screenImage.classList.toggle("hidden", !success); | 252 this._screenImage.classList.toggle("hidden", !success); |
| 252 }, | 253 }, |
| 253 | 254 |
| 254 _contentAreaResized: function() | 255 _contentAreaResized: function() |
| 255 { | 256 { |
| 256 var zoomFactor = WebInspector.zoomManager.zoomFactor(); | 257 var zoomFactor = WebInspector.zoomManager.zoomFactor(); |
| 257 var rect = this._contentArea.getBoundingClientRect(); | 258 var rect = this._contentArea.getBoundingClientRect(); |
| 258 var handleWidth = this._widthResizerElement.offsetWidth; | 259 this._handleWidth = this._handleWidth || this._widthResizerElement.offse
tWidth; |
| 259 var handleHeight = this._heightResizerElement.offsetHeight; | 260 this._handleHeight = this._handleHeight || this._heightResizerElement.of
fsetHeight; |
| 260 var availableSize = new Size(Math.max(rect.width * zoomFactor, 1), Math.
max(rect.height * zoomFactor, 1)); | 261 var availableSize = new Size(Math.max(rect.width * zoomFactor, 1), Math.
max(rect.height * zoomFactor, 1)); |
| 261 var preferredSize = new Size(Math.max((rect.width - 2 * handleWidth) * z
oomFactor, 1), Math.max((rect.height - handleHeight) * zoomFactor, 1)); | 262 var preferredSize = new Size(Math.max((rect.width - 2 * this._handleWidt
h) * zoomFactor, 1), Math.max((rect.height - this._handleHeight) * zoomFactor, 1
)); |
| 262 this._model.setAvailableSize(availableSize, preferredSize); | 263 this._model.setAvailableSize(availableSize, preferredSize); |
| 263 }, | 264 }, |
| 264 | 265 |
| 266 _zoomChanged: function() |
| 267 { |
| 268 delete this._handleWidth; |
| 269 delete this._handleHeight; |
| 270 if (this.isShowing()) |
| 271 this._contentAreaResized(); |
| 272 }, |
| 273 |
| 265 /** | 274 /** |
| 266 * @override | 275 * @override |
| 267 */ | 276 */ |
| 268 onResize: function() | 277 onResize: function() |
| 269 { | 278 { |
| 270 if (this.isShowing()) | 279 if (this.isShowing()) |
| 271 this._contentAreaResized(); | 280 this._contentAreaResized(); |
| 272 }, | 281 }, |
| 273 | 282 |
| 274 /** | 283 /** |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 | 339 |
| 331 var middle = this._element.createChild("div", "device-mode-toolbar-middle-co
ntainer"); | 340 var middle = this._element.createChild("div", "device-mode-toolbar-middle-co
ntainer"); |
| 332 this._noneToolbar = this._wrapMiddleToolbar(middle, this._createNoneToolbar(
)); | 341 this._noneToolbar = this._wrapMiddleToolbar(middle, this._createNoneToolbar(
)); |
| 333 this._responsiveToolbar = this._wrapMiddleToolbar(middle, this._createRespon
siveToolbar()); | 342 this._responsiveToolbar = this._wrapMiddleToolbar(middle, this._createRespon
siveToolbar()); |
| 334 this._deviceToolbar = this._wrapMiddleToolbar(middle, this._createDeviceTool
bar()); | 343 this._deviceToolbar = this._wrapMiddleToolbar(middle, this._createDeviceTool
bar()); |
| 335 | 344 |
| 336 var rightContainer = this._element.createChild("div", "device-mode-toolbar-r
ight"); | 345 var rightContainer = this._element.createChild("div", "device-mode-toolbar-r
ight"); |
| 337 rightContainer.createChild("div", "device-mode-toolbar-spacer"); | 346 rightContainer.createChild("div", "device-mode-toolbar-spacer"); |
| 338 var rightToolbar = new WebInspector.Toolbar("", rightContainer); | 347 var rightToolbar = new WebInspector.Toolbar("", rightContainer); |
| 339 rightToolbar.makeWrappable(true); | 348 rightToolbar.makeWrappable(true); |
| 349 this._uaItem = new WebInspector.ToolbarLabel(); |
| 350 this._uaItem.setVisible(false); |
| 351 this._uaItem.setTitle(WebInspector.UIString("User agent type")); |
| 352 rightToolbar.appendToolbarItem(this._uaItem); |
| 353 this._deviceScaleItem = new WebInspector.ToolbarLabel(); |
| 354 this._deviceScaleItem.setVisible(false); |
| 355 this._deviceScaleItem.setTitle(WebInspector.UIString("Device pixel ratio")); |
| 356 rightToolbar.appendToolbarItem(this._deviceScaleItem); |
| 340 rightToolbar.appendSeparator(); | 357 rightToolbar.appendSeparator(); |
| 341 var moreOptionsButton = new WebInspector.ToolbarMenuButton(this._appendMenuI
tems.bind(this)); | 358 var moreOptionsButton = new WebInspector.ToolbarMenuButton(this._appendMenuI
tems.bind(this)); |
| 342 moreOptionsButton.setTitle(WebInspector.UIString("More options")); | 359 moreOptionsButton.setTitle(WebInspector.UIString("More options")); |
| 343 rightToolbar.appendToolbarItem(moreOptionsButton); | 360 rightToolbar.appendToolbarItem(moreOptionsButton); |
| 344 | 361 |
| 345 this._persistenceSetting = WebInspector.settings.createSetting("emulation.de
viceModeViewPersistence", {type: WebInspector.DeviceModeModel.Type.None, device:
"", orientation: "", mode: ""}); | 362 this._persistenceSetting = WebInspector.settings.createSetting("emulation.de
viceModeViewPersistence", {type: WebInspector.DeviceModeModel.Type.None, device:
"", orientation: "", mode: ""}); |
| 346 this._restored = false; | 363 this._restored = false; |
| 347 } | 364 } |
| 348 | 365 |
| 349 WebInspector.DeviceModeView.Toolbar.prototype = { | 366 WebInspector.DeviceModeView.Toolbar.prototype = { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 widthInput.title = WebInspector.UIString("Width"); | 402 widthInput.title = WebInspector.UIString("Width"); |
| 386 WebInspector.SettingsUI.bindSettingInputField(widthInput, this._model.wi
dthSetting(), true, WebInspector.DeviceModeModel.deviceSizeValidator, true); | 403 WebInspector.SettingsUI.bindSettingInputField(widthInput, this._model.wi
dthSetting(), true, WebInspector.DeviceModeModel.deviceSizeValidator, true); |
| 387 toolbar.appendToolbarItem(this._wrapToolbarItem(widthInput)); | 404 toolbar.appendToolbarItem(this._wrapToolbarItem(widthInput)); |
| 388 | 405 |
| 389 var xElement = createElementWithClass("div", "device-mode-x"); | 406 var xElement = createElementWithClass("div", "device-mode-x"); |
| 390 xElement.textContent = "\u00D7"; | 407 xElement.textContent = "\u00D7"; |
| 391 toolbar.appendToolbarItem(this._wrapToolbarItem(xElement)); | 408 toolbar.appendToolbarItem(this._wrapToolbarItem(xElement)); |
| 392 | 409 |
| 393 var heightInput = createElementWithClass("input", "device-mode-size-inpu
t"); | 410 var heightInput = createElementWithClass("input", "device-mode-size-inpu
t"); |
| 394 heightInput.maxLength = 5; | 411 heightInput.maxLength = 5; |
| 395 heightInput.title = WebInspector.UIString("Height (leave empty to fit)")
; | 412 heightInput.title = WebInspector.UIString("Height (leave empty for full)
"); |
| 396 WebInspector.SettingsUI.bindSettingInputField(heightInput, this._model.h
eightSetting(), true, validateHeight, true, true); | 413 WebInspector.SettingsUI.bindSettingInputField(heightInput, this._model.h
eightSetting(), true, validateHeight, true, true); |
| 397 toolbar.appendToolbarItem(this._wrapToolbarItem(heightInput)); | 414 toolbar.appendToolbarItem(this._wrapToolbarItem(heightInput)); |
| 398 this._heightInput = heightInput; | 415 this._heightInput = heightInput; |
| 399 | 416 |
| 400 toolbar.appendSeparator(); | 417 toolbar.appendSeparator(); |
| 401 this._appendScaleItem(toolbar); | 418 this._appendScaleItem(toolbar); |
| 402 return toolbar; | 419 return toolbar; |
| 403 | 420 |
| 404 /** | 421 /** |
| 405 * @param {string} value | 422 * @param {string} value |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 | 462 |
| 446 /** | 463 /** |
| 447 * @param {!WebInspector.Toolbar} toolbar | 464 * @param {!WebInspector.Toolbar} toolbar |
| 448 */ | 465 */ |
| 449 _appendScaleItem: function(toolbar) | 466 _appendScaleItem: function(toolbar) |
| 450 { | 467 { |
| 451 var scaleItem = new WebInspector.ToolbarMenuButton(this._appendScaleMenu
Items.bind(this)); | 468 var scaleItem = new WebInspector.ToolbarMenuButton(this._appendScaleMenu
Items.bind(this)); |
| 452 scaleItem.setTitle(WebInspector.UIString("Click to change zoom")); | 469 scaleItem.setTitle(WebInspector.UIString("Click to change zoom")); |
| 453 scaleItem.setGlyph(""); | 470 scaleItem.setGlyph(""); |
| 454 scaleItem.setBold(false); | 471 scaleItem.setBold(false); |
| 472 scaleItem.setDimmed(true); |
| 455 scaleItem.addDropDownArrow(); | 473 scaleItem.addDropDownArrow(); |
| 456 toolbar.appendToolbarItem(scaleItem); | 474 toolbar.appendToolbarItem(scaleItem); |
| 457 this._scaleItems.push(scaleItem); | 475 this._scaleItems.push(scaleItem); |
| 458 }, | 476 }, |
| 459 | 477 |
| 460 /** | 478 /** |
| 461 * @param {!WebInspector.ContextMenu} contextMenu | 479 * @param {!WebInspector.ContextMenu} contextMenu |
| 462 */ | 480 */ |
| 463 _appendScaleMenuItems: function(contextMenu) | 481 _appendScaleMenuItems: function(contextMenu) |
| 464 { | 482 { |
| 465 var scaleSetting = this._model.scaleSetting(); | 483 var scaleSetting = this._model.scaleSetting(); |
| 466 appendScaleItem(WebInspector.UIString("25%"), 0.25); | 484 appendScaleItem(WebInspector.UIString("25%"), 0.25); |
| 467 appendScaleItem(WebInspector.UIString("50%"), 0.5); | 485 appendScaleItem(WebInspector.UIString("50%"), 0.5); |
| 468 appendScaleItem(WebInspector.UIString("100%"), 1); | 486 appendScaleItem(WebInspector.UIString("100%"), 1); |
| 469 appendScaleItem(WebInspector.UIString("150%"), 1.5); | 487 appendScaleItem(WebInspector.UIString("150%"), 1.5); |
| 470 appendScaleItem(WebInspector.UIString("200%"), 2); | 488 appendScaleItem(WebInspector.UIString("200%"), 2); |
| 471 contextMenu.appendSeparator(); | 489 contextMenu.appendSeparator(); |
| 472 contextMenu.appendItem(WebInspector.UIString("Fit (%.0f%%)", this._model
.fitScale() * 100), scaleSetting.set.bind(scaleSetting, this._model.fitScale()),
false); | 490 contextMenu.appendItem(WebInspector.UIString("Fit to window (%.0f%%)", t
his._model.fitScale() * 100), scaleSetting.set.bind(scaleSetting, this._model.fi
tScale()), false); |
| 473 | 491 |
| 474 /** | 492 /** |
| 475 * @param {string} title | 493 * @param {string} title |
| 476 * @param {number} value | 494 * @param {number} value |
| 477 */ | 495 */ |
| 478 function appendScaleItem(title, value) | 496 function appendScaleItem(title, value) |
| 479 { | 497 { |
| 480 contextMenu.appendCheckboxItem(title, scaleSetting.set.bind(scaleSet
ting, value), scaleSetting.get() === value, false); | 498 contextMenu.appendCheckboxItem(title, scaleSetting.set.bind(scaleSet
ting, value), scaleSetting.get() === value, false); |
| 481 } | 499 } |
| 482 }, | 500 }, |
| 483 | 501 |
| 484 /** | 502 /** |
| 485 * @param {!WebInspector.ContextMenu} contextMenu | 503 * @param {!WebInspector.ContextMenu} contextMenu |
| 486 */ | 504 */ |
| 487 _appendMenuItems: function(contextMenu) | 505 _appendMenuItems: function(contextMenu) |
| 488 { | 506 { |
| 489 var uaDisabled = this._model.type() !== WebInspector.DeviceModeModel.Typ
e.Responsive; | 507 var uaDisabled = this._model.type() !== WebInspector.DeviceModeModel.Typ
e.Responsive; |
| 490 var uaSetting = this._model.uaSetting(); | 508 var uaSetting = this._model.uaSetting(); |
| 491 var uaSubmenu = contextMenu.appendSubMenuItem(WebInspector.UIString("Use
r agent type"), false); | 509 var uaSubmenu = contextMenu.appendSubMenuItem(WebInspector.UIString("Use
r agent type"), false); |
| 492 var uaValue = this._model.uaSetting().get(); | 510 var uaValue = this._model.uaSetting().get(); |
| 493 if (this._model.type() === WebInspector.DeviceModeModel.Type.None) | 511 if (this._model.type() === WebInspector.DeviceModeModel.Type.None) |
| 494 uaValue = WebInspector.DeviceModeModel.UA.Desktop; | 512 uaValue = WebInspector.DeviceModeModel.UA.Desktop; |
| 495 if (this._model.type() === WebInspector.DeviceModeModel.Type.Device) | 513 if (this._model.type() === WebInspector.DeviceModeModel.Type.Device) |
| 496 uaValue = this._model.device().mobile() ? WebInspector.DeviceModeMod
el.UA.Mobile : this._model.device().touch() ? WebInspector.DeviceModeModel.UA.De
sktopTouch : WebInspector.DeviceModeModel.UA.Desktop; | 514 uaValue = this._model.device().mobile() ? WebInspector.DeviceModeMod
el.UA.Mobile : this._model.device().touch() ? WebInspector.DeviceModeModel.UA.De
sktopTouch : WebInspector.DeviceModeModel.UA.Desktop; |
| 497 appendUAItem(WebInspector.UIString("Mobile"), WebInspector.DeviceModeMod
el.UA.Mobile); | 515 appendUAItem(WebInspector.UIString("Mobile (default)"), WebInspector.Dev
iceModeModel.UA.Mobile); |
| 498 appendUAItem(WebInspector.UIString("Desktop"), WebInspector.DeviceModeMo
del.UA.Desktop); | 516 appendUAItem(WebInspector.UIString("Desktop"), WebInspector.DeviceModeMo
del.UA.Desktop); |
| 499 appendUAItem(WebInspector.UIString("Desktop with touch"), WebInspector.D
eviceModeModel.UA.DesktopTouch); | 517 appendUAItem(WebInspector.UIString("Desktop with touch"), WebInspector.D
eviceModeModel.UA.DesktopTouch); |
| 500 | 518 |
| 501 /** | 519 /** |
| 502 * @param {string} title | 520 * @param {string} title |
| 503 * @param {!WebInspector.DeviceModeModel.UA} value | 521 * @param {!WebInspector.DeviceModeModel.UA} value |
| 504 */ | 522 */ |
| 505 function appendUAItem(title, value) | 523 function appendUAItem(title, value) |
| 506 { | 524 { |
| 507 uaSubmenu.appendCheckboxItem(title, uaSetting.set.bind(uaSetting, va
lue), uaValue === value, uaDisabled); | 525 uaSubmenu.appendCheckboxItem(title, uaSetting.set.bind(uaSetting, va
lue), uaValue === value, uaDisabled); |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 this._heightInput.placeholder = size.height; | 808 this._heightInput.placeholder = size.height; |
| 791 this._cachedSize = size; | 809 this._cachedSize = size; |
| 792 } | 810 } |
| 793 | 811 |
| 794 if (this._model.scale() !== this._cachedScale) { | 812 if (this._model.scale() !== this._cachedScale) { |
| 795 for (var item of this._scaleItems) | 813 for (var item of this._scaleItems) |
| 796 item.setText(WebInspector.UIString("%.0f%%", this._model.scale()
* 100)); | 814 item.setText(WebInspector.UIString("%.0f%%", this._model.scale()
* 100)); |
| 797 this._cachedScale = this._model.scale(); | 815 this._cachedScale = this._model.scale(); |
| 798 } | 816 } |
| 799 | 817 |
| 818 var offscreen = this._model.screenRect().width > this._model.visiblePage
Rect().width || this._model.screenRect().height > this._model.visiblePageRect().
height; |
| 819 if (offscreen !== this._cachedOffscreen) { |
| 820 for (var item of this._scaleItems) |
| 821 item.setDimmed(!offscreen); |
| 822 this._cachedOffscreen = offscreen; |
| 823 } |
| 824 |
| 825 var deviceScale = this._model.deviceScaleFactorSetting().get(); |
| 826 if (deviceScale !== this._cachedDeviceScale) { |
| 827 this._deviceScaleItem.setVisible(!!deviceScale); |
| 828 this._deviceScaleItem.setText(WebInspector.UIString("DPR: %.1f", dev
iceScale)); |
| 829 this._cachedDeviceScale = deviceScale; |
| 830 } |
| 831 |
| 832 var uaType = this._model.type() === WebInspector.DeviceModeModel.Type.Re
sponsive ? this._model.uaSetting().get() : WebInspector.DeviceModeModel.UA.Mobil
e; |
| 833 if (uaType !== this._cachedUaType) { |
| 834 this._uaItem.setVisible(uaType !== WebInspector.DeviceModeModel.UA.M
obile); |
| 835 this._uaItem.setText(uaType === WebInspector.DeviceModeModel.UA.Desk
top ? WebInspector.UIString("Desktop") : WebInspector.UIString("Touch")); |
| 836 this._cachedUaType = uaType; |
| 837 } |
| 838 |
| 800 if (this._model.device() !== this._cachedModelDevice) { | 839 if (this._model.device() !== this._cachedModelDevice) { |
| 801 var device = this._model.device(); | 840 var device = this._model.device(); |
| 802 | 841 |
| 803 if (device) { | 842 if (device) { |
| 804 var modeCount = device ? device.modes.length : 0; | 843 var modeCount = device ? device.modes.length : 0; |
| 805 this._modeButton.setEnabled(modeCount >= 2); | 844 this._modeButton.setEnabled(modeCount >= 2); |
| 806 this._modeButton.setTitle(modeCount === 2 ? WebInspector.UIStrin
g("Rotate") : WebInspector.UIString("Screen options")); | 845 this._modeButton.setTitle(modeCount === 2 ? WebInspector.UIStrin
g("Rotate") : WebInspector.UIString("Screen options")); |
| 807 } | 846 } |
| 808 this._updateDeviceSelectedIndex(); | 847 this._updateDeviceSelectedIndex(); |
| 809 | 848 |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 } else { | 1093 } else { |
| 1055 this._deviceModeView.detach(); | 1094 this._deviceModeView.detach(); |
| 1056 this._inspectedPagePlaceholder.restoreMinimumSizeAndMargins(); | 1095 this._inspectedPagePlaceholder.restoreMinimumSizeAndMargins(); |
| 1057 this._inspectedPagePlaceholder.show(this.element); | 1096 this._inspectedPagePlaceholder.show(this.element); |
| 1058 this._deviceModeView._model.emulate(WebInspector.DeviceModeModel.Typ
e.None, null, null); | 1097 this._deviceModeView._model.emulate(WebInspector.DeviceModeModel.Typ
e.None, null, null); |
| 1059 } | 1098 } |
| 1060 }, | 1099 }, |
| 1061 | 1100 |
| 1062 __proto__: WebInspector.VBox.prototype | 1101 __proto__: WebInspector.VBox.prototype |
| 1063 } | 1102 } |
| OLD | NEW |