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

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

Issue 2888843002: DevTools: fix race when revealing formatted source code (Closed)
Patch Set: rebased 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
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 /** 6 /**
7 * @param {function(!Coverage.URLCoverageInfo):boolean} filterCallback 7 * @param {function(!Coverage.URLCoverageInfo):boolean} filterCallback
8 */ 8 */
9 constructor(filterCallback) { 9 constructor(filterCallback) {
10 super(true); 10 super(true);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 hadTreeUpdates = true; 92 hadTreeUpdates = true;
93 if (!shouldBeVisible) 93 if (!shouldBeVisible)
94 node.remove(); 94 node.remove();
95 else 95 else
96 this._dataGrid.rootNode().appendChild(node); 96 this._dataGrid.rootNode().appendChild(node);
97 } 97 }
98 if (hadTreeUpdates) 98 if (hadTreeUpdates)
99 this._sortingChanged(); 99 this._sortingChanged();
100 } 100 }
101 101
102 /** 102 _onOpenedNode() {
103 * @param {!Common.Event} event 103 this._revealSourceForSelectedNode();
104 */
105 _onOpenedNode(event) {
106 var node = /** @type Coverage.CoverageListView.GridNode */ (event.data);
107 this._revealSourceForNode(node);
108 } 104 }
109 105
110 /** 106 /**
111 * @param {!Event} event 107 * @param {!Event} event
112 */ 108 */
113 _onKeyDown(event) { 109 _onKeyDown(event) {
114 if (!isEnterKey(event)) 110 if (!isEnterKey(event))
115 return; 111 return;
116 event.consume(true); 112 event.consume(true);
117 this._revealSourceForNode(this._dataGrid.selectedNode); 113 this._revealSourceForSelectedNode();
118 } 114 }
119 115
120 /** 116 async _revealSourceForSelectedNode() {
121 * @param {?DataGrid.DataGridNode} node 117 var node = this._dataGrid.selectedNode;
122 */
123 async _revealSourceForNode(node) {
124 if (!node) 118 if (!node)
125 return; 119 return;
126 var coverageInfo = /** @type {!Coverage.CoverageListView.GridNode} */ (node) ._coverageInfo; 120 var coverageInfo = /** @type {!Coverage.CoverageListView.GridNode} */ (node) ._coverageInfo;
127 var sourceCode = Workspace.workspace.uiSourceCodeForURL(coverageInfo.url()); 121 var sourceCode = Workspace.workspace.uiSourceCodeForURL(coverageInfo.url());
128 if (!sourceCode) 122 if (!sourceCode)
129 return; 123 return;
130 var content = await sourceCode.requestContent(); 124 var content = await sourceCode.requestContent();
131 if (TextUtils.isMinified(content)) { 125 if (TextUtils.isMinified(content)) {
132 var formatData = await Sources.sourceFormatter.format(sourceCode); 126 var formatData = await Sources.sourceFormatter.format(sourceCode);
133 Common.Revealer.reveal(formatData.formattedSourceCode); 127 // ------------ ASYNC ------------
134 } else { 128 sourceCode = formatData.formattedSourceCode;
135 Common.Revealer.reveal(sourceCode);
136 } 129 }
130 if (this._dataGrid.selectedNode !== node)
131 return;
132 Common.Revealer.reveal(sourceCode);
137 } 133 }
138 134
139 _sortingChanged() { 135 _sortingChanged() {
140 var columnId = this._dataGrid.sortColumnId(); 136 var columnId = this._dataGrid.sortColumnId();
141 if (!columnId) 137 if (!columnId)
142 return; 138 return;
143 var sortFunction; 139 var sortFunction;
144 switch (columnId) { 140 switch (columnId) {
145 case 'url': 141 case 'url':
146 sortFunction = compareURL; 142 sortFunction = compareURL;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 * @param {string} textContent 297 * @param {string} textContent
302 */ 298 */
303 _highlight(element, textContent) { 299 _highlight(element, textContent) {
304 var matches = this._highlightRegExp.exec(textContent); 300 var matches = this._highlightRegExp.exec(textContent);
305 if (!matches || !matches.length) 301 if (!matches || !matches.length)
306 return; 302 return;
307 var range = new TextUtils.SourceRange(matches.index, matches[0].length); 303 var range = new TextUtils.SourceRange(matches.index, matches[0].length);
308 UI.highlightRangesWithStyleClass(element, [range], 'filter-highlight'); 304 UI.highlightRangesWithStyleClass(element, [range], 'filter-highlight');
309 } 305 }
310 }; 306 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698