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 11f093d1bbdae929bd9b380901ba0a93dca422e4..a40e3ebaf3e95a05c1f30f60e52b5dbb23475ca3 100644 |
| --- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js |
| +++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js |
| @@ -17,6 +17,7 @@ goog.require('LiveRegions'); |
| goog.require('NextEarcons'); |
| goog.require('Output'); |
| goog.require('Output.EventType'); |
| +goog.require('PanelCommand'); |
| goog.require('constants'); |
| goog.require('cursors.Cursor'); |
| goog.require('cvox.BrailleKeyCommand'); |
| @@ -63,6 +64,12 @@ Background = function() { |
| this.currentRange_ = null; |
| /** |
| + * @type {cursors.Range} |
| + * @private |
| + */ |
| + this.savedRange_ = null; |
| + |
| + /** |
| * Which variant of ChromeVox is active. |
| * @type {ChromeVoxMode} |
| * @private |
| @@ -184,6 +191,13 @@ Background.prototype = { |
| cvox.ChromeVox.earcons.cancelEarcon(cvox.Earcon.PAGE_START_LOADING); |
| } |
| + if (mode === ChromeVoxMode.NEXT || |
| + mode === ChromeVoxMode.FORCE_NEXT) { |
| + (new PanelCommand(PanelCommandType.ENABLE_MENUS)).send(); |
| + } else { |
| + (new PanelCommand(PanelCommandType.DISABLE_MENUS)).send(); |
| + } |
| + |
| this.mode_ = mode; |
| }, |
| @@ -225,6 +239,11 @@ Background.prototype = { |
| if (!newRange) |
| return; |
| + var panelUrl = chrome.extension.getURL('cvox2/background/panel.html'); |
| + if (newRange.start.node.root.docUrl.indexOf(panelUrl) != 0) { |
| + this.savedRange_ = new cursors.Range(newRange.start, newRange.end); |
| + } |
| + |
| this.currentRange_ = newRange; |
| if (this.currentRange_) |
| @@ -285,12 +304,12 @@ Background.prototype = { |
| pred = AutomationPredicate.button; |
| predErrorMsg = 'no_previous_button'; |
| break; |
| - case 'nextCheckBox': |
| + case 'nextCheckbox': |
| dir = Dir.FORWARD; |
| pred = AutomationPredicate.checkBox; |
| predErrorMsg = 'no_next_checkbox'; |
| break; |
| - case 'previousCheckBox': |
| + case 'previousCheckbox': |
| dir = Dir.BACKWARD; |
| pred = AutomationPredicate.checkBox; |
| predErrorMsg = 'no_previous_checkbox'; |
| @@ -366,14 +385,14 @@ Background.prototype = { |
| predErrorMsg = 'no_previous_visited_link'; |
| break; |
| case 'right': |
| - case 'nextElement': |
| + case 'nextObject': |
| current = current.move(cursors.Unit.DOM_NODE, Dir.FORWARD); |
| break; |
| case 'left': |
| - case 'previousElement': |
| + case 'previousObject': |
| current = current.move(cursors.Unit.DOM_NODE, Dir.BACKWARD); |
| break; |
| - case 'goToBeginning': |
| + case 'jumpToTop': |
| var node = |
| AutomationUtil.findNodePost(current.start.node.root, |
| Dir.FORWARD, |
| @@ -390,7 +409,7 @@ Background.prototype = { |
| current = cursors.Range.fromNode(node); |
| break; |
| case 'forceClickOnCurrentItem': |
| - case 'doDefault': |
| + case 'performDefaultAction': |
| if (this.currentRange_) { |
| var actionNode = this.currentRange_.start.node; |
| if (actionNode.role == RoleType.inlineTextBox) |
| @@ -400,7 +419,7 @@ Background.prototype = { |
| // Skip all other processing; if focus changes, we should get an event |
| // for that. |
| return false; |
| - case 'continuousRead': |
| + case 'readFromHere': |
| global.isReadingContinuously = true; |
| var continueReading = function(prevRange) { |
| if (!global.isReadingContinuously || !this.currentRange_) |
| @@ -420,7 +439,7 @@ Background.prototype = { |
| continueReading(null); |
| return false; |
| - case 'showContextMenu': |
| + case 'contextMenu': |
| if (this.currentRange_) { |
| var actionNode = this.currentRange_.start.node; |
| if (actionNode.role == RoleType.inlineTextBox) |
| @@ -464,6 +483,32 @@ Background.prototype = { |
| cvox.ChromeVoxBackground.setPref('sticky', |
| !cvox.ChromeVox.isStickyPrefOn, |
| true); |
| + case 'openChromeVoxMenus': |
| + (new PanelCommand(PanelCommandType.OPEN_MENUS)).send(); |
| + break; |
| + case 'decreaseTtsRate': |
| + cvox.ChromeVox.tts.increaseOrDecreaseProperty( |
| + cvox.AbstractTts.RATE, false); |
| + break; |
|
David Tseng
2016/01/08 21:39:32
Needs to announce the percentage (same with all of
dmazzoni
2016/01/11 22:04:06
Done.
|
| + case 'increaseTtsRate': |
| + cvox.ChromeVox.tts.increaseOrDecreaseProperty( |
| + cvox.AbstractTts.RATE, true); |
| + break; |
| + case 'decreaseTtsPitch': |
| + cvox.ChromeVox.tts.increaseOrDecreaseProperty( |
| + cvox.AbstractTts.PITCH, false); |
| + break; |
| + case 'increaseTtsPitch': |
| + cvox.ChromeVox.tts.increaseOrDecreaseProperty( |
| + cvox.AbstractTts.PITCH, true); |
| + break; |
| + case 'decreaseTtsVolume': |
| + cvox.ChromeVox.tts.increaseOrDecreaseProperty( |
| + cvox.AbstractTts.VOLUME, false); |
| + break; |
| + case 'increaseTtsVolume': |
| + cvox.ChromeVox.tts.increaseOrDecreaseProperty( |
| + cvox.AbstractTts.VOLUME, true); |
| break; |
| default: |
| return true; |
| @@ -484,23 +529,29 @@ Background.prototype = { |
| } |
| } |
| - if (current) { |
| - // TODO(dtseng): Figure out what it means to focus a range. |
| - var actionNode = current.start.node; |
| - if (actionNode.role == RoleType.inlineTextBox) |
| - actionNode = actionNode.parent; |
| - actionNode.focus(); |
| + if (current) |
| + this.navigateToRange_(current); |
| - var prevRange = this.currentRange_; |
| - this.setCurrentRange(current); |
| + return false; |
| + }, |
| - new Output().withSpeechAndBraille( |
| - this.currentRange_, prevRange, Output.EventType.NAVIGATE) |
| - .withQueueMode(cvox.QueueMode.FLUSH) |
| - .go(); |
| - } |
| + /** |
| + * Navigate to the given range - it both sets the range and outputs it. |
| + * @param {!cursors.Range} range The new range. |
| + * @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; |
| + actionNode.focus(); |
| - return false; |
| + var prevRange = this.currentRange_; |
| + this.setCurrentRange(range); |
| + |
| + new Output().withSpeechAndBraille( |
| + range, prevRange, Output.EventType.NAVIGATE).go(); |
| }, |
| /** |
| @@ -539,10 +590,10 @@ Background.prototype = { |
| switch (evt.command) { |
| case cvox.BrailleKeyCommand.PAN_LEFT: |
| - this.onGotCommand('previousElement'); |
| + this.onGotCommand('previousObject'); |
| break; |
| case cvox.BrailleKeyCommand.PAN_RIGHT: |
| - this.onGotCommand('nextElement'); |
| + this.onGotCommand('nextObject'); |
| break; |
| case cvox.BrailleKeyCommand.LINE_UP: |
| this.onGotCommand('previousLine'); |
| @@ -551,10 +602,10 @@ Background.prototype = { |
| this.onGotCommand('nextLine'); |
| break; |
| case cvox.BrailleKeyCommand.TOP: |
| - this.onGotCommand('goToBeginning'); |
| + this.onGotCommand('jumpToTop'); |
| break; |
| case cvox.BrailleKeyCommand.BOTTOM: |
| - this.onGotCommand('goToEnd'); |
| + this.onGotCommand('jumpToBottom'); |
| break; |
| case cvox.BrailleKeyCommand.ROUTING: |
| this.brailleRoutingCommand_( |
| @@ -660,7 +711,25 @@ Background.prototype = { |
| } |
| break; |
| } |
| - } |
| + }, |
| + |
| + /** |
| + * |
|
David Tseng
2016/01/08 21:39:32
?
dmazzoni
2016/01/11 22:04:06
Done.
|
| + */ |
| + restoreCurrentRange: function() { |
| + if (this.savedRange_) { |
| + var containingWindow = this.savedRange_.start.node; |
|
David Tseng
2016/01/08 21:39:32
Rename to containingWebView?
dmazzoni
2016/01/11 22:04:06
Done.
|
| + while (containingWindow && containingWindow.role != RoleType.webView) { |
| + containingWindow = containingWindow.parent; |
| + } |
| + if (containingWindow) { |
|
David Tseng
2016/01/08 21:39:32
nit: remove braces
dmazzoni
2016/01/11 22:04:06
Done.
|
| + containingWindow.focus(); |
| + } |
| + |
| + this.navigateToRange_(this.savedRange_); |
| + this.savedRange_ = null; |
| + } |
| + }, |
| }; |
| /** |