| 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("deviceArt")) |
| 18 this.element.classList.add("device-art"); |
| 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(th
is._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")); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 636 swapButton.addEventListener("click", WebInspector.overridesSupport.swapD
imensions.bind(WebInspector.overridesSupport), false); | 650 swapButton.addEventListener("click", WebInspector.overridesSupport.swapD
imensions.bind(WebInspector.overridesSupport), false); |
| 637 | 651 |
| 638 // Device pixel ratio. | 652 // Device pixel ratio. |
| 639 detailsElement.createChild("div", "responsive-design-suite-separator"); | 653 detailsElement.createChild("div", "responsive-design-suite-separator"); |
| 640 | 654 |
| 641 var dprElement = detailsElement.createChild("div", ""); | 655 var dprElement = detailsElement.createChild("div", ""); |
| 642 var resolutionFieldset2 = WebInspector.SettingsUI.createSettingFieldset(
WebInspector.overridesSupport.settings.emulateResolution); | 656 var resolutionFieldset2 = WebInspector.SettingsUI.createSettingFieldset(
WebInspector.overridesSupport.settings.emulateResolution); |
| 643 dprElement.appendChild(resolutionFieldset2); | 657 dprElement.appendChild(resolutionFieldset2); |
| 644 var dprButton = resolutionFieldset2.createChild("div", "responsive-desig
n-icon responsive-design-icon-dpr"); | 658 var dprButton = resolutionFieldset2.createChild("div", "responsive-desig
n-icon responsive-design-icon-dpr"); |
| 645 dprButton.title = WebInspector.UIString("Device pixel ratio"); | 659 dprButton.title = WebInspector.UIString("Device pixel ratio"); |
| 646 resolutionFieldset2.appendChild(WebInspector.SettingsUI.createSettingInp
utField("", WebInspector.overridesSupport.settings.deviceScaleFactor, true, 4, "
1.9em", WebInspector.OverridesSupport.deviceScaleFactorValidator, true, true, We
bInspector.UIString("\u2013"))); | 660 var width = Runtime.experiments.isEnabled("deviceArt") ? "2.5em" : "1.9e
m"; |
| 661 resolutionFieldset2.appendChild(WebInspector.SettingsUI.createSettingInp
utField("", WebInspector.overridesSupport.settings.deviceScaleFactor, true, 4, w
idth, WebInspector.OverridesSupport.deviceScaleFactorValidator, true, true, WebI
nspector.UIString("\u2013"))); |
| 647 | 662 |
| 648 // Fit to window. | 663 // Fit to window. |
| 649 detailsElement.createChild("div", "responsive-design-suite-separator"); | 664 detailsElement.createChild("div", "responsive-design-suite-separator"); |
| 650 var fitToWindowElement = detailsElement.createChild("div", ""); | 665 var fitToWindowElement = detailsElement.createChild("div", ""); |
| 651 fieldsetElement = fitToWindowElement.createChild("fieldset"); | 666 fieldsetElement = fitToWindowElement.createChild("fieldset"); |
| 652 fieldsetElement.appendChild(WebInspector.SettingsUI.createSettingCheckbo
x(WebInspector.UIString("Fit"), WebInspector.overridesSupport.settings.deviceFit
Window, true, WebInspector.UIString("Zoom to fit available space"))); | 667 var title = Runtime.experiments.isEnabled("deviceArt") ? WebInspector.UI
String("Zoom to fit") : WebInspector.UIString("Fit"); |
| 668 fieldsetElement.appendChild(WebInspector.SettingsUI.createSettingCheckbo
x(title, WebInspector.overridesSupport.settings.deviceFitWindow, true, WebInspec
tor.UIString("Zoom to fit available space"))); |
| 653 }, | 669 }, |
| 654 | 670 |
| 655 _createNetworkSection: function() | 671 _createNetworkSection: function() |
| 656 { | 672 { |
| 657 var networkSection = this._toolbarElement.createChild("div", "responsive
-design-section responsive-design-section-network"); | 673 var networkSection = this._toolbarElement.createChild("div", "responsive
-design-section responsive-design-section-network"); |
| 658 | 674 |
| 659 networkSection.createChild("div", "responsive-design-section-decorator")
; | 675 networkSection.createChild("div", "responsive-design-section-decorator")
; |
| 660 | 676 |
| 661 // Bandwidth. | 677 // Bandwidth. |
| 662 var bandwidthElement = networkSection.createChild("div", "responsive-des
ign-suite responsive-design-suite-top").createChild("div"); | 678 var bandwidthElement = networkSection.createChild("div", "responsive-des
ign-suite responsive-design-suite-top").createChild("div"); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 this._warningMessage.textContent = message; | 721 this._warningMessage.textContent = message; |
| 706 this._warningInfobar.setVisible(!!message); | 722 this._warningInfobar.setVisible(!!message); |
| 707 }, | 723 }, |
| 708 | 724 |
| 709 _showEmulationInDrawer: function() | 725 _showEmulationInDrawer: function() |
| 710 { | 726 { |
| 711 WebInspector.Revealer.reveal(WebInspector.overridesSupport); | 727 WebInspector.Revealer.reveal(WebInspector.overridesSupport); |
| 712 }, | 728 }, |
| 713 | 729 |
| 714 /** | 730 /** |
| 731 * @param {?WebInspector.EmulatedDevice} device |
| 732 * @param {?WebInspector.EmulatedDevice.Mode} mode |
| 733 */ |
| 734 _deviceModeSelected: function(device, mode) |
| 735 { |
| 736 if (device && mode) { |
| 737 var orientation = device.orientationByName(mode.orientation); |
| 738 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); |
| 739 } else { |
| 740 this._deviceInsets = new Insets(0, 0, 0, 0); |
| 741 } |
| 742 this.dispatchEventToListeners(WebInspector.OverridesSupport.PageResizer.
Events.InsetsChanged, this._deviceInsets); |
| 743 }, |
| 744 |
| 745 /** |
| 715 * @param {!EmulationAgent.Viewport=} viewport | 746 * @param {!EmulationAgent.Viewport=} viewport |
| 716 */ | 747 */ |
| 717 _viewportChanged: function(viewport) | 748 _viewportChanged: function(viewport) |
| 718 { | 749 { |
| 719 if (viewport) { | 750 if (viewport) { |
| 720 this._viewport = viewport; | 751 this._viewport = viewport; |
| 721 this._viewport.minimumPageScaleFactor = Math.max(0.1, this._viewport
.minimumPageScaleFactor); | 752 this._viewport.minimumPageScaleFactor = Math.max(0.1, this._viewport
.minimumPageScaleFactor); |
| 722 this._viewport.minimumPageScaleFactor = Math.min(this._viewport.mini
mumPageScaleFactor, this._viewport.pageScaleFactor); | 753 this._viewport.minimumPageScaleFactor = Math.min(this._viewport.mini
mumPageScaleFactor, this._viewport.pageScaleFactor); |
| 723 this._viewport.maximumPageScaleFactor = Math.min(10, this._viewport.
maximumPageScaleFactor); | 754 this._viewport.maximumPageScaleFactor = Math.min(10, this._viewport.
maximumPageScaleFactor); |
| 724 this._viewport.maximumPageScaleFactor = Math.max(this._viewport.maxi
mumPageScaleFactor, this._viewport.pageScaleFactor); | 755 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... |
| 793 WebInspector.EmulationDispatcher.prototype = { | 824 WebInspector.EmulationDispatcher.prototype = { |
| 794 /** | 825 /** |
| 795 * @override | 826 * @override |
| 796 * @param {!EmulationAgent.Viewport=} viewport | 827 * @param {!EmulationAgent.Viewport=} viewport |
| 797 */ | 828 */ |
| 798 viewportChanged: function(viewport) | 829 viewportChanged: function(viewport) |
| 799 { | 830 { |
| 800 this._responsiveDesignView._viewportChanged(viewport); | 831 this._responsiveDesignView._viewportChanged(viewport); |
| 801 } | 832 } |
| 802 } | 833 } |
| OLD | NEW |