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 7142a0e773bb4b22448e356ac01491c95241af20..1f3f614f456956e3267a7211d83ff11298e7050f 100644 |
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/cursors.js |
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/cursors.js |
@@ -445,9 +445,14 @@ cursors.Cursor.prototype = { |
var target = newNode.firstChild; |
var length = 0; |
while (target && length < newIndex) { |
- if (length <= newIndex && newIndex < (length + target.name.length)) |
+ var newLength = length + target.name.length; |
+ |
+ // Either |newIndex| falls between target's text or |newIndex| is the |
+ // total length of all sibling text content. |
+ if ((length <= newIndex && newIndex < newLength) || |
+ (newIndex == newLength && !target.nextSibling)) |
break; |
- length += target.name.length; |
+ length = newLength; |
target = target.nextSibling; |
} |
if (target) { |