Commit 2ff29563 authored by dtseng's avatar dtseng Committed by Commit bot

Fix editable text selection

We need to special-case setting selections when the focused node is itself editable.
- make no adjustments for the selected node; placing selection outside of the editable content causes key presses to go to the page
- if we are trying to select the entire node, set the selection index to 0 (placing selection at the beginning of the node); otherwise, use the character offset

TEST=move to a text field or content editable via ChromeVox commands; verify typing works to echo the keys. Furthermore, verify that in a content editable with headings, links, etc, jump commands move the selection. Finally, verify ChromeVox text movement commands (e.g. next character), moves selection in single line editables.
BUG=656349,658045
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2442503008
Cr-Commit-Position: refs/heads/master@{#427106}
parent 79eb040c
...@@ -166,6 +166,10 @@ cursors.Cursor.prototype = { ...@@ -166,6 +166,10 @@ cursors.Cursor.prototype = {
if (!adjustedNode) if (!adjustedNode)
return null; return null;
// Make no adjustments if we're within editable content.
if (adjustedNode.state.editable)
return adjustedNode;
// Selections over line break nodes are broken. // Selections over line break nodes are broken.
var parent = adjustedNode.parent; var parent = adjustedNode.parent;
var grandparent = parent && parent.parent; var grandparent = parent && parent.parent;
...@@ -197,8 +201,13 @@ cursors.Cursor.prototype = { ...@@ -197,8 +201,13 @@ cursors.Cursor.prototype = {
get selectionIndex_() { get selectionIndex_() {
var adjustedIndex = this.index_; var adjustedIndex = this.index_;
// Selecting things under a line break is currently broken. if (!this.node)
if (this.node.role == RoleType.inlineTextBox && return -1;
if (this.node.state.editable) {
return this.index_ == cursors.NODE_INDEX ? 0 : this.index_;
} else if (this.node.role == RoleType.inlineTextBox &&
// Selections under a line break are broken.
this.node.parent && this.node.parent.role != RoleType.lineBreak) { this.node.parent && this.node.parent.role != RoleType.lineBreak) {
if (adjustedIndex == cursors.NODE_INDEX) if (adjustedIndex == cursors.NODE_INDEX)
adjustedIndex = 0; adjustedIndex = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment