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 * @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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 407 | 407 |
| 408 this._popoverHelper = new WebInspector.PopoverHelper(this._networkLogVie w.element); | 408 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)); | 409 this._popoverHelper.initializeCallbacks(this._getPopoverAnchor.bind(this ), this._showPopover.bind(this), this._onHidePopover.bind(this)); |
| 410 | 410 |
| 411 this._dataGrid = new WebInspector.SortableDataGrid(this._columns.map(Web Inspector.NetworkLogViewColumns._convertToDataGridDescriptor)); | 411 this._dataGrid = new WebInspector.SortableDataGrid(this._columns.map(Web Inspector.NetworkLogViewColumns._convertToDataGridDescriptor)); |
| 412 this._dataGrid.element.addEventListener("mousedown", event => { | 412 this._dataGrid.element.addEventListener("mousedown", event => { |
| 413 if ((!this._dataGrid.selectedNode && event.button) || event.target.e nclosingNodeOrSelfWithNodeName("a")) | 413 if ((!this._dataGrid.selectedNode && event.button) || event.target.e nclosingNodeOrSelfWithNodeName("a")) |
| 414 event.consume(); | 414 event.consume(); |
| 415 }, true); | 415 }, true); |
| 416 | 416 |
| 417 this._dataGridScroller = this._dataGrid.scrollContainer; | |
| 418 | |
| 417 this._updateColumns(); | 419 this._updateColumns(); |
| 418 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChan ged, this._sortHandler, this); | 420 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChan ged, this._sortHandler, this); |
| 419 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.ColumnsResi zed, this.updateDividersIfNeeded, this); | 421 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.ColumnsResi zed, this.updateDividersIfNeeded, this); |
| 420 this._dataGrid.setHeaderContextMenuCallback(this._innerHeaderContextMenu .bind(this)); | 422 this._dataGrid.setHeaderContextMenuCallback(this._innerHeaderContextMenu .bind(this)); |
| 421 | 423 |
| 422 this._timelineGrid = new WebInspector.TimelineGrid(); | 424 this._timelineGrid = new WebInspector.TimelineGrid(); |
| 423 this._timelineGrid.element.classList.add("network-timeline-grid"); | 425 this._timelineGrid.element.classList.add("network-timeline-grid"); |
| 424 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline")) | 426 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline")) |
| 425 this._dataGrid.element.appendChild(this._timelineGrid.element); | 427 this._dataGrid.element.appendChild(this._timelineGrid.element); |
| 426 | 428 |
| 427 this._setupDropdownColumns(); | 429 this._setupDropdownColumns(); |
| 428 | 430 |
| 429 this._dataGrid.markColumnAsSortedBy(WebInspector.NetworkLogViewColumns._ initialSortColumn, WebInspector.DataGrid.Order.Ascending); | 431 this._dataGrid.markColumnAsSortedBy(WebInspector.NetworkLogViewColumns._ initialSortColumn, WebInspector.DataGrid.Order.Ascending); |
| 430 | 432 |
| 431 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) { | 433 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) { |
| 432 this._splitWidget = new WebInspector.SplitWidget(true, false, "netwo rkPanelSplitViewTimeline"); | 434 this._splitWidget = new WebInspector.SplitWidget(true, false, "netwo rkPanelSplitViewTimeline"); |
| 433 this._splitWidget.setSidebarWidget(this._dataGrid.asWidget()); | 435 this._splitWidget.setSidebarWidget(this._dataGrid.asWidget()); |
| 434 } | 436 } |
| 435 }, | 437 }, |
| 436 | 438 |
| 437 _setupTimeline: function() | 439 _setupTimeline: function() |
| 438 { | 440 { |
| 439 var dataGridScroller = this._dataGrid.scrollContainer; | 441 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); | 442 |
| 441 this._dataGrid.setScrollContainer(this._timelineColumn.getScrollContaine r()); | 443 this._timelineColumn.element.addEventListener("mousewheel", this._onMous eWheel.bind(this), { passive: true }); |
| 442 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.PaddingChan ged, () => this._timelineColumn.setScrollHeight(dataGridScroller.scrollHeight)); | 444 this._dataGridScroller.addEventListener("mousewheel", event => { |
|
dgozman
2016/10/27 20:11:42
Just this._onMouseWheel.bind(this), and consume in
allada
2016/10/27 21:21:56
Done.
| |
| 445 event.consume(true); | |
| 446 this._onMouseWheel(event); | |
| 447 }, true); | |
| 448 | |
| 449 this._timelineColumn.element.addEventListener("mousemove", event => this ._networkLogView.setHoveredRequest(this._timelineColumn.getRequestFromPoint(even t.offsetX, event.offsetY + event.target.offsetTop)), true); | |
| 450 this._timelineColumn.element.addEventListener("mouseleave", this._networ kLogView.setHoveredRequest.bind(this._networkLogView, null), true); | |
| 451 | |
| 452 this._timelineScroller = this._timelineColumn.contentElement.createChild ("div", "network-timeline-v-scroll"); | |
| 453 this._timelineScroller.addEventListener("scroll", this._syncScrollers.bi nd(this), { passive: true }); | |
| 454 this._timelineScrollerContent = this._timelineScroller.createChild("div" , "network-timeline-v-scroll-content"); | |
| 455 | |
| 456 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.PaddingChan ged, this._syncScrollers.bind(this)); | |
| 443 this._dataGrid.addEventListener(WebInspector.ViewportDataGrid.Events.Vie wportCalculated, this._redrawTimelineColumn.bind(this)); | 457 this._dataGrid.addEventListener(WebInspector.ViewportDataGrid.Events.Vie wportCalculated, this._redrawTimelineColumn.bind(this)); |
| 444 | 458 |
| 445 this._timelineColumn.addEventListener(WebInspector.NetworkTimelineColumn .Events.RequestHovered, event => this._networkLogView.setHoveredRequest(/** @typ e {?WebInspector.NetworkRequest} */ (event.data))); | |
| 446 | 459 |
| 447 this._createTimelineHeader(); | 460 this._createTimelineHeader(); |
| 448 this._timelineColumn.contentElement.classList.add("network-timeline-view "); | 461 this._timelineColumn.contentElement.classList.add("network-timeline-view "); |
| 449 | 462 |
| 450 this._splitWidget.setMainWidget(this._timelineColumn); | 463 this._splitWidget.setMainWidget(this._timelineColumn); |
| 451 | 464 |
| 452 this.switchViewMode(false); | 465 this.switchViewMode(false); |
| 453 }, | 466 }, |
| 454 | 467 |
| 468 /** | |
| 469 * @param {!Event} event | |
| 470 */ | |
| 471 _onMouseWheel: function(event) | |
| 472 { | |
| 473 this._activeScroller.scrollTop -= event.wheelDeltaY; | |
| 474 this._syncScrollers(); | |
| 475 this._networkLogView.setHoveredRequest(this._timelineColumn.getRequestFr omPoint(event.offsetX, event.offsetY)); | |
| 476 }, | |
| 477 | |
| 478 _syncScrollers: function() | |
| 479 { | |
| 480 if (!this._timelineColumn.isShowing()) | |
| 481 return; | |
| 482 this._timelineScrollerContent.style.height = this._dataGridScroller.scro llHeight + "px"; | |
| 483 this._timelineColumn.setRightPadding(this._timelineScroller.offsetWidth - this._timelineScrollerContent.offsetWidth); | |
|
dgozman
2016/10/27 20:11:42
This forces sync layout. We should cached the widt
allada
2016/10/27 21:21:56
Done.
| |
| 484 this._dataGridScroller.scrollTop = this._timelineScroller.scrollTop; | |
| 485 }, | |
| 486 | |
| 455 _redrawTimelineColumn: function() | 487 _redrawTimelineColumn: function() |
| 456 { | 488 { |
| 457 if (!this._timelineRequestsAreStale) { | 489 if (!this._timelineRequestsAreStale) { |
| 458 this._timelineColumn.update(); | 490 this._timelineColumn.update(this._activeScroller.scrollTop); |
| 459 return; | 491 return; |
| 460 } | 492 } |
| 461 var currentNode = this._dataGrid.rootNode(); | 493 var currentNode = this._dataGrid.rootNode(); |
| 462 var requestData = { | 494 var requestData = { |
| 463 requests: [], | 495 requests: [], |
| 464 navigationRequest: null | 496 navigationRequest: null |
| 465 }; | 497 }; |
| 466 while (currentNode = currentNode.traverseNextNode(true)) { | 498 while (currentNode = currentNode.traverseNextNode(true)) { |
| 467 if (currentNode.isNavigationRequest()) | 499 if (currentNode.isNavigationRequest()) |
| 468 requestData.navigationRequest = currentNode.request(); | 500 requestData.navigationRequest = currentNode.request(); |
| 469 requestData.requests.push(currentNode.request()); | 501 requestData.requests.push(currentNode.request()); |
| 470 } | 502 } |
| 471 this._timelineColumn.update(requestData); | 503 this._timelineColumn.update(this._activeScroller.scrollTop, requestData) ; |
| 472 }, | 504 }, |
| 473 | 505 |
| 474 /** | 506 /** |
| 475 * @param {?WebInspector.NetworkRequest} request | 507 * @param {?WebInspector.NetworkRequest} request |
| 476 */ | 508 */ |
| 477 setHoveredRequest: function(request) | 509 setHoveredRequest: function(request) |
| 478 { | 510 { |
| 479 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) | 511 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) |
| 480 this._timelineColumn.setHoveredRequest(request); | 512 this._timelineColumn.setHoveredRequest(request); |
| 481 }, | 513 }, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 518 | 550 |
| 519 _updateRowsSize: function() | 551 _updateRowsSize: function() |
| 520 { | 552 { |
| 521 var largeRows = !!this._networkLogLargeRowsSetting.get(); | 553 var largeRows = !!this._networkLogLargeRowsSetting.get(); |
| 522 this._dataGrid.element.classList.toggle("small", !largeRows); | 554 this._dataGrid.element.classList.toggle("small", !largeRows); |
| 523 this._dataGrid.scheduleUpdate(); | 555 this._dataGrid.scheduleUpdate(); |
| 524 | 556 |
| 525 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline")) | 557 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline")) |
| 526 return; | 558 return; |
| 527 this._timelineColumn.setRowHeight(this._networkLogView.rowHeight()); | 559 this._timelineColumn.setRowHeight(this._networkLogView.rowHeight()); |
| 528 // TODO(allada) Make these non-magic numbers. | 560 var rowHeight = largeRows ? 31 : 27; |
| 529 this._timelineColumn.setHeaderHeight(largeRows ? 31 : 27); | 561 this._timelineColumn.setHeaderHeight(rowHeight); |
| 562 this._timelineScroller.style.marginTop = rowHeight + "px"; | |
|
dgozman
2016/10/27 20:11:42
Let's do this with css.
allada
2016/10/27 21:21:56
Done.
| |
| 530 this._timelineHeaderElement.classList.toggle("small", !largeRows); | 563 this._timelineHeaderElement.classList.toggle("small", !largeRows); |
| 531 this._timelineGrid.element.classList.toggle("small", !this._networkLogLa rgeRowsSetting.get()); | 564 this._timelineGrid.element.classList.toggle("small", !this._networkLogLa rgeRowsSetting.get()); |
| 532 }, | 565 }, |
| 533 | 566 |
| 534 /** | 567 /** |
| 535 * @param {!Element} element | 568 * @param {!Element} element |
| 536 */ | 569 */ |
| 537 show: function(element) | 570 show: function(element) |
| 538 { | 571 { |
| 539 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) | 572 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 679 this._popoverHelper.hidePopover(); | 712 this._popoverHelper.hidePopover(); |
| 680 } | 713 } |
| 681 | 714 |
| 682 this._networkLogView.element.classList.toggle("brief-mode", !gridMode); | 715 this._networkLogView.element.classList.toggle("brief-mode", !gridMode); |
| 683 this._updateColumns(); | 716 this._updateColumns(); |
| 684 | 717 |
| 685 | 718 |
| 686 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline")) | 719 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline")) |
| 687 return; | 720 return; |
| 688 // TODO(allada) Move this code into the code above. | 721 // TODO(allada) Move this code into the code above. |
| 689 if (gridMode) | 722 if (gridMode) { |
| 690 this._splitWidget.showBoth(); | 723 this._splitWidget.showBoth(); |
| 691 else | 724 this._activeScroller = this._timelineScroller; |
| 725 this._timelineScroller.scrollTop = this._dataGridScroller.scrollTop; | |
| 726 this._dataGridScroller.style.overflow = "hidden"; | |
| 727 this._dataGrid.setScrollContainer(this._timelineScroller); | |
| 728 } else { | |
| 692 this._splitWidget.hideMain(); | 729 this._splitWidget.hideMain(); |
| 730 this._activeScroller = this._dataGridScroller; | |
| 731 this._dataGridScroller.style.overflow = "overlay"; | |
| 732 this._dataGrid.setScrollContainer(this._dataGridScroller); | |
| 733 } | |
| 693 }, | 734 }, |
| 694 | 735 |
| 695 /** | 736 /** |
| 696 * @param {!WebInspector.NetworkLogViewColumns.Descriptor} columnConfig | 737 * @param {!WebInspector.NetworkLogViewColumns.Descriptor} columnConfig |
| 697 */ | 738 */ |
| 698 _toggleColumnVisibility: function(columnConfig) | 739 _toggleColumnVisibility: function(columnConfig) |
| 699 { | 740 { |
| 700 this._loadColumns(); | 741 this._loadColumns(); |
| 701 columnConfig.visible = !columnConfig.visible; | 742 columnConfig.visible = !columnConfig.visible; |
| 702 this._saveColumns(); | 743 this._saveColumns(); |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 983 for (var divider of this._eventDividers) | 1024 for (var divider of this._eventDividers) |
| 984 divider.element.classList.toggle("network-frame-divider-selected", d ivider.time === time); | 1025 divider.element.classList.toggle("network-frame-divider-selected", d ivider.time === time); |
| 985 }, | 1026 }, |
| 986 | 1027 |
| 987 clearFilmStripFrame: function() | 1028 clearFilmStripFrame: function() |
| 988 { | 1029 { |
| 989 for (var divider of this._eventDividers) | 1030 for (var divider of this._eventDividers) |
| 990 divider.element.classList.toggle("network-frame-divider-selected", f alse); | 1031 divider.element.classList.toggle("network-frame-divider-selected", f alse); |
| 991 } | 1032 } |
| 992 }; | 1033 }; |
| OLD | NEW |