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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/panel.js

Issue 2496823002: Implement word wrapping and panning in multiline Braille. (Closed)
Patch Set: removed unnecessary files Created 4 years, 1 month 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 The ChromeVox panel and menus. 6 * @fileoverview The ChromeVox panel and menus.
7 */ 7 */
8 8
9 goog.provide('Panel'); 9 goog.provide('Panel');
10 10
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 var rows = parseInt(localStorage['virtualBrailleRows'], 10); 475 var rows = parseInt(localStorage['virtualBrailleRows'], 10);
476 var sideBySide = localStorage['brailleSideBySide'] === 'true'; 476 var sideBySide = localStorage['brailleSideBySide'] === 'true';
477 477
478 var addBorders = function(event) { 478 var addBorders = function(event) {
479 var cell = event.target; 479 var cell = event.target;
480 if (cell.tagName == 'TD') { 480 if (cell.tagName == 'TD') {
481 cell.className = 'highlighted-cell'; 481 cell.className = 'highlighted-cell';
482 var companionID = cell.getAttribute('companionID'); 482 var companionID = cell.getAttribute('companionID');
483 var companion = $(companionID); 483 var companion = $(companionID);
484 companion.className = 'highlighted-cell'; 484 companion.className = 'highlighted-cell';
485
486 // If the cell has companionID2, then highlight it
487 var companionID2 = cell.getAttribute('companionID2');
dmazzoni 2016/11/14 21:37:37 Rather than two attributes, how about a single att
ultimatedbz 2016/11/15 18:04:02 That's a great idea! I also heard that attributes
488 if (companionID2 != undefined) {
489 var companion2 = $(companionID2);
490 companion2.className = 'highlighted-cell';
491 }
485 } 492 }
486 }; 493 };
487 494
488 var removeBorders = function(event) { 495 var removeBorders = function(event) {
489 var cell = event.target; 496 var cell = event.target;
490 if (cell.tagName == 'TD') { 497 if (cell.tagName == 'TD') {
491 cell.className = 'unhighlighted-cell'; 498 cell.className = 'unhighlighted-cell';
492 var companionID = cell.getAttribute('companionID'); 499 var companionID = cell.getAttribute('companionID');
493 var companion = $(companionID); 500 var companion = $(companionID);
494 companion.className = 'unhighlighted-cell'; 501 companion.className = 'unhighlighted-cell';
502
503 // If the cell has companionID2, then highlight it
504 var companionID2 = cell.getAttribute('companionID2');
505 if (companionID2 != undefined) {
506 var companion2 = $(companionID2);
507 companion2.className = 'unhighlighted-cell';
508 }
495 } 509 }
496 }; 510 };
497 511
498 this.brailleContainer_.addEventListener('mouseover', addBorders); 512 this.brailleContainer_.addEventListener('mouseover', addBorders);
499 this.brailleContainer_.addEventListener('mouseout', removeBorders); 513 this.brailleContainer_.addEventListener('mouseout', removeBorders);
500 514
501 // Clear the tables. 515 // Clear the tables.
502 var rowCount = this.brailleTableElement_.rows.length; 516 var rowCount = this.brailleTableElement_.rows.length;
503 for (var i = 0; i < rowCount; i++) { 517 for (var i = 0; i < rowCount; i++) {
504 this.brailleTableElement_.deleteRow(0); 518 this.brailleTableElement_.deleteRow(0);
505 } 519 }
506 rowCount = this.brailleTableElement2_.rows.length; 520 rowCount = this.brailleTableElement2_.rows.length;
507 for (var i = 0; i < rowCount; i++) { 521 for (var i = 0; i < rowCount; i++) {
508 this.brailleTableElement2_.deleteRow(0); 522 this.brailleTableElement2_.deleteRow(0);
509 } 523 }
510 524
511 var row1, row2; 525 var row1, row2;
512 rowCount = 0; 526 rowCount = 0;
527 var cellCount = cols;
513 for (var i = 0; i < groups.length; i++) { 528 for (var i = 0; i < groups.length; i++) {
514 if (i % cols == 0) { 529 if (cellCount == cols) {
530 cellCount = 0;
515 // Check if we reached the limit on the number of rows we can have. 531 // Check if we reached the limit on the number of rows we can have.
516 if (rowCount == rows) 532 if (rowCount == rows)
517 break; 533 break;
518 rowCount++; 534 rowCount++;
519 row1 = this.brailleTableElement_.insertRow(-1); 535 row1 = this.brailleTableElement_.insertRow(-1);
520 if (sideBySide) { 536 if (sideBySide) {
521 // Side by side. 537 // Side by side.
522 row2 = this.brailleTableElement2_.insertRow(-1); 538 row2 = this.brailleTableElement2_.insertRow(-1);
523 } else { 539 } else {
524 // Interleaved. 540 // Interleaved.
525 row2 = this.brailleTableElement_.insertRow(-1); 541 row2 = this.brailleTableElement_.insertRow(-1);
526 } 542 }
527 } 543 }
528 544
529 var topCell = row1.insertCell(-1); 545 var topCell = row1.insertCell(-1);
530 topCell.innerHTML = groups[i][0]; 546 topCell.innerHTML = groups[i][0];
531 topCell.id = i + '-textCell'; 547 topCell.id = i + '-textCell';
532 topCell.setAttribute('companionID', i + '-brailleCell'); 548 topCell.setAttribute('companionID', i + '-brailleCell');
533 topCell.className = 'unhighlighted-cell'; 549 topCell.className = 'unhighlighted-cell';
534 550
535 var bottomCell = row2.insertCell(-1); 551 var bottomCell = row2.insertCell(-1);
536 bottomCell.innerHTML = groups[i][1];
537 bottomCell.id = i + '-brailleCell'; 552 bottomCell.id = i + '-brailleCell';
538 bottomCell.setAttribute('companionID', i + '-textCell'); 553 bottomCell.setAttribute('companionID', i + '-textCell');
539 bottomCell.className = 'unhighlighted-cell'; 554 bottomCell.className = 'unhighlighted-cell';
555 if (cellCount + groups[i][1].length > cols) {
556 bottomCell.innerHTML = groups[i][1].substring(0, cols - cellCount);
557 if (rowCount == rows)
558 break;
559 rowCount++;
560 row1 = this.brailleTableElement_.insertRow(-1);
561 if (sideBySide) {
562 // Side by side.
563 row2 = this.brailleTableElement2_.insertRow(-1);
564 } else {
565 // Interleaved.
566 row2 = this.brailleTableElement_.insertRow(-1);
567 }
568 var bottomCell2 = row2.insertCell(-1);
569 bottomCell2.id = i + '-brailleCell2';
570 bottomCell2.setAttribute('companionID', i + '-textCell');
571 bottomCell2.setAttribute('companionID2', i + '-brailleCell');
572 bottomCell.setAttribute('companionID2', i + '-brailleCell2');
573 topCell.setAttribute('companionID2', i + '-brailleCell2');
574
575 bottomCell2.className = 'unhighlighted-cell';
576 bottomCell2.innerHTML = groups[i][1].substring(cols - cellCount);
577 cellCount = bottomCell2.innerHTML.length;
578 } else {
579 bottomCell.innerHTML = groups[i][1];
580 cellCount += groups[i][1].length;
581 }
540 } 582 }
541 }; 583 };
542 584
543 585
544 586
545 /** 587 /**
546 * Create a new node menu with the given name and add it to the menu bar. 588 * Create a new node menu with the given name and add it to the menu bar.
547 * @param {string} menuMsg The msg id of the new menu to add. 589 * @param {string} menuMsg The msg id of the new menu to add.
548 * @param {!chrome.automation.AutomationNode} node 590 * @param {!chrome.automation.AutomationNode} node
549 * @param {AutomationPredicate.Unary} pred 591 * @param {AutomationPredicate.Unary} pred
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 }, false); 884 }, false);
843 885
844 window.addEventListener('hashchange', function() { 886 window.addEventListener('hashchange', function() {
845 if (location.hash == '#fullscreen' || location.hash == '#focus') { 887 if (location.hash == '#fullscreen' || location.hash == '#focus') {
846 this.originalStickyState_ = cvox.ChromeVox.isStickyPrefOn; 888 this.originalStickyState_ = cvox.ChromeVox.isStickyPrefOn;
847 cvox.ChromeVox.isStickyPrefOn = false; 889 cvox.ChromeVox.isStickyPrefOn = false;
848 } else { 890 } else {
849 cvox.ChromeVox.isStickyPrefOn = this.originalStickyState_; 891 cvox.ChromeVox.isStickyPrefOn = this.originalStickyState_;
850 } 892 }
851 }, false); 893 }, false);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698