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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js

Issue 2550223002: Support basic stereo pan positioning for earcons (Closed)
Patch Set: Fix test. Created 4 years 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 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 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 }; 620 };
621 621
622 Output.Action.prototype = { 622 Output.Action.prototype = {
623 run: function() { 623 run: function() {
624 } 624 }
625 }; 625 };
626 626
627 /** 627 /**
628 * Action to play an earcon. 628 * Action to play an earcon.
629 * @param {string} earconId 629 * @param {string} earconId
630 * @param {chrome.automation.Rect=} opt_location
630 * @constructor 631 * @constructor
631 * @extends {Output.Action} 632 * @extends {Output.Action}
632 */ 633 */
633 Output.EarconAction = function(earconId) { 634 Output.EarconAction = function(earconId, opt_location) {
634 Output.Action.call(this); 635 Output.Action.call(this);
635 /** @type {string} */ 636 /** @type {string} */
636 this.earconId = earconId; 637 this.earconId = earconId;
638 /** @type {chrome.automation.Rect|undefined} */
639 this.location = opt_location;
637 }; 640 };
638 641
639 Output.EarconAction.prototype = { 642 Output.EarconAction.prototype = {
640 __proto__: Output.Action.prototype, 643 __proto__: Output.Action.prototype,
641 644
642 /** @override */ 645 /** @override */
643 run: function() { 646 run: function() {
644 cvox.ChromeVox.earcons.playEarcon(cvox.Earcon[this.earconId]); 647 cvox.ChromeVox.earcons.playEarcon(
648 cvox.Earcon[this.earconId], this.location);
649 },
650
651 /** @override */
652 toJSON: function() {
653 return {earconId: this.earconId};
645 } 654 }
646 }; 655 };
647 656
648 /** 657 /**
649 * Annotation for text with a selection inside it. 658 * Annotation for text with a selection inside it.
650 * @param {number} startIndex 659 * @param {number} startIndex
651 * @param {number} endIndex 660 * @param {number} endIndex
652 * @constructor 661 * @constructor
653 */ 662 */
654 Output.SelectionSpan = function(startIndex, endIndex) { 663 Output.SelectionSpan = function(startIndex, endIndex) {
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 this.append_(buff, value, options); 1250 this.append_(buff, value, options);
1242 } else if (Output.STATE_INFO_[token]) { 1251 } else if (Output.STATE_INFO_[token]) {
1243 options.annotation.push('state'); 1252 options.annotation.push('state');
1244 var stateInfo = Output.STATE_INFO_[token]; 1253 var stateInfo = Output.STATE_INFO_[token];
1245 var resolvedInfo = {}; 1254 var resolvedInfo = {};
1246 resolvedInfo = node.state[token] ? stateInfo.on : stateInfo.off; 1255 resolvedInfo = node.state[token] ? stateInfo.on : stateInfo.off;
1247 if (!resolvedInfo) 1256 if (!resolvedInfo)
1248 return; 1257 return;
1249 if (this.formatOptions_.speech && resolvedInfo.earconId) { 1258 if (this.formatOptions_.speech && resolvedInfo.earconId) {
1250 options.annotation.push( 1259 options.annotation.push(
1251 new Output.EarconAction(resolvedInfo.earconId)); 1260 new Output.EarconAction(resolvedInfo.earconId), node.location);
1252 } 1261 }
1253 var msgId = 1262 var msgId =
1254 this.formatOptions_.braille ? resolvedInfo.msgId + '_brl' : 1263 this.formatOptions_.braille ? resolvedInfo.msgId + '_brl' :
1255 resolvedInfo.msgId; 1264 resolvedInfo.msgId;
1256 var msg = Msgs.getMsg(msgId); 1265 var msg = Msgs.getMsg(msgId);
1257 this.append_(buff, msg, options); 1266 this.append_(buff, msg, options);
1258 } else if (tree.firstChild) { 1267 } else if (tree.firstChild) {
1259 // Custom functions. 1268 // Custom functions.
1260 if (token == 'if') { 1269 if (token == 'if') {
1261 var cond = tree.firstChild; 1270 var cond = tree.firstChild;
1262 var attrib = cond.value.slice(1); 1271 var attrib = cond.value.slice(1);
1263 if (node[attrib] || node.state[attrib]) 1272 if (node[attrib] || node.state[attrib])
1264 this.format_(node, cond.nextSibling, buff); 1273 this.format_(node, cond.nextSibling, buff);
1265 else 1274 else
1266 this.format_(node, cond.nextSibling.nextSibling, buff); 1275 this.format_(node, cond.nextSibling.nextSibling, buff);
1267 } else if (token == 'earcon') { 1276 } else if (token == 'earcon') {
1268 // Ignore unless we're generating speech output. 1277 // Ignore unless we're generating speech output.
1269 if (!this.formatOptions_.speech) 1278 if (!this.formatOptions_.speech)
1270 return; 1279 return;
1271 1280
1272 options.annotation.push( 1281 options.annotation.push(
1273 new Output.EarconAction(tree.firstChild.value)); 1282 new Output.EarconAction(tree.firstChild.value, node.location));
1274 this.append_(buff, '', options); 1283 this.append_(buff, '', options);
1275 } else if (token == 'countChildren') { 1284 } else if (token == 'countChildren') {
1276 var role = tree.firstChild.value; 1285 var role = tree.firstChild.value;
1277 var count = node.children.filter(function(e) { 1286 var count = node.children.filter(function(e) {
1278 return e.role == role; 1287 return e.role == role;
1279 }).length; 1288 }).length;
1280 this.append_(buff, String(count)); 1289 this.append_(buff, String(count));
1281 } 1290 }
1282 } 1291 }
1283 } else if (prefix == '@') { 1292 } else if (prefix == '@') {
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
1788 var earconFinder = node; 1797 var earconFinder = node;
1789 var ancestors; 1798 var ancestors;
1790 if (opt_prevNode) 1799 if (opt_prevNode)
1791 ancestors = AutomationUtil.getUniqueAncestors(opt_prevNode, node); 1800 ancestors = AutomationUtil.getUniqueAncestors(opt_prevNode, node);
1792 else 1801 else
1793 ancestors = AutomationUtil.getAncestors(node); 1802 ancestors = AutomationUtil.getAncestors(node);
1794 1803
1795 while (earconFinder = ancestors.pop()) { 1804 while (earconFinder = ancestors.pop()) {
1796 var info = Output.ROLE_INFO_[earconFinder.role]; 1805 var info = Output.ROLE_INFO_[earconFinder.role];
1797 if (info && info.earconId) { 1806 if (info && info.earconId) {
1798 return new Output.EarconAction(info.earconId); 1807 return new Output.EarconAction(info.earconId, node.location);
1799 break; 1808 break;
1800 } 1809 }
1801 earconFinder = earconFinder.parent; 1810 earconFinder = earconFinder.parent;
1802 } 1811 }
1803 } 1812 }
1804 return null; 1813 return null;
1805 }, 1814 },
1806 1815
1807 /** 1816 /**
1808 * Gets a human friendly string with the contents of output. 1817 * Gets a human friendly string with the contents of output.
(...skipping 25 matching lines...) Expand all
1834 /** 1843 /**
1835 * Gets the output buffer for braille. 1844 * Gets the output buffer for braille.
1836 * @return {!Spannable} 1845 * @return {!Spannable}
1837 */ 1846 */
1838 get brailleOutputForTest() { 1847 get brailleOutputForTest() {
1839 return this.mergeBraille_(this.brailleBuffer_); 1848 return this.mergeBraille_(this.brailleBuffer_);
1840 } 1849 }
1841 }; 1850 };
1842 1851
1843 }); // goog.scope 1852 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698