Commit 60383b1f authored by plundblad's avatar plundblad Committed by Commit bot

Chromevox2: make sure the braille cursor is shown for empty text fields.

The empty string in a boolean context led to the cursor not being
shown.  Changed to compare against undefined instead.
This also fixes the value start offset to always be 0. It should only be
non-zero for multiline text fields where only part of the field is included in
the braille output.

BUG=

Review URL: https://codereview.chromium.org/1019283003

Cr-Commit-Position: refs/heads/master@{#321543}
parent 68954c5c
...@@ -331,19 +331,17 @@ Output.prototype = { ...@@ -331,19 +331,17 @@ Output.prototype = {
this.brailleBuffer_.getSpanInstanceOf(Output.SelectionSpan); this.brailleBuffer_.getSpanInstanceOf(Output.SelectionSpan);
var startIndex = -1, endIndex = -1; var startIndex = -1, endIndex = -1;
if (selSpan) { if (selSpan) {
var valueStart = this.brailleBuffer_.getSpanStart(selSpan); // Casts ok, since the span is known to be in the spannable.
var valueEnd = this.brailleBuffer_.getSpanEnd(selSpan); var valueStart =
if (valueStart === undefined || valueEnd === undefined) { /** @type {number} */ (this.brailleBuffer_.getSpanStart(selSpan));
valueStart = -1; var valueEnd =
valueEnd = -1; /** @type {number} */ (this.brailleBuffer_.getSpanEnd(selSpan));
} else { startIndex = valueStart + selSpan.startIndex;
startIndex = valueStart + selSpan.startIndex; endIndex = valueStart + selSpan.endIndex;
endIndex = valueStart + selSpan.endIndex; this.brailleBuffer_.setSpan(new cvox.ValueSpan(0),
this.brailleBuffer_.setSpan(new cvox.ValueSpan(valueStart), valueStart, valueEnd);
valueStart, valueEnd); this.brailleBuffer_.setSpan(new cvox.ValueSelectionSpan(),
this.brailleBuffer_.setSpan(new cvox.ValueSelectionSpan(), startIndex, endIndex);
startIndex, endIndex);
}
} }
var output = new cvox.NavBraille({ var output = new cvox.NavBraille({
...@@ -432,7 +430,7 @@ Output.prototype = { ...@@ -432,7 +430,7 @@ Output.prototype = {
this.addToSpannable_(buff, node.role, options); this.addToSpannable_(buff, node.role, options);
} else if (token == 'value') { } else if (token == 'value') {
var text = node.attributes.value; var text = node.attributes.value;
if (text) { if (text !== undefined) {
var offset = buff.getLength(); var offset = buff.getLength();
if (node.attributes.textSelStart !== undefined) { if (node.attributes.textSelStart !== undefined) {
options.annotation = new Output.SelectionSpan( options.annotation = new Output.SelectionSpan(
......
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