| 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("overflow-hidden"); | 16 this.element.classList.add("overflow-hidden"); |
| 17 | 17 |
| 18 this._responsiveDesignContainer = new WebInspector.VBox(); | 18 this._responsiveDesignContainer = new WebInspector.VBox(); |
| 19 this._responsiveDesignContainer.registerRequiredCSS("responsiveDesignView.cs
s"); | 19 this._responsiveDesignContainer.registerRequiredCSS("responsiveDesignView.cs
s"); |
| 20 | 20 |
| 21 this._createToolbar(); | 21 this._createToolbar(); |
| 22 | 22 |
| 23 this._mediaInspector = new WebInspector.MediaQueryInspector(); | |
| 24 this._mediaInspectorContainer = this._responsiveDesignContainer.element.crea
teChild("div", "responsive-design-media-container"); | |
| 25 this._updateMediaQueryInspector(); | |
| 26 | |
| 27 this._canvasContainer = new WebInspector.View(); | 23 this._canvasContainer = new WebInspector.View(); |
| 28 this._canvasContainer.element.classList.add("responsive-design"); | 24 this._canvasContainer.element.classList.add("responsive-design"); |
| 29 this._canvasContainer.show(this._responsiveDesignContainer.element); | 25 this._canvasContainer.show(this._responsiveDesignContainer.element); |
| 30 | 26 |
| 31 this._canvas = this._canvasContainer.element.createChild("canvas", "fill"); | 27 this._mediaInspectorContainer = this._canvasContainer.element.createChild("d
iv", "responsive-design-media-container"); |
| 28 this._mediaInspector = new WebInspector.MediaQueryInspector(); |
| 29 this._updateMediaQueryInspector(); |
| 32 | 30 |
| 33 this._rulerGlasspane = this._canvasContainer.element.createChild("div", "res
ponsive-design-ruler-glasspane"); | 31 this._canvas = this._canvasContainer.element.createChild("canvas", "fill res
ponsive-design-canvas"); |
| 34 this._rulerGlasspane.appendChild(this._mediaInspector.rulerDecorationLayer()
); | |
| 35 | 32 |
| 36 this._warningMessage = this._canvasContainer.element.createChild("div", "res
ponsive-design-warning hidden"); | 33 this._warningMessage = this._canvasContainer.element.createChild("div", "res
ponsive-design-warning hidden"); |
| 37 this._warningMessage.createChild("div", "warning-icon-small"); | 34 this._warningMessage.createChild("div", "warning-icon-small"); |
| 38 this._warningMessage.createChild("span"); | 35 this._warningMessage.createChild("span"); |
| 39 var warningCloseButton = this._warningMessage.createChild("div", "close-butt
on"); | 36 var warningCloseButton = this._warningMessage.createChild("div", "close-butt
on"); |
| 40 warningCloseButton.addEventListener("click", WebInspector.overridesSupport.c
learWarningMessage.bind(WebInspector.overridesSupport), false); | 37 warningCloseButton.addEventListener("click", WebInspector.overridesSupport.c
learWarningMessage.bind(WebInspector.overridesSupport), false); |
| 41 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport
.Events.OverridesWarningUpdated, this._overridesWarningUpdated, this); | 38 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport
.Events.OverridesWarningUpdated, this._overridesWarningUpdated, this); |
| 42 | 39 |
| 43 this._slidersContainer = this._canvasContainer.element.createChild("div", "v
box responsive-design-sliders-container"); | 40 this._slidersContainer = this._canvasContainer.element.createChild("div", "v
box responsive-design-sliders-container"); |
| 44 var hbox = this._slidersContainer.createChild("div", "hbox flex-auto"); | 41 var hbox = this._slidersContainer.createChild("div", "hbox flex-auto"); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 this._mediaInspector.addEventListener(WebInspector.MediaQueryInspector.Event
s.CountUpdated, this._updateMediaQueryInspectorButton, this); | 79 this._mediaInspector.addEventListener(WebInspector.MediaQueryInspector.Event
s.CountUpdated, this._updateMediaQueryInspectorButton, this); |
| 83 this._mediaInspector.addEventListener(WebInspector.MediaQueryInspector.Event
s.HeightUpdated, this.onResize, this); | 80 this._mediaInspector.addEventListener(WebInspector.MediaQueryInspector.Event
s.HeightUpdated, this.onResize, this); |
| 84 WebInspector.targetManager.observeTargets(this); | 81 WebInspector.targetManager.observeTargets(this); |
| 85 | 82 |
| 86 this._emulationEnabledChanged(); | 83 this._emulationEnabledChanged(); |
| 87 this._overridesWarningUpdated(); | 84 this._overridesWarningUpdated(); |
| 88 }; | 85 }; |
| 89 | 86 |
| 90 // Measured in DIP. | 87 // Measured in DIP. |
| 91 WebInspector.ResponsiveDesignView.SliderWidth = 19; | 88 WebInspector.ResponsiveDesignView.SliderWidth = 19; |
| 92 WebInspector.ResponsiveDesignView.RulerWidth = 22; | 89 WebInspector.ResponsiveDesignView.RulerWidth = 34; |
| 90 WebInspector.ResponsiveDesignView.RulerHeight = 22; |
| 91 WebInspector.ResponsiveDesignView.RulerBottomHeight = 9; |
| 93 WebInspector.ResponsiveDesignView.PageScaleContainerWidth = 40; | 92 WebInspector.ResponsiveDesignView.PageScaleContainerWidth = 40; |
| 94 WebInspector.ResponsiveDesignView.PageScaleContainerHeight = 80; | 93 WebInspector.ResponsiveDesignView.PageScaleContainerHeight = 80; |
| 95 | 94 |
| 96 WebInspector.ResponsiveDesignView.prototype = { | 95 WebInspector.ResponsiveDesignView.prototype = { |
| 97 | 96 |
| 98 /** | 97 /** |
| 99 * @param {!WebInspector.Target} target | 98 * @param {!WebInspector.Target} target |
| 100 */ | 99 */ |
| 101 targetAdded: function(target) | 100 targetAdded: function(target) |
| 102 { | 101 { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 120 _invalidateCache: function() | 119 _invalidateCache: function() |
| 121 { | 120 { |
| 122 delete this._cachedScale; | 121 delete this._cachedScale; |
| 123 delete this._cachedCssCanvasWidth; | 122 delete this._cachedCssCanvasWidth; |
| 124 delete this._cachedCssCanvasHeight; | 123 delete this._cachedCssCanvasHeight; |
| 125 delete this._cachedCssHeight; | 124 delete this._cachedCssHeight; |
| 126 delete this._cachedCssWidth; | 125 delete this._cachedCssWidth; |
| 127 delete this._cachedZoomFactor; | 126 delete this._cachedZoomFactor; |
| 128 delete this._cachedViewport; | 127 delete this._cachedViewport; |
| 129 delete this._cachedDrawContentsSize; | 128 delete this._cachedDrawContentsSize; |
| 129 delete this._cachedMediaInspectorHeight; |
| 130 delete this._availableSize; | 130 delete this._availableSize; |
| 131 }, | 131 }, |
| 132 | 132 |
| 133 _emulationEnabledChanged: function() | 133 _emulationEnabledChanged: function() |
| 134 { | 134 { |
| 135 var enabled = WebInspector.overridesSupport.emulationEnabled(); | 135 var enabled = WebInspector.overridesSupport.emulationEnabled(); |
| 136 this._mediaInspector.setEnabled(enabled); | 136 this._mediaInspector.setEnabled(enabled); |
| 137 if (enabled && !this._enabled) { | 137 if (enabled && !this._enabled) { |
| 138 this._invalidateCache(); | 138 this._invalidateCache(); |
| 139 this._ignoreResize = true; | 139 this._ignoreResize = true; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 }, | 176 }, |
| 177 | 177 |
| 178 /** | 178 /** |
| 179 * @return {!Size} | 179 * @return {!Size} |
| 180 */ | 180 */ |
| 181 _availableDipSize: function() | 181 _availableDipSize: function() |
| 182 { | 182 { |
| 183 if (typeof this._availableSize === "undefined") { | 183 if (typeof this._availableSize === "undefined") { |
| 184 var zoomFactor = WebInspector.zoomManager.zoomFactor(); | 184 var zoomFactor = WebInspector.zoomManager.zoomFactor(); |
| 185 var rect = this._canvasContainer.element.getBoundingClientRect(); | 185 var rect = this._canvasContainer.element.getBoundingClientRect(); |
| 186 var mediaInspectorHeight = this._mediaInspector.element.offsetHeight
; |
| 187 if (mediaInspectorHeight) |
| 188 mediaInspectorHeight += WebInspector.ResponsiveDesignView.RulerB
ottomHeight; |
| 186 this._availableSize = new Size(Math.max(rect.width * zoomFactor - We
bInspector.ResponsiveDesignView.RulerWidth, 1), | 189 this._availableSize = new Size(Math.max(rect.width * zoomFactor - We
bInspector.ResponsiveDesignView.RulerWidth, 1), |
| 187 Math.max(rect.height * zoomFactor - W
ebInspector.ResponsiveDesignView.RulerWidth, 1)); | 190 Math.max(rect.height * zoomFactor - m
ediaInspectorHeight - WebInspector.ResponsiveDesignView.RulerHeight, 1)); |
| 188 } | 191 } |
| 189 return this._availableSize; | 192 return this._availableSize; |
| 190 }, | 193 }, |
| 191 | 194 |
| 192 /** | 195 /** |
| 193 * @param {!Element} element | 196 * @param {!Element} element |
| 194 * @param {boolean} vertical | 197 * @param {boolean} vertical |
| 195 * @return {!WebInspector.ResizerWidget} | 198 * @return {!WebInspector.ResizerWidget} |
| 196 */ | 199 */ |
| 197 _createResizer: function(element, vertical) | 200 _createResizer: function(element, vertical) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 this.dispatchEventToListeners(WebInspector.OverridesSupport.PageResizer.
Events.FixedScaleRequested, false); | 250 this.dispatchEventToListeners(WebInspector.OverridesSupport.PageResizer.
Events.FixedScaleRequested, false); |
| 248 delete this._resizeStartSize; | 251 delete this._resizeStartSize; |
| 249 this._updateUI(); | 252 this._updateUI(); |
| 250 }, | 253 }, |
| 251 | 254 |
| 252 /** | 255 /** |
| 253 * Draws canvas of the specified css size in DevTools page space. | 256 * Draws canvas of the specified css size in DevTools page space. |
| 254 * Canvas contains grid and rulers. | 257 * Canvas contains grid and rulers. |
| 255 * @param {number} cssCanvasWidth | 258 * @param {number} cssCanvasWidth |
| 256 * @param {number} cssCanvasHeight | 259 * @param {number} cssCanvasHeight |
| 260 * @param {number} mediaInspectorHeight |
| 257 */ | 261 */ |
| 258 _drawCanvas: function(cssCanvasWidth, cssCanvasHeight) | 262 _drawCanvas: function(cssCanvasWidth, cssCanvasHeight, mediaInspectorHeight) |
| 259 { | 263 { |
| 260 if (!this._enabled) | 264 if (!this._enabled) |
| 261 return; | 265 return; |
| 262 | 266 |
| 263 var canvas = this._canvas; | 267 var canvas = this._canvas; |
| 264 var context = canvas.getContext("2d"); | 268 var context = canvas.getContext("2d"); |
| 265 canvas.style.width = cssCanvasWidth + "px"; | 269 canvas.style.width = cssCanvasWidth + "px"; |
| 266 canvas.style.height = cssCanvasHeight + "px"; | 270 canvas.style.height = cssCanvasHeight + "px"; |
| 267 | 271 |
| 268 var zoomFactor = WebInspector.zoomManager.zoomFactor(); | 272 var zoomFactor = WebInspector.zoomManager.zoomFactor(); |
| 269 var dipCanvasWidth = cssCanvasWidth * zoomFactor; | 273 var dipCanvasWidth = cssCanvasWidth * zoomFactor; |
| 270 var dipCanvasHeight = cssCanvasHeight * zoomFactor; | 274 var dipCanvasHeight = cssCanvasHeight * zoomFactor; |
| 275 var dipMediaInspectorHeight = mediaInspectorHeight * zoomFactor; |
| 271 | 276 |
| 272 var deviceScaleFactor = window.devicePixelRatio; | 277 var deviceScaleFactor = window.devicePixelRatio; |
| 273 canvas.width = deviceScaleFactor * cssCanvasWidth; | 278 canvas.width = deviceScaleFactor * cssCanvasWidth; |
| 274 canvas.height = deviceScaleFactor * cssCanvasHeight; | 279 canvas.height = deviceScaleFactor * cssCanvasHeight; |
| 275 context.scale(canvas.width / dipCanvasWidth, canvas.height / dipCanvasHe
ight); | 280 context.scale(canvas.width / dipCanvasWidth, canvas.height / dipCanvasHe
ight); |
| 276 context.font = "11px " + WebInspector.fontFamily(); | 281 context.font = "11px " + WebInspector.fontFamily(); |
| 277 | 282 |
| 278 const rulerBackgroundColor = "rgb(0, 0, 0)"; | |
| 279 const backgroundColor = "rgb(102, 102, 102)"; | 283 const backgroundColor = "rgb(102, 102, 102)"; |
| 280 const lightLineColor = "rgb(132, 132, 132)"; | 284 const lightLineColor = "rgb(132, 132, 132)"; |
| 281 const darkLineColor = "rgb(114, 114, 114)"; | 285 const darkLineColor = "rgb(114, 114, 114)"; |
| 282 const rulerColor = "rgb(125, 125, 125)"; | 286 const rulerColor = "rgb(125, 125, 125)"; |
| 287 const rulerOverlayColor = "rgba(255, 255, 255, 0.4)"; |
| 283 const textColor = "rgb(186, 186, 186)"; | 288 const textColor = "rgb(186, 186, 186)"; |
| 284 const contentsSizeColor = "rgba(0, 0, 0, 0.3)"; | 289 const contentsSizeColor = "rgba(0, 0, 0, 0.3)"; |
| 285 | 290 |
| 286 var scale = (this._scale || 1) * this._viewport.pageScaleFactor; | 291 var scale = (this._scale || 1) * this._viewport.pageScaleFactor; |
| 287 var rulerScale = 0.5; | 292 var rulerScale = 0.5; |
| 288 while (Math.abs(rulerScale * scale - 1) > Math.abs((rulerScale + 0.5) *
scale - 1)) | 293 while (Math.abs(rulerScale * scale - 1) > Math.abs((rulerScale + 0.5) *
scale - 1)) |
| 289 rulerScale += 0.5; | 294 rulerScale += 0.5; |
| 290 | 295 |
| 291 var gridStep = 50 * scale * rulerScale; | 296 var gridStep = 50 * scale * rulerScale; |
| 292 var gridSubStep = 10 * scale * rulerScale; | 297 var gridSubStep = 10 * scale * rulerScale; |
| 293 | 298 |
| 294 var rulerSubStep = 5 * scale * rulerScale; | 299 var rulerSubStep = 5 * scale * rulerScale; |
| 295 var rulerStepCount = 20; | 300 var rulerStepCount = 20; |
| 296 | 301 |
| 297 var rulerWidth = WebInspector.ResponsiveDesignView.RulerWidth; | 302 var rulerWidth = WebInspector.ResponsiveDesignView.RulerWidth; |
| 303 var rulerHeight = WebInspector.ResponsiveDesignView.RulerHeight; |
| 304 if (dipMediaInspectorHeight) |
| 305 rulerHeight += WebInspector.ResponsiveDesignView.RulerBottomHeight +
dipMediaInspectorHeight; |
| 298 var dipGridWidth = dipCanvasWidth - rulerWidth; | 306 var dipGridWidth = dipCanvasWidth - rulerWidth; |
| 299 var dipGridHeight = dipCanvasHeight - rulerWidth; | 307 var dipGridHeight = dipCanvasHeight - rulerHeight; |
| 300 var dipScrollX = this._viewport.scrollX * scale; | 308 var dipScrollX = this._viewport.scrollX * scale; |
| 301 var dipScrollY = this._viewport.scrollY * scale; | 309 var dipScrollY = this._viewport.scrollY * scale; |
| 302 context.translate(rulerWidth, rulerWidth); | 310 context.translate(rulerWidth, rulerHeight); |
| 303 | |
| 304 context.fillStyle = rulerBackgroundColor; | |
| 305 context.fillRect(-rulerWidth, -rulerWidth, dipGridWidth + rulerWidth, ru
lerWidth); | |
| 306 context.fillRect(-rulerWidth, 0, rulerWidth, dipGridHeight); | |
| 307 | 311 |
| 308 context.fillStyle = backgroundColor; | 312 context.fillStyle = backgroundColor; |
| 309 context.fillRect(0, 0, dipGridWidth, dipGridHeight); | 313 context.fillRect(0, 0, dipGridWidth, dipGridHeight); |
| 310 | 314 |
| 311 context.translate(0.5, 0.5); | 315 context.translate(0.5, 0.5); |
| 312 context.strokeStyle = rulerColor; | 316 context.strokeStyle = rulerColor; |
| 313 context.fillStyle = textColor; | 317 context.fillStyle = textColor; |
| 314 context.lineWidth = 1; | 318 context.lineWidth = 1; |
| 315 | 319 |
| 316 // Draw vertical ruler. | 320 // Draw horizontal ruler. |
| 317 context.save(); | 321 context.save(); |
| 322 context.beginPath(); |
| 323 context.moveTo(0, -rulerHeight + WebInspector.ResponsiveDesignView.Ruler
Height); |
| 324 context.lineTo(dipGridWidth, -rulerHeight + WebInspector.ResponsiveDesig
nView.RulerHeight); |
| 325 context.stroke(); |
| 326 |
| 318 var minXIndex = Math.ceil(dipScrollX / rulerSubStep); | 327 var minXIndex = Math.ceil(dipScrollX / rulerSubStep); |
| 319 var maxXIndex = Math.floor((dipScrollX + dipGridWidth) / rulerSubStep); | 328 var maxXIndex = Math.floor((dipScrollX + dipGridWidth) / rulerSubStep); |
| 329 if (minXIndex) { |
| 330 context.beginPath(); |
| 331 context.moveTo(0, -rulerHeight); |
| 332 context.lineTo(0, 0); |
| 333 context.stroke(); |
| 334 } |
| 335 |
| 320 context.translate(-dipScrollX, 0); | 336 context.translate(-dipScrollX, 0); |
| 321 for (var index = minXIndex; index <= maxXIndex; index++) { | 337 for (var index = minXIndex; index <= maxXIndex; index++) { |
| 322 var x = index * rulerSubStep; | 338 var x = index * rulerSubStep; |
| 323 var y = -rulerWidth / 4; | 339 var y = -WebInspector.ResponsiveDesignView.RulerHeight * 0.25; |
| 340 var copyHeight = WebInspector.ResponsiveDesignView.RulerHeight * 0.2
5; |
| 341 |
| 324 if (!(index % (rulerStepCount / 4))) | 342 if (!(index % (rulerStepCount / 4))) |
| 325 y = -rulerWidth / 2; | 343 copyHeight = WebInspector.ResponsiveDesignView.RulerHeight * 0.5
; |
| 326 if (!(index % (rulerStepCount / 2))) | 344 if (!(index % (rulerStepCount / 2))) { |
| 327 y = -rulerWidth + 2; | 345 context.strokeStyle = rulerOverlayColor; |
| 328 | 346 y = -rulerHeight + WebInspector.ResponsiveDesignView.RulerHeight
* 0.25; |
| 347 copyHeight = 0; |
| 348 } |
| 329 if (!(index % rulerStepCount)) { | 349 if (!(index % rulerStepCount)) { |
| 330 context.save(); | 350 context.save(); |
| 331 context.translate(x, 0); | 351 context.translate(x, 0); |
| 332 context.fillText(Math.round(x / scale), 2, -rulerWidth / 2); | 352 context.fillText(Math.round(x / scale), 2, -rulerHeight + 10); |
| 333 context.restore(); | 353 context.restore(); |
| 334 y = -rulerWidth; | 354 y = -rulerHeight; |
| 335 } | 355 } |
| 336 | 356 |
| 337 context.beginPath(); | 357 context.beginPath(); |
| 338 context.moveTo(x, y); | 358 context.moveTo(x, y); |
| 339 context.lineTo(x, 0); | 359 context.lineTo(x, 0); |
| 340 context.stroke(); | 360 context.stroke(); |
| 361 if (copyHeight) { |
| 362 context.beginPath(); |
| 363 context.moveTo(x, -rulerHeight + WebInspector.ResponsiveDesignVi
ew.RulerHeight - copyHeight); |
| 364 context.lineTo(x, -rulerHeight + WebInspector.ResponsiveDesignVi
ew.RulerHeight); |
| 365 context.stroke(); |
| 366 } |
| 367 |
| 368 if (!(index % (rulerStepCount / 2))) |
| 369 context.strokeStyle = rulerColor; |
| 341 } | 370 } |
| 342 context.restore(); | 371 context.restore(); |
| 343 | 372 |
| 344 // Draw horizontal ruler. | 373 // Draw vertical ruler. |
| 345 context.save(); | 374 context.save(); |
| 346 var minYIndex = Math.ceil(dipScrollY / rulerSubStep); | 375 var minYIndex = Math.ceil(dipScrollY / rulerSubStep); |
| 347 var maxYIndex = Math.floor((dipScrollY + dipGridHeight) / rulerSubStep); | 376 var maxYIndex = Math.floor((dipScrollY + dipGridHeight) / rulerSubStep); |
| 348 context.translate(0, -dipScrollY); | 377 context.translate(0, -dipScrollY); |
| 349 for (var index = minYIndex; index <= maxYIndex; index++) { | 378 for (var index = minYIndex; index <= maxYIndex; index++) { |
| 350 var y = index * rulerSubStep; | 379 var y = index * rulerSubStep; |
| 351 var x = -rulerWidth / 4; | 380 var x = -rulerWidth * 0.25; |
| 352 if (!(index % (rulerStepCount / 4))) | 381 if (!(index % (rulerStepCount / 4))) |
| 353 x = -rulerWidth / 2; | 382 x = -rulerWidth * 0.5; |
| 354 if (!(index % (rulerStepCount / 2))) | 383 if (!(index % (rulerStepCount / 2))) |
| 355 x = -rulerWidth + 2; | 384 x = -rulerWidth * 0.75; |
| 356 | 385 |
| 357 if (!(index % rulerStepCount)) { | 386 if (!(index % rulerStepCount)) { |
| 358 context.save(); | 387 context.save(); |
| 359 context.translate(0, y); | 388 context.translate(0, y); |
| 360 context.rotate(-Math.PI / 2); | 389 context.rotate(-Math.PI / 2); |
| 361 context.fillText(Math.round(y / scale), 2, -rulerWidth / 2); | 390 context.fillText(Math.round(y / scale), 2, -rulerWidth + 10); |
| 362 context.restore(); | 391 context.restore(); |
| 363 x = -rulerWidth; | 392 x = -rulerWidth; |
| 364 } | 393 } |
| 365 | 394 |
| 366 context.beginPath(); | 395 context.beginPath(); |
| 367 context.moveTo(x, y); | 396 context.moveTo(x, y); |
| 368 context.lineTo(0, y); | 397 context.lineTo(0, y); |
| 369 context.stroke(); | 398 context.stroke(); |
| 370 } | 399 } |
| 371 context.restore(); | 400 context.restore(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 _updateUI: function() | 453 _updateUI: function() |
| 425 { | 454 { |
| 426 if (!this._enabled || !this.isShowing()) | 455 if (!this._enabled || !this.isShowing()) |
| 427 return; | 456 return; |
| 428 | 457 |
| 429 var zoomFactor = WebInspector.zoomManager.zoomFactor(); | 458 var zoomFactor = WebInspector.zoomManager.zoomFactor(); |
| 430 var rect = this._canvas.parentElement.getBoundingClientRect(); | 459 var rect = this._canvas.parentElement.getBoundingClientRect(); |
| 431 var availableDip = this._availableDipSize(); | 460 var availableDip = this._availableDipSize(); |
| 432 var cssCanvasWidth = rect.width; | 461 var cssCanvasWidth = rect.width; |
| 433 var cssCanvasHeight = rect.height; | 462 var cssCanvasHeight = rect.height; |
| 463 var mediaInspectorHeight = this._mediaInspector.isShowing() ? this._medi
aInspector.element.offsetHeight : 0; |
| 464 var rulerTotalHeight = WebInspector.ResponsiveDesignView.RulerHeight + (
mediaInspectorHeight ? WebInspector.ResponsiveDesignView.RulerBottomHeight : 0); |
| 434 | 465 |
| 435 this._mediaInspector.setAxisTransform(WebInspector.ResponsiveDesignView.
RulerWidth / zoomFactor, this._viewport.scrollX, this._scale * this._viewport.pa
geScaleFactor); | 466 this._mediaInspector.setAxisTransform(this._viewport.scrollX, this._scal
e * this._viewport.pageScaleFactor); |
| 436 | 467 |
| 437 if (this._cachedZoomFactor !== zoomFactor) { | 468 if (this._cachedZoomFactor !== zoomFactor || this._cachedMediaInspectorH
eight !== mediaInspectorHeight) { |
| 438 var cssRulerWidth = WebInspector.ResponsiveDesignView.RulerWidth / z
oomFactor + "px"; | 469 var cssRulerWidth = WebInspector.ResponsiveDesignView.RulerWidth / z
oomFactor + "px"; |
| 439 this._rulerGlasspane.style.height = cssRulerWidth; | 470 var cssRulerHeight = WebInspector.ResponsiveDesignView.RulerHeight /
zoomFactor + "px"; |
| 440 this._rulerGlasspane.style.left = cssRulerWidth; | 471 var cssCanvasOffset = rulerTotalHeight / zoomFactor + mediaInspector
Height + "px"; |
| 441 this._slidersContainer.style.left = cssRulerWidth; | 472 this._slidersContainer.style.left = cssRulerWidth; |
| 442 this._slidersContainer.style.top = cssRulerWidth; | 473 this._slidersContainer.style.top = cssCanvasOffset; |
| 443 this._warningMessage.style.height = cssRulerWidth; | 474 this._warningMessage.style.height = cssRulerHeight; |
| 475 this._mediaInspectorContainer.style.left = cssRulerWidth; |
| 476 this._mediaInspectorContainer.style.top = cssRulerHeight; |
| 444 | 477 |
| 445 var cssSliderWidth = WebInspector.ResponsiveDesignView.SliderWidth /
zoomFactor + "px"; | 478 var cssSliderWidth = WebInspector.ResponsiveDesignView.SliderWidth /
zoomFactor + "px"; |
| 446 this._heightSliderContainer.style.flexBasis = cssSliderWidth; | 479 this._heightSliderContainer.style.flexBasis = cssSliderWidth; |
| 447 this._heightSliderContainer.style.marginBottom = "-" + cssSliderWidt
h; | 480 this._heightSliderContainer.style.marginBottom = "-" + cssSliderWidt
h; |
| 448 this._widthSliderContainer.style.flexBasis = cssSliderWidth; | 481 this._widthSliderContainer.style.flexBasis = cssSliderWidth; |
| 449 this._widthSliderContainer.style.marginRight = "-" + cssSliderWidth; | 482 this._widthSliderContainer.style.marginRight = "-" + cssSliderWidth; |
| 450 } | 483 } |
| 451 | 484 |
| 452 var cssWidth = (this._dipWidth ? this._dipWidth : availableDip.width) /
zoomFactor; | 485 var cssWidth = (this._dipWidth ? this._dipWidth : availableDip.width) /
zoomFactor; |
| 453 var cssHeight = (this._dipHeight ? this._dipHeight : availableDip.height
) / zoomFactor; | 486 var cssHeight = (this._dipHeight ? this._dipHeight : availableDip.height
) / zoomFactor; |
| 454 if (this._cachedCssWidth !== cssWidth || this._cachedCssHeight !== cssHe
ight) { | 487 if (this._cachedCssWidth !== cssWidth || this._cachedCssHeight !== cssHe
ight) { |
| 455 this._slidersContainer.style.width = cssWidth + "px"; | 488 this._slidersContainer.style.width = cssWidth + "px"; |
| 456 this._slidersContainer.style.height = cssHeight + "px"; | 489 this._slidersContainer.style.height = cssHeight + "px"; |
| 457 this._inspectedPagePlaceholder.onResize(); | 490 this._inspectedPagePlaceholder.onResize(); |
| 458 } | 491 } |
| 459 | 492 |
| 460 var pageScaleVisible = cssWidth + WebInspector.ResponsiveDesignView.Page
ScaleContainerWidth + WebInspector.ResponsiveDesignView.RulerWidth <= rect.width
|| | 493 var pageScaleVisible = cssWidth + WebInspector.ResponsiveDesignView.Page
ScaleContainerWidth + WebInspector.ResponsiveDesignView.RulerWidth / zoomFactor
<= rect.width || |
| 461 cssHeight + WebInspector.ResponsiveDesignView.PageScaleContainerHeig
ht + WebInspector.ResponsiveDesignView.RulerWidth <= rect.height; | 494 cssHeight + WebInspector.ResponsiveDesignView.PageScaleContainerHeig
ht + mediaInspectorHeight + rulerTotalHeight / zoomFactor <= rect.height; |
| 462 this._pageScaleContainer.classList.toggle("hidden", !pageScaleVisible); | 495 this._pageScaleContainer.classList.toggle("hidden", !pageScaleVisible); |
| 463 | 496 |
| 464 var viewportChanged = !this._cachedViewport | 497 var viewportChanged = !this._cachedViewport |
| 465 || this._cachedViewport.scrollX !== this._viewport.scrollX || this._
cachedViewport.scrollY !== this._viewport.scrollY | 498 || this._cachedViewport.scrollX !== this._viewport.scrollX || this._
cachedViewport.scrollY !== this._viewport.scrollY |
| 466 || this._cachedViewport.contentsWidth !== this._viewport.contentsWid
th || this._cachedViewport.contentsHeight !== this._viewport.contentsHeight | 499 || this._cachedViewport.contentsWidth !== this._viewport.contentsWid
th || this._cachedViewport.contentsHeight !== this._viewport.contentsHeight |
| 467 || this._cachedViewport.pageScaleFactor !== this._viewport.pageScale
Factor | 500 || this._cachedViewport.pageScaleFactor !== this._viewport.pageScale
Factor |
| 468 || this._cachedViewport.minimumPageScaleFactor !== this._viewport.mi
nimumPageScaleFactor | 501 || this._cachedViewport.minimumPageScaleFactor !== this._viewport.mi
nimumPageScaleFactor |
| 469 || this._cachedViewport.maximumPageScaleFactor !== this._viewport.ma
ximumPageScaleFactor; | 502 || this._cachedViewport.maximumPageScaleFactor !== this._viewport.ma
ximumPageScaleFactor; |
| 470 if (viewportChanged || this._drawContentsSize !== this._cachedDrawConten
tsSize || this._cachedScale !== this._scale || this._cachedCssCanvasWidth !== cs
sCanvasWidth || this._cachedCssCanvasHeight !== cssCanvasHeight || this._cachedZ
oomFactor !== zoomFactor) | 503 |
| 471 this._drawCanvas(cssCanvasWidth, cssCanvasHeight); | 504 var canvasInvalidated = viewportChanged || this._drawContentsSize !== th
is._cachedDrawContentsSize || this._cachedScale !== this._scale || |
| 505 this._cachedCssCanvasWidth !== cssCanvasWidth || this._cachedCssCanv
asHeight !== cssCanvasHeight || this._cachedZoomFactor !== zoomFactor || |
| 506 this._cachedMediaInspectorHeight !== mediaInspectorHeight; |
| 507 |
| 508 if (canvasInvalidated) |
| 509 this._drawCanvas(cssCanvasWidth, cssCanvasHeight, mediaInspectorHeig
ht); |
| 472 | 510 |
| 473 if (viewportChanged) { | 511 if (viewportChanged) { |
| 474 this._pageScaleLabel.textContent = WebInspector.UIString("%.1f", thi
s._viewport.pageScaleFactor); | 512 this._pageScaleLabel.textContent = WebInspector.UIString("%.1f", thi
s._viewport.pageScaleFactor); |
| 475 this._decreasePageScaleButton.title = WebInspector.UIString("Scale d
own (minimum %.1f)", this._viewport.minimumPageScaleFactor); | 513 this._decreasePageScaleButton.title = WebInspector.UIString("Scale d
own (minimum %.1f)", this._viewport.minimumPageScaleFactor); |
| 476 this._decreasePageScaleButton.setEnabled(this._viewport.pageScaleFac
tor > this._viewport.minimumPageScaleFactor); | 514 this._decreasePageScaleButton.setEnabled(this._viewport.pageScaleFac
tor > this._viewport.minimumPageScaleFactor); |
| 477 this._increasePageScaleButton.title = WebInspector.UIString("Scale u
p (maximum %.1f)", this._viewport.maximumPageScaleFactor); | 515 this._increasePageScaleButton.title = WebInspector.UIString("Scale u
p (maximum %.1f)", this._viewport.maximumPageScaleFactor); |
| 478 this._increasePageScaleButton.setEnabled(this._viewport.pageScaleFac
tor < this._viewport.maximumPageScaleFactor); | 516 this._increasePageScaleButton.setEnabled(this._viewport.pageScaleFac
tor < this._viewport.maximumPageScaleFactor); |
| 479 } | 517 } |
| 480 | 518 |
| 481 this._cachedScale = this._scale; | 519 this._cachedScale = this._scale; |
| 482 this._cachedCssCanvasWidth = cssCanvasWidth; | 520 this._cachedCssCanvasWidth = cssCanvasWidth; |
| 483 this._cachedCssCanvasHeight = cssCanvasHeight; | 521 this._cachedCssCanvasHeight = cssCanvasHeight; |
| 484 this._cachedCssHeight = cssHeight; | 522 this._cachedCssHeight = cssHeight; |
| 485 this._cachedCssWidth = cssWidth; | 523 this._cachedCssWidth = cssWidth; |
| 486 this._cachedZoomFactor = zoomFactor; | 524 this._cachedZoomFactor = zoomFactor; |
| 487 this._cachedViewport = this._viewport; | 525 this._cachedViewport = this._viewport; |
| 488 this._cachedDrawContentsSize = this._drawContentsSize; | 526 this._cachedDrawContentsSize = this._drawContentsSize; |
| 527 this._cachedMediaInspectorHeight = mediaInspectorHeight; |
| 489 }, | 528 }, |
| 490 | 529 |
| 491 onResize: function() | 530 onResize: function() |
| 492 { | 531 { |
| 493 if (!this._enabled || this._ignoreResize) | 532 if (!this._enabled || this._ignoreResize) |
| 494 return; | 533 return; |
| 495 var oldSize = this._availableSize; | 534 var oldSize = this._availableSize; |
| 496 delete this._availableSize; | 535 delete this._availableSize; |
| 497 var newSize = this._availableDipSize(); | 536 var newSize = this._availableDipSize(); |
| 498 if (!newSize.isEqual(oldSize)) | 537 if (!newSize.isEqual(oldSize)) |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 value = Math.min(this._viewport.maximumPageScaleFactor, value); | 743 value = Math.min(this._viewport.maximumPageScaleFactor, value); |
| 705 value = Math.max(this._viewport.minimumPageScaleFactor, value) | 744 value = Math.max(this._viewport.minimumPageScaleFactor, value) |
| 706 this._target.pageAgent().setPageScaleFactor(value); | 745 this._target.pageAgent().setPageScaleFactor(value); |
| 707 } | 746 } |
| 708 finishCallback(); | 747 finishCallback(); |
| 709 } | 748 } |
| 710 }, | 749 }, |
| 711 | 750 |
| 712 __proto__: WebInspector.VBox.prototype | 751 __proto__: WebInspector.VBox.prototype |
| 713 }; | 752 }; |
| OLD | NEW |