Commit 8e4d512b authored by David Tseng's avatar David Tseng Committed by Commit Bot

Fix wrapped braille cursor state

Test: navigate within editable text. Hit the 'end' key. Verify the cursor lands on the extra cell padding after this change. Before this change, the cursor "disappears".
Change-Id: I370bb2ae2bc458e4d94a1cd364c381fec3e976da
Reviewed-on: https://chromium-review.googlesource.com/1231982Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: David Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592246}
parent 67512a0e
......@@ -302,6 +302,11 @@ cvox.PanStrategy.prototype = {
}
}
// It's possible the end of the wrapped cursor falls at the
// |translatedContent.byteLength| exactly.
this.maybeSetWrappedCursor_(
index - cellsPadded, wrappedBrailleArray.length);
// Convert the wrapped Braille Uint8 Array back to ArrayBuffer.
var wrappedBrailleUint8Array = new Uint8Array(wrappedBrailleArray);
this.wrappedBuffer_ = new ArrayBuffer(wrappedBrailleUint8Array.length);
......@@ -327,7 +332,10 @@ cvox.PanStrategy.prototype = {
},
/**
*
* Refreshes the wrapped cursor given a mapping from an unwrapped index to a
* wrapped index.
* @param {number} unwrappedIndex
* @param {number} wrappedIndex
*/
maybeSetWrappedCursor_: function(unwrappedIndex, wrappedIndex) {
// We only care about the bounds of the index start/end.
......
......@@ -268,3 +268,27 @@ TEST_F('CvoxPanStrategyUnitTest', 'getCurrentTextViewportContents', function() {
panner.next();
assertEquals('789', panner.getCurrentTextViewportContents());
});
TEST_F('CvoxPanStrategyUnitTest', 'WrappedUnwrappedCursors', function() {
var panner = new cvox.PanStrategy();
panner.setPanStrategy(true);
// 30 cells with blank cells at positions 8, 22 and 26.
var content = createArrayBuffer('11234567 9112345678911 345 789');
panner.setCursor(1, 3);
panner.setContent('a', content, [], 0);
panner.setDisplaySize(2, 10);
assertEqualsJSON({start: 1, end: 3}, panner.getCursor());
assertEqualsJSON({start: 1, end: 3}, panner.wrappedCursor_);
panner.setCursor(5, 10);
panner.setContent('a', content, [], 0);
assertEqualsJSON({start: 5, end: 10}, panner.getCursor());
assertEqualsJSON({start: 5, end: 11}, panner.wrappedCursor_);
panner.setCursor(9, 9);
panner.setContent('a', content, [], 0);
assertEqualsJSON({start: 9, end: 9}, panner.getCursor());
assertEqualsJSON({start: 10, end: 11}, panner.wrappedCursor_);
});
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