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

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

Issue 2447773002: Use setSequentialFocusNavigationStartingPoint in ChromeVox (Closed)
Patch Set: Links or controls Created 4 years, 2 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 8b57e089303b6107dd79721e451e75429f5c7e74..db92e2e2b5a292d4403e12454d59703ca8014a2b 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js
@@ -766,25 +766,37 @@ Background.prototype = {
if (start.state.focused || end.state.focused)
return;
- // Iframes, when focused, causes the child webArea to fire focus
- // event. This can result in getting stuck when navigating
- // backward.
- var isFocusable = function(node) {
- return node.role != RoleType.iframe &&
- node.state.focusable &&
- !node.state.focused &&
- !AutomationPredicate.structuralContainer(node);
+ var isFocusableLinkOrControl = function(node) {
+ return node.state.focusable &&
+ AutomationPredicate.linkOrControl(node);
};
- if (isFocusable(start)) {
- start.focus();
+
+ // First, try to focus the start or end node.
+ if (isFocusableLinkOrControl(start)) {
+ if (!start.state.focused)
+ start.focus();
return;
- }
- if (isFocusable(end)) {
- end.focus();
+ } else if (isFocusableLinkOrControl(end)) {
+ if (!end.state.focused)
+ end.focus();
return;
}
- // TODO(dmazzoni): Set sequential focus.
+ // If a common ancestor of |start| and |end| is a link, focus that.
+ var ancestor = AutomationUtil.getLeastCommonAncestor(start, end);
+ while (ancestor && ancestor.root == start.root) {
+ if (isFocusableLinkOrControl(ancestor)) {
+ if (!ancestor.state.focused)
+ ancestor.focus();
+ return;
+ }
+ ancestor = ancestor.parent;
+ }
+
+ // If nothing is focusable, set the sequential focus navigation starting
+ // point, which ensures that the next time you press Tab, you'll reach
+ // the next or previous focusable node from |start|.
+ start.setSequentialFocusNavigationStartingPoint();
}
};

Powered by Google App Engine
This is Rietveld 408576698