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

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

Issue 2153213002: Better work around for Blink selection issues. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Handle line breaks. 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 b855f90952ceefe7645cd876159344e5175d1d11..a438d5cf6f64c71975c849abda70849865f68114 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/cursors.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/cursors.js
@@ -165,17 +165,29 @@ 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 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;
+ // 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;
}
}
} else if (this.index_ == cursors.NODE_INDEX) {
@@ -588,19 +600,10 @@ cursors.Range.prototype = {
if (!startNode || !endNode)
return;
- // 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) {
+ // Only allow selections inside of the same web tree.
+ if (startNode.root &&
+ startNode.root.role == RoleType.rootWebArea &&
+ startNode.root === 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