diff options
author | dmazzoni <dmazzoni@chromium.org> | 2015-08-28 14:57:15 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-28 21:57:47 +0000 |
commit | b36f1f53ef2e73c6b09e41170832ac1196404a39 (patch) | |
tree | 81fd415951ceded38c3a2f0266a6ecf7b89b8775 | |
parent | 82ec0e3702fdabf77618b28d5b1c37f69e66f643 (diff) | |
download | chromium_src-b36f1f53ef2e73c6b09e41170832ac1196404a39.zip chromium_src-b36f1f53ef2e73c6b09e41170832ac1196404a39.tar.gz chromium_src-b36f1f53ef2e73c6b09e41170832ac1196404a39.tar.bz2 |
Make earcon ids strings instead of numbers.
BUG=491243
Review URL: https://codereview.chromium.org/1306773003
Cr-Commit-Position: refs/heads/master@{#346245}
22 files changed, 99 insertions, 342 deletions
diff --git a/chrome/browser/resources/chromeos/chromevox/chromevox/background/tabs_api_handler.js b/chrome/browser/resources/chromeos/chromevox/chromevox/background/tabs_api_handler.js index 8c48e1d..6d40b88 100644 --- a/chrome/browser/resources/chromeos/chromevox/chromevox/background/tabs_api_handler.js +++ b/chrome/browser/resources/chromeos/chromevox/chromevox/background/tabs_api_handler.js @@ -62,7 +62,7 @@ cvox.TabsApiHandler.prototype = { cvox.AbstractTts.PERSONALITY_ANNOUNCEMENT); this.braille_.write( cvox.NavBraille.fromText(this.msg_('chrome_tab_created'))); - this.earcons_.playEarcon(cvox.AbstractEarcons.OBJECT_OPEN); + this.earcons_.playEarcon(cvox.Earcon.OBJECT_OPEN); }, /** @@ -73,7 +73,7 @@ cvox.TabsApiHandler.prototype = { if (!cvox.ChromeVox.isActive) { return; } - this.earcons_.playEarcon(cvox.AbstractEarcons.OBJECT_CLOSE); + this.earcons_.playEarcon(cvox.Earcon.OBJECT_CLOSE); }, /** @@ -96,7 +96,7 @@ cvox.TabsApiHandler.prototype = { cvox.AbstractTts.PERSONALITY_ANNOUNCEMENT); this.braille_.write( cvox.NavBraille.fromText(this.msg_('chrome_tab_selected', [title]))); - this.earcons_.playEarcon(cvox.AbstractEarcons.OBJECT_SELECT); + this.earcons_.playEarcon(cvox.Earcon.OBJECT_SELECT); }.bind(this)); }, @@ -115,10 +115,10 @@ cvox.TabsApiHandler.prototype = { } if (tab.status == 'loading') { this.lastActiveTabLoaded_ = false; - this.earcons_.playEarcon(cvox.AbstractEarcons.BUSY_PROGRESS_LOOP); + this.earcons_.playEarcon(cvox.Earcon.BUSY_PROGRESS_LOOP); } else if (!this.lastActiveTabLoaded_) { this.lastActiveTabLoaded_ = true; - this.earcons_.playEarcon(cvox.AbstractEarcons.TASK_SUCCESS); + this.earcons_.playEarcon(cvox.Earcon.TASK_SUCCESS); } }.bind(this)); }, @@ -145,7 +145,7 @@ cvox.TabsApiHandler.prototype = { cvox.AbstractTts.PERSONALITY_ANNOUNCEMENT); this.braille_.write( cvox.NavBraille.fromText(this.msg_(msgId, [title]))); - this.earcons_.playEarcon(cvox.AbstractEarcons.OBJECT_SELECT); + this.earcons_.playEarcon(cvox.Earcon.OBJECT_SELECT); }.bind(this)); }.bind(this)); } diff --git a/chrome/browser/resources/chromeos/chromevox/chromevox/injected/api_implementation.js b/chrome/browser/resources/chromeos/chromevox/chromevox/injected/api_implementation.js index ab938b2..8b8423d7 100644 --- a/chrome/browser/resources/chromeos/chromevox/chromevox/injected/api_implementation.js +++ b/chrome/browser/resources/chromeos/chromevox/chromevox/injected/api_implementation.js @@ -198,8 +198,8 @@ cvox.ApiImplementation.stop = function() { * @param {string} earcon An earcon name. */ cvox.ApiImplementation.playEarcon = function(earcon) { - if (cvox.ChromeVox.isActive) { - cvox.ChromeVox.earcons.playEarconByName(earcon); + if (cvox.ChromeVox.isActive && cvox.Earcon[earcon]) { + cvox.ChromeVox.earcons.playEarcon(cvox.Earcon[earcon]); } }; diff --git a/chrome/browser/resources/chromeos/chromevox/chromevox/injected/event_watcher.js b/chrome/browser/resources/chromeos/chromevox/chromevox/injected/event_watcher.js index b563896..d4c228c 100644 --- a/chrome/browser/resources/chromeos/chromevox/chromevox/injected/event_watcher.js +++ b/chrome/browser/resources/chromeos/chromevox/chromevox/injected/event_watcher.js @@ -1104,9 +1104,9 @@ cvox.ChromeVoxEventWatcher.handleControlChanged = function(control) { announceChange = true; // Play earcons for checkboxes and radio buttons if (control.checked) { - cvox.ChromeVox.earcons.playEarcon(cvox.AbstractEarcons.CHECK_ON); + cvox.ChromeVox.earcons.playEarcon(cvox.Earcon.CHECK_ON); } else { - cvox.ChromeVox.earcons.playEarcon(cvox.AbstractEarcons.CHECK_OFF); + cvox.ChromeVox.earcons.playEarcon(cvox.Earcon.CHECK_OFF); } } diff --git a/chrome/browser/resources/chromeos/chromevox/chromevox/injected/navigation_manager.js b/chrome/browser/resources/chromeos/chromevox/chromevox/injected/navigation_manager.js index 6dc6603..00b3728 100644 --- a/chrome/browser/resources/chromeos/chromevox/chromevox/injected/navigation_manager.js +++ b/chrome/browser/resources/chromeos/chromevox/chromevox/injected/navigation_manager.js @@ -111,7 +111,7 @@ cvox.NavigationManager.prototype.reset = function() { * @private */ this.curSel_ = document.activeElement != document.body ? - /** @type {!cvox.CursorSelection} **/ + /** @type {!cvox.CursorSelection} */ (cvox.CursorSelection.fromNode(document.activeElement)) : this.shifter_.begin(this.curSel_, {reversed: false}); @@ -449,23 +449,23 @@ cvox.NavigationManager.prototype.getDescription = function() { // Earcons. if (this.skipped_) { - earcons.push(cvox.AbstractEarcons.PARAGRAPH_BREAK); + earcons.push(cvox.Earcon.PARAGRAPH_BREAK); this.skipped_ = false; } if (this.recovered_) { - earcons.push(cvox.AbstractEarcons.FONT_CHANGE); + earcons.push(cvox.Earcon.FONT_CHANGE); this.recovered_ = false; } if (this.pageEnd_) { - earcons.push(cvox.AbstractEarcons.WRAP); + earcons.push(cvox.Earcon.WRAP); this.pageEnd_ = false; } if (this.enteredShifter_) { - earcons.push(cvox.AbstractEarcons.OBJECT_ENTER); + earcons.push(cvox.Earcon.OBJECT_ENTER); this.enteredShifter_ = false; } if (this.exitedShifter_) { - earcons.push(cvox.AbstractEarcons.OBJECT_EXIT); + earcons.push(cvox.Earcon.OBJECT_EXIT); this.exitedShifter_ = false; } if (earcons.length > 0 && desc.length > 0) { @@ -701,7 +701,7 @@ cvox.NavigationManager.prototype.finishNavCommand = function( if (this.pageEnd_ && !this.pageEndAnnounced_) { this.pageEndAnnounced_ = true; cvox.ChromeVox.tts.stop(); - cvox.ChromeVox.earcons.playEarcon(cvox.AbstractEarcons.WRAP); + cvox.ChromeVox.earcons.playEarcon(cvox.Earcon.WRAP); if (cvox.ChromeVox.verbosity === cvox.VERBOSITY_VERBOSE) { var msg = cvox.ChromeVox.msgs.getMsg('wrapped_to_top'); if (this.isReversed()) { diff --git a/chrome/browser/resources/chromeos/chromevox/chromevox/injected/ui/search_widget.js b/chrome/browser/resources/chromeos/chromevox/chromevox/injected/ui/search_widget.js index e98e7f6..fec7fb1 100644 --- a/chrome/browser/resources/chromeos/chromevox/chromevox/injected/ui/search_widget.js +++ b/chrome/browser/resources/chromeos/chromevox/chromevox/injected/ui/search_widget.js @@ -418,7 +418,7 @@ cvox.SearchWidget.prototype.next_ = function(searchStr, opt_reversed) { cvox.ChromeVox.navigationManager.setReversed(!!opt_reversed); if (!success) { cvox.ChromeVox.navigationManager.syncToBeginning(); - cvox.ChromeVox.earcons.playEarcon(cvox.AbstractEarcons.WRAP); + cvox.ChromeVox.earcons.playEarcon(cvox.Earcon.WRAP); success = true; } } else { @@ -444,7 +444,7 @@ cvox.SearchWidget.prototype.next_ = function(searchStr, opt_reversed) { cvox.SearchWidget.prototype.outputSearchResult_ = function(result, searchStr) { cvox.ChromeVox.tts.stop(); if (!result) { - cvox.ChromeVox.earcons.playEarcon(cvox.AbstractEarcons.WRAP); + cvox.ChromeVox.earcons.playEarcon(cvox.Earcon.WRAP); this.hasMatch_ = false; return; } diff --git a/chrome/browser/resources/chromeos/chromevox/chromevox/injected/ui/widget.js b/chrome/browser/resources/chromeos/chromevox/chromevox/injected/ui/widget.js index da44a57..475ad98 100644 --- a/chrome/browser/resources/chromeos/chromevox/chromevox/injected/ui/widget.js +++ b/chrome/browser/resources/chromeos/chromevox/chromevox/injected/ui/widget.js @@ -93,7 +93,7 @@ cvox.Widget.prototype.show = function() { andMessage(this.getHelpMsg()). speakFlush(); } - cvox.ChromeVox.earcons.playEarcon(cvox.AbstractEarcons.OBJECT_OPEN); + cvox.ChromeVox.earcons.playEarcon(cvox.Earcon.OBJECT_OPEN); this.active = true; }; @@ -110,7 +110,7 @@ cvox.Widget.prototype.hide = function(opt_noSync) { window.removeEventListener('keydown', this.onKeyDown, true); cvox.ChromeVox.stickyOverride = null; - cvox.ChromeVox.earcons.playEarcon(cvox.AbstractEarcons.OBJECT_CLOSE); + cvox.ChromeVox.earcons.playEarcon(cvox.Earcon.OBJECT_CLOSE); if (!opt_noSync) { this.initialNode = this.initialNode.nodeType == 1 ? this.initialNode : this.initialNode.parentNode; diff --git a/chrome/browser/resources/chromeos/chromevox/chromevox/injected/user_commands.js b/chrome/browser/resources/chromeos/chromevox/chromevox/injected/user_commands.js index 1d5838a..70c2388 100644 --- a/chrome/browser/resources/chromeos/chromevox/chromevox/injected/user_commands.js +++ b/chrome/browser/resources/chromeos/chromevox/chromevox/injected/user_commands.js @@ -325,7 +325,7 @@ cvox.ChromeVoxUserCommands.doCommand_ = function(cmdStruct) { cvox.ChromeVox.navigationManager.saveSel(); prefixMsg = wrap; cvox.ChromeVox.navigationManager.syncToBeginning(); - cvox.ChromeVox.earcons.playEarcon(cvox.AbstractEarcons.WRAP); + cvox.ChromeVox.earcons.playEarcon(cvox.Earcon.WRAP); found = cvox.ChromeVox.navigationManager.findNext( predicate, predicateName, true); if (!found) { diff --git a/chrome/browser/resources/chromeos/chromevox/common/aria_util.js b/chrome/browser/resources/chromeos/chromevox/common/aria_util.js index c1b7dc3..7018b3d 100644 --- a/chrome/browser/resources/chromeos/chromevox/common/aria_util.js +++ b/chrome/browser/resources/chromeos/chromevox/common/aria_util.js @@ -905,7 +905,7 @@ cvox.AriaUtil.isGrid = function(node) { * Returns the id of an earcon to play along with the description for a node. * * @param {Node} node The node to get the earcon for. - * @return {number?} The earcon id, or null if none applies. + * @return {cvox.Earcon?} The earcon id, or null if none applies. */ cvox.AriaUtil.getEarcon = function(node) { if (!node || !node.getAttribute) { @@ -914,26 +914,26 @@ cvox.AriaUtil.getEarcon = function(node) { var role = cvox.AriaUtil.getRoleAttribute(node); switch (role) { case 'button': - return cvox.AbstractEarcons.BUTTON; + return cvox.Earcon.BUTTON; case 'checkbox': case 'radio': case 'menuitemcheckbox': case 'menuitemradio': var checked = node.getAttribute('aria-checked'); if (checked == 'true') { - return cvox.AbstractEarcons.CHECK_ON; + return cvox.Earcon.CHECK_ON; } else { - return cvox.AbstractEarcons.CHECK_OFF; + return cvox.Earcon.CHECK_OFF; } case 'combobox': case 'listbox': - return cvox.AbstractEarcons.LISTBOX; + return cvox.Earcon.LISTBOX; case 'textbox': - return cvox.AbstractEarcons.EDITABLE_TEXT; + return cvox.Earcon.EDITABLE_TEXT; case 'listitem': - return cvox.AbstractEarcons.BULLET; + return cvox.Earcon.BULLET; case 'link': - return cvox.AbstractEarcons.LINK; + return cvox.Earcon.LINK; } return null; diff --git a/chrome/browser/resources/chromeos/chromevox/common/description_util.js b/chrome/browser/resources/chromeos/chromevox/common/description_util.js index 237bb06..e14def4 100644 --- a/chrome/browser/resources/chromeos/chromevox/common/description_util.js +++ b/chrome/browser/resources/chromeos/chromevox/common/description_util.js @@ -469,6 +469,6 @@ cvox.DescriptionUtil.getMathDescription = function(node) { if (cvox.ChromeVox.verbosity == cvox.VERBOSITY_VERBOSE) { ret[ret.length - 1].annotation = 'math'; } - ret[0].pushEarcon(cvox.AbstractEarcons.SPECIAL_CONTENT); + ret[0].pushEarcon(cvox.Earcon.SPECIAL_CONTENT); return ret; }; diff --git a/chrome/browser/resources/chromeos/chromevox/common/earcon_util.js b/chrome/browser/resources/chromeos/chromevox/common/earcon_util.js index c938d9b..51679ab 100644 --- a/chrome/browser/resources/chromeos/chromevox/common/earcon_util.js +++ b/chrome/browser/resources/chromeos/chromevox/common/earcon_util.js @@ -16,7 +16,7 @@ goog.require('cvox.DomUtil'); * Returns the id of an earcon to play along with the description for a node. * * @param {Node} node The node to get the earcon for. - * @return {number?} The earcon id, or null if none applies. + * @return {cvox.Earcon?} The earcon id, or null if none applies. */ cvox.EarconUtil.getEarcon = function(node) { var earcon = cvox.AriaUtil.getEarcon(node); @@ -26,40 +26,40 @@ cvox.EarconUtil.getEarcon = function(node) { switch (node.tagName) { case 'BUTTON': - return cvox.AbstractEarcons.BUTTON; + return cvox.Earcon.BUTTON; case 'A': if (node.hasAttribute('href')) { - return cvox.AbstractEarcons.LINK; + return cvox.Earcon.LINK; } break; case 'IMG': if (cvox.DomUtil.hasLongDesc(node)) { - return cvox.AbstractEarcons.LONG_DESC; + return cvox.Earcon.LONG_DESC; } break; case 'LI': - return cvox.AbstractEarcons.LIST_ITEM; + return cvox.Earcon.LIST_ITEM; case 'SELECT': - return cvox.AbstractEarcons.LISTBOX; + return cvox.Earcon.LISTBOX; case 'TEXTAREA': - return cvox.AbstractEarcons.EDITABLE_TEXT; + return cvox.Earcon.EDITABLE_TEXT; case 'INPUT': switch (node.type) { case 'button': case 'submit': case 'reset': - return cvox.AbstractEarcons.BUTTON; + return cvox.Earcon.BUTTON; case 'checkbox': case 'radio': if (node.checked) { - return cvox.AbstractEarcons.CHECK_ON; + return cvox.Earcon.CHECK_ON; } else { - return cvox.AbstractEarcons.CHECK_OFF; + return cvox.Earcon.CHECK_OFF; } default: if (cvox.DomUtil.isInputTypeText(node)) { // 'text', 'password', etc. - return cvox.AbstractEarcons.EDITABLE_TEXT; + return cvox.Earcon.EDITABLE_TEXT; } } } diff --git a/chrome/browser/resources/chromeos/chromevox/common/nav_description.js b/chrome/browser/resources/chromeos/chromevox/common/nav_description.js index e143ca1..a158b57 100644 --- a/chrome/browser/resources/chromeos/chromevox/common/nav_description.js +++ b/chrome/browser/resources/chromeos/chromevox/common/nav_description.js @@ -23,7 +23,7 @@ goog.require('cvox.QueueMode'); * text: (string), * userValue: (undefined|string), * annotation: (undefined|string), - * earcons: (undefined|Array<number>), + * earcons: (undefined|Array<cvox.Earcon>), * personality: (undefined|Object), * hint: (undefined|string), category: (undefined|string)}} kwargs The arguments for this @@ -81,8 +81,8 @@ cvox.NavDescription.prototype.toString = function() { /** * Modifies the earcon to play along with the spoken description of the object. - * @param {number} earconId An earcon id to be pushed on to the list of earcon - * ids to play along with the spoken description of this object. + * @param {cvox.Earcon} earconId An earcon id to be pushed on to the list of + * earcon ids to play along with the spoken description of this object. */ cvox.NavDescription.prototype.pushEarcon = function(earconId) { this.earcons.push(earconId); diff --git a/chrome/browser/resources/chromeos/chromevox/common/nav_math_description.js b/chrome/browser/resources/chromeos/chromevox/common/nav_math_description.js index c402307..e76c688 100644 --- a/chrome/browser/resources/chromeos/chromevox/common/nav_math_description.js +++ b/chrome/browser/resources/chromeos/chromevox/common/nav_math_description.js @@ -20,7 +20,7 @@ goog.require('cvox.NavDescription'); * text: (string), * userValue: (undefined|string), * annotation: (undefined|string), - * earcons: (undefined|Array<number>), + * earcons: (undefined|Array<cvox.Earcon>), * personality: (undefined|Object), * hint: (undefined|string), * category: (undefined|string), diff --git a/chrome/browser/resources/chromeos/chromevox/common/page_selection.js b/chrome/browser/resources/chromeos/chromevox/common/page_selection.js index ad39e4a..de87d9f 100644 --- a/chrome/browser/resources/chromeos/chromevox/common/page_selection.js +++ b/chrome/browser/resources/chromeos/chromevox/common/page_selection.js @@ -46,19 +46,19 @@ cvox.PageSelection.prototype.getDescription = // A shrinking selection. desc = navShifter.getDescription(curSel, prevSel); desc[0].annotation = cvox.ChromeVox.msgs.getMsg('describe_unselected'); - desc[0].pushEarcon(cvox.AbstractEarcons.SELECTION_REVERSE); + desc[0].pushEarcon(cvox.Earcon.SELECTION_REVERSE); } else { // A growing selection. desc = navShifter.getDescription(prevSel, curSel); desc[0].annotation = cvox.ChromeVox.msgs.getMsg('describe_selected'); - desc[0].pushEarcon(cvox.AbstractEarcons.SELECTION); + desc[0].pushEarcon(cvox.Earcon.SELECTION); if (!this.wasBegin_ && this.sel_.absEquals(curSel.clone().normalize())) { // A selection has inverted across the start cursor. Describe it. var prevDesc = navShifter.getDescription(curSel, prevSel); prevDesc[0].annotation = cvox.ChromeVox.msgs.getMsg('describe_unselected'); - prevDesc[0].pushEarcon(cvox.AbstractEarcons.SELECTION_REVERSE); - prevDesc[0].pushEarcon(cvox.AbstractEarcons.WRAP); + prevDesc[0].pushEarcon(cvox.Earcon.SELECTION_REVERSE); + prevDesc[0].pushEarcon(cvox.Earcon.WRAP); desc = prevDesc.concat(desc); } } diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js index b1f58bf..639ca1e 100644 --- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js +++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/output.js @@ -526,7 +526,7 @@ Output.EarconAction.prototype = { /** @override */ run: function() { - cvox.ChromeVox.earcons.playEarcon(cvox.AbstractEarcons[this.earconId]); + cvox.ChromeVox.earcons.playEarcon(cvox.Earcon[this.earconId]); } }; diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/output_test.extjs b/chrome/browser/resources/chromeos/chromevox/cvox2/background/output_test.extjs index b34641b..73acdea 100644 --- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/output_test.extjs +++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/output_test.extjs @@ -493,7 +493,7 @@ SYNC_TEST_F('OutputE2ETest', 'MessageIdAndEarconValidity', function() { cvox.ChromeVox.msgs.getMsg(value.msgId + '_brl'); assertFalse(/[A-Z]+/.test(value.msgId)); if (value.earconId) - assertNotNullNorUndefined(cvox.AbstractEarcons[value.earconId]); + assertNotNullNorUndefined(cvox.Earcon[value.earconId]); } for (var key in Output.STATE_INFO_) { var value = Output.STATE_INFO_[key]; @@ -503,7 +503,7 @@ SYNC_TEST_F('OutputE2ETest', 'MessageIdAndEarconValidity', function() { cvox.ChromeVox.msgs.getMsg(innerValue.msgId + '_brl'); assertFalse(/[A-Z]+/.test(innerValue.msgId)); if (innerValue.earconId) - assertNotNullNorUndefined(cvox.AbstractEarcons[innerValue.earconId]); + assertNotNullNorUndefined(cvox.Earcon[innerValue.earconId]); } } }); diff --git a/chrome/browser/resources/chromeos/chromevox/extensions/searchvox/search.js b/chrome/browser/resources/chromeos/chromevox/extensions/searchvox/search.js index ac6a429..9c8175a 100644 --- a/chrome/browser/resources/chromeos/chromevox/extensions/searchvox/search.js +++ b/chrome/browser/resources/chromeos/chromevox/extensions/searchvox/search.js @@ -238,7 +238,7 @@ cvox.Search.keyhandler = function(evt) { cvox.Search.index = cvox.SearchUtil.subOneWrap(cvox.Search.index, cvox.Search.results.length); if (cvox.Search.index === cvox.Search.results.length - 1) { - cvox.ChromeVox.earcons.playEarconByName('WRAP'); + cvox.ChromeVox.earcons.playEarcon(cvox.Earcon.WRAP); } cvox.Search.syncToIndex(); break; @@ -247,7 +247,7 @@ cvox.Search.keyhandler = function(evt) { cvox.Search.index = cvox.SearchUtil.addOneWrap(cvox.Search.index, cvox.Search.results.length); if (cvox.Search.index === 0) { - cvox.ChromeVox.earcons.playEarconByName('WRAP'); + cvox.ChromeVox.earcons.playEarcon(cvox.Earcon.WRAP); } cvox.Search.syncToIndex(); break; diff --git a/chrome/browser/resources/chromeos/chromevox/host/chrome/earcons_background.js b/chrome/browser/resources/chromeos/chromevox/host/chrome/earcons_background.js index 22285e6..500da1a 100644 --- a/chrome/browser/resources/chromeos/chromevox/host/chrome/earcons_background.js +++ b/chrome/browser/resources/chromeos/chromevox/host/chrome/earcons_background.js @@ -54,13 +54,13 @@ cvox.EarconsBackground.prototype.playEarcon = function(earcon) { return; } if (window['console']) { - window['console']['log']('Earcon ' + this.getEarconName(earcon)); + window['console']['log']('Earcon ' + earcon); } this.currentAudio = this.audioMap[earcon]; if (!this.currentAudio) { this.currentAudio = new Audio(chrome.extension.getURL(this.getBaseUrl() + - this.getEarconFilename(earcon))); + earcon + '.ogg')); this.audioMap[earcon] = this.currentAudio; } try { diff --git a/chrome/browser/resources/chromeos/chromevox/host/interface/abstract_earcons.js b/chrome/browser/resources/chromeos/chromevox/host/interface/abstract_earcons.js index f325fd9..6bf8c9b 100644 --- a/chrome/browser/resources/chromeos/chromevox/host/interface/abstract_earcons.js +++ b/chrome/browser/resources/chromeos/chromevox/host/interface/abstract_earcons.js @@ -10,6 +10,42 @@ */ goog.provide('cvox.AbstractEarcons'); +goog.provide('cvox.Earcon'); + + +/** + * Earcon names. + * @enum {string} + */ +cvox.Earcon = { + ALERT_MODAL: 'alert_modal', + ALERT_NONMODAL: 'alert_nonmodal', + BULLET: 'bullet', + BUSY_PROGRESS_LOOP: 'busy_progress_loop', + BUTTON: 'button', + CHECK_OFF: 'check_off', + CHECK_ON: 'check_on', + EDITABLE_TEXT: 'editable_text', + FONT_CHANGE: 'font_change', + INVALID_KEYPRESS: 'invalid_keypress', + LINK: 'link', + LISTBOX: 'listbox', + LIST_ITEM: 'bullet', + LONG_DESC: 'long_desc', + OBJECT_CLOSE: 'object_close', + OBJECT_ENTER: 'object_enter', + OBJECT_EXIT: 'object_exit', + OBJECT_OPEN: 'object_open', + OBJECT_SELECT: 'object_select', + PARAGRAPH_BREAK: 'paragraph_break', + SECTION: 'section', + SELECTION: 'selection', + SELECTION_REVERSE: 'selection_reverse', + SPECIAL_CONTENT: 'special_content', + TASK_SUCCESS: 'task_success', + WRAP: 'wrap', + WRAP_EDGE: 'wrap_edge', +}; /** @@ -27,22 +63,13 @@ cvox.AbstractEarcons = function() { /** * Plays the specified earcon sound. - * @param {number} earcon An earcon index. + * @param {cvox.Earcon} earcon An earcon identifier. */ cvox.AbstractEarcons.prototype.playEarcon = function(earcon) { }; /** - * Plays the specified earcon sound, given the name of the earcon. - * @param {string} earconName The name of the earcon. - */ -cvox.AbstractEarcons.prototype.playEarconByName = function(earconName) { - this.playEarcon(this.getEarconId(earconName)); -}; - - -/** * Whether or not earcons are available. * @return {boolean} True if earcons are available. */ @@ -52,98 +79,6 @@ cvox.AbstractEarcons.prototype.earconsAvailable = function() { /** - * @param {number} earcon An earcon index. - * @return {string} The readable earcon name. - */ -cvox.AbstractEarcons.prototype.getEarconName = function(earcon) { - if (!this.earconNames) { - this.earconNames = new Array(); - this.earconNames.push('ALERT_MODAL'); - this.earconNames.push('ALERT_NONMODAL'); - this.earconNames.push('BULLET'); - this.earconNames.push('BUSY_PROGRESS_LOOP'); - this.earconNames.push('BUTTON'); - this.earconNames.push('CHECK_OFF'); - this.earconNames.push('CHECK_ON'); - this.earconNames.push('EDITABLE_TEXT'); - this.earconNames.push('FONT_CHANGE'); - this.earconNames.push('INVALID_KEYPRESS'); - this.earconNames.push('LINK'); - this.earconNames.push('LISTBOX'); - this.earconNames.push('LIST_ITEM'); - this.earconNames.push('LONG_DESC'); - this.earconNames.push('OBJECT_CLOSE'); - this.earconNames.push('OBJECT_ENTER'); - this.earconNames.push('OBJECT_EXIT'); - this.earconNames.push('OBJECT_OPEN'); - this.earconNames.push('OBJECT_SELECT'); - this.earconNames.push('PARAGRAPH_BREAK'); - this.earconNames.push('SELECTION'); - this.earconNames.push('SELECTION_REVERSE'); - this.earconNames.push('SPECIAL_CONTENT'); - this.earconNames.push('TASK_SUCCESS'); - this.earconNames.push('WRAP'); - this.earconNames.push('WRAP_EDGE'); - } - return this.earconNames[earcon]; -}; - - -/** - * @param {string} earconName An earcon name. - * @return {number} The earcon ID. - */ -cvox.AbstractEarcons.prototype.getEarconId = function(earconName) { - if (!this.earconNamesToIds) { - this.earconNamesToIds = new Object(); - this.earconNamesToIds['ALERT_MODAL'] = - cvox.AbstractEarcons.ALERT_MODAL; - this.earconNamesToIds['ALERT_NONMODAL'] = - cvox.AbstractEarcons.ALERT_NONMODAL; - this.earconNamesToIds['BULLET'] = cvox.AbstractEarcons.BULLET; - this.earconNamesToIds['BUSY_PROGRESS_LOOP'] = - cvox.AbstractEarcons.BUSY_PROGRESS_LOOP; - this.earconNamesToIds['BUTTON'] = cvox.AbstractEarcons.BUTTON; - this.earconNamesToIds['CHECK_OFF'] = cvox.AbstractEarcons.CHECK_OFF; - this.earconNamesToIds['CHECK_ON'] = cvox.AbstractEarcons.CHECK_ON; - this.earconNamesToIds['EDITABLE_TEXT'] = cvox.AbstractEarcons.EDITABLE_TEXT; - this.earconNamesToIds['FONT_CHANGE'] = cvox.AbstractEarcons.FONT_CHANGE; - this.earconNamesToIds['INVALID_KEYPRESS'] = - cvox.AbstractEarcons.INVALID_KEYPRESS; - this.earconNamesToIds['LINK'] = cvox.AbstractEarcons.LINK; - this.earconNamesToIds['LISTBOX'] = cvox.AbstractEarcons.LISTBOX; - this.earconNamesToIds['LIST_ITEM'] = cvox.AbstractEarcons.LIST_ITEM; - this.earconNamesToIds['LONG_DESC'] = cvox.AbstractEarcons.LONG_DESC; - this.earconNamesToIds['OBJECT_CLOSE'] = cvox.AbstractEarcons.OBJECT_CLOSE; - this.earconNamesToIds['OBJECT_ENTER'] = cvox.AbstractEarcons.OBJECT_ENTER; - this.earconNamesToIds['OBJECT_EXIT'] = cvox.AbstractEarcons.OBJECT_EXIT; - this.earconNamesToIds['OBJECT_OPEN'] = cvox.AbstractEarcons.OBJECT_OPEN; - this.earconNamesToIds['OBJECT_SELECT'] = cvox.AbstractEarcons.OBJECT_SELECT; - this.earconNamesToIds['PARAGRAPH_BREAK'] = - cvox.AbstractEarcons.PARAGRAPH_BREAK; - this.earconNamesToIds['SELECTION'] = cvox.AbstractEarcons.SELECTION; - this.earconNamesToIds['SELECTION_REVERSE'] = - cvox.AbstractEarcons.SELECTION_REVERSE; - this.earconNamesToIds['SPECIAL_CONTENT'] = - cvox.AbstractEarcons.SPECIAL_CONTENT; - this.earconNamesToIds['TASK_SUCCESS'] = cvox.AbstractEarcons.TASK_SUCCESS; - this.earconNamesToIds['WRAP'] = cvox.AbstractEarcons.WRAP; - this.earconNamesToIds['WRAP_EDGE'] = cvox.AbstractEarcons.WRAP_EDGE; - } - return this.earconNamesToIds[earconName]; -}; - - -/** - * @param {number} earconId The earcon ID. - * @return {string} The filename for the earcon. - */ -cvox.AbstractEarcons.prototype.getEarconFilename = function(earconId) { - return cvox.AbstractEarcons.earconMap[earconId]; -}; - - -/** * Toggles earcons on or off. * @return {boolean} True if earcons are now enabled; false otherwise. */ @@ -151,181 +86,3 @@ cvox.AbstractEarcons.prototype.toggle = function() { this.enabled = !this.enabled; return this.enabled; }; - - -/** - * @type {number} - */ -cvox.AbstractEarcons.ALERT_MODAL = 0; - -/** - * @type {number} - */ -cvox.AbstractEarcons.ALERT_NONMODAL = 1; - -/** - * @type {number} - */ -cvox.AbstractEarcons.BULLET = 2; - -/** - * @type {number} - */ -cvox.AbstractEarcons.BUSY_PROGRESS_LOOP = 3; - -/** - * @type {number} - */ -cvox.AbstractEarcons.BUTTON = 4; - -/** - * @type {number} - */ -cvox.AbstractEarcons.CHECK_OFF = 5; - -/** - * @type {number} - */ -cvox.AbstractEarcons.CHECK_ON = 6; - -/** - * @type {number} - */ -cvox.AbstractEarcons.EDITABLE_TEXT = 7; - -/** - * @type {number} - */ -cvox.AbstractEarcons.FONT_CHANGE = 8; - -/** - * @type {number} - */ -cvox.AbstractEarcons.INVALID_KEYPRESS = 9; - -/** - * @type {number} - */ -cvox.AbstractEarcons.LINK = 10; - -/** - * @type {number} - */ -cvox.AbstractEarcons.LISTBOX = 11; - -/** - * @type {number} - */ -cvox.AbstractEarcons.LIST_ITEM = 12; - -/** - * @type {number} - */ -cvox.AbstractEarcons.LONG_DESC = 13; - -/** - * @type {number} - */ -cvox.AbstractEarcons.OBJECT_CLOSE = 14; - -/** - * @type {number} - */ -cvox.AbstractEarcons.OBJECT_ENTER = 15; - -/** - * @type {number} - */ -cvox.AbstractEarcons.OBJECT_EXIT = 16; - -/** - * @type {number} - */ -cvox.AbstractEarcons.OBJECT_OPEN = 17; - -/** - * @type {number} - */ -cvox.AbstractEarcons.OBJECT_SELECT = 18; - -/** - * @type {number} - */ -cvox.AbstractEarcons.PARAGRAPH_BREAK = 19; - -/** - * @type {number} - */ -cvox.AbstractEarcons.SELECTION = 20; - -/** - * @type {number} - */ -cvox.AbstractEarcons.SELECTION_REVERSE = 21; - -/** - * @type {number} - */ -cvox.AbstractEarcons.SPECIAL_CONTENT = 22; - -/** - * @type {number} - */ -cvox.AbstractEarcons.TASK_SUCCESS = 23; - -/** - * @type {number} - */ -cvox.AbstractEarcons.WRAP = 24; - -/** - * @type {number} - */ -cvox.AbstractEarcons.WRAP_EDGE = 25; - -/** - * The earcon map. - * @type {Object} - */ -cvox.AbstractEarcons.earconMap = new Object(); -cvox.AbstractEarcons.earconMap[cvox.AbstractEarcons.ALERT_NONMODAL] = - 'alert_nonmodal.ogg'; -cvox.AbstractEarcons.earconMap[cvox.AbstractEarcons.BULLET] = 'bullet.ogg'; -cvox.AbstractEarcons.earconMap[cvox.AbstractEarcons.BUSY_PROGRESS_LOOP] = - 'busy_progress_loop.ogg'; -cvox.AbstractEarcons.earconMap[cvox.AbstractEarcons.BUTTON] = 'button.ogg'; -cvox.AbstractEarcons.earconMap[cvox.AbstractEarcons.CHECK_OFF] = - 'check_off.ogg'; -cvox.AbstractEarcons.earconMap[cvox.AbstractEarcons.CHECK_ON] = 'check_on.ogg'; -cvox.AbstractEarcons.earconMap[cvox.AbstractEarcons.EDITABLE_TEXT] = - 'editable_text.ogg'; -cvox.AbstractEarcons.earconMap[cvox.AbstractEarcons.FONT_CHANGE] = - 'font_change.ogg'; -cvox.AbstractEarcons.earconMap[cvox.AbstractEarcons.LINK] = 'link.ogg'; -cvox.AbstractEarcons.earconMap[cvox.AbstractEarcons.LISTBOX] = 'listbox.ogg'; -cvox.AbstractEarcons.earconMap[cvox.AbstractEarcons.LIST_ITEM] = 'bullet.ogg'; -cvox.AbstractEarcons.earconMap[cvox.AbstractEarcons.LONG_DESC] = - 'long_desc.ogg'; -cvox.AbstractEarcons.earconMap[cvox.AbstractEarcons.OBJECT_CLOSE] = - 'object_close.ogg'; -cvox.AbstractEarcons.earconMap[cvox.AbstractEarcons.OBJECT_ENTER] = - 'object_enter.ogg'; -cvox.AbstractEarcons.earconMap[cvox.AbstractEarcons.OBJECT_EXIT] = - 'object_exit.ogg'; -cvox.AbstractEarcons.earconMap[cvox.AbstractEarcons.OBJECT_OPEN] = - 'object_open.ogg'; -cvox.AbstractEarcons.earconMap[cvox.AbstractEarcons.OBJECT_SELECT] = - 'object_select.ogg'; -cvox.AbstractEarcons.earconMap[cvox.AbstractEarcons.PARAGRAPH_BREAK] = - 'paragraph_break.ogg'; -cvox.AbstractEarcons.earconMap[cvox.AbstractEarcons.SELECTION] = - 'selection.ogg'; -cvox.AbstractEarcons.earconMap[cvox.AbstractEarcons.SELECTION_REVERSE] = - 'selection_reverse.ogg'; -cvox.AbstractEarcons.earconMap[cvox.AbstractEarcons.SPECIAL_CONTENT] = - 'special_content.ogg'; -cvox.AbstractEarcons.earconMap[cvox.AbstractEarcons.TASK_SUCCESS] = - 'task_success.ogg'; -cvox.AbstractEarcons.earconMap[cvox.AbstractEarcons.WRAP] = 'wrap.ogg'; -cvox.AbstractEarcons.earconMap[cvox.AbstractEarcons.WRAP_EDGE] = - 'wrap_edge.ogg'; diff --git a/chrome/browser/resources/chromeos/chromevox/host/testing/earcons.js b/chrome/browser/resources/chromeos/chromevox/host/testing/earcons.js index 356e725..c2a2658 100644 --- a/chrome/browser/resources/chromeos/chromevox/host/testing/earcons.js +++ b/chrome/browser/resources/chromeos/chromevox/host/testing/earcons.js @@ -17,7 +17,7 @@ goog.require('cvox.HostFactory'); * @extends {cvox.AbstractEarcons} */ cvox.TestEarcons = function() { - cvox.AbstractEarcons.call(this); + cvox.Earcon.call(this); }; goog.inherits(cvox.TestEarcons, cvox.AbstractEarcons); diff --git a/chrome/browser/resources/chromeos/chromevox/walkers/layout_line_walker_test.unitjs b/chrome/browser/resources/chromeos/chromevox/walkers/layout_line_walker_test.unitjs index 56143d2..70c16d7 100644 --- a/chrome/browser/resources/chromeos/chromevox/walkers/layout_line_walker_test.unitjs +++ b/chrome/browser/resources/chromeos/chromevox/walkers/layout_line_walker_test.unitjs @@ -63,7 +63,7 @@ CvoxLayoutLineWalkerUnitTest.prototype = { 'userValue': '', 'annotation': '', 'earcons': [], 'personality': null, 'hint': '', 'category': null}, {'context': '', 'text': 'google', 'userValue': '', 'annotation': 'Link', - 'earcons': [cvox.AbstractEarcons.LINK], 'personality': null, + 'earcons': [cvox.Earcon.LINK], 'personality': null, hint: '', 'category': null}, {'context': '', 'text': 'are considered a single layout line.', 'userValue': '', 'annotation': '', 'earcons': [], 'personality': null, @@ -78,7 +78,7 @@ CvoxLayoutLineWalkerUnitTest.prototype = { 'text': 'Wikipedia', 'userValue': '', 'annotation': 'Link', - 'earcons': [cvox.AbstractEarcons.LINK], + 'earcons': [cvox.Earcon.LINK], 'personality': null, 'hint': '', 'category': null}, {'context': '', 'text': diff --git a/chrome/browser/resources/chromeos/chromevox/walkers/math_shifter.js b/chrome/browser/resources/chromeos/chromevox/walkers/math_shifter.js index db15789..07dda0d 100644 --- a/chrome/browser/resources/chromeos/chromevox/walkers/math_shifter.js +++ b/chrome/browser/resources/chromeos/chromevox/walkers/math_shifter.js @@ -89,7 +89,7 @@ cvox.MathShifter.prototype.getDescription = function(prevSel, sel) { var descs = cvox.SpeechRuleEngine.getInstance().evaluateNode( cvox.TraverseMath.getInstance().activeNode); if (this.bumped_ && descs.length > 0) { - descs[0].pushEarcon(cvox.AbstractEarcons.WRAP_EDGE); + descs[0].pushEarcon(cvox.Earcon.WRAP_EDGE); } return descs; }; diff --git a/chrome/browser/resources/chromeos/chromevox/walkers/table_shifter.js b/chrome/browser/resources/chromeos/chromevox/walkers/table_shifter.js index 1f9421e..090aa10 100644 --- a/chrome/browser/resources/chromeos/chromevox/walkers/table_shifter.js +++ b/chrome/browser/resources/chromeos/chromevox/walkers/table_shifter.js @@ -78,7 +78,7 @@ cvox.TableShifter.prototype.getDescription = function(prevSel, sel) { var descs = this.currentWalker_.getDescription(prevSel, sel); if (descs.length > 0) { if (this.bumpedEdge_) { - descs[0].pushEarcon(cvox.AbstractEarcons.WRAP_EDGE); + descs[0].pushEarcon(cvox.Earcon.WRAP_EDGE); this.bumpedEdge_ = false; } if (this.begin_) { |