| 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 this.registerRequiredCSS("emulation/responsiveDesignView.css"); | 17 this.registerRequiredCSS("emulation/responsiveDesignView.css"); |
| 18 | 18 |
| 19 this._showMediaQueryInspectorSetting = WebInspector.settings.createSetting("
showMediaQueryInspector", false); | 19 this._showMediaQueryInspectorSetting = WebInspector.settings.createSetting("
showMediaQueryInspector", false); |
| 20 | 20 |
| 21 this._responsiveDesignContainer = new WebInspector.VBox(); | 21 this._responsiveDesignContainer = new WebInspector.VBox(); |
| 22 this._uiInitialized = false; | 22 this._uiInitialized = false; |
| 23 | 23 |
| 24 this._inspectedPagePlaceholder = inspectedPagePlaceholder; | 24 this._inspectedPagePlaceholder = inspectedPagePlaceholder; |
| 25 inspectedPagePlaceholder.show(this.element); | 25 inspectedPagePlaceholder.show(this.element); |
| 26 | 26 |
| 27 this._enabled = false; | 27 this._enabled = false; |
| 28 this._viewport = { scrollX: 0, scrollY: 0, contentsWidth: 0, contentsHeight:
0, pageScaleFactor: 1, minimumPageScaleFactor: 1, maximumPageScaleFactor: 1 }; | 28 this._viewport = { scrollX: 0, scrollY: 0, contentsWidth: 0, contentsHeight:
0, pageScaleFactor: 1, minimumPageScaleFactor: 1, maximumPageScaleFactor: 1 }; |
| 29 this._drawContentsSize = true; | 29 this._drawContentsSize = true; |
| 30 this._deviceInsets = new Insets(0, 0, 0, 0); |
| 30 this._viewportChangedThrottler = new WebInspector.Throttler(0); | 31 this._viewportChangedThrottler = new WebInspector.Throttler(0); |
| 31 this._pageScaleFactorThrottler = new WebInspector.Throttler(50); | 32 this._pageScaleFactorThrottler = new WebInspector.Throttler(50); |
| 32 | 33 |
| 33 WebInspector.zoomManager.addEventListener(WebInspector.ZoomManager.Events.Zo
omChanged, this._onZoomChanged, this); | 34 WebInspector.zoomManager.addEventListener(WebInspector.ZoomManager.Events.Zo
omChanged, this._onZoomChanged, this); |
| 34 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport
.Events.EmulationStateChanged, this._emulationEnabledChanged, this); | 35 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport
.Events.EmulationStateChanged, this._emulationEnabledChanged, this); |
| 35 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Type.Pag
e); | 36 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Type.Pag
e); |
| 36 this._emulationEnabledChanged(); | 37 this._emulationEnabledChanged(); |
| 37 }; | 38 }; |
| 38 | 39 |
| 39 // Measured in DIP. | 40 // 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"); | 74 var genericDeviceOutline = this._slidersContainer.createChild("div", "re
sponsive-design-generic-outline-container"); |
| 74 genericDeviceOutline.createChild("div", "responsive-design-generic-outli
ne"); | 75 genericDeviceOutline.createChild("div", "responsive-design-generic-outli
ne"); |
| 75 var widthSlider = this._slidersContainer.createChild("div", "responsive-
design-slider-width"); | 76 var widthSlider = this._slidersContainer.createChild("div", "responsive-
design-slider-width"); |
| 76 widthSlider.createChild("div", "responsive-design-thumb-handle"); | 77 widthSlider.createChild("div", "responsive-design-thumb-handle"); |
| 77 this._createResizer(widthSlider, true, false); | 78 this._createResizer(widthSlider, true, false); |
| 78 var heightSlider = this._slidersContainer.createChild("div", "responsive
-design-slider-height"); | 79 var heightSlider = this._slidersContainer.createChild("div", "responsive
-design-slider-height"); |
| 79 heightSlider.createChild("div", "responsive-design-thumb-handle"); | 80 heightSlider.createChild("div", "responsive-design-thumb-handle"); |
| 80 this._createResizer(heightSlider, false, true); | 81 this._createResizer(heightSlider, false, true); |
| 81 var cornerSlider = this._slidersContainer.createChild("div", "responsive
-design-slider-corner"); | 82 var cornerSlider = this._slidersContainer.createChild("div", "responsive
-design-slider-corner"); |
| 82 this._createResizer(cornerSlider, true, true); | 83 this._createResizer(cornerSlider, true, true); |
| 83 this._pageContainer = this._slidersContainer.createChild("div", "vbox fl
ex-auto"); | 84 this._pageContainer = this._slidersContainer.createChild("div", "vbox fl
ex-auto responsive-design-page-container"); |
| 84 | 85 |
| 85 // Page scale controls. | 86 // Page scale controls. |
| 86 this._pageScaleContainer = this._canvasContainer.element.createChild("di
v", "hbox responsive-design-page-scale-container"); | 87 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"); | 88 this._decreasePageScaleButton = this._pageScaleContainer.createChild("bu
tton", "responsive-design-page-scale-button responsive-design-page-scale-decreas
e"); |
| 88 this._decreasePageScaleButton.createChild("div", "glyph"); | 89 this._decreasePageScaleButton.createChild("div", "glyph"); |
| 89 this._decreasePageScaleButton.tabIndex = -1; | 90 this._decreasePageScaleButton.tabIndex = -1; |
| 90 this._decreasePageScaleButton.addEventListener("click", this._pageScaleB
uttonClicked.bind(this, false), false); | 91 this._decreasePageScaleButton.addEventListener("click", this._pageScaleB
uttonClicked.bind(this, false), false); |
| 91 | 92 |
| 92 this._pageScaleLabel = this._pageScaleContainer.createChild("label", "re
sponsive-design-page-scale-label"); | 93 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."); | 94 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 { | 124 { |
| 124 }, | 125 }, |
| 125 | 126 |
| 126 _invalidateCache: function() | 127 _invalidateCache: function() |
| 127 { | 128 { |
| 128 delete this._cachedScale; | 129 delete this._cachedScale; |
| 129 delete this._cachedCssCanvasWidth; | 130 delete this._cachedCssCanvasWidth; |
| 130 delete this._cachedCssCanvasHeight; | 131 delete this._cachedCssCanvasHeight; |
| 131 delete this._cachedCssHeight; | 132 delete this._cachedCssHeight; |
| 132 delete this._cachedCssWidth; | 133 delete this._cachedCssWidth; |
| 134 delete this._cachedDeviceInsets; |
| 133 delete this._cachedZoomFactor; | 135 delete this._cachedZoomFactor; |
| 134 delete this._cachedViewport; | 136 delete this._cachedViewport; |
| 135 delete this._cachedDrawContentsSize; | 137 delete this._cachedDrawContentsSize; |
| 136 delete this._cachedMediaInspectorHeight; | 138 delete this._cachedMediaInspectorHeight; |
| 137 delete this._availableSize; | 139 delete this._availableSize; |
| 138 }, | 140 }, |
| 139 | 141 |
| 140 _emulationEnabledChanged: function() | 142 _emulationEnabledChanged: function() |
| 141 { | 143 { |
| 142 var enabled = WebInspector.overridesSupport.emulationEnabled(); | 144 var enabled = WebInspector.overridesSupport.emulationEnabled(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 update: function(dipWidth, dipHeight, scale) | 178 update: function(dipWidth, dipHeight, scale) |
| 177 { | 179 { |
| 178 this._scale = scale; | 180 this._scale = scale; |
| 179 this._dipWidth = dipWidth ? Math.max(dipWidth, 1) : 0; | 181 this._dipWidth = dipWidth ? Math.max(dipWidth, 1) : 0; |
| 180 this._dipHeight = dipHeight ? Math.max(dipHeight, 1) : 0; | 182 this._dipHeight = dipHeight ? Math.max(dipHeight, 1) : 0; |
| 181 this._updateUI(); | 183 this._updateUI(); |
| 182 }, | 184 }, |
| 183 | 185 |
| 184 updatePageResizer: function() | 186 updatePageResizer: function() |
| 185 { | 187 { |
| 186 WebInspector.overridesSupport.setPageResizer(this, this._availableDipSiz
e()); | 188 var available = this._availableDipSize(); |
| 189 WebInspector.overridesSupport.setPageResizer(this, available.size, avail
able.insets); |
| 187 }, | 190 }, |
| 188 | 191 |
| 189 /** | 192 /** |
| 190 * @return {!Size} | 193 * @return {!{size: !Size, insets: !Insets}} |
| 191 */ | 194 */ |
| 192 _availableDipSize: function() | 195 _availableDipSize: function() |
| 193 { | 196 { |
| 194 if (typeof this._availableSize === "undefined") { | 197 if (typeof this._availableSize === "undefined") { |
| 195 if (!this._enabled) | 198 if (!this._enabled) |
| 196 return new Size(1, 1); | 199 return {size: new Size(1, 1), insets: new Insets(0, 0, 0, 0)}; |
| 197 var zoomFactor = WebInspector.zoomManager.zoomFactor(); | 200 var zoomFactor = WebInspector.zoomManager.zoomFactor(); |
| 198 var rect = this._canvasContainer.element.getBoundingClientRect(); | 201 var rect = this._canvasContainer.element.getBoundingClientRect(); |
| 199 var rulerTotalHeight = this._rulerTotalHeightDIP(); | 202 var rulerTotalHeight = this._rulerTotalHeightDIP(); |
| 200 this._availableSize = new Size(Math.max(rect.width * zoomFactor - We
bInspector.ResponsiveDesignView.RulerWidth, 1), | 203 this._availableSize = {size: new Size(Math.max(rect.width * zoomFact
or - WebInspector.ResponsiveDesignView.RulerWidth, 1), |
| 201 Math.max(rect.height * zoomFactor - r
ulerTotalHeight, 1)); | 204 Math.max(rect.height * zoomFac
tor - rulerTotalHeight, 1)), |
| 205 insets: this._deviceInsets}; |
| 202 } | 206 } |
| 203 return this._availableSize; | 207 return this._availableSize; |
| 204 }, | 208 }, |
| 205 | 209 |
| 206 /** | 210 /** |
| 207 * @param {!Element} element | 211 * @param {!Element} element |
| 208 * @param {boolean} x | 212 * @param {boolean} x |
| 209 * @param {boolean} y | 213 * @param {boolean} y |
| 210 * @return {!WebInspector.ResizerWidget} | 214 * @return {!WebInspector.ResizerWidget} |
| 211 */ | 215 */ |
| 212 _createResizer: function(element, x, y) | 216 _createResizer: function(element, x, y) |
| 213 { | 217 { |
| 214 var resizer = new WebInspector.ResizerWidget(); | 218 var resizer = new WebInspector.ResizerWidget(); |
| 215 resizer.addElement(element); | 219 resizer.addElement(element); |
| 216 resizer.setCursor(x && y ? "nwse-resize" : (x ? "ew-resize" : "ns-resize
")); | 220 resizer.setCursor(x && y ? "nwse-resize" : (x ? "ew-resize" : "ns-resize
")); |
| 217 resizer.addEventListener(WebInspector.ResizerWidget.Events.ResizeStart,
this._onResizeStart, this); | 221 resizer.addEventListener(WebInspector.ResizerWidget.Events.ResizeStart,
this._onResizeStart, this); |
| 218 resizer.addEventListener(WebInspector.ResizerWidget.Events.ResizeUpdate,
this._onResizeUpdate.bind(this, x, y)); | 222 resizer.addEventListener(WebInspector.ResizerWidget.Events.ResizeUpdate,
this._onResizeUpdate.bind(this, x, y)); |
| 219 resizer.addEventListener(WebInspector.ResizerWidget.Events.ResizeEnd, th
is._onResizeEnd, this); | 223 resizer.addEventListener(WebInspector.ResizerWidget.Events.ResizeEnd, th
is._onResizeEnd, this); |
| 220 return resizer; | 224 return resizer; |
| 221 }, | 225 }, |
| 222 | 226 |
| 223 /** | 227 /** |
| 224 * @param {!WebInspector.Event} event | 228 * @param {!WebInspector.Event} event |
| 225 */ | 229 */ |
| 226 _onResizeStart: function(event) | 230 _onResizeStart: function(event) |
| 227 { | 231 { |
| 228 this._drawContentsSize = false; | 232 this._drawContentsSize = false; |
| 229 var available = this._availableDipSize(); | 233 var available = this._availableDipSize().size; |
| 230 this._slowPositionStart = null; | 234 this._slowPositionStart = null; |
| 231 this._resizeStart = { x: this._dipWidth || available.width, y : this._di
pHeight || available.height }; | 235 this._resizeStart = { x: this._dipWidth || available.width, y : this._di
pHeight || available.height }; |
| 232 this.dispatchEventToListeners(WebInspector.OverridesSupport.PageResizer.
Events.FixedScaleRequested, true); | 236 this.dispatchEventToListeners(WebInspector.OverridesSupport.PageResizer.
Events.FixedScaleRequested, true); |
| 233 this._updateUI(); | 237 this._updateUI(); |
| 234 }, | 238 }, |
| 235 | 239 |
| 236 /** | 240 /** |
| 237 * @param {boolean} x | 241 * @param {boolean} x |
| 238 * @param {boolean} y | 242 * @param {boolean} y |
| 239 * @param {!WebInspector.Event} event | 243 * @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(); | 472 return WebInspector.ResponsiveDesignView.RulerTopHeight + WebInspector.R
esponsiveDesignView.RulerBottomHeight + mediaInspectorHeight * WebInspector.zoom
Manager.zoomFactor(); |
| 469 }, | 473 }, |
| 470 | 474 |
| 471 _updateUI: function() | 475 _updateUI: function() |
| 472 { | 476 { |
| 473 if (!this._enabled || !this.isShowing()) | 477 if (!this._enabled || !this.isShowing()) |
| 474 return; | 478 return; |
| 475 | 479 |
| 476 var zoomFactor = WebInspector.zoomManager.zoomFactor(); | 480 var zoomFactor = WebInspector.zoomManager.zoomFactor(); |
| 477 var rect = this._canvas.parentElement.getBoundingClientRect(); | 481 var rect = this._canvas.parentElement.getBoundingClientRect(); |
| 478 var availableDip = this._availableDipSize(); | 482 var availableDip = this._availableDipSize().size; |
| 479 var cssCanvasWidth = rect.width; | 483 var cssCanvasWidth = rect.width; |
| 480 var cssCanvasHeight = rect.height; | 484 var cssCanvasHeight = rect.height; |
| 481 var mediaInspectorHeight = this._mediaInspector.isShowing() ? this._medi
aInspector.element.offsetHeight : 0; | 485 var mediaInspectorHeight = this._mediaInspector.isShowing() ? this._medi
aInspector.element.offsetHeight : 0; |
| 482 var rulerTotalHeight = this._rulerTotalHeightDIP(); | 486 var rulerTotalHeight = this._rulerTotalHeightDIP(); |
| 483 | 487 |
| 484 this._mediaInspector.setAxisTransform(this._viewport.scrollX, this._scal
e * this._viewport.pageScaleFactor); | 488 this._mediaInspector.setAxisTransform(this._viewport.scrollX, this._scal
e * this._viewport.pageScaleFactor); |
| 485 | 489 |
| 486 if (this._cachedZoomFactor !== zoomFactor || this._cachedMediaInspectorH
eight !== mediaInspectorHeight) { | 490 if (this._cachedZoomFactor !== zoomFactor || this._cachedMediaInspectorH
eight !== mediaInspectorHeight) { |
| 487 var cssRulerWidth = WebInspector.ResponsiveDesignView.RulerWidth / z
oomFactor + "px"; | 491 var cssRulerWidth = WebInspector.ResponsiveDesignView.RulerWidth / z
oomFactor + "px"; |
| 488 var cssRulerHeight = (mediaInspectorHeight ? WebInspector.Responsive
DesignView.RulerTopHeight : WebInspector.ResponsiveDesignView.RulerHeight) / zoo
mFactor + "px"; | 492 var cssRulerHeight = (mediaInspectorHeight ? WebInspector.Responsive
DesignView.RulerTopHeight : WebInspector.ResponsiveDesignView.RulerHeight) / zoo
mFactor + "px"; |
| 489 var cssCanvasOffset = rulerTotalHeight / zoomFactor + "px"; | 493 var cssCanvasOffset = rulerTotalHeight / zoomFactor + "px"; |
| 490 this._slidersContainer.style.left = cssRulerWidth; | 494 this._slidersContainer.style.left = cssRulerWidth; |
| 491 this._slidersContainer.style.top = cssCanvasOffset; | 495 this._slidersContainer.style.top = cssCanvasOffset; |
| 492 this._warningInfobar.element.style.height = cssCanvasOffset; | 496 this._warningInfobar.element.style.height = cssCanvasOffset; |
| 493 this._pageScaleContainer.style.top = cssCanvasOffset; | 497 this._pageScaleContainer.style.top = cssCanvasOffset; |
| 494 this._mediaInspectorContainer.style.left = cssRulerWidth; | 498 this._mediaInspectorContainer.style.left = cssRulerWidth; |
| 495 this._mediaInspectorContainer.style.marginTop = cssRulerHeight; | 499 this._mediaInspectorContainer.style.marginTop = cssRulerHeight; |
| 496 } | 500 } |
| 497 | 501 |
| 498 var cssWidth = (this._dipWidth ? this._dipWidth : availableDip.width) /
zoomFactor; | 502 var cssWidth = (this._dipWidth ? this._dipWidth : availableDip.width) /
zoomFactor; |
| 499 var cssHeight = (this._dipHeight ? this._dipHeight : availableDip.height
) / zoomFactor; | 503 var cssHeight = (this._dipHeight ? this._dipHeight : availableDip.height
) / zoomFactor; |
| 500 if (this._cachedCssWidth !== cssWidth || this._cachedCssHeight !== cssHe
ight) { | 504 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); |
| 505 cssWidth += deviceInsets.left + deviceInsets.right; |
| 506 cssHeight += deviceInsets.top + deviceInsets.bottom; |
| 507 if (this._cachedCssWidth !== cssWidth || this._cachedCssHeight !== cssHe
ight || !deviceInsets.isEqual(this._cachedDeviceInsets)) { |
| 501 this._slidersContainer.style.width = cssWidth + "px"; | 508 this._slidersContainer.style.width = cssWidth + "px"; |
| 502 this._slidersContainer.style.height = cssHeight + "px"; | 509 this._slidersContainer.style.height = cssHeight + "px"; |
| 510 this._pageContainer.style.paddingLeft = deviceInsets.left + "px"; |
| 511 this._pageContainer.style.paddingTop = deviceInsets.top + "px"; |
| 512 this._pageContainer.style.paddingRight = deviceInsets.right + "px"; |
| 513 this._pageContainer.style.paddingBottom = deviceInsets.bottom + "px"
; |
| 503 this._inspectedPagePlaceholder.onResize(); | 514 this._inspectedPagePlaceholder.onResize(); |
| 504 } | 515 } |
| 505 | 516 |
| 506 var pageScaleVisible = cssWidth + this._pageScaleContainerWidth + WebIns
pector.ResponsiveDesignView.RulerWidth / zoomFactor <= rect.width; | 517 var pageScaleVisible = cssWidth + this._pageScaleContainerWidth + WebIns
pector.ResponsiveDesignView.RulerWidth / zoomFactor <= rect.width; |
| 507 this._pageScaleContainer.classList.toggle("hidden", !pageScaleVisible); | 518 this._pageScaleContainer.classList.toggle("hidden", !pageScaleVisible); |
| 508 | 519 |
| 509 var viewportChanged = !this._cachedViewport | 520 var viewportChanged = !this._cachedViewport |
| 510 || this._cachedViewport.scrollX !== this._viewport.scrollX || this._
cachedViewport.scrollY !== this._viewport.scrollY | 521 || 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 | 522 || this._cachedViewport.contentsWidth !== this._viewport.contentsWid
th || this._cachedViewport.contentsHeight !== this._viewport.contentsHeight |
| 512 || this._cachedViewport.pageScaleFactor !== this._viewport.pageScale
Factor | 523 || 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; | 537 this._decreasePageScaleButton.disabled = this._viewport.pageScaleFac
tor <= this._viewport.minimumPageScaleFactor; |
| 527 this._increasePageScaleButton.title = WebInspector.UIString("Scale u
p (maximum %.1f)", this._viewport.maximumPageScaleFactor); | 538 this._increasePageScaleButton.title = WebInspector.UIString("Scale u
p (maximum %.1f)", this._viewport.maximumPageScaleFactor); |
| 528 this._increasePageScaleButton.disabled = this._viewport.pageScaleFac
tor >= this._viewport.maximumPageScaleFactor; | 539 this._increasePageScaleButton.disabled = this._viewport.pageScaleFac
tor >= this._viewport.maximumPageScaleFactor; |
| 529 } | 540 } |
| 530 | 541 |
| 531 this._cachedScale = this._scale; | 542 this._cachedScale = this._scale; |
| 532 this._cachedCssCanvasWidth = cssCanvasWidth; | 543 this._cachedCssCanvasWidth = cssCanvasWidth; |
| 533 this._cachedCssCanvasHeight = cssCanvasHeight; | 544 this._cachedCssCanvasHeight = cssCanvasHeight; |
| 534 this._cachedCssHeight = cssHeight; | 545 this._cachedCssHeight = cssHeight; |
| 535 this._cachedCssWidth = cssWidth; | 546 this._cachedCssWidth = cssWidth; |
| 547 this._cachedDeviceInsets = deviceInsets; |
| 536 this._cachedZoomFactor = zoomFactor; | 548 this._cachedZoomFactor = zoomFactor; |
| 537 this._cachedViewport = this._viewport; | 549 this._cachedViewport = this._viewport; |
| 538 this._cachedDrawContentsSize = this._drawContentsSize; | 550 this._cachedDrawContentsSize = this._drawContentsSize; |
| 539 this._cachedMediaInspectorHeight = mediaInspectorHeight; | 551 this._cachedMediaInspectorHeight = mediaInspectorHeight; |
| 540 }, | 552 }, |
| 541 | 553 |
| 542 onResize: function() | 554 onResize: function() |
| 543 { | 555 { |
| 544 if (!this._enabled || this._ignoreResize) | 556 if (!this._enabled || this._ignoreResize) |
| 545 return; | 557 return; |
| 546 var oldSize = this._availableSize; | 558 var oldSize = this._availableSize; |
| 547 | 559 |
| 548 this._pageScaleContainer.classList.remove("hidden"); | 560 this._pageScaleContainer.classList.remove("hidden"); |
| 549 this._pageScaleContainerWidth = this._pageScaleContainer.offsetWidth; | 561 this._pageScaleContainerWidth = this._pageScaleContainer.offsetWidth; |
| 550 | 562 |
| 551 delete this._availableSize; | 563 delete this._availableSize; |
| 552 var newSize = this._availableDipSize(); | 564 var newSize = this._availableDipSize(); |
| 553 if (!newSize.isEqual(oldSize)) | 565 if (!oldSize || !newSize.size.isEqual(oldSize.size) || !newSize.insets.i
sEqual(oldSize.insets)) |
| 554 this.dispatchEventToListeners(WebInspector.OverridesSupport.PageResi
zer.Events.AvailableSizeChanged, newSize); | 566 this.dispatchEventToListeners(WebInspector.OverridesSupport.PageResi
zer.Events.AvailableSizeChanged, newSize); |
| 555 this._updateUI(); | 567 this._updateUI(); |
| 556 this._inspectedPagePlaceholder.onResize(); | 568 this._inspectedPagePlaceholder.onResize(); |
| 557 }, | 569 }, |
| 558 | 570 |
| 559 _onZoomChanged: function() | 571 _onZoomChanged: function() |
| 560 { | 572 { |
| 561 this._updateUI(); | 573 this._updateUI(); |
| 562 }, | 574 }, |
| 563 | 575 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 592 this._toggleMediaInspectorButton.setToggled(this._showMediaQueryInspecto
rSetting.get()); | 604 this._toggleMediaInspectorButton.setToggled(this._showMediaQueryInspecto
rSetting.get()); |
| 593 this._toggleMediaInspectorButton.setEnabled(false); | 605 this._toggleMediaInspectorButton.setEnabled(false); |
| 594 this._toggleMediaInspectorButton.addEventListener("click", this._onToggl
eMediaInspectorButtonClick, this); | 606 this._toggleMediaInspectorButton.addEventListener("click", this._onToggl
eMediaInspectorButtonClick, this); |
| 595 this._showMediaQueryInspectorSetting.addChangeListener(this._updateMedia
QueryInspector, this); | 607 this._showMediaQueryInspectorSetting.addChangeListener(this._updateMedia
QueryInspector, this); |
| 596 buttonsToolbar.appendToolbarItem(this._toggleMediaInspectorButton); | 608 buttonsToolbar.appendToolbarItem(this._toggleMediaInspectorButton); |
| 597 }, | 609 }, |
| 598 | 610 |
| 599 _createDeviceSection: function() | 611 _createDeviceSection: function() |
| 600 { | 612 { |
| 601 var deviceSection = this._toolbarElement.createChild("div", "responsive-
design-section responsive-design-section-device"); | 613 var deviceSection = this._toolbarElement.createChild("div", "responsive-
design-section responsive-design-section-device"); |
| 602 | |
| 603 deviceSection.createChild("div", "responsive-design-section-decorator"); | 614 deviceSection.createChild("div", "responsive-design-section-decorator"); |
| 604 | 615 |
| 605 // Device. | 616 // Device. |
| 606 var deviceElement = deviceSection.createChild("div", "responsive-design-
suite responsive-design-suite-top").createChild("div"); | 617 var deviceElement = deviceSection.createChild("div", "responsive-design-
suite responsive-design-suite-top").createChild("div"); |
| 607 | 618 |
| 608 var fieldsetElement = deviceElement.createChild("fieldset"); | 619 var fieldsetElement = deviceElement.createChild("fieldset"); |
| 609 fieldsetElement.createChild("label").textContent = WebInspector.UIString
("Device"); | 620 fieldsetElement.createChild("label").textContent = WebInspector.UIString
("Device"); |
| 610 var deviceSelectElement = WebInspector.OverridesUI.createDeviceSelect(); | 621 var deviceSelect = new WebInspector.DeviceSelect(createElementWithClass(
"button", "responsive-design-icon responsive-design-icon-swap")); |
| 611 fieldsetElement.appendChild(deviceSelectElement); | 622 deviceSelect.setCallback(this._deviceModeSelected.bind(this)); |
| 612 deviceSelectElement.classList.add("responsive-design-device-select"); | 623 fieldsetElement.appendChild(deviceSelect.element); |
| 624 deviceSelect.element.classList.add("responsive-design-device-select"); |
| 613 | 625 |
| 614 var detailsElement = deviceSection.createChild("div", "responsive-design
-suite"); | 626 var detailsElement = deviceSection.createChild("div", "responsive-design
-suite"); |
| 615 | 627 |
| 616 // Dimensions. | 628 // Dimensions. |
| 617 var screenElement = detailsElement.createChild("div", ""); | 629 var screenElement = detailsElement.createChild("div", ""); |
| 618 fieldsetElement = screenElement.createChild("fieldset"); | 630 fieldsetElement = screenElement.createChild("fieldset"); |
| 619 | 631 |
| 620 var emulateResolutionCheckbox = WebInspector.SettingsUI.createSettingChe
ckbox("", WebInspector.overridesSupport.settings.emulateResolution, true, WebIns
pector.UIString("Emulate screen resolution")); | 632 var emulateResolutionCheckbox = WebInspector.SettingsUI.createSettingChe
ckbox("", WebInspector.overridesSupport.settings.emulateResolution, true, WebIns
pector.UIString("Emulate screen resolution")); |
| 621 themeCheckbox(emulateResolutionCheckbox); | 633 themeCheckbox(emulateResolutionCheckbox); |
| 622 fieldsetElement.appendChild(emulateResolutionCheckbox); | 634 fieldsetElement.appendChild(emulateResolutionCheckbox); |
| 623 | 635 |
| 624 var resolutionIcon = fieldsetElement.createChild("div", "responsive-desi
gn-icon responsive-design-icon-resolution"); | 636 var resolutionIcon = fieldsetElement.createChild("div", "responsive-desi
gn-icon responsive-design-icon-resolution"); |
| 625 resolutionIcon.title = WebInspector.UIString("Screen resolution"); | 637 resolutionIcon.title = WebInspector.UIString("Screen resolution"); |
| 626 var resolutionFieldset = WebInspector.SettingsUI.createSettingFieldset(W
ebInspector.overridesSupport.settings.emulateResolution); | 638 var resolutionFieldset = WebInspector.SettingsUI.createSettingFieldset(W
ebInspector.overridesSupport.settings.emulateResolution); |
| 627 fieldsetElement.appendChild(resolutionFieldset); | 639 fieldsetElement.appendChild(resolutionFieldset); |
| 628 | 640 |
| 629 resolutionFieldset.appendChild(WebInspector.SettingsUI.createSettingInpu
tField("", WebInspector.overridesSupport.settings.deviceWidth, true, 4, "3em", W
ebInspector.OverridesSupport.deviceSizeValidator, true, true, WebInspector.UIStr
ing("\u2013"))); | 641 resolutionFieldset.appendChild(WebInspector.SettingsUI.createSettingInpu
tField("", WebInspector.overridesSupport.settings.deviceWidth, true, 4, "3em", W
ebInspector.OverridesSupport.deviceSizeValidator, true, true, WebInspector.UIStr
ing("\u2013"))); |
| 630 resolutionFieldset.createTextChild("\u00D7"); | 642 resolutionFieldset.createTextChild("\u00D7"); |
| 631 resolutionFieldset.appendChild(WebInspector.SettingsUI.createSettingInpu
tField("", WebInspector.overridesSupport.settings.deviceHeight, true, 4, "3em",
WebInspector.OverridesSupport.deviceSizeValidator, true, true, WebInspector.UISt
ring("\u2013"))); | 643 resolutionFieldset.appendChild(WebInspector.SettingsUI.createSettingInpu
tField("", WebInspector.overridesSupport.settings.deviceHeight, true, 4, "3em",
WebInspector.OverridesSupport.deviceSizeValidator, true, true, WebInspector.UISt
ring("\u2013"))); |
| 632 | 644 |
| 633 var swapButton = resolutionFieldset.createChild("button", "responsive-de
sign-icon responsive-design-icon-swap"); | |
| 634 swapButton.title = WebInspector.UIString("Swap dimensions"); | |
| 635 swapButton.addEventListener("click", WebInspector.overridesSupport.swapD
imensions.bind(WebInspector.overridesSupport), false); | |
| 636 | |
| 637 // Device pixel ratio. | 645 // Device pixel ratio. |
| 638 detailsElement.createChild("div", "responsive-design-suite-separator"); | 646 detailsElement.createChild("div", "responsive-design-suite-separator"); |
| 639 | 647 |
| 640 var dprElement = detailsElement.createChild("div", ""); | 648 var dprElement = detailsElement.createChild("div", ""); |
| 641 var resolutionFieldset2 = WebInspector.SettingsUI.createSettingFieldset(
WebInspector.overridesSupport.settings.emulateResolution); | 649 var resolutionFieldset2 = WebInspector.SettingsUI.createSettingFieldset(
WebInspector.overridesSupport.settings.emulateResolution); |
| 642 dprElement.appendChild(resolutionFieldset2); | 650 dprElement.appendChild(resolutionFieldset2); |
| 643 var dprButton = resolutionFieldset2.createChild("div", "responsive-desig
n-icon responsive-design-icon-dpr"); | 651 var dprButton = resolutionFieldset2.createChild("div", "responsive-desig
n-icon responsive-design-icon-dpr"); |
| 644 dprButton.title = WebInspector.UIString("Device pixel ratio"); | 652 dprButton.title = WebInspector.UIString("Device pixel ratio"); |
| 645 resolutionFieldset2.appendChild(WebInspector.SettingsUI.createSettingInp
utField("", WebInspector.overridesSupport.settings.deviceScaleFactor, true, 4, "
1.9em", WebInspector.OverridesSupport.deviceScaleFactorValidator, true, true, We
bInspector.UIString("\u2013"))); | 653 resolutionFieldset2.appendChild(WebInspector.SettingsUI.createSettingInp
utField("", WebInspector.overridesSupport.settings.deviceScaleFactor, true, 4, "
1.9em", WebInspector.OverridesSupport.deviceScaleFactorValidator, true, true, We
bInspector.UIString("\u2013"))); |
| 646 | 654 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 this._warningMessage.textContent = message; | 720 this._warningMessage.textContent = message; |
| 713 this._warningInfobar.setVisible(!!message); | 721 this._warningInfobar.setVisible(!!message); |
| 714 }, | 722 }, |
| 715 | 723 |
| 716 _showEmulationInDrawer: function() | 724 _showEmulationInDrawer: function() |
| 717 { | 725 { |
| 718 WebInspector.Revealer.reveal(WebInspector.overridesSupport); | 726 WebInspector.Revealer.reveal(WebInspector.overridesSupport); |
| 719 }, | 727 }, |
| 720 | 728 |
| 721 /** | 729 /** |
| 730 * @param {?WebInspector.EmulatedDevice} device |
| 731 * @param {?WebInspector.EmulatedDevice.Mode} mode |
| 732 */ |
| 733 _deviceModeSelected: function(device, mode) |
| 734 { |
| 735 if (device && mode) { |
| 736 var orientation = device.orientationByName(mode.orientation); |
| 737 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); |
| 738 } else { |
| 739 this._deviceInsets = new Insets(0, 0, 0, 0); |
| 740 } |
| 741 this.dispatchEventToListeners(WebInspector.OverridesSupport.PageResizer.
Events.InsetsChanged, this._deviceInsets); |
| 742 }, |
| 743 |
| 744 /** |
| 722 * @param {!EmulationAgent.Viewport=} viewport | 745 * @param {!EmulationAgent.Viewport=} viewport |
| 723 */ | 746 */ |
| 724 _viewportChanged: function(viewport) | 747 _viewportChanged: function(viewport) |
| 725 { | 748 { |
| 726 if (viewport) { | 749 if (viewport) { |
| 727 this._viewport = viewport; | 750 this._viewport = viewport; |
| 728 this._viewport.minimumPageScaleFactor = Math.max(0.1, this._viewport
.minimumPageScaleFactor); | 751 this._viewport.minimumPageScaleFactor = Math.max(0.1, this._viewport
.minimumPageScaleFactor); |
| 729 this._viewport.minimumPageScaleFactor = Math.min(this._viewport.mini
mumPageScaleFactor, this._viewport.pageScaleFactor); | 752 this._viewport.minimumPageScaleFactor = Math.min(this._viewport.mini
mumPageScaleFactor, this._viewport.pageScaleFactor); |
| 730 this._viewport.maximumPageScaleFactor = Math.min(10, this._viewport.
maximumPageScaleFactor); | 753 this._viewport.maximumPageScaleFactor = Math.min(10, this._viewport.
maximumPageScaleFactor); |
| 731 this._viewport.maximumPageScaleFactor = Math.max(this._viewport.maxi
mumPageScaleFactor, this._viewport.pageScaleFactor); | 754 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... |
| 800 WebInspector.EmulationDispatcher.prototype = { | 823 WebInspector.EmulationDispatcher.prototype = { |
| 801 /** | 824 /** |
| 802 * @override | 825 * @override |
| 803 * @param {!EmulationAgent.Viewport=} viewport | 826 * @param {!EmulationAgent.Viewport=} viewport |
| 804 */ | 827 */ |
| 805 viewportChanged: function(viewport) | 828 viewportChanged: function(viewport) |
| 806 { | 829 { |
| 807 this._responsiveDesignView._viewportChanged(viewport); | 830 this._responsiveDesignView._viewportChanged(viewport); |
| 808 } | 831 } |
| 809 } | 832 } |
| OLD | NEW |