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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 /** | 177 /** |
178 * @return {!Array.<!Element>} | 178 * @return {!Array.<!Element>} |
179 */ | 179 */ |
180 elementsToRestoreScrollPositionsFor: function() | 180 elementsToRestoreScrollPositionsFor: function() |
181 { | 181 { |
182 if (!this._dataGrid) // Not initialized yet. | 182 if (!this._dataGrid) // Not initialized yet. |
183 return []; | 183 return []; |
184 return [this._dataGrid.scrollContainer]; | 184 return [this._dataGrid.scrollContainer]; |
185 }, | 185 }, |
186 | 186 |
187 onResize: function() | |
188 { | |
189 this._updateOffscreenRows(); | |
190 }, | |
191 | |
192 _createTimelineGrid: function() | 187 _createTimelineGrid: function() |
193 { | 188 { |
194 this._timelineGrid = new WebInspector.TimelineGrid(); | 189 this._timelineGrid = new WebInspector.TimelineGrid(); |
195 this._timelineGrid.element.classList.add("network-timeline-grid"); | 190 this._timelineGrid.element.classList.add("network-timeline-grid"); |
196 this._dataGrid.element.appendChild(this._timelineGrid.element); | 191 this._dataGrid.element.appendChild(this._timelineGrid.element); |
197 }, | 192 }, |
198 | 193 |
199 _createTable: function() | 194 _createTable: function() |
200 { | 195 { |
201 var columns = []; | 196 var columns = []; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
318 this._dataGrid = new WebInspector.DataGrid(columns); | 313 this._dataGrid = new WebInspector.DataGrid(columns); |
319 this._dataGrid.setName("networkLog"); | 314 this._dataGrid.setName("networkLog"); |
320 this._dataGrid.resizeMethod = WebInspector.DataGrid.ResizeMethod.Last; | 315 this._dataGrid.resizeMethod = WebInspector.DataGrid.ResizeMethod.Last; |
321 this._dataGrid.element.classList.add("network-log-grid"); | 316 this._dataGrid.element.classList.add("network-log-grid"); |
322 this._dataGrid.element.addEventListener("contextmenu", this._contextMenu .bind(this), true); | 317 this._dataGrid.element.addEventListener("contextmenu", this._contextMenu .bind(this), true); |
323 this._dataGrid.show(this.element); | 318 this._dataGrid.show(this.element); |
324 | 319 |
325 // Event listeners need to be added _after_ we attach to the document, s o that owner document is properly update. | 320 // Event listeners need to be added _after_ we attach to the document, s o that owner document is properly update. |
326 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChan ged, this._sortItems, this); | 321 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChan ged, this._sortItems, this); |
327 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.ColumnsResi zed, this._updateDividersIfNeeded, this); | 322 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.ColumnsResi zed, this._updateDividersIfNeeded, this); |
328 this._dataGrid.scrollContainer.addEventListener("scroll", this._updateOf fscreenRows.bind(this)); | |
329 | 323 |
330 this._patchTimelineHeader(); | 324 this._patchTimelineHeader(); |
331 }, | 325 }, |
332 | 326 |
333 _makeHeaderFragment: function(title, subtitle) | 327 _makeHeaderFragment: function(title, subtitle) |
334 { | 328 { |
335 var fragment = document.createDocumentFragment(); | 329 var fragment = document.createDocumentFragment(); |
336 fragment.createTextChild(title); | 330 fragment.createTextChild(title); |
337 var subtitleDiv = fragment.createChild("div", "network-header-subtitle") ; | 331 var subtitleDiv = fragment.createChild("div", "network-header-subtitle") ; |
338 subtitleDiv.createTextChild(subtitle); | 332 subtitleDiv.createTextChild(subtitle); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
422 if (columnIdentifier === "timeline") { | 416 if (columnIdentifier === "timeline") { |
423 this._sortByTimeline(); | 417 this._sortByTimeline(); |
424 return; | 418 return; |
425 } | 419 } |
426 var sortingFunction = this._sortingFunctions[columnIdentifier]; | 420 var sortingFunction = this._sortingFunctions[columnIdentifier]; |
427 if (!sortingFunction) | 421 if (!sortingFunction) |
428 return; | 422 return; |
429 | 423 |
430 this._dataGrid.sortNodes(sortingFunction, !this._dataGrid.isSortOrderAsc ending()); | 424 this._dataGrid.sortNodes(sortingFunction, !this._dataGrid.isSortOrderAsc ending()); |
431 this._timelineSortSelector.selectedIndex = 0; | 425 this._timelineSortSelector.selectedIndex = 0; |
432 this._updateOffscreenRows(); | 426 this._updateRows(); |
433 | 427 |
434 this.searchCanceled(); | 428 this.searchCanceled(); |
435 | 429 |
436 WebInspector.notifications.dispatchEventToListeners(WebInspector.UserMet rics.UserAction, { | 430 WebInspector.notifications.dispatchEventToListeners(WebInspector.UserMet rics.UserAction, { |
437 action: WebInspector.UserMetrics.UserActionNames.NetworkSort, | 431 action: WebInspector.UserMetrics.UserActionNames.NetworkSort, |
438 column: columnIdentifier, | 432 column: columnIdentifier, |
439 sortOrder: this._dataGrid.sortOrder() | 433 sortOrder: this._dataGrid.sortOrder() |
440 }); | 434 }); |
441 }, | 435 }, |
442 | 436 |
443 _sortByTimeline: function() | 437 _sortByTimeline: function() |
444 { | 438 { |
445 this._removeAllNodeHighlights(); | 439 this._removeAllNodeHighlights(); |
446 var selectedIndex = this._timelineSortSelector.selectedIndex; | 440 var selectedIndex = this._timelineSortSelector.selectedIndex; |
447 if (!selectedIndex) | 441 if (!selectedIndex) |
448 selectedIndex = 1; // Sort by start time by default. | 442 selectedIndex = 1; // Sort by start time by default. |
449 var selectedOption = this._timelineSortSelector[selectedIndex]; | 443 var selectedOption = this._timelineSortSelector[selectedIndex]; |
450 var value = selectedOption.value; | 444 var value = selectedOption.value; |
451 | 445 |
452 var sortingFunction = this._sortingFunctions[value]; | 446 var sortingFunction = this._sortingFunctions[value]; |
453 this._dataGrid.sortNodes(sortingFunction); | 447 this._dataGrid.sortNodes(sortingFunction); |
454 this.calculator = this._calculators[value]; | 448 this.calculator = this._calculators[value]; |
455 if (this.calculator.startAtZero) | 449 if (this.calculator.startAtZero) |
456 this._timelineGrid.hideEventDividers(); | 450 this._timelineGrid.hideEventDividers(); |
457 else | 451 else |
458 this._timelineGrid.showEventDividers(); | 452 this._timelineGrid.showEventDividers(); |
459 this._dataGrid.markColumnAsSortedBy("timeline", WebInspector.DataGrid.Or der.Ascending); | 453 this._dataGrid.markColumnAsSortedBy("timeline", WebInspector.DataGrid.Or der.Ascending); |
460 this._updateOffscreenRows(); | 454 this._updateRows(); |
461 }, | 455 }, |
462 | 456 |
463 _createStatusBarItems: function() | 457 _createStatusBarItems: function() |
464 { | 458 { |
465 this._progressBarContainer = document.createElement("div"); | 459 this._progressBarContainer = document.createElement("div"); |
466 this._progressBarContainer.className = "status-bar-item"; | 460 this._progressBarContainer.className = "status-bar-item"; |
467 }, | 461 }, |
468 | 462 |
469 _updateSummaryBar: function() | 463 _updateSummaryBar: function() |
470 { | 464 { |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
905 if (!enabled) { | 899 if (!enabled) { |
906 this._largerRequestsButton.title = WebInspector.UIString("Use large resource rows."); | 900 this._largerRequestsButton.title = WebInspector.UIString("Use large resource rows."); |
907 this._dataGrid.element.classList.add("small"); | 901 this._dataGrid.element.classList.add("small"); |
908 this._timelineGrid.element.classList.add("small"); | 902 this._timelineGrid.element.classList.add("small"); |
909 } else { | 903 } else { |
910 this._largerRequestsButton.title = WebInspector.UIString("Use small resource rows."); | 904 this._largerRequestsButton.title = WebInspector.UIString("Use small resource rows."); |
911 this._dataGrid.element.classList.remove("small"); | 905 this._dataGrid.element.classList.remove("small"); |
912 this._timelineGrid.element.classList.remove("small"); | 906 this._timelineGrid.element.classList.remove("small"); |
913 } | 907 } |
914 this.dispatchEventToListeners(WebInspector.NetworkLogView.EventTypes.Row SizeChanged, { largeRows: enabled }); | 908 this.dispatchEventToListeners(WebInspector.NetworkLogView.EventTypes.Row SizeChanged, { largeRows: enabled }); |
915 this._updateOffscreenRows(); | |
916 }, | 909 }, |
917 | 910 |
918 _getPopoverAnchor: function(element) | 911 _getPopoverAnchor: function(element) |
919 { | 912 { |
920 if (!this._allowPopover) | 913 if (!this._allowPopover) |
921 return; | 914 return; |
922 var anchor = element.enclosingNodeOrSelfWithClass("network-graph-bar") | | element.enclosingNodeOrSelfWithClass("network-graph-label"); | 915 var anchor = element.enclosingNodeOrSelfWithClass("network-graph-bar") | | element.enclosingNodeOrSelfWithClass("network-graph-label"); |
923 if (anchor && anchor.parentElement.request && anchor.parentElement.reque st.timing) | 916 if (anchor && anchor.parentElement.request && anchor.parentElement.reque st.timing) |
924 return anchor; | 917 return anchor; |
925 anchor = element.enclosingNodeOrSelfWithClass("network-script-initiated" ); | 918 anchor = element.enclosingNodeOrSelfWithClass("network-script-initiated" ); |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1147 if (confirm(WebInspector.UIString("Are you sure you want to clear browse r cache?"))) | 1140 if (confirm(WebInspector.UIString("Are you sure you want to clear browse r cache?"))) |
1148 NetworkAgent.clearBrowserCache(); | 1141 NetworkAgent.clearBrowserCache(); |
1149 }, | 1142 }, |
1150 | 1143 |
1151 _clearBrowserCookies: function() | 1144 _clearBrowserCookies: function() |
1152 { | 1145 { |
1153 if (confirm(WebInspector.UIString("Are you sure you want to clear browse r cookies?"))) | 1146 if (confirm(WebInspector.UIString("Are you sure you want to clear browse r cookies?"))) |
1154 NetworkAgent.clearBrowserCookies(); | 1147 NetworkAgent.clearBrowserCookies(); |
1155 }, | 1148 }, |
1156 | 1149 |
1157 _updateOffscreenRows: function() | 1150 _updateRows: function() |
eustas
2014/03/26 04:46:48
This method could be eliminated totally by adding
pfeldman
2014/03/26 05:00:57
I don't think so - it is responsible for filtering
| |
1158 { | 1151 { |
1159 var dataTableBody = this._dataGrid.dataTableBody; | 1152 var dataTableBody = this._dataGrid.dataTableBody; |
1160 var rows = dataTableBody.children; | 1153 var rows = dataTableBody.children; |
1161 var recordsCount = rows.length; | 1154 var recordsCount = rows.length; |
1162 if (recordsCount < 2) | 1155 if (recordsCount < 2) |
1163 return; // Filler row only. | 1156 return; // Filler row only. |
1164 | 1157 |
1165 var visibleTop = this._dataGrid.scrollContainer.scrollTop; | |
1166 var visibleBottom = visibleTop + this._dataGrid.scrollContainer.offsetHe ight; | |
1167 | |
1168 var rowHeight = 0; | |
1169 | |
1170 // Filler is at recordsCount - 1. | 1158 // Filler is at recordsCount - 1. |
1171 var unfilteredRowIndex = 0; | 1159 var unfilteredRowIndex = 0; |
1172 for (var i = 0; i < recordsCount - 1; ++i) { | 1160 for (var i = 0; i < recordsCount - 1; ++i) { |
1173 var row = rows[i]; | 1161 var row = rows[i]; |
1174 | 1162 |
1175 var dataGridNode = this._dataGrid.dataGridNodeFromNode(row); | 1163 var dataGridNode = this._dataGrid.dataGridNodeFromNode(row); |
1176 if (dataGridNode.isFilteredOut()) { | 1164 if (dataGridNode.isFilteredOut()) { |
1177 row.classList.remove("offscreen"); | 1165 row.classList.remove("offscreen"); |
1178 continue; | 1166 continue; |
1179 } | 1167 } |
1180 | 1168 |
1181 if (!rowHeight) | |
1182 rowHeight = row.offsetHeight; | |
1183 | |
1184 var rowIsVisible = unfilteredRowIndex * rowHeight < visibleBottom && (unfilteredRowIndex + 1) * rowHeight > visibleTop; | |
1185 if (rowIsVisible !== row.rowIsVisible) { | |
1186 row.classList.toggle("offscreen", !rowIsVisible); | |
1187 row.rowIsVisible = rowIsVisible; | |
1188 } | |
1189 var rowIsOdd = !!(unfilteredRowIndex & 1); | 1169 var rowIsOdd = !!(unfilteredRowIndex & 1); |
1190 if (rowIsOdd !== row.rowIsOdd) { | 1170 if (rowIsOdd !== row.rowIsOdd) { |
1191 row.classList.toggle("odd", rowIsOdd); | 1171 row.classList.toggle("odd", rowIsOdd); |
1192 row.rowIsOdd = rowIsOdd; | 1172 row.rowIsOdd = rowIsOdd; |
1193 } | 1173 } |
1194 unfilteredRowIndex++; | 1174 unfilteredRowIndex++; |
1195 } | 1175 } |
1196 }, | 1176 }, |
1197 | 1177 |
1198 _matchRequest: function(request) | 1178 _matchRequest: function(request) |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1396 | 1376 |
1397 _filterRequests: function() | 1377 _filterRequests: function() |
1398 { | 1378 { |
1399 this._removeAllHighlights(); | 1379 this._removeAllHighlights(); |
1400 this._filteredOutRequests.clear(); | 1380 this._filteredOutRequests.clear(); |
1401 | 1381 |
1402 var nodes = this._dataGrid.rootNode().children; | 1382 var nodes = this._dataGrid.rootNode().children; |
1403 for (var i = 0; i < nodes.length; ++i) | 1383 for (var i = 0; i < nodes.length; ++i) |
1404 this._applyFilter(nodes[i]); | 1384 this._applyFilter(nodes[i]); |
1405 this._updateSummaryBar(); | 1385 this._updateSummaryBar(); |
1406 this._updateOffscreenRows(); | 1386 this._updateRows(); |
1407 }, | 1387 }, |
1408 | 1388 |
1409 jumpToPreviousSearchResult: function() | 1389 jumpToPreviousSearchResult: function() |
1410 { | 1390 { |
1411 if (!this._matchedRequests.length) | 1391 if (!this._matchedRequests.length) |
1412 return; | 1392 return; |
1413 this._highlightNthMatchedRequestForSearch((this._currentMatchedRequestIn dex + this._matchedRequests.length - 1) % this._matchedRequests.length, true); | 1393 this._highlightNthMatchedRequestForSearch((this._currentMatchedRequestIn dex + this._matchedRequests.length - 1) % this._matchedRequests.length, true); |
1414 }, | 1394 }, |
1415 | 1395 |
1416 jumpToNextSearchResult: function() | 1396 jumpToNextSearchResult: function() |
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2376 WebInspector.DataGridNode.call(this, {}); | 2356 WebInspector.DataGridNode.call(this, {}); |
2377 this._parentView = parentView; | 2357 this._parentView = parentView; |
2378 this._request = request; | 2358 this._request = request; |
2379 this._linkifier = new WebInspector.Linkifier(); | 2359 this._linkifier = new WebInspector.Linkifier(); |
2380 } | 2360 } |
2381 | 2361 |
2382 WebInspector.NetworkDataGridNode.prototype = { | 2362 WebInspector.NetworkDataGridNode.prototype = { |
2383 /** override */ | 2363 /** override */ |
2384 createCells: function() | 2364 createCells: function() |
2385 { | 2365 { |
2386 // Out of sight, out of mind: create nodes offscreen to save on render t ree update times when running updateOffscreenRows() | 2366 // Out of sight, out of mind: create nodes offscreen to save on render t ree update times when running updateOffscreenRows() |
alph
2014/03/25 22:07:24
Nuke it
pfeldman
2014/03/26 05:00:57
Done.
| |
2387 this._element.classList.add("offscreen"); | |
2388 this._nameCell = this._createDivInTD("name"); | 2367 this._nameCell = this._createDivInTD("name"); |
2389 this._methodCell = this._createDivInTD("method"); | 2368 this._methodCell = this._createDivInTD("method"); |
2390 this._statusCell = this._createDivInTD("status"); | 2369 this._statusCell = this._createDivInTD("status"); |
2391 this._schemeCell = this._createDivInTD("scheme"); | 2370 this._schemeCell = this._createDivInTD("scheme"); |
2392 this._domainCell = this._createDivInTD("domain"); | 2371 this._domainCell = this._createDivInTD("domain"); |
2393 this._remoteAddressCell = this._createDivInTD("remoteAddress"); | 2372 this._remoteAddressCell = this._createDivInTD("remoteAddress"); |
2394 this._typeCell = this._createDivInTD("type"); | 2373 this._typeCell = this._createDivInTD("type"); |
2395 this._initiatorCell = this._createDivInTD("initiator"); | 2374 this._initiatorCell = this._createDivInTD("initiator"); |
2396 this._cookiesCell = this._createDivInTD("cookies"); | 2375 this._cookiesCell = this._createDivInTD("cookies"); |
2397 this._setCookiesCell = this._createDivInTD("setCookies"); | 2376 this._setCookiesCell = this._createDivInTD("setCookies"); |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2896 WebInspector.NetworkDataGridNode.RequestPropertyComparator = function(propertyNa me, revert, a, b) | 2875 WebInspector.NetworkDataGridNode.RequestPropertyComparator = function(propertyNa me, revert, a, b) |
2897 { | 2876 { |
2898 var aValue = a._request[propertyName]; | 2877 var aValue = a._request[propertyName]; |
2899 var bValue = b._request[propertyName]; | 2878 var bValue = b._request[propertyName]; |
2900 if (aValue > bValue) | 2879 if (aValue > bValue) |
2901 return revert ? -1 : 1; | 2880 return revert ? -1 : 1; |
2902 if (bValue > aValue) | 2881 if (bValue > aValue) |
2903 return revert ? 1 : -1; | 2882 return revert ? 1 : -1; |
2904 return 0; | 2883 return 0; |
2905 } | 2884 } |
OLD | NEW |