3 Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file.
8 <link rel="import" href="/tracing/filter.html">
9 <link rel="import" href="/tracing/selection.html">
15 * @fileoverview FindController.
17 tvcm.exportTo('tracing', function() {
18 function FindController() {
19 this.timeline_ = undefined;
20 this.model_ = undefined;
21 this.filterText_ = '';
22 this.filterHits_ = new tracing.Selection();
23 this.filterHitsDirty_ = true;
24 this.currentHitIndex_ = -1;
27 FindController.prototype = {
28 __proto__: Object.prototype,
31 return this.timeline_;
36 this.filterHitsDirty_ = true;
40 return this.filterText_;
44 if (f == this.filterText_)
47 this.filterHitsDirty_ = true;
52 this.timeline.setHighlightAndClearSelection(this.filterHits);
56 if (this.filterHitsDirty_) {
57 this.filterHitsDirty_ = false;
58 this.filterHits_ = new tracing.Selection();
59 this.currentHitIndex_ = -1;
61 if (this.timeline_ && this.filterText.length) {
62 var filter = new tracing.TitleFilter(this.filterText);
63 this.timeline.addAllObjectsMatchingFilterToSelection(
64 filter, this.filterHits_);
67 return this.filterHits_;
70 get currentHitIndex() {
71 return this.currentHitIndex_;
74 find_: function(dir) {
75 var firstHit = this.currentHitIndex_ === -1;
76 if (firstHit && dir < 0)
77 this.currentHitIndex_ = 0;
79 var N = this.filterHits.length;
80 this.currentHitIndex_ = (this.currentHitIndex_ + dir + N) % N;
85 this.timeline.selection =
86 this.filterHits.subSelection(this.currentHitIndex_, 1);
89 findNext: function() {
93 findPrevious: function() {
98 this.filterText_ = '';
99 this.filterHitsDirty_ = true;
104 FindController: FindController