| 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.scheduleDraw(); |
| 144 }, | |
| 145 | |
| 146 scheduleRefreshData: function() | |
| 147 { | |
| 148 this._needsRefreshData = true; | |
| 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 }, | 142 }, |
| 161 | 143 |
| 162 /** | 144 /** |
| 145 * @return {!Element} |
| 146 */ |
| 147 getScrollContainer: function() |
| 148 { |
| 149 return this._vScrollElement; |
| 150 }, |
| 151 |
| 152 /** |
| 163 * @param {?WebInspector.NetworkRequest} request | 153 * @param {?WebInspector.NetworkRequest} request |
| 164 */ | 154 */ |
| 165 setHoveredRequest: function(request) | 155 setHoveredRequest: function(request) |
| 166 { | 156 { |
| 167 this._hoveredRequest = request; | 157 this._hoveredRequest = request; |
| 168 this.scheduleUpdate(); | 158 this.scheduleDraw(); |
| 169 }, | 159 }, |
| 170 | 160 |
| 171 /** | 161 /** |
| 162 * @param {number} height |
| 163 */ |
| 164 setRowHeight: function(height) |
| 165 { |
| 166 this._rowHeight = height; |
| 167 }, |
| 168 |
| 169 /** |
| 170 * @param {number} height |
| 171 */ |
| 172 setHeaderHeight: function(height) |
| 173 { |
| 174 this._headerHeight = height; |
| 175 }, |
| 176 |
| 177 /** |
| 178 * @param {!WebInspector.NetworkTimeCalculator} calculator |
| 179 */ |
| 180 setCalculator: function(calculator) |
| 181 { |
| 182 this._calculator = calculator; |
| 183 }, |
| 184 |
| 185 /** |
| 172 * @param {!Event} event | 186 * @param {!Event} event |
| 173 */ | 187 */ |
| 174 _onMouseMove: function(event) | 188 _onMouseMove: function(event) |
| 175 { | 189 { |
| 176 var request = this._getRequestFromPoint(event.offsetX, event.offsetY); | 190 var request = this._getRequestFromPoint(event.offsetX, event.offsetY); |
| 177 this.dispatchEventToListeners(WebInspector.NetworkTimelineColumn.Events.
RequestHovered, request); | 191 this.dispatchEventToListeners(WebInspector.NetworkTimelineColumn.Events.
RequestHovered, request); |
| 178 }, | 192 }, |
| 179 | 193 |
| 180 /** | 194 /** |
| 181 * @param {!Event} event | 195 * @param {!Event} event |
| 182 */ | 196 */ |
| 183 _onMouseWheel: function(event) | 197 _onMouseWheel: function(event) |
| 184 { | 198 { |
| 185 this._vScrollElement.scrollTop -= event.wheelDeltaY; | 199 this._vScrollElement.scrollTop -= event.wheelDeltaY; |
| 186 this._dataGridScrollContainer.scrollTop = this._vScrollElement.scrollTop
; | 200 this._boundScrollContainer.scrollTop = this._vScrollElement.scrollTop; |
| 187 this._popoverHelper.hidePopover(); | 201 this._popoverHelper.hidePopover(); |
| 188 | 202 |
| 189 var request = this._getRequestFromPoint(event.offsetX, event.offsetY); | 203 var request = this._getRequestFromPoint(event.offsetX, event.offsetY); |
| 190 this.dispatchEventToListeners(WebInspector.NetworkTimelineColumn.Events.
RequestHovered, request); | 204 this.dispatchEventToListeners(WebInspector.NetworkTimelineColumn.Events.
RequestHovered, request); |
| 191 }, | 205 }, |
| 192 | 206 |
| 193 /** | 207 /** |
| 194 * @param {!Event} event | 208 * @param {!Event} event |
| 195 */ | 209 */ |
| 196 _onScroll: function(event) | 210 _onScroll: function(event) |
| 197 { | 211 { |
| 198 this._dataGridScrollContainer.scrollTop = this._vScrollElement.scrollTop
; | 212 this._boundScrollContainer.scrollTop = this._vScrollElement.scrollTop; |
| 199 this._popoverHelper.hidePopover(); | 213 this._popoverHelper.hidePopover(); |
| 200 }, | 214 }, |
| 201 | 215 |
| 202 /** | 216 /** |
| 203 * @param {number} x | 217 * @param {number} x |
| 204 * @param {number} y | 218 * @param {number} y |
| 205 * @return {?WebInspector.NetworkRequest} | 219 * @return {?WebInspector.NetworkRequest} |
| 206 */ | 220 */ |
| 207 _getRequestFromPoint: function(x, y) | 221 _getRequestFromPoint: function(x, y) |
| 208 { | 222 { |
| 209 var rowHeight = this._networkLogView.rowHeight(); | |
| 210 var scrollTop = this._vScrollElement.scrollTop; | 223 var scrollTop = this._vScrollElement.scrollTop; |
| 211 return this._requestData[Math.floor((scrollTop + y - this._networkLogVie
w.headerHeight()) / rowHeight)] || null; | 224 return this._requestData[Math.floor((scrollTop + y - this._headerHeight)
/ this._rowHeight)] || null; |
| 212 }, | 225 }, |
| 213 | 226 |
| 214 scheduleUpdate: function() | 227 scheduleDraw: function() |
| 215 { | 228 { |
| 216 if (this._updateRequestID) | 229 if (this._updateRequestID) |
| 217 return; | 230 return; |
| 218 this._updateRequestID = this.element.window().requestAnimationFrame(this
._update.bind(this)); | 231 this._updateRequestID = this.element.window().requestAnimationFrame(this
.update.bind(this, undefined)); |
| 219 }, | 232 }, |
| 220 | 233 |
| 221 _update: function() | 234 /** |
| 235 * @param {!Array<!WebInspector.NetworkRequest>=} requests |
| 236 */ |
| 237 update: function(requests) |
| 222 { | 238 { |
| 239 if (requests) |
| 240 this._requestData = requests; |
| 223 this.element.window().cancelAnimationFrame(this._updateRequestID); | 241 this.element.window().cancelAnimationFrame(this._updateRequestID); |
| 224 this._updateRequestID = null; | 242 this._updateRequestID = null; |
| 225 | 243 |
| 226 this._refreshDataIfNeeded(); | 244 this._startTime = this._calculator.minimumBoundary(); |
| 227 | 245 this._endTime = this._calculator.maximumBoundary(); |
| 228 this._startTime = this._networkLogView.calculator().minimumBoundary(); | |
| 229 this._endTime = this._networkLogView.calculator().maximumBoundary(); | |
| 230 this._resetCanvas(); | 246 this._resetCanvas(); |
| 231 this._draw(); | 247 this._draw(); |
| 232 }, | 248 }, |
| 233 | 249 |
| 234 _updateHeight: function() | 250 /** |
| 251 * @param {number} height |
| 252 */ |
| 253 setScrollHeight: function(height) |
| 235 { | 254 { |
| 236 var totalHeight = this._dataGridScrollContainer.scrollHeight; | 255 this._vScrollContent.style.height = height + "px"; |
| 237 this._vScrollContent.style.height = totalHeight + "px"; | |
| 238 }, | 256 }, |
| 239 | 257 |
| 240 _resetCanvas: function() | 258 _resetCanvas: function() |
| 241 { | 259 { |
| 242 var ratio = window.devicePixelRatio; | 260 var ratio = window.devicePixelRatio; |
| 243 this._canvas.width = this._offsetWidth * ratio; | 261 this._canvas.width = this._offsetWidth * ratio; |
| 244 this._canvas.height = this._offsetHeight * ratio; | 262 this._canvas.height = this._offsetHeight * ratio; |
| 245 this._canvas.style.width = this._offsetWidth + "px"; | 263 this._canvas.style.width = this._offsetWidth + "px"; |
| 246 this._canvas.style.height = this._offsetHeight + "px"; | 264 this._canvas.style.height = this._offsetHeight + "px"; |
| 247 }, | 265 }, |
| 248 | 266 |
| 249 /** | 267 /** |
| 250 * @override | 268 * @override |
| 251 */ | 269 */ |
| 252 onResize: function() | 270 onResize: function() |
| 253 { | 271 { |
| 254 WebInspector.VBox.prototype.onResize.call(this); | 272 WebInspector.VBox.prototype.onResize.call(this); |
| 255 this._offsetWidth = this.contentElement.offsetWidth; | 273 this._offsetWidth = this.contentElement.offsetWidth; |
| 256 this._offsetHeight = this.contentElement.offsetHeight; | 274 this._offsetHeight = this.contentElement.offsetHeight; |
| 257 this.scheduleUpdate(); | 275 this.scheduleDraw(); |
| 258 }, | 276 }, |
| 259 | 277 |
| 260 /** | 278 /** |
| 261 * @param {!WebInspector.RequestTimeRangeNames} type | 279 * @param {!WebInspector.RequestTimeRangeNames} type |
| 262 * @return {string} | 280 * @return {string} |
| 263 */ | 281 */ |
| 264 _colorForType: function(type) | 282 _colorForType: function(type) |
| 265 { | 283 { |
| 266 var types = WebInspector.RequestTimeRangeNames; | 284 var types = WebInspector.RequestTimeRangeNames; |
| 267 switch (type) { | 285 switch (type) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 297 */ | 315 */ |
| 298 _timeToPosition: function(time) | 316 _timeToPosition: function(time) |
| 299 { | 317 { |
| 300 var availableWidth = this._offsetWidth - this._leftPadding - this._right
Padding; | 318 var availableWidth = this._offsetWidth - this._leftPadding - this._right
Padding; |
| 301 var timeToPixel = availableWidth / (this._endTime - this._startTime); | 319 var timeToPixel = availableWidth / (this._endTime - this._startTime); |
| 302 return Math.floor(this._leftPadding + (time - this._startTime) * timeToP
ixel); | 320 return Math.floor(this._leftPadding + (time - this._startTime) * timeToP
ixel); |
| 303 }, | 321 }, |
| 304 | 322 |
| 305 _draw: function() | 323 _draw: function() |
| 306 { | 324 { |
| 307 var useTimingBars = !WebInspector.moduleSetting("networkColorCodeResourc
eTypes").get() && !this._networkLogView.calculator().startAtZero; | 325 var useTimingBars = !WebInspector.moduleSetting("networkColorCodeResourc
eTypes").get() && !this._calculator.startAtZero; |
| 308 var requests = this._requestData; | 326 var requests = this._requestData; |
| 309 var context = this._canvas.getContext("2d"); | 327 var context = this._canvas.getContext("2d"); |
| 310 context.save(); | 328 context.save(); |
| 311 context.scale(window.devicePixelRatio, window.devicePixelRatio); | 329 context.scale(window.devicePixelRatio, window.devicePixelRatio); |
| 312 context.translate(0, this._networkLogView.headerHeight()); | 330 context.translate(0, this._headerHeight); |
| 313 context.rect(0, 0, this._offsetWidth, this._offsetHeight); | 331 context.rect(0, 0, this._offsetWidth, this._offsetHeight); |
| 314 context.clip(); | 332 context.clip(); |
| 315 var rowHeight = this._networkLogView.rowHeight(); | |
| 316 var scrollTop = this._vScrollElement.scrollTop; | 333 var scrollTop = this._vScrollElement.scrollTop; |
| 317 var firstRequestIndex = Math.floor(scrollTop / rowHeight); | 334 var firstRequestIndex = Math.floor(scrollTop / this._rowHeight); |
| 318 var lastRequestIndex = Math.min(requests.length, firstRequestIndex + Mat
h.ceil(this._offsetHeight / rowHeight)); | 335 var lastRequestIndex = Math.min(requests.length, firstRequestIndex + Mat
h.ceil(this._offsetHeight / this._rowHeight)); |
| 319 for (var i = firstRequestIndex; i < lastRequestIndex; i++) { | 336 for (var i = firstRequestIndex; i < lastRequestIndex; i++) { |
| 320 var rowOffset = rowHeight * i; | 337 var rowOffset = this._rowHeight * i; |
| 321 var request = requests[i]; | 338 var request = requests[i]; |
| 322 this._decorateRow(context, request, i, rowOffset - scrollTop, rowHei
ght); | 339 this._decorateRow(context, request, i, rowOffset - scrollTop); |
| 323 if (useTimingBars) | 340 if (useTimingBars) |
| 324 this._drawTimingBars(context, request, rowOffset - scrollTop); | 341 this._drawTimingBars(context, request, rowOffset - scrollTop); |
| 325 else | 342 else |
| 326 this._drawSimplifiedBars(context, request, rowOffset - scrollTop
); | 343 this._drawSimplifiedBars(context, request, rowOffset - scrollTop
); |
| 327 } | 344 } |
| 328 context.restore(); | 345 context.restore(); |
| 329 this._drawDividers(context); | 346 this._drawDividers(context); |
| 330 }, | 347 }, |
| 331 | 348 |
| 332 _drawDividers: function(context) | 349 _drawDividers: function(context) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 361 for (var position = gridSliceTime * pixelsPerTime; position < drawableWi
dth; position += gridSliceTime * pixelsPerTime) { | 378 for (var position = gridSliceTime * pixelsPerTime; position < drawableWi
dth; position += gridSliceTime * pixelsPerTime) { |
| 362 // Added .5 because canvas drawing points are between pixels. | 379 // Added .5 because canvas drawing points are between pixels. |
| 363 var drawPosition = Math.floor(position) + this._leftPadding + .5; | 380 var drawPosition = Math.floor(position) + this._leftPadding + .5; |
| 364 context.beginPath(); | 381 context.beginPath(); |
| 365 context.moveTo(drawPosition, 0); | 382 context.moveTo(drawPosition, 0); |
| 366 context.lineTo(drawPosition, this._offsetHeight); | 383 context.lineTo(drawPosition, this._offsetHeight); |
| 367 context.stroke(); | 384 context.stroke(); |
| 368 if (position <= gridSliceTime * pixelsPerTime) | 385 if (position <= gridSliceTime * pixelsPerTime) |
| 369 continue; | 386 continue; |
| 370 var textData = Number.secondsToString(position / pixelsPerTime); | 387 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)); | 388 context.fillText(textData, drawPosition - context.measureText(textDa
ta).width - 2, Math.floor(this._headerHeight - this._fontSize / 2)); |
| 372 } | 389 } |
| 373 context.restore(); | 390 context.restore(); |
| 374 }, | 391 }, |
| 375 | 392 |
| 376 /** | 393 /** |
| 377 * @return {number} | 394 * @return {number} |
| 378 */ | 395 */ |
| 379 _timelineDuration: function() | 396 _timelineDuration: function() |
| 380 { | 397 { |
| 381 return this._networkLogView.calculator().maximumBoundary() - this._netwo
rkLogView.calculator().minimumBoundary(); | 398 return this._calculator.maximumBoundary() - this._calculator.minimumBoun
dary(); |
| 382 }, | 399 }, |
| 383 | 400 |
| 384 /** | 401 /** |
| 385 * @param {!WebInspector.RequestTimeRangeNames=} type | 402 * @param {!WebInspector.RequestTimeRangeNames=} type |
| 386 * @return {number} | 403 * @return {number} |
| 387 */ | 404 */ |
| 388 _getBarHeight: function(type) | 405 _getBarHeight: function(type) |
| 389 { | 406 { |
| 390 var types = WebInspector.RequestTimeRangeNames; | 407 var types = WebInspector.RequestTimeRangeNames; |
| 391 switch (type) { | 408 switch (type) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 * @param {!CanvasRenderingContext2D} context | 469 * @param {!CanvasRenderingContext2D} context |
| 453 * @param {!WebInspector.NetworkRequest} request | 470 * @param {!WebInspector.NetworkRequest} request |
| 454 * @param {number} y | 471 * @param {number} y |
| 455 */ | 472 */ |
| 456 _drawSimplifiedBars: function(context, request, y) | 473 _drawSimplifiedBars: function(context, request, y) |
| 457 { | 474 { |
| 458 /** @const */ | 475 /** @const */ |
| 459 var borderWidth = 1; | 476 var borderWidth = 1; |
| 460 | 477 |
| 461 context.save(); | 478 context.save(); |
| 462 var calculator = this._networkLogView.calculator(); | 479 var percentages = this._calculator.computeBarGraphPercentages(request); |
| 463 var percentages = calculator.computeBarGraphPercentages(request); | |
| 464 var drawWidth = this._offsetWidth - this._leftPadding - this._rightPaddi
ng; | 480 var drawWidth = this._offsetWidth - this._leftPadding - this._rightPaddi
ng; |
| 465 var borderOffset = borderWidth % 2 === 0 ? 0 : .5; | 481 var borderOffset = borderWidth % 2 === 0 ? 0 : .5; |
| 466 var start = this._leftPadding + Math.floor((percentages.start / 100) * d
rawWidth) + borderOffset; | 482 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; | 483 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; | 484 var end = this._leftPadding + Math.floor((percentages.end / 100) * drawW
idth) + borderOffset; |
| 469 var height = this._getBarHeight(); | 485 var height = this._getBarHeight(); |
| 470 y += Math.floor(this._networkLogView.rowHeight() / 2 - height / 2 + bord
erWidth) - borderWidth / 2; | 486 y += Math.floor(this._rowHeight / 2 - height / 2 + borderWidth) - border
Width / 2; |
| 471 | 487 |
| 472 context.translate(0, y); | 488 context.translate(0, y); |
| 473 context.fillStyle = this._colorForResourceType(context, request); | 489 context.fillStyle = this._colorForResourceType(context, request); |
| 474 context.strokeStyle = this._borderColorForResourceType(request); | 490 context.strokeStyle = this._borderColorForResourceType(request); |
| 475 context.lineWidth = borderWidth; | 491 context.lineWidth = borderWidth; |
| 476 | 492 |
| 477 context.beginPath(); | 493 context.beginPath(); |
| 478 context.globalAlpha = .5; | 494 context.globalAlpha = .5; |
| 479 context.rect(start, 0, mid - start, height - borderWidth); | 495 context.rect(start, 0, mid - start, height - borderWidth); |
| 480 context.fill(); | 496 context.fill(); |
| 481 context.stroke(); | 497 context.stroke(); |
| 482 | 498 |
| 483 var barWidth = Math.max(2, end - mid); | 499 var barWidth = Math.max(2, end - mid); |
| 484 context.beginPath(); | 500 context.beginPath(); |
| 485 context.globalAlpha = 1; | 501 context.globalAlpha = 1; |
| 486 context.rect(mid, 0, barWidth, height - borderWidth); | 502 context.rect(mid, 0, barWidth, height - borderWidth); |
| 487 context.fill(); | 503 context.fill(); |
| 488 context.stroke(); | 504 context.stroke(); |
| 489 | 505 |
| 490 if (request === this._hoveredRequest) { | 506 if (request === this._hoveredRequest) { |
| 491 var labels = calculator.computeBarGraphLabels(request); | 507 var labels = this._calculator.computeBarGraphLabels(request); |
| 492 this._drawSimplifiedBarDetails(context, labels.left, labels.right, s
tart, mid, mid + barWidth + borderOffset); | 508 this._drawSimplifiedBarDetails(context, labels.left, labels.right, s
tart, mid, mid + barWidth + borderOffset); |
| 493 } | 509 } |
| 494 | 510 |
| 495 context.restore(); | 511 context.restore(); |
| 496 }, | 512 }, |
| 497 | 513 |
| 498 /** | 514 /** |
| 499 * @param {!CanvasRenderingContext2D} context | 515 * @param {!CanvasRenderingContext2D} context |
| 500 * @param {string} leftText | 516 * @param {string} leftText |
| 501 * @param {string} rightText | 517 * @param {string} rightText |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 var color = this._colorForType(range.name); | 581 var color = this._colorForType(range.name); |
| 566 var borderColor = color; | 582 var borderColor = color; |
| 567 if (range.name === WebInspector.RequestTimeRangeNames.Queueing) { | 583 if (range.name === WebInspector.RequestTimeRangeNames.Queueing) { |
| 568 borderColor = "lightgrey"; | 584 borderColor = "lightgrey"; |
| 569 lineWidth = 2; | 585 lineWidth = 2; |
| 570 } | 586 } |
| 571 if (range.name === WebInspector.RequestTimeRangeNames.Receiving) | 587 if (range.name === WebInspector.RequestTimeRangeNames.Receiving) |
| 572 lineWidth = 2; | 588 lineWidth = 2; |
| 573 context.fillStyle = color; | 589 context.fillStyle = color; |
| 574 var height = this._getBarHeight(range.name); | 590 var height = this._getBarHeight(range.name); |
| 575 var middleBarY = y + Math.floor(this._networkLogView.rowHeight() / 2
- height / 2) + lineWidth / 2; | 591 var middleBarY = y + Math.floor(this._rowHeight / 2 - height / 2) +
lineWidth / 2; |
| 576 var start = this._timeToPosition(range.start); | 592 var start = this._timeToPosition(range.start); |
| 577 var end = this._timeToPosition(range.end); | 593 var end = this._timeToPosition(range.end); |
| 578 context.rect(start, middleBarY, end - start, height - lineWidth); | 594 context.rect(start, middleBarY, end - start, height - lineWidth); |
| 579 if (lineWidth) { | 595 if (lineWidth) { |
| 580 context.lineWidth = lineWidth; | 596 context.lineWidth = lineWidth; |
| 581 context.strokeStyle = borderColor; | 597 context.strokeStyle = borderColor; |
| 582 context.stroke(); | 598 context.stroke(); |
| 583 } | 599 } |
| 584 context.fill(); | 600 context.fill(); |
| 585 } | 601 } |
| 586 context.restore(); | 602 context.restore(); |
| 587 }, | 603 }, |
| 588 | 604 |
| 589 /** | 605 /** |
| 590 * @param {!CanvasRenderingContext2D} context | 606 * @param {!CanvasRenderingContext2D} context |
| 591 * @param {!WebInspector.NetworkRequest} request | 607 * @param {!WebInspector.NetworkRequest} request |
| 592 * @param {number} rowNumber | 608 * @param {number} rowNumber |
| 593 * @param {number} y | 609 * @param {number} y |
| 594 * @param {number} rowHeight | |
| 595 */ | 610 */ |
| 596 _decorateRow: function(context, request, rowNumber, y, rowHeight) | 611 _decorateRow: function(context, request, rowNumber, y) |
| 597 { | 612 { |
| 598 if (rowNumber % 2 === 1 && this._hoveredRequest !== request) | 613 if (rowNumber % 2 === 1 && this._hoveredRequest !== request) |
| 599 return; | 614 return; |
| 600 context.save(); | 615 context.save(); |
| 601 context.beginPath(); | 616 context.beginPath(); |
| 602 var color = this._rowStripeColor; | 617 var color = this._rowStripeColor; |
| 603 if (this._hoveredRequest === request) | 618 if (this._hoveredRequest === request) |
| 604 color = this._rowHoverColor; | 619 color = this._rowHoverColor; |
| 605 | 620 |
| 606 context.fillStyle = color; | 621 context.fillStyle = color; |
| 607 context.rect(0, y, this._offsetWidth, rowHeight); | 622 context.rect(0, y, this._offsetWidth, this._rowHeight); |
| 608 context.fill(); | 623 context.fill(); |
| 609 context.restore(); | 624 context.restore(); |
| 610 }, | 625 }, |
| 611 | 626 |
| 612 __proto__: WebInspector.VBox.prototype | 627 __proto__: WebInspector.VBox.prototype |
| 613 } | 628 } |
| OLD | NEW |