| 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 * @param {!WebInspector.NetworkLogView} networkLogView | 7 * @param {!WebInspector.NetworkLogView} networkLogView |
| 8 * @param {!WebInspector.NetworkTransferTimeCalculator} timeCalculator | 8 * @param {!WebInspector.NetworkTransferTimeCalculator} timeCalculator |
| 9 * @param {!WebInspector.NetworkTransferDurationCalculator} durationCalculator | 9 * @param {!WebInspector.NetworkTransferDurationCalculator} durationCalculator |
| 10 * @param {!WebInspector.Setting} networkLogLargeRowsSetting | 10 * @param {!WebInspector.Setting} networkLogLargeRowsSetting |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 this._gridMode = true; | 37 this._gridMode = true; |
| 38 | 38 |
| 39 /** @type {!Array.<!WebInspector.NetworkLogViewColumns.Descriptor>} */ | 39 /** @type {!Array.<!WebInspector.NetworkLogViewColumns.Descriptor>} */ |
| 40 this._columns = []; | 40 this._columns = []; |
| 41 | 41 |
| 42 /** @type {?WebInspector.TimelineGrid} */ | 42 /** @type {?WebInspector.TimelineGrid} */ |
| 43 this._timelineGrid = null; | 43 this._timelineGrid = null; |
| 44 this._timelineHeaderElement = null; | 44 this._timelineHeaderElement = null; |
| 45 this._timelineRequestsAreStale = false; | 45 this._timelineRequestsAreStale = false; |
| 46 this._timelineScrollerWidthIsStale = true; |
| 46 | 47 |
| 47 /** @type {!WebInspector.Linkifier} */ | 48 /** @type {!WebInspector.Linkifier} */ |
| 48 this._popupLinkifier = new WebInspector.Linkifier(); | 49 this._popupLinkifier = new WebInspector.Linkifier(); |
| 49 | 50 |
| 50 /** @type {!Map<string, !WebInspector.NetworkTimeCalculator>} */ | 51 /** @type {!Map<string, !WebInspector.NetworkTimeCalculator>} */ |
| 51 this._calculatorsMap = new Map(); | 52 this._calculatorsMap = new Map(); |
| 52 this._calculatorsMap.set(WebInspector.NetworkLogViewColumns._calculatorTypes
.Time, timeCalculator); | 53 this._calculatorsMap.set(WebInspector.NetworkLogViewColumns._calculatorTypes
.Time, timeCalculator); |
| 53 this._calculatorsMap.set(WebInspector.NetworkLogViewColumns._calculatorTypes
.Duration, durationCalculator); | 54 this._calculatorsMap.set(WebInspector.NetworkLogViewColumns._calculatorTypes
.Duration, durationCalculator); |
| 54 | 55 |
| 55 this._setupDataGrid(); | 56 this._setupDataGrid(); |
| 56 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) | 57 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) |
| 57 this._setupTimeline(); | 58 this._setupTimeline(); |
| 59 }; |
| 58 | 60 |
| 59 this._updateRowsSize(); | |
| 60 }; | |
| 61 WebInspector.NetworkLogViewColumns._initialSortColumn = "timeline"; | 61 WebInspector.NetworkLogViewColumns._initialSortColumn = "timeline"; |
| 62 | 62 |
| 63 /** | 63 /** |
| 64 * @typedef {{ | 64 * @typedef {{ |
| 65 * id: string, | 65 * id: string, |
| 66 * title: string, | 66 * title: string, |
| 67 * titleDOMFragment: (!DocumentFragment|undefined), | 67 * titleDOMFragment: (!DocumentFragment|undefined), |
| 68 * subtitle: (string|null), | 68 * subtitle: (string|null), |
| 69 * visible: boolean, | 69 * visible: boolean, |
| 70 * weight: number, | 70 * weight: number, |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 id: columnConfig.id, | 370 id: columnConfig.id, |
| 371 title: columnConfig.title, | 371 title: columnConfig.title, |
| 372 sortable: columnConfig.sortable, | 372 sortable: columnConfig.sortable, |
| 373 align: columnConfig.align, | 373 align: columnConfig.align, |
| 374 nonSelectable: columnConfig.nonSelectable, | 374 nonSelectable: columnConfig.nonSelectable, |
| 375 weight: columnConfig.weight | 375 weight: columnConfig.weight |
| 376 }); | 376 }); |
| 377 }; | 377 }; |
| 378 | 378 |
| 379 WebInspector.NetworkLogViewColumns.prototype = { | 379 WebInspector.NetworkLogViewColumns.prototype = { |
| 380 wasShown: function() |
| 381 { |
| 382 this._updateRowsSize(); |
| 383 }, |
| 384 |
| 380 willHide: function() | 385 willHide: function() |
| 381 { | 386 { |
| 382 this._popoverHelper.hidePopover(); | 387 this._popoverHelper.hidePopover(); |
| 383 }, | 388 }, |
| 384 | 389 |
| 385 reset: function() | 390 reset: function() |
| 386 { | 391 { |
| 387 if (this._popoverHelper) | 392 if (this._popoverHelper) |
| 388 this._popoverHelper.hidePopover(); | 393 this._popoverHelper.hidePopover(); |
| 389 this._timelineGrid.removeEventDividers(); | 394 this._timelineGrid.removeEventDividers(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 407 | 412 |
| 408 this._popoverHelper = new WebInspector.PopoverHelper(this._networkLogVie
w.element); | 413 this._popoverHelper = new WebInspector.PopoverHelper(this._networkLogVie
w.element); |
| 409 this._popoverHelper.initializeCallbacks(this._getPopoverAnchor.bind(this
), this._showPopover.bind(this), this._onHidePopover.bind(this)); | 414 this._popoverHelper.initializeCallbacks(this._getPopoverAnchor.bind(this
), this._showPopover.bind(this), this._onHidePopover.bind(this)); |
| 410 | 415 |
| 411 this._dataGrid = new WebInspector.SortableDataGrid(this._columns.map(Web
Inspector.NetworkLogViewColumns._convertToDataGridDescriptor)); | 416 this._dataGrid = new WebInspector.SortableDataGrid(this._columns.map(Web
Inspector.NetworkLogViewColumns._convertToDataGridDescriptor)); |
| 412 this._dataGrid.element.addEventListener("mousedown", event => { | 417 this._dataGrid.element.addEventListener("mousedown", event => { |
| 413 if ((!this._dataGrid.selectedNode && event.button) || event.target.e
nclosingNodeOrSelfWithNodeName("a")) | 418 if ((!this._dataGrid.selectedNode && event.button) || event.target.e
nclosingNodeOrSelfWithNodeName("a")) |
| 414 event.consume(); | 419 event.consume(); |
| 415 }, true); | 420 }, true); |
| 416 | 421 |
| 422 this._dataGridScroller = this._dataGrid.scrollContainer; |
| 423 |
| 417 this._updateColumns(); | 424 this._updateColumns(); |
| 418 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChan
ged, this._sortHandler, this); | 425 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChan
ged, this._sortHandler, this); |
| 419 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.ColumnsResi
zed, this.updateDividersIfNeeded, this); | 426 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.ColumnsResi
zed, this.updateDividersIfNeeded, this); |
| 420 this._dataGrid.setHeaderContextMenuCallback(this._innerHeaderContextMenu
.bind(this)); | 427 this._dataGrid.setHeaderContextMenuCallback(this._innerHeaderContextMenu
.bind(this)); |
| 421 | 428 |
| 422 this._timelineGrid = new WebInspector.TimelineGrid(); | 429 this._timelineGrid = new WebInspector.TimelineGrid(); |
| 423 this._timelineGrid.element.classList.add("network-timeline-grid"); | 430 this._timelineGrid.element.classList.add("network-timeline-grid"); |
| 424 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline")) | 431 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline")) |
| 425 this._dataGrid.element.appendChild(this._timelineGrid.element); | 432 this._dataGrid.element.appendChild(this._timelineGrid.element); |
| 426 | 433 |
| 427 this._setupDropdownColumns(); | 434 this._setupDropdownColumns(); |
| 428 | 435 |
| 429 this._dataGrid.markColumnAsSortedBy(WebInspector.NetworkLogViewColumns._
initialSortColumn, WebInspector.DataGrid.Order.Ascending); | 436 this._dataGrid.markColumnAsSortedBy(WebInspector.NetworkLogViewColumns._
initialSortColumn, WebInspector.DataGrid.Order.Ascending); |
| 430 | 437 |
| 431 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) { | 438 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) { |
| 432 this._splitWidget = new WebInspector.SplitWidget(true, false, "netwo
rkPanelSplitViewTimeline"); | 439 this._splitWidget = new WebInspector.SplitWidget(true, false, "netwo
rkPanelSplitViewTimeline"); |
| 433 this._splitWidget.setSidebarWidget(this._dataGrid.asWidget()); | 440 this._splitWidget.setSidebarWidget(this._dataGrid.asWidget()); |
| 434 } | 441 } |
| 435 }, | 442 }, |
| 436 | 443 |
| 437 _setupTimeline: function() | 444 _setupTimeline: function() |
| 438 { | 445 { |
| 439 var dataGridScroller = this._dataGrid.scrollContainer; | 446 this._timelineColumn = new WebInspector.NetworkTimelineColumn(this._netw
orkLogView.rowHeight(), this._networkLogView.calculator()); |
| 440 this._timelineColumn = new WebInspector.NetworkTimelineColumn(this._netw
orkLogView.rowHeight(), this._networkLogView.calculator(), dataGridScroller); | 447 |
| 441 this._dataGrid.setScrollContainer(this._timelineColumn.getScrollContaine
r()); | 448 this._timelineColumn.element.addEventListener("mousewheel", this._onMous
eWheel.bind(this, false), { passive: true }); |
| 442 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.PaddingChan
ged, () => this._timelineColumn.setScrollHeight(dataGridScroller.scrollHeight)); | 449 this._dataGridScroller.addEventListener("mousewheel",this._onMouseWheel.
bind(this, true), true); |
| 450 |
| 451 this._timelineColumn.element.addEventListener("mousemove", event => this
._networkLogView.setHoveredRequest(this._timelineColumn.getRequestFromPoint(even
t.offsetX, event.offsetY + event.target.offsetTop)), true); |
| 452 this._timelineColumn.element.addEventListener("mouseleave", this._networ
kLogView.setHoveredRequest.bind(this._networkLogView, null), true); |
| 453 |
| 454 this._timelineScroller = this._timelineColumn.contentElement.createChild
("div", "network-timeline-v-scroll"); |
| 455 this._timelineScroller.addEventListener("scroll", this._syncScrollers.bi
nd(this), { passive: true }); |
| 456 this._timelineScrollerContent = this._timelineScroller.createChild("div"
, "network-timeline-v-scroll-content"); |
| 457 |
| 458 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.PaddingChan
ged, () => { |
| 459 this._timelineScrollerWidthIsStale = true; |
| 460 this._syncScrollers(); |
| 461 }); |
| 443 this._dataGrid.addEventListener(WebInspector.ViewportDataGrid.Events.Vie
wportCalculated, this._redrawTimelineColumn.bind(this)); | 462 this._dataGrid.addEventListener(WebInspector.ViewportDataGrid.Events.Vie
wportCalculated, this._redrawTimelineColumn.bind(this)); |
| 444 | 463 |
| 445 this._timelineColumn.addEventListener(WebInspector.NetworkTimelineColumn
.Events.RequestHovered, event => this._networkLogView.setHoveredRequest(/** @typ
e {?WebInspector.NetworkRequest} */ (event.data))); | |
| 446 | 464 |
| 447 this._createTimelineHeader(); | 465 this._createTimelineHeader(); |
| 448 this._timelineColumn.contentElement.classList.add("network-timeline-view
"); | 466 this._timelineColumn.contentElement.classList.add("network-timeline-view
"); |
| 449 | 467 |
| 450 this._splitWidget.setMainWidget(this._timelineColumn); | 468 this._splitWidget.setMainWidget(this._timelineColumn); |
| 451 | 469 |
| 452 this.switchViewMode(false); | 470 this.switchViewMode(false); |
| 453 }, | 471 }, |
| 454 | 472 |
| 473 /** |
| 474 * @param {boolean} shouldConsume |
| 475 * @param {!Event} event |
| 476 */ |
| 477 _onMouseWheel: function(shouldConsume, event) |
| 478 { |
| 479 if (shouldConsume) |
| 480 event.consume(true); |
| 481 this._activeScroller.scrollTop -= event.wheelDeltaY; |
| 482 this._syncScrollers(); |
| 483 this._networkLogView.setHoveredRequest(this._timelineColumn.getRequestFr
omPoint(event.offsetX, event.offsetY)); |
| 484 }, |
| 485 |
| 486 _syncScrollers: function() |
| 487 { |
| 488 if (!this._timelineColumn.isShowing()) |
| 489 return; |
| 490 this._timelineScrollerContent.style.height = this._dataGridScroller.scro
llHeight + "px"; |
| 491 this._updateScrollerWidthIfNeeded(); |
| 492 this._dataGridScroller.scrollTop = this._timelineScroller.scrollTop; |
| 493 }, |
| 494 |
| 495 _updateScrollerWidthIfNeeded: function() |
| 496 { |
| 497 if (this._timelineScrollerWidthIsStale) { |
| 498 this._timelineScrollerWidthIsStale = false; |
| 499 this._timelineColumn.setRightPadding(this._timelineScroller.offsetWi
dth - this._timelineScrollerContent.offsetWidth); |
| 500 } |
| 501 }, |
| 502 |
| 455 _redrawTimelineColumn: function() | 503 _redrawTimelineColumn: function() |
| 456 { | 504 { |
| 457 if (!this._timelineRequestsAreStale) { | 505 if (!this._timelineRequestsAreStale) { |
| 458 this._timelineColumn.update(); | 506 this._updateScrollerWidthIfNeeded(); |
| 507 this._timelineColumn.update(this._activeScroller.scrollTop); |
| 459 return; | 508 return; |
| 460 } | 509 } |
| 461 var currentNode = this._dataGrid.rootNode(); | 510 var currentNode = this._dataGrid.rootNode(); |
| 462 var requestData = { | 511 var requestData = { |
| 463 requests: [], | 512 requests: [], |
| 464 navigationRequest: null | 513 navigationRequest: null |
| 465 }; | 514 }; |
| 466 while (currentNode = currentNode.traverseNextNode(true)) { | 515 while (currentNode = currentNode.traverseNextNode(true)) { |
| 467 if (currentNode.isNavigationRequest()) | 516 if (currentNode.isNavigationRequest()) |
| 468 requestData.navigationRequest = currentNode.request(); | 517 requestData.navigationRequest = currentNode.request(); |
| 469 requestData.requests.push(currentNode.request()); | 518 requestData.requests.push(currentNode.request()); |
| 470 } | 519 } |
| 471 this._timelineColumn.update(requestData); | 520 this._timelineColumn.update(this._activeScroller.scrollTop, requestData)
; |
| 472 }, | 521 }, |
| 473 | 522 |
| 474 /** | 523 /** |
| 475 * @param {?WebInspector.NetworkRequest} request | 524 * @param {?WebInspector.NetworkRequest} request |
| 476 */ | 525 */ |
| 477 setHoveredRequest: function(request) | 526 setHoveredRequest: function(request) |
| 478 { | 527 { |
| 479 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) | 528 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) |
| 480 this._timelineColumn.setHoveredRequest(request); | 529 this._timelineColumn.setHoveredRequest(request); |
| 481 }, | 530 }, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 }, | 566 }, |
| 518 | 567 |
| 519 _updateRowsSize: function() | 568 _updateRowsSize: function() |
| 520 { | 569 { |
| 521 var largeRows = !!this._networkLogLargeRowsSetting.get(); | 570 var largeRows = !!this._networkLogLargeRowsSetting.get(); |
| 522 this._dataGrid.element.classList.toggle("small", !largeRows); | 571 this._dataGrid.element.classList.toggle("small", !largeRows); |
| 523 this._dataGrid.scheduleUpdate(); | 572 this._dataGrid.scheduleUpdate(); |
| 524 | 573 |
| 525 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline")) | 574 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline")) |
| 526 return; | 575 return; |
| 576 this._timelineScrollerWidthIsStale = true; |
| 527 this._timelineColumn.setRowHeight(this._networkLogView.rowHeight()); | 577 this._timelineColumn.setRowHeight(this._networkLogView.rowHeight()); |
| 528 // TODO(allada) Make these non-magic numbers. | 578 this._timelineScroller.classList.toggle("small", !largeRows); |
| 529 this._timelineColumn.setHeaderHeight(largeRows ? 31 : 27); | |
| 530 this._timelineHeaderElement.classList.toggle("small", !largeRows); | 579 this._timelineHeaderElement.classList.toggle("small", !largeRows); |
| 531 this._timelineGrid.element.classList.toggle("small", !this._networkLogLa
rgeRowsSetting.get()); | 580 this._timelineGrid.element.classList.toggle("small", !this._networkLogLa
rgeRowsSetting.get()); |
| 581 this._timelineColumn.setHeaderHeight(this._timelineScroller.offsetTop); |
| 532 }, | 582 }, |
| 533 | 583 |
| 534 /** | 584 /** |
| 535 * @param {!Element} element | 585 * @param {!Element} element |
| 536 */ | 586 */ |
| 537 show: function(element) | 587 show: function(element) |
| 538 { | 588 { |
| 539 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) | 589 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) |
| 540 this._splitWidget.show(element); | 590 this._splitWidget.show(element); |
| 541 else | 591 else |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 this._popoverHelper.hidePopover(); | 729 this._popoverHelper.hidePopover(); |
| 680 } | 730 } |
| 681 | 731 |
| 682 this._networkLogView.element.classList.toggle("brief-mode", !gridMode); | 732 this._networkLogView.element.classList.toggle("brief-mode", !gridMode); |
| 683 this._updateColumns(); | 733 this._updateColumns(); |
| 684 | 734 |
| 685 | 735 |
| 686 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline")) | 736 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline")) |
| 687 return; | 737 return; |
| 688 // TODO(allada) Move this code into the code above. | 738 // TODO(allada) Move this code into the code above. |
| 689 if (gridMode) | 739 if (gridMode) { |
| 690 this._splitWidget.showBoth(); | 740 this._splitWidget.showBoth(); |
| 691 else | 741 this._activeScroller = this._timelineScroller; |
| 742 this._timelineScroller.scrollTop = this._dataGridScroller.scrollTop; |
| 743 this._dataGridScroller.style.overflow = "hidden"; |
| 744 this._dataGrid.setScrollContainer(this._timelineScroller); |
| 745 } else { |
| 692 this._splitWidget.hideMain(); | 746 this._splitWidget.hideMain(); |
| 747 this._activeScroller = this._dataGridScroller; |
| 748 this._dataGridScroller.style.overflow = "overlay"; |
| 749 this._dataGrid.setScrollContainer(this._dataGridScroller); |
| 750 } |
| 693 }, | 751 }, |
| 694 | 752 |
| 695 /** | 753 /** |
| 696 * @param {!WebInspector.NetworkLogViewColumns.Descriptor} columnConfig | 754 * @param {!WebInspector.NetworkLogViewColumns.Descriptor} columnConfig |
| 697 */ | 755 */ |
| 698 _toggleColumnVisibility: function(columnConfig) | 756 _toggleColumnVisibility: function(columnConfig) |
| 699 { | 757 { |
| 700 this._loadColumns(); | 758 this._loadColumns(); |
| 701 columnConfig.visible = !columnConfig.visible; | 759 columnConfig.visible = !columnConfig.visible; |
| 702 this._saveColumns(); | 760 this._saveColumns(); |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 for (var divider of this._eventDividers) | 1041 for (var divider of this._eventDividers) |
| 984 divider.element.classList.toggle("network-frame-divider-selected", d
ivider.time === time); | 1042 divider.element.classList.toggle("network-frame-divider-selected", d
ivider.time === time); |
| 985 }, | 1043 }, |
| 986 | 1044 |
| 987 clearFilmStripFrame: function() | 1045 clearFilmStripFrame: function() |
| 988 { | 1046 { |
| 989 for (var divider of this._eventDividers) | 1047 for (var divider of this._eventDividers) |
| 990 divider.element.classList.toggle("network-frame-divider-selected", f
alse); | 1048 divider.element.classList.toggle("network-frame-divider-selected", f
alse); |
| 991 } | 1049 } |
| 992 }; | 1050 }; |
| OLD | NEW |