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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/braille/braille_table.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 Holds information about a braille table. 6 * @fileoverview Holds information about a braille table.
7 */ 7 */
8 8
9 goog.provide('cvox.BrailleTable'); 9 goog.provide('cvox.BrailleTable');
10 10
(...skipping 19 matching lines...) Expand all
30 30
31 /** 31 /**
32 * @const {string} 32 * @const {string}
33 * @private 33 * @private
34 */ 34 */
35 cvox.BrailleTable.COMMON_DEFS_FILENAME_ = 'cvox-common.cti'; 35 cvox.BrailleTable.COMMON_DEFS_FILENAME_ = 'cvox-common.cti';
36 36
37 37
38 /** 38 /**
39 * Retrieves a list of all available braille tables. 39 * Retrieves a list of all available braille tables.
40 * @param {function(!Array.<cvox.BrailleTable.Table>)} callback 40 * @param {function(!Array<cvox.BrailleTable.Table>)} callback
41 * Called asynchronously with an array of tables. 41 * Called asynchronously with an array of tables.
42 */ 42 */
43 cvox.BrailleTable.getAll = function(callback) { 43 cvox.BrailleTable.getAll = function(callback) {
44 function appendCommonFilename(tables) { 44 function appendCommonFilename(tables) {
45 // Append the common definitions to all table filenames. 45 // Append the common definitions to all table filenames.
46 tables.forEach(function(table) { 46 tables.forEach(function(table) {
47 table.fileNames += (',' + cvox.BrailleTable.COMMON_DEFS_FILENAME_); 47 table.fileNames += (',' + cvox.BrailleTable.COMMON_DEFS_FILENAME_);
48 }); 48 });
49 return tables; 49 return tables;
50 } 50 }
51 var url = chrome.extension.getURL(cvox.BrailleTable.TABLE_PATH); 51 var url = chrome.extension.getURL(cvox.BrailleTable.TABLE_PATH);
52 if (!url) { 52 if (!url) {
53 throw 'Invalid path: ' + cvox.BrailleTable.TABLE_PATH; 53 throw 'Invalid path: ' + cvox.BrailleTable.TABLE_PATH;
54 } 54 }
55 55
56 var xhr = new XMLHttpRequest(); 56 var xhr = new XMLHttpRequest();
57 xhr.open('GET', url, true); 57 xhr.open('GET', url, true);
58 xhr.onreadystatechange = function() { 58 xhr.onreadystatechange = function() {
59 if (xhr.readyState == 4) { 59 if (xhr.readyState == 4) {
60 if (xhr.status == 200) { 60 if (xhr.status == 200) {
61 callback( 61 callback(
62 appendCommonFilename( 62 appendCommonFilename(
63 /** @type {!Array.<cvox.BrailleTable.Table>} */ ( 63 /** @type {!Array<cvox.BrailleTable.Table>} */ (
64 JSON.parse(xhr.responseText)))); 64 JSON.parse(xhr.responseText))));
65 } 65 }
66 } 66 }
67 }; 67 };
68 xhr.send(); 68 xhr.send();
69 }; 69 };
70 70
71 71
72 /** 72 /**
73 * Finds a table in a list of tables by id. 73 * Finds a table in a list of tables by id.
74 * @param {!Array.<cvox.BrailleTable.Table>} tables tables to search in. 74 * @param {!Array<cvox.BrailleTable.Table>} tables tables to search in.
75 * @param {string} id id of table to find. 75 * @param {string} id id of table to find.
76 * @return {cvox.BrailleTable.Table} The found table, or null if not found. 76 * @return {cvox.BrailleTable.Table} The found table, or null if not found.
77 */ 77 */
78 cvox.BrailleTable.forId = function(tables, id) { 78 cvox.BrailleTable.forId = function(tables, id) {
79 return tables.filter(function(table) { return table.id === id })[0] || null; 79 return tables.filter(function(table) { return table.id === id })[0] || null;
80 }; 80 };
81 81
82 82
83 /** 83 /**
84 * Returns an uncontracted braille table corresponding to another, possibly 84 * Returns an uncontracted braille table corresponding to another, possibly
85 * contracted, table. If {@code table} is the lowest-grade table for its 85 * contracted, table. If {@code table} is the lowest-grade table for its
86 * locale and dot count, {@code table} itself is returned. 86 * locale and dot count, {@code table} itself is returned.
87 * @param {!Array.<cvox.BrailleTable.Table>} tables tables to search in. 87 * @param {!Array<cvox.BrailleTable.Table>} tables tables to search in.
88 * @param {!cvox.BrailleTable.Table} table Table to match. 88 * @param {!cvox.BrailleTable.Table} table Table to match.
89 * @return {!cvox.BrailleTable.Table} Corresponding uncontracted table, 89 * @return {!cvox.BrailleTable.Table} Corresponding uncontracted table,
90 * or {@code table} if it is uncontracted. 90 * or {@code table} if it is uncontracted.
91 */ 91 */
92 cvox.BrailleTable.getUncontracted = function(tables, table) { 92 cvox.BrailleTable.getUncontracted = function(tables, table) {
93 function mostUncontractedOf(current, candidate) { 93 function mostUncontractedOf(current, candidate) {
94 // An 8 dot table for the same language is prefered over a 6 dot table 94 // An 8 dot table for the same language is prefered over a 6 dot table
95 // even if the locales differ by region. 95 // even if the locales differ by region.
96 if (current.dots === '6' && 96 if (current.dots === '6' &&
97 candidate.dots === '8' && 97 candidate.dots === '8' &&
(...skipping 26 matching lines...) Expand all
124 return msgs.getMsg('braille_table_name_with_grade', 124 return msgs.getMsg('braille_table_name_with_grade',
125 [localeName, table.grade]); 125 [localeName, table.grade]);
126 } else if (!table.grade && table.variant) { 126 } else if (!table.grade && table.variant) {
127 return msgs.getMsg('braille_table_name_with_variant', 127 return msgs.getMsg('braille_table_name_with_variant',
128 [localeName, table.variant]); 128 [localeName, table.variant]);
129 } else { 129 } else {
130 return msgs.getMsg('braille_table_name_with_variant_and_grade', 130 return msgs.getMsg('braille_table_name_with_variant_and_grade',
131 [localeName, table.variant, table.grade]); 131 [localeName, table.variant, table.grade]);
132 } 132 }
133 }; 133 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698