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 8b57e089303b6107dd79721e451e75429f5c7e74..48e2ac93ea6fb06bb75eb7a6e1d6046a7534e29e 100644 |
| --- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js |
| +++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js |
| @@ -771,20 +771,37 @@ Background.prototype = { |
| // backward. |
| var isFocusable = function(node) { |
| return node.role != RoleType.iframe && |
| + node.role != RoleType.rootWebArea && |
| 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. |
| + // 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) { |
|
David Tseng
2016/10/27 17:03:18
Counter example:
<a href="test">
<button>ok</bu
dmazzoni
2016/10/27 19:42:50
As discussed in person, NVDA behaves the same for
|
| + if (ancestor.role == RoleType.link && ancestor.state.focusable) { |
| + 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(); |
| } |
| }; |