| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 * @param {number} rowHeight | 8 * @param {number} rowHeight |
| 9 * @param {!WebInspector.NetworkTimeCalculator} calculator | 9 * @param {!WebInspector.NetworkTimeCalculator} calculator |
| 10 */ | 10 */ |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 /** @type {!Array<!WebInspector.NetworkRequest>} */ | 36 /** @type {!Array<!WebInspector.NetworkRequest>} */ |
| 37 this._requestData = []; | 37 this._requestData = []; |
| 38 | 38 |
| 39 /** @type {?WebInspector.NetworkRequest} */ | 39 /** @type {?WebInspector.NetworkRequest} */ |
| 40 this._hoveredRequest = null; | 40 this._hoveredRequest = null; |
| 41 | 41 |
| 42 /** @type {?WebInspector.NetworkRequest} */ | 42 /** @type {?WebInspector.NetworkRequest} */ |
| 43 this._navigationRequest = null; | 43 this._navigationRequest = null; |
| 44 | 44 |
| 45 /** @type {!Map<string, !Array<number>>} */ |
| 46 this._eventDividers = new Map(); |
| 47 |
| 45 var colorUsage = WebInspector.ThemeSupport.ColorUsage; | 48 var colorUsage = WebInspector.ThemeSupport.ColorUsage; |
| 46 this._rowNavigationRequestColor = WebInspector.themeSupport.patchColor("#def
", colorUsage.Background); | 49 this._rowNavigationRequestColor = WebInspector.themeSupport.patchColor("#def
", colorUsage.Background); |
| 47 this._rowStripeColor = WebInspector.themeSupport.patchColor("#f5f5f5", color
Usage.Background); | 50 this._rowStripeColor = WebInspector.themeSupport.patchColor("#f5f5f5", color
Usage.Background); |
| 48 this._rowHoverColor = WebInspector.themeSupport.patchColor("#ebf2fc", /** @t
ype {!WebInspector.ThemeSupport.ColorUsage} */ (colorUsage.Background | colorUsa
ge.Selection)); | 51 this._rowHoverColor = WebInspector.themeSupport.patchColor("#ebf2fc", /** @t
ype {!WebInspector.ThemeSupport.ColorUsage} */ (colorUsage.Background | colorUsa
ge.Selection)); |
| 49 | 52 |
| 50 /** @type {!Map<!WebInspector.ResourceType, string>} */ | 53 /** @type {!Map<!WebInspector.ResourceType, string>} */ |
| 51 this._borderColorsForResourceTypeCache = new Map(); | 54 this._borderColorsForResourceTypeCache = new Map(); |
| 52 /** @type {!Map<string, !CanvasGradient>} */ | 55 /** @type {!Map<string, !CanvasGradient>} */ |
| 53 this._colorsForResourceTypeCache = new Map(); | 56 this._colorsForResourceTypeCache = new Map(); |
| 54 }; | 57 }; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 184 |
| 182 scheduleDraw: function() | 185 scheduleDraw: function() |
| 183 { | 186 { |
| 184 if (this._updateRequestID) | 187 if (this._updateRequestID) |
| 185 return; | 188 return; |
| 186 this._updateRequestID = this.element.window().requestAnimationFrame(() =
> this.update()); | 189 this._updateRequestID = this.element.window().requestAnimationFrame(() =
> this.update()); |
| 187 }, | 190 }, |
| 188 | 191 |
| 189 /** | 192 /** |
| 190 * @param {number=} scrollTop | 193 * @param {number=} scrollTop |
| 194 * @param {!Map<string, !Array<number>>=} eventDividers |
| 191 * @param {!{requests: !Array<!WebInspector.NetworkRequest>, navigationReque
st: ?WebInspector.NetworkRequest}=} requestData | 195 * @param {!{requests: !Array<!WebInspector.NetworkRequest>, navigationReque
st: ?WebInspector.NetworkRequest}=} requestData |
| 192 */ | 196 */ |
| 193 update: function(scrollTop, requestData) | 197 update: function(scrollTop, eventDividers, requestData) |
| 194 { | 198 { |
| 195 if (scrollTop !== undefined) | 199 if (scrollTop !== undefined) |
| 196 this._scrollTop = scrollTop; | 200 this._scrollTop = scrollTop; |
| 197 if (requestData) { | 201 if (requestData) { |
| 198 this._requestData = requestData.requests; | 202 this._requestData = requestData.requests; |
| 199 this._navigationRequest = requestData.navigationRequest; | 203 this._navigationRequest = requestData.navigationRequest; |
| 200 this._calculateCanvasSize(); | 204 this._calculateCanvasSize(); |
| 201 } | 205 } |
| 206 if (eventDividers !== undefined) |
| 207 this._eventDividers = eventDividers; |
| 202 this.element.window().cancelAnimationFrame(this._updateRequestID); | 208 this.element.window().cancelAnimationFrame(this._updateRequestID); |
| 203 this._updateRequestID = null; | 209 this._updateRequestID = null; |
| 204 | 210 |
| 205 this._startTime = this._calculator.minimumBoundary(); | 211 this._startTime = this._calculator.minimumBoundary(); |
| 206 this._endTime = this._calculator.maximumBoundary(); | 212 this._endTime = this._calculator.maximumBoundary(); |
| 207 this._resetCanvas(); | 213 this._resetCanvas(); |
| 208 this._draw(); | 214 this._draw(); |
| 209 }, | 215 }, |
| 210 | 216 |
| 211 _resetCanvas: function() | 217 _resetCanvas: function() |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 return Math.floor(this._leftPadding + (time - this._startTime) * timeToP
ixel); | 284 return Math.floor(this._leftPadding + (time - this._startTime) * timeToP
ixel); |
| 279 }, | 285 }, |
| 280 | 286 |
| 281 _draw: function() | 287 _draw: function() |
| 282 { | 288 { |
| 283 var useTimingBars = !WebInspector.moduleSetting("networkColorCodeResourc
eTypes").get() && !this._calculator.startAtZero; | 289 var useTimingBars = !WebInspector.moduleSetting("networkColorCodeResourc
eTypes").get() && !this._calculator.startAtZero; |
| 284 var requests = this._requestData; | 290 var requests = this._requestData; |
| 285 var context = this._canvas.getContext("2d"); | 291 var context = this._canvas.getContext("2d"); |
| 286 context.save(); | 292 context.save(); |
| 287 context.scale(window.devicePixelRatio, window.devicePixelRatio); | 293 context.scale(window.devicePixelRatio, window.devicePixelRatio); |
| 294 context.save(); |
| 288 context.translate(0, this._headerHeight); | 295 context.translate(0, this._headerHeight); |
| 289 context.rect(0, 0, this._offsetWidth, this._offsetHeight); | 296 context.rect(0, 0, this._offsetWidth, this._offsetHeight); |
| 290 context.clip(); | 297 context.clip(); |
| 291 var firstRequestIndex = Math.floor(this._scrollTop / this._rowHeight); | 298 var firstRequestIndex = Math.floor(this._scrollTop / this._rowHeight); |
| 292 var lastRequestIndex = Math.min(requests.length, firstRequestIndex + Mat
h.ceil(this._offsetHeight / this._rowHeight)); | 299 var lastRequestIndex = Math.min(requests.length, firstRequestIndex + Mat
h.ceil(this._offsetHeight / this._rowHeight)); |
| 293 for (var i = firstRequestIndex; i < lastRequestIndex; i++) { | 300 for (var i = firstRequestIndex; i < lastRequestIndex; i++) { |
| 294 var rowOffset = this._rowHeight * i; | 301 var rowOffset = this._rowHeight * i; |
| 295 var request = requests[i]; | 302 var request = requests[i]; |
| 296 this._decorateRow(context, request, i, rowOffset - this._scrollTop); | 303 this._decorateRow(context, request, i, rowOffset - this._scrollTop); |
| 297 if (useTimingBars) | 304 if (useTimingBars) |
| 298 this._drawTimingBars(context, request, rowOffset - this._scrollT
op); | 305 this._drawTimingBars(context, request, rowOffset - this._scrollT
op); |
| 299 else | 306 else |
| 300 this._drawSimplifiedBars(context, request, rowOffset - this._scr
ollTop); | 307 this._drawSimplifiedBars(context, request, rowOffset - this._scr
ollTop); |
| 301 } | 308 } |
| 309 this._drawEventDividers(context); |
| 302 context.restore(); | 310 context.restore(); |
| 311 // This is outside of the save/restore above because it must draw in hea
der. |
| 303 this._drawDividers(context); | 312 this._drawDividers(context); |
| 313 context.restore(); |
| 304 }, | 314 }, |
| 305 | 315 |
| 316 /** |
| 317 * @param {!CanvasRenderingContext2D} context |
| 318 */ |
| 319 _drawEventDividers: function(context) |
| 320 { |
| 321 context.save(); |
| 322 context.lineWidth = 1; |
| 323 for (var color of this._eventDividers.keys()) { |
| 324 context.strokeStyle = color; |
| 325 for (var time of this._eventDividers.get(color)) { |
| 326 context.beginPath(); |
| 327 var x = this._timeToPosition(time); |
| 328 context.moveTo(x, 0); |
| 329 context.lineTo(x, this._offsetHeight); |
| 330 } |
| 331 context.stroke(); |
| 332 } |
| 333 context.restore(); |
| 334 }, |
| 335 |
| 336 /** |
| 337 * @param {!CanvasRenderingContext2D} context |
| 338 */ |
| 306 _drawDividers: function(context) | 339 _drawDividers: function(context) |
| 307 { | 340 { |
| 308 context.save(); | 341 context.save(); |
| 309 /** @const */ | 342 /** @const */ |
| 310 var minGridSlicePx = 64; // minimal distance between grid lines. | 343 var minGridSlicePx = 64; // minimal distance between grid lines. |
| 311 | 344 |
| 312 var drawableWidth = this._offsetWidth - this._leftPadding; | 345 var drawableWidth = this._offsetWidth - this._leftPadding; |
| 313 var timelineDuration = this._timelineDuration(); | 346 var timelineDuration = this._timelineDuration(); |
| 314 var dividersCount = drawableWidth / minGridSlicePx; | 347 var dividersCount = drawableWidth / minGridSlicePx; |
| 315 var gridSliceTime = timelineDuration / dividersCount; | 348 var gridSliceTime = timelineDuration / dividersCount; |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 color = this._rowNavigationRequestColor; | 611 color = this._rowNavigationRequestColor; |
| 579 | 612 |
| 580 context.fillStyle = color; | 613 context.fillStyle = color; |
| 581 context.rect(0, y, this._offsetWidth, this._rowHeight); | 614 context.rect(0, y, this._offsetWidth, this._rowHeight); |
| 582 context.fill(); | 615 context.fill(); |
| 583 context.restore(); | 616 context.restore(); |
| 584 }, | 617 }, |
| 585 | 618 |
| 586 __proto__: WebInspector.VBox.prototype | 619 __proto__: WebInspector.VBox.prototype |
| 587 }; | 620 }; |
| OLD | NEW |