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 Provides output services for ChromeVox. | 6 * @fileoverview Provides output services for ChromeVox. |
7 */ | 7 */ |
8 | 8 |
9 goog.provide('Output'); | 9 goog.provide('Output'); |
10 goog.provide('Output.EventType'); | 10 goog.provide('Output.EventType'); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 } | 149 } |
150 }; | 150 }; |
151 | 151 |
152 /** | 152 /** |
153 * Rules specifying format of AutomationNodes for output. | 153 * Rules specifying format of AutomationNodes for output. |
154 * @type {!Object<string, Object<string, Object<string, string>>>} | 154 * @type {!Object<string, Object<string, Object<string, string>>>} |
155 */ | 155 */ |
156 Output.RULES = { | 156 Output.RULES = { |
157 navigate: { | 157 navigate: { |
158 'default': { | 158 'default': { |
159 speak: '$name $value $role', | 159 speak: '$name $value $description $role', |
160 braille: '' | 160 braille: '' |
161 }, | 161 }, |
162 alert: { | 162 alert: { |
163 speak: '!doNotInterrupt $role $descendants' | 163 speak: '!doNotInterrupt $role $descendants' |
164 }, | 164 }, |
165 checkBox: { | 165 checkBox: { |
166 speak: '$name $role $checked' | 166 speak: '$name $role $checked' |
167 }, | 167 }, |
168 dialog: { | 168 dialog: { |
169 enter: '$name $role' | 169 enter: '$name $role' |
(...skipping 30 matching lines...) Expand all Loading... |
200 }, | 200 }, |
201 popUpButton: { | 201 popUpButton: { |
202 speak: '$value $name $role @aria_has_popup ' + | 202 speak: '$value $name $role @aria_has_popup ' + |
203 '$if($collapsed, @aria_expanded_false, @aria_expanded_true)' | 203 '$if($collapsed, @aria_expanded_false, @aria_expanded_true)' |
204 }, | 204 }, |
205 radioButton: { | 205 radioButton: { |
206 speak: '$if($checked, @describe_radio_selected($name), ' + | 206 speak: '$if($checked, @describe_radio_selected($name), ' + |
207 '@describe_radio_unselected($name))' | 207 '@describe_radio_unselected($name))' |
208 }, | 208 }, |
209 slider: { | 209 slider: { |
210 speak: '@describe_slider($value, $name)' | 210 speak: '@describe_slider($value, $name) $help' |
211 }, | 211 }, |
212 staticText: { | 212 staticText: { |
213 speak: '$value $name' | 213 speak: '$value $name' |
214 }, | 214 }, |
215 tab: { | 215 tab: { |
216 speak: '@describe_tab($name)' | 216 speak: '@describe_tab($name)' |
217 }, | 217 }, |
218 toolbar: { | 218 toolbar: { |
219 enter: '$name $role' | 219 enter: '$name $role' |
220 }, | 220 }, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 * Possible events handled by ChromeVox internally. | 296 * Possible events handled by ChromeVox internally. |
297 * @enum {string} | 297 * @enum {string} |
298 */ | 298 */ |
299 Output.EventType = { | 299 Output.EventType = { |
300 NAVIGATE: 'navigate' | 300 NAVIGATE: 'navigate' |
301 }; | 301 }; |
302 | 302 |
303 Output.prototype = { | 303 Output.prototype = { |
304 /** | 304 /** |
305 * Gets the output buffer for speech. | 305 * Gets the output buffer for speech. |
| 306 * @param {string=} opt_separator Used to join components of the output. |
306 * @return {!cvox.Spannable} | 307 * @return {!cvox.Spannable} |
307 */ | 308 */ |
308 toSpannable: function() { | 309 toSpannable: function(opt_separator) { |
| 310 opt_separator = opt_separator || ''; |
309 return this.buffer_.reduce(function(prev, cur) { | 311 return this.buffer_.reduce(function(prev, cur) { |
| 312 if (prev === null) |
| 313 return cur; |
| 314 prev.append(opt_separator); |
310 prev.append(cur); | 315 prev.append(cur); |
311 return prev; | 316 return prev; |
312 }, new cvox.Spannable()); | 317 }, null); |
313 }, | 318 }, |
314 | 319 |
315 /** | 320 /** |
| 321 * Gets the output buffer for speech with separator '|'. |
| 322 * @return {!cvox.Spannable} |
| 323 */ |
| 324 toSpannableForTest: function() { |
| 325 return this.toSpannable('|'); |
| 326 }, |
| 327 |
| 328 /** |
316 * Specify ranges for speech. | 329 * Specify ranges for speech. |
317 * @param {!cursors.Range} range | 330 * @param {!cursors.Range} range |
318 * @param {cursors.Range} prevRange | 331 * @param {cursors.Range} prevRange |
319 * @param {chrome.automation.EventType|Output.EventType} type | 332 * @param {chrome.automation.EventType|Output.EventType} type |
320 * @return {!Output} | 333 * @return {!Output} |
321 */ | 334 */ |
322 withSpeech: function(range, prevRange, type) { | 335 withSpeech: function(range, prevRange, type) { |
323 this.formatOptions_ = {speech: true, braille: false, location: true}; | 336 this.formatOptions_ = {speech: true, braille: false, location: true}; |
324 this.render_(range, prevRange, type, this.buffer_); | 337 this.render_(range, prevRange, type, this.buffer_); |
325 return this; | 338 return this; |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 } | 880 } |
868 | 881 |
869 if (currentNode != root) | 882 if (currentNode != root) |
870 throw 'Unbalanced parenthesis.'; | 883 throw 'Unbalanced parenthesis.'; |
871 | 884 |
872 return root; | 885 return root; |
873 } | 886 } |
874 }; | 887 }; |
875 | 888 |
876 }); // goog.scope | 889 }); // goog.scope |
OLD | NEW |