Chromium Code Reviews| Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js |
| diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js |
| index 229bb3862a1daf65f111da43cd8b04f96204c2ca..8656365412a1c507c87e91fcc6ea9018e93c51ef 100644 |
| --- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js |
| +++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js |
| @@ -638,10 +638,31 @@ Background.prototype = { |
| cvox.ChromeVox.tts.speak( |
| Msgs.getMsg('pass_through_key'), cvox.QueueMode.QUEUE); |
| return true; |
| - case 'openChromeVoxMenus': |
| + case 'toggleKeyboardHelp': |
| this.startExcursion(); |
| (new PanelCommand(PanelCommandType.OPEN_MENUS)).send(); |
| return false; |
| + case 'showHeadingsList': |
| + this.startExcursion(); |
| + (new PanelCommand(PanelCommandType.OPEN_MENUS, 'role_heading')).send(); |
| + return false; |
| + case 'showFormsList': |
| + this.startExcursion(); |
| + (new PanelCommand(PanelCommandType.OPEN_MENUS, 'role_form')).send(); |
| + return false; |
| + case 'showLandmarksList': |
| + this.startExcursion(); |
| + (new PanelCommand(PanelCommandType.OPEN_MENUS, 'role_landmark')).send(); |
| + return false; |
| + case 'showLinksList': |
| + this.startExcursion(); |
| + (new PanelCommand(PanelCommandType.OPEN_MENUS, 'role_link')).send(); |
| + return false; |
| + case 'showTablesList': |
| + this.startExcursion(); |
| + (new PanelCommand(PanelCommandType.OPEN_MENUS, 'table_strategy')) |
| + .send(); |
| + return false; |
| case 'toggleSearchWidget': |
| (new PanelCommand(PanelCommandType.SEARCH)).send(); |
| return false; |
| @@ -789,7 +810,7 @@ Background.prototype = { |
| } |
| if (current) |
| - this.navigateToRange_(current); |
| + this.navigateToRange(current); |
| return false; |
| }, |
| @@ -826,20 +847,24 @@ Background.prototype = { |
| /** |
| * Navigate to the given range - it both sets the range and outputs it. |
| * @param {!cursors.Range} range The new range. |
| + * @param {boolean=} opt_focus Focus the range; defaults to true. |
| * @private |
| */ |
| - navigateToRange_: function(range) { |
| - // TODO(dtseng): Figure out what it means to focus a range. |
| - var actionNode = range.start.node; |
| - if (actionNode.role == RoleType.inlineTextBox) |
| - actionNode = actionNode.parent; |
| - |
| - // Iframes, when focused, causes the child webArea to fire focus event. |
| - // This can result in getting stuck when navigating backward. |
| - if (actionNode.role != RoleType.iframe && !actionNode.state.focused && |
| - !AutomationPredicate.container(actionNode)) |
| - actionNode.focus(); |
| - |
| + navigateToRange: function(range, opt_focus) { |
| + opt_focus = opt_focus === undefined ? true : opt_focus; |
| + |
| + if (opt_focus) { |
| + // TODO(dtseng): Figure out what it means to focus a range. |
| + var actionNode = range.start.node; |
| + if (actionNode.role == RoleType.inlineTextBox) |
| + actionNode = actionNode.parent; |
| + |
| + // Iframes, when focused, causes the child webArea to fire focus event. |
| + // This can result in getting stuck when navigating backward. |
| + if (actionNode.role != RoleType.iframe && !actionNode.state.focused && |
| + !AutomationPredicate.container(actionNode)) |
| + actionNode.focus(); |
| + } |
| var prevRange = this.currentRange_; |
| this.setCurrentRange(range); |
| @@ -1040,9 +1065,10 @@ Background.prototype = { |
| /** |
| * Restore the range to the last range that was *not* in the ChromeVox |
| * panel. This is used when the ChromeVox Panel closes. |
| + * @param {function()=} opt_callback |
|
dmazzoni
2016/06/07 16:36:06
nit: indentation
David Tseng
2016/06/08 19:28:33
Done.
|
| * @private |
| */ |
| - restoreCurrentRange_: function() { |
| + restoreCurrentRange_: function(opt_callback) { |
| if (this.savedRange_) { |
| var node = this.savedRange_.start.node; |
| var containingWebView = node; |
| @@ -1054,14 +1080,16 @@ Background.prototype = { |
| // away from the saved range. |
| var saved = this.savedRange_; |
| var setSavedRange = function(e) { |
| - if (e.target.root == saved.start.node.root) |
| - this.navigateToRange_(saved); |
| + if (e.target.root == saved.start.node.root) { |
| + this.navigateToRange(saved, false); |
| + opt_callback && opt_callback(); |
| + } |
| node.root.removeEventListener(EventType.focus, setSavedRange, true); |
| }.bind(this); |
| node.root.addEventListener(EventType.focus, setSavedRange, true); |
| containingWebView.focus(); |
| } |
| - this.navigateToRange_(this.savedRange_); |
| + this.navigateToRange(this.savedRange_); |
| this.savedRange_ = null; |
| } |
| }, |
| @@ -1075,10 +1103,11 @@ Background.prototype = { |
| /** |
| * Move ChromeVox back to the last saved range. |
| + * @param {function()=} opt_callback Called when range has been restored. |
| */ |
| - endExcursion: function() { |
| + endExcursion: function(opt_callback) { |
| this.inExcursion_ = false; |
| - this.restoreCurrentRange_(); |
| + this.restoreCurrentRange_(opt_callback); |
| }, |
| /** |