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

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

Issue 1191783002: Support Compat mode inside of the desktop tree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@commands_alt
Patch Set: Resolve focus. Created 5 years, 6 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
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 8d988b54ca49e5997c65452d90f75533081629ee..64caa91fde5f09ac0da2a708a170a2c528adf36a 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js
@@ -61,7 +61,7 @@ Background = function() {
this.mode_ = ChromeVoxMode.CLASSIC;
/** @type {!ClassicCompatibility} @private */
- this.compat_ = new ClassicCompatibility(this.mode_ === ChromeVoxMode.COMPAT);
+ this.compat_ = new ClassicCompatibility();
// Manually bind all functions to |this|.
for (var func in this) {
@@ -87,8 +87,8 @@ Background = function() {
};
// Register listeners for ...
- // Desktop.
chrome.automation.getDesktop(this.onGotDesktop);
+ chrome.commands.onCommand.addListener(this.onGotCommand);
};
Background.prototype = {
@@ -127,18 +127,20 @@ Background.prototype = {
* @param {string} command
* @param {boolean=} opt_skipCompat Whether to skip compatibility checks.
*/
- onGotCommand: function(command, opt_skipCompat) {
+ onGotCommand: function(command, opt_skipCompat) {
+ if (this.mode_ === ChromeVoxMode.CLASSIC) {
+ if (this.compat_.onGotClassicCommand(command))
+ return;
+ }
+
if (!this.currentRange_)
return;
- if (!opt_skipCompat) {
+ if (!opt_skipCompat && this.mode_ === ChromeVoxMode.COMPAT) {
if (this.compat_.onGotCommand(command))
return;
}
- if (this.mode_ === ChromeVoxMode.CLASSIC)
- return;
-
var current = this.currentRange_;
var dir = Dir.FORWARD;
var pred = null;
@@ -328,10 +330,14 @@ Background.prototype = {
if (current) {
// TODO(dtseng): Figure out what it means to focus a range.
- current.getStart().getNode().focus();
+ var actionNode = current.getStart().getNode();
+ if (actionNode.role == chrome.automation.RoleType.inlineTextBox)
+ actionNode = actionNode.parent;
+ actionNode.focus();
var prevRange = this.currentRange_;
this.currentRange_ = current;
+
new Output().withSpeechAndBraille(
this.currentRange_, prevRange, Output.EventType.NAVIGATE)
.go();
@@ -352,8 +358,10 @@ Background.prototype = {
this.currentRange_ = cursors.Range.fromNode(node);
- // Check to see if we've crossed roots. Only care about focused roots.
- if (!prevRange ||
+ // Check to see if we've crossed roots. Continue if we've crossed roots or
+ // are not within web content.
+ if (node.root.role == 'desktop' ||
+ !prevRange ||
(prevRange.getStart().getNode().root != node.root &&
node.root.focused))
this.setupChromeVoxVariants_(node.root.docUrl || '');
@@ -365,6 +373,12 @@ Background.prototype = {
return;
}
+ // Don't output if focused node hasn't changed.
+ if (prevRange &&
+ evt.type == 'focus' &&
+ this.currentRange_.equals(prevRange))
+ return;
+
new Output().withSpeechAndBraille(
this.currentRange_, prevRange, evt.type)
.go();
@@ -512,7 +526,7 @@ Background.prototype = {
* @private
*/
isWhitelistedForCompat_: function(url) {
- return url.indexOf('chrome://md-settings') != -1;
+ return url.indexOf('chrome://md-settings') != -1 || url === '';
},
/**
@@ -532,14 +546,15 @@ Background.prototype = {
* @private
*/
setupChromeVoxVariants_: function(url) {
- this.compat_.active = this.isWhitelistedForCompat_(url);
var mode = this.mode_;
- if (this.compat_.active)
- mode = ChromeVoxMode.COMPAT;
- else if (this.isWhitelistedForNext_(url))
- mode = ChromeVoxMode.NEXT;
- else if (mode != ChromeVoxMode.FORCE_NEXT)
- mode = ChromeVoxMode.CLASSIC;
+ if (mode != ChromeVoxMode.FORCE_NEXT) {
+ if (this.isWhitelistedForCompat_(url))
+ mode = ChromeVoxMode.COMPAT;
+ else if (this.isWhitelistedForNext_(url))
+ mode = ChromeVoxMode.NEXT;
+ else
+ mode = ChromeVoxMode.CLASSIC;
+ }
this.setChromeVoxMode(mode);
},
@@ -560,16 +575,6 @@ Background.prototype = {
* @param {ChromeVoxMode} mode
*/
setChromeVoxMode: function(mode) {
- if (mode === ChromeVoxMode.NEXT ||
- mode === ChromeVoxMode.COMPAT ||
- mode === ChromeVoxMode.FORCE_NEXT) {
- if (!chrome.commands.onCommand.hasListener(this.onGotCommand))
- chrome.commands.onCommand.addListener(this.onGotCommand);
- } else {
- if (chrome.commands.onCommand.hasListener(this.onGotCommand))
- chrome.commands.onCommand.removeListener(this.onGotCommand);
- }
-
chrome.tabs.query({active: true}, function(tabs) {
if (mode === ChromeVoxMode.CLASSIC) {
// This case should do nothing because Classic gets injected by the
@@ -583,7 +588,6 @@ Background.prototype = {
}
}.bind(this));
- this.compat_.active = mode === ChromeVoxMode.COMPAT;
this.mode_ = mode;
}
};

Powered by Google App Engine
This is Rietveld 408576698