| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 * @implements {WebInspector.OverridesSupport.PageResizer} | 8 * @implements {WebInspector.OverridesSupport.PageResizer} |
| 9 * @implements {WebInspector.TargetManager.Observer} | 9 * @implements {WebInspector.TargetManager.Observer} |
| 10 * @param {!WebInspector.InspectedPagePlaceholder} inspectedPagePlaceholder | 10 * @param {!WebInspector.InspectedPagePlaceholder} inspectedPagePlaceholder |
| 11 */ | 11 */ |
| 12 WebInspector.ResponsiveDesignView = function(inspectedPagePlaceholder) | 12 WebInspector.ResponsiveDesignView = function(inspectedPagePlaceholder) |
| 13 { | 13 { |
| 14 WebInspector.VBox.call(this); | 14 WebInspector.VBox.call(this); |
| 15 this.setMinimumSize(150, 150); | 15 this.setMinimumSize(150, 150); |
| 16 this.element.classList.add("responsive-design-view"); | 16 this.element.classList.add("responsive-design-view"); |
| 17 if (Runtime.experiments.isEnabled("deviceModes")) |
| 18 this.element.classList.add("device-modes"); |
| 17 this.registerRequiredCSS("emulation/responsiveDesignView.css"); | 19 this.registerRequiredCSS("emulation/responsiveDesignView.css"); |
| 18 | 20 |
| 19 this._showMediaQueryInspectorSetting = WebInspector.settings.createSetting("
showMediaQueryInspector", false); | 21 this._showMediaQueryInspectorSetting = WebInspector.settings.createSetting("
showMediaQueryInspector", false); |
| 20 | 22 |
| 21 this._responsiveDesignContainer = new WebInspector.VBox(); | 23 this._responsiveDesignContainer = new WebInspector.VBox(); |
| 22 this._uiInitialized = false; | 24 this._uiInitialized = false; |
| 23 | 25 |
| 24 this._inspectedPagePlaceholder = inspectedPagePlaceholder; | 26 this._inspectedPagePlaceholder = inspectedPagePlaceholder; |
| 25 inspectedPagePlaceholder.show(this.element); | 27 inspectedPagePlaceholder.show(this.element); |
| 26 | 28 |
| 27 this._enabled = false; | 29 this._enabled = false; |
| 28 this._viewport = { scrollX: 0, scrollY: 0, contentsWidth: 0, contentsHeight:
0, pageScaleFactor: 1, minimumPageScaleFactor: 1, maximumPageScaleFactor: 1 }; | 30 this._viewport = { scrollX: 0, scrollY: 0, contentsWidth: 0, contentsHeight:
0, pageScaleFactor: 1, minimumPageScaleFactor: 1, maximumPageScaleFactor: 1 }; |
| 29 this._drawContentsSize = true; | 31 this._drawContentsSize = true; |
| 32 this._deviceInsets = new Insets(0, 0, 0, 0); |
| 30 this._viewportChangedThrottler = new WebInspector.Throttler(0); | 33 this._viewportChangedThrottler = new WebInspector.Throttler(0); |
| 31 this._pageScaleFactorThrottler = new WebInspector.Throttler(50); | 34 this._pageScaleFactorThrottler = new WebInspector.Throttler(50); |
| 32 | 35 |
| 33 WebInspector.zoomManager.addEventListener(WebInspector.ZoomManager.Events.Zo
omChanged, this._onZoomChanged, this); | 36 WebInspector.zoomManager.addEventListener(WebInspector.ZoomManager.Events.Zo
omChanged, this._onZoomChanged, this); |
| 34 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport
.Events.EmulationStateChanged, this._emulationEnabledChanged, this); | 37 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport
.Events.EmulationStateChanged, this._emulationEnabledChanged, this); |
| 35 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Type.Pag
e); | 38 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Type.Pag
e); |
| 36 this._emulationEnabledChanged(); | 39 this._emulationEnabledChanged(); |
| 37 }; | 40 }; |
| 38 | 41 |
| 39 // Measured in DIP. | 42 // Measured in DIP. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 var genericDeviceOutline = this._slidersContainer.createChild("div", "re
sponsive-design-generic-outline-container"); | 76 var genericDeviceOutline = this._slidersContainer.createChild("div", "re
sponsive-design-generic-outline-container"); |
| 74 genericDeviceOutline.createChild("div", "responsive-design-generic-outli
ne"); | 77 genericDeviceOutline.createChild("div", "responsive-design-generic-outli
ne"); |
| 75 var widthSlider = this._slidersContainer.createChild("div", "responsive-
design-slider-width"); | 78 var widthSlider = this._slidersContainer.createChild("div", "responsive-
design-slider-width"); |
| 76 widthSlider.createChild("div", "responsive-design-thumb-handle"); | 79 widthSlider.createChild("div", "responsive-design-thumb-handle"); |
| 77 this._createResizer(widthSlider, true, false); | 80 this._createResizer(widthSlider, true, false); |
| 78 var heightSlider = this._slidersContainer.createChild("div", "responsive
-design-slider-height"); | 81 var heightSlider = this._slidersContainer.createChild("div", "responsive
-design-slider-height"); |
| 79 heightSlider.createChild("div", "responsive-design-thumb-handle"); | 82 heightSlider.createChild("div", "responsive-design-thumb-handle"); |
| 80 this._createResizer(heightSlider, false, true); | 83 this._createResizer(heightSlider, false, true); |
| 81 var cornerSlider = this._slidersContainer.createChild("div", "responsive
-design-slider-corner"); | 84 var cornerSlider = this._slidersContainer.createChild("div", "responsive
-design-slider-corner"); |
| 82 this._createResizer(cornerSlider, true, true); | 85 this._createResizer(cornerSlider, true, true); |
| 83 this._pageContainer = this._slidersContainer.createChild("div", "vbox fl
ex-auto"); | 86 this._pageContainer = this._slidersContainer.createChild("div", "vbox fl
ex-auto responsive-design-page-container"); |
| 84 | 87 |
| 85 // Page scale controls. | 88 // Page scale controls. |
| 86 this._pageScaleContainer = this._canvasContainer.element.createChild("di
v", "hbox responsive-design-page-scale-container"); | 89 this._pageScaleContainer = this._canvasContainer.element.createChild("di
v", "hbox responsive-design-page-scale-container"); |
| 87 this._decreasePageScaleButton = this._pageScaleContainer.createChild("bu
tton", "responsive-design-page-scale-button responsive-design-page-scale-decreas
e"); | 90 this._decreasePageScaleButton = this._pageScaleContainer.createChild("bu
tton", "responsive-design-page-scale-button responsive-design-page-scale-decreas
e"); |
| 88 this._decreasePageScaleButton.createChild("div", "glyph"); | 91 this._decreasePageScaleButton.createChild("div", "glyph"); |
| 89 this._decreasePageScaleButton.tabIndex = -1; | 92 this._decreasePageScaleButton.tabIndex = -1; |
| 90 this._decreasePageScaleButton.addEventListener("click", this._pageScaleB
uttonClicked.bind(this, false), false); | 93 this._decreasePageScaleButton.addEventListener("click", this._pageScaleB
uttonClicked.bind(this, false), false); |
| 91 | 94 |
| 92 this._pageScaleLabel = this._pageScaleContainer.createChild("label", "re
sponsive-design-page-scale-label"); | 95 this._pageScaleLabel = this._pageScaleContainer.createChild("label", "re
sponsive-design-page-scale-label"); |
| 93 this._pageScaleLabel.title = WebInspector.UIString("For a simpler way to
change the current page scale, hold down Shift and drag with your mouse."); | 96 this._pageScaleLabel.title = WebInspector.UIString("For a simpler way to
change the current page scale, hold down Shift and drag with your mouse."); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 123 { | 126 { |
| 124 }, | 127 }, |
| 125 | 128 |
| 126 _invalidateCache: function() | 129 _invalidateCache: function() |
| 127 { | 130 { |
| 128 delete this._cachedScale; | 131 delete this._cachedScale; |
| 129 delete this._cachedCssCanvasWidth; | 132 delete this._cachedCssCanvasWidth; |
| 130 delete this._cachedCssCanvasHeight; | 133 delete this._cachedCssCanvasHeight; |
| 131 delete this._cachedCssHeight; | 134 delete this._cachedCssHeight; |
| 132 delete this._cachedCssWidth; | 135 delete this._cachedCssWidth; |
| 136 delete this._cachedDeviceInsets; |
| 133 delete this._cachedZoomFactor; | 137 delete this._cachedZoomFactor; |
| 134 delete this._cachedViewport; | 138 delete this._cachedViewport; |
| 135 delete this._cachedDrawContentsSize; | 139 delete this._cachedDrawContentsSize; |
| 136 delete this._cachedMediaInspectorHeight; | 140 delete this._cachedMediaInspectorHeight; |
| 137 delete this._availableSize; | 141 delete this._availableSize; |
| 138 }, | 142 }, |
| 139 | 143 |
| 140 _emulationEnabledChanged: function() | 144 _emulationEnabledChanged: function() |
| 141 { | 145 { |
| 142 var enabled = WebInspector.overridesSupport.emulationEnabled(); | 146 var enabled = WebInspector.overridesSupport.emulationEnabled(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 update: function(dipWidth, dipHeight, scale) | 180 update: function(dipWidth, dipHeight, scale) |
| 177 { | 181 { |
| 178 this._scale = scale; | 182 this._scale = scale; |
| 179 this._dipWidth = dipWidth ? Math.max(dipWidth, 1) : 0; | 183 this._dipWidth = dipWidth ? Math.max(dipWidth, 1) : 0; |
| 180 this._dipHeight = dipHeight ? Math.max(dipHeight, 1) : 0; | 184 this._dipHeight = dipHeight ? Math.max(dipHeight, 1) : 0; |
| 181 this._updateUI(); | 185 this._updateUI(); |
| 182 }, | 186 }, |
| 183 | 187 |
| 184 updatePageResizer: function() | 188 updatePageResizer: function() |
| 185 { | 189 { |
| 186 WebInspector.overridesSupport.setPageResizer(this, this._availableDipSiz
e()); | 190 var available = this._availableDipSize(); |
| 191 WebInspector.overridesSupport.setPageResizer(this, available.size, avail
able.insets); |
| 187 }, | 192 }, |
| 188 | 193 |
| 189 /** | 194 /** |
| 190 * @return {!Size} | 195 * @return {!{size: !Size, insets: !Insets}} |
| 191 */ | 196 */ |
| 192 _availableDipSize: function() | 197 _availableDipSize: function() |
| 193 { | 198 { |
| 194 if (typeof this._availableSize === "undefined") { | 199 if (typeof this._availableSize === "undefined") { |
| 195 if (!this._enabled) | 200 if (!this._enabled) |
| 196 return new Size(1, 1); | 201 return {size: new Size(1, 1), insets: new Insets(0, 0, 0, 0)}; |
| 197 var zoomFactor = WebInspector.zoomManager.zoomFactor(); | 202 var zoomFactor = WebInspector.zoomManager.zoomFactor(); |
| 198 var rect = this._canvasContainer.element.getBoundingClientRect(); | 203 var rect = this._canvasContainer.element.getBoundingClientRect(); |
| 199 var rulerTotalHeight = this._rulerTotalHeightDIP(); | 204 var rulerTotalHeight = this._rulerTotalHeightDIP(); |
| 200 this._availableSize = new Size(Math.max(rect.width * zoomFactor - We
bInspector.ResponsiveDesignView.RulerWidth, 1), | 205 this._availableSize = {size: new Size(Math.max(rect.width * zoomFact
or - WebInspector.ResponsiveDesignView.RulerWidth, 1), |
| 201 Math.max(rect.height * zoomFactor - r
ulerTotalHeight, 1)); | 206 Math.max(rect.height * zoomFac
tor - rulerTotalHeight, 1)), |
| 207 insets: this._deviceInsets}; |
| 202 } | 208 } |
| 203 return this._availableSize; | 209 return this._availableSize; |
| 204 }, | 210 }, |
| 205 | 211 |
| 206 /** | 212 /** |
| 207 * @param {!Element} element | 213 * @param {!Element} element |
| 208 * @param {boolean} x | 214 * @param {boolean} x |
| 209 * @param {boolean} y | 215 * @param {boolean} y |
| 210 * @return {!WebInspector.ResizerWidget} | 216 * @return {!WebInspector.ResizerWidget} |
| 211 */ | 217 */ |
| 212 _createResizer: function(element, x, y) | 218 _createResizer: function(element, x, y) |
| 213 { | 219 { |
| 214 var resizer = new WebInspector.ResizerWidget(); | 220 var resizer = new WebInspector.ResizerWidget(); |
| 215 resizer.addElement(element); | 221 resizer.addElement(element); |
| 216 resizer.setCursor(x && y ? "nwse-resize" : (x ? "ew-resize" : "ns-resize
")); | 222 resizer.setCursor(x && y ? "nwse-resize" : (x ? "ew-resize" : "ns-resize
")); |
| 217 resizer.addEventListener(WebInspector.ResizerWidget.Events.ResizeStart,
this._onResizeStart, this); | 223 resizer.addEventListener(WebInspector.ResizerWidget.Events.ResizeStart,
this._onResizeStart, this); |
| 218 resizer.addEventListener(WebInspector.ResizerWidget.Events.ResizeUpdate,
this._onResizeUpdate.bind(this, x, y)); | 224 resizer.addEventListener(WebInspector.ResizerWidget.Events.ResizeUpdate,
this._onResizeUpdate.bind(this, x, y)); |
| 219 resizer.addEventListener(WebInspector.ResizerWidget.Events.ResizeEnd, th
is._onResizeEnd, this); | 225 resizer.addEventListener(WebInspector.ResizerWidget.Events.ResizeEnd, th
is._onResizeEnd, this); |
| 220 return resizer; | 226 return resizer; |
| 221 }, | 227 }, |
| 222 | 228 |
| 223 /** | 229 /** |
| 224 * @param {!WebInspector.Event} event | 230 * @param {!WebInspector.Event} event |
| 225 */ | 231 */ |
| 226 _onResizeStart: function(event) | 232 _onResizeStart: function(event) |
| 227 { | 233 { |
| 228 this._drawContentsSize = false; | 234 this._drawContentsSize = false; |
| 229 var available = this._availableDipSize(); | 235 var available = this._availableDipSize().size; |
| 230 this._slowPositionStart = null; | 236 this._slowPositionStart = null; |
| 231 this._resizeStart = { x: this._dipWidth || available.width, y : this._di
pHeight || available.height }; | 237 this._resizeStart = { x: this._dipWidth || available.width, y : this._di
pHeight || available.height }; |
| 232 this.dispatchEventToListeners(WebInspector.OverridesSupport.PageResizer.
Events.FixedScaleRequested, true); | 238 this.dispatchEventToListeners(WebInspector.OverridesSupport.PageResizer.
Events.FixedScaleRequested, true); |
| 233 this._updateUI(); | 239 this._updateUI(); |
| 234 }, | 240 }, |
| 235 | 241 |
| 236 /** | 242 /** |
| 237 * @param {boolean} x | 243 * @param {boolean} x |
| 238 * @param {boolean} y | 244 * @param {boolean} y |
| 239 * @param {!WebInspector.Event} event | 245 * @param {!WebInspector.Event} event |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 return WebInspector.ResponsiveDesignView.RulerTopHeight + WebInspector.R
esponsiveDesignView.RulerBottomHeight + mediaInspectorHeight * WebInspector.zoom
Manager.zoomFactor(); | 474 return WebInspector.ResponsiveDesignView.RulerTopHeight + WebInspector.R
esponsiveDesignView.RulerBottomHeight + mediaInspectorHeight * WebInspector.zoom
Manager.zoomFactor(); |
| 469 }, | 475 }, |
| 470 | 476 |
| 471 _updateUI: function() | 477 _updateUI: function() |
| 472 { | 478 { |
| 473 if (!this._enabled || !this.isShowing()) | 479 if (!this._enabled || !this.isShowing()) |
| 474 return; | 480 return; |
| 475 | 481 |
| 476 var zoomFactor = WebInspector.zoomManager.zoomFactor(); | 482 var zoomFactor = WebInspector.zoomManager.zoomFactor(); |
| 477 var rect = this._canvas.parentElement.getBoundingClientRect(); | 483 var rect = this._canvas.parentElement.getBoundingClientRect(); |
| 478 var availableDip = this._availableDipSize(); | 484 var availableDip = this._availableDipSize().size; |
| 479 var cssCanvasWidth = rect.width; | 485 var cssCanvasWidth = rect.width; |
| 480 var cssCanvasHeight = rect.height; | 486 var cssCanvasHeight = rect.height; |
| 481 var mediaInspectorHeight = this._mediaInspector.isShowing() ? this._medi
aInspector.element.offsetHeight : 0; | 487 var mediaInspectorHeight = this._mediaInspector.isShowing() ? this._medi
aInspector.element.offsetHeight : 0; |
| 482 var rulerTotalHeight = this._rulerTotalHeightDIP(); | 488 var rulerTotalHeight = this._rulerTotalHeightDIP(); |
| 483 | 489 |
| 484 this._mediaInspector.setAxisTransform(this._viewport.scrollX, this._scal
e * this._viewport.pageScaleFactor); | 490 this._mediaInspector.setAxisTransform(this._viewport.scrollX, this._scal
e * this._viewport.pageScaleFactor); |
| 485 | 491 |
| 486 if (this._cachedZoomFactor !== zoomFactor || this._cachedMediaInspectorH
eight !== mediaInspectorHeight) { | 492 if (this._cachedZoomFactor !== zoomFactor || this._cachedMediaInspectorH
eight !== mediaInspectorHeight) { |
| 487 var cssRulerWidth = WebInspector.ResponsiveDesignView.RulerWidth / z
oomFactor + "px"; | 493 var cssRulerWidth = WebInspector.ResponsiveDesignView.RulerWidth / z
oomFactor + "px"; |
| 488 var cssRulerHeight = (mediaInspectorHeight ? WebInspector.Responsive
DesignView.RulerTopHeight : WebInspector.ResponsiveDesignView.RulerHeight) / zoo
mFactor + "px"; | 494 var cssRulerHeight = (mediaInspectorHeight ? WebInspector.Responsive
DesignView.RulerTopHeight : WebInspector.ResponsiveDesignView.RulerHeight) / zoo
mFactor + "px"; |
| 489 var cssCanvasOffset = rulerTotalHeight / zoomFactor + "px"; | 495 var cssCanvasOffset = rulerTotalHeight / zoomFactor + "px"; |
| 490 this._slidersContainer.style.left = cssRulerWidth; | 496 this._slidersContainer.style.left = cssRulerWidth; |
| 491 this._slidersContainer.style.top = cssCanvasOffset; | 497 this._slidersContainer.style.top = cssCanvasOffset; |
| 492 this._warningInfobar.element.style.height = cssCanvasOffset; | 498 this._warningInfobar.element.style.height = cssCanvasOffset; |
| 493 this._pageScaleContainer.style.top = cssCanvasOffset; | 499 this._pageScaleContainer.style.top = cssCanvasOffset; |
| 494 this._mediaInspectorContainer.style.left = cssRulerWidth; | 500 this._mediaInspectorContainer.style.left = cssRulerWidth; |
| 495 this._mediaInspectorContainer.style.marginTop = cssRulerHeight; | 501 this._mediaInspectorContainer.style.marginTop = cssRulerHeight; |
| 496 } | 502 } |
| 497 | 503 |
| 498 var cssWidth = (this._dipWidth ? this._dipWidth : availableDip.width) /
zoomFactor; | 504 var cssWidth = (this._dipWidth ? this._dipWidth : availableDip.width) /
zoomFactor; |
| 499 var cssHeight = (this._dipHeight ? this._dipHeight : availableDip.height
) / zoomFactor; | 505 var cssHeight = (this._dipHeight ? this._dipHeight : availableDip.height
) / zoomFactor; |
| 500 if (this._cachedCssWidth !== cssWidth || this._cachedCssHeight !== cssHe
ight) { | 506 var deviceInsets = new Insets(this._deviceInsets.left * this._scale / zo
omFactor, this._deviceInsets.top * this._scale / zoomFactor, this._deviceInsets.
right * this._scale / zoomFactor, this._deviceInsets.bottom * this._scale / zoom
Factor); |
| 507 cssWidth += deviceInsets.left + deviceInsets.right; |
| 508 cssHeight += deviceInsets.top + deviceInsets.bottom; |
| 509 if (this._cachedCssWidth !== cssWidth || this._cachedCssHeight !== cssHe
ight || !deviceInsets.isEqual(this._cachedDeviceInsets)) { |
| 501 this._slidersContainer.style.width = cssWidth + "px"; | 510 this._slidersContainer.style.width = cssWidth + "px"; |
| 502 this._slidersContainer.style.height = cssHeight + "px"; | 511 this._slidersContainer.style.height = cssHeight + "px"; |
| 512 this._pageContainer.style.paddingLeft = deviceInsets.left + "px"; |
| 513 this._pageContainer.style.paddingTop = deviceInsets.top + "px"; |
| 514 this._pageContainer.style.paddingRight = deviceInsets.right + "px"; |
| 515 this._pageContainer.style.paddingBottom = deviceInsets.bottom + "px"
; |
| 503 this._inspectedPagePlaceholder.onResize(); | 516 this._inspectedPagePlaceholder.onResize(); |
| 504 } | 517 } |
| 505 | 518 |
| 506 var pageScaleVisible = cssWidth + this._pageScaleContainerWidth + WebIns
pector.ResponsiveDesignView.RulerWidth / zoomFactor <= rect.width; | 519 var pageScaleVisible = cssWidth + this._pageScaleContainerWidth + WebIns
pector.ResponsiveDesignView.RulerWidth / zoomFactor <= rect.width; |
| 507 this._pageScaleContainer.classList.toggle("hidden", !pageScaleVisible); | 520 this._pageScaleContainer.classList.toggle("hidden", !pageScaleVisible); |
| 508 | 521 |
| 509 var viewportChanged = !this._cachedViewport | 522 var viewportChanged = !this._cachedViewport |
| 510 || this._cachedViewport.scrollX !== this._viewport.scrollX || this._
cachedViewport.scrollY !== this._viewport.scrollY | 523 || this._cachedViewport.scrollX !== this._viewport.scrollX || this._
cachedViewport.scrollY !== this._viewport.scrollY |
| 511 || this._cachedViewport.contentsWidth !== this._viewport.contentsWid
th || this._cachedViewport.contentsHeight !== this._viewport.contentsHeight | 524 || this._cachedViewport.contentsWidth !== this._viewport.contentsWid
th || this._cachedViewport.contentsHeight !== this._viewport.contentsHeight |
| 512 || this._cachedViewport.pageScaleFactor !== this._viewport.pageScale
Factor | 525 || this._cachedViewport.pageScaleFactor !== this._viewport.pageScale
Factor |
| (...skipping 13 matching lines...) Expand all Loading... |
| 526 this._decreasePageScaleButton.disabled = this._viewport.pageScaleFac
tor <= this._viewport.minimumPageScaleFactor; | 539 this._decreasePageScaleButton.disabled = this._viewport.pageScaleFac
tor <= this._viewport.minimumPageScaleFactor; |
| 527 this._increasePageScaleButton.title = WebInspector.UIString("Scale u
p (maximum %.1f)", this._viewport.maximumPageScaleFactor); | 540 this._increasePageScaleButton.title = WebInspector.UIString("Scale u
p (maximum %.1f)", this._viewport.maximumPageScaleFactor); |
| 528 this._increasePageScaleButton.disabled = this._viewport.pageScaleFac
tor >= this._viewport.maximumPageScaleFactor; | 541 this._increasePageScaleButton.disabled = this._viewport.pageScaleFac
tor >= this._viewport.maximumPageScaleFactor; |
| 529 } | 542 } |
| 530 | 543 |
| 531 this._cachedScale = this._scale; | 544 this._cachedScale = this._scale; |
| 532 this._cachedCssCanvasWidth = cssCanvasWidth; | 545 this._cachedCssCanvasWidth = cssCanvasWidth; |
| 533 this._cachedCssCanvasHeight = cssCanvasHeight; | 546 this._cachedCssCanvasHeight = cssCanvasHeight; |
| 534 this._cachedCssHeight = cssHeight; | 547 this._cachedCssHeight = cssHeight; |
| 535 this._cachedCssWidth = cssWidth; | 548 this._cachedCssWidth = cssWidth; |
| 549 this._cachedDeviceInsets = deviceInsets; |
| 536 this._cachedZoomFactor = zoomFactor; | 550 this._cachedZoomFactor = zoomFactor; |
| 537 this._cachedViewport = this._viewport; | 551 this._cachedViewport = this._viewport; |
| 538 this._cachedDrawContentsSize = this._drawContentsSize; | 552 this._cachedDrawContentsSize = this._drawContentsSize; |
| 539 this._cachedMediaInspectorHeight = mediaInspectorHeight; | 553 this._cachedMediaInspectorHeight = mediaInspectorHeight; |
| 540 }, | 554 }, |
| 541 | 555 |
| 542 onResize: function() | 556 onResize: function() |
| 543 { | 557 { |
| 544 if (!this._enabled || this._ignoreResize) | 558 if (!this._enabled || this._ignoreResize) |
| 545 return; | 559 return; |
| 546 var oldSize = this._availableSize; | 560 var oldSize = this._availableSize; |
| 547 | 561 |
| 548 this._pageScaleContainer.classList.remove("hidden"); | 562 this._pageScaleContainer.classList.remove("hidden"); |
| 549 this._pageScaleContainerWidth = this._pageScaleContainer.offsetWidth; | 563 this._pageScaleContainerWidth = this._pageScaleContainer.offsetWidth; |
| 550 | 564 |
| 551 delete this._availableSize; | 565 delete this._availableSize; |
| 552 var newSize = this._availableDipSize(); | 566 var newSize = this._availableDipSize(); |
| 553 if (!newSize.isEqual(oldSize)) | 567 if (!oldSize || !newSize.size.isEqual(oldSize.size) || !newSize.insets.i
sEqual(oldSize.insets)) |
| 554 this.dispatchEventToListeners(WebInspector.OverridesSupport.PageResi
zer.Events.AvailableSizeChanged, newSize); | 568 this.dispatchEventToListeners(WebInspector.OverridesSupport.PageResi
zer.Events.AvailableSizeChanged, newSize); |
| 555 this._updateUI(); | 569 this._updateUI(); |
| 556 this._inspectedPagePlaceholder.onResize(); | 570 this._inspectedPagePlaceholder.onResize(); |
| 557 }, | 571 }, |
| 558 | 572 |
| 559 _onZoomChanged: function() | 573 _onZoomChanged: function() |
| 560 { | 574 { |
| 561 this._updateUI(); | 575 this._updateUI(); |
| 562 }, | 576 }, |
| 563 | 577 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 { | 616 { |
| 603 var deviceSection = this._toolbarElement.createChild("div", "responsive-
design-section responsive-design-section-device"); | 617 var deviceSection = this._toolbarElement.createChild("div", "responsive-
design-section responsive-design-section-device"); |
| 604 | 618 |
| 605 deviceSection.createChild("div", "responsive-design-section-decorator"); | 619 deviceSection.createChild("div", "responsive-design-section-decorator"); |
| 606 | 620 |
| 607 // Device. | 621 // Device. |
| 608 var deviceElement = deviceSection.createChild("div", "responsive-design-
suite responsive-design-suite-top").createChild("div"); | 622 var deviceElement = deviceSection.createChild("div", "responsive-design-
suite responsive-design-suite-top").createChild("div"); |
| 609 | 623 |
| 610 var fieldsetElement = deviceElement.createChild("fieldset"); | 624 var fieldsetElement = deviceElement.createChild("fieldset"); |
| 611 fieldsetElement.createChild("label").textContent = WebInspector.UIString
("Device"); | 625 fieldsetElement.createChild("label").textContent = WebInspector.UIString
("Device"); |
| 612 var deviceSelectElement = WebInspector.OverridesUI.createDeviceSelect(); | 626 var deviceSelectElement = WebInspector.OverridesUI.createDeviceSelect(""
, this._deviceModeSelected.bind(this)); |
| 613 fieldsetElement.appendChild(deviceSelectElement); | 627 fieldsetElement.appendChild(deviceSelectElement); |
| 614 deviceSelectElement.classList.add("responsive-design-device-select"); | 628 deviceSelectElement.classList.add("responsive-design-device-select"); |
| 615 | 629 |
| 616 var detailsElement = deviceSection.createChild("div", "responsive-design
-suite"); | 630 var detailsElement = deviceSection.createChild("div", "responsive-design
-suite"); |
| 617 | 631 |
| 618 // Dimensions. | 632 // Dimensions. |
| 619 var screenElement = detailsElement.createChild("div", ""); | 633 var screenElement = detailsElement.createChild("div", ""); |
| 620 fieldsetElement = screenElement.createChild("fieldset"); | 634 fieldsetElement = screenElement.createChild("fieldset"); |
| 621 | 635 |
| 622 var emulateResolutionCheckbox = WebInspector.SettingsUI.createSettingChe
ckbox("", WebInspector.overridesSupport.settings.emulateResolution, true, WebIns
pector.UIString("Emulate screen resolution")); | 636 var emulateResolutionCheckbox = WebInspector.SettingsUI.createSettingChe
ckbox("", WebInspector.overridesSupport.settings.emulateResolution, true, WebIns
pector.UIString("Emulate screen resolution")); |
| 623 themeCheckbox(emulateResolutionCheckbox); | 637 themeCheckbox(emulateResolutionCheckbox); |
| 624 fieldsetElement.appendChild(emulateResolutionCheckbox); | 638 fieldsetElement.appendChild(emulateResolutionCheckbox); |
| 625 | 639 |
| 626 var resolutionIcon = fieldsetElement.createChild("div", "responsive-desi
gn-icon responsive-design-icon-resolution"); | 640 var resolutionIcon = fieldsetElement.createChild("div", "responsive-desi
gn-icon responsive-design-icon-resolution"); |
| 627 resolutionIcon.title = WebInspector.UIString("Screen resolution"); | 641 resolutionIcon.title = WebInspector.UIString("Screen resolution"); |
| 628 var resolutionFieldset = WebInspector.SettingsUI.createSettingFieldset(W
ebInspector.overridesSupport.settings.emulateResolution); | 642 var resolutionFieldset = WebInspector.SettingsUI.createSettingFieldset(W
ebInspector.overridesSupport.settings.emulateResolution); |
| 629 fieldsetElement.appendChild(resolutionFieldset); | 643 fieldsetElement.appendChild(resolutionFieldset); |
| 630 | 644 |
| 631 resolutionFieldset.appendChild(WebInspector.SettingsUI.createSettingInpu
tField("", WebInspector.overridesSupport.settings.deviceWidth, true, 4, "3em", W
ebInspector.OverridesSupport.deviceSizeValidator, true, true, WebInspector.UIStr
ing("\u2013"))); | 645 resolutionFieldset.appendChild(WebInspector.SettingsUI.createSettingInpu
tField("", WebInspector.overridesSupport.settings.deviceWidth, true, 4, "3em", W
ebInspector.OverridesSupport.deviceSizeValidator, true, true, WebInspector.UIStr
ing("\u2013"))); |
| 632 resolutionFieldset.createTextChild("\u00D7"); | 646 resolutionFieldset.createTextChild("\u00D7"); |
| 633 resolutionFieldset.appendChild(WebInspector.SettingsUI.createSettingInpu
tField("", WebInspector.overridesSupport.settings.deviceHeight, true, 4, "3em",
WebInspector.OverridesSupport.deviceSizeValidator, true, true, WebInspector.UISt
ring("\u2013"))); | 647 resolutionFieldset.appendChild(WebInspector.SettingsUI.createSettingInpu
tField("", WebInspector.overridesSupport.settings.deviceHeight, true, 4, "3em",
WebInspector.OverridesSupport.deviceSizeValidator, true, true, WebInspector.UISt
ring("\u2013"))); |
| 634 | 648 |
| 635 var swapButton = resolutionFieldset.createChild("button", "responsive-de
sign-icon responsive-design-icon-swap"); | 649 if (!Runtime.experiments.isEnabled("deviceModes")) { |
| 636 swapButton.title = WebInspector.UIString("Swap dimensions"); | 650 var swapButton = resolutionFieldset.createChild("button", "responsiv
e-design-icon responsive-design-icon-swap"); |
| 637 swapButton.addEventListener("click", WebInspector.overridesSupport.swapD
imensions.bind(WebInspector.overridesSupport), false); | 651 swapButton.title = WebInspector.UIString("Swap dimensions"); |
| 652 swapButton.addEventListener("click", WebInspector.overridesSupport.s
wapDimensions.bind(WebInspector.overridesSupport), false); |
| 653 } |
| 638 | 654 |
| 639 // Device pixel ratio. | 655 // Device pixel ratio. |
| 640 detailsElement.createChild("div", "responsive-design-suite-separator"); | 656 detailsElement.createChild("div", "responsive-design-suite-separator"); |
| 641 | 657 |
| 642 var dprElement = detailsElement.createChild("div", ""); | 658 var dprElement = detailsElement.createChild("div", ""); |
| 643 var resolutionFieldset2 = WebInspector.SettingsUI.createSettingFieldset(
WebInspector.overridesSupport.settings.emulateResolution); | 659 var resolutionFieldset2 = WebInspector.SettingsUI.createSettingFieldset(
WebInspector.overridesSupport.settings.emulateResolution); |
| 644 dprElement.appendChild(resolutionFieldset2); | 660 dprElement.appendChild(resolutionFieldset2); |
| 645 var dprButton = resolutionFieldset2.createChild("div", "responsive-desig
n-icon responsive-design-icon-dpr"); | 661 var dprButton = resolutionFieldset2.createChild("div", "responsive-desig
n-icon responsive-design-icon-dpr"); |
| 646 dprButton.title = WebInspector.UIString("Device pixel ratio"); | 662 dprButton.title = WebInspector.UIString("Device pixel ratio"); |
| 647 resolutionFieldset2.appendChild(WebInspector.SettingsUI.createSettingInp
utField("", WebInspector.overridesSupport.settings.deviceScaleFactor, true, 4, "
1.9em", WebInspector.OverridesSupport.deviceScaleFactorValidator, true, true, We
bInspector.UIString("\u2013"))); | 663 var width = Runtime.experiments.isEnabled("deviceModes") ? "2.5em" : "1.
9em"; |
| 664 resolutionFieldset2.appendChild(WebInspector.SettingsUI.createSettingInp
utField("", WebInspector.overridesSupport.settings.deviceScaleFactor, true, 4, w
idth, WebInspector.OverridesSupport.deviceScaleFactorValidator, true, true, WebI
nspector.UIString("\u2013"))); |
| 648 | 665 |
| 649 // Fit to window. | 666 // Fit to window. |
| 650 detailsElement.createChild("div", "responsive-design-suite-separator"); | 667 detailsElement.createChild("div", "responsive-design-suite-separator"); |
| 651 var fitToWindowElement = detailsElement.createChild("div", ""); | 668 var fitToWindowElement = detailsElement.createChild("div", ""); |
| 652 fieldsetElement = fitToWindowElement.createChild("fieldset"); | 669 fieldsetElement = fitToWindowElement.createChild("fieldset"); |
| 653 var fitCheckbox = WebInspector.SettingsUI.createSettingCheckbox(WebInspe
ctor.UIString("Fit"), WebInspector.overridesSupport.settings.deviceFitWindow, tr
ue, WebInspector.UIString("Zoom to fit available space")) | 670 var fitTitle = Runtime.experiments.isEnabled("deviceModes") ? WebInspect
or.UIString("Zoom to fit") : WebInspector.UIString("Fit"); |
| 671 var fitCheckbox = WebInspector.SettingsUI.createSettingCheckbox(fitTitle
, WebInspector.overridesSupport.settings.deviceFitWindow, true, WebInspector.UIS
tring("Zoom to fit available space")) |
| 654 fieldsetElement.appendChild(fitCheckbox); | 672 fieldsetElement.appendChild(fitCheckbox); |
| 655 themeCheckbox(fitCheckbox); | 673 themeCheckbox(fitCheckbox); |
| 656 | 674 |
| 657 /** | 675 /** |
| 658 * @param {!Element} checkbox | 676 * @param {!Element} checkbox |
| 659 */ | 677 */ |
| 660 function themeCheckbox(checkbox) | 678 function themeCheckbox(checkbox) |
| 661 { | 679 { |
| 662 checkbox.checkColor = "rgb(255, 156, 0)"; | 680 checkbox.checkColor = "rgb(255, 156, 0)"; |
| 663 checkbox.backgroundColor = "rgb(102, 102, 102)"; | 681 checkbox.backgroundColor = "rgb(102, 102, 102)"; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 this._warningMessage.textContent = message; | 736 this._warningMessage.textContent = message; |
| 719 this._warningInfobar.setVisible(!!message); | 737 this._warningInfobar.setVisible(!!message); |
| 720 }, | 738 }, |
| 721 | 739 |
| 722 _showEmulationInDrawer: function() | 740 _showEmulationInDrawer: function() |
| 723 { | 741 { |
| 724 WebInspector.Revealer.reveal(WebInspector.overridesSupport); | 742 WebInspector.Revealer.reveal(WebInspector.overridesSupport); |
| 725 }, | 743 }, |
| 726 | 744 |
| 727 /** | 745 /** |
| 746 * @param {?WebInspector.EmulatedDevice} device |
| 747 * @param {?WebInspector.EmulatedDevice.Mode} mode |
| 748 */ |
| 749 _deviceModeSelected: function(device, mode) |
| 750 { |
| 751 if (device && mode) { |
| 752 var orientation = device.orientationByName(mode.orientation); |
| 753 this._deviceInsets = new Insets(mode.pageRect.left, mode.pageRect.to
p, orientation.width - mode.pageRect.left - mode.pageRect.width, orientation.hei
ght - mode.pageRect.top - mode.pageRect.height); |
| 754 } else { |
| 755 this._deviceInsets = new Insets(0, 0, 0, 0); |
| 756 } |
| 757 this.dispatchEventToListeners(WebInspector.OverridesSupport.PageResizer.
Events.InsetsChanged, this._deviceInsets); |
| 758 }, |
| 759 |
| 760 /** |
| 728 * @param {!EmulationAgent.Viewport=} viewport | 761 * @param {!EmulationAgent.Viewport=} viewport |
| 729 */ | 762 */ |
| 730 _viewportChanged: function(viewport) | 763 _viewportChanged: function(viewport) |
| 731 { | 764 { |
| 732 if (viewport) { | 765 if (viewport) { |
| 733 this._viewport = viewport; | 766 this._viewport = viewport; |
| 734 this._viewport.minimumPageScaleFactor = Math.max(0.1, this._viewport
.minimumPageScaleFactor); | 767 this._viewport.minimumPageScaleFactor = Math.max(0.1, this._viewport
.minimumPageScaleFactor); |
| 735 this._viewport.minimumPageScaleFactor = Math.min(this._viewport.mini
mumPageScaleFactor, this._viewport.pageScaleFactor); | 768 this._viewport.minimumPageScaleFactor = Math.min(this._viewport.mini
mumPageScaleFactor, this._viewport.pageScaleFactor); |
| 736 this._viewport.maximumPageScaleFactor = Math.min(10, this._viewport.
maximumPageScaleFactor); | 769 this._viewport.maximumPageScaleFactor = Math.min(10, this._viewport.
maximumPageScaleFactor); |
| 737 this._viewport.maximumPageScaleFactor = Math.max(this._viewport.maxi
mumPageScaleFactor, this._viewport.pageScaleFactor); | 770 this._viewport.maximumPageScaleFactor = Math.max(this._viewport.maxi
mumPageScaleFactor, this._viewport.pageScaleFactor); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 WebInspector.EmulationDispatcher.prototype = { | 839 WebInspector.EmulationDispatcher.prototype = { |
| 807 /** | 840 /** |
| 808 * @override | 841 * @override |
| 809 * @param {!EmulationAgent.Viewport=} viewport | 842 * @param {!EmulationAgent.Viewport=} viewport |
| 810 */ | 843 */ |
| 811 viewportChanged: function(viewport) | 844 viewportChanged: function(viewport) |
| 812 { | 845 { |
| 813 this._responsiveDesignView._viewportChanged(viewport); | 846 this._responsiveDesignView._viewportChanged(viewport); |
| 814 } | 847 } |
| 815 } | 848 } |
| OLD | NEW |