Commit d2c5a96b authored by David Tseng's avatar David Tseng Committed by Commit Bot

Fixes navigation out of multiline editables

Fixed: 1024950

Change-Id: I3ee9108056c70956c3777702ba55c6af5f31640f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2082318
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: default avatarAkihiro Ota <akihiroota@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748050}
parent 6a3e1c15
......@@ -2411,3 +2411,41 @@ TEST_F('ChromeVoxBackgroundTest', 'NoFocusTalkBackEnabled', function() {
mockFeedback.replay();
});
});
TEST_F('ChromeVoxBackgroundTest', 'NavigateOutOfMultiline', function() {
const mockFeedback = this.createMockFeedback();
this.runWithLoadedTree(
`
<p>start</p>
<p>before</p>
<div role="textbox" contenteditable>
Testing testing<br>
one two three
</div>
<p>after</p>
`,
function(root) {
const textField = root.find({role: RoleType.TEXT_FIELD});
mockFeedback.call(textField.focus.bind(textField))
.expectSpeech('Testing testing\none two three')
.expectSpeech('Edit text')
.call(doCmd('nextLine'))
.expectSpeech('one two three')
.call(doCmd('nextLine'))
.expectSpeech('after')
// In reverse (explicitly focus, instead of moving to previous line,
// because all subsequent commands require the text field be focused
// first):
.clearPendingOutput()
.call(textField.focus.bind(textField))
.expectSpeech('Edit text')
.call(doCmd('nextLine'))
.expectSpeech('one two three')
.call(doCmd('previousLine'))
.expectSpeech('Testing testing')
.call(doCmd('previousLine'))
.expectSpeech('before')
.replay();
});
});
......@@ -279,16 +279,16 @@ CommandHandler.onCommand = function(command) {
return true;
}
let current = ChromeVoxState.instance.currentRange;
// If true, will check if the predicate matches the current node.
let matchCurrent = false;
// Allow edit commands first.
if (!CommandHandler.onEditCommand_(command)) {
return false;
}
let current = ChromeVoxState.instance.currentRange;
// If true, will check if the predicate matches the current node.
let matchCurrent = false;
let dir = Dir.FORWARD;
let pred = null;
let predErrorMsg = undefined;
......@@ -1282,14 +1282,15 @@ CommandHandler.viewGraphicAsBraille_ = function(current) {
* @private
*/
CommandHandler.onEditCommand_ = function(command) {
const current = ChromeVoxState.instance.currentRange;
if (ChromeVox.isStickyModeOn() || !current || !current.start ||
!current.start.node || !current.start.node.state[StateType.EDITABLE]) {
if (ChromeVox.isStickyModeOn()) {
return true;
}
const textEditHandler = DesktopAutomationHandler.instance.textEditHandler;
if (!textEditHandler || current.start.node !== textEditHandler.node) {
if (!textEditHandler ||
!AutomationUtil.isDescendantOf(
ChromeVoxState.instance.currentRange.start.node,
textEditHandler.node)) {
return true;
}
......@@ -1305,7 +1306,7 @@ CommandHandler.onEditCommand_ = function(command) {
return true;
}
const isMultiline = AutomationPredicate.multiline(current.start.node);
const isMultiline = AutomationPredicate.multiline(textEditHandler.node);
switch (command) {
case 'previousCharacter':
BackgroundKeyboardHandler.sendKeyPress(36, {shift: true});
......@@ -1320,7 +1321,13 @@ CommandHandler.onEditCommand_ = function(command) {
BackgroundKeyboardHandler.sendKeyPress(35, {shift: true, ctrl: true});
break;
case 'previousObject':
if (!isMultiline || textEditHandler.isSelectionOnFirstLine()) {
if (!isMultiline) {
return true;
}
if (textEditHandler.isSelectionOnFirstLine()) {
ChromeVoxState.instance.setCurrentRange(
cursors.Range.fromNode(textEditHandler.node));
return true;
}
BackgroundKeyboardHandler.sendKeyPress(36);
......@@ -1338,7 +1345,12 @@ CommandHandler.onEditCommand_ = function(command) {
BackgroundKeyboardHandler.sendKeyPress(35);
break;
case 'previousLine':
if (!isMultiline || textEditHandler.isSelectionOnFirstLine()) {
if (!isMultiline) {
return true;
}
if (textEditHandler.isSelectionOnFirstLine()) {
ChromeVoxState.instance.setCurrentRange(
cursors.Range.fromNode(textEditHandler.node));
return true;
}
BackgroundKeyboardHandler.sendKeyPress(33);
......@@ -1352,7 +1364,6 @@ CommandHandler.onEditCommand_ = function(command) {
textEditHandler.moveToAfterEditText();
return false;
}
BackgroundKeyboardHandler.sendKeyPress(34);
break;
case 'jumpToTop':
......
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