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

Unified Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/i_search.js

Issue 2621773003: Fix ISearch regressions (Closed)
Patch Set: Fix ISearch regressions Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/chromevox/cvox2/background/panel.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/i_search.js
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/i_search.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/i_search.js
index 74e9871a8bca4cbabf95e44f0fa93a2c8643bbb4..070ba0d68729ab99641e8a23ce740c2def35343a 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/i_search.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/i_search.js
@@ -45,15 +45,18 @@ ISearchHandler.prototype = {
/**
* Controls an incremental search.
- * @param {!AutomationNode} initialNode
+ * @param {!cursors.Cursor} cursor
* @constructor
*/
-ISearch = function(initialNode) {
+ISearch = function(cursor) {
+ if (!cursor.node)
+ throw 'Incremental search started from invalid range.';
+
var leaf = AutomationUtil.findNodePre(
- initialNode, Dir.FORWARD, AutomationPredicate.leaf) || initialNode;
+ cursor.node, Dir.FORWARD, AutomationPredicate.leaf) || cursor.node;
- /** @type {!AutomationNode} @private */
- this.node_ = leaf;
+ /** @type {!cursors.Cursor} */
+ this.cursor = cursors.Cursor.fromNode(leaf);
/**
* This tracks the id of a search that is in progress.
@@ -90,19 +93,19 @@ ISearch.prototype = {
cur =
cur.move(cursors.Unit.NODE, cursors.Movement.DIRECTIONAL, dir);
if (prev.equals(cur)) {
- this.handler_.onSearchReachedBoundary(this.node_);
+ this.handler_.onSearchReachedBoundary(this.cursor.node);
return;
}
if (cur.getText().toLocaleLowerCase().indexOf(searchStr) != -1) {
- this.node_ = cur.node;
- this.handler_.onSearchResultChanged(this.node_);
+ this.cursor = cur;
+ this.handler_.onSearchResultChanged(this.cursor.node);
return;
}
if (this.pendingSearchId_ == currentSearchId)
window.setTimeout(move.bind(this, cur.node), 0);
};
- window.setTimeout(move.bind(this, this.node_), 0);
+ window.setTimeout(move.bind(this, this.cursor.node), 0);
}
};
@@ -115,7 +118,7 @@ ISearchUI = function(input) {
/** @type {ChromeVoxState} @private */
this.background_ =
chrome.extension.getBackgroundPage()['ChromeVoxState']['instance'];
- this.iSearch_ = new ISearch(this.background_.currentRange.start.node);
+ this.iSearch_ = new ISearch(this.background_.currentRange.start);
this.input_ = input;
this.dir_ = Dir.FORWARD;
this.iSearch_.handler = this;
@@ -131,11 +134,16 @@ ISearchUI = function(input) {
* @param {Element} input
* @return {ISearchUI}
*/
-ISearchUI.get = function(input) {
+ISearchUI.init = function(input) {
if (ISearchUI.instance_)
ISearchUI.instance_.destroy();
+
+ if (!input)
+ return null;
+
ISearchUI.instance_ = new ISearchUI(input);
input.focus();
+ input.select();
return ISearchUI.instance_;
};
@@ -159,6 +167,14 @@ ISearchUI.prototype = {
return false;
case 'Enter':
this.pendingSearchId_ = 0;
+ Panel.setPendingCallback(function() {
+ var node = this.iSearch_.cursor.node;
+ if (!node)
+ return;
+ chrome.extension.getBackgroundPage().ChromeVoxState.instance[
+ 'navigateToRange'](
+ cursors.Range.fromNode(node));
+ }.bind(this));
Panel.closeMenusAndRestoreFocus();
return false;
default:
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/chromevox/cvox2/background/panel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698