| 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.registerRequiredCSS("network/networkTimelineColumn.css"); | 14 this.registerRequiredCSS("network/networkTimelineColumn.css"); |
| 15 | 15 |
| 16 this._canvas = this.contentElement.createChild("canvas"); | 16 this._canvas = this.contentElement.createChild("canvas"); |
| 17 this._canvas.tabIndex = 1; | 17 this._canvas.tabIndex = 1; |
| 18 this.setDefaultFocusedElement(this._canvas); | 18 this.setDefaultFocusedElement(this._canvas); |
| 19 | 19 |
| 20 /** @const */ | 20 /** @const */ |
| 21 this._leftPadding = 5; | 21 this._leftPadding = 5; |
| 22 /** @const */ | 22 /** @const */ |
| 23 this._rightPadding = 5; | 23 this._rightPadding = 5; |
| 24 | 24 |
| 25 this._dataGrid = dataGrid; | 25 this._dataGrid = dataGrid; |
| 26 this._networkLogView = networkLogView; | 26 this._networkLogView = networkLogView; |
| 27 | 27 |
| 28 this._popoverHelper = new WebInspector.PopoverHelper(this.element, this._get
PopoverAnchor.bind(this), this._showPopover.bind(this)); |
| 29 this._popoverHelper.setTimeout(300, 300); |
| 30 |
| 28 this._vScrollElement = this.contentElement.createChild("div", "network-timel
ine-v-scroll"); | 31 this._vScrollElement = this.contentElement.createChild("div", "network-timel
ine-v-scroll"); |
| 29 this._vScrollContent = this._vScrollElement.createChild("div"); | |
| 30 this._vScrollElement.addEventListener("scroll", this._onScroll.bind(this), {
passive: true }); | 32 this._vScrollElement.addEventListener("scroll", this._onScroll.bind(this), {
passive: true }); |
| 31 this._vScrollElement.addEventListener("mousewheel", this._onMouseWheel.bind(
this), { passive: true }); | 33 this._vScrollElement.addEventListener("mousewheel", this._onMouseWheel.bind(
this), { passive: true }); |
| 32 this._canvas.addEventListener("mousewheel", this._onMouseWheel.bind(this), {
passive: true }); | 34 this._vScrollContent = this._vScrollElement.createChild("div"); |
| 33 this._canvas.addEventListener("mousemove", this._onMouseMove.bind(this), tru
e); | 35 |
| 34 this._canvas.addEventListener("mouseleave", this.setHoveredRequest.bind(this
, null), true); | 36 this.element.addEventListener("mousewheel", this._onMouseWheel.bind(this), {
passive: true }); |
| 37 this.element.addEventListener("mousemove", this._onMouseMove.bind(this), tru
e); |
| 38 this.element.addEventListener("mouseleave", this.setHoveredRequest.bind(this
, null), true); |
| 35 | 39 |
| 36 this._dataGridScrollContainer = this._dataGrid.scrollContainer; | 40 this._dataGridScrollContainer = this._dataGrid.scrollContainer; |
| 37 this._dataGridScrollContainer.addEventListener("mousewheel", event => { | 41 this._dataGridScrollContainer.addEventListener("mousewheel", event => { |
| 38 event.consume(true); | 42 event.consume(true); |
| 39 this._onMouseWheel(event); | 43 this._onMouseWheel(event); |
| 40 }, true); | 44 }, true); |
| 41 | 45 |
| 42 // TODO(allada) When timeline canvas moves out of experiment move this to st
ylesheet. | 46 // TODO(allada) When timeline canvas moves out of experiment move this to st
ylesheet. |
| 43 this._dataGridScrollContainer.style.overflow = "hidden"; | 47 this._dataGridScrollContainer.style.overflow = "hidden"; |
| 44 this._dataGrid.setScrollContainer(this._vScrollElement); | 48 this._dataGrid.setScrollContainer(this._vScrollElement); |
| 45 | 49 |
| 46 this._dataGrid.addEventListener(WebInspector.ViewportDataGrid.Events.Viewpor
tCalculated, this._update.bind(this)); | 50 this._dataGrid.addEventListener(WebInspector.ViewportDataGrid.Events.Viewpor
tCalculated, this._update.bind(this)); |
| 47 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.PaddingChanged,
this._updateHeight.bind(this)); | 51 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.PaddingChanged,
this._updateHeight.bind(this)); |
| 48 | 52 |
| 49 /** @type {!Array<!WebInspector.NetworkRequest>} */ | 53 /** @type {!Array<!WebInspector.NetworkRequest>} */ |
| 50 this._requestData = []; | 54 this._requestData = []; |
| 51 | 55 |
| 52 /** @type {?WebInspector.NetworkRequest} */ | 56 /** @type {?WebInspector.NetworkRequest} */ |
| 53 this._hoveredRequest = null; | 57 this._hoveredRequest = null; |
| 54 | 58 |
| 55 this._rowStripeColor = WebInspector.themeSupport.patchColor("#f5f5f5", WebIn
spector.ThemeSupport.ColorUsage.Background); | 59 this._rowStripeColor = WebInspector.themeSupport.patchColor("#f5f5f5", WebIn
spector.ThemeSupport.ColorUsage.Background); |
| 56 this._rowHoverColor = WebInspector.themeSupport.patchColor("#ebf2fc", WebIns
pector.ThemeSupport.ColorUsage.Background); | 60 this._rowHoverColor = WebInspector.themeSupport.patchColor("#ebf2fc", WebIns
pector.ThemeSupport.ColorUsage.Background); |
| 57 } | 61 } |
| 58 | 62 |
| 59 WebInspector.NetworkTimelineColumn.Events = { | 63 WebInspector.NetworkTimelineColumn.Events = { |
| 60 RequestHovered: Symbol("RequestHovered") | 64 RequestHovered: Symbol("RequestHovered") |
| 61 } | 65 } |
| 62 | 66 |
| 63 WebInspector.NetworkTimelineColumn.prototype = { | 67 WebInspector.NetworkTimelineColumn.prototype = { |
| 68 /** |
| 69 * @override |
| 70 */ |
| 71 willHide: function() |
| 72 { |
| 73 this._popoverHelper.hidePopover(); |
| 74 }, |
| 75 |
| 76 /** |
| 77 * @param {!Element} element |
| 78 * @param {!Event} event |
| 79 * @return {!AnchorBox|undefined} |
| 80 */ |
| 81 _getPopoverAnchor: function(element, event) |
| 82 { |
| 83 if (!this._hoveredRequest) |
| 84 return; |
| 85 |
| 86 var rowHeight = this._networkLogView.rowHeight(); |
| 87 var range = WebInspector.RequestTimingView.calculateRequestTimeRanges(th
is._hoveredRequest, 0).find(data => data.name === "total"); |
| 88 var start = this._timeToPosition(range.start); |
| 89 var end = this._timeToPosition(range.end); |
| 90 |
| 91 if (event.offsetX < start || event.offsetX > end) |
| 92 return; |
| 93 |
| 94 var rowIndex = this._requestData.findIndex(request => this._hoveredReque
st === request); |
| 95 var barHeight = this._getBarHeight(range.name); |
| 96 var y = this._networkLogView.headerHeight() + (rowHeight * rowIndex - th
is._vScrollElement.scrollTop) + ((rowHeight - barHeight) / 2); |
| 97 |
| 98 if (event.offsetY < y || event.offsetY > y + barHeight) |
| 99 return; |
| 100 |
| 101 var anchorBox = this.element.boxInWindow(); |
| 102 anchorBox.x += start; |
| 103 anchorBox.y += y; |
| 104 anchorBox.width = end - start; |
| 105 anchorBox.height = barHeight; |
| 106 return anchorBox; |
| 107 }, |
| 108 |
| 109 /** |
| 110 * @param {!Element|!AnchorBox} anchor |
| 111 * @param {!WebInspector.Popover} popover |
| 112 */ |
| 113 _showPopover: function(anchor, popover) |
| 114 { |
| 115 if (!this._hoveredRequest) |
| 116 return; |
| 117 var content = WebInspector.RequestTimingView.createTimingTable(this._hov
eredRequest, this._networkLogView.timeCalculator().minimumBoundary()); |
| 118 popover.showForAnchor(content, anchor); |
| 119 }, |
| 120 |
| 64 wasShown: function() | 121 wasShown: function() |
| 65 { | 122 { |
| 66 this.scheduleUpdate(); | 123 this.scheduleUpdate(); |
| 67 }, | 124 }, |
| 68 | 125 |
| 69 scheduleRefreshData: function() | 126 scheduleRefreshData: function() |
| 70 { | 127 { |
| 71 this._needsRefreshData = true; | 128 this._needsRefreshData = true; |
| 72 }, | 129 }, |
| 73 | 130 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 100 this.dispatchEventToListeners(WebInspector.NetworkTimelineColumn.Events.
RequestHovered, request); | 157 this.dispatchEventToListeners(WebInspector.NetworkTimelineColumn.Events.
RequestHovered, request); |
| 101 }, | 158 }, |
| 102 | 159 |
| 103 /** | 160 /** |
| 104 * @param {!Event} event | 161 * @param {!Event} event |
| 105 */ | 162 */ |
| 106 _onMouseWheel: function(event) | 163 _onMouseWheel: function(event) |
| 107 { | 164 { |
| 108 this._vScrollElement.scrollTop -= event.wheelDeltaY; | 165 this._vScrollElement.scrollTop -= event.wheelDeltaY; |
| 109 this._dataGridScrollContainer.scrollTop = this._vScrollElement.scrollTop
; | 166 this._dataGridScrollContainer.scrollTop = this._vScrollElement.scrollTop
; |
| 167 this._popoverHelper.hidePopover(); |
| 168 |
| 110 var request = this._getRequestFromPoint(event.offsetX, event.offsetY); | 169 var request = this._getRequestFromPoint(event.offsetX, event.offsetY); |
| 111 this.dispatchEventToListeners(WebInspector.NetworkTimelineColumn.Events.
RequestHovered, request); | 170 this.dispatchEventToListeners(WebInspector.NetworkTimelineColumn.Events.
RequestHovered, request); |
| 112 }, | 171 }, |
| 113 | 172 |
| 114 /** | 173 /** |
| 115 * @param {!Event} event | 174 * @param {!Event} event |
| 116 */ | 175 */ |
| 117 _onScroll: function(event) | 176 _onScroll: function(event) |
| 118 { | 177 { |
| 119 this._dataGridScrollContainer.scrollTop = this._vScrollElement.scrollTop
; | 178 this._dataGridScrollContainer.scrollTop = this._vScrollElement.scrollTop
; |
| 179 this._popoverHelper.hidePopover(); |
| 120 }, | 180 }, |
| 121 | 181 |
| 122 /** | 182 /** |
| 123 * @param {number} x | 183 * @param {number} x |
| 124 * @param {number} y | 184 * @param {number} y |
| 125 * @return {?WebInspector.NetworkRequest} | 185 * @return {?WebInspector.NetworkRequest} |
| 126 */ | 186 */ |
| 127 _getRequestFromPoint: function(x, y) | 187 _getRequestFromPoint: function(x, y) |
| 128 { | 188 { |
| 129 var rowHeight = this._networkLogView.rowHeight(); | 189 var rowHeight = this._networkLogView.rowHeight(); |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 color = this._rowHoverColor; | 438 color = this._rowHoverColor; |
| 379 | 439 |
| 380 context.fillStyle = color; | 440 context.fillStyle = color; |
| 381 context.rect(0, y, this._offsetWidth, rowHeight); | 441 context.rect(0, y, this._offsetWidth, rowHeight); |
| 382 context.fill(); | 442 context.fill(); |
| 383 context.restore(); | 443 context.restore(); |
| 384 }, | 444 }, |
| 385 | 445 |
| 386 __proto__: WebInspector.VBox.prototype | 446 __proto__: WebInspector.VBox.prototype |
| 387 } | 447 } |
| OLD | NEW |