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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
104 }, | 104 }, |
105 application: { | 105 application: { |
106 msgId: 'aria_role_application', | 106 msgId: 'aria_role_application', |
107 inherits: 'abstractContainer' | 107 inherits: 'abstractContainer' |
108 }, | 108 }, |
109 banner: { | 109 banner: { |
110 msgId: 'aria_role_banner', | 110 msgId: 'aria_role_banner', |
111 inherits: 'abstractContainer' | 111 inherits: 'abstractContainer' |
112 }, | 112 }, |
113 button: { | 113 button: { |
114 msgId: 'tag_button', | 114 msgId: 'aria_role_button', |
115 earconId: 'BUTTON' | 115 earconId: 'BUTTON' |
116 }, | 116 }, |
117 buttonDropDown: { | 117 buttonDropDown: { |
118 msgId: 'tag_button', | 118 msgId: 'aria_role_button', |
119 earconId: 'BUTTON' | 119 earconId: 'BUTTON' |
120 }, | 120 }, |
121 cell: { | 121 cell: { |
122 msgId: 'aria_role_gridcell' | 122 msgId: 'aria_role_gridcell' |
123 }, | 123 }, |
124 checkBox: { | 124 checkBox: { |
125 msgId: 'input_type_checkbox' | 125 msgId: 'aria_role_checkbox' |
126 }, | 126 }, |
127 columnHeader: { | 127 columnHeader: { |
128 msgId: 'aria_role_columnheader', | 128 msgId: 'aria_role_columnheader', |
129 inherits: 'abstractContainer' | 129 inherits: 'abstractContainer' |
130 }, | 130 }, |
131 comboBox: { | 131 comboBox: { |
132 msgId: 'aria_role_combobox' | 132 msgId: 'aria_role_combobox' |
133 }, | 133 }, |
134 complementary: { | 134 complementary: { |
135 msgId: 'aria_role_complementary', | 135 msgId: 'aria_role_complementary', |
136 inherits: 'abstractContainer' | 136 inherits: 'abstractContainer' |
137 }, | 137 }, |
138 contentInfo: { | 138 contentInfo: { |
139 msgId: 'aria_role_contentinfo', | 139 msgId: 'aria_role_contentinfo', |
140 inherits: 'abstractContainer' | 140 inherits: 'abstractContainer' |
141 }, | 141 }, |
142 date: { | 142 date: { |
143 msgId: 'input_type_date', | 143 msgId: 'input_type_date', |
144 inherits: 'abstractContainer' | 144 inherits: 'abstractContainer' |
145 }, | 145 }, |
146 definition: { | 146 definition: { |
147 msgId: 'aria_role_definition', | 147 msgId: 'aria_role_definition', |
148 inherits: 'abstractContainer' | 148 inherits: 'abstractContainer' |
149 }, | 149 }, |
150 dialog: { | 150 dialog: { |
151 msgId: 'dialog' | 151 msgId: 'aria_role_dialog' |
152 }, | 152 }, |
153 directory: { | 153 directory: { |
154 msgId: 'aria_role_directory', | 154 msgId: 'aria_role_directory', |
155 inherits: 'abstractContainer' | 155 inherits: 'abstractContainer' |
156 }, | 156 }, |
157 document: { | 157 document: { |
158 msgId: 'aria_role_document', | 158 msgId: 'aria_role_document', |
159 inherits: 'abstractContainer' | 159 inherits: 'abstractContainer' |
160 }, | 160 }, |
161 form: { | 161 form: { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 }, | 231 }, |
232 navigation: { | 232 navigation: { |
233 msgId: 'aria_role_navigation', | 233 msgId: 'aria_role_navigation', |
234 inherits: 'abstractContainer' | 234 inherits: 'abstractContainer' |
235 }, | 235 }, |
236 note: { | 236 note: { |
237 msgId: 'aria_role_note', | 237 msgId: 'aria_role_note', |
238 inherits: 'abstractContainer' | 238 inherits: 'abstractContainer' |
239 }, | 239 }, |
240 popUpButton: { | 240 popUpButton: { |
241 msgId: 'tag_button', | 241 msgId: 'aria_role_button', |
242 earcon: 'LISTBOX' | 242 earcon: 'LISTBOX' |
243 }, | 243 }, |
244 radioButton: { | 244 radioButton: { |
245 msgId: 'input_type_radio' | 245 msgId: 'aria_role_radio' |
246 }, | 246 }, |
247 radioGroup: { | 247 radioGroup: { |
248 msgId: 'aria_role_radiogroup', | 248 msgId: 'aria_role_radiogroup', |
249 }, | 249 }, |
250 region: { | 250 region: { |
251 msgId: 'aria_role_region', | 251 msgId: 'aria_role_region', |
252 inherits: 'abstractContainer' | 252 inherits: 'abstractContainer' |
253 }, | 253 }, |
254 rowHeader: { | 254 rowHeader: { |
255 msgId: 'aria_role_rowheader', | 255 msgId: 'aria_role_rowheader', |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
356 } | 356 } |
357 }; | 357 }; |
358 | 358 |
359 /** | 359 /** |
360 * Maps input types to message IDs. | 360 * Maps input types to message IDs. |
361 * @const {Object<string>} | 361 * @const {Object<string>} |
362 * @private | 362 * @private |
363 */ | 363 */ |
364 Output.INPUT_TYPE_MESSAGE_IDS_ = { | 364 Output.INPUT_TYPE_MESSAGE_IDS_ = { |
365 'email': 'input_type_email', | 365 'email': 'input_type_email', |
366 'file': 'input_type_file', | |
367 'number': 'input_type_number', | 366 'number': 'input_type_number', |
368 'password': 'input_type_password', | 367 'password': 'input_type_password', |
369 'search': 'input_type_search', | 368 'search': 'input_type_search', |
370 'tel': 'input_type_tel', | 369 'tel': 'input_type_number', |
dmazzoni
2015/09/25 16:23:35
Is this intentional? I think we should distinguish
| |
371 'text': 'input_type_text', | 370 'text': 'input_type_text', |
372 'url': 'input_type_url', | 371 'url': 'input_type_url', |
373 }; | 372 }; |
374 | 373 |
375 /** | 374 /** |
376 * Rules specifying format of AutomationNodes for output. | 375 * Rules specifying format of AutomationNodes for output. |
377 * @type {!Object<Object<Object<string>>>} | 376 * @type {!Object<Object<Object<string>>>} |
378 */ | 377 */ |
379 Output.RULES = { | 378 Output.RULES = { |
380 navigate: { | 379 navigate: { |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
888 var prev = null; | 887 var prev = null; |
889 if (node) | 888 if (node) |
890 prev = cursors.Range.fromNode(node); | 889 prev = cursors.Range.fromNode(node); |
891 this.range_(subrange, prev, 'navigate', buff); | 890 this.range_(subrange, prev, 'navigate', buff); |
892 } else if (token == 'role') { | 891 } else if (token == 'role') { |
893 options.annotation.push(token); | 892 options.annotation.push(token); |
894 var msg = node.role; | 893 var msg = node.role; |
895 var info = Output.ROLE_INFO_[node.role]; | 894 var info = Output.ROLE_INFO_[node.role]; |
896 if (info) { | 895 if (info) { |
897 if (this.formatOptions_.braille) | 896 if (this.formatOptions_.braille) |
898 msg = cvox.ChromeVox.msgs.getMsg(info.msgId + '_brl'); | 897 msg = Msgs.getMsg(info.msgId + '_brl'); |
899 else | 898 else |
900 msg = cvox.ChromeVox.msgs.getMsg(info.msgId); | 899 msg = Msgs.getMsg(info.msgId); |
901 } else { | 900 } else { |
902 console.error('Missing role info for ' + node.role); | 901 console.error('Missing role info for ' + node.role); |
903 } | 902 } |
904 this.append_(buff, msg, options); | 903 this.append_(buff, msg, options); |
905 } else if (token == 'inputType') { | 904 } else if (token == 'inputType') { |
906 if (!node.inputType) | 905 if (!node.inputType) |
907 return; | 906 return; |
908 options.annotation.push(token); | 907 options.annotation.push(token); |
909 var msgId = Output.INPUT_TYPE_MESSAGE_IDS_[node.inputType] || | 908 var msgId = Output.INPUT_TYPE_MESSAGE_IDS_[node.inputType] || |
910 'input_type_text'; | 909 'input_type_text'; |
911 if (this.formatOptions_.braille) | 910 if (this.formatOptions_.braille) |
912 msgId = msgId + '_brl'; | 911 msgId = msgId + '_brl'; |
913 this.append_(buff, cvox.ChromeVox.msgs.getMsg(msgId), options); | 912 this.append_(buff, Msgs.getMsg(msgId), options); |
914 } else if (token == 'tableRowIndex' || | 913 } else if (token == 'tableRowIndex' || |
915 token == 'tableCellColumnIndex') { | 914 token == 'tableCellColumnIndex') { |
916 var value = node[token]; | 915 var value = node[token]; |
917 if (!value) | 916 if (!value) |
918 return; | 917 return; |
919 value = String(value + 1); | 918 value = String(value + 1); |
920 options.annotation.push(token); | 919 options.annotation.push(token); |
921 this.append_(buff, value, options); | 920 this.append_(buff, value, options); |
922 } else if (node[token] !== undefined) { | 921 } else if (node[token] !== undefined) { |
923 options.annotation.push(token); | 922 options.annotation.push(token); |
(...skipping 11 matching lines...) Expand all Loading... | |
935 resolvedInfo = node.state[token] ? stateInfo.on : stateInfo.off; | 934 resolvedInfo = node.state[token] ? stateInfo.on : stateInfo.off; |
936 if (!resolvedInfo) | 935 if (!resolvedInfo) |
937 return; | 936 return; |
938 if (this.formatOptions_.speech && resolvedInfo.earconId) { | 937 if (this.formatOptions_.speech && resolvedInfo.earconId) { |
939 options.annotation.push( | 938 options.annotation.push( |
940 new Output.EarconAction(resolvedInfo.earconId)); | 939 new Output.EarconAction(resolvedInfo.earconId)); |
941 } | 940 } |
942 var msgId = | 941 var msgId = |
943 this.formatOptions_.braille ? resolvedInfo.msgId + '_brl' : | 942 this.formatOptions_.braille ? resolvedInfo.msgId + '_brl' : |
944 resolvedInfo.msgId; | 943 resolvedInfo.msgId; |
945 var msg = cvox.ChromeVox.msgs.getMsg(msgId); | 944 var msg = Msgs.getMsg(msgId); |
946 this.append_(buff, msg, options); | 945 this.append_(buff, msg, options); |
947 } else if (tree.firstChild) { | 946 } else if (tree.firstChild) { |
948 // Custom functions. | 947 // Custom functions. |
949 if (token == 'if') { | 948 if (token == 'if') { |
950 var cond = tree.firstChild; | 949 var cond = tree.firstChild; |
951 var attrib = cond.value.slice(1); | 950 var attrib = cond.value.slice(1); |
952 if (node[attrib] || node.state[attrib]) | 951 if (node[attrib] || node.state[attrib]) |
953 this.format_(node, cond.nextSibling, buff); | 952 this.format_(node, cond.nextSibling, buff); |
954 else | 953 else |
955 this.format_(node, cond.nextSibling.nextSibling, buff); | 954 this.format_(node, cond.nextSibling.nextSibling, buff); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
992 if (curArg.value[0] != '$') { | 991 if (curArg.value[0] != '$') { |
993 console.error('Unexpected value: ' + curArg.value); | 992 console.error('Unexpected value: ' + curArg.value); |
994 return; | 993 return; |
995 } | 994 } |
996 var msgBuff = []; | 995 var msgBuff = []; |
997 this.format_(node, curArg, msgBuff); | 996 this.format_(node, curArg, msgBuff); |
998 msgArgs = msgArgs.concat(msgBuff); | 997 msgArgs = msgArgs.concat(msgBuff); |
999 curArg = curArg.nextSibling; | 998 curArg = curArg.nextSibling; |
1000 } | 999 } |
1001 } | 1000 } |
1002 var msg = cvox.ChromeVox.msgs.getMsg(msgId, msgArgs); | 1001 var msg = Msgs.getMsg(msgId, msgArgs); |
1003 try { | 1002 try { |
1004 if (this.formatOptions_.braille) | 1003 if (this.formatOptions_.braille) |
1005 msg = cvox.ChromeVox.msgs.getMsg(msgId + '_brl', msgArgs) || msg; | 1004 msg = Msgs.getMsg(msgId + '_brl', msgArgs) || msg; |
1006 } catch(e) {} | 1005 } catch(e) {} |
1007 | 1006 |
1008 if (!msg) { | 1007 if (!msg) { |
1009 console.error('Could not get message ' + msgId); | 1008 console.error('Could not get message ' + msgId); |
1010 return; | 1009 return; |
1011 } | 1010 } |
1012 | 1011 |
1013 if (isPluralized) { | 1012 if (isPluralized) { |
1014 var arg = tree.firstChild; | 1013 var arg = tree.firstChild; |
1015 if (!arg || arg.nextSibling) { | 1014 if (!arg || arg.nextSibling) { |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1321 elem.end); | 1320 elem.end); |
1322 }); | 1321 }); |
1323 spansToRemove.forEach(result.removeSpan.bind(result)); | 1322 spansToRemove.forEach(result.removeSpan.bind(result)); |
1324 separator = Output.SPACE; | 1323 separator = Output.SPACE; |
1325 }); | 1324 }); |
1326 return result; | 1325 return result; |
1327 } | 1326 } |
1328 }; | 1327 }; |
1329 | 1328 |
1330 }); // goog.scope | 1329 }); // goog.scope |
OLD | NEW |