Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 _initializeView: function() | 274 _initializeView: function() |
| 263 { | 275 { |
| 264 this.element.id = "network-container"; | 276 this.element.id = "network-container"; |
| 265 | 277 |
| 266 /** @type {!WebInspector.NetworkTransferTimeCalculator} */ | 278 /** @type {!WebInspector.NetworkTransferTimeCalculator} */ |
| 267 this._timeCalculator = new WebInspector.NetworkTransferTimeCalculator(); | 279 this._timeCalculator = new WebInspector.NetworkTransferTimeCalculator(); |
| 268 /** @type {!WebInspector.NetworkTransferDurationCalculator} */ | 280 /** @type {!WebInspector.NetworkTransferDurationCalculator} */ |
| 269 this._durationCalculator = new WebInspector.NetworkTransferDurationCalcu lator(); | 281 this._durationCalculator = new WebInspector.NetworkTransferDurationCalcu lator(); |
| 270 this._calculator = this._timeCalculator; | 282 this._calculator = this._timeCalculator; |
| 271 | 283 |
| 272 this._createTable(); | 284 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) { |
| 273 this._summaryBarElement = this.element.createChild("div", "network-summa ry-bar"); | 285 this._splitWidget = new WebInspector.SplitWidget(true, false, "netwo rkPanelSplitViewTimeline"); |
| 286 this._splitWidget.show(this.element); | |
| 287 this._createTable(); | |
| 288 this._splitWidget.setSidebarWidget(this._dataGrid.asWidget()); | |
| 274 | 289 |
| 290 this._summaryBarElement = this.element.createChild("div", "network-s ummary-bar"); | |
| 291 | |
| 292 this._timelineWidget = new WebInspector.VBox(); | |
| 293 this._createTimelineHeader(); | |
| 294 this._timelineWidget.element.classList.add("network-timeline-view"); | |
| 295 this._splitWidget.setMainWidget(this._timelineWidget); | |
| 296 | |
| 297 var networkTimelineView = new WebInspector.NetworkTimelineColumn(thi s, this._dataGrid); | |
| 298 networkTimelineView.show(this._timelineWidget.element); | |
| 299 this.switchViewMode(false); | |
| 300 } else { | |
| 301 this._createTable(); | |
| 302 this._dataGrid.asWidget().show(this.element); | |
| 303 this._summaryBarElement = this.element.createChild("div", "network-s ummary-bar"); | |
| 304 } | |
| 305 | |
| 306 this._columns.sortByCurrentColumn(); | |
| 275 this._updateRowsSize(); | 307 this._updateRowsSize(); |
| 276 }, | 308 }, |
| 277 | 309 |
| 278 _showRecordingHint: function() | 310 _showRecordingHint: function() |
| 279 { | 311 { |
| 280 this._hideRecordingHint(); | 312 this._hideRecordingHint(); |
| 281 this._recordingHint = this.element.createChild("div", "network-status-pa ne fill"); | 313 this._recordingHint = this.element.createChild("div", "network-status-pa ne fill"); |
| 282 var hintText = this._recordingHint.createChild("div", "recording-hint"); | 314 var hintText = this._recordingHint.createChild("div", "recording-hint"); |
| 283 var reloadShortcutNode = this._recordingHint.createChild("b"); | 315 var reloadShortcutNode = this._recordingHint.createChild("b"); |
| 284 reloadShortcutNode.textContent = WebInspector.shortcutRegistry.shortcutD escriptorsForAction("main.reload")[0].name; | 316 reloadShortcutNode.textContent = WebInspector.shortcutRegistry.shortcutD escriptorsForAction("main.reload")[0].name; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 { | 349 { |
| 318 this._dataGrid = this._columns.createGrid(this._timeCalculator, this._du rationCalculator); | 350 this._dataGrid = this._columns.createGrid(this._timeCalculator, this._du rationCalculator); |
| 319 this._dataGrid.setStickToBottom(true); | 351 this._dataGrid.setStickToBottom(true); |
| 320 this._dataGrid.setName("networkLog"); | 352 this._dataGrid.setName("networkLog"); |
| 321 this._dataGrid.setResizeMethod(WebInspector.DataGrid.ResizeMethod.Last); | 353 this._dataGrid.setResizeMethod(WebInspector.DataGrid.ResizeMethod.Last); |
| 322 this._dataGrid.element.classList.add("network-log-grid"); | 354 this._dataGrid.element.classList.add("network-log-grid"); |
| 323 this._dataGrid.element.addEventListener("contextmenu", this._contextMenu .bind(this), true); | 355 this._dataGrid.element.addEventListener("contextmenu", this._contextMenu .bind(this), true); |
| 324 this._dataGrid.element.addEventListener("mousedown", this._dataGridMouse Down.bind(this), true); | 356 this._dataGrid.element.addEventListener("mousedown", this._dataGridMouse Down.bind(this), true); |
| 325 this._dataGrid.element.addEventListener("mousemove", this._dataGridMouse Move.bind(this), true); | 357 this._dataGrid.element.addEventListener("mousemove", this._dataGridMouse Move.bind(this), true); |
| 326 this._dataGrid.element.addEventListener("mouseleave", this._highlightIni tiatorChain.bind(this, null), true); | 358 this._dataGrid.element.addEventListener("mouseleave", this._highlightIni tiatorChain.bind(this, null), true); |
| 327 this._columns.sortByCurrentColumn(); | |
| 328 }, | 359 }, |
| 329 | 360 |
| 330 /** | 361 /** |
| 331 * @param {!Event} event | 362 * @param {!Event} event |
| 332 */ | 363 */ |
| 333 _dataGridMouseDown: function(event) | 364 _dataGridMouseDown: function(event) |
| 334 { | 365 { |
| 335 if ((!this._dataGrid.selectedNode && event.button) || event.target.enclo singNodeOrSelfWithNodeName("a")) | 366 if ((!this._dataGrid.selectedNode && event.button) || event.target.enclo singNodeOrSelfWithNodeName("a")) |
| 336 event.consume(); | 367 event.consume(); |
| 337 }, | 368 }, |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 803 for (var i = 0; i < requestsToPick.length; ++i) { | 834 for (var i = 0; i < requestsToPick.length; ++i) { |
| 804 var request = requestsToPick[i]; | 835 var request = requestsToPick[i]; |
| 805 var node = this._nodesByRequestId.get(request.requestId); | 836 var node = this._nodesByRequestId.get(request.requestId); |
| 806 if (node) { | 837 if (node) { |
| 807 node.markAsNavigationRequest(); | 838 node.markAsNavigationRequest(); |
| 808 break; | 839 break; |
| 809 } | 840 } |
| 810 } | 841 } |
| 811 }, | 842 }, |
| 812 | 843 |
| 844 _createTimelineHeader: function() | |
| 845 { | |
| 846 this._timelineHeaderElement = this._timelineWidget.element.createChild(" div", "timelineHeader"); | |
|
alph
2016/10/08 01:35:09
we use dash-style for classes.
allada
2016/10/08 02:06:33
Done.
| |
| 847 this._timelineHeaderElement.addEventListener("click", timelineHeaderClic ked.bind(this)); | |
| 848 this._timelineHeaderElement.addEventListener("contextmenu", this._contex tMenu.bind(this)); | |
| 849 var innerElement = this._timelineHeaderElement.createChild("div"); | |
| 850 innerElement.textContent = WebInspector.UIString("Timeline"); | |
| 851 this._timelineColumnSortIcon = this._timelineHeaderElement.createChild(" div", "sort-order-icon-container").createChild("div", "sort-order-icon"); | |
| 852 | |
| 853 /** | |
| 854 * @this {WebInspector.NetworkLogView} | |
| 855 */ | |
| 856 function timelineHeaderClicked() | |
| 857 { | |
| 858 var sortOrders = WebInspector.DataGrid.Order; | |
| 859 var sortOrder = this._dataGrid.sortOrder() === sortOrders.Ascending ? sortOrders.Descending : sortOrders.Ascending; | |
|
alph
2016/10/08 01:35:09
s/g /g /
allada
2016/10/08 02:06:33
Done.
| |
| 860 this._dataGrid.markColumnAsSortedBy("timeline", sortOrder); | |
| 861 this._columns.sortByCurrentColumn(); | |
| 862 } | |
| 863 }, | |
| 864 | |
| 813 /** | 865 /** |
| 814 * @param {boolean} gridMode | 866 * @param {boolean} gridMode |
| 815 */ | 867 */ |
| 816 switchViewMode: function(gridMode) | 868 switchViewMode: function(gridMode) |
| 817 { | 869 { |
| 818 this._columns.switchViewMode(gridMode); | 870 this._columns.switchViewMode(gridMode); |
| 871 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline")) | |
| 872 return; | |
| 873 | |
| 874 if (gridMode && this._nodesByRequestId.size) | |
| 875 this._splitWidget.showBoth(); | |
| 876 else | |
| 877 this._splitWidget.hideMain(); | |
| 819 }, | 878 }, |
| 820 | 879 |
| 821 /** | 880 /** |
| 822 * @return {number} | 881 * @return {number} |
| 823 */ | 882 */ |
| 824 rowHeight: function() | 883 rowHeight: function() |
| 825 { | 884 { |
| 826 return this._rowHeight; | 885 return this._rowHeight; |
| 827 }, | 886 }, |
| 828 | 887 |
| 829 _updateRowsSize: function() | 888 _updateRowsSize: function() |
| 830 { | 889 { |
| 831 var largeRows = !!this._networkLogLargeRowsSetting.get(); | 890 var largeRows = !!this._networkLogLargeRowsSetting.get(); |
| 832 this._rowHeight = largeRows ? 41 : 21; | 891 this._rowHeight = largeRows ? 41 : 21; |
| 892 this._headerHeight = largeRows ? 31 : 27; | |
| 833 this._dataGrid.element.classList.toggle("small", !largeRows); | 893 this._dataGrid.element.classList.toggle("small", !largeRows); |
| 894 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) | |
| 895 this._timelineHeaderElement.classList.toggle("small", !largeRows); | |
| 834 this._dataGrid.scheduleUpdate(); | 896 this._dataGrid.scheduleUpdate(); |
| 835 }, | 897 }, |
| 836 | 898 |
| 837 /** | 899 /** |
| 838 * @param {!Event} event | 900 * @param {!Event} event |
| 839 */ | 901 */ |
| 840 _contextMenu: function(event) | 902 _contextMenu: function(event) |
| 841 { | 903 { |
| 842 // TODO(allada) Fix datagrid's contextmenu so NetworkLogViewColumns can attach it's own contextmenu event | 904 // TODO(allada) Fix datagrid's contextmenu so NetworkLogViewColumns can attach it's own contextmenu event |
| 843 if (this._columns.contextMenu(event)) | 905 if (this._columns.contextMenu(event)) |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1051 { | 1113 { |
| 1052 this.removeAllNodeHighlights(); | 1114 this.removeAllNodeHighlights(); |
| 1053 for (var i = 0; i < this._highlightedSubstringChanges.length; ++i) | 1115 for (var i = 0; i < this._highlightedSubstringChanges.length; ++i) |
| 1054 WebInspector.revertDomChanges(this._highlightedSubstringChanges[i]); | 1116 WebInspector.revertDomChanges(this._highlightedSubstringChanges[i]); |
| 1055 this._highlightedSubstringChanges = []; | 1117 this._highlightedSubstringChanges = []; |
| 1056 }, | 1118 }, |
| 1057 | 1119 |
| 1058 dataGridSorted: function() | 1120 dataGridSorted: function() |
| 1059 { | 1121 { |
| 1060 this._highlightNthMatchedRequestForSearch(this._updateMatchCountAndFindM atchIndex(this._currentMatchedRequestNode), false); | 1122 this._highlightNthMatchedRequestForSearch(this._updateMatchCountAndFindM atchIndex(this._currentMatchedRequestNode), false); |
| 1123 | |
| 1124 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline")) | |
| 1125 return; | |
| 1126 | |
| 1127 this._timelineColumnSortIcon.classList.remove("sort-ascending"); | |
|
alph
2016/10/08 01:35:09
nit: you can pass several classes in a single call
allada
2016/10/08 02:06:33
Done.
| |
| 1128 this._timelineColumnSortIcon.classList.remove("sort-descending"); | |
| 1129 if (this._dataGrid.sortColumnIdentifier() === "timeline") { | |
|
alph
2016/10/08 01:35:09
nit: we prefer early returns i.e. if (!...) return
allada
2016/10/08 02:06:33
Done.
| |
| 1130 if (this._dataGrid.sortOrder() === WebInspector.DataGrid.Order.Ascen ding) | |
| 1131 this._timelineColumnSortIcon.classList.add("sort-ascending"); | |
| 1132 else | |
| 1133 this._timelineColumnSortIcon.classList.add("sort-descending"); | |
| 1134 } | |
| 1061 }, | 1135 }, |
| 1062 | 1136 |
| 1063 /** | 1137 /** |
| 1064 * @param {number} n | 1138 * @param {number} n |
| 1065 * @param {boolean} reveal | 1139 * @param {boolean} reveal |
| 1066 */ | 1140 */ |
| 1067 _highlightNthMatchedRequestForSearch: function(n, reveal) | 1141 _highlightNthMatchedRequestForSearch: function(n, reveal) |
| 1068 { | 1142 { |
| 1069 this._removeAllHighlights(); | 1143 this._removeAllHighlights(); |
| 1070 | 1144 |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1739 * @return {boolean} | 1813 * @return {boolean} |
| 1740 */ | 1814 */ |
| 1741 WebInspector.NetworkLogView._requestTimeFilter = function(windowStart, windowEnd , request) | 1815 WebInspector.NetworkLogView._requestTimeFilter = function(windowStart, windowEnd , request) |
| 1742 { | 1816 { |
| 1743 if (request.issueTime() > windowEnd) | 1817 if (request.issueTime() > windowEnd) |
| 1744 return false; | 1818 return false; |
| 1745 if (request.endTime !== -1 && request.endTime < windowStart) | 1819 if (request.endTime !== -1 && request.endTime < windowStart) |
| 1746 return false; | 1820 return false; |
| 1747 return true; | 1821 return true; |
| 1748 } | 1822 } |
| OLD | NEW |