OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /** | 5 /** |
6 * @unrestricted | 6 * @unrestricted |
7 * @implements {UI.Searchable} | 7 * @implements {UI.Searchable} |
8 */ | 8 */ |
9 Timeline.TimelineTreeView = class extends UI.VBox { | 9 Timeline.TimelineTreeView = class extends UI.VBox { |
10 constructor() { | 10 constructor() { |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 * @override | 376 * @override |
377 * @param {!UI.SearchableView.SearchConfig} searchConfig | 377 * @param {!UI.SearchableView.SearchConfig} searchConfig |
378 * @param {boolean} shouldJump | 378 * @param {boolean} shouldJump |
379 * @param {boolean=} jumpBackwards | 379 * @param {boolean=} jumpBackwards |
380 */ | 380 */ |
381 performSearch(searchConfig, shouldJump, jumpBackwards) { | 381 performSearch(searchConfig, shouldJump, jumpBackwards) { |
382 this._searchResults = []; | 382 this._searchResults = []; |
383 this._currentResult = 0; | 383 this._currentResult = 0; |
384 if (!this._root) | 384 if (!this._root) |
385 return; | 385 return; |
386 this.populateSearchResults(createPlainTextSearchRegex(searchConfig.query, 'i
')); | 386 var searchRegex = createPlainTextSearchRegex(searchConfig.query, 'i'); |
| 387 this._searchResults = |
| 388 this._root.searchTree(event => Timeline.TimelineUIUtils.testContentMatch
ing(event, searchRegex)); |
| 389 this._searchableView.updateSearchMatchesCount(this._searchResults.length); |
387 } | 390 } |
388 | 391 |
389 /** | 392 /** |
390 * @protected | |
391 * @param {!RegExp} searchRegex | |
392 */ | |
393 populateSearchResults(searchRegex) { | |
394 var searchResults = []; | |
395 searchTree(this._root); | |
396 this._searchableView.updateSearchMatchesCount(searchResults.length); | |
397 this._searchResults = searchResults; | |
398 | |
399 function searchTree(node) { | |
400 if (node.event && Timeline.TimelineUIUtils.testContentMatching(node.event,
searchRegex)) | |
401 searchResults.push(node); | |
402 for (var child of node.children().values()) | |
403 searchTree(child); | |
404 } | |
405 } | |
406 | |
407 /** | |
408 * @override | 393 * @override |
409 */ | 394 */ |
410 jumpToNextSearchResult() { | 395 jumpToNextSearchResult() { |
411 if (!this._searchResults.length) | 396 if (!this._searchResults.length) |
412 return; | 397 return; |
413 this.selectProfileNode(this._searchResults[this._currentResult], false); | 398 this.selectProfileNode(this._searchResults[this._currentResult], false); |
414 this._currentResult = mod(this._currentResult + 1, this._searchResults.lengt
h); | 399 this._currentResult = mod(this._currentResult + 1, this._searchResults.lengt
h); |
415 } | 400 } |
416 | 401 |
417 /** | 402 /** |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 | 940 |
956 _onSelectionChanged() { | 941 _onSelectionChanged() { |
957 this.dispatchEventToListeners(Timeline.TimelineStackView.Events.SelectionCha
nged); | 942 this.dispatchEventToListeners(Timeline.TimelineStackView.Events.SelectionCha
nged); |
958 } | 943 } |
959 }; | 944 }; |
960 | 945 |
961 /** @enum {symbol} */ | 946 /** @enum {symbol} */ |
962 Timeline.TimelineStackView.Events = { | 947 Timeline.TimelineStackView.Events = { |
963 SelectionChanged: Symbol('SelectionChanged') | 948 SelectionChanged: Symbol('SelectionChanged') |
964 }; | 949 }; |
OLD | NEW |