Chromium Code Reviews| 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 308 */ | 308 */ |
| 309 WebInspector.DeviceModeView.Toolbar = function(model, showMediaInspectorSetting, showRulersSetting) | 309 WebInspector.DeviceModeView.Toolbar = function(model, showMediaInspectorSetting, showRulersSetting) |
| 310 { | 310 { |
| 311 this._model = model; | 311 this._model = model; |
| 312 this._showMediaInspectorSetting = showMediaInspectorSetting; | 312 this._showMediaInspectorSetting = showMediaInspectorSetting; |
| 313 this._showRulersSetting = showRulersSetting; | 313 this._showRulersSetting = showRulersSetting; |
| 314 /** @type {!Map<!WebInspector.EmulatedDevice, !WebInspector.EmulatedDevice.M ode>} */ | 314 /** @type {!Map<!WebInspector.EmulatedDevice, !WebInspector.EmulatedDevice.M ode>} */ |
| 315 this._lastMode = new Map(); | 315 this._lastMode = new Map(); |
| 316 /** @type {?WebInspector.EmulatedDevice} */ | 316 /** @type {?WebInspector.EmulatedDevice} */ |
| 317 this._lastDevice = null; | 317 this._lastDevice = null; |
| 318 /** @type {!Array<!WebInspector.ToolbarLabel>} */ | 318 /** @type {!Array<!WebInspector.ToolbarButton>} */ |
| 319 this._appliedSizeItems = []; | 319 this._appliedSizeItems = []; |
| 320 /** @type {!Array<!WebInspector.ToolbarMenuButton>} */ | 320 /** @type {!Array<!WebInspector.ToolbarMenuButton>} */ |
| 321 this._scaleItems = []; | 321 this._scaleItems = []; |
| 322 /** @type {?Element} */ | 322 /** @type {?Element} */ |
| 323 this._visibleToolbar = null; | 323 this._visibleToolbar = null; |
| 324 | 324 |
| 325 this._element = createElementWithClass("div", "device-mode-toolbar"); | 325 this._element = createElementWithClass("div", "device-mode-toolbar"); |
| 326 | 326 |
| 327 var leftContainer = this._element.createChild("div", "device-mode-toolbar-le ft"); | 327 var leftContainer = this._element.createChild("div", "device-mode-toolbar-le ft"); |
| 328 var leftToolbar = new WebInspector.Toolbar("", leftContainer); | 328 var leftToolbar = new WebInspector.Toolbar("", leftContainer); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 339 | 339 |
| 340 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"); |
| 341 this._noneToolbar = this._wrapMiddleToolbar(middle, this._createNoneToolbar( )); | 341 this._noneToolbar = this._wrapMiddleToolbar(middle, this._createNoneToolbar( )); |
| 342 this._responsiveToolbar = this._wrapMiddleToolbar(middle, this._createRespon siveToolbar()); | 342 this._responsiveToolbar = this._wrapMiddleToolbar(middle, this._createRespon siveToolbar()); |
| 343 this._deviceToolbar = this._wrapMiddleToolbar(middle, this._createDeviceTool bar()); | 343 this._deviceToolbar = this._wrapMiddleToolbar(middle, this._createDeviceTool bar()); |
| 344 | 344 |
| 345 var rightContainer = this._element.createChild("div", "device-mode-toolbar-r ight"); | 345 var rightContainer = this._element.createChild("div", "device-mode-toolbar-r ight"); |
| 346 rightContainer.createChild("div", "device-mode-toolbar-spacer"); | 346 rightContainer.createChild("div", "device-mode-toolbar-spacer"); |
| 347 var rightToolbar = new WebInspector.Toolbar("", rightContainer); | 347 var rightToolbar = new WebInspector.Toolbar("", rightContainer); |
| 348 rightToolbar.makeWrappable(true); | 348 rightToolbar.makeWrappable(true); |
| 349 this._uaItem = new WebInspector.ToolbarLabel(); | 349 this._uaItem = new WebInspector.ToolbarText(); |
| 350 this._uaItem.setVisible(false); | 350 this._uaItem.setVisible(false); |
| 351 this._uaItem.setTitle(WebInspector.UIString("User agent type")); | 351 this._uaItem.setTitle(WebInspector.UIString("User agent type")); |
| 352 rightToolbar.appendToolbarItem(this._uaItem); | 352 rightToolbar.appendToolbarItem(this._uaItem); |
| 353 this._deviceScaleItem = new WebInspector.ToolbarLabel(); | 353 this._deviceScaleItem = new WebInspector.ToolbarText(); |
| 354 this._deviceScaleItem.setVisible(false); | 354 this._deviceScaleItem.setVisible(false); |
| 355 this._deviceScaleItem.setTitle(WebInspector.UIString("Device pixel ratio")); | 355 this._deviceScaleItem.setTitle(WebInspector.UIString("Device pixel ratio")); |
| 356 rightToolbar.appendToolbarItem(this._deviceScaleItem); | 356 rightToolbar.appendToolbarItem(this._deviceScaleItem); |
| 357 rightToolbar.appendSeparator(); | 357 rightToolbar.appendSeparator(); |
| 358 var moreOptionsButton = new WebInspector.ToolbarMenuButton(this._appendMenuI tems.bind(this)); | 358 var moreOptionsButton = new WebInspector.ToolbarMenuButton(this._appendMenuI tems.bind(this)); |
| 359 moreOptionsButton.setTitle(WebInspector.UIString("More options")); | 359 moreOptionsButton.setTitle(WebInspector.UIString("More options")); |
| 360 rightToolbar.appendToolbarItem(moreOptionsButton); | 360 rightToolbar.appendToolbarItem(moreOptionsButton); |
| 361 | 361 |
| 362 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: ""}); |
| 363 this._restored = false; | 363 this._restored = false; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 448 this._appendScaleItem(toolbar); | 448 this._appendScaleItem(toolbar); |
| 449 | 449 |
| 450 return toolbar; | 450 return toolbar; |
| 451 }, | 451 }, |
| 452 | 452 |
| 453 /** | 453 /** |
| 454 * @param {!WebInspector.Toolbar} toolbar | 454 * @param {!WebInspector.Toolbar} toolbar |
| 455 */ | 455 */ |
| 456 _appendAppliedSizeItems: function(toolbar) | 456 _appendAppliedSizeItems: function(toolbar) |
| 457 { | 457 { |
| 458 var item = new WebInspector.ToolbarLabel(); | 458 var item = new WebInspector.ToolbarText(""); |
| 459 this._appliedSizeItems.push(item); | 459 this._appliedSizeItems.push(item); |
| 460 toolbar.appendToolbarItem(item); | 460 toolbar.appendToolbarItem(item); |
| 461 }, | 461 }, |
| 462 | 462 |
| 463 /** | 463 /** |
| 464 * @param {!WebInspector.Toolbar} toolbar | 464 * @param {!WebInspector.Toolbar} toolbar |
| 465 */ | 465 */ |
| 466 _appendScaleItem: function(toolbar) | 466 _appendScaleItem: function(toolbar) |
| 467 { | 467 { |
| 468 var scaleItem = new WebInspector.ToolbarMenuButton(this._appendScaleMenu Items.bind(this)); | 468 var scaleItem = new WebInspector.ToolbarMenuButton(this._appendScaleMenu Items.bind(this)); |
| 469 scaleItem.setTitle(WebInspector.UIString("Zoom")); | 469 scaleItem.setTitle(WebInspector.UIString("Zoom")); |
| 470 scaleItem.setGlyph(""); | 470 scaleItem.setGlyph(""); |
| 471 scaleItem.setBold(false); | |
| 472 scaleItem.setDimmed(true); | |
| 473 scaleItem.addDropDownArrow(); | 471 scaleItem.addDropDownArrow(); |
| 474 toolbar.appendToolbarItem(scaleItem); | 472 toolbar.appendToolbarItem(scaleItem); |
| 475 this._scaleItems.push(scaleItem); | 473 this._scaleItems.push(scaleItem); |
| 476 }, | 474 }, |
| 477 | 475 |
| 478 /** | 476 /** |
| 479 * @param {!WebInspector.ContextMenu} contextMenu | 477 * @param {!WebInspector.ContextMenu} contextMenu |
| 480 */ | 478 */ |
| 481 _appendScaleMenuItems: function(contextMenu) | 479 _appendScaleMenuItems: function(contextMenu) |
| 482 { | 480 { |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 806 this._heightInput.placeholder = size.height; | 804 this._heightInput.placeholder = size.height; |
| 807 this._cachedSize = size; | 805 this._cachedSize = size; |
| 808 } | 806 } |
| 809 | 807 |
| 810 if (this._model.scale() !== this._cachedScale) { | 808 if (this._model.scale() !== this._cachedScale) { |
| 811 for (var item of this._scaleItems) | 809 for (var item of this._scaleItems) |
| 812 item.setText(WebInspector.UIString("%.0f%%", this._model.scale() * 100)); | 810 item.setText(WebInspector.UIString("%.0f%%", this._model.scale() * 100)); |
| 813 this._cachedScale = this._model.scale(); | 811 this._cachedScale = this._model.scale(); |
| 814 } | 812 } |
| 815 | 813 |
| 816 var offscreen = this._model.screenRect().width > this._model.visiblePage Rect().width || this._model.screenRect().height > this._model.visiblePageRect(). height; | 814 var offscreen = this._model.screenRect().width > this._model.visiblePage Rect().width || this._model.screenRect().height > this._model.visiblePageRect(). height; |
|
dgozman
2016/01/14 22:05:21
Remove the whole offscreen code then.
| |
| 817 if (offscreen !== this._cachedOffscreen) { | 815 if (offscreen !== this._cachedOffscreen) |
| 818 for (var item of this._scaleItems) | |
| 819 item.setDimmed(!offscreen); | |
| 820 this._cachedOffscreen = offscreen; | 816 this._cachedOffscreen = offscreen; |
| 821 } | |
| 822 | 817 |
| 823 var deviceScale = this._model.deviceScaleFactorSetting().get(); | 818 var deviceScale = this._model.deviceScaleFactorSetting().get(); |
| 824 if (deviceScale !== this._cachedDeviceScale) { | 819 if (deviceScale !== this._cachedDeviceScale) { |
| 825 this._deviceScaleItem.setVisible(!!deviceScale); | 820 this._deviceScaleItem.setVisible(!!deviceScale); |
| 826 this._deviceScaleItem.setText(WebInspector.UIString("DPR: %.1f", dev iceScale)); | 821 this._deviceScaleItem.setText(WebInspector.UIString("DPR: %.1f", dev iceScale)); |
| 827 this._cachedDeviceScale = deviceScale; | 822 this._cachedDeviceScale = deviceScale; |
| 828 } | 823 } |
| 829 | 824 |
| 830 var uaType = this._model.type() === WebInspector.DeviceModeModel.Type.Re sponsive ? this._model.uaSetting().get() : WebInspector.DeviceModeModel.UA.Mobil e; | 825 var uaType = this._model.type() === WebInspector.DeviceModeModel.Type.Re sponsive ? this._model.uaSetting().get() : WebInspector.DeviceModeModel.UA.Mobil e; |
| 831 if (uaType !== this._cachedUaType) { | 826 if (uaType !== this._cachedUaType) { |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1091 } else { | 1086 } else { |
| 1092 this._deviceModeView.detach(); | 1087 this._deviceModeView.detach(); |
| 1093 this._inspectedPagePlaceholder.restoreMinimumSizeAndMargins(); | 1088 this._inspectedPagePlaceholder.restoreMinimumSizeAndMargins(); |
| 1094 this._inspectedPagePlaceholder.show(this.element); | 1089 this._inspectedPagePlaceholder.show(this.element); |
| 1095 this._deviceModeView._model.emulate(WebInspector.DeviceModeModel.Typ e.None, null, null); | 1090 this._deviceModeView._model.emulate(WebInspector.DeviceModeModel.Typ e.None, null, null); |
| 1096 } | 1091 } |
| 1097 }, | 1092 }, |
| 1098 | 1093 |
| 1099 __proto__: WebInspector.VBox.prototype | 1094 __proto__: WebInspector.VBox.prototype |
| 1100 } | 1095 } |
| OLD | NEW |