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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/coverage/CoverageListView.js

Issue 2890863003: DevTools/Coverage: filter out content scripts (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/coverage/CoverageModel.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2017 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 Coverage.CoverageListView = class extends UI.VBox { 5 Coverage.CoverageListView = class extends UI.VBox {
6 constructor() { 6 /**
7 * @param {function(!Coverage.URLCoverageInfo):boolean} filterCallback
8 */
9 constructor(filterCallback) {
7 super(true); 10 super(true);
8 /** @type {!Map<!Coverage.URLCoverageInfo, !Coverage.CoverageListView.GridNo de>} */ 11 /** @type {!Map<!Coverage.URLCoverageInfo, !Coverage.CoverageListView.GridNo de>} */
9 this._nodeForCoverageInfo = new Map(); 12 this._nodeForCoverageInfo = new Map();
13 /** @type {function(!Coverage.URLCoverageInfo):boolean} */
alph 2017/05/18 01:02:31 no need to annotate
14 this._filterCallback = filterCallback;
10 /** @type {?RegExp} */ 15 /** @type {?RegExp} */
11 this._filterRegExp = null; 16 this._highlightRegExp = null;
12 this.registerRequiredCSS('coverage/coverageListView.css'); 17 this.registerRequiredCSS('coverage/coverageListView.css');
13 var columns = [ 18 var columns = [
14 {id: 'url', title: Common.UIString('URL'), width: '300px', fixedWidth: fal se, sortable: true}, 19 {id: 'url', title: Common.UIString('URL'), width: '250px', fixedWidth: fal se, sortable: true},
15 {id: 'type', title: Common.UIString('Type'), width: '45px', fixedWidth: tr ue, sortable: true}, { 20 {id: 'type', title: Common.UIString('Type'), width: '45px', fixedWidth: tr ue, sortable: true}, {
16 id: 'size', 21 id: 'size',
17 title: Common.UIString('Total Bytes'), 22 title: Common.UIString('Total Bytes'),
18 width: '60px', 23 width: '60px',
19 fixedWidth: true, 24 fixedWidth: true,
20 sortable: true, 25 sortable: true,
21 align: DataGrid.DataGrid.Align.Right 26 align: DataGrid.DataGrid.Align.Right
22 }, 27 },
23 { 28 {
24 id: 'unusedSize', 29 id: 'unusedSize',
25 title: Common.UIString('Unused Bytes'), 30 title: Common.UIString('Unused Bytes'),
26 width: '60px', 31 width: '100px',
27 fixedWidth: true, 32 fixedWidth: true,
28 sortable: true, 33 sortable: true,
29 align: DataGrid.DataGrid.Align.Right, 34 align: DataGrid.DataGrid.Align.Right,
30 sort: DataGrid.DataGrid.Order.Descending 35 sort: DataGrid.DataGrid.Order.Descending
31 }, 36 },
32 {id: 'bars', title: '', width: '500px', fixedWidth: false, sortable: true} 37 {id: 'bars', title: '', width: '250px', fixedWidth: false, sortable: true}
33 ]; 38 ];
34 this._dataGrid = new DataGrid.SortableDataGrid(columns); 39 this._dataGrid = new DataGrid.SortableDataGrid(columns);
35 this._dataGrid.setResizeMethod(DataGrid.DataGrid.ResizeMethod.Last); 40 this._dataGrid.setResizeMethod(DataGrid.DataGrid.ResizeMethod.Last);
36 this._dataGrid.element.classList.add('flex-auto'); 41 this._dataGrid.element.classList.add('flex-auto');
37 this._dataGrid.element.addEventListener('keydown', this._onKeyDown.bind(this ), false); 42 this._dataGrid.element.addEventListener('keydown', this._onKeyDown.bind(this ), false);
38 this._dataGrid.addEventListener(DataGrid.DataGrid.Events.OpenedNode, this._o nOpenedNode, this); 43 this._dataGrid.addEventListener(DataGrid.DataGrid.Events.OpenedNode, this._o nOpenedNode, this);
39 this._dataGrid.addEventListener(DataGrid.DataGrid.Events.SortingChanged, thi s._sortingChanged, this); 44 this._dataGrid.addEventListener(DataGrid.DataGrid.Events.SortingChanged, thi s._sortingChanged, this);
40 45
41 var dataGridWidget = this._dataGrid.asWidget(); 46 var dataGridWidget = this._dataGrid.asWidget();
42 dataGridWidget.show(this.contentElement); 47 dataGridWidget.show(this.contentElement);
43 } 48 }
44 49
45 /** 50 /**
46 * @param {!Array<!Coverage.URLCoverageInfo>} coverageInfo 51 * @param {!Array<!Coverage.URLCoverageInfo>} coverageInfo
47 */ 52 */
48 update(coverageInfo) { 53 update(coverageInfo) {
49 var hadUpdates = false; 54 var hadUpdates = false;
50 var maxSize = coverageInfo.reduce((acc, entry) => Math.max(acc, entry.size() ), 0); 55 var maxSize = coverageInfo.reduce((acc, entry) => Math.max(acc, entry.size() ), 0);
51 var rootNode = this._dataGrid.rootNode(); 56 var rootNode = this._dataGrid.rootNode();
52 for (var entry of coverageInfo) { 57 for (var entry of coverageInfo) {
53 var node = this._nodeForCoverageInfo.get(entry); 58 var node = this._nodeForCoverageInfo.get(entry);
54 if (node) { 59 if (node) {
55 if (this._isVisible(node)) 60 if (this._filterCallback(node._coverageInfo))
56 hadUpdates = node._refreshIfNeeded(maxSize) || hadUpdates; 61 hadUpdates = node._refreshIfNeeded(maxSize) || hadUpdates;
57 continue; 62 continue;
58 } 63 }
59 node = new Coverage.CoverageListView.GridNode(entry, maxSize); 64 node = new Coverage.CoverageListView.GridNode(entry, maxSize);
60 this._nodeForCoverageInfo.set(entry, node); 65 this._nodeForCoverageInfo.set(entry, node);
61 if (this._isVisible(node)) { 66 if (this._filterCallback(node._coverageInfo)) {
62 rootNode.appendChild(node); 67 rootNode.appendChild(node);
63 hadUpdates = true; 68 hadUpdates = true;
64 } 69 }
65 } 70 }
66 if (hadUpdates) 71 if (hadUpdates)
67 this._sortingChanged(); 72 this._sortingChanged();
68 } 73 }
69 74
70 reset() { 75 reset() {
71 this._nodeForCoverageInfo.clear(); 76 this._nodeForCoverageInfo.clear();
72 this._dataGrid.rootNode().removeChildren(); 77 this._dataGrid.rootNode().removeChildren();
73 } 78 }
74 79
75 /** 80 /**
76 * @param {?RegExp} regExp 81 * @param {?RegExp} highlightRegExp
77 */ 82 */
78 setFilter(regExp) { 83 updateFilterAndHighlight(highlightRegExp) {
79 this._filterRegExp = regExp; 84 this._highlightRegExp = highlightRegExp;
80 var hadTreeUpdates = false; 85 var hadTreeUpdates = false;
81 for (var node of this._nodeForCoverageInfo.values()) { 86 for (var node of this._nodeForCoverageInfo.values()) {
82 var shouldBeVisible = this._isVisible(node); 87 var shouldBeVisible = this._filterCallback(node._coverageInfo);
83 var isVisible = !!node.parent; 88 var isVisible = !!node.parent;
84 if (shouldBeVisible) 89 if (shouldBeVisible)
85 node._setHighlight(regExp); 90 node._setHighlight(this._highlightRegExp);
86 if (shouldBeVisible === isVisible) 91 if (shouldBeVisible === isVisible)
87 continue; 92 continue;
88 hadTreeUpdates = true; 93 hadTreeUpdates = true;
89 if (!shouldBeVisible) 94 if (!shouldBeVisible)
90 node.remove(); 95 node.remove();
91 else 96 else
92 this._dataGrid.rootNode().appendChild(node); 97 this._dataGrid.rootNode().appendChild(node);
93 } 98 }
94 if (hadTreeUpdates) 99 if (hadTreeUpdates)
95 this._sortingChanged(); 100 this._sortingChanged();
96 } 101 }
97 102
98 /** 103 /**
99 * @param {!Common.Event} event 104 * @param {!Common.Event} event
100 */ 105 */
101 _onOpenedNode(event) { 106 _onOpenedNode(event) {
102 var node = /** @type Coverage.CoverageListView.GridNode */ (event.data); 107 var node = /** @type Coverage.CoverageListView.GridNode */ (event.data);
103 this._revealSourceForNode(node); 108 this._revealSourceForNode(node);
104 } 109 }
105 110
106 /** 111 /**
107 * @param {!Coverage.CoverageListView.GridNode} node
108 * @return {boolean}
109 */
110 _isVisible(node) {
111 return !this._filterRegExp || this._filterRegExp.test(node._url);
112 }
113
114 /**
115 * @param {!Event} event 112 * @param {!Event} event
116 */ 113 */
117 _onKeyDown(event) { 114 _onKeyDown(event) {
118 if (!isEnterKey(event)) 115 if (!isEnterKey(event))
119 return; 116 return;
120 event.consume(true); 117 event.consume(true);
121 this._revealSourceForNode(this._dataGrid.selectedNode); 118 this._revealSourceForNode(this._dataGrid.selectedNode);
122 } 119 }
123 120
124 /** 121 /**
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 * @param {string} textContent 302 * @param {string} textContent
306 */ 303 */
307 _highlight(element, textContent) { 304 _highlight(element, textContent) {
308 var matches = this._highlightRegExp.exec(textContent); 305 var matches = this._highlightRegExp.exec(textContent);
309 if (!matches || !matches.length) 306 if (!matches || !matches.length)
310 return; 307 return;
311 var range = new TextUtils.SourceRange(matches.index, matches[0].length); 308 var range = new TextUtils.SourceRange(matches.index, matches[0].length);
312 UI.highlightRangesWithStyleClass(element, [range], 'filter-highlight'); 309 UI.highlightRangesWithStyleClass(element, [range], 'filter-highlight');
313 } 310 }
314 }; 311 };
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/coverage/CoverageModel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698