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 * @param {!WebInspector.InspectedPagePlaceholder} inspectedPagePlaceholder | 9 * @param {!WebInspector.InspectedPagePlaceholder} inspectedPagePlaceholder |
10 */ | 10 */ |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 this._widthSlider.createChild("div", "responsive-design-thumb-handle"); | 49 this._widthSlider.createChild("div", "responsive-design-thumb-handle"); |
50 this._createResizer(this._widthSlider, false); | 50 this._createResizer(this._widthSlider, false); |
51 this._heightSlider = this._heightSliderContainer.createChild("div", "respons
ive-design-slider-thumb"); | 51 this._heightSlider = this._heightSliderContainer.createChild("div", "respons
ive-design-slider-thumb"); |
52 this._heightSlider.createChild("div", "responsive-design-thumb-handle"); | 52 this._heightSlider.createChild("div", "responsive-design-thumb-handle"); |
53 this._createResizer(this._heightSlider, true); | 53 this._createResizer(this._heightSlider, true); |
54 | 54 |
55 this._inspectedPagePlaceholder = inspectedPagePlaceholder; | 55 this._inspectedPagePlaceholder = inspectedPagePlaceholder; |
56 inspectedPagePlaceholder.show(this.element); | 56 inspectedPagePlaceholder.show(this.element); |
57 | 57 |
58 this._enabled = false; | 58 this._enabled = false; |
| 59 this._viewport = { scrollX: 0, scrollY: 0, contentsWidth: 0, contentsHeight:
0, pageScaleFactor: 1 }; |
| 60 this._drawContentsSize = true; |
| 61 this._viewportChangedThrottler = new WebInspector.Throttler(0); |
59 | 62 |
60 WebInspector.zoomManager.addEventListener(WebInspector.ZoomManager.Events.Zo
omChanged, this._onZoomChanged, this); | 63 WebInspector.zoomManager.addEventListener(WebInspector.ZoomManager.Events.Zo
omChanged, this._onZoomChanged, this); |
61 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport
.Events.EmulationStateChanged, this._emulationEnabledChanged, this); | 64 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport
.Events.EmulationStateChanged, this._emulationEnabledChanged, this); |
62 this._mediaInspector.addEventListener(WebInspector.MediaQueryInspector.Event
s.HeightUpdated, this.onResize, this); | 65 this._mediaInspector.addEventListener(WebInspector.MediaQueryInspector.Event
s.HeightUpdated, this.onResize, this); |
| 66 WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeMod
el.EventTypes.ViewportChanged, this._viewportChanged, this); |
| 67 |
63 this._emulationEnabledChanged(); | 68 this._emulationEnabledChanged(); |
64 this._overridesWarningUpdated(); | 69 this._overridesWarningUpdated(); |
65 }; | 70 }; |
66 | 71 |
67 // Measured in DIP. | 72 // Measured in DIP. |
68 WebInspector.ResponsiveDesignView.SliderWidth = 19; | 73 WebInspector.ResponsiveDesignView.SliderWidth = 19; |
69 WebInspector.ResponsiveDesignView.RulerWidth = 22; | 74 WebInspector.ResponsiveDesignView.RulerWidth = 22; |
70 | 75 |
71 WebInspector.ResponsiveDesignView.prototype = { | 76 WebInspector.ResponsiveDesignView.prototype = { |
72 _invalidateCache: function() | 77 _invalidateCache: function() |
73 { | 78 { |
74 delete this._cachedScale; | 79 delete this._cachedScale; |
75 delete this._cachedCssCanvasWidth; | 80 delete this._cachedCssCanvasWidth; |
76 delete this._cachedCssCanvasHeight; | 81 delete this._cachedCssCanvasHeight; |
77 delete this._cachedCssHeight; | 82 delete this._cachedCssHeight; |
78 delete this._cachedCssWidth; | 83 delete this._cachedCssWidth; |
79 delete this._cachedZoomFactor; | 84 delete this._cachedZoomFactor; |
| 85 delete this._cachedViewport; |
| 86 delete this._cachedDrawContentsSize; |
80 delete this._availableSize; | 87 delete this._availableSize; |
81 }, | 88 }, |
82 | 89 |
83 _emulationEnabledChanged: function() | 90 _emulationEnabledChanged: function() |
84 { | 91 { |
85 var enabled = WebInspector.overridesSupport.emulationEnabled(); | 92 var enabled = WebInspector.overridesSupport.emulationEnabled(); |
86 this._mediaInspector.setEnabled(enabled); | 93 this._mediaInspector.setEnabled(enabled); |
87 if (enabled && !this._enabled) { | 94 if (enabled && !this._enabled) { |
88 this._invalidateCache(); | 95 this._invalidateCache(); |
89 this._ignoreResize = true; | 96 this._ignoreResize = true; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 resizer.addEventListener(WebInspector.ResizerWidget.Events.ResizeUpdate,
this._onResizeUpdate, this); | 160 resizer.addEventListener(WebInspector.ResizerWidget.Events.ResizeUpdate,
this._onResizeUpdate, this); |
154 resizer.addEventListener(WebInspector.ResizerWidget.Events.ResizeEnd, th
is._onResizeEnd, this); | 161 resizer.addEventListener(WebInspector.ResizerWidget.Events.ResizeEnd, th
is._onResizeEnd, this); |
155 return resizer; | 162 return resizer; |
156 }, | 163 }, |
157 | 164 |
158 /** | 165 /** |
159 * @param {!WebInspector.Event} event | 166 * @param {!WebInspector.Event} event |
160 */ | 167 */ |
161 _onResizeStart: function(event) | 168 _onResizeStart: function(event) |
162 { | 169 { |
| 170 this._drawContentsSize = false; |
163 var available = this._availableDipSize(); | 171 var available = this._availableDipSize(); |
164 this._slowPositionStart = null; | 172 this._slowPositionStart = null; |
165 this._resizeStartSize = event.target.isVertical() ? (this._dipHeight ||
available.height) : (this._dipWidth || available.width); | 173 this._resizeStartSize = event.target.isVertical() ? (this._dipHeight ||
available.height) : (this._dipWidth || available.width); |
166 this.dispatchEventToListeners(WebInspector.OverridesSupport.PageResizer.
Events.FixedScaleRequested, true); | 174 this.dispatchEventToListeners(WebInspector.OverridesSupport.PageResizer.
Events.FixedScaleRequested, true); |
| 175 this._updateUI(); |
167 }, | 176 }, |
168 | 177 |
169 /** | 178 /** |
170 * @param {!WebInspector.Event} event | 179 * @param {!WebInspector.Event} event |
171 */ | 180 */ |
172 _onResizeUpdate: function(event) | 181 _onResizeUpdate: function(event) |
173 { | 182 { |
174 if (event.data.shiftKey !== !!this._slowPositionStart) | 183 if (event.data.shiftKey !== !!this._slowPositionStart) |
175 this._slowPositionStart = event.data.shiftKey ? event.data.currentPo
sition : null; | 184 this._slowPositionStart = event.data.shiftKey ? event.data.currentPo
sition : null; |
176 var cssOffset = this._slowPositionStart ? (event.data.currentPosition -
this._slowPositionStart) / 10 + this._slowPositionStart - event.data.startPositi
on : event.data.currentPosition - event.data.startPosition; | 185 var cssOffset = this._slowPositionStart ? (event.data.currentPosition -
this._slowPositionStart) / 10 + this._slowPositionStart - event.data.startPositi
on : event.data.currentPosition - event.data.startPosition; |
177 var dipOffset = Math.round(cssOffset * WebInspector.zoomManager.zoomFact
or()); | 186 var dipOffset = Math.round(cssOffset * WebInspector.zoomManager.zoomFact
or()); |
178 var newSize = this._resizeStartSize + dipOffset; | 187 var newSize = this._resizeStartSize + dipOffset; |
179 newSize = Math.round(newSize / (this._scale || 1)); | 188 newSize = Math.round(newSize / (this._scale || 1)); |
180 newSize = Math.max(Math.min(newSize, WebInspector.OverridesSupport.MaxDe
viceSize), 1); | 189 newSize = Math.max(Math.min(newSize, WebInspector.OverridesSupport.MaxDe
viceSize), 1); |
181 var requested = {}; | 190 var requested = {}; |
182 if (event.target.isVertical()) | 191 if (event.target.isVertical()) |
183 requested.height = newSize; | 192 requested.height = newSize; |
184 else | 193 else |
185 requested.width = newSize; | 194 requested.width = newSize; |
186 this.dispatchEventToListeners(WebInspector.OverridesSupport.PageResizer.
Events.ResizeRequested, requested); | 195 this.dispatchEventToListeners(WebInspector.OverridesSupport.PageResizer.
Events.ResizeRequested, requested); |
187 }, | 196 }, |
188 | 197 |
189 /** | 198 /** |
190 * @param {!WebInspector.Event} event | 199 * @param {!WebInspector.Event} event |
191 */ | 200 */ |
192 _onResizeEnd: function(event) | 201 _onResizeEnd: function(event) |
193 { | 202 { |
| 203 this._drawContentsSize = true; |
194 this.dispatchEventToListeners(WebInspector.OverridesSupport.PageResizer.
Events.FixedScaleRequested, false); | 204 this.dispatchEventToListeners(WebInspector.OverridesSupport.PageResizer.
Events.FixedScaleRequested, false); |
195 delete this._resizeStartSize; | 205 delete this._resizeStartSize; |
| 206 this._updateUI(); |
196 }, | 207 }, |
197 | 208 |
198 /** | 209 /** |
199 * Draws canvas of the specified css size in DevTools page space. | 210 * Draws canvas of the specified css size in DevTools page space. |
200 * Canvas contains grid and rulers. | 211 * Canvas contains grid and rulers. |
201 * @param {number} cssCanvasWidth | 212 * @param {number} cssCanvasWidth |
202 * @param {number} cssCanvasHeight | 213 * @param {number} cssCanvasHeight |
203 */ | 214 */ |
204 _drawCanvas: function(cssCanvasWidth, cssCanvasHeight) | 215 _drawCanvas: function(cssCanvasWidth, cssCanvasHeight) |
205 { | 216 { |
(...skipping 14 matching lines...) Expand all Loading... |
220 canvas.height = deviceScaleFactor * cssCanvasHeight; | 231 canvas.height = deviceScaleFactor * cssCanvasHeight; |
221 context.scale(canvas.width / dipCanvasWidth, canvas.height / dipCanvasHe
ight); | 232 context.scale(canvas.width / dipCanvasWidth, canvas.height / dipCanvasHe
ight); |
222 context.font = "11px " + WebInspector.fontFamily(); | 233 context.font = "11px " + WebInspector.fontFamily(); |
223 | 234 |
224 const rulerBackgroundColor = "rgb(0, 0, 0)"; | 235 const rulerBackgroundColor = "rgb(0, 0, 0)"; |
225 const backgroundColor = "rgb(102, 102, 102)"; | 236 const backgroundColor = "rgb(102, 102, 102)"; |
226 const lightLineColor = "rgb(132, 132, 132)"; | 237 const lightLineColor = "rgb(132, 132, 132)"; |
227 const darkLineColor = "rgb(114, 114, 114)"; | 238 const darkLineColor = "rgb(114, 114, 114)"; |
228 const rulerColor = "rgb(125, 125, 125)"; | 239 const rulerColor = "rgb(125, 125, 125)"; |
229 const textColor = "rgb(186, 186, 186)"; | 240 const textColor = "rgb(186, 186, 186)"; |
| 241 const contentsSizeColor = "rgba(128, 128, 128, 0.5)"; |
230 | 242 |
231 var scale = this._scale || 1; | 243 var scale = (this._scale || 1) * this._viewport.pageScaleFactor; |
232 var rulerScale = 1; | 244 var rulerScale = 0.5; |
233 while (Math.abs(rulerScale * scale - 1) > Math.abs((rulerScale + 1) * sc
ale - 1)) | 245 while (Math.abs(rulerScale * scale - 1) > Math.abs((rulerScale + 0.5) *
scale - 1)) |
234 rulerScale++; | 246 rulerScale += 0.5; |
235 | 247 |
236 var gridStep = 50 * scale * rulerScale; | 248 var gridStep = 50 * scale * rulerScale; |
237 var gridSubStep = 10 * scale * rulerScale; | 249 var gridSubStep = 10 * scale * rulerScale; |
238 | 250 |
239 var rulerSubStep = 5 * scale * rulerScale; | 251 var rulerSubStep = 5 * scale * rulerScale; |
240 var rulerStepCount = 20; | 252 var rulerStepCount = 20; |
241 | 253 |
242 var rulerWidth = WebInspector.ResponsiveDesignView.RulerWidth; | 254 var rulerWidth = WebInspector.ResponsiveDesignView.RulerWidth; |
243 var dipGridWidth = dipCanvasWidth - rulerWidth; | 255 var dipGridWidth = dipCanvasWidth - rulerWidth; |
244 var dipGridHeight = dipCanvasHeight - rulerWidth; | 256 var dipGridHeight = dipCanvasHeight - rulerWidth; |
| 257 var dipScrollX = this._viewport.scrollX * scale; |
| 258 var dipScrollY = this._viewport.scrollY * scale; |
245 context.translate(rulerWidth, rulerWidth); | 259 context.translate(rulerWidth, rulerWidth); |
246 | 260 |
247 context.fillStyle = rulerBackgroundColor; | 261 context.fillStyle = rulerBackgroundColor; |
248 context.fillRect(-rulerWidth, -rulerWidth, dipGridWidth + rulerWidth, ru
lerWidth); | 262 context.fillRect(-rulerWidth, -rulerWidth, dipGridWidth + rulerWidth, ru
lerWidth); |
249 context.fillRect(-rulerWidth, 0, rulerWidth, dipGridHeight); | 263 context.fillRect(-rulerWidth, 0, rulerWidth, dipGridHeight); |
250 | 264 |
251 context.fillStyle = backgroundColor; | 265 context.fillStyle = backgroundColor; |
252 context.fillRect(0, 0, dipGridWidth, dipGridHeight); | 266 context.fillRect(0, 0, dipGridWidth, dipGridHeight); |
253 | 267 |
254 context.translate(0.5, 0.5); | 268 context.translate(0.5, 0.5); |
255 context.strokeStyle = rulerColor; | 269 context.strokeStyle = rulerColor; |
256 context.fillStyle = textColor; | 270 context.fillStyle = textColor; |
257 context.lineWidth = 1; | 271 context.lineWidth = 1; |
258 | 272 |
259 // Draw vertical ruler. | 273 // Draw vertical ruler. |
260 for (var x, index = 0; (x = index * rulerSubStep) < dipGridWidth; index+
+) { | 274 context.save(); |
| 275 var minXIndex = Math.ceil(dipScrollX / rulerSubStep); |
| 276 var maxXIndex = Math.floor((dipScrollX + dipGridWidth) / rulerSubStep); |
| 277 context.translate(-dipScrollX, 0); |
| 278 for (var index = minXIndex; index <= maxXIndex; index++) { |
| 279 var x = index * rulerSubStep; |
261 var y = -rulerWidth / 4; | 280 var y = -rulerWidth / 4; |
262 if (!(index % (rulerStepCount / 4))) | 281 if (!(index % (rulerStepCount / 4))) |
263 y = -rulerWidth / 2; | 282 y = -rulerWidth / 2; |
264 if (!(index % (rulerStepCount / 2))) | 283 if (!(index % (rulerStepCount / 2))) |
265 y = -rulerWidth + 2; | 284 y = -rulerWidth + 2; |
266 | 285 |
267 if (!(index % rulerStepCount)) { | 286 if (!(index % rulerStepCount)) { |
268 context.save(); | 287 context.save(); |
269 context.translate(x, 0); | 288 context.translate(x, 0); |
270 context.fillText(Math.round(x / scale), 2, -rulerWidth / 2); | 289 context.fillText(Math.round(x / scale), 2, -rulerWidth / 2); |
271 context.restore(); | 290 context.restore(); |
272 y = -rulerWidth; | 291 y = -rulerWidth; |
273 } | 292 } |
274 | 293 |
275 context.beginPath(); | 294 context.beginPath(); |
276 context.moveTo(x, y); | 295 context.moveTo(x, y); |
277 context.lineTo(x, 0); | 296 context.lineTo(x, 0); |
278 context.stroke(); | 297 context.stroke(); |
279 } | 298 } |
| 299 context.restore(); |
280 | 300 |
281 // Draw horizontal ruler. | 301 // Draw horizontal ruler. |
282 for (var y, index = 0; (y = index * rulerSubStep) < dipGridHeight; index
++) { | 302 context.save(); |
| 303 var minYIndex = Math.ceil(dipScrollY / rulerSubStep); |
| 304 var maxYIndex = Math.floor((dipScrollY + dipGridHeight) / rulerSubStep); |
| 305 context.translate(0, -dipScrollY); |
| 306 for (var index = minYIndex; index <= maxYIndex; index++) { |
| 307 var y = index * rulerSubStep; |
283 var x = -rulerWidth / 4; | 308 var x = -rulerWidth / 4; |
284 if (!(index % (rulerStepCount / 4))) | 309 if (!(index % (rulerStepCount / 4))) |
285 x = -rulerWidth / 2; | 310 x = -rulerWidth / 2; |
286 if (!(index % (rulerStepCount / 2))) | 311 if (!(index % (rulerStepCount / 2))) |
287 x = -rulerWidth + 2; | 312 x = -rulerWidth + 2; |
288 | 313 |
289 if (!(index % rulerStepCount)) { | 314 if (!(index % rulerStepCount)) { |
290 context.save(); | 315 context.save(); |
291 context.translate(0, y); | 316 context.translate(0, y); |
292 context.rotate(-Math.PI / 2); | 317 context.rotate(-Math.PI / 2); |
293 context.fillText(Math.round(y / scale), 2, -rulerWidth / 2); | 318 context.fillText(Math.round(y / scale), 2, -rulerWidth / 2); |
294 context.restore(); | 319 context.restore(); |
295 x = -rulerWidth; | 320 x = -rulerWidth; |
296 } | 321 } |
297 | 322 |
298 context.beginPath(); | 323 context.beginPath(); |
299 context.moveTo(x, y); | 324 context.moveTo(x, y); |
300 context.lineTo(0, y); | 325 context.lineTo(0, y); |
301 context.stroke(); | 326 context.stroke(); |
302 } | 327 } |
| 328 context.restore(); |
303 | 329 |
304 // Draw grid. | 330 // Draw grid. |
305 drawGrid(darkLineColor, gridSubStep); | 331 drawGrid(dipScrollX, dipScrollY, darkLineColor, gridSubStep); |
306 drawGrid(lightLineColor, gridStep); | 332 drawGrid(dipScrollX, dipScrollY, lightLineColor, gridStep); |
307 | 333 |
308 /** | 334 /** |
| 335 * @param {number} scrollX |
| 336 * @param {number} scrollY |
309 * @param {string} color | 337 * @param {string} color |
310 * @param {number} step | 338 * @param {number} step |
311 */ | 339 */ |
312 function drawGrid(color, step) | 340 function drawGrid(scrollX, scrollY, color, step) |
313 { | 341 { |
314 context.strokeStyle = color; | 342 context.strokeStyle = color; |
315 for (var x = 0; x < dipGridWidth; x += step) { | 343 var minX = Math.ceil(scrollX / step) * step; |
| 344 var maxX = Math.floor((scrollX + dipGridWidth) / step) * step - minX
; |
| 345 var minY = Math.ceil(scrollY / step) * step; |
| 346 var maxY = Math.floor((scrollY + dipGridHeight) / step) * step - min
Y; |
| 347 |
| 348 context.save(); |
| 349 context.translate(minX - scrollX, 0); |
| 350 for (var x = 0; x <= maxX; x += step) { |
316 context.beginPath(); | 351 context.beginPath(); |
317 context.moveTo(x, 0); | 352 context.moveTo(x, 0); |
318 context.lineTo(x, dipGridHeight); | 353 context.lineTo(x, dipGridHeight); |
319 context.stroke(); | 354 context.stroke(); |
320 } | 355 } |
321 for (var y = 0; y < dipGridHeight; y += step) { | 356 context.restore(); |
| 357 |
| 358 context.save(); |
| 359 context.translate(0, minY - scrollY); |
| 360 for (var y = 0; y <= maxY; y += step) { |
322 context.beginPath(); | 361 context.beginPath(); |
323 context.moveTo(0, y); | 362 context.moveTo(0, y); |
324 context.lineTo(dipGridWidth, y); | 363 context.lineTo(dipGridWidth, y); |
325 context.stroke(); | 364 context.stroke(); |
326 } | 365 } |
| 366 context.restore(); |
| 367 } |
| 368 |
| 369 context.translate(-0.5, -0.5); |
| 370 |
| 371 // Draw contents size. |
| 372 if (this._drawContentsSize) { |
| 373 context.fillStyle = contentsSizeColor; |
| 374 var visibleContentsWidth = Math.max(0, Math.min(dipGridWidth, this._
viewport.contentsWidth * scale - dipScrollX)); |
| 375 var visibleContentsHeight = Math.max(0, Math.min(dipGridHeight, this
._viewport.contentsHeight * scale - dipScrollY)); |
| 376 context.fillRect(0, 0, visibleContentsWidth, visibleContentsHeight); |
327 } | 377 } |
328 }, | 378 }, |
329 | 379 |
330 _updateUI: function() | 380 _updateUI: function() |
331 { | 381 { |
332 if (!this._enabled || !this.isShowing()) | 382 if (!this._enabled || !this.isShowing()) |
333 return; | 383 return; |
334 | 384 |
335 var zoomFactor = WebInspector.zoomManager.zoomFactor(); | 385 var zoomFactor = WebInspector.zoomManager.zoomFactor(); |
336 var rect = this._canvas.parentElement.getBoundingClientRect(); | 386 var rect = this._canvas.parentElement.getBoundingClientRect(); |
337 var availableDip = this._availableDipSize(); | 387 var availableDip = this._availableDipSize(); |
338 var cssCanvasWidth = rect.width; | 388 var cssCanvasWidth = rect.width; |
339 var cssCanvasHeight = rect.height; | 389 var cssCanvasHeight = rect.height; |
340 | 390 |
341 this._mediaInspector.setAxisTransform(WebInspector.ResponsiveDesignView.
RulerWidth / zoomFactor, this._scale); | 391 this._mediaInspector.setAxisTransform(WebInspector.ResponsiveDesignView.
RulerWidth / zoomFactor, this._viewport.scrollX, this._scale * this._viewport.pa
geScaleFactor); |
342 | 392 |
343 if (this._cachedZoomFactor !== zoomFactor) { | 393 if (this._cachedZoomFactor !== zoomFactor) { |
344 var cssRulerWidth = WebInspector.ResponsiveDesignView.RulerWidth / z
oomFactor + "px"; | 394 var cssRulerWidth = WebInspector.ResponsiveDesignView.RulerWidth / z
oomFactor + "px"; |
345 this._rulerGlasspane.style.height = cssRulerWidth; | 395 this._rulerGlasspane.style.height = cssRulerWidth; |
346 this._rulerGlasspane.style.left = cssRulerWidth; | 396 this._rulerGlasspane.style.left = cssRulerWidth; |
347 this._slidersContainer.style.left = cssRulerWidth; | 397 this._slidersContainer.style.left = cssRulerWidth; |
348 this._slidersContainer.style.top = cssRulerWidth; | 398 this._slidersContainer.style.top = cssRulerWidth; |
349 this._warningMessage.style.height = cssRulerWidth; | 399 this._warningMessage.style.height = cssRulerWidth; |
350 | 400 |
351 var cssSliderWidth = WebInspector.ResponsiveDesignView.SliderWidth /
zoomFactor + "px"; | 401 var cssSliderWidth = WebInspector.ResponsiveDesignView.SliderWidth /
zoomFactor + "px"; |
352 this._heightSliderContainer.style.flexBasis = cssSliderWidth; | 402 this._heightSliderContainer.style.flexBasis = cssSliderWidth; |
353 this._heightSliderContainer.style.marginBottom = "-" + cssSliderWidt
h; | 403 this._heightSliderContainer.style.marginBottom = "-" + cssSliderWidt
h; |
354 this._widthSliderContainer.style.flexBasis = cssSliderWidth; | 404 this._widthSliderContainer.style.flexBasis = cssSliderWidth; |
355 this._widthSliderContainer.style.marginRight = "-" + cssSliderWidth; | 405 this._widthSliderContainer.style.marginRight = "-" + cssSliderWidth; |
356 } | 406 } |
357 | 407 |
358 var cssWidth = this._dipWidth ? (this._dipWidth / zoomFactor + "px") : (
availableDip.width / zoomFactor + "px"); | 408 var cssWidth = this._dipWidth ? (this._dipWidth / zoomFactor + "px") : (
availableDip.width / zoomFactor + "px"); |
359 this._widthSliderContainer.classList.toggle("hidden", !this._dipWidth); | 409 this._widthSliderContainer.classList.toggle("hidden", !this._dipWidth); |
360 this._heightSliderContainer.classList.toggle("hidden", !this._dipHeight)
; | 410 this._heightSliderContainer.classList.toggle("hidden", !this._dipHeight)
; |
361 var cssHeight = this._dipHeight ? (this._dipHeight / zoomFactor + "px")
: (availableDip.height / zoomFactor + "px"); | 411 var cssHeight = this._dipHeight ? (this._dipHeight / zoomFactor + "px")
: (availableDip.height / zoomFactor + "px"); |
362 if (this._cachedCssWidth !== cssWidth || this._cachedCssHeight !== cssHe
ight) { | 412 if (this._cachedCssWidth !== cssWidth || this._cachedCssHeight !== cssHe
ight) { |
363 this._slidersContainer.style.width = cssWidth; | 413 this._slidersContainer.style.width = cssWidth; |
364 this._slidersContainer.style.height = cssHeight; | 414 this._slidersContainer.style.height = cssHeight; |
365 this._inspectedPagePlaceholder.onResize(); | 415 this._inspectedPagePlaceholder.onResize(); |
366 } | 416 } |
367 | 417 |
368 if (this._cachedScale !== this._scale || this._cachedCssCanvasWidth !==
cssCanvasWidth || this._cachedCssCanvasHeight !== cssCanvasHeight || this._cache
dZoomFactor !== zoomFactor) | 418 var viewportChanged = !this._cachedViewport |
| 419 || this._cachedViewport.scrollX !== this._viewport.scrollX || this._
cachedViewport.scrollY !== this._viewport.scrollY |
| 420 || this._cachedViewport.contentsWidth !== this._viewport.contentsWid
th || this._cachedViewport.contentsHeight !== this._viewport.contentsHeight |
| 421 || this._cachedViewport.pageScaleFactor !== this._viewport.pageScale
Factor; |
| 422 if (viewportChanged || this._drawContentsSize !== this._cachedDrawConten
tsSize || this._cachedScale !== this._scale || this._cachedCssCanvasWidth !== cs
sCanvasWidth || this._cachedCssCanvasHeight !== cssCanvasHeight || this._cachedZ
oomFactor !== zoomFactor) |
369 this._drawCanvas(cssCanvasWidth, cssCanvasHeight); | 423 this._drawCanvas(cssCanvasWidth, cssCanvasHeight); |
370 | 424 |
371 this._cachedScale = this._scale; | 425 this._cachedScale = this._scale; |
372 this._cachedCssCanvasWidth = cssCanvasWidth; | 426 this._cachedCssCanvasWidth = cssCanvasWidth; |
373 this._cachedCssCanvasHeight = cssCanvasHeight; | 427 this._cachedCssCanvasHeight = cssCanvasHeight; |
374 this._cachedCssHeight = cssHeight; | 428 this._cachedCssHeight = cssHeight; |
375 this._cachedCssWidth = cssWidth; | 429 this._cachedCssWidth = cssWidth; |
376 this._cachedZoomFactor = zoomFactor; | 430 this._cachedZoomFactor = zoomFactor; |
| 431 this._cachedViewport = this._viewport; |
| 432 this._cachedDrawContentsSize = this._drawContentsSize; |
377 }, | 433 }, |
378 | 434 |
379 onResize: function() | 435 onResize: function() |
380 { | 436 { |
381 if (!this._enabled || this._ignoreResize) | 437 if (!this._enabled || this._ignoreResize) |
382 return; | 438 return; |
383 var oldSize = this._availableSize; | 439 var oldSize = this._availableSize; |
384 delete this._availableSize; | 440 delete this._availableSize; |
385 var newSize = this._availableDipSize(); | 441 var newSize = this._availableDipSize(); |
386 if (!newSize.isEqual(oldSize)) | 442 if (!newSize.isEqual(oldSize)) |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 this._warningMessage.querySelector("span").textContent = message; | 582 this._warningMessage.querySelector("span").textContent = message; |
527 this._invalidateCache(); | 583 this._invalidateCache(); |
528 this.onResize(); | 584 this.onResize(); |
529 }, | 585 }, |
530 | 586 |
531 _showEmulationInDrawer: function() | 587 _showEmulationInDrawer: function() |
532 { | 588 { |
533 WebInspector.overridesSupport.reveal(); | 589 WebInspector.overridesSupport.reveal(); |
534 }, | 590 }, |
535 | 591 |
| 592 /** |
| 593 * @param {!WebInspector.Event} event |
| 594 */ |
| 595 _viewportChanged: function(event) |
| 596 { |
| 597 var viewport = /** @type {?PageAgent.Viewport} */ (event.data); |
| 598 if (viewport) { |
| 599 this._viewport = viewport; |
| 600 this._viewportChangedThrottler.schedule(this._updateUIThrottled.bind
(this)); |
| 601 } |
| 602 }, |
| 603 |
| 604 /** |
| 605 * @param {!WebInspector.Throttler.FinishCallback} finishCallback |
| 606 */ |
| 607 _updateUIThrottled: function(finishCallback) |
| 608 { |
| 609 this._updateUI(); |
| 610 finishCallback(); |
| 611 }, |
| 612 |
536 __proto__: WebInspector.VBox.prototype | 613 __proto__: WebInspector.VBox.prototype |
537 }; | 614 }; |
OLD | NEW |