Commit 8cf0e258 authored by Abigail Klein's avatar Abigail Klein Committed by Commit Bot

Add cursor routing to the braille caption panel in Chromevox.

When a user clicks on a character in the braille caption panel, it
sends a routing event to the braille command listener and moves
the cursor to the designated position.

Chromevox. Click on a character in the panel to move the cursor to the
desired position.

AX-Relnotes: Added cursor routing to the braille caption panel in
Change-Id: I28e10e17f81c9b0336842a2756263c9f5acb8df2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2333752Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Commit-Queue: Abigail Klein <abigailbklein@google.com>
Cr-Commit-Position: refs/heads/master@{#795933}
parent f6f48d63
...@@ -126,6 +126,11 @@ BrailleBackground = class { ...@@ -126,6 +126,11 @@ BrailleBackground = class {
this.displayManager_.panRight(); this.displayManager_.panRight();
} }
/** @override */
route(displayPosition) {
return this.displayManager_.route(displayPosition);
}
/** /**
* @param {!NavBraille} newContent * @param {!NavBraille} newContent
* @param {?string} newContentId * @param {?string} newContentId
......
...@@ -388,11 +388,8 @@ BrailleDisplayManager = class { ...@@ -388,11 +388,8 @@ BrailleDisplayManager = class {
this.panRight(); this.panRight();
break; break;
case BrailleKeyCommand.ROUTING: case BrailleKeyCommand.ROUTING:
event.displayPosition = this.brailleToTextPosition_( this.route(event.displayPosition);
event.displayPosition + break;
this.panStrategy_.viewPort.firstRow *
this.panStrategy_.displaySize.columns);
// fall through
default: default:
this.commandListener_(event, this.content_); this.commandListener_(event, this.content_);
break; break;
...@@ -427,6 +424,24 @@ BrailleDisplayManager = class { ...@@ -427,6 +424,24 @@ BrailleDisplayManager = class {
} }
} }
/**
* Moves the cursor to the given braille position.
* @param {number|undefined} braillePosition The 0-based position relative to
* the start of the currently displayed text. The position is given in
* braille cells, not text cells.
*/
route(braillePosition) {
if (braillePosition == undefined) {
return;
}
const displayPosition = this.brailleToTextPosition_(
braillePosition +
this.panStrategy_.viewPort.firstRow *
this.panStrategy_.displaySize.columns);
this.commandListener_(
{command: BrailleKeyCommand.ROUTING, displayPosition}, this.content_);
}
/** /**
* Sets a cursor within translated content. * Sets a cursor within translated content.
* @param {ArrayBuffer} buffer Buffer to add cursor to. * @param {ArrayBuffer} buffer Buffer to add cursor to.
......
...@@ -58,4 +58,12 @@ BrailleInterface = class { ...@@ -58,4 +58,12 @@ BrailleInterface = class {
* Requests the braille display pan right. * Requests the braille display pan right.
*/ */
panRight() {} panRight() {}
/**
* Moves the cursor to the given braille position.
* @param {number|undefined} braillePosition The 0-based position relative to
* the start of the currently displayed text. The position is given in
* braille cells, not text cells.
*/
route(braillePosition) {}
}; };
...@@ -660,8 +660,24 @@ Panel = class { ...@@ -660,8 +660,24 @@ Panel = class {
} }
}; };
const routeCursor = function(event) {
const cell = event.target;
if (cell.tagName == 'TD') {
const displayPosition = parseInt(cell.id.split('-')[0], 10);
if (Number.isNaN(displayPosition)) {
throw new Error(
'The display position is calculated assuming that the cell ID ' +
'is formatted like int-string. For example, 0-brailleCell is a ' +
'valid cell ID.');
}
chrome.extension.getBackgroundPage()['ChromeVox'].braille.route(
displayPosition);
}
};
Panel.brailleContainer_.addEventListener('mouseover', addBorders); Panel.brailleContainer_.addEventListener('mouseover', addBorders);
Panel.brailleContainer_.addEventListener('mouseout', removeBorders); Panel.brailleContainer_.addEventListener('mouseout', removeBorders);
Panel.brailleContainer_.addEventListener('click', routeCursor);
// Clear the tables. // Clear the tables.
let rowCount = Panel.brailleTableElement_.rows.length; let rowCount = Panel.brailleTableElement_.rows.length;
......
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