Commit 1f2aab90 authored by David Tseng's avatar David Tseng Committed by Commit Bot

Clean up editing.js for braille

R=dmazzoni@chromium.org

AX-Relnotes: n/a
Change-Id: Id9be642689ddd4898d7d062fad51408642fed204
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2204844
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#770847}
parent c235d030
......@@ -418,6 +418,26 @@ const AutomationRichEditableText = class extends AutomationEditableText {
const prev = this.line_;
this.line_ = cur;
this.handleSpeech_(
cur, prev, startLine, endLine, prevStartLine, prevEndLine,
baseLineOnStart, intents);
this.brailleCurrentRichLine_();
}
/**
* @param {!editing.EditableLine} cur
* @param {!editing.EditableLine} prev
* @param {!editing.EditableLine} startLine
* @param {!editing.EditableLine} endLine
* @param {!editing.EditableLine} prevStartLine
* @param {!editing.EditableLine} prevEndLine
* @param {boolean} baseLineOnStart
* @param {!Array<AutomationIntent>} intents
* @private
*/
handleSpeech_(
cur, prev, startLine, endLine, prevStartLine, prevEndLine,
baseLineOnStart, intents) {
// During continuous read, skip speech (which gets handled in
// CommandHandler). We use the speech end callback to trigger additional
// speech.
......@@ -425,14 +445,13 @@ const AutomationRichEditableText = class extends AutomationEditableText {
if (ChromeVoxState.isReadingContinuously ||
AutomationPredicate.shouldOnlyOutputSelectionChangeInBraille(
this.node_)) {
this.brailleCurrentRichLine_();
this.updateIntraLineState_(cur);
return;
}
// Before entering into our state machine below, use selected intents to
// decipher ambiguous cases.
if (this.maybeOutputUsingIntents_(intents, cur, prev)) {
if (this.maybeSpeakUsingIntents_(intents, cur, prev)) {
return;
}
......@@ -472,14 +491,12 @@ const AutomationRichEditableText = class extends AutomationEditableText {
new Range(prev.start_, prev.end_), Output.EventType.NAVIGATE)
.go();
}
this.brailleCurrentRichLine_();
// Be careful to update state in EditableTextBase since we don't
// explicitly call through to it here.
this.updateIntraLineState_(cur);
this.speakAllMarkers_(cur);
return;
}
......@@ -505,13 +522,10 @@ const AutomationRichEditableText = class extends AutomationEditableText {
new TextChangeEvent(
cur.startContainerValue_, cur.localContainerStartOffset_,
cur.localContainerEndOffset_, true));
// Braille here simply displays the current line.
this.brailleCurrentRichLine_();
} else if (cur.text == '') {
// This line has no text content. Describe the DOM selection.
new Output()
.withRichSpeechAndBraille(
.withRichSpeech(
new Range(cur.start_, cur.end_),
new Range(prev.start_, prev.end_), Output.EventType.NAVIGATE)
.go();
......@@ -575,7 +589,6 @@ const AutomationRichEditableText = class extends AutomationEditableText {
ChromeVox.tts.speak(text, QueueMode.CATEGORY_FLUSH);
ChromeVox.tts.speak(Msgs.getMsg(suffixMsg), QueueMode.QUEUE);
this.brailleCurrentRichLine_();
} else if (!cur.hasCollapsedSelection()) {
// Without any other information, try describing the selection. This state
// catches things like select all.
......@@ -584,8 +597,6 @@ const AutomationRichEditableText = class extends AutomationEditableText {
cur.localEndOffset);
ChromeVox.tts.speak(text, QueueMode.CATEGORY_FLUSH);
ChromeVox.tts.speak(Msgs.getMsg('selected'), QueueMode.QUEUE);
this.brailleCurrentRichLine_();
} else {
// A catch-all for any other transitions.
......@@ -594,7 +605,6 @@ const AutomationRichEditableText = class extends AutomationEditableText {
// above). This is also the code path for describing paste. It also covers
// jump commands which are non-overlapping selections from prev to cur.
this.speakCurrentRichLine_(prev);
this.brailleCurrentRichLine_();
}
this.updateIntraLineState_(cur);
}
......@@ -824,8 +834,7 @@ const AutomationRichEditableText = class extends AutomationEditableText {
// Provide context for the current selection.
const context = cur.startContainer_;
if (context) {
if (context && context.role != RoleType.TEXT_FIELD) {
const output = new Output().suppress('name').withBraille(
Range.fromNode(context), Range.fromNode(this.node_),
Output.EventType.NAVIGATE);
......@@ -913,7 +922,7 @@ const AutomationRichEditableText = class extends AutomationEditableText {
* @param {!editing.EditableLine} prev
* @private
*/
maybeOutputUsingIntents_(intents, cur, prev) {
maybeSpeakUsingIntents_(intents, cur, prev) {
if (intents.length == 0) {
return false;
}
......@@ -935,7 +944,6 @@ const AutomationRichEditableText = class extends AutomationEditableText {
cur.text.substring(cur.startOffset, cur.startOffset + 1) || '\n';
ChromeVox.tts.speak(text, QueueMode.CATEGORY_FLUSH);
this.speakAllMarkers_(cur);
this.brailleCurrentRichLine_();
return true;
}
......@@ -945,7 +953,6 @@ const AutomationRichEditableText = class extends AutomationEditableText {
chrome.automation.EventTextBoundaryType.LINE_END) {
this.updateIntraLineState_(cur);
this.speakCurrentRichLine_(prev);
this.brailleCurrentRichLine_();
return true;
}
......
......@@ -1218,7 +1218,7 @@ TEST_F('ChromeVoxEditingTest', 'BackwardWordDelete', function() {
.expectBraille('this\u00a0mled', {startIndex: 5, endIndex: 5})
.call(this.press(8 /* backspace */, {ctrl: true}))
.expectSpeech('this , deleted')
.expectBraille(' ed mled', {startIndex: 0, endIndex: 0})
.expectBraille(' mled', {startIndex: 0, endIndex: 0})
.replay();
});
input.focus();
......
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