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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/common/selection_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 A collection of JavaScript utilities used to improve selection 6 * @fileoverview A collection of JavaScript utilities used to improve selection
7 * at different granularities. 7 * at different granularities.
8 */ 8 */
9 9
10 10
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 var text = range.cloneContents().textContent; 200 var text = range.cloneContents().textContent;
201 var regExpWhiteSpace = new RegExp(/^\s+$/); 201 var regExpWhiteSpace = new RegExp(/^\s+$/);
202 return (! ((regExpWhiteSpace.test(text)) || 202 return (! ((regExpWhiteSpace.test(text)) ||
203 (text == ''))); 203 (text == '')));
204 }; 204 };
205 205
206 /** 206 /**
207 * Returns absolute top and left positions of an element. 207 * Returns absolute top and left positions of an element.
208 * 208 *
209 * @param {!Node} node The element for which to compute the position. 209 * @param {!Node} node The element for which to compute the position.
210 * @return {Array.<number>} Index 0 is the left; index 1 is the top. 210 * @return {Array<number>} Index 0 is the left; index 1 is the top.
211 * @private 211 * @private
212 */ 212 */
213 cvox.SelectionUtil.findPos_ = function(node) { 213 cvox.SelectionUtil.findPos_ = function(node) {
214 var curLeft = 0; 214 var curLeft = 0;
215 var curTop = 0; 215 var curTop = 0;
216 if (node.offsetParent) { 216 if (node.offsetParent) {
217 do { 217 do {
218 curLeft += node.offsetLeft; 218 curLeft += node.offsetLeft;
219 curTop += node.offsetTop; 219 curTop += node.offsetTop;
220 } while (node = node.offsetParent); 220 } while (node = node.offsetParent);
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 return this.getSelectionText_(); 581 return this.getSelectionText_();
582 } 582 }
583 }; 583 };
584 584
585 /** 585 /**
586 * Returns the selection as text instead of a selection object. Note that this 586 * Returns the selection as text instead of a selection object. Note that this
587 * function must be used in place of getting text directly from the DOM 587 * function must be used in place of getting text directly from the DOM
588 * if you want i18n tests to pass. 588 * if you want i18n tests to pass.
589 * 589 *
590 * @return {string} The text. 590 * @return {string} The text.
591 * @private
591 */ 592 */
592 cvox.SelectionUtil.getSelectionText_ = function() { 593 cvox.SelectionUtil.getSelectionText_ = function() {
593 return '' + window.getSelection(); 594 return '' + window.getSelection();
594 }; 595 };
595 596
596 597
597 /** 598 /**
598 * Returns a range as text instead of a selection object. Note that this 599 * Returns a range as text instead of a selection object. Note that this
599 * function must be used in place of getting text directly from the DOM 600 * function must be used in place of getting text directly from the DOM
600 * if you want i18n tests to pass. 601 * if you want i18n tests to pass.
601 * 602 *
602 * @param {Range} range A range. 603 * @param {Range} range A range.
603 * @return {string} The text. 604 * @return {string} The text.
604 */ 605 */
605 cvox.SelectionUtil.getRangeText = function(range) { 606 cvox.SelectionUtil.getRangeText = function(range) {
606 if (range) 607 if (range)
607 return range.cloneContents().textContent.replace(/\s+/g, ' '); 608 return range.cloneContents().textContent.replace(/\s+/g, ' ');
608 else 609 else
609 return ''; 610 return '';
610 }; 611 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698