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 {!WebInspector.NetworkLogView} networkLogView | 8 * @param {number} rowHeight |
9 * @param {!WebInspector.SortableDataGrid} dataGrid | 9 * @param {number} headerHeight |
10 * @param {!WebInspector.NetworkTransferTimeCalculator} calculator | |
11 * @param {!Element} scrollContainer | |
10 */ | 12 */ |
11 WebInspector.NetworkTimelineColumn = function(networkLogView, dataGrid) | 13 WebInspector.NetworkTimelineColumn = function(rowHeight, headerHeight, calculato r, scrollContainer) |
12 { | 14 { |
13 WebInspector.VBox.call(this, true); | 15 WebInspector.VBox.call(this, true); |
14 this.registerRequiredCSS("network/networkTimelineColumn.css"); | 16 this.registerRequiredCSS("network/networkTimelineColumn.css"); |
15 | 17 |
16 this._canvas = this.contentElement.createChild("canvas"); | 18 this._canvas = this.contentElement.createChild("canvas"); |
17 this._canvas.tabIndex = 1; | 19 this._canvas.tabIndex = 1; |
18 this.setDefaultFocusedElement(this._canvas); | 20 this.setDefaultFocusedElement(this._canvas); |
19 | 21 |
20 /** @const */ | 22 /** @const */ |
21 this._leftPadding = 5; | 23 this._leftPadding = 5; |
22 /** @const */ | 24 /** @const */ |
23 this._rightPadding = 5; | 25 this._rightPadding = 5; |
24 /** @const */ | 26 /** @const */ |
25 this._fontSize = 10; | 27 this._fontSize = 10; |
26 | 28 |
27 this._dataGrid = dataGrid; | 29 this._rowHeight = rowHeight; |
28 this._networkLogView = networkLogView; | 30 this._headerHeight = headerHeight; |
31 this._calculator = calculator; | |
29 | 32 |
30 this._popoverHelper = new WebInspector.PopoverHelper(this.element, this._get PopoverAnchor.bind(this), this._showPopover.bind(this)); | 33 this._popoverHelper = new WebInspector.PopoverHelper(this.element, this._get PopoverAnchor.bind(this), this._showPopover.bind(this)); |
31 this._popoverHelper.setTimeout(300, 300); | 34 this._popoverHelper.setTimeout(300, 300); |
32 | 35 |
33 this._vScrollElement = this.contentElement.createChild("div", "network-timel ine-v-scroll"); | 36 this._vScrollElement = this.contentElement.createChild("div", "network-timel ine-v-scroll"); |
34 this._vScrollElement.addEventListener("scroll", this._onScroll.bind(this), { passive: true }); | 37 this._vScrollElement.addEventListener("scroll", this._onScroll.bind(this), { passive: true }); |
35 this._vScrollElement.addEventListener("mousewheel", this._onMouseWheel.bind( this), { passive: true }); | 38 this._vScrollElement.addEventListener("mousewheel", this._onMouseWheel.bind( this), { passive: true }); |
36 this._vScrollContent = this._vScrollElement.createChild("div"); | 39 this._vScrollContent = this._vScrollElement.createChild("div"); |
37 | 40 |
38 this.element.addEventListener("mousewheel", this._onMouseWheel.bind(this), { passive: true }); | 41 this.element.addEventListener("mousewheel", this._onMouseWheel.bind(this), { passive: true }); |
39 this.element.addEventListener("mousemove", this._onMouseMove.bind(this), tru e); | 42 this.element.addEventListener("mousemove", this._onMouseMove.bind(this), tru e); |
40 this.element.addEventListener("mouseleave", this.setHoveredRequest.bind(this , null), true); | 43 this.element.addEventListener("mouseleave", this.setHoveredRequest.bind(this , null), true); |
41 | 44 |
42 this._dataGridScrollContainer = this._dataGrid.scrollContainer; | 45 this._boundScrollContainer = scrollContainer; |
43 this._dataGridScrollContainer.addEventListener("mousewheel", event => { | 46 this._boundScrollContainer.addEventListener("mousewheel", event => { |
44 event.consume(true); | 47 event.consume(true); |
45 this._onMouseWheel(event); | 48 this._onMouseWheel(event); |
46 }, true); | 49 }, true); |
47 | 50 |
48 // TODO(allada) When timeline canvas moves out of experiment move this to st ylesheet. | 51 // TODO(allada) When timeline canvas moves out of experiment move this to st ylesheet. |
49 this._dataGridScrollContainer.style.overflow = "hidden"; | 52 this._boundScrollContainer.style.overflow = "hidden"; |
50 this._dataGrid.setScrollContainer(this._vScrollElement); | |
51 | |
52 this._dataGrid.addEventListener(WebInspector.ViewportDataGrid.Events.Viewpor tCalculated, this._update.bind(this)); | |
53 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.PaddingChanged, this._updateHeight.bind(this)); | |
54 | 53 |
55 /** @type {!Array<!WebInspector.NetworkRequest>} */ | 54 /** @type {!Array<!WebInspector.NetworkRequest>} */ |
56 this._requestData = []; | 55 this._requestData = []; |
57 | 56 |
58 /** @type {?WebInspector.NetworkRequest} */ | 57 /** @type {?WebInspector.NetworkRequest} */ |
59 this._hoveredRequest = null; | 58 this._hoveredRequest = null; |
60 | 59 |
61 this._rowStripeColor = WebInspector.themeSupport.patchColor("#f5f5f5", WebIn spector.ThemeSupport.ColorUsage.Background); | 60 this._rowStripeColor = WebInspector.themeSupport.patchColor("#f5f5f5", WebIn spector.ThemeSupport.ColorUsage.Background); |
62 this._rowHoverColor = WebInspector.themeSupport.patchColor("#ebf2fc", WebIns pector.ThemeSupport.ColorUsage.Background); | 61 this._rowHoverColor = WebInspector.themeSupport.patchColor("#ebf2fc", WebIns pector.ThemeSupport.ColorUsage.Background); |
63 | 62 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 /** | 95 /** |
97 * @param {!Element} element | 96 * @param {!Element} element |
98 * @param {!Event} event | 97 * @param {!Event} event |
99 * @return {!AnchorBox|undefined} | 98 * @return {!AnchorBox|undefined} |
100 */ | 99 */ |
101 _getPopoverAnchor: function(element, event) | 100 _getPopoverAnchor: function(element, event) |
102 { | 101 { |
103 if (!this._hoveredRequest) | 102 if (!this._hoveredRequest) |
104 return; | 103 return; |
105 | 104 |
106 var rowHeight = this._networkLogView.rowHeight(); | |
107 var range = WebInspector.RequestTimingView.calculateRequestTimeRanges(th is._hoveredRequest, 0).find(data => data.name === "total"); | 105 var range = WebInspector.RequestTimingView.calculateRequestTimeRanges(th is._hoveredRequest, 0).find(data => data.name === "total"); |
108 var start = this._timeToPosition(range.start); | 106 var start = this._timeToPosition(range.start); |
109 var end = this._timeToPosition(range.end); | 107 var end = this._timeToPosition(range.end); |
110 | 108 |
111 if (event.offsetX < start || event.offsetX > end) | 109 if (event.offsetX < start || event.offsetX > end) |
112 return; | 110 return; |
113 | 111 |
114 var rowIndex = this._requestData.findIndex(request => this._hoveredReque st === request); | 112 var rowIndex = this._requestData.findIndex(request => this._hoveredReque st === request); |
115 var barHeight = this._getBarHeight(range.name); | 113 var barHeight = this._getBarHeight(range.name); |
116 var y = this._networkLogView.headerHeight() + (rowHeight * rowIndex - th is._vScrollElement.scrollTop) + ((rowHeight - barHeight) / 2); | 114 var y = this._headerHeight + (this._rowHeight * rowIndex - this._vScroll Element.scrollTop) + ((this._rowHeight - barHeight) / 2); |
117 | 115 |
118 if (event.offsetY < y || event.offsetY > y + barHeight) | 116 if (event.offsetY < y || event.offsetY > y + barHeight) |
119 return; | 117 return; |
120 | 118 |
121 var anchorBox = this.element.boxInWindow(); | 119 var anchorBox = this.element.boxInWindow(); |
122 anchorBox.x += start; | 120 anchorBox.x += start; |
123 anchorBox.y += y; | 121 anchorBox.y += y; |
124 anchorBox.width = end - start; | 122 anchorBox.width = end - start; |
125 anchorBox.height = barHeight; | 123 anchorBox.height = barHeight; |
126 return anchorBox; | 124 return anchorBox; |
127 }, | 125 }, |
128 | 126 |
129 /** | 127 /** |
130 * @param {!Element|!AnchorBox} anchor | 128 * @param {!Element|!AnchorBox} anchor |
131 * @param {!WebInspector.Popover} popover | 129 * @param {!WebInspector.Popover} popover |
132 */ | 130 */ |
133 _showPopover: function(anchor, popover) | 131 _showPopover: function(anchor, popover) |
134 { | 132 { |
135 if (!this._hoveredRequest) | 133 if (!this._hoveredRequest) |
136 return; | 134 return; |
137 var content = WebInspector.RequestTimingView.createTimingTable(this._hov eredRequest, this._networkLogView.calculator().minimumBoundary()); | 135 var content = WebInspector.RequestTimingView.createTimingTable(this._hov eredRequest, this._calculator.minimumBoundary()); |
138 popover.showForAnchor(content, anchor); | 136 popover.showForAnchor(content, anchor); |
139 }, | 137 }, |
140 | 138 |
141 wasShown: function() | 139 wasShown: function() |
142 { | 140 { |
143 this.scheduleUpdate(); | 141 this.scheduleUpdate(); |
144 }, | 142 }, |
145 | 143 |
146 scheduleRefreshData: function() | 144 /** |
145 * @return {!Element} | |
146 */ | |
147 getScrollContainer: function() | |
147 { | 148 { |
148 this._needsRefreshData = true; | 149 return this._vScrollElement; |
149 }, | |
150 | |
151 _refreshDataIfNeeded: function() | |
152 { | |
153 if (!this._needsRefreshData) | |
154 return; | |
155 this._needsRefreshData = false; | |
156 var currentNode = this._dataGrid.rootNode(); | |
157 this._requestData = []; | |
158 while (currentNode = currentNode.traverseNextNode(true)) | |
159 this._requestData.push(currentNode.request()); | |
160 }, | 150 }, |
161 | 151 |
162 /** | 152 /** |
153 * @param {!Array<!WebInspector.NetworkRequest>} requests | |
154 */ | |
155 setRequests: function(requests) | |
156 { | |
157 this._requestData = requests; | |
dgozman
2016/10/20 20:52:00
Don't we have to update() here? If not, should we
allada
2016/10/20 21:08:31
At first I was doing an update here, however I cha
| |
158 }, | |
159 | |
160 /** | |
163 * @param {?WebInspector.NetworkRequest} request | 161 * @param {?WebInspector.NetworkRequest} request |
164 */ | 162 */ |
165 setHoveredRequest: function(request) | 163 setHoveredRequest: function(request) |
166 { | 164 { |
167 this._hoveredRequest = request; | 165 this._hoveredRequest = request; |
168 this.scheduleUpdate(); | 166 this.scheduleUpdate(); |
169 }, | 167 }, |
170 | 168 |
171 /** | 169 /** |
170 * @param {number} height | |
171 */ | |
172 setRowHeight: function(height) | |
173 { | |
174 this._rowHeight = height; | |
175 }, | |
176 | |
177 /** | |
178 * @param {number} height | |
179 */ | |
180 setHeaderHeight: function(height) | |
181 { | |
182 this._headerHeight = height; | |
183 }, | |
184 | |
185 /** | |
186 * @param {!WebInspector.NetworkTimeCalculator} calculator | |
187 */ | |
188 setCalculator: function(calculator) | |
189 { | |
190 this._calculator = calculator; | |
191 }, | |
192 | |
193 /** | |
172 * @param {!Event} event | 194 * @param {!Event} event |
173 */ | 195 */ |
174 _onMouseMove: function(event) | 196 _onMouseMove: function(event) |
175 { | 197 { |
176 var request = this._getRequestFromPoint(event.offsetX, event.offsetY); | 198 var request = this._getRequestFromPoint(event.offsetX, event.offsetY); |
177 this.dispatchEventToListeners(WebInspector.NetworkTimelineColumn.Events. RequestHovered, request); | 199 this.dispatchEventToListeners(WebInspector.NetworkTimelineColumn.Events. RequestHovered, request); |
178 }, | 200 }, |
179 | 201 |
180 /** | 202 /** |
181 * @param {!Event} event | 203 * @param {!Event} event |
182 */ | 204 */ |
183 _onMouseWheel: function(event) | 205 _onMouseWheel: function(event) |
184 { | 206 { |
185 this._vScrollElement.scrollTop -= event.wheelDeltaY; | 207 this._vScrollElement.scrollTop -= event.wheelDeltaY; |
186 this._dataGridScrollContainer.scrollTop = this._vScrollElement.scrollTop ; | 208 this._boundScrollContainer.scrollTop = this._vScrollElement.scrollTop; |
187 this._popoverHelper.hidePopover(); | 209 this._popoverHelper.hidePopover(); |
188 | 210 |
189 var request = this._getRequestFromPoint(event.offsetX, event.offsetY); | 211 var request = this._getRequestFromPoint(event.offsetX, event.offsetY); |
190 this.dispatchEventToListeners(WebInspector.NetworkTimelineColumn.Events. RequestHovered, request); | 212 this.dispatchEventToListeners(WebInspector.NetworkTimelineColumn.Events. RequestHovered, request); |
191 }, | 213 }, |
192 | 214 |
193 /** | 215 /** |
194 * @param {!Event} event | 216 * @param {!Event} event |
195 */ | 217 */ |
196 _onScroll: function(event) | 218 _onScroll: function(event) |
197 { | 219 { |
198 this._dataGridScrollContainer.scrollTop = this._vScrollElement.scrollTop ; | 220 this._boundScrollContainer.scrollTop = this._vScrollElement.scrollTop; |
199 this._popoverHelper.hidePopover(); | 221 this._popoverHelper.hidePopover(); |
200 }, | 222 }, |
201 | 223 |
202 /** | 224 /** |
203 * @param {number} x | 225 * @param {number} x |
204 * @param {number} y | 226 * @param {number} y |
205 * @return {?WebInspector.NetworkRequest} | 227 * @return {?WebInspector.NetworkRequest} |
206 */ | 228 */ |
207 _getRequestFromPoint: function(x, y) | 229 _getRequestFromPoint: function(x, y) |
208 { | 230 { |
209 var rowHeight = this._networkLogView.rowHeight(); | |
210 var scrollTop = this._vScrollElement.scrollTop; | 231 var scrollTop = this._vScrollElement.scrollTop; |
211 return this._requestData[Math.floor((scrollTop + y - this._networkLogVie w.headerHeight()) / rowHeight)] || null; | 232 return this._requestData[Math.floor((scrollTop + y - this._headerHeight) / this._rowHeight)] || null; |
212 }, | 233 }, |
213 | 234 |
214 scheduleUpdate: function() | 235 scheduleUpdate: function() |
215 { | 236 { |
216 if (this._updateRequestID) | 237 if (this._updateRequestID) |
217 return; | 238 return; |
218 this._updateRequestID = this.element.window().requestAnimationFrame(this ._update.bind(this)); | 239 this._updateRequestID = this.element.window().requestAnimationFrame(this .update.bind(this)); |
219 }, | 240 }, |
220 | 241 |
221 _update: function() | 242 update: function() |
dgozman
2016/10/20 20:52:00
If we don't pass any data, I feel like this is "re
allada
2016/10/20 22:35:05
Done.
| |
222 { | 243 { |
223 this.element.window().cancelAnimationFrame(this._updateRequestID); | 244 this.element.window().cancelAnimationFrame(this._updateRequestID); |
224 this._updateRequestID = null; | 245 this._updateRequestID = null; |
225 | 246 |
226 this._refreshDataIfNeeded(); | 247 this._startTime = this._calculator.minimumBoundary(); |
227 | 248 this._endTime = this._calculator.maximumBoundary(); |
228 this._startTime = this._networkLogView.calculator().minimumBoundary(); | |
229 this._endTime = this._networkLogView.calculator().maximumBoundary(); | |
230 this._resetCanvas(); | 249 this._resetCanvas(); |
231 this._draw(); | 250 this._draw(); |
232 }, | 251 }, |
233 | 252 |
234 _updateHeight: function() | 253 /** |
254 * @param {number} height | |
255 */ | |
256 setScrollHeight: function(height) | |
235 { | 257 { |
236 var totalHeight = this._dataGridScrollContainer.scrollHeight; | 258 this._vScrollContent.style.height = height + "px"; |
237 this._vScrollContent.style.height = totalHeight + "px"; | |
238 }, | 259 }, |
239 | 260 |
240 _resetCanvas: function() | 261 _resetCanvas: function() |
241 { | 262 { |
242 var ratio = window.devicePixelRatio; | 263 var ratio = window.devicePixelRatio; |
243 this._canvas.width = this._offsetWidth * ratio; | 264 this._canvas.width = this._offsetWidth * ratio; |
244 this._canvas.height = this._offsetHeight * ratio; | 265 this._canvas.height = this._offsetHeight * ratio; |
245 this._canvas.style.width = this._offsetWidth + "px"; | 266 this._canvas.style.width = this._offsetWidth + "px"; |
246 this._canvas.style.height = this._offsetHeight + "px"; | 267 this._canvas.style.height = this._offsetHeight + "px"; |
247 }, | 268 }, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
297 */ | 318 */ |
298 _timeToPosition: function(time) | 319 _timeToPosition: function(time) |
299 { | 320 { |
300 var availableWidth = this._offsetWidth - this._leftPadding - this._right Padding; | 321 var availableWidth = this._offsetWidth - this._leftPadding - this._right Padding; |
301 var timeToPixel = availableWidth / (this._endTime - this._startTime); | 322 var timeToPixel = availableWidth / (this._endTime - this._startTime); |
302 return Math.floor(this._leftPadding + (time - this._startTime) * timeToP ixel); | 323 return Math.floor(this._leftPadding + (time - this._startTime) * timeToP ixel); |
303 }, | 324 }, |
304 | 325 |
305 _draw: function() | 326 _draw: function() |
306 { | 327 { |
307 var useTimingBars = !WebInspector.moduleSetting("networkColorCodeResourc eTypes").get() && !this._networkLogView.calculator().startAtZero; | 328 var useTimingBars = !WebInspector.moduleSetting("networkColorCodeResourc eTypes").get() && !this._calculator.startAtZero; |
308 var requests = this._requestData; | 329 var requests = this._requestData; |
309 var context = this._canvas.getContext("2d"); | 330 var context = this._canvas.getContext("2d"); |
310 context.save(); | 331 context.save(); |
311 context.scale(window.devicePixelRatio, window.devicePixelRatio); | 332 context.scale(window.devicePixelRatio, window.devicePixelRatio); |
312 context.translate(0, this._networkLogView.headerHeight()); | 333 context.translate(0, this._headerHeight); |
313 context.rect(0, 0, this._offsetWidth, this._offsetHeight); | 334 context.rect(0, 0, this._offsetWidth, this._offsetHeight); |
314 context.clip(); | 335 context.clip(); |
315 var rowHeight = this._networkLogView.rowHeight(); | |
316 var scrollTop = this._vScrollElement.scrollTop; | 336 var scrollTop = this._vScrollElement.scrollTop; |
317 var firstRequestIndex = Math.floor(scrollTop / rowHeight); | 337 var firstRequestIndex = Math.floor(scrollTop / this._rowHeight); |
318 var lastRequestIndex = Math.min(requests.length, firstRequestIndex + Mat h.ceil(this._offsetHeight / rowHeight)); | 338 var lastRequestIndex = Math.min(requests.length, firstRequestIndex + Mat h.ceil(this._offsetHeight / this._rowHeight)); |
319 for (var i = firstRequestIndex; i < lastRequestIndex; i++) { | 339 for (var i = firstRequestIndex; i < lastRequestIndex; i++) { |
320 var rowOffset = rowHeight * i; | 340 var rowOffset = this._rowHeight * i; |
321 var request = requests[i]; | 341 var request = requests[i]; |
322 this._decorateRow(context, request, i, rowOffset - scrollTop, rowHei ght); | 342 this._decorateRow(context, request, i, rowOffset - scrollTop); |
323 if (useTimingBars) | 343 if (useTimingBars) |
324 this._drawTimingBars(context, request, rowOffset - scrollTop); | 344 this._drawTimingBars(context, request, rowOffset - scrollTop); |
325 else | 345 else |
326 this._drawSimplifiedBars(context, request, rowOffset - scrollTop ); | 346 this._drawSimplifiedBars(context, request, rowOffset - scrollTop ); |
327 } | 347 } |
328 context.restore(); | 348 context.restore(); |
329 this._drawDividers(context); | 349 this._drawDividers(context); |
330 }, | 350 }, |
331 | 351 |
332 _drawDividers: function(context) | 352 _drawDividers: function(context) |
(...skipping 28 matching lines...) Expand all Loading... | |
361 for (var position = gridSliceTime * pixelsPerTime; position < drawableWi dth; position += gridSliceTime * pixelsPerTime) { | 381 for (var position = gridSliceTime * pixelsPerTime; position < drawableWi dth; position += gridSliceTime * pixelsPerTime) { |
362 // Added .5 because canvas drawing points are between pixels. | 382 // Added .5 because canvas drawing points are between pixels. |
363 var drawPosition = Math.floor(position) + this._leftPadding + .5; | 383 var drawPosition = Math.floor(position) + this._leftPadding + .5; |
364 context.beginPath(); | 384 context.beginPath(); |
365 context.moveTo(drawPosition, 0); | 385 context.moveTo(drawPosition, 0); |
366 context.lineTo(drawPosition, this._offsetHeight); | 386 context.lineTo(drawPosition, this._offsetHeight); |
367 context.stroke(); | 387 context.stroke(); |
368 if (position <= gridSliceTime * pixelsPerTime) | 388 if (position <= gridSliceTime * pixelsPerTime) |
369 continue; | 389 continue; |
370 var textData = Number.secondsToString(position / pixelsPerTime); | 390 var textData = Number.secondsToString(position / pixelsPerTime); |
371 context.fillText(textData, drawPosition - context.measureText(textDa ta).width - 2, Math.floor(this._networkLogView.headerHeight() - this._fontSize / 2)); | 391 context.fillText(textData, drawPosition - context.measureText(textDa ta).width - 2, Math.floor(this._headerHeight - this._fontSize / 2)); |
372 } | 392 } |
373 context.restore(); | 393 context.restore(); |
374 }, | 394 }, |
375 | 395 |
376 /** | 396 /** |
377 * @return {number} | 397 * @return {number} |
378 */ | 398 */ |
379 _timelineDuration: function() | 399 _timelineDuration: function() |
380 { | 400 { |
381 return this._networkLogView.calculator().maximumBoundary() - this._netwo rkLogView.calculator().minimumBoundary(); | 401 return this._calculator.maximumBoundary() - this._calculator.minimumBoun dary(); |
382 }, | 402 }, |
383 | 403 |
384 /** | 404 /** |
385 * @param {!WebInspector.RequestTimeRangeNames=} type | 405 * @param {!WebInspector.RequestTimeRangeNames=} type |
386 * @return {number} | 406 * @return {number} |
387 */ | 407 */ |
388 _getBarHeight: function(type) | 408 _getBarHeight: function(type) |
389 { | 409 { |
390 var types = WebInspector.RequestTimeRangeNames; | 410 var types = WebInspector.RequestTimeRangeNames; |
391 switch (type) { | 411 switch (type) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
452 * @param {!CanvasRenderingContext2D} context | 472 * @param {!CanvasRenderingContext2D} context |
453 * @param {!WebInspector.NetworkRequest} request | 473 * @param {!WebInspector.NetworkRequest} request |
454 * @param {number} y | 474 * @param {number} y |
455 */ | 475 */ |
456 _drawSimplifiedBars: function(context, request, y) | 476 _drawSimplifiedBars: function(context, request, y) |
457 { | 477 { |
458 /** @const */ | 478 /** @const */ |
459 var borderWidth = 1; | 479 var borderWidth = 1; |
460 | 480 |
461 context.save(); | 481 context.save(); |
462 var calculator = this._networkLogView.calculator(); | 482 var percentages = this._calculator.computeBarGraphPercentages(request); |
463 var percentages = calculator.computeBarGraphPercentages(request); | |
464 var drawWidth = this._offsetWidth - this._leftPadding - this._rightPaddi ng; | 483 var drawWidth = this._offsetWidth - this._leftPadding - this._rightPaddi ng; |
465 var borderOffset = borderWidth % 2 === 0 ? 0 : .5; | 484 var borderOffset = borderWidth % 2 === 0 ? 0 : .5; |
466 var start = this._leftPadding + Math.floor((percentages.start / 100) * d rawWidth) + borderOffset; | 485 var start = this._leftPadding + Math.floor((percentages.start / 100) * d rawWidth) + borderOffset; |
467 var mid = this._leftPadding + Math.floor((percentages.middle / 100) * dr awWidth) + borderOffset; | 486 var mid = this._leftPadding + Math.floor((percentages.middle / 100) * dr awWidth) + borderOffset; |
468 var end = this._leftPadding + Math.floor((percentages.end / 100) * drawW idth) + borderOffset; | 487 var end = this._leftPadding + Math.floor((percentages.end / 100) * drawW idth) + borderOffset; |
469 var height = this._getBarHeight(); | 488 var height = this._getBarHeight(); |
470 y += Math.floor(this._networkLogView.rowHeight() / 2 - height / 2 + bord erWidth) - borderWidth / 2; | 489 y += Math.floor(this._rowHeight / 2 - height / 2 + borderWidth) - border Width / 2; |
471 | 490 |
472 context.translate(0, y); | 491 context.translate(0, y); |
473 context.fillStyle = this._colorForResourceType(context, request); | 492 context.fillStyle = this._colorForResourceType(context, request); |
474 context.strokeStyle = this._borderColorForResourceType(request); | 493 context.strokeStyle = this._borderColorForResourceType(request); |
475 context.lineWidth = borderWidth; | 494 context.lineWidth = borderWidth; |
476 | 495 |
477 context.beginPath(); | 496 context.beginPath(); |
478 context.globalAlpha = .5; | 497 context.globalAlpha = .5; |
479 context.rect(start, 0, mid - start, height - borderWidth); | 498 context.rect(start, 0, mid - start, height - borderWidth); |
480 context.fill(); | 499 context.fill(); |
481 context.stroke(); | 500 context.stroke(); |
482 | 501 |
483 var barWidth = Math.max(2, end - mid); | 502 var barWidth = Math.max(2, end - mid); |
484 context.beginPath(); | 503 context.beginPath(); |
485 context.globalAlpha = 1; | 504 context.globalAlpha = 1; |
486 context.rect(mid, 0, barWidth, height - borderWidth); | 505 context.rect(mid, 0, barWidth, height - borderWidth); |
487 context.fill(); | 506 context.fill(); |
488 context.stroke(); | 507 context.stroke(); |
489 | 508 |
490 if (request === this._hoveredRequest) { | 509 if (request === this._hoveredRequest) { |
491 var labels = calculator.computeBarGraphLabels(request); | 510 var labels = this._calculator.computeBarGraphLabels(request); |
492 this._drawSimplifiedBarDetails(context, labels.left, labels.right, s tart, mid, mid + barWidth + borderOffset); | 511 this._drawSimplifiedBarDetails(context, labels.left, labels.right, s tart, mid, mid + barWidth + borderOffset); |
493 } | 512 } |
494 | 513 |
495 context.restore(); | 514 context.restore(); |
496 }, | 515 }, |
497 | 516 |
498 /** | 517 /** |
499 * @param {!CanvasRenderingContext2D} context | 518 * @param {!CanvasRenderingContext2D} context |
500 * @param {string} leftText | 519 * @param {string} leftText |
501 * @param {string} rightText | 520 * @param {string} rightText |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
565 var color = this._colorForType(range.name); | 584 var color = this._colorForType(range.name); |
566 var borderColor = color; | 585 var borderColor = color; |
567 if (range.name === WebInspector.RequestTimeRangeNames.Queueing) { | 586 if (range.name === WebInspector.RequestTimeRangeNames.Queueing) { |
568 borderColor = "lightgrey"; | 587 borderColor = "lightgrey"; |
569 lineWidth = 2; | 588 lineWidth = 2; |
570 } | 589 } |
571 if (range.name === WebInspector.RequestTimeRangeNames.Receiving) | 590 if (range.name === WebInspector.RequestTimeRangeNames.Receiving) |
572 lineWidth = 2; | 591 lineWidth = 2; |
573 context.fillStyle = color; | 592 context.fillStyle = color; |
574 var height = this._getBarHeight(range.name); | 593 var height = this._getBarHeight(range.name); |
575 var middleBarY = y + Math.floor(this._networkLogView.rowHeight() / 2 - height / 2) + lineWidth / 2; | 594 var middleBarY = y + Math.floor(this._rowHeight / 2 - height / 2) + lineWidth / 2; |
576 var start = this._timeToPosition(range.start); | 595 var start = this._timeToPosition(range.start); |
577 var end = this._timeToPosition(range.end); | 596 var end = this._timeToPosition(range.end); |
578 context.rect(start, middleBarY, end - start, height - lineWidth); | 597 context.rect(start, middleBarY, end - start, height - lineWidth); |
579 if (lineWidth) { | 598 if (lineWidth) { |
580 context.lineWidth = lineWidth; | 599 context.lineWidth = lineWidth; |
581 context.strokeStyle = borderColor; | 600 context.strokeStyle = borderColor; |
582 context.stroke(); | 601 context.stroke(); |
583 } | 602 } |
584 context.fill(); | 603 context.fill(); |
585 } | 604 } |
586 context.restore(); | 605 context.restore(); |
587 }, | 606 }, |
588 | 607 |
589 /** | 608 /** |
590 * @param {!CanvasRenderingContext2D} context | 609 * @param {!CanvasRenderingContext2D} context |
591 * @param {!WebInspector.NetworkRequest} request | 610 * @param {!WebInspector.NetworkRequest} request |
592 * @param {number} rowNumber | 611 * @param {number} rowNumber |
593 * @param {number} y | 612 * @param {number} y |
594 * @param {number} rowHeight | |
595 */ | 613 */ |
596 _decorateRow: function(context, request, rowNumber, y, rowHeight) | 614 _decorateRow: function(context, request, rowNumber, y) |
597 { | 615 { |
598 if (rowNumber % 2 === 1 && this._hoveredRequest !== request) | 616 if (rowNumber % 2 === 1 && this._hoveredRequest !== request) |
599 return; | 617 return; |
600 context.save(); | 618 context.save(); |
601 context.beginPath(); | 619 context.beginPath(); |
602 var color = this._rowStripeColor; | 620 var color = this._rowStripeColor; |
603 if (this._hoveredRequest === request) | 621 if (this._hoveredRequest === request) |
604 color = this._rowHoverColor; | 622 color = this._rowHoverColor; |
605 | 623 |
606 context.fillStyle = color; | 624 context.fillStyle = color; |
607 context.rect(0, y, this._offsetWidth, rowHeight); | 625 context.rect(0, y, this._offsetWidth, this._rowHeight); |
608 context.fill(); | 626 context.fill(); |
609 context.restore(); | 627 context.restore(); |
610 }, | 628 }, |
611 | 629 |
612 __proto__: WebInspector.VBox.prototype | 630 __proto__: WebInspector.VBox.prototype |
613 } | 631 } |
OLD | NEW |