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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/common/traverse_util.js

Issue 924083004: Shorten Closure template notation from Array.<*> to Array<*> in cvox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 Low-level DOM traversal utility functions to find the 6 * @fileoverview Low-level DOM traversal utility functions to find the
7 * next (or previous) character, word, sentence, line, or paragraph, 7 * next (or previous) character, word, sentence, line, or paragraph,
8 * in a completely stateless manner without actually manipulating the 8 * in a completely stateless manner without actually manipulating the
9 * selection. 9 * selection.
10 */ 10 */
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 return true; 104 return true;
105 } 105 }
106 return false; 106 return false;
107 }; 107 };
108 108
109 /** 109 /**
110 * Moves the cursor forwards until it has crossed exactly one character. 110 * Moves the cursor forwards until it has crossed exactly one character.
111 * @param {cvox.Cursor} cursor The cursor location where the search should 111 * @param {cvox.Cursor} cursor The cursor location where the search should
112 * start. On exit, the cursor will be immediately to the right of the 112 * start. On exit, the cursor will be immediately to the right of the
113 * character returned. 113 * character returned.
114 * @param {Array.<Element>} elementsEntered Any HTML elements entered. 114 * @param {Array<Element>} elementsEntered Any HTML elements entered.
115 * @param {Array.<Element>} elementsLeft Any HTML elements left. 115 * @param {Array<Element>} elementsLeft Any HTML elements left.
116 * @return {?string} The character found, or null if the bottom of the 116 * @return {?string} The character found, or null if the bottom of the
117 * document has been reached. 117 * document has been reached.
118 */ 118 */
119 cvox.TraverseUtil.forwardsChar = function( 119 cvox.TraverseUtil.forwardsChar = function(
120 cursor, elementsEntered, elementsLeft) { 120 cursor, elementsEntered, elementsLeft) {
121 while (true) { 121 while (true) {
122 // Move down until we get to a leaf node. 122 // Move down until we get to a leaf node.
123 var childNode = null; 123 var childNode = null;
124 if (!cvox.TraverseUtil.treatAsLeafNode(cursor.node)) { 124 if (!cvox.TraverseUtil.treatAsLeafNode(cursor.node)) {
125 for (var i = cursor.index; i < cursor.node.childNodes.length; i++) { 125 for (var i = cursor.index; i < cursor.node.childNodes.length; i++) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 } 198 }
199 } 199 }
200 } 200 }
201 }; 201 };
202 202
203 /** 203 /**
204 * Moves the cursor backwards until it has crossed exactly one character. 204 * Moves the cursor backwards until it has crossed exactly one character.
205 * @param {cvox.Cursor} cursor The cursor location where the search should 205 * @param {cvox.Cursor} cursor The cursor location where the search should
206 * start. On exit, the cursor will be immediately to the left of the 206 * start. On exit, the cursor will be immediately to the left of the
207 * character returned. 207 * character returned.
208 * @param {Array.<Element>} elementsEntered Any HTML elements entered. 208 * @param {Array<Element>} elementsEntered Any HTML elements entered.
209 * @param {Array.<Element>} elementsLeft Any HTML elements left. 209 * @param {Array<Element>} elementsLeft Any HTML elements left.
210 * @return {?string} The previous character, or null if the top of the 210 * @return {?string} The previous character, or null if the top of the
211 * document has been reached. 211 * document has been reached.
212 */ 212 */
213 cvox.TraverseUtil.backwardsChar = function( 213 cvox.TraverseUtil.backwardsChar = function(
214 cursor, elementsEntered, elementsLeft) { 214 cursor, elementsEntered, elementsLeft) {
215 while (true) { 215 while (true) {
216 // Move down until we get to a leaf node. 216 // Move down until we get to a leaf node.
217 var childNode = null; 217 var childNode = null;
218 if (!cvox.TraverseUtil.treatAsLeafNode(cursor.node)) { 218 if (!cvox.TraverseUtil.treatAsLeafNode(cursor.node)) {
219 for (var i = cursor.index - 1; i >= 0; i--) { 219 for (var i = cursor.index - 1; i >= 0; i--) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 /** 303 /**
304 * Finds the next character, starting from endCursor. Upon exit, startCursor 304 * Finds the next character, starting from endCursor. Upon exit, startCursor
305 * and endCursor will surround the next character. If skipWhitespace is 305 * and endCursor will surround the next character. If skipWhitespace is
306 * true, will skip until a real character is found. Otherwise, it will 306 * true, will skip until a real character is found. Otherwise, it will
307 * attempt to select all of the whitespace between the initial position 307 * attempt to select all of the whitespace between the initial position
308 * of endCursor and the next non-whitespace character. 308 * of endCursor and the next non-whitespace character.
309 * @param {!cvox.Cursor} startCursor On exit, points to the position before 309 * @param {!cvox.Cursor} startCursor On exit, points to the position before
310 * the char. 310 * the char.
311 * @param {!cvox.Cursor} endCursor The position to start searching for the next 311 * @param {!cvox.Cursor} endCursor The position to start searching for the next
312 * char. On exit, will point to the position past the char. 312 * char. On exit, will point to the position past the char.
313 * @param {Array.<Element>} elementsEntered Any HTML elements entered. 313 * @param {Array<Element>} elementsEntered Any HTML elements entered.
314 * @param {Array.<Element>} elementsLeft Any HTML elements left. 314 * @param {Array<Element>} elementsLeft Any HTML elements left.
315 * initial and final cursor position will be pushed onto this array. 315 * initial and final cursor position will be pushed onto this array.
316 * @param {boolean} skipWhitespace If true, will keep scanning until a 316 * @param {boolean} skipWhitespace If true, will keep scanning until a
317 * non-whitespace character is found. 317 * non-whitespace character is found.
318 * @return {?string} The next char, or null if the bottom of the 318 * @return {?string} The next char, or null if the bottom of the
319 * document has been reached. 319 * document has been reached.
320 */ 320 */
321 cvox.TraverseUtil.getNextChar = function( 321 cvox.TraverseUtil.getNextChar = function(
322 startCursor, endCursor, elementsEntered, elementsLeft, skipWhitespace) { 322 startCursor, endCursor, elementsEntered, elementsLeft, skipWhitespace) {
323 323
324 // Save the starting position and get the first character. 324 // Save the starting position and get the first character.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 /** 366 /**
367 * Finds the previous character, starting from startCursor. Upon exit, 367 * Finds the previous character, starting from startCursor. Upon exit,
368 * startCursor and endCursor will surround the previous character. 368 * startCursor and endCursor will surround the previous character.
369 * If skipWhitespace is true, will skip until a real character is found. 369 * If skipWhitespace is true, will skip until a real character is found.
370 * Otherwise, it will attempt to select all of the whitespace between 370 * Otherwise, it will attempt to select all of the whitespace between
371 * the initial position of endCursor and the next non-whitespace character. 371 * the initial position of endCursor and the next non-whitespace character.
372 * @param {!cvox.Cursor} startCursor The position to start searching for the 372 * @param {!cvox.Cursor} startCursor The position to start searching for the
373 * char. On exit, will point to the position before the char. 373 * char. On exit, will point to the position before the char.
374 * @param {!cvox.Cursor} endCursor The position to start searching for the next 374 * @param {!cvox.Cursor} endCursor The position to start searching for the next
375 * char. On exit, will point to the position past the char. 375 * char. On exit, will point to the position past the char.
376 * @param {Array.<Element>} elementsEntered Any HTML elements entered. 376 * @param {Array<Element>} elementsEntered Any HTML elements entered.
377 * @param {Array.<Element>} elementsLeft Any HTML elements left. 377 * @param {Array<Element>} elementsLeft Any HTML elements left.
378 * initial and final cursor position will be pushed onto this array. 378 * initial and final cursor position will be pushed onto this array.
379 * @param {boolean} skipWhitespace If true, will keep scanning until a 379 * @param {boolean} skipWhitespace If true, will keep scanning until a
380 * non-whitespace character is found. 380 * non-whitespace character is found.
381 * @return {?string} The previous char, or null if the top of the 381 * @return {?string} The previous char, or null if the top of the
382 * document has been reached. 382 * document has been reached.
383 */ 383 */
384 cvox.TraverseUtil.getPreviousChar = function( 384 cvox.TraverseUtil.getPreviousChar = function(
385 startCursor, endCursor, elementsEntered, elementsLeft, skipWhitespace) { 385 startCursor, endCursor, elementsEntered, elementsLeft, skipWhitespace) {
386 386
387 // Save the starting position and get the first character. 387 // Save the starting position and get the first character.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 }; 424 };
425 425
426 /** 426 /**
427 * Finds the next word, starting from endCursor. Upon exit, startCursor 427 * Finds the next word, starting from endCursor. Upon exit, startCursor
428 * and endCursor will surround the next word. A word is defined to be 428 * and endCursor will surround the next word. A word is defined to be
429 * a string of 1 or more non-whitespace characters in the same DOM node. 429 * a string of 1 or more non-whitespace characters in the same DOM node.
430 * @param {cvox.Cursor} startCursor On exit, will point to the beginning of the 430 * @param {cvox.Cursor} startCursor On exit, will point to the beginning of the
431 * word returned. 431 * word returned.
432 * @param {cvox.Cursor} endCursor The position to start searching for the next 432 * @param {cvox.Cursor} endCursor The position to start searching for the next
433 * word. On exit, will point to the end of the word returned. 433 * word. On exit, will point to the end of the word returned.
434 * @param {Array.<Element>} elementsEntered Any HTML elements entered. 434 * @param {Array<Element>} elementsEntered Any HTML elements entered.
435 * @param {Array.<Element>} elementsLeft Any HTML elements left. 435 * @param {Array<Element>} elementsLeft Any HTML elements left.
436 * @return {?string} The next word, or null if the bottom of the 436 * @return {?string} The next word, or null if the bottom of the
437 * document has been reached. 437 * document has been reached.
438 */ 438 */
439 cvox.TraverseUtil.getNextWord = function(startCursor, endCursor, 439 cvox.TraverseUtil.getNextWord = function(startCursor, endCursor,
440 elementsEntered, elementsLeft) { 440 elementsEntered, elementsLeft) {
441 441
442 // Find the first non-whitespace or non-skipped character. 442 // Find the first non-whitespace or non-skipped character.
443 var cursor = endCursor.clone(); 443 var cursor = endCursor.clone();
444 var c = cvox.TraverseUtil.forwardsChar(cursor, elementsEntered, elementsLeft); 444 var c = cvox.TraverseUtil.forwardsChar(cursor, elementsEntered, elementsLeft);
445 if (c == null) 445 if (c == null)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 485
486 /** 486 /**
487 * Finds the previous word, starting from startCursor. Upon exit, startCursor 487 * Finds the previous word, starting from startCursor. Upon exit, startCursor
488 * and endCursor will surround the previous word. A word is defined to be 488 * and endCursor will surround the previous word. A word is defined to be
489 * a string of 1 or more non-whitespace characters in the same DOM node. 489 * a string of 1 or more non-whitespace characters in the same DOM node.
490 * @param {cvox.Cursor} startCursor The position to start searching for the 490 * @param {cvox.Cursor} startCursor The position to start searching for the
491 * previous word. On exit, will point to the beginning of the 491 * previous word. On exit, will point to the beginning of the
492 * word returned. 492 * word returned.
493 * @param {cvox.Cursor} endCursor On exit, will point to the end of the 493 * @param {cvox.Cursor} endCursor On exit, will point to the end of the
494 * word returned. 494 * word returned.
495 * @param {Array.<Element>} elementsEntered Any HTML elements entered. 495 * @param {Array<Element>} elementsEntered Any HTML elements entered.
496 * @param {Array.<Element>} elementsLeft Any HTML elements left. 496 * @param {Array<Element>} elementsLeft Any HTML elements left.
497 * @return {?string} The previous word, or null if the bottom of the 497 * @return {?string} The previous word, or null if the bottom of the
498 * document has been reached. 498 * document has been reached.
499 */ 499 */
500 cvox.TraverseUtil.getPreviousWord = function(startCursor, endCursor, 500 cvox.TraverseUtil.getPreviousWord = function(startCursor, endCursor,
501 elementsEntered, elementsLeft) { 501 elementsEntered, elementsLeft) {
502 // Find the first non-whitespace or non-skipped character. 502 // Find the first non-whitespace or non-skipped character.
503 var cursor = startCursor.clone(); 503 var cursor = startCursor.clone();
504 var c = cvox.TraverseUtil.backwardsChar( 504 var c = cvox.TraverseUtil.backwardsChar(
505 cursor, elementsEntered, elementsLeft); 505 cursor, elementsEntered, elementsLeft);
506 if (c == null) 506 if (c == null)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 return word; 539 return word;
540 } 540 }
541 541
542 return word; 542 return word;
543 }; 543 };
544 544
545 545
546 /** 546 /**
547 * Given elements entered and left, and break tags, returns true if the 547 * Given elements entered and left, and break tags, returns true if the
548 * current word should break. 548 * current word should break.
549 * @param {Array.<Element>} elementsEntered Any HTML elements entered. 549 * @param {Array<Element>} elementsEntered Any HTML elements entered.
550 * @param {Array.<Element>} elementsLeft Any HTML elements left. 550 * @param {Array<Element>} elementsLeft Any HTML elements left.
551 * @param {Object.<string, boolean>} breakTags Associative array of tags 551 * @param {Object<string, boolean>} breakTags Associative array of tags
552 * that should break. 552 * that should break.
553 * @return {boolean} True if elementsEntered or elementsLeft include an 553 * @return {boolean} True if elementsEntered or elementsLeft include an
554 * element with one of these tags. 554 * element with one of these tags.
555 */ 555 */
556 cvox.TraverseUtil.includesBreakTagOrSkippedNode = function( 556 cvox.TraverseUtil.includesBreakTagOrSkippedNode = function(
557 elementsEntered, elementsLeft, breakTags) { 557 elementsEntered, elementsLeft, breakTags) {
558 for (var i = 0; i < elementsEntered.length; i++) { 558 for (var i = 0; i < elementsEntered.length; i++) {
559 if (cvox.TraverseUtil.isHidden(elementsEntered[i])) { 559 if (cvox.TraverseUtil.isHidden(elementsEntered[i])) {
560 return true; 560 return true;
561 } 561 }
(...skipping 15 matching lines...) Expand all
577 577
578 578
579 /** 579 /**
580 * Finds the next sentence, starting from endCursor. Upon exit, 580 * Finds the next sentence, starting from endCursor. Upon exit,
581 * startCursor and endCursor will surround the next sentence. 581 * startCursor and endCursor will surround the next sentence.
582 * 582 *
583 * @param {cvox.Cursor} startCursor On exit, marks the beginning of the 583 * @param {cvox.Cursor} startCursor On exit, marks the beginning of the
584 * sentence. 584 * sentence.
585 * @param {cvox.Cursor} endCursor The position to start searching for the next 585 * @param {cvox.Cursor} endCursor The position to start searching for the next
586 * sentence. On exit, will point to the end of the returned string. 586 * sentence. On exit, will point to the end of the returned string.
587 * @param {Array.<Element>} elementsEntered Any HTML elements entered. 587 * @param {Array<Element>} elementsEntered Any HTML elements entered.
588 * @param {Array.<Element>} elementsLeft Any HTML elements left. 588 * @param {Array<Element>} elementsLeft Any HTML elements left.
589 * @param {Object.<string, boolean>} breakTags Associative array of tags 589 * @param {Object<string, boolean>} breakTags Associative array of tags
590 * that should break the sentence. 590 * that should break the sentence.
591 * @return {?string} The next sentence, or null if the bottom of the 591 * @return {?string} The next sentence, or null if the bottom of the
592 * document has been reached. 592 * document has been reached.
593 */ 593 */
594 cvox.TraverseUtil.getNextSentence = function( 594 cvox.TraverseUtil.getNextSentence = function(
595 startCursor, endCursor, elementsEntered, elementsLeft, breakTags) { 595 startCursor, endCursor, elementsEntered, elementsLeft, breakTags) {
596 return cvox.TraverseUtil.getNextString( 596 return cvox.TraverseUtil.getNextString(
597 startCursor, endCursor, elementsEntered, elementsLeft, 597 startCursor, endCursor, elementsEntered, elementsLeft,
598 function(str, word, elementsEntered, elementsLeft) { 598 function(str, word, elementsEntered, elementsLeft) {
599 if (str.substr(-1) == '.') 599 if (str.substr(-1) == '.')
600 return true; 600 return true;
601 return cvox.TraverseUtil.includesBreakTagOrSkippedNode( 601 return cvox.TraverseUtil.includesBreakTagOrSkippedNode(
602 elementsEntered, elementsLeft, breakTags); 602 elementsEntered, elementsLeft, breakTags);
603 }); 603 });
604 }; 604 };
605 605
606 /** 606 /**
607 * Finds the previous sentence, starting from startCursor. Upon exit, 607 * Finds the previous sentence, starting from startCursor. Upon exit,
608 * startCursor and endCursor will surround the previous sentence. 608 * startCursor and endCursor will surround the previous sentence.
609 * 609 *
610 * @param {cvox.Cursor} startCursor The position to start searching for the next 610 * @param {cvox.Cursor} startCursor The position to start searching for the next
611 * sentence. On exit, will point to the start of the returned string. 611 * sentence. On exit, will point to the start of the returned string.
612 * @param {cvox.Cursor} endCursor On exit, the end of the returned string. 612 * @param {cvox.Cursor} endCursor On exit, the end of the returned string.
613 * @param {Array.<Element>} elementsEntered Any HTML elements entered. 613 * @param {Array<Element>} elementsEntered Any HTML elements entered.
614 * @param {Array.<Element>} elementsLeft Any HTML elements left. 614 * @param {Array<Element>} elementsLeft Any HTML elements left.
615 * @param {Object.<string, boolean>} breakTags Associative array of tags 615 * @param {Object<string, boolean>} breakTags Associative array of tags
616 * that should break the sentence. 616 * that should break the sentence.
617 * @return {?string} The previous sentence, or null if the bottom of the 617 * @return {?string} The previous sentence, or null if the bottom of the
618 * document has been reached. 618 * document has been reached.
619 */ 619 */
620 cvox.TraverseUtil.getPreviousSentence = function( 620 cvox.TraverseUtil.getPreviousSentence = function(
621 startCursor, endCursor, elementsEntered, elementsLeft, breakTags) { 621 startCursor, endCursor, elementsEntered, elementsLeft, breakTags) {
622 return cvox.TraverseUtil.getPreviousString( 622 return cvox.TraverseUtil.getPreviousString(
623 startCursor, endCursor, elementsEntered, elementsLeft, 623 startCursor, endCursor, elementsEntered, elementsLeft,
624 function(str, word, elementsEntered, elementsLeft) { 624 function(str, word, elementsEntered, elementsLeft) {
625 if (word.substr(-1) == '.') 625 if (word.substr(-1) == '.')
626 return true; 626 return true;
627 return cvox.TraverseUtil.includesBreakTagOrSkippedNode( 627 return cvox.TraverseUtil.includesBreakTagOrSkippedNode(
628 elementsEntered, elementsLeft, breakTags); 628 elementsEntered, elementsLeft, breakTags);
629 }); 629 });
630 }; 630 };
631 631
632 /** 632 /**
633 * Finds the next line, starting from endCursor. Upon exit, 633 * Finds the next line, starting from endCursor. Upon exit,
634 * startCursor and endCursor will surround the next line. 634 * startCursor and endCursor will surround the next line.
635 * 635 *
636 * @param {cvox.Cursor} startCursor On exit, marks the beginning of the line. 636 * @param {cvox.Cursor} startCursor On exit, marks the beginning of the line.
637 * @param {cvox.Cursor} endCursor The position to start searching for the next 637 * @param {cvox.Cursor} endCursor The position to start searching for the next
638 * line. On exit, will point to the end of the returned string. 638 * line. On exit, will point to the end of the returned string.
639 * @param {Array.<Element>} elementsEntered Any HTML elements entered. 639 * @param {Array<Element>} elementsEntered Any HTML elements entered.
640 * @param {Array.<Element>} elementsLeft Any HTML elements left. 640 * @param {Array<Element>} elementsLeft Any HTML elements left.
641 * @param {Object.<string, boolean>} breakTags Associative array of tags 641 * @param {Object<string, boolean>} breakTags Associative array of tags
642 * that should break the line. 642 * that should break the line.
643 * @return {?string} The next line, or null if the bottom of the 643 * @return {?string} The next line, or null if the bottom of the
644 * document has been reached. 644 * document has been reached.
645 */ 645 */
646 cvox.TraverseUtil.getNextLine = function( 646 cvox.TraverseUtil.getNextLine = function(
647 startCursor, endCursor, elementsEntered, elementsLeft, breakTags) { 647 startCursor, endCursor, elementsEntered, elementsLeft, breakTags) {
648 var range = document.createRange(); 648 var range = document.createRange();
649 var currentRect = null; 649 var currentRect = null;
650 var rightMostRect = null; 650 var rightMostRect = null;
651 var prevCursor = endCursor.clone(); 651 var prevCursor = endCursor.clone();
(...skipping 23 matching lines...) Expand all
675 }); 675 });
676 }; 676 };
677 677
678 /** 678 /**
679 * Finds the previous line, starting from startCursor. Upon exit, 679 * Finds the previous line, starting from startCursor. Upon exit,
680 * startCursor and endCursor will surround the previous line. 680 * startCursor and endCursor will surround the previous line.
681 * 681 *
682 * @param {cvox.Cursor} startCursor The position to start searching for the next 682 * @param {cvox.Cursor} startCursor The position to start searching for the next
683 * line. On exit, will point to the start of the returned string. 683 * line. On exit, will point to the start of the returned string.
684 * @param {cvox.Cursor} endCursor On exit, the end of the returned string. 684 * @param {cvox.Cursor} endCursor On exit, the end of the returned string.
685 * @param {Array.<Element>} elementsEntered Any HTML elements entered. 685 * @param {Array<Element>} elementsEntered Any HTML elements entered.
686 * @param {Array.<Element>} elementsLeft Any HTML elements left. 686 * @param {Array<Element>} elementsLeft Any HTML elements left.
687 * @param {Object.<string, boolean>} breakTags Associative array of tags 687 * @param {Object<string, boolean>} breakTags Associative array of tags
688 * that should break the line. 688 * that should break the line.
689 * @return {?string} The previous line, or null if the bottom of the 689 * @return {?string} The previous line, or null if the bottom of the
690 * document has been reached. 690 * document has been reached.
691 */ 691 */
692 cvox.TraverseUtil.getPreviousLine = function( 692 cvox.TraverseUtil.getPreviousLine = function(
693 startCursor, endCursor, elementsEntered, elementsLeft, breakTags) { 693 startCursor, endCursor, elementsEntered, elementsLeft, breakTags) {
694 var range = document.createRange(); 694 var range = document.createRange();
695 var currentRect = null; 695 var currentRect = null;
696 var leftMostRect = null; 696 var leftMostRect = null;
697 var prevCursor = startCursor.clone(); 697 var prevCursor = startCursor.clone();
(...skipping 24 matching lines...) Expand all
722 }; 722 };
723 723
724 /** 724 /**
725 * Finds the next paragraph, starting from endCursor. Upon exit, 725 * Finds the next paragraph, starting from endCursor. Upon exit,
726 * startCursor and endCursor will surround the next paragraph. 726 * startCursor and endCursor will surround the next paragraph.
727 * 727 *
728 * @param {cvox.Cursor} startCursor On exit, marks the beginning of the 728 * @param {cvox.Cursor} startCursor On exit, marks the beginning of the
729 * paragraph. 729 * paragraph.
730 * @param {cvox.Cursor} endCursor The position to start searching for the next 730 * @param {cvox.Cursor} endCursor The position to start searching for the next
731 * paragraph. On exit, will point to the end of the returned string. 731 * paragraph. On exit, will point to the end of the returned string.
732 * @param {Array.<Element>} elementsEntered Any HTML elements entered. 732 * @param {Array<Element>} elementsEntered Any HTML elements entered.
733 * @param {Array.<Element>} elementsLeft Any HTML elements left. 733 * @param {Array<Element>} elementsLeft Any HTML elements left.
734 * @return {?string} The next paragraph, or null if the bottom of the 734 * @return {?string} The next paragraph, or null if the bottom of the
735 * document has been reached. 735 * document has been reached.
736 */ 736 */
737 cvox.TraverseUtil.getNextParagraph = function(startCursor, endCursor, 737 cvox.TraverseUtil.getNextParagraph = function(startCursor, endCursor,
738 elementsEntered, elementsLeft) { 738 elementsEntered, elementsLeft) {
739 return cvox.TraverseUtil.getNextString( 739 return cvox.TraverseUtil.getNextString(
740 startCursor, endCursor, elementsEntered, elementsLeft, 740 startCursor, endCursor, elementsEntered, elementsLeft,
741 function(str, word, elementsEntered, elementsLeft) { 741 function(str, word, elementsEntered, elementsLeft) {
742 for (var i = 0; i < elementsEntered.length; i++) { 742 for (var i = 0; i < elementsEntered.length; i++) {
743 if (cvox.TraverseUtil.isHidden(elementsEntered[i])) { 743 if (cvox.TraverseUtil.isHidden(elementsEntered[i])) {
(...skipping 14 matching lines...) Expand all
758 }); 758 });
759 }; 759 };
760 760
761 /** 761 /**
762 * Finds the previous paragraph, starting from startCursor. Upon exit, 762 * Finds the previous paragraph, starting from startCursor. Upon exit,
763 * startCursor and endCursor will surround the previous paragraph. 763 * startCursor and endCursor will surround the previous paragraph.
764 * 764 *
765 * @param {cvox.Cursor} startCursor The position to start searching for the next 765 * @param {cvox.Cursor} startCursor The position to start searching for the next
766 * paragraph. On exit, will point to the start of the returned string. 766 * paragraph. On exit, will point to the start of the returned string.
767 * @param {cvox.Cursor} endCursor On exit, the end of the returned string. 767 * @param {cvox.Cursor} endCursor On exit, the end of the returned string.
768 * @param {Array.<Element>} elementsEntered Any HTML elements entered. 768 * @param {Array<Element>} elementsEntered Any HTML elements entered.
769 * @param {Array.<Element>} elementsLeft Any HTML elements left. 769 * @param {Array<Element>} elementsLeft Any HTML elements left.
770 * @return {?string} The previous paragraph, or null if the bottom of the 770 * @return {?string} The previous paragraph, or null if the bottom of the
771 * document has been reached. 771 * document has been reached.
772 */ 772 */
773 cvox.TraverseUtil.getPreviousParagraph = function( 773 cvox.TraverseUtil.getPreviousParagraph = function(
774 startCursor, endCursor, elementsEntered, elementsLeft) { 774 startCursor, endCursor, elementsEntered, elementsLeft) {
775 return cvox.TraverseUtil.getPreviousString( 775 return cvox.TraverseUtil.getPreviousString(
776 startCursor, endCursor, elementsEntered, elementsLeft, 776 startCursor, endCursor, elementsEntered, elementsLeft,
777 function(str, word, elementsEntered, elementsLeft) { 777 function(str, word, elementsEntered, elementsLeft) {
778 for (var i = 0; i < elementsEntered.length; i++) { 778 for (var i = 0; i < elementsEntered.length; i++) {
779 if (cvox.TraverseUtil.isHidden(elementsEntered[i])) { 779 if (cvox.TraverseUtil.isHidden(elementsEntered[i])) {
(...skipping 28 matching lines...) Expand all
808 * next word: 808 * next word:
809 * str The string so far. 809 * str The string so far.
810 * word The next word to be added. 810 * word The next word to be added.
811 * elementsEntered The elements entered in reaching this next word. 811 * elementsEntered The elements entered in reaching this next word.
812 * elementsLeft The elements left in reaching this next word. 812 * elementsLeft The elements left in reaching this next word.
813 * 813 *
814 * @param {cvox.Cursor} startCursor On exit, will point to the beginning of the 814 * @param {cvox.Cursor} startCursor On exit, will point to the beginning of the
815 * next string. 815 * next string.
816 * @param {cvox.Cursor} endCursor The position to start searching for the next 816 * @param {cvox.Cursor} endCursor The position to start searching for the next
817 * string. On exit, will point to the end of the returned string. 817 * string. On exit, will point to the end of the returned string.
818 * @param {Array.<Element>} elementsEntered Any HTML elements entered. 818 * @param {Array<Element>} elementsEntered Any HTML elements entered.
819 * @param {Array.<Element>} elementsLeft Any HTML elements left. 819 * @param {Array<Element>} elementsLeft Any HTML elements left.
820 * @param {function(string, string, Array.<Element>, Array.<Element>)} 820 * @param {function(string, string, Array<Element>, Array<Element>)}
821 * breakBefore Function that takes the string so far, next word to be 821 * breakBefore Function that takes the string so far, next word to be
822 * added, and elements entered and left, and returns true if the string 822 * added, and elements entered and left, and returns true if the string
823 * should be ended before adding this word. 823 * should be ended before adding this word.
824 * @return {?string} The next string, or null if the bottom of the 824 * @return {?string} The next string, or null if the bottom of the
825 * document has been reached. 825 * document has been reached.
826 */ 826 */
827 cvox.TraverseUtil.getNextString = function( 827 cvox.TraverseUtil.getNextString = function(
828 startCursor, endCursor, elementsEntered, elementsLeft, breakBefore) { 828 startCursor, endCursor, elementsEntered, elementsLeft, breakBefore) {
829 // Get the first word and set the start cursor to the start of the 829 // Get the first word and set the start cursor to the start of the
830 // first word. 830 // first word.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 * the next. See getNextString, above, for more details. 870 * the next. See getNextString, above, for more details.
871 * 871 *
872 * Finds the previous contiguous string, starting from startCursor. Upon exit, 872 * Finds the previous contiguous string, starting from startCursor. Upon exit,
873 * startCursor and endCursor will surround the next string. 873 * startCursor and endCursor will surround the next string.
874 * 874 *
875 * @param {cvox.Cursor} startCursor The position to start searching for the 875 * @param {cvox.Cursor} startCursor The position to start searching for the
876 * previous string. On exit, will point to the beginning of the 876 * previous string. On exit, will point to the beginning of the
877 * string returned. 877 * string returned.
878 * @param {cvox.Cursor} endCursor On exit, will point to the end of the 878 * @param {cvox.Cursor} endCursor On exit, will point to the end of the
879 * string returned. 879 * string returned.
880 * @param {Array.<Element>} elementsEntered Any HTML elements entered. 880 * @param {Array<Element>} elementsEntered Any HTML elements entered.
881 * @param {Array.<Element>} elementsLeft Any HTML elements left. 881 * @param {Array<Element>} elementsLeft Any HTML elements left.
882 * @param {function(string, string, Array.<Element>, Array.<Element>)} 882 * @param {function(string, string, Array<Element>, Array<Element>)}
883 * breakBefore Function that takes the string so far, the word to be 883 * breakBefore Function that takes the string so far, the word to be
884 * added, and nodes crossed, and returns true if the string should be 884 * added, and nodes crossed, and returns true if the string should be
885 * ended before adding this word. 885 * ended before adding this word.
886 * @return {?string} The next string, or null if the top of the 886 * @return {?string} The next string, or null if the top of the
887 * document has been reached. 887 * document has been reached.
888 */ 888 */
889 cvox.TraverseUtil.getPreviousString = function( 889 cvox.TraverseUtil.getPreviousString = function(
890 startCursor, endCursor, elementsEntered, elementsLeft, breakBefore) { 890 startCursor, endCursor, elementsEntered, elementsLeft, breakBefore) {
891 // Get the first word and set the end cursor to the end of the 891 // Get the first word and set the end cursor to the end of the
892 // first word. 892 // first word.
(...skipping 25 matching lines...) Expand all
918 newEntered = []; 918 newEntered = [];
919 newLeft = []; 919 newLeft = [];
920 word = cvox.TraverseUtil.getPreviousWord( 920 word = cvox.TraverseUtil.getPreviousWord(
921 wordStartCursor, wordEndCursor, newEntered, newLeft); 921 wordStartCursor, wordEndCursor, newEntered, newLeft);
922 if (word == null) 922 if (word == null)
923 return str; 923 return str;
924 } 924 }
925 925
926 return str; 926 return str;
927 }; 927 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698