OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 * @fileoverview Objects related to incremental search. | 6 * @fileoverview Objects related to incremental search. |
7 */ | 7 */ |
8 | 8 |
9 goog.provide('ISearch'); | 9 goog.provide('ISearch'); |
10 goog.provide('ISearchHandler'); | 10 goog.provide('ISearchHandler'); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 */ | 81 */ |
82 search: function(searchStr, dir) { | 82 search: function(searchStr, dir) { |
83 searchStr = searchStr.toLocaleLowerCase(); | 83 searchStr = searchStr.toLocaleLowerCase(); |
84 // Keep things responsive by chunking cursor moves up into discrete | 84 // Keep things responsive by chunking cursor moves up into discrete |
85 // blocks. We can, if needed, simulate getting interrupted by the enter key. | 85 // blocks. We can, if needed, simulate getting interrupted by the enter key. |
86 var currentSearchId = ++this.pendingSearchId_; | 86 var currentSearchId = ++this.pendingSearchId_; |
87 var move = function(curNode) { | 87 var move = function(curNode) { |
88 var cur = cursors.Cursor.fromNode(curNode); | 88 var cur = cursors.Cursor.fromNode(curNode); |
89 var prev = cur; | 89 var prev = cur; |
90 cur = | 90 cur = |
91 cur.move(cursors.Unit.DOM_NODE, cursors.Movement.DIRECTIONAL, dir); | 91 cur.move(cursors.Unit.NODE, cursors.Movement.DIRECTIONAL, dir); |
92 if (prev.equals(cur)) { | 92 if (prev.equals(cur)) { |
93 this.handler_.onSearchReachedBoundary(this.node_); | 93 this.handler_.onSearchReachedBoundary(this.node_); |
94 return; | 94 return; |
95 } | 95 } |
96 | 96 |
97 if (cur.getText().toLocaleLowerCase().indexOf(searchStr) != -1) { | 97 if (cur.getText().toLocaleLowerCase().indexOf(searchStr) != -1) { |
98 this.node_ = cur.node; | 98 this.node_ = cur.node; |
99 this.handler_.onSearchResultChanged(this.node_); | 99 this.handler_.onSearchResultChanged(this.node_); |
100 return; | 100 return; |
101 } | 101 } |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 this.iSearch_.handler_ = null; | 216 this.iSearch_.handler_ = null; |
217 this.iSearch_ = null; | 217 this.iSearch_ = null; |
218 var input = this.input_; | 218 var input = this.input_; |
219 this.input_ = null; | 219 this.input_ = null; |
220 input.removeEventListener('keydown', this.onKeyDown, true); | 220 input.removeEventListener('keydown', this.onKeyDown, true); |
221 input.removeEventListener('textInput', this.onTextInput, true); | 221 input.removeEventListener('textInput', this.onTextInput, true); |
222 } | 222 } |
223 }; | 223 }; |
224 | 224 |
225 }); // goog.scope | 225 }); // goog.scope |
OLD | NEW |