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

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

Issue 2164813003: Fix visible position calculation in accessible setSelection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert ChromeVox workaround and update test Created 4 years, 5 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/cursors.js
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/cursors.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/cursors.js
index 19c4bbd490e5777d0ae0d6d52376284c91cbc3f2..5d0eeb16de6dd19539a69ef6ac48035f18f6a6e0 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/cursors.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/cursors.js
@@ -165,29 +165,17 @@ cursors.Cursor.prototype = {
adjustedIndex += sibling.name.length;
sibling = sibling.previousSibling;
}
- }
- if (this.selectionNode_ && AutomationPredicate.text(this.selectionNode_)) {
// Work around Blink's somewhat unexpected offset calculation which
- // requires us to consider all previous siblings of the parenting node of
- // the static text.
-
- var parent = this.selectionNode_.parent;
- if (parent) {
- // Grab all of the text nodes and accumulate their lengths up to
- // but not including the current static text node.
- var texts = [];
- AutomationUtil.findNodePre(parent, Dir.FORWARD, function(node) {
- if (AutomationPredicate.text(node))
- texts.push(node);
- return false;
- });
-
- for (var i = 0; i < texts.length; i++) {
- if (texts[i] == this.selectionNode_)
- break;
-
- adjustedIndex += texts[i].name.length;
+ // requires us to consider all previous siblings of the parenting static
+ // text.
+ var parent = this.node.parent;
+ if (parent.role == RoleType.staticText) {
+ sibling = parent.previousSibling;
+ while (sibling) {
+ if (sibling.name)
+ adjustedIndex += sibling.name.length;
+ sibling = sibling.previousSibling;
}
}
} else if (this.index_ == cursors.NODE_INDEX) {
@@ -601,10 +589,19 @@ cursors.Range.prototype = {
if (!startNode || !endNode)
return;
- // Only allow selections inside of the same web tree.
- if (startNode.root &&
- startNode.root.role == RoleType.rootWebArea &&
- startNode.root === endNode.root) {
+ // Find the most common root.
+ var uniqueAncestors = AutomationUtil.getUniqueAncestors(startNode, endNode);
+ var mcr = startNode.root;
+ if (uniqueAncestors) {
+ var common = uniqueAncestors.pop().parent;
+ if (common)
+ mcr = common.root;
+ }
+
+ if (!mcr || mcr.role == RoleType.desktop)
+ return;
+
+ if (mcr === startNode.root && mcr === endNode.root) {
var startIndex = this.start.selectionIndex_;
// We want to adjust to select the entire node for node offsets;

Powered by Google App Engine
This is Rietveld 408576698