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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/braille/braille_display_manager.js

Issue 2943193002: Run clang-format on .js files in c/b/r/chromeos/chromevox (Closed)
Patch Set: Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Puts text on a braille display. 6 * @fileoverview Puts text on a braille display.
7 * 7 *
8 */ 8 */
9 9
10 goog.provide('cvox.BrailleDisplayManager'); 10 goog.provide('cvox.BrailleDisplayManager');
(...skipping 19 matching lines...) Expand all
30 this.translatorManager_ = translatorManager; 30 this.translatorManager_ = translatorManager;
31 /** 31 /**
32 * @type {!cvox.NavBraille} 32 * @type {!cvox.NavBraille}
33 * @private 33 * @private
34 */ 34 */
35 this.content_ = new cvox.NavBraille({}); 35 this.content_ = new cvox.NavBraille({});
36 /** 36 /**
37 * @type {!cvox.ExpandingBrailleTranslator.ExpansionType} valueExpansion 37 * @type {!cvox.ExpandingBrailleTranslator.ExpansionType} valueExpansion
38 * @private 38 * @private
39 */ 39 */
40 this.expansionType_ = 40 this.expansionType_ = cvox.ExpandingBrailleTranslator.ExpansionType.SELECTION;
41 cvox.ExpandingBrailleTranslator.ExpansionType.SELECTION;
42 /** 41 /**
43 * @type {cvox.PanStrategy} 42 * @type {cvox.PanStrategy}
44 * @private 43 * @private
45 */ 44 */
46 this.panStrategy_ = new cvox.PanStrategy(); 45 this.panStrategy_ = new cvox.PanStrategy();
47 /** 46 /**
48 * @type {function(!cvox.BrailleKeyEvent, !cvox.NavBraille)} 47 * @type {function(!cvox.BrailleKeyEvent, !cvox.NavBraille)}
49 * @private 48 * @private
50 */ 49 */
51 this.commandListener_ = function() {}; 50 this.commandListener_ = function() {};
52 /** 51 /**
53 * Current display state to show in the Virtual Braille Captions display. 52 * Current display state to show in the Virtual Braille Captions display.
54 * This is different from realDisplayState_ if the braille captions feature 53 * This is different from realDisplayState_ if the braille captions feature
55 * is enabled and there is no hardware display connected. Otherwise, it is 54 * is enabled and there is no hardware display connected. Otherwise, it is
56 * the same object as realDisplayState_. 55 * the same object as realDisplayState_.
57 * @type {!cvox.BrailleDisplayState} 56 * @type {!cvox.BrailleDisplayState}
58 * @private 57 * @private
59 */ 58 */
60 this.displayState_ = {available: false, textRowCount: 0, 59 this.displayState_ = {available: false, textRowCount: 0, textColumnCount: 0};
61 textColumnCount: 0};
62 /** 60 /**
63 * State reported from the chrome api, reflecting a real hardware 61 * State reported from the chrome api, reflecting a real hardware
64 * display. 62 * display.
65 * @type {!cvox.BrailleDisplayState} 63 * @type {!cvox.BrailleDisplayState}
66 * @private 64 * @private
67 */ 65 */
68 this.realDisplayState_ = this.displayState_; 66 this.realDisplayState_ = this.displayState_;
69 67
70 translatorManager.addChangeListener(function() { 68 translatorManager.addChangeListener(function() {
71 this.translateContent_(this.content_, this.expansionType_); 69 this.translateContent_(this.content_, this.expansionType_);
72 }.bind(this)); 70 }.bind(this));
73 71
74 chrome.storage.onChanged.addListener(function(changes, area) { 72 chrome.storage.onChanged.addListener(function(changes, area) {
75 if (area == 'local' && 'brailleWordWrap' in changes) { 73 if (area == 'local' && 'brailleWordWrap' in changes) {
76 this.updatePanStrategy_(changes.brailleWordWrap.newValue); 74 this.updatePanStrategy_(changes.brailleWordWrap.newValue);
77 } 75 }
78 if (area == 'local' && ('virtualBrailleRows' in changes || 76 if (area == 'local' &&
79 'virtualBrailleColumns' in changes)) { 77 ('virtualBrailleRows' in changes ||
78 'virtualBrailleColumns' in changes)) {
80 this.onCaptionsStateChanged_(); 79 this.onCaptionsStateChanged_();
81 } 80 }
82 }.bind(this)); 81 }.bind(this));
83 chrome.storage.local.get({brailleWordWrap: true}, function(items) { 82 chrome.storage.local.get({brailleWordWrap: true}, function(items) {
84 this.updatePanStrategy_(items.brailleWordWrap); 83 this.updatePanStrategy_(items.brailleWordWrap);
85 }.bind(this)); 84 }.bind(this));
86 85
87 cvox.BrailleCaptionsBackground.init(goog.bind( 86 cvox.BrailleCaptionsBackground.init(
88 this.onCaptionsStateChanged_, this)); 87 goog.bind(this.onCaptionsStateChanged_, this));
89 if (goog.isDef(chrome.brailleDisplayPrivate)) { 88 if (goog.isDef(chrome.brailleDisplayPrivate)) {
90 var onDisplayStateChanged = goog.bind(this.refreshDisplayState_, this); 89 var onDisplayStateChanged = goog.bind(this.refreshDisplayState_, this);
91 chrome.brailleDisplayPrivate.getDisplayState(onDisplayStateChanged); 90 chrome.brailleDisplayPrivate.getDisplayState(onDisplayStateChanged);
92 chrome.brailleDisplayPrivate.onDisplayStateChanged.addListener( 91 chrome.brailleDisplayPrivate.onDisplayStateChanged.addListener(
93 onDisplayStateChanged); 92 onDisplayStateChanged);
94 chrome.brailleDisplayPrivate.onKeyEvent.addListener( 93 chrome.brailleDisplayPrivate.onKeyEvent.addListener(
95 goog.bind(this.onKeyEvent_, this)); 94 goog.bind(this.onKeyEvent_, this));
96 } else { 95 } else {
97 // Get the initial captions state since we won't refresh the display 96 // Get the initial captions state since we won't refresh the display
98 // state in an API callback in this case. 97 // state in an API callback in this case.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 // are 6-dot (2 x 3), but we should have a way to detect that via brltty. 167 // are 6-dot (2 x 3), but we should have a way to detect that via brltty.
169 var cellWidth = 2; 168 var cellWidth = 2;
170 var cellHeight = 3; 169 var cellHeight = 3;
171 var maxCellHeight = 4; 170 var maxCellHeight = 4;
172 171
173 var rows = this.displayState_.textRowCount; 172 var rows = this.displayState_.textRowCount;
174 var columns = this.displayState_.textColumnCount; 173 var columns = this.displayState_.textColumnCount;
175 var imageDataUrl = imageUrl; 174 var imageDataUrl = imageUrl;
176 var imgElement = document.createElement('img'); 175 var imgElement = document.createElement('img');
177 imgElement.src = imageDataUrl; 176 imgElement.src = imageDataUrl;
178 imgElement.onload = (function() { 177 imgElement.onload = function() {
179 var canvas = document.createElement('canvas'); 178 var canvas = document.createElement('canvas');
180 var context = canvas.getContext('2d'); 179 var context = canvas.getContext('2d');
181 canvas.width = columns * cellWidth; 180 canvas.width = columns * cellWidth;
182 canvas.height = rows * cellHeight; 181 canvas.height = rows * cellHeight;
183 context.drawImage(imgElement, 0, 0, canvas.width, canvas.height); 182 context.drawImage(imgElement, 0, 0, canvas.width, canvas.height);
184 var imageData = context.getImageData(0, 0, canvas.width, canvas.height); 183 var imageData = context.getImageData(0, 0, canvas.width, canvas.height);
185 var data = imageData.data; 184 var data = imageData.data;
186 var outputData = []; 185 var outputData = [];
187 186
188 // Convert image to black and white by thresholding the luminance for 187 // Convert image to black and white by thresholding the luminance for
189 // all opaque (non-transparent) pixels. 188 // all opaque (non-transparent) pixels.
190 for (var i = 0; i < data.length; i += 4) { 189 for (var i = 0; i < data.length; i += 4) {
191 var red = data[i]; 190 var red = data[i];
192 var green = data[i + 1]; 191 var green = data[i + 1];
193 var blue = data[i + 2]; 192 var blue = data[i + 2];
194 var alpha = data[i + 3]; 193 var alpha = data[i + 3];
195 var luminance = 194 var luminance = 0.2126 * red + 0.7152 * green + 0.0722 * blue;
196 0.2126 * red +
197 0.7152 * green +
198 0.0722 * blue;
199 // Show braille pin if the alpha is greater than the threshold and 195 // Show braille pin if the alpha is greater than the threshold and
200 // the luminance is less than the threshold. 196 // the luminance is less than the threshold.
201 var show = (alpha >= cvox.BrailleDisplayManager.ALPHA_THRESHOLD_ && 197 var show =
202 luminance < cvox.BrailleDisplayManager.LUMINANCE_THRESHOLD_); 198 (alpha >= cvox.BrailleDisplayManager.ALPHA_THRESHOLD_ &&
199 luminance < cvox.BrailleDisplayManager.LUMINANCE_THRESHOLD_);
203 outputData.push(show); 200 outputData.push(show);
204 } 201 }
205 202
206 // Convert black-and-white array to the proper encoding for Braille cells. 203 // Convert black-and-white array to the proper encoding for Braille
204 // cells.
207 var brailleBuf = new ArrayBuffer(rows * columns); 205 var brailleBuf = new ArrayBuffer(rows * columns);
208 var view = new Uint8Array(brailleBuf); 206 var view = new Uint8Array(brailleBuf);
209 for (var i = 0; i < rows; i++) { 207 for (var i = 0; i < rows; i++) {
210 for (var j = 0; j < columns; j++) { 208 for (var j = 0; j < columns; j++) {
211 // Index in braille array 209 // Index in braille array
212 var brailleIndex = i * columns + j; 210 var brailleIndex = i * columns + j;
213 for (var cellColumn = 0; cellColumn < cellWidth; cellColumn++) { 211 for (var cellColumn = 0; cellColumn < cellWidth; cellColumn++) {
214 for (var cellRow = 0; cellRow < cellHeight; cellRow++) { 212 for (var cellRow = 0; cellRow < cellHeight; cellRow++) {
215 var bitmapIndex = 213 var bitmapIndex =
216 (i * columns * cellHeight + j + cellRow * columns) * cellWidth 214 (i * columns * cellHeight + j + cellRow * columns) * cellWidth +
217 + cellColumn; 215 cellColumn;
218 if (outputData[bitmapIndex]) { 216 if (outputData[bitmapIndex]) {
219 view[brailleIndex] += 217 view[brailleIndex] +=
220 cvox.BrailleDisplayManager.COORDS_TO_BRAILLE_DOT_[ 218 cvox.BrailleDisplayManager.COORDS_TO_BRAILLE_DOT_
221 cellColumn * maxCellHeight + cellRow]; 219 [cellColumn * maxCellHeight + cellRow];
222 } 220 }
223 } 221 }
224 } 222 }
225 } 223 }
226 } 224 }
227 225
228 if (this.realDisplayState_.available) { 226 if (this.realDisplayState_.available) {
229 chrome.brailleDisplayPrivate.writeDots( 227 chrome.brailleDisplayPrivate.writeDots(
230 brailleBuf, 228 brailleBuf, this.displayState_.textColumnCount,
231 this.displayState_.textColumnCount,
232 this.displayState_.textRowCount); 229 this.displayState_.textRowCount);
233 } 230 }
234 if (cvox.BrailleCaptionsBackground.isEnabled()) { 231 if (cvox.BrailleCaptionsBackground.isEnabled()) {
235 cvox.BrailleCaptionsBackground.setImageContent( 232 cvox.BrailleCaptionsBackground.setImageContent(brailleBuf, rows, columns);
236 brailleBuf, rows, columns);
237 } 233 }
238 }).bind(this); 234 }.bind(this);
239 }; 235 };
240 236
241 237
242 /** 238 /**
243 * Sets the command listener. When a command is invoked, the listener will be 239 * Sets the command listener. When a command is invoked, the listener will be
244 * called with the BrailleKeyEvent corresponding to the command and the content 240 * called with the BrailleKeyEvent corresponding to the command and the content
245 * that was present on the display when the command was invoked. The content 241 * that was present on the display when the command was invoked. The content
246 * is guaranteed to be identical to an object previously used as the parameter 242 * is guaranteed to be identical to an object previously used as the parameter
247 * to cvox.BrailleDisplayManager.setContent, or null if no content was set. 243 * to cvox.BrailleDisplayManager.setContent, or null if no content was set.
248 * @param {function(!cvox.BrailleKeyEvent, !cvox.NavBraille)} func The listener. 244 * @param {function(!cvox.BrailleKeyEvent, !cvox.NavBraille)} func The listener.
(...skipping 12 matching lines...) Expand all
261 257
262 258
263 /** 259 /**
264 * @param {{available: boolean, textRowCount: (number|undefined), 260 * @param {{available: boolean, textRowCount: (number|undefined),
265 * textColumnCount: (number|undefined)}} newState Display state reported 261 * textColumnCount: (number|undefined)}} newState Display state reported
266 * by the extension API. Note that the type is almost the same as 262 * by the extension API. Note that the type is almost the same as
267 * cvox.BrailleDisplayState except that the extension API allows 263 * cvox.BrailleDisplayState except that the extension API allows
268 * some fields to be undefined, while cvox.BrailleDisplayState does not. 264 * some fields to be undefined, while cvox.BrailleDisplayState does not.
269 * @private 265 * @private
270 */ 266 */
271 cvox.BrailleDisplayManager.prototype.refreshDisplayState_ = function( 267 cvox.BrailleDisplayManager.prototype.refreshDisplayState_ = function(newState) {
272 newState) {
273 var oldColumnCount = this.displayState_.textColumnCount || 0; 268 var oldColumnCount = this.displayState_.textColumnCount || 0;
274 var oldRowCount = this.displayState_.textRowCount || 0; 269 var oldRowCount = this.displayState_.textRowCount || 0;
275 var processDisplayState = function(displayState) { 270 var processDisplayState = function(displayState) {
276 this.displayState_ = displayState; 271 this.displayState_ = displayState;
277 var newColumnCount = displayState.textColumnCount || 0; 272 var newColumnCount = displayState.textColumnCount || 0;
278 var newRowCount = displayState.textRowCount || 0; 273 var newRowCount = displayState.textRowCount || 0;
279 274
280 if (oldColumnCount != newColumnCount || oldRowCount != newRowCount) { 275 if (oldColumnCount != newColumnCount || oldRowCount != newRowCount) {
281 this.panStrategy_.setDisplaySize(newRowCount, newColumnCount); 276 this.panStrategy_.setDisplaySize(newRowCount, newColumnCount);
282 } 277 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 * braille captions display. 309 * braille captions display.
315 * @private 310 * @private
316 */ 311 */
317 cvox.BrailleDisplayManager.prototype.refresh_ = function() { 312 cvox.BrailleDisplayManager.prototype.refresh_ = function() {
318 if (!this.displayState_.available) { 313 if (!this.displayState_.available) {
319 return; 314 return;
320 } 315 }
321 var brailleBuf = this.panStrategy_.getCurrentBrailleViewportContents(); 316 var brailleBuf = this.panStrategy_.getCurrentBrailleViewportContents();
322 var textBuf = this.panStrategy_.getCurrentTextViewportContents(); 317 var textBuf = this.panStrategy_.getCurrentTextViewportContents();
323 if (this.realDisplayState_.available) { 318 if (this.realDisplayState_.available) {
324 chrome.brailleDisplayPrivate.writeDots(brailleBuf, 319 chrome.brailleDisplayPrivate.writeDots(
325 brailleBuf.byteLength, 1); 320 brailleBuf, brailleBuf.byteLength, 1);
326 } 321 }
327 if (cvox.BrailleCaptionsBackground.isEnabled()) { 322 if (cvox.BrailleCaptionsBackground.isEnabled()) {
328 cvox.BrailleCaptionsBackground.setContent(textBuf, brailleBuf, 323 cvox.BrailleCaptionsBackground.setContent(
329 this.panStrategy_.brailleToText, this.panStrategy_.offsetsForSlices, 324 textBuf, brailleBuf, this.panStrategy_.brailleToText,
330 this.displayState_.textRowCount, this.displayState_.textColumnCount); 325 this.panStrategy_.offsetsForSlices, this.displayState_.textRowCount,
326 this.displayState_.textColumnCount);
331 } 327 }
332 }; 328 };
333 329
334 /** 330 /**
335 * @param {!cvox.NavBraille} newContent New display content. 331 * @param {!cvox.NavBraille} newContent New display content.
336 * @param {cvox.ExpandingBrailleTranslator.ExpansionType} newExpansionType 332 * @param {cvox.ExpandingBrailleTranslator.ExpansionType} newExpansionType
337 * How the value part of of the new content should be expanded 333 * How the value part of of the new content should be expanded
338 * with regards to contractions. 334 * with regards to contractions.
339 * @private 335 * @private
340 */ 336 */
(...skipping 26 matching lines...) Expand all
367 translatedEndIndex = cells.byteLength; 363 translatedEndIndex = cells.byteLength;
368 } else { 364 } else {
369 translatedEndIndex = textToBraille[endIndex]; 365 translatedEndIndex = textToBraille[endIndex];
370 } 366 }
371 // Add the cursor to cells. 367 // Add the cursor to cells.
372 this.writeCursor_(cells, translatedStartIndex, translatedEndIndex); 368 this.writeCursor_(cells, translatedStartIndex, translatedEndIndex);
373 targetPosition = translatedStartIndex; 369 targetPosition = translatedStartIndex;
374 } else { 370 } else {
375 targetPosition = 0; 371 targetPosition = 0;
376 } 372 }
377 this.panStrategy_.setContent(this.content_.text.toString(), 373 this.panStrategy_.setContent(
378 cells, brailleToText, targetPosition); 374 this.content_.text.toString(), cells, brailleToText, targetPosition);
379 375
380 this.refresh_(); 376 this.refresh_();
381 }.bind(this); 377 }.bind(this);
382 378
383 var translator = this.translatorManager_.getExpandingTranslator(); 379 var translator = this.translatorManager_.getExpandingTranslator();
384 if (!translator) { 380 if (!translator) {
385 writeTranslatedContent(new ArrayBuffer(0), [], []); 381 writeTranslatedContent(new ArrayBuffer(0), [], []);
386 } else { 382 } else {
387 translator.translate( 383 translator.translate(
388 newContent.text, 384 newContent.text, newExpansionType, writeTranslatedContent);
389 newExpansionType,
390 writeTranslatedContent);
391 } 385 }
392 }; 386 };
393 387
394 388
395 /** 389 /**
396 * @param {cvox.BrailleKeyEvent} event The key event. 390 * @param {cvox.BrailleKeyEvent} event The key event.
397 * @private 391 * @private
398 */ 392 */
399 cvox.BrailleDisplayManager.prototype.onKeyEvent_ = function(event) { 393 cvox.BrailleDisplayManager.prototype.onKeyEvent_ = function(event) {
400 switch (event.command) { 394 switch (event.command) {
401 case cvox.BrailleKeyCommand.PAN_LEFT: 395 case cvox.BrailleKeyCommand.PAN_LEFT:
402 this.panLeft_(); 396 this.panLeft_();
403 break; 397 break;
404 case cvox.BrailleKeyCommand.PAN_RIGHT: 398 case cvox.BrailleKeyCommand.PAN_RIGHT:
405 this.panRight_(); 399 this.panRight_();
406 break; 400 break;
407 case cvox.BrailleKeyCommand.ROUTING: 401 case cvox.BrailleKeyCommand.ROUTING:
408 event.displayPosition = this.brailleToTextPosition_( 402 event.displayPosition = this.brailleToTextPosition_(
409 event.displayPosition + this.panStrategy_.viewPort.firstRow * 403 event.displayPosition +
410 this.panStrategy_.displaySize.columns); 404 this.panStrategy_.viewPort.firstRow *
411 // fall through 405 this.panStrategy_.displaySize.columns);
406 // fall through
412 default: 407 default:
413 this.commandListener_(event, this.content_); 408 this.commandListener_(event, this.content_);
414 break; 409 break;
415 } 410 }
416 }; 411 };
417 412
418 413
419 /** 414 /**
420 * Shift the display by one full display size and refresh the content. 415 * Shift the display by one full display size and refresh the content.
421 * Sends the appropriate command if the display is already at the leftmost 416 * Sends the appropriate command if the display is already at the leftmost
422 * position. 417 * position.
423 * @private 418 * @private
424 */ 419 */
425 cvox.BrailleDisplayManager.prototype.panLeft_ = function() { 420 cvox.BrailleDisplayManager.prototype.panLeft_ = function() {
426 if (this.panStrategy_.previous()) { 421 if (this.panStrategy_.previous()) {
427 this.refresh_(); 422 this.refresh_();
428 } else { 423 } else {
429 this.commandListener_({ 424 this.commandListener_(
430 command: cvox.BrailleKeyCommand.PAN_LEFT 425 {command: cvox.BrailleKeyCommand.PAN_LEFT}, this.content_);
431 }, this.content_);
432 } 426 }
433 }; 427 };
434 428
435 429
436 /** 430 /**
437 * Shifts the display position to the right by one full display size and 431 * Shifts the display position to the right by one full display size and
438 * refreshes the content. Sends the appropriate command if the display is 432 * refreshes the content. Sends the appropriate command if the display is
439 * already at its rightmost position. 433 * already at its rightmost position.
440 * @private 434 * @private
441 */ 435 */
442 cvox.BrailleDisplayManager.prototype.panRight_ = function() { 436 cvox.BrailleDisplayManager.prototype.panRight_ = function() {
443 if (this.panStrategy_.next()) { 437 if (this.panStrategy_.next()) {
444 this.refresh_(); 438 this.refresh_();
445 } else { 439 } else {
446 this.commandListener_({ 440 this.commandListener_(
447 command: cvox.BrailleKeyCommand.PAN_RIGHT 441 {command: cvox.BrailleKeyCommand.PAN_RIGHT}, this.content_);
448 }, this.content_);
449 } 442 }
450 }; 443 };
451 444
452 /** 445 /**
453 * Writes a cursor in the specified range into translated content. 446 * Writes a cursor in the specified range into translated content.
454 * @param {ArrayBuffer} buffer Buffer to add cursor to. 447 * @param {ArrayBuffer} buffer Buffer to add cursor to.
455 * @param {number} startIndex The start index to place the cursor. 448 * @param {number} startIndex The start index to place the cursor.
456 * @param {number} endIndex The end index to place the cursor (exclusive). 449 * @param {number} endIndex The end index to place the cursor (exclusive).
457 * @private 450 * @private
458 */ 451 */
(...skipping 16 matching lines...) Expand all
475 }; 468 };
476 469
477 /** 470 /**
478 * Returns the text position corresponding to an absolute braille position, 471 * Returns the text position corresponding to an absolute braille position,
479 * that is not accounting for the current pan position. 472 * that is not accounting for the current pan position.
480 * @private 473 * @private
481 * @param {number} braillePosition Braille position relative to the startof 474 * @param {number} braillePosition Braille position relative to the startof
482 * the translated content. 475 * the translated content.
483 * @return {number} The mapped position in code units. 476 * @return {number} The mapped position in code units.
484 */ 477 */
485 cvox.BrailleDisplayManager.prototype.brailleToTextPosition_ = 478 cvox.BrailleDisplayManager.prototype.brailleToTextPosition_ = function(
486 function(braillePosition) { 479 braillePosition) {
487 var mapping = this.panStrategy_.brailleToText; 480 var mapping = this.panStrategy_.brailleToText;
488 if (braillePosition < 0) { 481 if (braillePosition < 0) {
489 // This shouldn't happen. 482 // This shouldn't happen.
490 console.error('WARNING: Braille position < 0: ' + braillePosition); 483 console.error('WARNING: Braille position < 0: ' + braillePosition);
491 return 0; 484 return 0;
492 } else if (braillePosition >= mapping.length) { 485 } else if (braillePosition >= mapping.length) {
493 // This happens when the user clicks on the right part of the display 486 // This happens when the user clicks on the right part of the display
494 // when it is not entirely filled with content. Allow addressing the 487 // when it is not entirely filled with content. Allow addressing the
495 // position after the last character. 488 // position after the last character.
496 return this.content_.text.length; 489 return this.content_.text.length;
497 } else { 490 } else {
498 return mapping[braillePosition]; 491 return mapping[braillePosition];
499 } 492 }
500 }; 493 };
501 494
502 /** 495 /**
503 * @param {boolean} wordWrap 496 * @param {boolean} wordWrap
504 * @private 497 * @private
505 */ 498 */
506 cvox.BrailleDisplayManager.prototype.updatePanStrategy_ = function(wordWrap) { 499 cvox.BrailleDisplayManager.prototype.updatePanStrategy_ = function(wordWrap) {
507 this.panStrategy_.setPanStrategy(wordWrap); 500 this.panStrategy_.setPanStrategy(wordWrap);
508 this.refresh_(); 501 this.refresh_();
509 }; 502 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698