| 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 * @unrestricted | 5 * @unrestricted |
| 6 */ | 6 */ |
| 7 WebInspector.NetworkWaterfallColumn = class extends WebInspector.VBox { | 7 Network.NetworkWaterfallColumn = class extends UI.VBox { |
| 8 /** | 8 /** |
| 9 * @param {number} rowHeight | 9 * @param {number} rowHeight |
| 10 * @param {!WebInspector.NetworkTimeCalculator} calculator | 10 * @param {!Network.NetworkTimeCalculator} calculator |
| 11 */ | 11 */ |
| 12 constructor(rowHeight, calculator) { | 12 constructor(rowHeight, calculator) { |
| 13 // TODO(allada) Make this a shadowDOM when the NetworkWaterfallColumn gets m
oved into NetworkLogViewColumns. | 13 // TODO(allada) Make this a shadowDOM when the NetworkWaterfallColumn gets m
oved into NetworkLogViewColumns. |
| 14 super(false); | 14 super(false); |
| 15 this.registerRequiredCSS('network/networkWaterfallColumn.css'); | 15 this.registerRequiredCSS('network/networkWaterfallColumn.css'); |
| 16 | 16 |
| 17 this._canvas = this.contentElement.createChild('canvas'); | 17 this._canvas = this.contentElement.createChild('canvas'); |
| 18 this._canvas.tabIndex = 1; | 18 this._canvas.tabIndex = 1; |
| 19 this.setDefaultFocusedElement(this._canvas); | 19 this.setDefaultFocusedElement(this._canvas); |
| 20 this._canvasPosition = this._canvas.getBoundingClientRect(); | 20 this._canvasPosition = this._canvas.getBoundingClientRect(); |
| 21 | 21 |
| 22 /** @const */ | 22 /** @const */ |
| 23 this._leftPadding = 5; | 23 this._leftPadding = 5; |
| 24 /** @const */ | 24 /** @const */ |
| 25 this._fontSize = 10; | 25 this._fontSize = 10; |
| 26 | 26 |
| 27 this._rightPadding = 0; | 27 this._rightPadding = 0; |
| 28 | 28 |
| 29 this._rowHeight = rowHeight; | 29 this._rowHeight = rowHeight; |
| 30 this._headerHeight = 0; | 30 this._headerHeight = 0; |
| 31 this._calculator = calculator; | 31 this._calculator = calculator; |
| 32 | 32 |
| 33 this._popoverHelper = new WebInspector.PopoverHelper(this.element); | 33 this._popoverHelper = new UI.PopoverHelper(this.element); |
| 34 this._popoverHelper.initializeCallbacks(this._getPopoverAnchor.bind(this), t
his._showPopover.bind(this)); | 34 this._popoverHelper.initializeCallbacks(this._getPopoverAnchor.bind(this), t
his._showPopover.bind(this)); |
| 35 this._popoverHelper.setTimeout(300, 300); | 35 this._popoverHelper.setTimeout(300, 300); |
| 36 | 36 |
| 37 /** @type {!Array<!WebInspector.NetworkRequest>} */ | 37 /** @type {!Array<!SDK.NetworkRequest>} */ |
| 38 this._requestData = []; | 38 this._requestData = []; |
| 39 | 39 |
| 40 /** @type {?WebInspector.NetworkRequest} */ | 40 /** @type {?SDK.NetworkRequest} */ |
| 41 this._hoveredRequest = null; | 41 this._hoveredRequest = null; |
| 42 /** @type {?WebInspector.NetworkRequest.InitiatorGraph} */ | 42 /** @type {?SDK.NetworkRequest.InitiatorGraph} */ |
| 43 this._initiatorGraph = null; | 43 this._initiatorGraph = null; |
| 44 | 44 |
| 45 /** @type {?WebInspector.NetworkRequest} */ | 45 /** @type {?SDK.NetworkRequest} */ |
| 46 this._navigationRequest = null; | 46 this._navigationRequest = null; |
| 47 | 47 |
| 48 /** @type {!Map<string, !Array<number>>} */ | 48 /** @type {!Map<string, !Array<number>>} */ |
| 49 this._eventDividers = new Map(); | 49 this._eventDividers = new Map(); |
| 50 | 50 |
| 51 var colorUsage = WebInspector.ThemeSupport.ColorUsage; | 51 var colorUsage = UI.ThemeSupport.ColorUsage; |
| 52 this._rowNavigationRequestColor = WebInspector.themeSupport.patchColor('#def
', colorUsage.Background); | 52 this._rowNavigationRequestColor = UI.themeSupport.patchColor('#def', colorUs
age.Background); |
| 53 this._rowStripeColor = WebInspector.themeSupport.patchColor('#f5f5f5', color
Usage.Background); | 53 this._rowStripeColor = UI.themeSupport.patchColor('#f5f5f5', colorUsage.Back
ground); |
| 54 this._rowHoverColor = WebInspector.themeSupport.patchColor( | 54 this._rowHoverColor = UI.themeSupport.patchColor( |
| 55 '#ebf2fc', /** @type {!WebInspector.ThemeSupport.ColorUsage} */ (colorUs
age.Background | colorUsage.Selection)); | 55 '#ebf2fc', /** @type {!UI.ThemeSupport.ColorUsage} */ (colorUsage.Backgr
ound | colorUsage.Selection)); |
| 56 this._parentInitiatorColor = | 56 this._parentInitiatorColor = |
| 57 WebInspector.themeSupport.patchColor('hsla(120, 68%, 54%, 0.2)', colorUs
age.Background); | 57 UI.themeSupport.patchColor('hsla(120, 68%, 54%, 0.2)', colorUsage.Backgr
ound); |
| 58 this._initiatedColor = WebInspector.themeSupport.patchColor('hsla(0, 68%, 54
%, 0.2)', colorUsage.Background); | 58 this._initiatedColor = UI.themeSupport.patchColor('hsla(0, 68%, 54%, 0.2)',
colorUsage.Background); |
| 59 | 59 |
| 60 /** @type {!Map<!WebInspector.ResourceType, string>} */ | 60 /** @type {!Map<!Common.ResourceType, string>} */ |
| 61 this._borderColorsForResourceTypeCache = new Map(); | 61 this._borderColorsForResourceTypeCache = new Map(); |
| 62 /** @type {!Map<string, !CanvasGradient>} */ | 62 /** @type {!Map<string, !CanvasGradient>} */ |
| 63 this._colorsForResourceTypeCache = new Map(); | 63 this._colorsForResourceTypeCache = new Map(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 /** | 66 /** |
| 67 * @override | 67 * @override |
| 68 */ | 68 */ |
| 69 willHide() { | 69 willHide() { |
| 70 this._popoverHelper.hidePopover(); | 70 this._popoverHelper.hidePopover(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 /** | 73 /** |
| 74 * @override | 74 * @override |
| 75 */ | 75 */ |
| 76 wasShown() { | 76 wasShown() { |
| 77 this.update(); | 77 this.update(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 /** | 80 /** |
| 81 * @param {!Element} element | 81 * @param {!Element} element |
| 82 * @param {!Event} event | 82 * @param {!Event} event |
| 83 * @return {!AnchorBox|undefined} | 83 * @return {!AnchorBox|undefined} |
| 84 */ | 84 */ |
| 85 _getPopoverAnchor(element, event) { | 85 _getPopoverAnchor(element, event) { |
| 86 if (!this._hoveredRequest) | 86 if (!this._hoveredRequest) |
| 87 return; | 87 return; |
| 88 var useTimingBars = | 88 var useTimingBars = |
| 89 !WebInspector.moduleSetting('networkColorCodeResourceTypes').get() && !t
his._calculator.startAtZero; | 89 !Common.moduleSetting('networkColorCodeResourceTypes').get() && !this._c
alculator.startAtZero; |
| 90 if (useTimingBars) { | 90 if (useTimingBars) { |
| 91 var range = WebInspector.RequestTimingView.calculateRequestTimeRanges(this
._hoveredRequest, 0) | 91 var range = Network.RequestTimingView.calculateRequestTimeRanges(this._hov
eredRequest, 0) |
| 92 .find(data => data.name === WebInspector.RequestTimeRangeNames.Total); | 92 .find(data => data.name === Network.RequestTimeRangeNames.Total); |
| 93 var start = this._timeToPosition(range.start); | 93 var start = this._timeToPosition(range.start); |
| 94 var end = this._timeToPosition(range.end); | 94 var end = this._timeToPosition(range.end); |
| 95 } else { | 95 } else { |
| 96 var range = this._getSimplifiedBarRange(this._hoveredRequest, 0); | 96 var range = this._getSimplifiedBarRange(this._hoveredRequest, 0); |
| 97 var start = range.start; | 97 var start = range.start; |
| 98 var end = range.end; | 98 var end = range.end; |
| 99 } | 99 } |
| 100 | 100 |
| 101 if (end - start < 50) { | 101 if (end - start < 50) { |
| 102 var halfWidth = (end - start) / 2; | 102 var halfWidth = (end - start) / 2; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 117 var anchorBox = this.element.boxInWindow(); | 117 var anchorBox = this.element.boxInWindow(); |
| 118 anchorBox.x += start; | 118 anchorBox.x += start; |
| 119 anchorBox.y += y; | 119 anchorBox.y += y; |
| 120 anchorBox.width = end - start; | 120 anchorBox.width = end - start; |
| 121 anchorBox.height = barHeight; | 121 anchorBox.height = barHeight; |
| 122 return anchorBox; | 122 return anchorBox; |
| 123 } | 123 } |
| 124 | 124 |
| 125 /** | 125 /** |
| 126 * @param {!Element|!AnchorBox} anchor | 126 * @param {!Element|!AnchorBox} anchor |
| 127 * @param {!WebInspector.Popover} popover | 127 * @param {!UI.Popover} popover |
| 128 */ | 128 */ |
| 129 _showPopover(anchor, popover) { | 129 _showPopover(anchor, popover) { |
| 130 if (!this._hoveredRequest) | 130 if (!this._hoveredRequest) |
| 131 return; | 131 return; |
| 132 var content = | 132 var content = |
| 133 WebInspector.RequestTimingView.createTimingTable(this._hoveredRequest, t
his._calculator.minimumBoundary()); | 133 Network.RequestTimingView.createTimingTable(this._hoveredRequest, this._
calculator.minimumBoundary()); |
| 134 popover.showForAnchor(content, anchor); | 134 popover.showForAnchor(content, anchor); |
| 135 } | 135 } |
| 136 | 136 |
| 137 /** | 137 /** |
| 138 * @param {?WebInspector.NetworkRequest} request | 138 * @param {?SDK.NetworkRequest} request |
| 139 * @param {boolean} highlightInitiatorChain | 139 * @param {boolean} highlightInitiatorChain |
| 140 */ | 140 */ |
| 141 setHoveredRequest(request, highlightInitiatorChain) { | 141 setHoveredRequest(request, highlightInitiatorChain) { |
| 142 this._hoveredRequest = request; | 142 this._hoveredRequest = request; |
| 143 this._initiatorGraph = (highlightInitiatorChain && request) ? request.initia
torGraph() : null; | 143 this._initiatorGraph = (highlightInitiatorChain && request) ? request.initia
torGraph() : null; |
| 144 this.update(); | 144 this.update(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 /** | 147 /** |
| 148 * @param {number} height | 148 * @param {number} height |
| (...skipping 11 matching lines...) Expand all Loading... |
| 160 | 160 |
| 161 /** | 161 /** |
| 162 * @param {number} padding | 162 * @param {number} padding |
| 163 */ | 163 */ |
| 164 setRightPadding(padding) { | 164 setRightPadding(padding) { |
| 165 this._rightPadding = padding; | 165 this._rightPadding = padding; |
| 166 this._calculateCanvasSize(); | 166 this._calculateCanvasSize(); |
| 167 } | 167 } |
| 168 | 168 |
| 169 /** | 169 /** |
| 170 * @param {!WebInspector.NetworkTimeCalculator} calculator | 170 * @param {!Network.NetworkTimeCalculator} calculator |
| 171 */ | 171 */ |
| 172 setCalculator(calculator) { | 172 setCalculator(calculator) { |
| 173 this._calculator = calculator; | 173 this._calculator = calculator; |
| 174 } | 174 } |
| 175 | 175 |
| 176 /** | 176 /** |
| 177 * @param {number} x | 177 * @param {number} x |
| 178 * @param {number} y | 178 * @param {number} y |
| 179 * @return {?WebInspector.NetworkRequest} | 179 * @return {?SDK.NetworkRequest} |
| 180 */ | 180 */ |
| 181 getRequestFromPoint(x, y) { | 181 getRequestFromPoint(x, y) { |
| 182 return this._requestData[Math.floor((this._scrollTop + y - this._headerHeigh
t) / this._rowHeight)] || null; | 182 return this._requestData[Math.floor((this._scrollTop + y - this._headerHeigh
t) / this._rowHeight)] || null; |
| 183 } | 183 } |
| 184 | 184 |
| 185 scheduleDraw() { | 185 scheduleDraw() { |
| 186 if (this._updateRequestID) | 186 if (this._updateRequestID) |
| 187 return; | 187 return; |
| 188 this._updateRequestID = this.element.window().requestAnimationFrame(() => th
is.update()); | 188 this._updateRequestID = this.element.window().requestAnimationFrame(() => th
is.update()); |
| 189 } | 189 } |
| 190 | 190 |
| 191 /** | 191 /** |
| 192 * @param {number=} scrollTop | 192 * @param {number=} scrollTop |
| 193 * @param {!Map<string, !Array<number>>=} eventDividers | 193 * @param {!Map<string, !Array<number>>=} eventDividers |
| 194 * @param {!WebInspector.NetworkWaterfallColumn.RequestData=} requestData | 194 * @param {!Network.NetworkWaterfallColumn.RequestData=} requestData |
| 195 */ | 195 */ |
| 196 update(scrollTop, eventDividers, requestData) { | 196 update(scrollTop, eventDividers, requestData) { |
| 197 if (scrollTop !== undefined) | 197 if (scrollTop !== undefined) |
| 198 this._scrollTop = scrollTop; | 198 this._scrollTop = scrollTop; |
| 199 if (requestData) { | 199 if (requestData) { |
| 200 this._requestData = requestData.requests; | 200 this._requestData = requestData.requests; |
| 201 this._navigationRequest = requestData.navigationRequest; | 201 this._navigationRequest = requestData.navigationRequest; |
| 202 this._calculateCanvasSize(); | 202 this._calculateCanvasSize(); |
| 203 } | 203 } |
| 204 if (eventDividers !== undefined) | 204 if (eventDividers !== undefined) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 230 } | 230 } |
| 231 | 231 |
| 232 _calculateCanvasSize() { | 232 _calculateCanvasSize() { |
| 233 this._offsetWidth = this.contentElement.offsetWidth - this._rightPadding; | 233 this._offsetWidth = this.contentElement.offsetWidth - this._rightPadding; |
| 234 this._offsetHeight = this.contentElement.offsetHeight; | 234 this._offsetHeight = this.contentElement.offsetHeight; |
| 235 this._calculator.setDisplayWindow(this._offsetWidth); | 235 this._calculator.setDisplayWindow(this._offsetWidth); |
| 236 this._canvasPosition = this._canvas.getBoundingClientRect(); | 236 this._canvasPosition = this._canvas.getBoundingClientRect(); |
| 237 } | 237 } |
| 238 | 238 |
| 239 /** | 239 /** |
| 240 * @param {!WebInspector.RequestTimeRangeNames} type | 240 * @param {!Network.RequestTimeRangeNames} type |
| 241 * @return {string} | 241 * @return {string} |
| 242 */ | 242 */ |
| 243 _colorForType(type) { | 243 _colorForType(type) { |
| 244 var types = WebInspector.RequestTimeRangeNames; | 244 var types = Network.RequestTimeRangeNames; |
| 245 switch (type) { | 245 switch (type) { |
| 246 case types.Receiving: | 246 case types.Receiving: |
| 247 case types.ReceivingPush: | 247 case types.ReceivingPush: |
| 248 return '#03A9F4'; | 248 return '#03A9F4'; |
| 249 case types.Waiting: | 249 case types.Waiting: |
| 250 return '#00C853'; | 250 return '#00C853'; |
| 251 case types.Connecting: | 251 case types.Connecting: |
| 252 return '#FF9800'; | 252 return '#FF9800'; |
| 253 case types.SSL: | 253 case types.SSL: |
| 254 return '#9C27B0'; | 254 return '#9C27B0'; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 274 * @return {number} | 274 * @return {number} |
| 275 */ | 275 */ |
| 276 _timeToPosition(time) { | 276 _timeToPosition(time) { |
| 277 var availableWidth = this._offsetWidth - this._leftPadding; | 277 var availableWidth = this._offsetWidth - this._leftPadding; |
| 278 var timeToPixel = availableWidth / (this._endTime - this._startTime); | 278 var timeToPixel = availableWidth / (this._endTime - this._startTime); |
| 279 return Math.floor(this._leftPadding + (time - this._startTime) * timeToPixel
); | 279 return Math.floor(this._leftPadding + (time - this._startTime) * timeToPixel
); |
| 280 } | 280 } |
| 281 | 281 |
| 282 _draw() { | 282 _draw() { |
| 283 var useTimingBars = | 283 var useTimingBars = |
| 284 !WebInspector.moduleSetting('networkColorCodeResourceTypes').get() && !t
his._calculator.startAtZero; | 284 !Common.moduleSetting('networkColorCodeResourceTypes').get() && !this._c
alculator.startAtZero; |
| 285 var requests = this._requestData; | 285 var requests = this._requestData; |
| 286 var context = this._canvas.getContext('2d'); | 286 var context = this._canvas.getContext('2d'); |
| 287 context.save(); | 287 context.save(); |
| 288 context.scale(window.devicePixelRatio, window.devicePixelRatio); | 288 context.scale(window.devicePixelRatio, window.devicePixelRatio); |
| 289 context.translate(0, this._headerHeight); | 289 context.translate(0, this._headerHeight); |
| 290 context.rect(0, 0, this._offsetWidth, this._offsetHeight); | 290 context.rect(0, 0, this._offsetWidth, this._offsetHeight); |
| 291 context.clip(); | 291 context.clip(); |
| 292 var firstRequestIndex = Math.floor(this._scrollTop / this._rowHeight); | 292 var firstRequestIndex = Math.floor(this._scrollTop / this._rowHeight); |
| 293 var lastRequestIndex = | 293 var lastRequestIndex = |
| 294 Math.min(requests.length, firstRequestIndex + Math.ceil(this._offsetHeig
ht / this._rowHeight)); | 294 Math.min(requests.length, firstRequestIndex + Math.ceil(this._offsetHeig
ht / this._rowHeight)); |
| 295 for (var i = firstRequestIndex; i < lastRequestIndex; i++) { | 295 for (var i = firstRequestIndex; i < lastRequestIndex; i++) { |
| 296 var rowOffset = this._rowHeight * i; | 296 var rowOffset = this._rowHeight * i; |
| 297 var request = requests[i]; | 297 var request = requests[i]; |
| 298 this._decorateRow(context, request, i, rowOffset - this._scrollTop); | 298 this._decorateRow(context, request, i, rowOffset - this._scrollTop); |
| 299 if (useTimingBars) | 299 if (useTimingBars) |
| 300 this._drawTimingBars(context, request, rowOffset - this._scrollTop); | 300 this._drawTimingBars(context, request, rowOffset - this._scrollTop); |
| 301 else | 301 else |
| 302 this._drawSimplifiedBars(context, request, rowOffset - this._scrollTop); | 302 this._drawSimplifiedBars(context, request, rowOffset - this._scrollTop); |
| 303 } | 303 } |
| 304 this._drawEventDividers(context); | 304 this._drawEventDividers(context); |
| 305 context.restore(); | 305 context.restore(); |
| 306 | 306 |
| 307 const freeZoneAtLeft = 75; | 307 const freeZoneAtLeft = 75; |
| 308 WebInspector.TimelineGrid.drawCanvasGrid(context, this._calculator, this._fo
ntSize, freeZoneAtLeft); | 308 UI.TimelineGrid.drawCanvasGrid(context, this._calculator, this._fontSize, fr
eeZoneAtLeft); |
| 309 } | 309 } |
| 310 | 310 |
| 311 /** | 311 /** |
| 312 * @param {!CanvasRenderingContext2D} context | 312 * @param {!CanvasRenderingContext2D} context |
| 313 */ | 313 */ |
| 314 _drawEventDividers(context) { | 314 _drawEventDividers(context) { |
| 315 context.save(); | 315 context.save(); |
| 316 context.lineWidth = 1; | 316 context.lineWidth = 1; |
| 317 for (var color of this._eventDividers.keys()) { | 317 for (var color of this._eventDividers.keys()) { |
| 318 context.strokeStyle = color; | 318 context.strokeStyle = color; |
| 319 for (var time of this._eventDividers.get(color)) { | 319 for (var time of this._eventDividers.get(color)) { |
| 320 context.beginPath(); | 320 context.beginPath(); |
| 321 var x = this._timeToPosition(time); | 321 var x = this._timeToPosition(time); |
| 322 context.moveTo(x, 0); | 322 context.moveTo(x, 0); |
| 323 context.lineTo(x, this._offsetHeight); | 323 context.lineTo(x, this._offsetHeight); |
| 324 } | 324 } |
| 325 context.stroke(); | 325 context.stroke(); |
| 326 } | 326 } |
| 327 context.restore(); | 327 context.restore(); |
| 328 } | 328 } |
| 329 | 329 |
| 330 /** | 330 /** |
| 331 * @return {number} | 331 * @return {number} |
| 332 */ | 332 */ |
| 333 _waterfallDuration() { | 333 _waterfallDuration() { |
| 334 return this._calculator.maximumBoundary() - this._calculator.minimumBoundary
(); | 334 return this._calculator.maximumBoundary() - this._calculator.minimumBoundary
(); |
| 335 } | 335 } |
| 336 | 336 |
| 337 /** | 337 /** |
| 338 * @param {!WebInspector.RequestTimeRangeNames=} type | 338 * @param {!Network.RequestTimeRangeNames=} type |
| 339 * @return {number} | 339 * @return {number} |
| 340 */ | 340 */ |
| 341 _getBarHeight(type) { | 341 _getBarHeight(type) { |
| 342 var types = WebInspector.RequestTimeRangeNames; | 342 var types = Network.RequestTimeRangeNames; |
| 343 switch (type) { | 343 switch (type) { |
| 344 case types.Connecting: | 344 case types.Connecting: |
| 345 case types.SSL: | 345 case types.SSL: |
| 346 case types.DNS: | 346 case types.DNS: |
| 347 case types.Proxy: | 347 case types.Proxy: |
| 348 case types.Blocking: | 348 case types.Blocking: |
| 349 case types.Push: | 349 case types.Push: |
| 350 case types.Queueing: | 350 case types.Queueing: |
| 351 return 7; | 351 return 7; |
| 352 default: | 352 default: |
| 353 return 13; | 353 return 13; |
| 354 } | 354 } |
| 355 } | 355 } |
| 356 | 356 |
| 357 /** | 357 /** |
| 358 * @param {!WebInspector.NetworkRequest} request | 358 * @param {!SDK.NetworkRequest} request |
| 359 * @return {string} | 359 * @return {string} |
| 360 */ | 360 */ |
| 361 _borderColorForResourceType(request) { | 361 _borderColorForResourceType(request) { |
| 362 var resourceType = request.resourceType(); | 362 var resourceType = request.resourceType(); |
| 363 if (this._borderColorsForResourceTypeCache.has(resourceType)) | 363 if (this._borderColorsForResourceTypeCache.has(resourceType)) |
| 364 return this._borderColorsForResourceTypeCache.get(resourceType); | 364 return this._borderColorsForResourceTypeCache.get(resourceType); |
| 365 var colorsForResourceType = WebInspector.NetworkWaterfallColumn._colorsForRe
sourceType; | 365 var colorsForResourceType = Network.NetworkWaterfallColumn._colorsForResourc
eType; |
| 366 var color = colorsForResourceType[resourceType] || colorsForResourceType.Oth
er; | 366 var color = colorsForResourceType[resourceType] || colorsForResourceType.Oth
er; |
| 367 var parsedColor = WebInspector.Color.parse(color); | 367 var parsedColor = Common.Color.parse(color); |
| 368 var hsla = parsedColor.hsla(); | 368 var hsla = parsedColor.hsla(); |
| 369 hsla[1] /= 2; | 369 hsla[1] /= 2; |
| 370 hsla[2] -= Math.min(hsla[2], 0.2); | 370 hsla[2] -= Math.min(hsla[2], 0.2); |
| 371 var resultColor = /** @type {string} */ (parsedColor.asString(null)); | 371 var resultColor = /** @type {string} */ (parsedColor.asString(null)); |
| 372 this._borderColorsForResourceTypeCache.set(resourceType, resultColor); | 372 this._borderColorsForResourceTypeCache.set(resourceType, resultColor); |
| 373 return resultColor; | 373 return resultColor; |
| 374 } | 374 } |
| 375 | 375 |
| 376 /** | 376 /** |
| 377 * @param {!CanvasRenderingContext2D} context | 377 * @param {!CanvasRenderingContext2D} context |
| 378 * @param {!WebInspector.NetworkRequest} request | 378 * @param {!SDK.NetworkRequest} request |
| 379 * @return {string|!CanvasGradient} | 379 * @return {string|!CanvasGradient} |
| 380 */ | 380 */ |
| 381 _colorForResourceType(context, request) { | 381 _colorForResourceType(context, request) { |
| 382 var colorsForResourceType = WebInspector.NetworkWaterfallColumn._colorsForRe
sourceType; | 382 var colorsForResourceType = Network.NetworkWaterfallColumn._colorsForResourc
eType; |
| 383 var resourceType = request.resourceType(); | 383 var resourceType = request.resourceType(); |
| 384 var color = colorsForResourceType[resourceType] || colorsForResourceType.Oth
er; | 384 var color = colorsForResourceType[resourceType] || colorsForResourceType.Oth
er; |
| 385 if (request.cached()) | 385 if (request.cached()) |
| 386 return color; | 386 return color; |
| 387 | 387 |
| 388 if (this._colorsForResourceTypeCache.has(color)) | 388 if (this._colorsForResourceTypeCache.has(color)) |
| 389 return this._colorsForResourceTypeCache.get(color); | 389 return this._colorsForResourceTypeCache.get(color); |
| 390 var parsedColor = WebInspector.Color.parse(color); | 390 var parsedColor = Common.Color.parse(color); |
| 391 var hsla = parsedColor.hsla(); | 391 var hsla = parsedColor.hsla(); |
| 392 hsla[1] -= Math.min(hsla[1], 0.28); | 392 hsla[1] -= Math.min(hsla[1], 0.28); |
| 393 hsla[2] -= Math.min(hsla[2], 0.15); | 393 hsla[2] -= Math.min(hsla[2], 0.15); |
| 394 var gradient = context.createLinearGradient(0, 0, 0, this._getBarHeight()); | 394 var gradient = context.createLinearGradient(0, 0, 0, this._getBarHeight()); |
| 395 gradient.addColorStop(0, color); | 395 gradient.addColorStop(0, color); |
| 396 gradient.addColorStop(1, /** @type {string} */ (parsedColor.asString(null)))
; | 396 gradient.addColorStop(1, /** @type {string} */ (parsedColor.asString(null)))
; |
| 397 this._colorsForResourceTypeCache.set(color, gradient); | 397 this._colorsForResourceTypeCache.set(color, gradient); |
| 398 return gradient; | 398 return gradient; |
| 399 } | 399 } |
| 400 | 400 |
| 401 /** | 401 /** |
| 402 * @param {!WebInspector.NetworkRequest} request | 402 * @param {!SDK.NetworkRequest} request |
| 403 * @param {number} borderOffset | 403 * @param {number} borderOffset |
| 404 * @return {!{start: number, mid: number, end: number}} | 404 * @return {!{start: number, mid: number, end: number}} |
| 405 */ | 405 */ |
| 406 _getSimplifiedBarRange(request, borderOffset) { | 406 _getSimplifiedBarRange(request, borderOffset) { |
| 407 var drawWidth = this._offsetWidth - this._leftPadding; | 407 var drawWidth = this._offsetWidth - this._leftPadding; |
| 408 var percentages = this._calculator.computeBarGraphPercentages(request); | 408 var percentages = this._calculator.computeBarGraphPercentages(request); |
| 409 return { | 409 return { |
| 410 start: this._leftPadding + Math.floor((percentages.start / 100) * drawWidt
h) + borderOffset, | 410 start: this._leftPadding + Math.floor((percentages.start / 100) * drawWidt
h) + borderOffset, |
| 411 mid: this._leftPadding + Math.floor((percentages.middle / 100) * drawWidth
) + borderOffset, | 411 mid: this._leftPadding + Math.floor((percentages.middle / 100) * drawWidth
) + borderOffset, |
| 412 end: this._leftPadding + Math.floor((percentages.end / 100) * drawWidth) +
borderOffset | 412 end: this._leftPadding + Math.floor((percentages.end / 100) * drawWidth) +
borderOffset |
| 413 }; | 413 }; |
| 414 } | 414 } |
| 415 | 415 |
| 416 /** | 416 /** |
| 417 * @param {!CanvasRenderingContext2D} context | 417 * @param {!CanvasRenderingContext2D} context |
| 418 * @param {!WebInspector.NetworkRequest} request | 418 * @param {!SDK.NetworkRequest} request |
| 419 * @param {number} y | 419 * @param {number} y |
| 420 */ | 420 */ |
| 421 _drawSimplifiedBars(context, request, y) { | 421 _drawSimplifiedBars(context, request, y) { |
| 422 const borderWidth = 1; | 422 const borderWidth = 1; |
| 423 var borderOffset = borderWidth % 2 === 0 ? 0 : 0.5; | 423 var borderOffset = borderWidth % 2 === 0 ? 0 : 0.5; |
| 424 | 424 |
| 425 context.save(); | 425 context.save(); |
| 426 var ranges = this._getSimplifiedBarRange(request, borderOffset); | 426 var ranges = this._getSimplifiedBarRange(request, borderOffset); |
| 427 var height = this._getBarHeight(); | 427 var height = this._getBarHeight(); |
| 428 y += Math.floor(this._rowHeight / 2 - height / 2 + borderWidth) - borderWidt
h / 2; | 428 y += Math.floor(this._rowHeight / 2 - height / 2 + borderWidth) - borderWidt
h / 2; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 447 | 447 |
| 448 /** @type {?{left: string, right: string, tooltip: (string|undefined)}} */ | 448 /** @type {?{left: string, right: string, tooltip: (string|undefined)}} */ |
| 449 var labels = null; | 449 var labels = null; |
| 450 if (request === this._hoveredRequest) { | 450 if (request === this._hoveredRequest) { |
| 451 labels = this._calculator.computeBarGraphLabels(request); | 451 labels = this._calculator.computeBarGraphLabels(request); |
| 452 this._drawSimplifiedBarDetails( | 452 this._drawSimplifiedBarDetails( |
| 453 context, labels.left, labels.right, ranges.start, ranges.mid, ranges.m
id + barWidth + borderOffset); | 453 context, labels.left, labels.right, ranges.start, ranges.mid, ranges.m
id + barWidth + borderOffset); |
| 454 } | 454 } |
| 455 | 455 |
| 456 if (!this._calculator.startAtZero) { | 456 if (!this._calculator.startAtZero) { |
| 457 var queueingRange = WebInspector.RequestTimingView.calculateRequestTimeRan
ges(request, 0) | 457 var queueingRange = Network.RequestTimingView.calculateRequestTimeRanges(r
equest, 0) |
| 458 .find(data => data.name === WebInspector.RequestTimeRangeNames.Total); | 458 .find(data => data.name === Network.RequestTimeRangeNames.Total); |
| 459 var leftLabelWidth = labels ? context.measureText(labels.left).width : 0; | 459 var leftLabelWidth = labels ? context.measureText(labels.left).width : 0; |
| 460 var leftTextPlacedInBar = leftLabelWidth < ranges.mid - ranges.start; | 460 var leftTextPlacedInBar = leftLabelWidth < ranges.mid - ranges.start; |
| 461 const wiskerTextPadding = 13; | 461 const wiskerTextPadding = 13; |
| 462 var textOffset = (labels && !leftTextPlacedInBar) ? leftLabelWidth + wiske
rTextPadding : 0; | 462 var textOffset = (labels && !leftTextPlacedInBar) ? leftLabelWidth + wiske
rTextPadding : 0; |
| 463 var queueingStart = this._timeToPosition(queueingRange.start); | 463 var queueingStart = this._timeToPosition(queueingRange.start); |
| 464 if (ranges.start - textOffset > queueingStart) { | 464 if (ranges.start - textOffset > queueingStart) { |
| 465 context.beginPath(); | 465 context.beginPath(); |
| 466 context.globalAlpha = 1; | 466 context.globalAlpha = 1; |
| 467 context.strokeStyle = WebInspector.themeSupport.patchColor( | 467 context.strokeStyle = UI.themeSupport.patchColor( |
| 468 '#a5a5a5', WebInspector.ThemeSupport.ColorUsage.Foreground); | 468 '#a5a5a5', UI.ThemeSupport.ColorUsage.Foreground); |
| 469 context.moveTo(queueingStart, Math.floor(height / 2)); | 469 context.moveTo(queueingStart, Math.floor(height / 2)); |
| 470 context.lineTo(ranges.start - textOffset, Math.floor(height / 2)); | 470 context.lineTo(ranges.start - textOffset, Math.floor(height / 2)); |
| 471 | 471 |
| 472 const wiskerHeight = height / 2; | 472 const wiskerHeight = height / 2; |
| 473 context.moveTo(queueingStart + borderOffset, wiskerHeight / 2); | 473 context.moveTo(queueingStart + borderOffset, wiskerHeight / 2); |
| 474 context.lineTo(queueingStart + borderOffset, height - wiskerHeight / 2 -
1); | 474 context.lineTo(queueingStart + borderOffset, height - wiskerHeight / 2 -
1); |
| 475 context.stroke(); | 475 context.stroke(); |
| 476 } | 476 } |
| 477 } | 477 } |
| 478 | 478 |
| 479 context.restore(); | 479 context.restore(); |
| 480 } | 480 } |
| 481 | 481 |
| 482 /** | 482 /** |
| 483 * @param {!CanvasRenderingContext2D} context | 483 * @param {!CanvasRenderingContext2D} context |
| 484 * @param {string} leftText | 484 * @param {string} leftText |
| 485 * @param {string} rightText | 485 * @param {string} rightText |
| 486 * @param {number} startX | 486 * @param {number} startX |
| 487 * @param {number} midX | 487 * @param {number} midX |
| 488 * @param {number} endX | 488 * @param {number} endX |
| 489 */ | 489 */ |
| 490 _drawSimplifiedBarDetails(context, leftText, rightText, startX, midX, endX) { | 490 _drawSimplifiedBarDetails(context, leftText, rightText, startX, midX, endX) { |
| 491 /** @const */ | 491 /** @const */ |
| 492 var barDotLineLength = 10; | 492 var barDotLineLength = 10; |
| 493 | 493 |
| 494 context.save(); | 494 context.save(); |
| 495 var height = this._getBarHeight(); | 495 var height = this._getBarHeight(); |
| 496 var leftLabelWidth = context.measureText(leftText).width; | 496 var leftLabelWidth = context.measureText(leftText).width; |
| 497 var rightLabelWidth = context.measureText(rightText).width; | 497 var rightLabelWidth = context.measureText(rightText).width; |
| 498 context.fillStyle = WebInspector.themeSupport.patchColor('#444', WebInspecto
r.ThemeSupport.ColorUsage.Foreground); | 498 context.fillStyle = UI.themeSupport.patchColor('#444', UI.ThemeSupport.Color
Usage.Foreground); |
| 499 context.strokeStyle = WebInspector.themeSupport.patchColor('#444', WebInspec
tor.ThemeSupport.ColorUsage.Foreground); | 499 context.strokeStyle = UI.themeSupport.patchColor('#444', UI.ThemeSupport.Col
orUsage.Foreground); |
| 500 if (leftLabelWidth < midX - startX) { | 500 if (leftLabelWidth < midX - startX) { |
| 501 var midBarX = startX + (midX - startX) / 2 - leftLabelWidth / 2; | 501 var midBarX = startX + (midX - startX) / 2 - leftLabelWidth / 2; |
| 502 context.fillText(leftText, midBarX, this._fontSize); | 502 context.fillText(leftText, midBarX, this._fontSize); |
| 503 } else if (barDotLineLength + leftLabelWidth + this._leftPadding < startX) { | 503 } else if (barDotLineLength + leftLabelWidth + this._leftPadding < startX) { |
| 504 context.beginPath(); | 504 context.beginPath(); |
| 505 context.arc(startX, Math.floor(height / 2), 2, 0, 2 * Math.PI); | 505 context.arc(startX, Math.floor(height / 2), 2, 0, 2 * Math.PI); |
| 506 context.fill(); | 506 context.fill(); |
| 507 context.fillText(leftText, startX - leftLabelWidth - barDotLineLength - 1,
this._fontSize); | 507 context.fillText(leftText, startX - leftLabelWidth - barDotLineLength - 1,
this._fontSize); |
| 508 context.beginPath(); | 508 context.beginPath(); |
| 509 context.lineWidth = 1; | 509 context.lineWidth = 1; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 524 context.lineWidth = 1; | 524 context.lineWidth = 1; |
| 525 context.moveTo(endX, Math.floor(height / 2)); | 525 context.moveTo(endX, Math.floor(height / 2)); |
| 526 context.lineTo(endX + barDotLineLength, Math.floor(height / 2)); | 526 context.lineTo(endX + barDotLineLength, Math.floor(height / 2)); |
| 527 context.stroke(); | 527 context.stroke(); |
| 528 } | 528 } |
| 529 context.restore(); | 529 context.restore(); |
| 530 } | 530 } |
| 531 | 531 |
| 532 /** | 532 /** |
| 533 * @param {!CanvasRenderingContext2D} context | 533 * @param {!CanvasRenderingContext2D} context |
| 534 * @param {!WebInspector.NetworkRequest} request | 534 * @param {!SDK.NetworkRequest} request |
| 535 * @param {number} y | 535 * @param {number} y |
| 536 */ | 536 */ |
| 537 _drawTimingBars(context, request, y) { | 537 _drawTimingBars(context, request, y) { |
| 538 context.save(); | 538 context.save(); |
| 539 var ranges = WebInspector.RequestTimingView.calculateRequestTimeRanges(reque
st, 0); | 539 var ranges = Network.RequestTimingView.calculateRequestTimeRanges(request, 0
); |
| 540 for (var range of ranges) { | 540 for (var range of ranges) { |
| 541 if (range.name === WebInspector.RequestTimeRangeNames.Total || | 541 if (range.name === Network.RequestTimeRangeNames.Total || |
| 542 range.name === WebInspector.RequestTimeRangeNames.Sending || range.end
- range.start === 0) | 542 range.name === Network.RequestTimeRangeNames.Sending || range.end - ra
nge.start === 0) |
| 543 continue; | 543 continue; |
| 544 context.beginPath(); | 544 context.beginPath(); |
| 545 var lineWidth = 0; | 545 var lineWidth = 0; |
| 546 var color = this._colorForType(range.name); | 546 var color = this._colorForType(range.name); |
| 547 var borderColor = color; | 547 var borderColor = color; |
| 548 if (range.name === WebInspector.RequestTimeRangeNames.Queueing) { | 548 if (range.name === Network.RequestTimeRangeNames.Queueing) { |
| 549 borderColor = 'lightgrey'; | 549 borderColor = 'lightgrey'; |
| 550 lineWidth = 2; | 550 lineWidth = 2; |
| 551 } | 551 } |
| 552 if (range.name === WebInspector.RequestTimeRangeNames.Receiving) | 552 if (range.name === Network.RequestTimeRangeNames.Receiving) |
| 553 lineWidth = 2; | 553 lineWidth = 2; |
| 554 context.fillStyle = color; | 554 context.fillStyle = color; |
| 555 var height = this._getBarHeight(range.name); | 555 var height = this._getBarHeight(range.name); |
| 556 var middleBarY = y + Math.floor(this._rowHeight / 2 - height / 2) + lineWi
dth / 2; | 556 var middleBarY = y + Math.floor(this._rowHeight / 2 - height / 2) + lineWi
dth / 2; |
| 557 var start = this._timeToPosition(range.start); | 557 var start = this._timeToPosition(range.start); |
| 558 var end = this._timeToPosition(range.end); | 558 var end = this._timeToPosition(range.end); |
| 559 context.rect(start, middleBarY, end - start, height - lineWidth); | 559 context.rect(start, middleBarY, end - start, height - lineWidth); |
| 560 if (lineWidth) { | 560 if (lineWidth) { |
| 561 context.lineWidth = lineWidth; | 561 context.lineWidth = lineWidth; |
| 562 context.strokeStyle = borderColor; | 562 context.strokeStyle = borderColor; |
| 563 context.stroke(); | 563 context.stroke(); |
| 564 } | 564 } |
| 565 context.fill(); | 565 context.fill(); |
| 566 } | 566 } |
| 567 context.restore(); | 567 context.restore(); |
| 568 } | 568 } |
| 569 | 569 |
| 570 /** | 570 /** |
| 571 * @param {!CanvasRenderingContext2D} context | 571 * @param {!CanvasRenderingContext2D} context |
| 572 * @param {!WebInspector.NetworkRequest} request | 572 * @param {!SDK.NetworkRequest} request |
| 573 * @param {number} rowNumber | 573 * @param {number} rowNumber |
| 574 * @param {number} y | 574 * @param {number} y |
| 575 */ | 575 */ |
| 576 _decorateRow(context, request, rowNumber, y) { | 576 _decorateRow(context, request, rowNumber, y) { |
| 577 if (rowNumber % 2 === 1 && this._hoveredRequest !== request && this._navigat
ionRequest !== request && | 577 if (rowNumber % 2 === 1 && this._hoveredRequest !== request && this._navigat
ionRequest !== request && |
| 578 !this._initiatorGraph) | 578 !this._initiatorGraph) |
| 579 return; | 579 return; |
| 580 | 580 |
| 581 var color = getRowColor.call(this); | 581 var color = getRowColor.call(this); |
| 582 if (color === 'transparent') | 582 if (color === 'transparent') |
| 583 return; | 583 return; |
| 584 context.save(); | 584 context.save(); |
| 585 context.beginPath(); | 585 context.beginPath(); |
| 586 context.fillStyle = color; | 586 context.fillStyle = color; |
| 587 context.rect(0, y, this._offsetWidth, this._rowHeight); | 587 context.rect(0, y, this._offsetWidth, this._rowHeight); |
| 588 context.fill(); | 588 context.fill(); |
| 589 context.restore(); | 589 context.restore(); |
| 590 | 590 |
| 591 /** | 591 /** |
| 592 * @return {string} | 592 * @return {string} |
| 593 * @this {WebInspector.NetworkWaterfallColumn} | 593 * @this {Network.NetworkWaterfallColumn} |
| 594 */ | 594 */ |
| 595 function getRowColor() { | 595 function getRowColor() { |
| 596 if (this._hoveredRequest === request) | 596 if (this._hoveredRequest === request) |
| 597 return this._rowHoverColor; | 597 return this._rowHoverColor; |
| 598 if (this._initiatorGraph) { | 598 if (this._initiatorGraph) { |
| 599 if (this._initiatorGraph.initiators.has(request)) | 599 if (this._initiatorGraph.initiators.has(request)) |
| 600 return this._parentInitiatorColor; | 600 return this._parentInitiatorColor; |
| 601 if (this._initiatorGraph.initiated.has(request)) | 601 if (this._initiatorGraph.initiated.has(request)) |
| 602 return this._initiatedColor; | 602 return this._initiatedColor; |
| 603 } | 603 } |
| 604 if (this._navigationRequest === request) | 604 if (this._navigationRequest === request) |
| 605 return this._rowNavigationRequestColor; | 605 return this._rowNavigationRequestColor; |
| 606 if (rowNumber % 2 === 1) | 606 if (rowNumber % 2 === 1) |
| 607 return 'transparent'; | 607 return 'transparent'; |
| 608 return this._rowStripeColor; | 608 return this._rowStripeColor; |
| 609 } | 609 } |
| 610 } | 610 } |
| 611 }; | 611 }; |
| 612 | 612 |
| 613 /** | 613 /** |
| 614 * @typedef {{requests: !Array<!WebInspector.NetworkRequest>, navigationRequest:
?WebInspector.NetworkRequest}} | 614 * @typedef {{requests: !Array<!SDK.NetworkRequest>, navigationRequest: ?SDK.Net
workRequest}} |
| 615 */ | 615 */ |
| 616 WebInspector.NetworkWaterfallColumn.RequestData; | 616 Network.NetworkWaterfallColumn.RequestData; |
| 617 | 617 |
| 618 WebInspector.NetworkWaterfallColumn._colorsForResourceType = { | 618 Network.NetworkWaterfallColumn._colorsForResourceType = { |
| 619 document: 'hsl(215, 100%, 80%)', | 619 document: 'hsl(215, 100%, 80%)', |
| 620 font: 'hsl(8, 100%, 80%)', | 620 font: 'hsl(8, 100%, 80%)', |
| 621 media: 'hsl(272, 64%, 80%)', | 621 media: 'hsl(272, 64%, 80%)', |
| 622 image: 'hsl(272, 64%, 80%)', | 622 image: 'hsl(272, 64%, 80%)', |
| 623 script: 'hsl(31, 100%, 80%)', | 623 script: 'hsl(31, 100%, 80%)', |
| 624 stylesheet: 'hsl(90, 50%, 80%)', | 624 stylesheet: 'hsl(90, 50%, 80%)', |
| 625 texttrack: 'hsl(8, 100%, 80%)', | 625 texttrack: 'hsl(8, 100%, 80%)', |
| 626 websocket: 'hsl(0, 0%, 95%)', | 626 websocket: 'hsl(0, 0%, 95%)', |
| 627 xhr: 'hsl(53, 100%, 80%)', | 627 xhr: 'hsl(53, 100%, 80%)', |
| 628 other: 'hsl(0, 0%, 95%)' | 628 other: 'hsl(0, 0%, 95%)' |
| 629 }; | 629 }; |
| OLD | NEW |