| 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 * @param {!Element} scrollContainer | |
| 11 */ | 10 */ |
| 12 WebInspector.NetworkTimelineColumn = function(rowHeight, calculator, scrollConta
iner) | 11 WebInspector.NetworkTimelineColumn = function(rowHeight, calculator) |
| 13 { | 12 { |
| 14 // TODO(allada) Make this a shadowDOM when the NetworkTimelineColumn gets mo
ved into NetworkLogViewColumns. | 13 // TODO(allada) Make this a shadowDOM when the NetworkTimelineColumn gets mo
ved into NetworkLogViewColumns. |
| 15 WebInspector.VBox.call(this, false); | 14 WebInspector.VBox.call(this, false); |
| 16 this.registerRequiredCSS("network/networkTimelineColumn.css"); | 15 this.registerRequiredCSS("network/networkTimelineColumn.css"); |
| 17 | 16 |
| 18 this._canvas = this.contentElement.createChild("canvas"); | 17 this._canvas = this.contentElement.createChild("canvas"); |
| 19 this._canvas.tabIndex = 1; | 18 this._canvas.tabIndex = 1; |
| 20 this.setDefaultFocusedElement(this._canvas); | 19 this.setDefaultFocusedElement(this._canvas); |
| 21 | 20 |
| 22 /** @const */ | 21 /** @const */ |
| 23 this._leftPadding = 5; | 22 this._leftPadding = 5; |
| 24 /** @const */ | 23 /** @const */ |
| 25 this._rightPadding = 5; | |
| 26 /** @const */ | |
| 27 this._fontSize = 10; | 24 this._fontSize = 10; |
| 28 | 25 |
| 26 this._rightPadding = 0; |
| 27 |
| 29 this._rowHeight = rowHeight; | 28 this._rowHeight = rowHeight; |
| 30 this._headerHeight = 0; | 29 this._headerHeight = 0; |
| 31 this._calculator = calculator; | 30 this._calculator = calculator; |
| 32 | 31 |
| 33 this._popoverHelper = new WebInspector.PopoverHelper(this.element); | 32 this._popoverHelper = new WebInspector.PopoverHelper(this.element); |
| 34 this._popoverHelper.initializeCallbacks(this._getPopoverAnchor.bind(this), t
his._showPopover.bind(this)); | 33 this._popoverHelper.initializeCallbacks(this._getPopoverAnchor.bind(this), t
his._showPopover.bind(this)); |
| 35 this._popoverHelper.setTimeout(300, 300); | 34 this._popoverHelper.setTimeout(300, 300); |
| 36 | 35 |
| 37 this._vScrollElement = this.contentElement.createChild("div", "network-timel
ine-v-scroll"); | |
| 38 this._vScrollElement.addEventListener("scroll", this._onScroll.bind(this), {
passive: true }); | |
| 39 this._vScrollElement.addEventListener("mousewheel", this._onMouseWheel.bind(
this), { passive: true }); | |
| 40 this._vScrollContent = this._vScrollElement.createChild("div", "network-time
line-v-scroll-content"); | |
| 41 | |
| 42 this.element.addEventListener("mousewheel", this._onMouseWheel.bind(this), {
passive: true }); | |
| 43 this.element.addEventListener("mousemove", this._onMouseMove.bind(this), tru
e); | |
| 44 this.element.addEventListener("mouseleave", this.dispatchEventToListeners.bi
nd(this, WebInspector.NetworkTimelineColumn.Events.RequestHovered, null), true); | |
| 45 | |
| 46 this._boundScrollContainer = scrollContainer; | |
| 47 this._boundScrollContainer.addEventListener("mousewheel", event => { | |
| 48 event.consume(true); | |
| 49 this._onMouseWheel(event); | |
| 50 }, true); | |
| 51 | |
| 52 // TODO(allada) When timeline canvas moves out of experiment move this to st
ylesheet. | |
| 53 this._boundScrollContainer.style.overflow = "hidden"; | |
| 54 | |
| 55 /** @type {!Array<!WebInspector.NetworkRequest>} */ | 36 /** @type {!Array<!WebInspector.NetworkRequest>} */ |
| 56 this._requestData = []; | 37 this._requestData = []; |
| 57 | 38 |
| 58 /** @type {?WebInspector.NetworkRequest} */ | 39 /** @type {?WebInspector.NetworkRequest} */ |
| 59 this._hoveredRequest = null; | 40 this._hoveredRequest = null; |
| 60 | 41 |
| 61 /** @type {?WebInspector.NetworkRequest} */ | 42 /** @type {?WebInspector.NetworkRequest} */ |
| 62 this._navigationRequest = null; | 43 this._navigationRequest = null; |
| 63 | 44 |
| 64 var colorUsage = WebInspector.ThemeSupport.ColorUsage; | 45 var colorUsage = WebInspector.ThemeSupport.ColorUsage; |
| 65 this._rowNavigationRequestColor = WebInspector.themeSupport.patchColor("#def
", colorUsage.Background); | 46 this._rowNavigationRequestColor = WebInspector.themeSupport.patchColor("#def
", colorUsage.Background); |
| 66 this._rowStripeColor = WebInspector.themeSupport.patchColor("#f5f5f5", color
Usage.Background); | 47 this._rowStripeColor = WebInspector.themeSupport.patchColor("#f5f5f5", color
Usage.Background); |
| 67 this._rowHoverColor = WebInspector.themeSupport.patchColor("#ebf2fc", /** @t
ype {!WebInspector.ThemeSupport.ColorUsage} */ (colorUsage.Background | colorUsa
ge.Selection)); | 48 this._rowHoverColor = WebInspector.themeSupport.patchColor("#ebf2fc", /** @t
ype {!WebInspector.ThemeSupport.ColorUsage} */ (colorUsage.Background | colorUsa
ge.Selection)); |
| 68 | 49 |
| 69 /** @type {!Map<!WebInspector.ResourceType, string>} */ | 50 /** @type {!Map<!WebInspector.ResourceType, string>} */ |
| 70 this._borderColorsForResourceTypeCache = new Map(); | 51 this._borderColorsForResourceTypeCache = new Map(); |
| 71 /** @type {!Map<string, !CanvasGradient>} */ | 52 /** @type {!Map<string, !CanvasGradient>} */ |
| 72 this._colorsForResourceTypeCache = new Map(); | 53 this._colorsForResourceTypeCache = new Map(); |
| 73 }; | 54 }; |
| 74 | 55 |
| 75 WebInspector.NetworkTimelineColumn.Events = { | |
| 76 RequestHovered: Symbol("RequestHovered") | |
| 77 }; | |
| 78 | |
| 79 WebInspector.NetworkTimelineColumn._colorsForResourceType = { | 56 WebInspector.NetworkTimelineColumn._colorsForResourceType = { |
| 80 document: "hsl(215, 100%, 80%)", | 57 document: "hsl(215, 100%, 80%)", |
| 81 font: "hsl(8, 100%, 80%)", | 58 font: "hsl(8, 100%, 80%)", |
| 82 media: "hsl(272, 64%, 80%)", | 59 media: "hsl(272, 64%, 80%)", |
| 83 image: "hsl(272, 64%, 80%)", | 60 image: "hsl(272, 64%, 80%)", |
| 84 script: "hsl(31, 100%, 80%)", | 61 script: "hsl(31, 100%, 80%)", |
| 85 stylesheet: "hsl(90, 50%, 80%)", | 62 stylesheet: "hsl(90, 50%, 80%)", |
| 86 texttrack: "hsl(8, 100%, 80%)", | 63 texttrack: "hsl(8, 100%, 80%)", |
| 87 websocket: "hsl(0, 0%, 95%)", | 64 websocket: "hsl(0, 0%, 95%)", |
| 88 xhr: "hsl(53, 100%, 80%)", | 65 xhr: "hsl(53, 100%, 80%)", |
| 89 other: "hsl(0, 0%, 95%)" | 66 other: "hsl(0, 0%, 95%)" |
| 90 }; | 67 }; |
| 91 | 68 |
| 92 WebInspector.NetworkTimelineColumn.prototype = { | 69 WebInspector.NetworkTimelineColumn.prototype = { |
| 93 /** | 70 /** |
| 94 * @override | 71 * @override |
| 95 */ | 72 */ |
| 96 willHide: function() | 73 willHide: function() |
| 97 { | 74 { |
| 98 this._popoverHelper.hidePopover(); | 75 this._popoverHelper.hidePopover(); |
| 99 }, | 76 }, |
| 100 | 77 |
| 101 /** | 78 /** |
| 79 * @override |
| 80 */ |
| 81 wasShown: function() |
| 82 { |
| 83 this.update(); |
| 84 }, |
| 85 |
| 86 /** |
| 102 * @param {!Element} element | 87 * @param {!Element} element |
| 103 * @param {!Event} event | 88 * @param {!Event} event |
| 104 * @return {!AnchorBox|undefined} | 89 * @return {!AnchorBox|undefined} |
| 105 */ | 90 */ |
| 106 _getPopoverAnchor: function(element, event) | 91 _getPopoverAnchor: function(element, event) |
| 107 { | 92 { |
| 108 if (!this._hoveredRequest) | 93 if (!this._hoveredRequest) |
| 109 return; | 94 return; |
| 110 | 95 |
| 111 var range = WebInspector.RequestTimingView.calculateRequestTimeRanges(th
is._hoveredRequest, 0).find(data => data.name === "total"); | 96 var range = WebInspector.RequestTimingView.calculateRequestTimeRanges(th
is._hoveredRequest, 0).find(data => data.name === "total"); |
| 112 var start = this._timeToPosition(range.start); | 97 var start = this._timeToPosition(range.start); |
| 113 var end = this._timeToPosition(range.end); | 98 var end = this._timeToPosition(range.end); |
| 114 | 99 |
| 115 if (event.offsetX < start || event.offsetX > end) | 100 if (event.offsetX < start || event.offsetX > end) |
| 116 return; | 101 return; |
| 117 | 102 |
| 118 var rowIndex = this._requestData.findIndex(request => this._hoveredReque
st === request); | 103 var rowIndex = this._requestData.findIndex(request => this._hoveredReque
st === request); |
| 119 var barHeight = this._getBarHeight(range.name); | 104 var barHeight = this._getBarHeight(range.name); |
| 120 var y = this._headerHeight + (this._rowHeight * rowIndex - this._vScroll
Element.scrollTop) + ((this._rowHeight - barHeight) / 2); | 105 var y = this._headerHeight + (this._rowHeight * rowIndex - this._scrollT
op) + ((this._rowHeight - barHeight) / 2); |
| 121 | 106 |
| 122 if (event.offsetY < y || event.offsetY > y + barHeight) | 107 if (event.offsetY < y || event.offsetY > y + barHeight) |
| 123 return; | 108 return; |
| 124 | 109 |
| 125 var anchorBox = this.element.boxInWindow(); | 110 var anchorBox = this.element.boxInWindow(); |
| 126 anchorBox.x += start; | 111 anchorBox.x += start; |
| 127 anchorBox.y += y; | 112 anchorBox.y += y; |
| 128 anchorBox.width = end - start; | 113 anchorBox.width = end - start; |
| 129 anchorBox.height = barHeight; | 114 anchorBox.height = barHeight; |
| 130 return anchorBox; | 115 return anchorBox; |
| 131 }, | 116 }, |
| 132 | 117 |
| 133 /** | 118 /** |
| 134 * @param {!Element|!AnchorBox} anchor | 119 * @param {!Element|!AnchorBox} anchor |
| 135 * @param {!WebInspector.Popover} popover | 120 * @param {!WebInspector.Popover} popover |
| 136 */ | 121 */ |
| 137 _showPopover: function(anchor, popover) | 122 _showPopover: function(anchor, popover) |
| 138 { | 123 { |
| 139 if (!this._hoveredRequest) | 124 if (!this._hoveredRequest) |
| 140 return; | 125 return; |
| 141 var content = WebInspector.RequestTimingView.createTimingTable(this._hov
eredRequest, this._calculator.minimumBoundary()); | 126 var content = WebInspector.RequestTimingView.createTimingTable(this._hov
eredRequest, this._calculator.minimumBoundary()); |
| 142 popover.showForAnchor(content, anchor); | 127 popover.showForAnchor(content, anchor); |
| 143 }, | 128 }, |
| 144 | 129 |
| 145 wasShown: function() | |
| 146 { | |
| 147 this.scheduleDraw(); | |
| 148 }, | |
| 149 | |
| 150 /** | |
| 151 * @return {!Element} | |
| 152 */ | |
| 153 getScrollContainer: function() | |
| 154 { | |
| 155 return this._vScrollElement; | |
| 156 }, | |
| 157 | |
| 158 /** | 130 /** |
| 159 * @param {?WebInspector.NetworkRequest} request | 131 * @param {?WebInspector.NetworkRequest} request |
| 160 */ | 132 */ |
| 161 setHoveredRequest: function(request) | 133 setHoveredRequest: function(request) |
| 162 { | 134 { |
| 163 this._hoveredRequest = request; | 135 this._hoveredRequest = request; |
| 164 this.update(); | 136 this.update(); |
| 165 }, | 137 }, |
| 166 | 138 |
| 167 /** | 139 /** |
| 168 * @param {number} height | 140 * @param {number} height |
| 169 */ | 141 */ |
| 170 setRowHeight: function(height) | 142 setRowHeight: function(height) |
| 171 { | 143 { |
| 172 this._rowHeight = height; | 144 this._rowHeight = height; |
| 173 }, | 145 }, |
| 174 | 146 |
| 175 /** | 147 /** |
| 176 * @param {number} height | 148 * @param {number} height |
| 177 */ | 149 */ |
| 178 setHeaderHeight: function(height) | 150 setHeaderHeight: function(height) |
| 179 { | 151 { |
| 180 this._headerHeight = height; | 152 this._headerHeight = height; |
| 181 this._vScrollElement.style.marginTop = height + "px"; | 153 }, |
| 154 |
| 155 /** |
| 156 * @param {number} padding |
| 157 */ |
| 158 setRightPadding: function(padding) |
| 159 { |
| 160 this._rightPadding = padding; |
| 161 this._calculateCanvasSize(); |
| 182 }, | 162 }, |
| 183 | 163 |
| 184 /** | 164 /** |
| 185 * @param {!WebInspector.NetworkTimeCalculator} calculator | 165 * @param {!WebInspector.NetworkTimeCalculator} calculator |
| 186 */ | 166 */ |
| 187 setCalculator: function(calculator) | 167 setCalculator: function(calculator) |
| 188 { | 168 { |
| 189 this._calculator = calculator; | 169 this._calculator = calculator; |
| 190 }, | 170 }, |
| 191 | 171 |
| 192 /** | 172 /** |
| 193 * @param {!Event} event | |
| 194 */ | |
| 195 _onMouseMove: function(event) | |
| 196 { | |
| 197 var request = this._getRequestFromPoint(event.offsetX, event.offsetY + e
vent.target.offsetTop); | |
| 198 this.dispatchEventToListeners(WebInspector.NetworkTimelineColumn.Events.
RequestHovered, request); | |
| 199 }, | |
| 200 | |
| 201 /** | |
| 202 * @param {!Event} event | |
| 203 */ | |
| 204 _onMouseWheel: function(event) | |
| 205 { | |
| 206 this._vScrollElement.scrollTop -= event.wheelDeltaY; | |
| 207 this._boundScrollContainer.scrollTop = this._vScrollElement.scrollTop; | |
| 208 this._popoverHelper.hidePopover(); | |
| 209 | |
| 210 var request = this._getRequestFromPoint(event.offsetX, event.offsetY); | |
| 211 this.dispatchEventToListeners(WebInspector.NetworkTimelineColumn.Events.
RequestHovered, request); | |
| 212 }, | |
| 213 | |
| 214 /** | |
| 215 * @param {!Event} event | |
| 216 */ | |
| 217 _onScroll: function(event) | |
| 218 { | |
| 219 this._boundScrollContainer.scrollTop = this._vScrollElement.scrollTop; | |
| 220 this._popoverHelper.hidePopover(); | |
| 221 }, | |
| 222 | |
| 223 /** | |
| 224 * @param {number} x | 173 * @param {number} x |
| 225 * @param {number} y | 174 * @param {number} y |
| 226 * @return {?WebInspector.NetworkRequest} | 175 * @return {?WebInspector.NetworkRequest} |
| 227 */ | 176 */ |
| 228 _getRequestFromPoint: function(x, y) | 177 getRequestFromPoint: function(x, y) |
| 229 { | 178 { |
| 230 var scrollTop = this._vScrollElement.scrollTop; | 179 return this._requestData[Math.floor((this._scrollTop + y - this._headerH
eight) / this._rowHeight)] || null; |
| 231 return this._requestData[Math.floor((scrollTop + y - this._headerHeight)
/ this._rowHeight)] || null; | |
| 232 }, | 180 }, |
| 233 | 181 |
| 234 scheduleDraw: function() | 182 scheduleDraw: function() |
| 235 { | 183 { |
| 236 if (this._updateRequestID) | 184 if (this._updateRequestID) |
| 237 return; | 185 return; |
| 238 this._updateRequestID = this.element.window().requestAnimationFrame(() =
> this.update()); | 186 this._updateRequestID = this.element.window().requestAnimationFrame(() =
> this.update()); |
| 239 }, | 187 }, |
| 240 | 188 |
| 241 /** | 189 /** |
| 190 * @param {number=} scrollTop |
| 242 * @param {!{requests: !Array<!WebInspector.NetworkRequest>, navigationReque
st: ?WebInspector.NetworkRequest}=} requestData | 191 * @param {!{requests: !Array<!WebInspector.NetworkRequest>, navigationReque
st: ?WebInspector.NetworkRequest}=} requestData |
| 243 */ | 192 */ |
| 244 update: function(requestData) | 193 update: function(scrollTop, requestData) |
| 245 { | 194 { |
| 195 if (scrollTop !== undefined) |
| 196 this._scrollTop = scrollTop; |
| 246 if (requestData) { | 197 if (requestData) { |
| 247 this._requestData = requestData.requests; | 198 this._requestData = requestData.requests; |
| 248 this._navigationRequest = requestData.navigationRequest; | 199 this._navigationRequest = requestData.navigationRequest; |
| 249 this._calculateCanvasSize(); | 200 this._calculateCanvasSize(); |
| 250 } | 201 } |
| 251 this.element.window().cancelAnimationFrame(this._updateRequestID); | 202 this.element.window().cancelAnimationFrame(this._updateRequestID); |
| 252 this._updateRequestID = null; | 203 this._updateRequestID = null; |
| 253 | 204 |
| 254 this._startTime = this._calculator.minimumBoundary(); | 205 this._startTime = this._calculator.minimumBoundary(); |
| 255 this._endTime = this._calculator.maximumBoundary(); | 206 this._endTime = this._calculator.maximumBoundary(); |
| 256 this._resetCanvas(); | 207 this._resetCanvas(); |
| 257 this._draw(); | 208 this._draw(); |
| 258 }, | 209 }, |
| 259 | 210 |
| 260 /** | |
| 261 * @param {number} height | |
| 262 */ | |
| 263 setScrollHeight: function(height) | |
| 264 { | |
| 265 this._vScrollContent.style.height = height + "px"; | |
| 266 }, | |
| 267 | |
| 268 _resetCanvas: function() | 211 _resetCanvas: function() |
| 269 { | 212 { |
| 270 var ratio = window.devicePixelRatio; | 213 var ratio = window.devicePixelRatio; |
| 271 this._canvas.width = this._offsetWidth * ratio; | 214 this._canvas.width = this._offsetWidth * ratio; |
| 272 this._canvas.height = this._offsetHeight * ratio; | 215 this._canvas.height = this._offsetHeight * ratio; |
| 273 this._canvas.style.width = this._offsetWidth + "px"; | 216 this._canvas.style.width = this._offsetWidth + "px"; |
| 274 this._canvas.style.height = this._offsetHeight + "px"; | 217 this._canvas.style.height = this._offsetHeight + "px"; |
| 275 }, | 218 }, |
| 276 | 219 |
| 277 /** | 220 /** |
| 278 * @override | 221 * @override |
| 279 */ | 222 */ |
| 280 onResize: function() | 223 onResize: function() |
| 281 { | 224 { |
| 282 WebInspector.VBox.prototype.onResize.call(this); | 225 WebInspector.VBox.prototype.onResize.call(this); |
| 283 this._calculateCanvasSize(); | 226 this._calculateCanvasSize(); |
| 284 this.scheduleDraw(); | 227 this.scheduleDraw(); |
| 285 }, | 228 }, |
| 286 | 229 |
| 287 _calculateCanvasSize: function() | 230 _calculateCanvasSize: function() |
| 288 { | 231 { |
| 289 var scrollbarWidth = this._vScrollElement.offsetWidth; | 232 this._offsetWidth = this.contentElement.offsetWidth - this._rightPadding
; |
| 290 // Offset by 1 px because css needs 1px to compute height and add scroll
bar. | |
| 291 if (scrollbarWidth) | |
| 292 scrollbarWidth -= 1; | |
| 293 this._offsetWidth = this.contentElement.offsetWidth - scrollbarWidth; | |
| 294 this._offsetHeight = this.contentElement.offsetHeight; | 233 this._offsetHeight = this.contentElement.offsetHeight; |
| 295 }, | 234 }, |
| 296 | 235 |
| 297 /** | 236 /** |
| 298 * @param {!WebInspector.RequestTimeRangeNames} type | 237 * @param {!WebInspector.RequestTimeRangeNames} type |
| 299 * @return {string} | 238 * @return {string} |
| 300 */ | 239 */ |
| 301 _colorForType: function(type) | 240 _colorForType: function(type) |
| 302 { | 241 { |
| 303 var types = WebInspector.RequestTimeRangeNames; | 242 var types = WebInspector.RequestTimeRangeNames; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 327 return "orange"; | 266 return "orange"; |
| 328 } | 267 } |
| 329 }, | 268 }, |
| 330 | 269 |
| 331 /** | 270 /** |
| 332 * @param {number} time | 271 * @param {number} time |
| 333 * @return {number} | 272 * @return {number} |
| 334 */ | 273 */ |
| 335 _timeToPosition: function(time) | 274 _timeToPosition: function(time) |
| 336 { | 275 { |
| 337 var availableWidth = this._offsetWidth - this._leftPadding - this._right
Padding; | 276 var availableWidth = this._offsetWidth - this._leftPadding; |
| 338 var timeToPixel = availableWidth / (this._endTime - this._startTime); | 277 var timeToPixel = availableWidth / (this._endTime - this._startTime); |
| 339 return Math.floor(this._leftPadding + (time - this._startTime) * timeToP
ixel); | 278 return Math.floor(this._leftPadding + (time - this._startTime) * timeToP
ixel); |
| 340 }, | 279 }, |
| 341 | 280 |
| 342 _draw: function() | 281 _draw: function() |
| 343 { | 282 { |
| 344 var useTimingBars = !WebInspector.moduleSetting("networkColorCodeResourc
eTypes").get() && !this._calculator.startAtZero; | 283 var useTimingBars = !WebInspector.moduleSetting("networkColorCodeResourc
eTypes").get() && !this._calculator.startAtZero; |
| 345 var requests = this._requestData; | 284 var requests = this._requestData; |
| 346 var context = this._canvas.getContext("2d"); | 285 var context = this._canvas.getContext("2d"); |
| 347 context.save(); | 286 context.save(); |
| 348 context.scale(window.devicePixelRatio, window.devicePixelRatio); | 287 context.scale(window.devicePixelRatio, window.devicePixelRatio); |
| 349 context.translate(0, this._headerHeight); | 288 context.translate(0, this._headerHeight); |
| 350 context.rect(0, 0, this._offsetWidth, this._offsetHeight); | 289 context.rect(0, 0, this._offsetWidth, this._offsetHeight); |
| 351 context.clip(); | 290 context.clip(); |
| 352 var scrollTop = this._vScrollElement.scrollTop; | 291 var firstRequestIndex = Math.floor(this._scrollTop / this._rowHeight); |
| 353 var firstRequestIndex = Math.floor(scrollTop / this._rowHeight); | |
| 354 var lastRequestIndex = Math.min(requests.length, firstRequestIndex + Mat
h.ceil(this._offsetHeight / this._rowHeight)); | 292 var lastRequestIndex = Math.min(requests.length, firstRequestIndex + Mat
h.ceil(this._offsetHeight / this._rowHeight)); |
| 355 for (var i = firstRequestIndex; i < lastRequestIndex; i++) { | 293 for (var i = firstRequestIndex; i < lastRequestIndex; i++) { |
| 356 var rowOffset = this._rowHeight * i; | 294 var rowOffset = this._rowHeight * i; |
| 357 var request = requests[i]; | 295 var request = requests[i]; |
| 358 this._decorateRow(context, request, i, rowOffset - scrollTop); | 296 this._decorateRow(context, request, i, rowOffset - this._scrollTop); |
| 359 if (useTimingBars) | 297 if (useTimingBars) |
| 360 this._drawTimingBars(context, request, rowOffset - scrollTop); | 298 this._drawTimingBars(context, request, rowOffset - this._scrollT
op); |
| 361 else | 299 else |
| 362 this._drawSimplifiedBars(context, request, rowOffset - scrollTop
); | 300 this._drawSimplifiedBars(context, request, rowOffset - this._scr
ollTop); |
| 363 } | 301 } |
| 364 context.restore(); | 302 context.restore(); |
| 365 this._drawDividers(context); | 303 this._drawDividers(context); |
| 366 }, | 304 }, |
| 367 | 305 |
| 368 _drawDividers: function(context) | 306 _drawDividers: function(context) |
| 369 { | 307 { |
| 370 context.save(); | 308 context.save(); |
| 371 /** @const */ | 309 /** @const */ |
| 372 var minGridSlicePx = 64; // minimal distance between grid lines. | 310 var minGridSlicePx = 64; // minimal distance between grid lines. |
| 373 | 311 |
| 374 var drawableWidth = this._offsetWidth - this._leftPadding - this._rightP
adding; | 312 var drawableWidth = this._offsetWidth - this._leftPadding; |
| 375 var timelineDuration = this._timelineDuration(); | 313 var timelineDuration = this._timelineDuration(); |
| 376 var dividersCount = drawableWidth / minGridSlicePx; | 314 var dividersCount = drawableWidth / minGridSlicePx; |
| 377 var gridSliceTime = timelineDuration / dividersCount; | 315 var gridSliceTime = timelineDuration / dividersCount; |
| 378 var pixelsPerTime = drawableWidth / timelineDuration; | 316 var pixelsPerTime = drawableWidth / timelineDuration; |
| 379 | 317 |
| 380 // Align gridSliceTime to a nearest round value. | 318 // Align gridSliceTime to a nearest round value. |
| 381 // We allow spans that fit into the formula: span = (1|2|5)x10^n, | 319 // We allow spans that fit into the formula: span = (1|2|5)x10^n, |
| 382 // e.g.: ... .1 .2 .5 1 2 5 10 20 50 ... | 320 // e.g.: ... .1 .2 .5 1 2 5 10 20 50 ... |
| 383 // After a span has been chosen make grid lines at multiples of the span
. | 321 // After a span has been chosen make grid lines at multiples of the span
. |
| 384 | 322 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 * @param {!WebInspector.NetworkRequest} request | 427 * @param {!WebInspector.NetworkRequest} request |
| 490 * @param {number} y | 428 * @param {number} y |
| 491 */ | 429 */ |
| 492 _drawSimplifiedBars: function(context, request, y) | 430 _drawSimplifiedBars: function(context, request, y) |
| 493 { | 431 { |
| 494 /** @const */ | 432 /** @const */ |
| 495 var borderWidth = 1; | 433 var borderWidth = 1; |
| 496 | 434 |
| 497 context.save(); | 435 context.save(); |
| 498 var percentages = this._calculator.computeBarGraphPercentages(request); | 436 var percentages = this._calculator.computeBarGraphPercentages(request); |
| 499 var drawWidth = this._offsetWidth - this._leftPadding - this._rightPaddi
ng; | 437 var drawWidth = this._offsetWidth - this._leftPadding; |
| 500 var borderOffset = borderWidth % 2 === 0 ? 0 : .5; | 438 var borderOffset = borderWidth % 2 === 0 ? 0 : .5; |
| 501 var start = this._leftPadding + Math.floor((percentages.start / 100) * d
rawWidth) + borderOffset; | 439 var start = this._leftPadding + Math.floor((percentages.start / 100) * d
rawWidth) + borderOffset; |
| 502 var mid = this._leftPadding + Math.floor((percentages.middle / 100) * dr
awWidth) + borderOffset; | 440 var mid = this._leftPadding + Math.floor((percentages.middle / 100) * dr
awWidth) + borderOffset; |
| 503 var end = this._leftPadding + Math.floor((percentages.end / 100) * drawW
idth) + borderOffset; | 441 var end = this._leftPadding + Math.floor((percentages.end / 100) * drawW
idth) + borderOffset; |
| 504 var height = this._getBarHeight(); | 442 var height = this._getBarHeight(); |
| 505 y += Math.floor(this._rowHeight / 2 - height / 2 + borderWidth) - border
Width / 2; | 443 y += Math.floor(this._rowHeight / 2 - height / 2 + borderWidth) - border
Width / 2; |
| 506 | 444 |
| 507 context.translate(0, y); | 445 context.translate(0, y); |
| 508 context.fillStyle = this._colorForResourceType(context, request); | 446 context.fillStyle = this._colorForResourceType(context, request); |
| 509 context.strokeStyle = this._borderColorForResourceType(request); | 447 context.strokeStyle = this._borderColorForResourceType(request); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 context.beginPath(); | 498 context.beginPath(); |
| 561 context.lineWidth = 1; | 499 context.lineWidth = 1; |
| 562 context.moveTo(startX - barDotLineLength, Math.floor(height / 2)); | 500 context.moveTo(startX - barDotLineLength, Math.floor(height / 2)); |
| 563 context.lineTo(startX, Math.floor(height / 2)); | 501 context.lineTo(startX, Math.floor(height / 2)); |
| 564 context.stroke(); | 502 context.stroke(); |
| 565 } | 503 } |
| 566 | 504 |
| 567 if (rightLabelWidth < endX - midX) { | 505 if (rightLabelWidth < endX - midX) { |
| 568 var midBarX = midX + (endX - midX) / 2 - rightLabelWidth / 2; | 506 var midBarX = midX + (endX - midX) / 2 - rightLabelWidth / 2; |
| 569 context.fillText(rightText, midBarX, this._fontSize); | 507 context.fillText(rightText, midBarX, this._fontSize); |
| 570 } else if (endX + barDotLineLength + rightLabelWidth < this._offsetWidth
- this._leftPadding - this._rightPadding) { | 508 } else if (endX + barDotLineLength + rightLabelWidth < this._offsetWidth
- this._leftPadding) { |
| 571 context.beginPath(); | 509 context.beginPath(); |
| 572 context.arc(endX, Math.floor(height / 2), 2, 0, 2 * Math.PI); | 510 context.arc(endX, Math.floor(height / 2), 2, 0, 2 * Math.PI); |
| 573 context.fill(); | 511 context.fill(); |
| 574 context.fillText(rightText, endX + barDotLineLength + 1, this._fontS
ize); | 512 context.fillText(rightText, endX + barDotLineLength + 1, this._fontS
ize); |
| 575 context.beginPath(); | 513 context.beginPath(); |
| 576 context.lineWidth = 1; | 514 context.lineWidth = 1; |
| 577 context.moveTo(endX, Math.floor(height / 2)); | 515 context.moveTo(endX, Math.floor(height / 2)); |
| 578 context.lineTo(endX + barDotLineLength, Math.floor(height / 2)); | 516 context.lineTo(endX + barDotLineLength, Math.floor(height / 2)); |
| 579 context.stroke(); | 517 context.stroke(); |
| 580 } | 518 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 color = this._rowNavigationRequestColor; | 578 color = this._rowNavigationRequestColor; |
| 641 | 579 |
| 642 context.fillStyle = color; | 580 context.fillStyle = color; |
| 643 context.rect(0, y, this._offsetWidth, this._rowHeight); | 581 context.rect(0, y, this._offsetWidth, this._rowHeight); |
| 644 context.fill(); | 582 context.fill(); |
| 645 context.restore(); | 583 context.restore(); |
| 646 }, | 584 }, |
| 647 | 585 |
| 648 __proto__: WebInspector.VBox.prototype | 586 __proto__: WebInspector.VBox.prototype |
| 649 }; | 587 }; |
| OLD | NEW |