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

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: changes 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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 calculator: WebInspector.NetworkLogViewColumns._calculatorTy pes.Duration 359 calculator: WebInspector.NetworkLogViewColumns._calculatorTy pes.Duration
363 } 360 }
364 ] 361 ]
365 } 362 }
366 } 363 }
367 ]; 364 ];
368 365
369 WebInspector.NetworkLogViewColumns._filmStripDividerColor = "#fccc49"; 366 WebInspector.NetworkLogViewColumns._filmStripDividerColor = "#fccc49";
370 367
371 /** 368 /**
369 * @enum {string}
370 */
371 WebInspector.NetworkLogViewColumns.TimelineSortIds = {
372 StartTime: "startTime",
373 ResponseTime: "responseReceivedTime",
374 EndTime: "endTime",
375 Duration: "duration",
376 Latency: "latency"
377 };
378
379 /**
372 * @param {!WebInspector.NetworkLogViewColumns.Descriptor} columnConfig 380 * @param {!WebInspector.NetworkLogViewColumns.Descriptor} columnConfig
373 * @return {!WebInspector.DataGrid.ColumnDescriptor} 381 * @return {!WebInspector.DataGrid.ColumnDescriptor}
374 */ 382 */
375 WebInspector.NetworkLogViewColumns._convertToDataGridDescriptor = function(colum nConfig) 383 WebInspector.NetworkLogViewColumns._convertToDataGridDescriptor = function(colum nConfig)
376 { 384 {
377 return /** @type {!WebInspector.DataGrid.ColumnDescriptor} */ ({ 385 return /** @type {!WebInspector.DataGrid.ColumnDescriptor} */ ({
378 id: columnConfig.id, 386 id: columnConfig.id,
379 title: columnConfig.title, 387 title: columnConfig.title,
380 sortable: columnConfig.sortable, 388 sortable: columnConfig.sortable,
381 align: columnConfig.align, 389 align: columnConfig.align,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.ColumnsResi zed, this.updateDividersIfNeeded, this); 444 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.ColumnsResi zed, this.updateDividersIfNeeded, this);
437 this._dataGrid.setHeaderContextMenuCallback(this._innerHeaderContextMenu .bind(this)); 445 this._dataGrid.setHeaderContextMenuCallback(this._innerHeaderContextMenu .bind(this));
438 446
439 this._timelineGrid = new WebInspector.TimelineGrid(); 447 this._timelineGrid = new WebInspector.TimelineGrid();
440 this._timelineGrid.element.classList.add("network-timeline-grid"); 448 this._timelineGrid.element.classList.add("network-timeline-grid");
441 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline")) 449 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline"))
442 this._dataGrid.element.appendChild(this._timelineGrid.element); 450 this._dataGrid.element.appendChild(this._timelineGrid.element);
443 451
444 this._setupDropdownColumns(); 452 this._setupDropdownColumns();
445 453
454 this._activeTimelineSortId = WebInspector.NetworkLogViewColumns.Timeline SortIds.StartTime;
446 this._dataGrid.markColumnAsSortedBy(WebInspector.NetworkLogViewColumns._ initialSortColumn, WebInspector.DataGrid.Order.Ascending); 455 this._dataGrid.markColumnAsSortedBy(WebInspector.NetworkLogViewColumns._ initialSortColumn, WebInspector.DataGrid.Order.Ascending);
447 456
448 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) { 457 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) {
449 this._splitWidget = new WebInspector.SplitWidget(true, false, "netwo rkPanelSplitViewTimeline"); 458 this._splitWidget = new WebInspector.SplitWidget(true, false, "netwo rkPanelSplitViewTimeline");
450 this._splitWidget.setSidebarWidget(this._dataGrid.asWidget()); 459 this._splitWidget.setSidebarWidget(this._dataGrid.asWidget());
451 } 460 }
452 }, 461 },
453 462
454 _setupTimeline: function() 463 _setupTimeline: function()
455 { 464 {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 }, 643 },
635 644
636 sortByCurrentColumn: function() 645 sortByCurrentColumn: function()
637 { 646 {
638 this._sortHandler(); 647 this._sortHandler();
639 }, 648 },
640 649
641 _sortHandler: function() 650 _sortHandler: function()
642 { 651 {
643 var columnId = this._dataGrid.sortColumnId(); 652 var columnId = this._dataGrid.sortColumnId();
653 this._networkLogView.removeAllNodeHighlights();
654 if (Runtime.experiments.isEnabled("canvasNetworkTimeline") && columnId = == "timeline") {
655 this._timelineColumnSortIcon.classList.remove("sort-ascending", "sor t-descending");
656
657 if (this._dataGrid.sortOrder() === WebInspector.DataGrid.Order.Ascen ding)
658 this._timelineColumnSortIcon.classList.add("sort-ascending");
659 else
660 this._timelineColumnSortIcon.classList.add("sort-descending");
661
662 this._timelineRequestsAreStale = true;
663 var sortFunction = WebInspector.NetworkDataGridNode.RequestPropertyC omparator.bind(null, this._activeTimelineSortId);
664 this._dataGrid.sortNodes(sortFunction, !this._dataGrid.isSortOrderAs cending());
665 return;
666 }
667
644 var columnConfig = this._columns.find(columnConfig => columnConfig.id == = columnId); 668 var columnConfig = this._columns.find(columnConfig => columnConfig.id == = columnId);
645 if (!columnConfig) 669 if (!columnConfig)
646 return; 670 return;
647 if (columnConfig.sortConfig && columnConfig.sortConfig.entries) { 671 if (columnConfig.sortConfig && columnConfig.sortConfig.entries) {
648 this._sortByDropdownItem(columnConfig); 672 this._sortByDropdownItem(columnConfig);
649 return; 673 return;
650 } 674 }
651 if (!columnConfig.sortConfig.sortingFunction) 675 if (!columnConfig.sortConfig.sortingFunction)
652 return; 676 return;
653 677
654 this._networkLogView.removeAllNodeHighlights();
655 this._dataGrid.sortNodes(columnConfig.sortConfig.sortingFunction, !this. _dataGrid.isSortOrderAscending()); 678 this._dataGrid.sortNodes(columnConfig.sortConfig.sortingFunction, !this. _dataGrid.isSortOrderAscending());
656 this._networkLogView.dataGridSorted(); 679 this._networkLogView.dataGridSorted();
657
658 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline"))
659 return;
660
661 this._timelineColumnSortIcon.classList.remove("sort-ascending", "sort-de scending");
662
663 if (this._dataGrid.sortColumnId() === "timeline") {
664 if (this._dataGrid.sortOrder() === WebInspector.DataGrid.Order.Ascen ding)
665 this._timelineColumnSortIcon.classList.add("sort-ascending");
666 else
667 this._timelineColumnSortIcon.classList.add("sort-descending");
668 }
669
670 this._timelineRequestsAreStale = true;
671
672 }, 680 },
673 681
674 /** 682 /**
675 * @param {!WebInspector.NetworkLogViewColumns.Descriptor} columnConfig 683 * @param {!WebInspector.NetworkLogViewColumns.Descriptor} columnConfig
676 */ 684 */
677 _sortByDropdownItem: function(columnConfig) 685 _sortByDropdownItem: function(columnConfig)
678 { 686 {
679 this._networkLogView.removeAllNodeHighlights(); 687 this._networkLogView.removeAllNodeHighlights();
680 var selectedIndex = columnConfig.selectBox.selectedIndex; 688 var selectedIndex = columnConfig.selectBox.selectedIndex;
681 if (!selectedIndex) 689 if (!selectedIndex)
682 selectedIndex = 1; // Sort by first item by default. 690 selectedIndex = 1; // Sort by first item by default.
683 var selectedItemConfig = columnConfig.sortConfig.entries[selectedIndex - 1]; // -1 because of placeholder. 691 var selectedItemConfig = columnConfig.sortConfig.entries[selectedIndex - 1]; // -1 because of placeholder.
684 var selectedOption = columnConfig.selectBox[selectedIndex]; 692 var selectedOption = columnConfig.selectBox[selectedIndex];
685 var value = selectedOption.value; 693 var value = selectedOption.value;
686 694
687 this._dataGrid.sortNodes(selectedItemConfig.sortingFunction); 695 this._dataGrid.sortNodes(selectedItemConfig.sortingFunction);
688 this._dataGrid.markColumnAsSortedBy(columnConfig.id, /** @type {!WebInsp ector.DataGrid.Order} */ (selectedItemConfig.sort)); 696 this._dataGrid.markColumnAsSortedBy(columnConfig.id, /** @type {!WebInsp ector.DataGrid.Order} */ (selectedItemConfig.sort));
689 if (selectedItemConfig.calculator) 697 if (selectedItemConfig.calculator)
690 this._networkLogView.setCalculator(this._calculatorsMap.get(selected ItemConfig.calculator)); 698 this._networkLogView.setCalculator(this._calculatorsMap.get(selected ItemConfig.calculator));
691 columnConfig.selectBox.options[0].label = selectedItemConfig.title; 699 columnConfig.selectBox.options[0].label = selectedItemConfig.title;
692 columnConfig.selectBox.selectedIndex = 0; 700 columnConfig.selectBox.selectedIndex = 0;
693 this._networkLogView.dataGridSorted(); 701 this._networkLogView.dataGridSorted();
694
695 // TODO(allada) This entire function will be removed when the timeline c omes out of exp, so copying code above for now.
696 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline"))
697 return;
698
699 this._timelineColumnSortIcon.classList.remove("sort-ascending", "sort-de scending");
700
701 if (this._dataGrid.sortColumnId() === "timeline") {
702 if (this._dataGrid.sortOrder() === WebInspector.DataGrid.Order.Ascen ding)
703 this._timelineColumnSortIcon.classList.add("sort-ascending");
704 else
705 this._timelineColumnSortIcon.classList.add("sort-descending");
706 }
707
708 this._timelineRequestsAreStale = true;
709 }, 702 },
710 703
711 _updateColumns: function() 704 _updateColumns: function()
712 { 705 {
713 if (!this._dataGrid) 706 if (!this._dataGrid)
714 return; 707 return;
715 var visibleColumns = /** @type {!Object.<string, boolean>} */ ({}); 708 var visibleColumns = /** @type {!Object.<string, boolean>} */ ({});
716 if (this._gridMode) { 709 if (this._gridMode) {
717 for (var columnConfig of this._columns) 710 for (var columnConfig of this._columns)
718 visibleColumns[columnConfig.id] = (columnConfig.visible || !colu mnConfig.hideable); 711 visibleColumns[columnConfig.id] = columnConfig.visible;
dgozman 2016/10/28 19:04:28 What about name column? It's not hideable as well.
allada 2016/10/28 21:11:04 This is already handled by not allowing it to be h
719 } else { 712 } else {
720 visibleColumns.name = true; 713 visibleColumns.name = true;
721 } 714 }
722 this._dataGrid.setColumnsVisiblity(visibleColumns); 715 this._dataGrid.setColumnsVisiblity(visibleColumns);
723 }, 716 },
724 717
725 /** 718 /**
726 * @param {boolean} gridMode 719 * @param {boolean} gridMode
727 */ 720 */
728 switchViewMode: function(gridMode) 721 switchViewMode: function(gridMode)
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 var subtitleDiv = fragment.createChild("div", "network-header-subtitle") ; 804 var subtitleDiv = fragment.createChild("div", "network-header-subtitle") ;
812 subtitleDiv.createTextChild(subtitle); 805 subtitleDiv.createTextChild(subtitle);
813 return fragment; 806 return fragment;
814 }, 807 },
815 808
816 /** 809 /**
817 * @param {!WebInspector.ContextMenu} contextMenu 810 * @param {!WebInspector.ContextMenu} contextMenu
818 */ 811 */
819 _innerHeaderContextMenu: function(contextMenu) 812 _innerHeaderContextMenu: function(contextMenu)
820 { 813 {
814 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) {
815 var timelineSortIds = WebInspector.NetworkLogViewColumns.TimelineSor tIds;
816 var timelineSubMenu = contextMenu.appendSubMenuItem(WebInspector.UIS tring("Timeline Views"));
817 timelineSubMenu.appendCheckboxItem(WebInspector.UIString("Start Time "), setTimelineMode.bind(this, timelineSortIds.StartTime), this._activeTimelineS ortId === timelineSortIds.StartTime);
818 timelineSubMenu.appendCheckboxItem(WebInspector.UIString("Response T ime"), setTimelineMode.bind(this, timelineSortIds.ResponseTime), this._activeTim elineSortId === timelineSortIds.ResponseTime);
819 timelineSubMenu.appendCheckboxItem(WebInspector.UIString("End Time") , setTimelineMode.bind(this, timelineSortIds.EndTime), this._activeTimelineSortI d === timelineSortIds.EndTime);
820 timelineSubMenu.appendCheckboxItem(WebInspector.UIString("Total Dura tion"), setTimelineMode.bind(this, timelineSortIds.Duration), this._activeTimeli neSortId === timelineSortIds.Duration);
821 timelineSubMenu.appendCheckboxItem(WebInspector.UIString("Latency"), setTimelineMode.bind(this, timelineSortIds.Latency), this._activeTimelineSortId === timelineSortIds.Latency);
822 contextMenu.appendSeparator();
823 }
821 var columnConfigs = this._columns.filter(columnConfig => columnConfig.hi deable); 824 var columnConfigs = this._columns.filter(columnConfig => columnConfig.hi deable);
822 var nonResponseHeaders = columnConfigs.filter(columnConfig => !columnCon fig.isResponseHeader); 825 var nonResponseHeaders = columnConfigs.filter(columnConfig => !columnCon fig.isResponseHeader);
823 for (var columnConfig of nonResponseHeaders) 826 for (var columnConfig of nonResponseHeaders)
824 contextMenu.appendCheckboxItem(columnConfig.title, this._toggleColum nVisibility.bind(this, columnConfig), columnConfig.visible); 827 contextMenu.appendCheckboxItem(columnConfig.title, this._toggleColum nVisibility.bind(this, columnConfig), columnConfig.visible);
825 828
826 contextMenu.appendSeparator(); 829 contextMenu.appendSeparator();
827 830
828 var responseSubMenu = contextMenu.appendSubMenuItem(WebInspector.UIStrin g("Response Headers")); 831 var responseSubMenu = contextMenu.appendSubMenuItem(WebInspector.UIStrin g("Response Headers"));
829 var responseHeaders = columnConfigs.filter(columnConfig => columnConfig. isResponseHeader); 832 var responseHeaders = columnConfigs.filter(columnConfig => columnConfig. isResponseHeader);
830 for (var columnConfig of responseHeaders) 833 for (var columnConfig of responseHeaders)
831 responseSubMenu.appendCheckboxItem(columnConfig.title, this._toggleC olumnVisibility.bind(this, columnConfig), columnConfig.visible); 834 responseSubMenu.appendCheckboxItem(columnConfig.title, this._toggleC olumnVisibility.bind(this, columnConfig), columnConfig.visible);
832 835
833 responseSubMenu.appendSeparator(); 836 responseSubMenu.appendSeparator();
834 responseSubMenu.appendItem(WebInspector.UIString("Manage Header Columns\ u2026"), this._manageCustomHeaderDialog.bind(this)); 837 responseSubMenu.appendItem(WebInspector.UIString("Manage Header Columns\ u2026"), this._manageCustomHeaderDialog.bind(this));
835 838
836 contextMenu.show(); 839 contextMenu.show();
840
841 /**
842 * @param {!WebInspector.NetworkLogViewColumns.TimelineSortIds} sortId
843 * @this {WebInspector.NetworkLogViewColumns}
844 */
845 function setTimelineMode(sortId)
846 {
847 var calculator = this._calculatorsMap.get(WebInspector.NetworkLogVie wColumns._calculatorTypes.Time);
848 var timelineSortIds = WebInspector.NetworkLogViewColumns.TimelineSor tIds;
849 if (sortId === timelineSortIds.Duration || sortId === timelineSortId s.Latency)
850 calculator = this._calculatorsMap.get(WebInspector.NetworkLogVie wColumns._calculatorTypes.Duration);
851 this._networkLogView.setCalculator(calculator);
852
853 this._activeTimelineSortId = sortId;
854 this._dataGrid.markColumnAsSortedBy("timeline", WebInspector.DataGri d.Order.Ascending);
855 this._sortHandler();
856 }
837 }, 857 },
838 858
839 _manageCustomHeaderDialog: function() 859 _manageCustomHeaderDialog: function()
840 { 860 {
841 var customHeaders = []; 861 var customHeaders = [];
842 for (var columnConfig of this._columns) { 862 for (var columnConfig of this._columns) {
843 if (columnConfig.isResponseHeader) 863 if (columnConfig.isResponseHeader)
844 customHeaders.push({title: columnConfig.title, editable: columnC onfig.isCustomHeader}); 864 customHeaders.push({title: columnConfig.title, editable: columnC onfig.isCustomHeader});
845 } 865 }
846 var manageCustomHeaders = new WebInspector.NetworkManageCustomHeadersVie w(customHeaders, headerTitle => !!this._addCustomHeader(headerTitle), this._chan geCustomHeader.bind(this), this._removeCustomHeader.bind(this)); 866 var manageCustomHeaders = new WebInspector.NetworkManageCustomHeadersVie w(customHeaders, headerTitle => !!this._addCustomHeader(headerTitle), this._chan geCustomHeader.bind(this), this._removeCustomHeader.bind(this));
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 { 1111 {
1092 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) { 1112 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) {
1093 this._shownEventDividers.delete(WebInspector.NetworkLogViewColumns._ filmStripDividerColor); 1113 this._shownEventDividers.delete(WebInspector.NetworkLogViewColumns._ filmStripDividerColor);
1094 this._redrawTimelineColumn(); 1114 this._redrawTimelineColumn();
1095 return; 1115 return;
1096 } 1116 }
1097 for (var divider of this._eventDividers) 1117 for (var divider of this._eventDividers)
1098 divider.element.classList.toggle("network-frame-divider-selected", f alse); 1118 divider.element.classList.toggle("network-frame-divider-selected", f alse);
1099 } 1119 }
1100 }; 1120 };
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