Chromium Code Reviews| 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 {!WebInspector.NetworkLogView} networkLogView |
| 9 * @param {!WebInspector.SortableDataGrid} dataGrid | 9 * @param {!WebInspector.SortableDataGrid} dataGrid |
| 10 */ | 10 */ |
| 11 WebInspector.NetworkTimelineColumn = function(networkLogView, dataGrid) | 11 WebInspector.NetworkTimelineColumn = function(networkLogView, dataGrid) |
| 12 { | 12 { |
| 13 WebInspector.VBox.call(this, true); | 13 WebInspector.VBox.call(this, true); |
| 14 this._canvas = this.contentElement.createChild("canvas"); | 14 this._canvas = this.contentElement.createChild("canvas"); |
| 15 this._canvas.tabIndex = 1; | 15 this._canvas.tabIndex = 1; |
| 16 this.setDefaultFocusedElement(this._canvas); | 16 this.setDefaultFocusedElement(this._canvas); |
| 17 | 17 |
| 18 /** @const */ | 18 /** @const */ |
| 19 this._leftPadding = 5; | 19 this._leftPadding = 5; |
| 20 /** @const */ | 20 /** @const */ |
| 21 this._rightPadding = 5; | 21 this._rightPadding = 5; |
| 22 | 22 |
| 23 this._dataGrid = dataGrid; | 23 this._dataGrid = dataGrid; |
| 24 this._networkLogView = networkLogView; | 24 this._networkLogView = networkLogView; |
| 25 /** @type {!Array<!WebInspector.NetworkRequest>} */ | 25 /** @type {!Array<!WebInspector.NetworkRequest>} */ |
| 26 this._requestData = []; | 26 this._requestData = []; |
| 27 this.scheduleUpdate(); | |
|
dgozman
2016/10/11 19:19:41
I don't think we need to schedule until wasShown.
| |
| 27 } | 28 } |
| 28 | 29 |
| 29 WebInspector.NetworkTimelineColumn.prototype = { | 30 WebInspector.NetworkTimelineColumn.prototype = { |
| 31 scheduleRefreshData: function() | |
| 32 { | |
| 33 this._needsRefreshData = true; | |
| 34 }, | |
| 35 | |
| 36 _refreshDataIfNeeded: function() | |
| 37 { | |
| 38 if (!this._needsRefreshData) | |
| 39 return; | |
| 40 this._needsRefreshData = false; | |
| 41 var currentNode = this._dataGrid.rootNode(); | |
| 42 this._requestData = []; | |
| 43 while (currentNode = currentNode.traverseNextNode(true)) | |
| 44 this._requestData.push(currentNode.request()); | |
| 45 this._update(); | |
| 46 }, | |
| 47 | |
| 30 scheduleUpdate: function() | 48 scheduleUpdate: function() |
| 31 { | 49 { |
| 32 if (this._updateRequestID) | 50 if (this._updateRequestID) |
| 33 return; | 51 return; |
| 34 this._updateRequestID = this.element.window().requestAnimationFrame(this ._update.bind(this)); | 52 this._updateRequestID = this.element.window().requestAnimationFrame(this ._update.bind(this)); |
| 35 }, | 53 }, |
| 36 | 54 |
| 37 _update: function() | 55 _update: function() |
|
dgozman
2016/10/11 19:19:41
We should also not do any updates while !isShowing
| |
| 38 { | 56 { |
| 39 this.element.window().cancelAnimationFrame(this._updateRequestID); | 57 this.element.window().cancelAnimationFrame(this._updateRequestID); |
| 40 this._updateRequestID = null; | 58 this._updateRequestID = null; |
| 41 | 59 |
| 60 this._refreshDataIfNeeded(); | |
| 61 | |
| 42 this._startTime = this._networkLogView.calculator().minimumBoundary(); | 62 this._startTime = this._networkLogView.calculator().minimumBoundary(); |
| 43 this._endTime = this._networkLogView.calculator().maximumBoundary(); | 63 this._endTime = this._networkLogView.calculator().maximumBoundary(); |
| 44 this._resetCanvas(); | 64 this._resetCanvas(); |
| 45 this._draw(); | 65 this._draw(); |
| 46 }, | 66 }, |
| 47 | 67 |
| 48 _resetCanvas: function() | 68 _resetCanvas: function() |
| 49 { | 69 { |
| 50 var ratio = window.devicePixelRatio; | 70 var ratio = window.devicePixelRatio; |
| 51 this._canvas.width = this._offsetWidth * ratio; | 71 this._canvas.width = this._offsetWidth * ratio; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 context.lineWidth = lineWidth; | 223 context.lineWidth = lineWidth; |
| 204 context.strokeStyle = borderColor; | 224 context.strokeStyle = borderColor; |
| 205 context.stroke(); | 225 context.stroke(); |
| 206 } | 226 } |
| 207 context.fill(); | 227 context.fill(); |
| 208 context.restore(); | 228 context.restore(); |
| 209 }, | 229 }, |
| 210 | 230 |
| 211 __proto__: WebInspector.VBox.prototype | 231 __proto__: WebInspector.VBox.prototype |
| 212 } | 232 } |
| OLD | NEW |