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