| 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 Network.NetworkWaterfallColumn = class extends UI.VBox { | 4 Network.NetworkWaterfallColumn = class extends UI.VBox { |
| 5 /** | 5 /** |
| 6 * @param {number} rowHeight | 6 * @param {number} rowHeight |
| 7 * @param {!Network.NetworkTimeCalculator} calculator | 7 * @param {!Network.NetworkTimeCalculator} calculator |
| 8 */ | 8 */ |
| 9 constructor(rowHeight, calculator) { | 9 constructor(rowHeight, calculator) { |
| 10 // TODO(allada) Make this a shadowDOM when the NetworkWaterfallColumn gets m
oved into NetworkLogViewColumns. | 10 // TODO(allada) Make this a shadowDOM when the NetworkWaterfallColumn gets m
oved into NetworkLogViewColumns. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 this._rowHeight = rowHeight; | 27 this._rowHeight = rowHeight; |
| 28 this._headerHeight = 0; | 28 this._headerHeight = 0; |
| 29 this._calculator = calculator; | 29 this._calculator = calculator; |
| 30 | 30 |
| 31 this._offsetWidth = 0; | 31 this._offsetWidth = 0; |
| 32 this._offsetHeight = 0; | 32 this._offsetHeight = 0; |
| 33 this._startTime = this._calculator.minimumBoundary(); | 33 this._startTime = this._calculator.minimumBoundary(); |
| 34 this._endTime = this._calculator.maximumBoundary(); | 34 this._endTime = this._calculator.maximumBoundary(); |
| 35 | 35 |
| 36 this._popoverHelper = new UI.PopoverHelper(this.element); | 36 this._popoverHelper = new UI.PopoverHelper(this.element, this._getPopoverReq
uest.bind(this)); |
| 37 this._popoverHelper.initializeCallbacks(this._getPopoverAnchor.bind(this), t
his._showPopover.bind(this)); | |
| 38 this._popoverHelper.setHasPadding(true); | 37 this._popoverHelper.setHasPadding(true); |
| 39 this._popoverHelper.setTimeout(300, 300); | 38 this._popoverHelper.setTimeout(300, 300); |
| 40 | 39 |
| 41 /** @type {!Array<!Network.NetworkNode>} */ | 40 /** @type {!Array<!Network.NetworkNode>} */ |
| 42 this._nodes = []; | 41 this._nodes = []; |
| 43 | 42 |
| 44 /** @type {?Network.NetworkNode} */ | 43 /** @type {?Network.NetworkNode} */ |
| 45 this._hoveredNode = null; | 44 this._hoveredNode = null; |
| 46 | 45 |
| 47 /** @type {!Map<string, !Array<number>>} */ | 46 /** @type {!Map<string, !Array<number>>} */ |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 } | 179 } |
| 181 | 180 |
| 182 /** | 181 /** |
| 183 * @param {!Event} event | 182 * @param {!Event} event |
| 184 */ | 183 */ |
| 185 _onMouseMove(event) { | 184 _onMouseMove(event) { |
| 186 this._setHoveredNode(this.getNodeFromPoint(event.offsetX, event.offsetY), ev
ent.shiftKey); | 185 this._setHoveredNode(this.getNodeFromPoint(event.offsetX, event.offsetY), ev
ent.shiftKey); |
| 187 } | 186 } |
| 188 | 187 |
| 189 /** | 188 /** |
| 190 * @param {!Element} element | |
| 191 * @param {!Event} event | 189 * @param {!Event} event |
| 192 * @return {!AnchorBox|undefined} | 190 * @return {?UI.PopoverRequest} |
| 193 */ | 191 */ |
| 194 _getPopoverAnchor(element, event) { | 192 _getPopoverRequest(event) { |
| 195 if (!this._hoveredNode) | 193 if (!this._hoveredNode) |
| 196 return; | 194 return null; |
| 197 var request = this._hoveredNode.request(); | 195 var request = this._hoveredNode.request(); |
| 198 if (!request) | 196 if (!request) |
| 199 return; | 197 return null; |
| 200 var useTimingBars = !Common.moduleSetting('networkColorCodeResourceTypes').g
et() && !this._calculator.startAtZero; | 198 var useTimingBars = !Common.moduleSetting('networkColorCodeResourceTypes').g
et() && !this._calculator.startAtZero; |
| 201 if (useTimingBars) { | 199 if (useTimingBars) { |
| 202 var range = Network.RequestTimingView.calculateRequestTimeRanges(request,
0) | 200 var range = Network.RequestTimingView.calculateRequestTimeRanges(request,
0) |
| 203 .find(data => data.name === Network.RequestTimeRangeNames.
Total); | 201 .find(data => data.name === Network.RequestTimeRangeNames.
Total); |
| 204 var start = this._timeToPosition(range.start); | 202 var start = this._timeToPosition(range.start); |
| 205 var end = this._timeToPosition(range.end); | 203 var end = this._timeToPosition(range.end); |
| 206 } else { | 204 } else { |
| 207 var range = this._getSimplifiedBarRange(request, 0); | 205 var range = this._getSimplifiedBarRange(request, 0); |
| 208 var start = range.start; | 206 var start = range.start; |
| 209 var end = range.end; | 207 var end = range.end; |
| 210 } | 208 } |
| 211 | 209 |
| 212 if (end - start < 50) { | 210 if (end - start < 50) { |
| 213 var halfWidth = (end - start) / 2; | 211 var halfWidth = (end - start) / 2; |
| 214 start = start + halfWidth - 25; | 212 start = start + halfWidth - 25; |
| 215 end = end - halfWidth + 25; | 213 end = end - halfWidth + 25; |
| 216 } | 214 } |
| 217 | 215 |
| 218 if (event.clientX < this._canvasPosition.left + start || event.clientX > thi
s._canvasPosition.left + end) | 216 if (event.clientX < this._canvasPosition.left + start || event.clientX > thi
s._canvasPosition.left + end) |
| 219 return; | 217 return null; |
| 220 | 218 |
| 221 var rowIndex = this._nodes.findIndex(node => node.hovered()); | 219 var rowIndex = this._nodes.findIndex(node => node.hovered()); |
| 222 var barHeight = this._getBarHeight(range.name); | 220 var barHeight = this._getBarHeight(range.name); |
| 223 var y = this._headerHeight + (this._rowHeight * rowIndex - this._scrollTop)
+ ((this._rowHeight - barHeight) / 2); | 221 var y = this._headerHeight + (this._rowHeight * rowIndex - this._scrollTop)
+ ((this._rowHeight - barHeight) / 2); |
| 224 | 222 |
| 225 if (event.clientY < this._canvasPosition.top + y || event.clientY > this._ca
nvasPosition.top + y + barHeight) | 223 if (event.clientY < this._canvasPosition.top + y || event.clientY > this._ca
nvasPosition.top + y + barHeight) |
| 226 return; | 224 return null; |
| 227 | 225 |
| 228 var anchorBox = this.element.boxInWindow(); | 226 var anchorBox = this.element.boxInWindow(); |
| 229 anchorBox.x += start; | 227 anchorBox.x += start; |
| 230 anchorBox.y += y; | 228 anchorBox.y += y; |
| 231 anchorBox.width = end - start; | 229 anchorBox.width = end - start; |
| 232 anchorBox.height = barHeight; | 230 anchorBox.height = barHeight; |
| 233 return anchorBox; | 231 |
| 232 return { |
| 233 box: anchorBox, |
| 234 show: popover => { |
| 235 var content = |
| 236 Network.RequestTimingView.createTimingTable(/** @type {!SDK.NetworkR
equest} */ (request), this._calculator); |
| 237 popover.contentElement.appendChild(content); |
| 238 return Promise.resolve(true); |
| 239 } |
| 240 }; |
| 234 } | 241 } |
| 235 | 242 |
| 236 /** | 243 /** |
| 237 * @param {!Element|!AnchorBox} anchor | |
| 238 * @param {!UI.GlassPane} popover | |
| 239 * @return {!Promise<boolean>} | |
| 240 */ | |
| 241 _showPopover(anchor, popover) { | |
| 242 if (!this._hoveredNode) | |
| 243 return Promise.resolve(false); | |
| 244 var request = this._hoveredNode.request(); | |
| 245 if (!request) | |
| 246 return Promise.resolve(false); | |
| 247 var content = Network.RequestTimingView.createTimingTable(request, this._cal
culator); | |
| 248 popover.contentElement.appendChild(content); | |
| 249 return Promise.resolve(true); | |
| 250 } | |
| 251 | |
| 252 /** | |
| 253 * @param {?Network.NetworkNode} node | 244 * @param {?Network.NetworkNode} node |
| 254 * @param {boolean} highlightInitiatorChain | 245 * @param {boolean} highlightInitiatorChain |
| 255 */ | 246 */ |
| 256 _setHoveredNode(node, highlightInitiatorChain) { | 247 _setHoveredNode(node, highlightInitiatorChain) { |
| 257 if (this._hoveredNode) | 248 if (this._hoveredNode) |
| 258 this._hoveredNode.setHovered(false, false); | 249 this._hoveredNode.setHovered(false, false); |
| 259 this._hoveredNode = node; | 250 this._hoveredNode = node; |
| 260 if (this._hoveredNode) | 251 if (this._hoveredNode) |
| 261 this._hoveredNode.setHovered(true, highlightInitiatorChain); | 252 this._hoveredNode.setHovered(true, highlightInitiatorChain); |
| 262 } | 253 } |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 return this._rowStripeColor; | 626 return this._rowStripeColor; |
| 636 } | 627 } |
| 637 } | 628 } |
| 638 }; | 629 }; |
| 639 | 630 |
| 640 /** @typedef {!{fillStyle: (string|undefined), lineWidth: (number|undefined), bo
rderColor: (string|undefined)}} */ | 631 /** @typedef {!{fillStyle: (string|undefined), lineWidth: (number|undefined), bo
rderColor: (string|undefined)}} */ |
| 641 Network.NetworkWaterfallColumn._LayerStyle; | 632 Network.NetworkWaterfallColumn._LayerStyle; |
| 642 | 633 |
| 643 /** @typedef {!{x: number, y: number, text: string}} */ | 634 /** @typedef {!{x: number, y: number, text: string}} */ |
| 644 Network.NetworkWaterfallColumn._TextLayer; | 635 Network.NetworkWaterfallColumn._TextLayer; |
| OLD | NEW |