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

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

Issue 2400093002: [Devtools] New network timeline experiment Part 1 (Closed)
Patch Set: [Devtools] New network timeline experirement Part 1 Created 4 years, 2 months 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org> 3 * Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org>
4 * Copyright (C) 2011 Google Inc. All rights reserved. 4 * Copyright (C) 2011 Google Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 /** @type {!WebInspector.Linkifier} */ 75 /** @type {!WebInspector.Linkifier} */
76 this.linkifier = new WebInspector.Linkifier(); 76 this.linkifier = new WebInspector.Linkifier();
77 77
78 this._recording = false; 78 this._recording = false;
79 this._preserveLog = false; 79 this._preserveLog = false;
80 80
81 /** @type {number} */ 81 /** @type {number} */
82 this._rowHeight = 0; 82 this._rowHeight = 0;
83 83
84 this._headerHeight = 0;
85 this._timelineHeaderElement = null;
86
87
84 this._addFilters(); 88 this._addFilters();
85 this._resetSuggestionBuilder(); 89 this._resetSuggestionBuilder();
86 this._initializeView(); 90 this._initializeView();
87 91
88 WebInspector.moduleSetting("networkColorCodeResourceTypes").addChangeListene r(this._invalidateAllItems, this); 92 WebInspector.moduleSetting("networkColorCodeResourceTypes").addChangeListene r(this._invalidateAllItems, this);
89 this._networkLogLargeRowsSetting.addChangeListener(this._updateRowsSize, thi s); 93 this._networkLogLargeRowsSetting.addChangeListener(this._updateRowsSize, thi s);
90 94
91 WebInspector.targetManager.observeTargets(this); 95 WebInspector.targetManager.observeTargets(this);
92 WebInspector.targetManager.addModelListener(WebInspector.NetworkManager, Web Inspector.NetworkManager.Events.RequestStarted, this._onRequestStarted, this); 96 WebInspector.targetManager.addModelListener(WebInspector.NetworkManager, Web Inspector.NetworkManager.Events.RequestStarted, this._onRequestStarted, this);
93 WebInspector.targetManager.addModelListener(WebInspector.NetworkManager, Web Inspector.NetworkManager.Events.RequestUpdated, this._onRequestUpdated, this); 97 WebInspector.targetManager.addModelListener(WebInspector.NetworkManager, Web Inspector.NetworkManager.Events.RequestUpdated, this._onRequestUpdated, this);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 /** @enum {string} */ 141 /** @enum {string} */
138 WebInspector.NetworkLogView.IsFilterType = { 142 WebInspector.NetworkLogView.IsFilterType = {
139 Running: "running" 143 Running: "running"
140 }; 144 };
141 145
142 /** @type {!Array<string>} */ 146 /** @type {!Array<string>} */
143 WebInspector.NetworkLogView._searchKeys = Object.keys(WebInspector.NetworkLogVie w.FilterType).map(key => WebInspector.NetworkLogView.FilterType[key]); 147 WebInspector.NetworkLogView._searchKeys = Object.keys(WebInspector.NetworkLogVie w.FilterType).map(key => WebInspector.NetworkLogView.FilterType[key]);
144 148
145 WebInspector.NetworkLogView.prototype = { 149 WebInspector.NetworkLogView.prototype = {
146 /** 150 /**
151 * @return {number}
152 */
153 headerHeight: function()
154 {
155 return this._headerHeight;
156 },
157
158 /**
147 * @param {boolean} recording 159 * @param {boolean} recording
148 */ 160 */
149 setRecording: function(recording) 161 setRecording: function(recording)
150 { 162 {
151 this._recording = recording; 163 this._recording = recording;
152 this._updateSummaryBar(); 164 this._updateSummaryBar();
153 }, 165 },
154 166
155 /** 167 /**
156 * @param {boolean} preserveLog 168 * @param {boolean} preserveLog
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 /** 264 /**
253 * @param {!WebInspector.Event} event 265 * @param {!WebInspector.Event} event
254 */ 266 */
255 _filterChanged: function(event) 267 _filterChanged: function(event)
256 { 268 {
257 this.removeAllNodeHighlights(); 269 this.removeAllNodeHighlights();
258 this._parseFilterQuery(this._textFilterUI.value()); 270 this._parseFilterQuery(this._textFilterUI.value());
259 this._filterRequests(); 271 this._filterRequests();
260 }, 272 },
261 273
274 show: function(element)
dgozman 2016/10/07 21:39:57 We are not supposed to override show(). It should
allada 2016/10/08 00:13:32 Done.
275 {
276 if (Runtime.experiments.isEnabled("networkCanvasTimeline")) {
277 WebInspector.VBox.prototype.show.call(this, this._splitWidget.elemen t);
278 this._outerWidget.show(element);
279 } else {
280 WebInspector.VBox.prototype.show.call(this, element);
281 }
282 },
283
262 _initializeView: function() 284 _initializeView: function()
263 { 285 {
264 this.element.id = "network-container"; 286 this.element.id = "network-container";
265 287
266 /** @type {!WebInspector.NetworkTransferTimeCalculator} */ 288 /** @type {!WebInspector.NetworkTransferTimeCalculator} */
267 this._timeCalculator = new WebInspector.NetworkTransferTimeCalculator(); 289 this._timeCalculator = new WebInspector.NetworkTransferTimeCalculator();
268 /** @type {!WebInspector.NetworkTransferDurationCalculator} */ 290 /** @type {!WebInspector.NetworkTransferDurationCalculator} */
269 this._durationCalculator = new WebInspector.NetworkTransferDurationCalcu lator(); 291 this._durationCalculator = new WebInspector.NetworkTransferDurationCalcu lator();
270 this._calculator = this._timeCalculator; 292 this._calculator = this._timeCalculator;
271 293
272 this._createTable(); 294 if (Runtime.experiments.isEnabled("networkCanvasTimeline")) {
273 this._summaryBarElement = this.element.createChild("div", "network-summa ry-bar"); 295 this._outerWidget = new WebInspector.VBox();
dgozman 2016/10/07 21:39:57 Not very descriptive name.
allada 2016/10/08 00:13:32 Done.
296 this._splitWidget = new WebInspector.SplitWidget(true, false, "netwo rkPanelSplitViewTimeline");
297 this._splitWidget.setSidebarWidget(this);
298 this._splitWidget.show(this._outerWidget.element);
299 this._createTable();
300 this._summaryBarElement = this._outerWidget.element.createChild("div ", "network-summary-bar");
301 } else {
302 this._createTable();
303 this._summaryBarElement = this.element.createChild("div", "network-s ummary-bar");
304 }
274 305
275 this._updateRowsSize(); 306 this._updateRowsSize();
276 }, 307 },
277 308
278 _showRecordingHint: function() 309 _showRecordingHint: function()
279 { 310 {
280 this._hideRecordingHint(); 311 this._hideRecordingHint();
281 this._recordingHint = this.element.createChild("div", "network-status-pa ne fill"); 312 this._recordingHint = this.element.createChild("div", "network-status-pa ne fill");
282 var hintText = this._recordingHint.createChild("div", "recording-hint"); 313 var hintText = this._recordingHint.createChild("div", "recording-hint");
283 var reloadShortcutNode = this._recordingHint.createChild("b"); 314 var reloadShortcutNode = this._recordingHint.createChild("b");
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 { 348 {
318 this._dataGrid = this._columns.createGrid(this._timeCalculator, this._du rationCalculator); 349 this._dataGrid = this._columns.createGrid(this._timeCalculator, this._du rationCalculator);
319 this._dataGrid.setStickToBottom(true); 350 this._dataGrid.setStickToBottom(true);
320 this._dataGrid.setName("networkLog"); 351 this._dataGrid.setName("networkLog");
321 this._dataGrid.setResizeMethod(WebInspector.DataGrid.ResizeMethod.Last); 352 this._dataGrid.setResizeMethod(WebInspector.DataGrid.ResizeMethod.Last);
322 this._dataGrid.element.classList.add("network-log-grid"); 353 this._dataGrid.element.classList.add("network-log-grid");
323 this._dataGrid.element.addEventListener("contextmenu", this._contextMenu .bind(this), true); 354 this._dataGrid.element.addEventListener("contextmenu", this._contextMenu .bind(this), true);
324 this._dataGrid.element.addEventListener("mousedown", this._dataGridMouse Down.bind(this), true); 355 this._dataGrid.element.addEventListener("mousedown", this._dataGridMouse Down.bind(this), true);
325 this._dataGrid.element.addEventListener("mousemove", this._dataGridMouse Move.bind(this), true); 356 this._dataGrid.element.addEventListener("mousemove", this._dataGridMouse Move.bind(this), true);
326 this._dataGrid.element.addEventListener("mouseleave", this._highlightIni tiatorChain.bind(this, null), true); 357 this._dataGrid.element.addEventListener("mouseleave", this._highlightIni tiatorChain.bind(this, null), true);
358
359 if (Runtime.experiments.isEnabled("networkCanvasTimeline")) {
360 this._timelineWidget = new WebInspector.VBox();
361 this._createTimelineHeader();
362 this._timelineWidget.element.classList.add("network-timeline-view");
363 this._splitWidget.setMainWidget(this._timelineWidget);
364 }
365
327 this._columns.sortByCurrentColumn(); 366 this._columns.sortByCurrentColumn();
328 }, 367 },
329 368
330 /** 369 /**
331 * @param {!Event} event 370 * @param {!Event} event
332 */ 371 */
333 _dataGridMouseDown: function(event) 372 _dataGridMouseDown: function(event)
334 { 373 {
335 if ((!this._dataGrid.selectedNode && event.button) || event.target.enclo singNodeOrSelfWithNodeName("a")) 374 if ((!this._dataGrid.selectedNode && event.button) || event.target.enclo singNodeOrSelfWithNodeName("a"))
336 event.consume(); 375 event.consume();
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 for (var i = 0; i < requestsToPick.length; ++i) { 842 for (var i = 0; i < requestsToPick.length; ++i) {
804 var request = requestsToPick[i]; 843 var request = requestsToPick[i];
805 var node = this._nodesByRequestId.get(request.requestId); 844 var node = this._nodesByRequestId.get(request.requestId);
806 if (node) { 845 if (node) {
807 node.markAsNavigationRequest(); 846 node.markAsNavigationRequest();
808 break; 847 break;
809 } 848 }
810 } 849 }
811 }, 850 },
812 851
852 _createTimelineHeader: function()
853 {
854 this._timelineHeaderElement = this._timelineWidget.element.createChild(" div", "timelineHeader");
855 this._timelineHeaderElement.addEventListener("click", timelineHeaderClic ked.bind(this));
856 this._timelineHeaderElement.addEventListener("contextmenu", this._contex tMenu.bind(this));
857 var innerElement = this._timelineHeaderElement.createChild("div");
858 innerElement.textContent = WebInspector.UIString("Timeline");
859 this._timelineColumnSortIcon = this._timelineHeaderElement.createChild(" div", "sort-order-icon-container").createChild("div", "sort-order-icon");
860
861 /**
862 * @this {WebInspector.NetworkLogView}
863 */
864 function timelineHeaderClicked()
865 {
866 var sortOrders = WebInspector.DataGrid.Order;
867 var sortOrder = this._dataGrid.sortOrder() === sortOrders.Ascending ? sortOrders.Descending : sortOrders.Ascending;
868 this._dataGrid.markColumnAsSortedBy("timeline", sortOrder);
869 this._columns.sortByCurrentColumn();
870 }
871 },
872
813 /** 873 /**
814 * @param {boolean} gridMode 874 * @param {boolean} gridMode
815 */ 875 */
816 switchViewMode: function(gridMode) 876 switchViewMode: function(gridMode)
817 { 877 {
818 this._columns.switchViewMode(gridMode); 878 this._columns.switchViewMode(gridMode);
879 if (!Runtime.experiments.isEnabled("networkCanvasTimeline"))
880 return;
881
882 if (this._networkTimelineView) {
883 this._networkTimelineView.detach();
884 this._networkTimelineView = null;
885 }
886 if (gridMode && this._nodesByRequestId.size) {
887 this._networkTimelineView = new WebInspector.NetworkTimelineColumn(t his, this._dataGrid);
dgozman 2016/10/07 21:39:57 Can we avoid recreating it all the time?
allada 2016/10/08 00:13:32 Done.
888 this._networkTimelineView.show(this._timelineWidget.element);
889 this._splitWidget.showBoth();
890 } else {
891 this._splitWidget.hideMain();
892 }
819 }, 893 },
820 894
821 /** 895 /**
822 * @return {number} 896 * @return {number}
823 */ 897 */
824 rowHeight: function() 898 rowHeight: function()
825 { 899 {
826 return this._rowHeight; 900 return this._rowHeight;
827 }, 901 },
828 902
829 _updateRowsSize: function() 903 _updateRowsSize: function()
830 { 904 {
831 var largeRows = !!this._networkLogLargeRowsSetting.get(); 905 var largeRows = !!this._networkLogLargeRowsSetting.get();
832 this._rowHeight = largeRows ? 41 : 21; 906 this._rowHeight = largeRows ? 41 : 21;
907 this._headerHeight = largeRows ? 31 : 27;
833 this._dataGrid.element.classList.toggle("small", !largeRows); 908 this._dataGrid.element.classList.toggle("small", !largeRows);
909 if (Runtime.experiments.isEnabled("networkCanvasTimeline"))
910 this._timelineHeaderElement.classList.toggle("small", !largeRows);
834 this._dataGrid.scheduleUpdate(); 911 this._dataGrid.scheduleUpdate();
835 }, 912 },
836 913
837 /** 914 /**
838 * @param {!Event} event 915 * @param {!Event} event
839 */ 916 */
840 _contextMenu: function(event) 917 _contextMenu: function(event)
841 { 918 {
842 // TODO(allada) Fix datagrid's contextmenu so NetworkLogViewColumns can attach it's own contextmenu event 919 // TODO(allada) Fix datagrid's contextmenu so NetworkLogViewColumns can attach it's own contextmenu event
843 if (this._columns.contextMenu(event)) 920 if (this._columns.contextMenu(event))
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 { 1128 {
1052 this.removeAllNodeHighlights(); 1129 this.removeAllNodeHighlights();
1053 for (var i = 0; i < this._highlightedSubstringChanges.length; ++i) 1130 for (var i = 0; i < this._highlightedSubstringChanges.length; ++i)
1054 WebInspector.revertDomChanges(this._highlightedSubstringChanges[i]); 1131 WebInspector.revertDomChanges(this._highlightedSubstringChanges[i]);
1055 this._highlightedSubstringChanges = []; 1132 this._highlightedSubstringChanges = [];
1056 }, 1133 },
1057 1134
1058 dataGridSorted: function() 1135 dataGridSorted: function()
1059 { 1136 {
1060 this._highlightNthMatchedRequestForSearch(this._updateMatchCountAndFindM atchIndex(this._currentMatchedRequestNode), false); 1137 this._highlightNthMatchedRequestForSearch(this._updateMatchCountAndFindM atchIndex(this._currentMatchedRequestNode), false);
1138
1139 if (!Runtime.experiments.isEnabled("networkCanvasTimeline"))
1140 return;
1141
1142 this._timelineColumnSortIcon.classList.remove("sort-ascending");
1143 this._timelineColumnSortIcon.classList.remove("sort-descending");
1144 if (this._dataGrid.sortColumnIdentifier() === "timeline") {
1145 if (this._dataGrid.sortOrder() === WebInspector.DataGrid.Order.Ascen ding)
1146 this._timelineColumnSortIcon.classList.add("sort-ascending");
1147 else
1148 this._timelineColumnSortIcon.classList.add("sort-descending");
1149 }
1061 }, 1150 },
1062 1151
1063 /** 1152 /**
1064 * @param {number} n 1153 * @param {number} n
1065 * @param {boolean} reveal 1154 * @param {boolean} reveal
1066 */ 1155 */
1067 _highlightNthMatchedRequestForSearch: function(n, reveal) 1156 _highlightNthMatchedRequestForSearch: function(n, reveal)
1068 { 1157 {
1069 this._removeAllHighlights(); 1158 this._removeAllHighlights();
1070 1159
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 * @return {boolean} 1828 * @return {boolean}
1740 */ 1829 */
1741 WebInspector.NetworkLogView._requestTimeFilter = function(windowStart, windowEnd , request) 1830 WebInspector.NetworkLogView._requestTimeFilter = function(windowStart, windowEnd , request)
1742 { 1831 {
1743 if (request.issueTime() > windowEnd) 1832 if (request.issueTime() > windowEnd)
1744 return false; 1833 return false;
1745 if (request.endTime !== -1 && request.endTime < windowStart) 1834 if (request.endTime !== -1 && request.endTime < windowStart)
1746 return false; 1835 return false;
1747 return true; 1836 return true;
1748 } 1837 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698