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

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

Issue 2447773002: Use setSequentialFocusNavigationStartingPoint in ChromeVox (Closed)
Patch Set: Fix focusing too, with new test 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 6f30e143b6fdb635f46da820675d7670785e62e9..834fbbb6e809f137bcbfe65dc0b4b045eb21064e 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js
@@ -765,19 +765,39 @@ Background.prototype = {
var isFocusable = function(node) {
return node.role != RoleType.iframe &&
node.state.focusable &&
- !node.state.focused &&
!AutomationPredicate.structuralContainer(node);
};
+
+ // First, try to focus the start or end node.
if (isFocusable(start)) {
- start.focus();
+ if (!start.state.focused)
+ start.focus();
return;
- }
- if (isFocusable(end)) {
- end.focus();
+ } else if (isFocusable(end)) {
+ if (!end.state.focused)
+ end.focus();
return;
}
- // TODO(dmazzoni): Set sequential focus.
+ // Next, see if an ancestor of both |start| and |end| is focusable.
+ var startAncestors = AutomationUtil.getAncestors(start);
+ var endAncestors = AutomationUtil.getAncestors(end);
+ var commonAncestorCount = (start == end ? startAncestors.length :
+ AutomationUtil.getDivergence(startAncestors, endAncestors));
David Tseng 2016/10/27 01:09:50 As mentioned, AutomationUtil.getLeastCommonAncesto
dmazzoni 2016/10/27 06:27:27 Done.
+
+ for (var i = commonAncestorCount - 1; i >= 0; --i) {
David Tseng 2016/10/27 01:09:50 Thanks for doing this, but I don't really like the
dmazzoni 2016/10/27 03:59:25 OK, what if we limit it to just links, and text fi
dmazzoni 2016/10/27 06:27:27 Switched to just links within the same frame, that
+ var ancestor = startAncestors[i];
+ if (isFocusable(ancestor)) {
+ if (!ancestor.state.focused)
+ ancestor.focus();
+ return;
+ }
+ }
+
+ // 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