| OLD | NEW |
| 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 15 matching lines...) Expand all Loading... |
| 26 * @const {string} | 26 * @const {string} |
| 27 */ | 27 */ |
| 28 cvox.BrailleUtil.ITEM_SEPARATOR = ' '; | 28 cvox.BrailleUtil.ITEM_SEPARATOR = ' '; |
| 29 | 29 |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * Messages considered as containers in braille. | 32 * Messages considered as containers in braille. |
| 33 * Containers are distinguished from roles by their appearance higher up in the | 33 * Containers are distinguished from roles by their appearance higher up in the |
| 34 * DOM tree of a selected node. | 34 * DOM tree of a selected node. |
| 35 * This list should be very short. | 35 * This list should be very short. |
| 36 * @type {!Array.<string>} | 36 * @type {!Array<string>} |
| 37 */ | 37 */ |
| 38 cvox.BrailleUtil.CONTAINER = [ | 38 cvox.BrailleUtil.CONTAINER = [ |
| 39 'tag_h1_brl', | 39 'tag_h1_brl', |
| 40 'tag_h2_brl', | 40 'tag_h2_brl', |
| 41 'tag_h3_brl', | 41 'tag_h3_brl', |
| 42 'tag_h4_brl', | 42 'tag_h4_brl', |
| 43 'tag_h5_brl', | 43 'tag_h5_brl', |
| 44 'tag_h6_brl' | 44 'tag_h6_brl' |
| 45 ]; | 45 ]; |
| 46 | 46 |
| 47 | 47 |
| 48 /** | 48 /** |
| 49 * Maps a ChromeVox message id to a braille template. | 49 * Maps a ChromeVox message id to a braille template. |
| 50 * The template takes one-character specifiers: | 50 * The template takes one-character specifiers: |
| 51 * n: replaced with braille name. | 51 * n: replaced with braille name. |
| 52 * r: replaced with braille role. | 52 * r: replaced with braille role. |
| 53 * s: replaced with braille state. | 53 * s: replaced with braille state. |
| 54 * c: replaced with braille container role; this potentially returns whitespace, | 54 * c: replaced with braille container role; this potentially returns whitespace, |
| 55 * so place at the beginning or end of templates for trimming. | 55 * so place at the beginning or end of templates for trimming. |
| 56 * v: replaced with braille value. | 56 * v: replaced with braille value. |
| 57 * @type {Object.<string, string>} | 57 * @type {Object<string, string>} |
| 58 */ | 58 */ |
| 59 cvox.BrailleUtil.TEMPLATE = { | 59 cvox.BrailleUtil.TEMPLATE = { |
| 60 'base': 'c n v r s', | 60 'base': 'c n v r s', |
| 61 'aria_role_alert': 'r: n', | 61 'aria_role_alert': 'r: n', |
| 62 'aria_role_button': 'n r s', | 62 'aria_role_button': 'n r s', |
| 63 'aria_role_checkbox': 'n r (s)', | 63 'aria_role_checkbox': 'n r (s)', |
| 64 'aria_role_menuitemcheckbox': 'n r (s)', | 64 'aria_role_menuitemcheckbox': 'n r (s)', |
| 65 'aria_role_menuitemradio': 'n r (s)', | 65 'aria_role_menuitemradio': 'n r (s)', |
| 66 'aria_role_radio': 'n r (s)', | 66 'aria_role_radio': 'n r (s)', |
| 67 'aria_role_textbox': 'n: v r s', | 67 'aria_role_textbox': 'n: v r s', |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 * @param {number} number The number to clamp. | 371 * @param {number} number The number to clamp. |
| 372 * @param {number} min The minimum value to return. | 372 * @param {number} min The minimum value to return. |
| 373 * @param {number} max The maximum value to return. | 373 * @param {number} max The maximum value to return. |
| 374 * @return {number} {@code number} if it is within the bounds, or the nearest | 374 * @return {number} {@code number} if it is within the bounds, or the nearest |
| 375 * number within the bounds otherwise. | 375 * number within the bounds otherwise. |
| 376 * @private | 376 * @private |
| 377 */ | 377 */ |
| 378 cvox.BrailleUtil.clamp_ = function(number, min, max) { | 378 cvox.BrailleUtil.clamp_ = function(number, min, max) { |
| 379 return Math.min(Math.max(number, min), max); | 379 return Math.min(Math.max(number, min), max); |
| 380 }; | 380 }; |
| OLD | NEW |