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

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

Issue 302063005: Fix crash when calling getMsg with no options. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/third_party/chromevox/chromeVoxChromePageScript.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 utility class for general braille functionality. 6 * @fileoverview A utility class for general braille functionality.
7 */ 7 */
8 8
9 9
10 goog.provide('cvox.BrailleUtil'); 10 goog.provide('cvox.BrailleUtil');
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 * Gets the braille state of a node. 185 * Gets the braille state of a node.
186 * @param {Node} node The node. 186 * @param {Node} node The node.
187 * @return {string} The string representation. 187 * @return {string} The string representation.
188 */ 188 */
189 cvox.BrailleUtil.getState = function(node) { 189 cvox.BrailleUtil.getState = function(node) {
190 if (!node) { 190 if (!node) {
191 return ''; 191 return '';
192 } 192 }
193 return cvox.NodeStateUtil.expand( 193 return cvox.NodeStateUtil.expand(
194 cvox.DomUtil.getStateMsgs(node, true).map(function(state) { 194 cvox.DomUtil.getStateMsgs(node, true).map(function(state) {
195 if (cvox.ChromeVox.msgs.getMsg(state[0] + '_brl')) { 195 // Check to see if a variant of the message with '_brl' exists,
196 // and use it if so.
197 //
198 // Note: many messages are templatized, and if we don't pass any
199 // argument to substitute, getMsg might throw an error if the
200 // resulting string is empty. To avoid this, we pass a dummy
201 // substitution string array here.
202 var dummySubs = ['dummy', 'dummy', 'dummy'];
203 if (cvox.ChromeVox.msgs.getMsg(state[0] + '_brl', dummySubs)) {
196 state[0] += '_brl'; 204 state[0] += '_brl';
197 } 205 }
198 return state; 206 return state;
199 })); 207 }));
200 }; 208 };
201 209
202 210
203 /** 211 /**
204 * Gets the braille container role of a node. 212 * Gets the braille container role of a node.
205 * @param {Node} prev The previous node in navigation. 213 * @param {Node} prev The previous node in navigation.
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 * @param {number} number The number to clamp. 414 * @param {number} number The number to clamp.
407 * @param {number} min The minimum value to return. 415 * @param {number} min The minimum value to return.
408 * @param {number} max The maximum value to return. 416 * @param {number} max The maximum value to return.
409 * @return {number} {@code number} if it is within the bounds, or the nearest 417 * @return {number} {@code number} if it is within the bounds, or the nearest
410 * number within the bounds otherwise. 418 * number within the bounds otherwise.
411 * @private 419 * @private
412 */ 420 */
413 cvox.BrailleUtil.clamp_ = function(number, min, max) { 421 cvox.BrailleUtil.clamp_ = function(number, min, max) {
414 return Math.min(Math.max(number, min), max); 422 return Math.min(Math.max(number, min), max);
415 }; 423 };
OLDNEW
« no previous file with comments | « no previous file | chrome/third_party/chromevox/chromeVoxChromePageScript.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698