Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5546)

Unified Diff: chrome/browser/resources/chromeos/chromevox/chromevox/background/braille_captions_background.js

Issue 2362673004: Aligns text to braille in chromevox. (Closed)
Patch Set: Addressed all presubmit issues. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/chromeos/chromevox/chromevox/background/braille_captions_background.js
diff --git a/chrome/browser/resources/chromeos/chromevox/chromevox/background/braille_captions_background.js b/chrome/browser/resources/chromeos/chromevox/chromevox/background/braille_captions_background.js
index a38d3b75dcfd09be1fc67631602dadf25149c574..cab516780d239e161d8ab0f2be84ff0b9c828def 100644
--- a/chrome/browser/resources/chromeos/chromevox/chromevox/background/braille_captions_background.js
+++ b/chrome/browser/resources/chromeos/chromevox/chromevox/background/braille_captions_background.js
@@ -57,19 +57,41 @@ cvox.BrailleCaptionsBackground.isEnabled = function() {
/**
* @param {string} text Text of the shown braille.
* @param {ArrayBuffer} cells Braille cells shown on the display.
+ * @param {Array} brailleToText Map of Braille letters to the first
dmazzoni 2016/09/26 04:53:49 How about {Array<number>} - it's always good to be
ultimatedbz 2016/09/27 22:56:24 Done.
+ * index of
+ * corresponding text letter.
dmazzoni 2016/09/26 04:53:48 nit: wrap this
ultimatedbz 2016/09/27 22:56:24 Done.
*/
-cvox.BrailleCaptionsBackground.setContent = function(text, cells) {
+cvox.BrailleCaptionsBackground.setContent = function(text, cells,
+ brailleToText) {
var self = cvox.BrailleCaptionsBackground;
// Convert the cells to Unicode braille pattern characters.
var byteBuf = new Uint8Array(cells);
var brailleChars = '';
- for (var i = 0; i < byteBuf.length; ++i) {
+ var brailleBuf = '';
+ var textIndex = 0;
+ var groups = [];
+
+ for (var i = 0; i < byteBuf.length - 1; ++i) {
dmazzoni 2016/09/26 04:53:48 Abstract this concept of breaking into groups into
ultimatedbz 2016/09/27 22:56:24 Done.
brailleChars += String.fromCharCode(
dmazzoni 2016/09/26 04:53:49 We're not using brailleChars anymore, so you can j
ultimatedbz 2016/09/27 21:15:49 Isn't brailleChars used below in line 100 though?
dmazzoni 2016/09/27 21:54:50 You're right, I missed that. That's for a way to d
ultimatedbz 2016/09/27 22:56:24 Done.
self.BRAILLE_UNICODE_BLOCK_START | byteBuf[i]);
+ if ((i != 0) && ((brailleToText[i] != textIndex))) {
+ groups.push([text.substr(textIndex, brailleToText[i] - textIndex),
dmazzoni 2016/09/26 04:53:49 Instead of each group being an array [text, braill
+ brailleBuf]);
+ brailleBuf = '';
+ textIndex = brailleToText[i];
+ }
+ brailleBuf += String.fromCharCode(
+ self.BRAILLE_UNICODE_BLOCK_START | byteBuf[i]);
+ }
+ // Puts the rest of the text into the last group.
+ if (byteBuf.length > 0) {
+ brailleChars += String.fromCharCode(
+ self.BRAILLE_UNICODE_BLOCK_START | byteBuf[byteBuf.length - 1]);
+ groups.push([text.substr(textIndex), brailleBuf]);
}
if (cvox.ChromeVox.isChromeOS) {
- var data = {text: text, braille: brailleChars};
+ var data = {groups: groups};
(new PanelCommand(PanelCommandType.UPDATE_BRAILLE, data)).send();
} else {
cvox.ExtensionBridge.send({

Powered by Google App Engine
This is Rietveld 408576698