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

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

Issue 2544203004: Display images in multiline Braille
Patch Set: Minor Nits, added TODO comments Created 4 years 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 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 var rowCount = this.brailleTableElement_.rows.length; 502 var rowCount = this.brailleTableElement_.rows.length;
503 for (var i = 0; i < rowCount; i++) { 503 for (var i = 0; i < rowCount; i++) {
504 this.brailleTableElement_.deleteRow(0); 504 this.brailleTableElement_.deleteRow(0);
505 } 505 }
506 rowCount = this.brailleTableElement2_.rows.length; 506 rowCount = this.brailleTableElement2_.rows.length;
507 for (var i = 0; i < rowCount; i++) { 507 for (var i = 0; i < rowCount; i++) {
508 this.brailleTableElement2_.deleteRow(0); 508 this.brailleTableElement2_.deleteRow(0);
509 } 509 }
510 510
511 var row1, row2; 511 var row1, row2;
512 // Number of rows already written.
512 rowCount = 0; 513 rowCount = 0;
514 // Number of cells already written in this row.
515 var cellCount = cols;
513 for (var i = 0; i < groups.length; i++) { 516 for (var i = 0; i < groups.length; i++) {
514 if (i % cols == 0) { 517 if (i % cols == 0) {
515 // Check if we reached the limit on the number of rows we can have. 518 // Check if we reached the limit on the number of rows we can have.
516 if (rowCount == rows) 519 if (rowCount == rows)
517 break; 520 break;
518 rowCount++; 521 rowCount++;
519 row1 = this.brailleTableElement_.insertRow(-1); 522 row1 = this.brailleTableElement_.insertRow(-1);
520 if (sideBySide) { 523 if (sideBySide) {
521 // Side by side. 524 // Side by side.
522 row2 = this.brailleTableElement2_.insertRow(-1); 525 row2 = this.brailleTableElement2_.insertRow(-1);
523 } else { 526 } else {
524 // Interleaved. 527 // Interleaved.
525 row2 = this.brailleTableElement_.insertRow(-1); 528 row2 = this.brailleTableElement_.insertRow(-1);
526 } 529 }
527 } 530 }
528 531
529 var topCell = row1.insertCell(-1); 532 var topCell = row1.insertCell(-1);
530 topCell.innerHTML = groups[i][0]; 533 topCell.innerHTML = groups[i][0];
531 topCell.id = i + '-textCell'; 534 topCell.id = i + '-textCell';
532 topCell.setAttribute('companionID', i + '-brailleCell'); 535 topCell.setAttribute('companionID', i + '-brailleCell');
533 topCell.className = 'unhighlighted-cell'; 536 topCell.className = 'unhighlighted-cell';
534 537
535 var bottomCell = row2.insertCell(-1); 538 var bottomCell = row2.insertCell(-1);
536 bottomCell.innerHTML = groups[i][1]; 539 bottomCell.innerHTML = groups[i][1];
537 bottomCell.id = i + '-brailleCell'; 540 bottomCell.id = i + '-brailleCell';
538 bottomCell.setAttribute('companionID', i + '-textCell'); 541 bottomCell.setAttribute('companionID', i + '-textCell');
539 bottomCell.className = 'unhighlighted-cell'; 542 bottomCell.className = 'unhighlighted-cell';
543 if (cellCount + groups[i][1].length > cols) {
544 var brailleText = groups[i][1];
545 while (cellCount + brailleText.length > cols) {
546 // At this point we already have a bottomCell to fill, so fill it.
547 bottomCell.innerHTML = brailleText.substring(0, cols - cellCount);
548 // Update to see what we still have to fill.
549 brailleText = brailleText.substring(cols - cellCount);
550 // Make new row.
551 if (rowCount == rows)
552 break;
553 rowCount++;
554 row1 = this.brailleTableElement_.insertRow(-1);
555 if (sideBySide) {
556 // Side by side.
557 row2 = this.brailleTableElement2_.insertRow(-1);
558 } else {
559 // Interleaved.
560 row2 = this.brailleTableElement_.insertRow(-1);
561 }
562 var bottomCell2 = row2.insertCell(-1);
563 bottomCell2.id = i + '-brailleCell2';
564 bottomCell2.setAttribute('data-companionIDs',
565 i + '-textCell ' + i + '-brailleCell');
566 bottomCell.setAttribute('data-companionIDs',
567 bottomCell.getAttribute('data-companionIDs') +
568 ' ' + i + '-brailleCell2');
569 topCell.setAttribute('data-companionID2',
570 bottomCell.getAttribute('data-companionIDs') +
571 ' ' + i + '-brailleCell2');
572
573 bottomCell2.className = 'unhighlighted-cell';
574 bottomCell = bottomCell2;
575 cellCount = 0;
576 }
577 // Fill the rest.
578 bottomCell.innerHTML = brailleText;
579 cellCount = brailleText.length;
580
581 } else {
582 bottomCell.innerHTML = groups[i][1];
583 cellCount += groups[i][1].length;
584 }
540 } 585 }
541 }; 586 };
542 587
543 588
544 589
545 /** 590 /**
546 * Create a new node menu with the given name and add it to the menu bar. 591 * 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. 592 * @param {string} menuMsg The msg id of the new menu to add.
548 * @param {!chrome.automation.AutomationNode} node 593 * @param {!chrome.automation.AutomationNode} node
549 * @param {AutomationPredicate.Unary} pred 594 * @param {AutomationPredicate.Unary} pred
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 }, false); 887 }, false);
843 888
844 window.addEventListener('hashchange', function() { 889 window.addEventListener('hashchange', function() {
845 if (location.hash == '#fullscreen' || location.hash == '#focus') { 890 if (location.hash == '#fullscreen' || location.hash == '#focus') {
846 this.originalStickyState_ = cvox.ChromeVox.isStickyPrefOn; 891 this.originalStickyState_ = cvox.ChromeVox.isStickyPrefOn;
847 cvox.ChromeVox.isStickyPrefOn = false; 892 cvox.ChromeVox.isStickyPrefOn = false;
848 } else { 893 } else {
849 cvox.ChromeVox.isStickyPrefOn = this.originalStickyState_; 894 cvox.ChromeVox.isStickyPrefOn = this.originalStickyState_;
850 } 895 }
851 }, false); 896 }, false);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698