Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/network/NetworkLogViewColumns.js

Issue 2454893004: [Devtools] Added contextmenu item to allow different timeline styles for exp (Closed)
Patch Set: Merge branch 'TIMELINE_DIVIDERS' into TIMELINE_TIMING_BARS Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/network/NetworkDataGridNode.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 */ 11 */
12 WebInspector.NetworkLogViewColumns = function(networkLogView, timeCalculator, du rationCalculator, networkLogLargeRowsSetting) 12 WebInspector.NetworkLogViewColumns = function(networkLogView, timeCalculator, du rationCalculator, networkLogLargeRowsSetting)
13 { 13 {
14 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) { 14 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) {
15 var timelineColumn = WebInspector.NetworkLogViewColumns._defaultColumns. find(columnConfig => columnConfig.id === "timeline"); 15 var timelineColumn = WebInspector.NetworkLogViewColumns._defaultColumns. find(columnConfig => columnConfig.id === "timeline");
16 timelineColumn.visible = false; 16 timelineColumn.visible = false;
17 timelineColumn.hideable = true; 17 timelineColumn.hideable = false;
18 timelineColumn.sortConfig = {
19 sortingFunction: WebInspector.NetworkDataGridNode.RequestPropertyCom parator.bind(null, "startTime")
20 };
21 } 18 }
22 19
23 this._networkLogView = networkLogView; 20 this._networkLogView = networkLogView;
24 21
25 /** @type {!WebInspector.Setting} */ 22 /** @type {!WebInspector.Setting} */
26 this._persistantSettings = WebInspector.settings.createSetting("networkLogCo lumns", {}); 23 this._persistantSettings = WebInspector.settings.createSetting("networkLogCo lumns", {});
27 24
28 /** @type {!Array<!Element>} */ 25 /** @type {!Array<!Element>} */
29 this._dropDownColumnSelectors = []; 26 this._dropDownColumnSelectors = [];
30 27
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 calculator: WebInspector.NetworkLogViewColumns._calculatorTy pes.Duration 357 calculator: WebInspector.NetworkLogViewColumns._calculatorTy pes.Duration
361 } 358 }
362 ] 359 ]
363 } 360 }
364 } 361 }
365 ]; 362 ];
366 363
367 WebInspector.NetworkLogViewColumns._filmStripDividerColor = "#fccc49"; 364 WebInspector.NetworkLogViewColumns._filmStripDividerColor = "#fccc49";
368 365
369 /** 366 /**
367 * @enum {string}
368 */
369 WebInspector.NetworkLogViewColumns.TimelineSortIds = {
370 StartTime: "startTime",
371 ResponseTime: "responseReceivedTime",
372 EndTime: "endTime",
373 Duration: "duration",
374 Latency: "latency"
375 };
376
377 /**
370 * @param {!WebInspector.NetworkLogViewColumns.Descriptor} columnConfig 378 * @param {!WebInspector.NetworkLogViewColumns.Descriptor} columnConfig
371 * @return {!WebInspector.DataGrid.ColumnDescriptor} 379 * @return {!WebInspector.DataGrid.ColumnDescriptor}
372 */ 380 */
373 WebInspector.NetworkLogViewColumns._convertToDataGridDescriptor = function(colum nConfig) 381 WebInspector.NetworkLogViewColumns._convertToDataGridDescriptor = function(colum nConfig)
374 { 382 {
375 return /** @type {!WebInspector.DataGrid.ColumnDescriptor} */ ({ 383 return /** @type {!WebInspector.DataGrid.ColumnDescriptor} */ ({
376 id: columnConfig.id, 384 id: columnConfig.id,
377 title: columnConfig.title, 385 title: columnConfig.title,
378 sortable: columnConfig.sortable, 386 sortable: columnConfig.sortable,
379 align: columnConfig.align, 387 align: columnConfig.align,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.ColumnsResi zed, this.updateDividersIfNeeded, this); 441 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.ColumnsResi zed, this.updateDividersIfNeeded, this);
434 this._dataGrid.setHeaderContextMenuCallback(this._innerHeaderContextMenu .bind(this)); 442 this._dataGrid.setHeaderContextMenuCallback(this._innerHeaderContextMenu .bind(this));
435 443
436 this._timelineGrid = new WebInspector.TimelineGrid(); 444 this._timelineGrid = new WebInspector.TimelineGrid();
437 this._timelineGrid.element.classList.add("network-timeline-grid"); 445 this._timelineGrid.element.classList.add("network-timeline-grid");
438 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline")) 446 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline"))
439 this._dataGrid.element.appendChild(this._timelineGrid.element); 447 this._dataGrid.element.appendChild(this._timelineGrid.element);
440 448
441 this._setupDropdownColumns(); 449 this._setupDropdownColumns();
442 450
451 this._activeTimelineSortId = WebInspector.NetworkLogViewColumns.Timeline SortIds.StartTime;
443 this._dataGrid.markColumnAsSortedBy(WebInspector.NetworkLogViewColumns._ initialSortColumn, WebInspector.DataGrid.Order.Ascending); 452 this._dataGrid.markColumnAsSortedBy(WebInspector.NetworkLogViewColumns._ initialSortColumn, WebInspector.DataGrid.Order.Ascending);
444 453
445 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) { 454 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) {
446 this._splitWidget = new WebInspector.SplitWidget(true, false, "netwo rkPanelSplitViewTimeline"); 455 this._splitWidget = new WebInspector.SplitWidget(true, false, "netwo rkPanelSplitViewTimeline");
447 this._splitWidget.setSidebarWidget(this._dataGrid.asWidget()); 456 this._splitWidget.setSidebarWidget(this._dataGrid.asWidget());
448 } 457 }
449 }, 458 },
450 459
451 _setupTimeline: function() 460 _setupTimeline: function()
452 { 461 {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 }, 640 },
632 641
633 sortByCurrentColumn: function() 642 sortByCurrentColumn: function()
634 { 643 {
635 this._sortHandler(); 644 this._sortHandler();
636 }, 645 },
637 646
638 _sortHandler: function() 647 _sortHandler: function()
639 { 648 {
640 var columnId = this._dataGrid.sortColumnId(); 649 var columnId = this._dataGrid.sortColumnId();
650 this._networkLogView.removeAllNodeHighlights();
651 if (Runtime.experiments.isEnabled("canvasNetworkTimeline") && columnId = == "timeline") {
652 this._timelineColumnSortIcon.classList.remove("sort-ascending", "sor t-descending");
653
654 if (this._dataGrid.sortOrder() === WebInspector.DataGrid.Order.Ascen ding)
655 this._timelineColumnSortIcon.classList.add("sort-ascending");
656 else
657 this._timelineColumnSortIcon.classList.add("sort-descending");
658
659 this._timelineRequestsAreStale = true;
660 var sortFunction = WebInspector.NetworkDataGridNode.RequestPropertyC omparator.bind(null, this._activeTimelineSortId);
661 this._dataGrid.sortNodes(sortFunction, !this._dataGrid.isSortOrderAs cending());
662 return;
663 }
664
641 var columnConfig = this._columns.find(columnConfig => columnConfig.id == = columnId); 665 var columnConfig = this._columns.find(columnConfig => columnConfig.id == = columnId);
642 if (!columnConfig) 666 if (!columnConfig)
643 return; 667 return;
644 if (columnConfig.sortConfig && columnConfig.sortConfig.entries) { 668 if (columnConfig.sortConfig && columnConfig.sortConfig.entries) {
645 this._sortByDropdownItem(columnConfig); 669 this._sortByDropdownItem(columnConfig);
646 return; 670 return;
647 } 671 }
648 if (!columnConfig.sortConfig.sortingFunction) 672 if (!columnConfig.sortConfig.sortingFunction)
649 return; 673 return;
650 674
651 this._networkLogView.removeAllNodeHighlights();
652 this._dataGrid.sortNodes(columnConfig.sortConfig.sortingFunction, !this. _dataGrid.isSortOrderAscending()); 675 this._dataGrid.sortNodes(columnConfig.sortConfig.sortingFunction, !this. _dataGrid.isSortOrderAscending());
653 this._networkLogView.dataGridSorted(); 676 this._networkLogView.dataGridSorted();
654
655 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline"))
656 return;
657
658 this._timelineColumnSortIcon.classList.remove("sort-ascending", "sort-de scending");
659
660 if (this._dataGrid.sortColumnId() === "timeline") {
661 if (this._dataGrid.sortOrder() === WebInspector.DataGrid.Order.Ascen ding)
662 this._timelineColumnSortIcon.classList.add("sort-ascending");
663 else
664 this._timelineColumnSortIcon.classList.add("sort-descending");
665 }
666
667 this._timelineRequestsAreStale = true;
668
669 }, 677 },
670 678
671 /** 679 /**
672 * @param {!WebInspector.NetworkLogViewColumns.Descriptor} columnConfig 680 * @param {!WebInspector.NetworkLogViewColumns.Descriptor} columnConfig
673 */ 681 */
674 _sortByDropdownItem: function(columnConfig) 682 _sortByDropdownItem: function(columnConfig)
675 { 683 {
676 this._networkLogView.removeAllNodeHighlights(); 684 this._networkLogView.removeAllNodeHighlights();
677 var selectedIndex = columnConfig.selectBox.selectedIndex; 685 var selectedIndex = columnConfig.selectBox.selectedIndex;
678 if (!selectedIndex) 686 if (!selectedIndex)
679 selectedIndex = 1; // Sort by first item by default. 687 selectedIndex = 1; // Sort by first item by default.
680 var selectedItemConfig = columnConfig.sortConfig.entries[selectedIndex - 1]; // -1 because of placeholder. 688 var selectedItemConfig = columnConfig.sortConfig.entries[selectedIndex - 1]; // -1 because of placeholder.
681 var selectedOption = columnConfig.selectBox[selectedIndex]; 689 var selectedOption = columnConfig.selectBox[selectedIndex];
682 var value = selectedOption.value; 690 var value = selectedOption.value;
683 691
684 this._dataGrid.sortNodes(selectedItemConfig.sortingFunction); 692 this._dataGrid.sortNodes(selectedItemConfig.sortingFunction);
685 this._dataGrid.markColumnAsSortedBy(columnConfig.id, /** @type {!WebInsp ector.DataGrid.Order} */ (selectedItemConfig.sort)); 693 this._dataGrid.markColumnAsSortedBy(columnConfig.id, /** @type {!WebInsp ector.DataGrid.Order} */ (selectedItemConfig.sort));
686 if (selectedItemConfig.calculator) 694 if (selectedItemConfig.calculator)
687 this._networkLogView.setCalculator(this._calculatorsMap.get(selected ItemConfig.calculator)); 695 this._networkLogView.setCalculator(this._calculatorsMap.get(selected ItemConfig.calculator));
688 columnConfig.selectBox.options[0].label = selectedItemConfig.title; 696 columnConfig.selectBox.options[0].label = selectedItemConfig.title;
689 columnConfig.selectBox.selectedIndex = 0; 697 columnConfig.selectBox.selectedIndex = 0;
690 this._networkLogView.dataGridSorted(); 698 this._networkLogView.dataGridSorted();
691
692 // TODO(allada) This entire function will be removed when the timeline c omes out of exp, so copying code above for now.
693 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline"))
694 return;
695
696 this._timelineColumnSortIcon.classList.remove("sort-ascending", "sort-de scending");
697
698 if (this._dataGrid.sortColumnId() === "timeline") {
699 if (this._dataGrid.sortOrder() === WebInspector.DataGrid.Order.Ascen ding)
700 this._timelineColumnSortIcon.classList.add("sort-ascending");
701 else
702 this._timelineColumnSortIcon.classList.add("sort-descending");
703 }
704
705 this._timelineRequestsAreStale = true;
706 }, 699 },
707 700
708 _updateColumns: function() 701 _updateColumns: function()
709 { 702 {
710 if (!this._dataGrid) 703 if (!this._dataGrid)
711 return; 704 return;
712 var visibleColumns = /** @type {!Object.<string, boolean>} */ ({}); 705 var visibleColumns = /** @type {!Object.<string, boolean>} */ ({});
713 if (this._gridMode) { 706 if (this._gridMode) {
714 for (var columnConfig of this._columns) 707 for (var columnConfig of this._columns)
715 visibleColumns[columnConfig.id] = (columnConfig.visible || !colu mnConfig.hideable); 708 visibleColumns[columnConfig.id] = columnConfig.visible;
716 } else { 709 } else {
717 visibleColumns.name = true; 710 visibleColumns.name = true;
718 } 711 }
719 this._dataGrid.setColumnsVisiblity(visibleColumns); 712 this._dataGrid.setColumnsVisiblity(visibleColumns);
720 }, 713 },
721 714
722 /** 715 /**
723 * @param {boolean} gridMode 716 * @param {boolean} gridMode
724 */ 717 */
725 switchViewMode: function(gridMode) 718 switchViewMode: function(gridMode)
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 var subtitleDiv = fragment.createChild("div", "network-header-subtitle") ; 801 var subtitleDiv = fragment.createChild("div", "network-header-subtitle") ;
809 subtitleDiv.createTextChild(subtitle); 802 subtitleDiv.createTextChild(subtitle);
810 return fragment; 803 return fragment;
811 }, 804 },
812 805
813 /** 806 /**
814 * @param {!WebInspector.ContextMenu} contextMenu 807 * @param {!WebInspector.ContextMenu} contextMenu
815 */ 808 */
816 _innerHeaderContextMenu: function(contextMenu) 809 _innerHeaderContextMenu: function(contextMenu)
817 { 810 {
811 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) {
812 var timelineSortIds = WebInspector.NetworkLogViewColumns.TimelineSor tIds;
813 var timelineSubMenu = contextMenu.appendSubMenuItem(WebInspector.UIS tring("Timeline"));
814 timelineSubMenu.appendCheckboxItem(WebInspector.UIString("Start Time "), setTimelineMode.bind(this, timelineSortIds.StartTime), this._activeTimelineS ortId === timelineSortIds.StartTime);
815 timelineSubMenu.appendCheckboxItem(WebInspector.UIString("Response T ime"), setTimelineMode.bind(this, timelineSortIds.ResponseTime), this._activeTim elineSortId === timelineSortIds.ResponseTime);
816 timelineSubMenu.appendCheckboxItem(WebInspector.UIString("End Time") , setTimelineMode.bind(this, timelineSortIds.EndTime), this._activeTimelineSortI d === timelineSortIds.EndTime);
817 timelineSubMenu.appendCheckboxItem(WebInspector.UIString("Total Dura tion"), setTimelineMode.bind(this, timelineSortIds.Duration), this._activeTimeli neSortId === timelineSortIds.Duration);
818 timelineSubMenu.appendCheckboxItem(WebInspector.UIString("Latency"), setTimelineMode.bind(this, timelineSortIds.Latency), this._activeTimelineSortId === timelineSortIds.Latency);
819 contextMenu.appendSeparator();
820 }
818 var columnConfigs = this._columns.filter(columnConfig => columnConfig.hi deable); 821 var columnConfigs = this._columns.filter(columnConfig => columnConfig.hi deable);
819 var nonResponseHeaders = columnConfigs.filter(columnConfig => !columnCon fig.isResponseHeader); 822 var nonResponseHeaders = columnConfigs.filter(columnConfig => !columnCon fig.isResponseHeader);
820 for (var columnConfig of nonResponseHeaders) 823 for (var columnConfig of nonResponseHeaders)
821 contextMenu.appendCheckboxItem(columnConfig.title, this._toggleColum nVisibility.bind(this, columnConfig), columnConfig.visible); 824 contextMenu.appendCheckboxItem(columnConfig.title, this._toggleColum nVisibility.bind(this, columnConfig), columnConfig.visible);
822 825
823 contextMenu.appendSeparator(); 826 contextMenu.appendSeparator();
824 827
825 var responseSubMenu = contextMenu.appendSubMenuItem(WebInspector.UIStrin g("Response Headers")); 828 var responseSubMenu = contextMenu.appendSubMenuItem(WebInspector.UIStrin g("Response Headers"));
826 var responseHeaders = columnConfigs.filter(columnConfig => columnConfig. isResponseHeader); 829 var responseHeaders = columnConfigs.filter(columnConfig => columnConfig. isResponseHeader);
827 for (var columnConfig of responseHeaders) 830 for (var columnConfig of responseHeaders)
828 responseSubMenu.appendCheckboxItem(columnConfig.title, this._toggleC olumnVisibility.bind(this, columnConfig), columnConfig.visible); 831 responseSubMenu.appendCheckboxItem(columnConfig.title, this._toggleC olumnVisibility.bind(this, columnConfig), columnConfig.visible);
829 832
830 responseSubMenu.appendSeparator(); 833 responseSubMenu.appendSeparator();
831 responseSubMenu.appendItem(WebInspector.UIString("Manage Header Columns\ u2026"), this._manageCustomHeaderDialog.bind(this)); 834 responseSubMenu.appendItem(WebInspector.UIString("Manage Header Columns\ u2026"), this._manageCustomHeaderDialog.bind(this));
832 835
833 contextMenu.show(); 836 contextMenu.show();
837
838 /**
839 * @param {!WebInspector.NetworkLogViewColumns.TimelineSortIds} sortId
840 * @this {WebInspector.NetworkLogViewColumns}
841 */
842 function setTimelineMode(sortId)
843 {
844 var calculator = this._calculatorsMap.get(WebInspector.NetworkLogVie wColumns._calculatorTypes.Time);
845 var timelineSortIds = WebInspector.NetworkLogViewColumns.TimelineSor tIds;
846 if (sortId === timelineSortIds.Duration || sortId === timelineSortId s.Latency)
847 calculator = this._calculatorsMap.get(WebInspector.NetworkLogVie wColumns._calculatorTypes.Duration);
848 this._networkLogView.setCalculator(calculator);
849
850 this._activeTimelineSortId = sortId;
851 this._dataGrid.markColumnAsSortedBy("timeline", WebInspector.DataGri d.Order.Ascending);
852 this._sortHandler();
853 }
834 }, 854 },
835 855
836 _manageCustomHeaderDialog: function() 856 _manageCustomHeaderDialog: function()
837 { 857 {
838 var customHeaders = []; 858 var customHeaders = [];
839 for (var columnConfig of this._columns) { 859 for (var columnConfig of this._columns) {
840 if (columnConfig.isResponseHeader) 860 if (columnConfig.isResponseHeader)
841 customHeaders.push({title: columnConfig.title, editable: columnC onfig.isCustomHeader}); 861 customHeaders.push({title: columnConfig.title, editable: columnC onfig.isCustomHeader});
842 } 862 }
843 var manageCustomHeaders = new WebInspector.NetworkManageCustomHeadersVie w(customHeaders, headerTitle => !!this._addCustomHeader(headerTitle), this._chan geCustomHeader.bind(this), this._removeCustomHeader.bind(this)); 863 var manageCustomHeaders = new WebInspector.NetworkManageCustomHeadersVie w(customHeaders, headerTitle => !!this._addCustomHeader(headerTitle), this._chan geCustomHeader.bind(this), this._removeCustomHeader.bind(this));
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 { 1102 {
1083 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) { 1103 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) {
1084 this._shownEventDividers.delete(WebInspector.NetworkLogViewColumns._ filmStripDividerColor); 1104 this._shownEventDividers.delete(WebInspector.NetworkLogViewColumns._ filmStripDividerColor);
1085 this._redrawTimelineColumn(); 1105 this._redrawTimelineColumn();
1086 return; 1106 return;
1087 } 1107 }
1088 for (var divider of this._eventDividers) 1108 for (var divider of this._eventDividers)
1089 divider.element.classList.toggle("network-frame-divider-selected", f alse); 1109 divider.element.classList.toggle("network-frame-divider-selected", f alse);
1090 } 1110 }
1091 }; 1111 };
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/network/NetworkDataGridNode.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698