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

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

Issue 1362223003: Improve braille related message descriptions and clean up message handling in Chromevox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@inputtypeexception
Patch Set: Move another braille message to Msgs.Untranslated Created 5 years, 2 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 The cvox.NodeState typedef. 6 * @fileoverview The cvox.NodeState typedef.
7 */ 7 */
8 8
9 goog.provide('cvox.NodeState'); 9 goog.provide('cvox.NodeState');
10 goog.provide('cvox.NodeStateUtil'); 10 goog.provide('cvox.NodeStateUtil');
11 11
12 goog.require('Msgs');
13
12 /** 14 /**
13 * Holds the state of a node. It is an Array or Arrays of strings and numbers. 15 * Holds the state of a node. It is an Array or Arrays of strings and numbers.
14 * Each sub array is in the format: 16 * Each sub array is in the format:
15 * [state, opt_arg, opt_arg, ...]. These sub arrays map directly to a 17 * [state, opt_arg, opt_arg, ...]. These sub arrays map directly to a
16 * cvox.ChromeVox.getMsg() call. For example [list_position, 3, 5] maps to 18 * cvox.ChromeVox.getMsg() call. For example [list_position, 3, 5] maps to
17 * getMsg('list_position', [3, 5]); 19 * getMsg('list_position', [3, 5]);
18 * 20 *
19 * @typedef {!Array<!Array<string|number>>} 21 * @typedef {!Array<!Array<string|number>>}
20 */ 22 */
21 cvox.NodeState; 23 cvox.NodeState;
22 24
23 /** 25 /**
24 * Returns a localized, readable string with the NodeState. 26 * Returns a localized, readable string with the NodeState.
25 * 27 *
26 * NOTE(deboer): Once AriaUtil and DomUtil are using NodeState exclusively, this 28 * NOTE(deboer): Once AriaUtil and DomUtil are using NodeState exclusively, this
27 * function can be moved into DescriptionUtil, removing the cvox.ChromeVox 29 * function can be moved into DescriptionUtil, removing the cvox.ChromeVox
28 * dependency here. 30 * dependency here.
29 * 31 *
30 * @param {cvox.NodeState} state The node state. 32 * @param {cvox.NodeState} state The node state.
31 * @return {string} The readable state string. 33 * @return {string} The readable state string.
32 */ 34 */
33 cvox.NodeStateUtil.expand = function(state) { 35 cvox.NodeStateUtil.expand = function(state) {
34 try { 36 try {
35 return state.map(function(s) { 37 return state.map(function(s) {
36 if (s.length < 1) { 38 if (s.length < 1) {
37 throw new Error('cvox.NodeState must have at least one entry'); 39 throw new Error('cvox.NodeState must have at least one entry');
38 } 40 }
39 var args = s.slice(1).map(function(a) { 41 var args = s.slice(1).map(function(a) {
40 if (typeof a == 'number') { 42 if (typeof a == 'number') {
41 return cvox.ChromeVox.msgs.getNumber(a); 43 return Msgs.getNumber(a);
42 } 44 }
43 return a; 45 return a;
44 }); 46 });
45 return cvox.ChromeVox.msgs.getMsg(/** @type {string} */ (s[0]), args); 47 return Msgs.getMsg(/** @type {string} */ (s[0]), args);
46 }).join(' '); 48 }).join(' ');
47 } catch (e) { 49 } catch (e) {
48 throw new Error('error: ' + e + ' state: ' + state); 50 throw new Error('error: ' + e + ' state: ' + state);
49 } 51 }
50 }; 52 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698