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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/common/spannable.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 Class which allows construction of annotated strings. 6 * @fileoverview Class which allows construction of annotated strings.
7 */ 7 */
8 8
9 goog.provide('cvox.Spannable'); 9 goog.provide('cvox.Spannable');
10 10
11 goog.require('goog.object'); 11 goog.require('goog.object');
12 12
13 /** 13 /**
14 * @constructor 14 * @constructor
15 * @param {string|!cvox.Spannable=} opt_string Initial value of the spannable. 15 * @param {string|!cvox.Spannable=} opt_string Initial value of the spannable.
16 * @param {*=} opt_annotation Initial annotation for the entire string. 16 * @param {*=} opt_annotation Initial annotation for the entire string.
17 */ 17 */
18 cvox.Spannable = function(opt_string, opt_annotation) { 18 cvox.Spannable = function(opt_string, opt_annotation) {
19 /** 19 /**
20 * Underlying string. 20 * Underlying string.
21 * @type {string} 21 * @type {string}
22 * @private 22 * @private
23 */ 23 */
24 this.string_ = opt_string instanceof cvox.Spannable ? '' : opt_string || ''; 24 this.string_ = opt_string instanceof cvox.Spannable ? '' : opt_string || '';
25 25
26 /** 26 /**
27 * Spans (annotations). 27 * Spans (annotations).
28 * @type {!Array.<!{ value: *, start: number, end: number }>} 28 * @type {!Array<!{ value: *, start: number, end: number }>}
29 * @private 29 * @private
30 */ 30 */
31 this.spans_ = []; 31 this.spans_ = [];
32 32
33 // Append the initial spannable. 33 // Append the initial spannable.
34 if (opt_string instanceof cvox.Spannable) 34 if (opt_string instanceof cvox.Spannable)
35 this.append(opt_string); 35 this.append(opt_string);
36 36
37 // Optionally annotate the entire string. 37 // Optionally annotate the entire string.
38 if (goog.isDef(opt_annotation)) { 38 if (goog.isDef(opt_annotation)) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 var span = this.spans_[i]; 135 var span = this.spans_[i];
136 if (span.value instanceof constructor) { 136 if (span.value instanceof constructor) {
137 return span.value; 137 return span.value;
138 } 138 }
139 } 139 }
140 }; 140 };
141 141
142 /** 142 /**
143 * Returns all span values which are an instance of a given constructor. 143 * Returns all span values which are an instance of a given constructor.
144 * @param {!Function} constructor Constructor. 144 * @param {!Function} constructor Constructor.
145 * @return {!Array.<Object>} Array of object. 145 * @return {!Array<Object>} Array of object.
146 */ 146 */
147 cvox.Spannable.prototype.getSpansInstanceOf = function(constructor) { 147 cvox.Spannable.prototype.getSpansInstanceOf = function(constructor) {
148 var ret = []; 148 var ret = [];
149 for (var i = 0; i < this.spans_.length; i++) { 149 for (var i = 0; i < this.spans_.length; i++) {
150 var span = this.spans_[i]; 150 var span = this.spans_[i];
151 if (span.value instanceof constructor) { 151 if (span.value instanceof constructor) {
152 ret.push(span.value); 152 ret.push(span.value);
153 } 153 }
154 } 154 }
155 return ret; 155 return ret;
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 * @typedef {{ctor: !Function, name: string, 398 * @typedef {{ctor: !Function, name: string,
399 * fromJson: function(!Object): !Object, 399 * fromJson: function(!Object): !Object,
400 * toJson: ((function(!Object): !Object)|undefined)}} 400 * toJson: ((function(!Object): !Object)|undefined)}}
401 * @private 401 * @private
402 */ 402 */
403 cvox.Spannable.SerializeInfo_; 403 cvox.Spannable.SerializeInfo_;
404 404
405 405
406 /** 406 /**
407 * The serialized format of a spannable. 407 * The serialized format of a spannable.
408 * @typedef {{string: string, spans: Array.<cvox.Spannable.SerializedSpan_>}} 408 * @typedef {{string: string, spans: Array<cvox.Spannable.SerializedSpan_>}}
409 * @private 409 * @private
410 */ 410 */
411 cvox.Spannable.SerializedSpannable_; 411 cvox.Spannable.SerializedSpannable_;
412 412
413 413
414 /** 414 /**
415 * The format of a single annotation in a serialized spannable. 415 * The format of a single annotation in a serialized spannable.
416 * @typedef {{type: string, value: !Object, start: number, end: number}} 416 * @typedef {{type: string, value: !Object, start: number, end: number}}
417 * @private 417 * @private
418 */ 418 */
419 cvox.Spannable.SerializedSpan_; 419 cvox.Spannable.SerializedSpan_;
420 420
421 /** 421 /**
422 * Maps type names to serialization info objects. 422 * Maps type names to serialization info objects.
423 * @type {Object.<string, cvox.Spannable.SerializeInfo_>} 423 * @type {Object<string, cvox.Spannable.SerializeInfo_>}
424 * @private 424 * @private
425 */ 425 */
426 cvox.Spannable.serializableSpansByName_ = {}; 426 cvox.Spannable.serializableSpansByName_ = {};
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698