Commit cdd27239 authored by dtseng's avatar dtseng Committed by Commit bot

Add a role info dictionary to output.js to resolve role msgs.

Currently, ChromeVox Next uses the programmatic string when whenever $role gets used. This cl makes it so $role resolves to a msg id, if one exists. Additionally, the role info object also lists the arcon associated with that role.

This allows us to remove a few of the output rules (button, textField).

Review URL: https://codereview.chromium.org/1011913002

Cr-Commit-Position: refs/heads/master@{#322423}
parent 12a84a1f
...@@ -263,16 +263,15 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, EnableSpokenFeedback) { ...@@ -263,16 +263,15 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, EnableSpokenFeedback) {
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusToolbar) { IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusToolbar) {
EnableChromeVox(); EnableChromeVox();
chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR); chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR);
EXPECT_TRUE( EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(),
MatchPattern(speech_monitor_.GetNextUtterance(), "about:blank*Tool bar Reload Button"));
"about:blank*toolbar Reload Button"));
} }
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TypeInOmnibox) { IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TypeInOmnibox) {
EnableChromeVox(); EnableChromeVox();
chrome::ExecuteCommand(browser(), IDC_FOCUS_LOCATION); chrome::ExecuteCommand(browser(), IDC_FOCUS_LOCATION);
EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "*Edit text")); EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "*Edit text*"));
SendKeyPress(ui::VKEY_X); SendKeyPress(ui::VKEY_X);
EXPECT_EQ("x", speech_monitor_.GetNextUtterance()); EXPECT_EQ("x", speech_monitor_.GetNextUtterance());
...@@ -292,8 +291,8 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusShelf) { ...@@ -292,8 +291,8 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusShelf) {
EXPECT_TRUE(PerformAcceleratorAction(ash::FOCUS_SHELF)); EXPECT_TRUE(PerformAcceleratorAction(ash::FOCUS_SHELF));
const char* expected = app_list::switches::IsExperimentalAppListEnabled() const char* expected = app_list::switches::IsExperimentalAppListEnabled()
? "Shelf toolbar Launcher Button" ? "Shelf Tool bar Launcher Button"
: "Shelf toolbar Apps Button"; : "Shelf Tool bar Apps Button";
EXPECT_EQ(expected, speech_monitor_.GetNextUtterance()); EXPECT_EQ(expected, speech_monitor_.GetNextUtterance());
SendKeyPress(ui::VKEY_TAB); SendKeyPress(ui::VKEY_TAB);
...@@ -542,9 +541,8 @@ IN_PROC_BROWSER_TEST_F(GuestSpokenFeedbackTest, FocusToolbar) { ...@@ -542,9 +541,8 @@ IN_PROC_BROWSER_TEST_F(GuestSpokenFeedbackTest, FocusToolbar) {
chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR); chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR);
EXPECT_TRUE( EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(),
MatchPattern(speech_monitor_.GetNextUtterance(), "about:blank*Tool bar Reload Button"));
"about:blank*toolbar Reload Button"));
} }
// //
......
...@@ -76,6 +76,56 @@ Output = function() { ...@@ -76,6 +76,56 @@ Output = function() {
*/ */
Output.SPACE = ' '; Output.SPACE = ' ';
/**
* Metadata about supported automation roles.
* @const {Object<string, {msgId: string, earcon: (string|undefined)}>}
* @private
*/
Output.ROLE_INFO_ = {
alert: {
msgId: 'aria_role_alert',
earcon: 'ALERT_NONMODAL',
},
button: {
msgId: 'tag_button',
earcon: 'BUTTON'
},
checkbox: {
msgId: 'input_type_checkbox'
},
heading: {
msgId: 'aria_role_heading',
},
link: {
msgId: 'tag_link',
earcon: 'LINK'
},
listItem: {
msgId: 'ARIA_ROLE_LISTITEM',
earcon: 'list_item'
},
menuListOption: {
msgId: 'aria_role_menuitem'
},
popUpButton: {
msgId: 'tag_button'
},
radioButton: {
msgId: 'input_type_radio'
},
textBox: {
msgId: 'input_type_text',
earcon: 'EDITABLE_TEXT'
},
textField: {
msgId: 'input_type_text',
earcon: 'EDITABLE_TEXT'
},
toolbar: {
msgId: 'aria_role_toolbar'
}
};
/** /**
* Rules specifying format of AutomationNodes for output. * Rules specifying format of AutomationNodes for output.
* @type {!Object<string, Object<string, Object<string, string>>>} * @type {!Object<string, Object<string, Object<string, string>>>}
...@@ -90,9 +140,6 @@ Output.RULES = { ...@@ -90,9 +140,6 @@ Output.RULES = {
speak: '!doNotInterrupt ' + speak: '!doNotInterrupt ' +
'@aria_role_alert $name $earcon(ALERT_NONMODAL) $descendants' '@aria_role_alert $name $earcon(ALERT_NONMODAL) $descendants'
}, },
button: {
speak: '$name $earcon(BUTTON, @tag_button)'
},
checkBox: { checkBox: {
speak: '$if($checked, @describe_checkbox_checked($name), ' + speak: '$if($checked, @describe_checkbox_checked($name), ' +
'@describe_checkbox_unchecked($name)) ' + '@describe_checkbox_unchecked($name)) ' +
...@@ -116,7 +163,7 @@ Output.RULES = { ...@@ -116,7 +163,7 @@ Output.RULES = {
speak: '$name= $visited $earcon(LINK, @tag_link)=' speak: '$name= $visited $earcon(LINK, @tag_link)='
}, },
list: { list: {
enter: '$role' enter: '@aria_role_list @list_with_items($parentChildCount)'
}, },
listItem: { listItem: {
enter: '$role' enter: '$role'
...@@ -150,15 +197,9 @@ Output.RULES = { ...@@ -150,15 +197,9 @@ Output.RULES = {
staticText: { staticText: {
speak: '$value' speak: '$value'
}, },
textBox: {
speak: '$name $value $earcon(EDITABLE_TEXT, @input_type_text)'
},
tab: { tab: {
speak: '@describe_tab($name)' speak: '@describe_tab($name)'
}, },
textField: {
speak: '$name $value $earcon(EDITABLE_TEXT, @input_type_text) $protected'
},
toolbar: { toolbar: {
enter: '$name $role' enter: '$name $role'
}, },
...@@ -425,10 +466,7 @@ Output.prototype = { ...@@ -425,10 +466,7 @@ Output.prototype = {
// All possible tokens based on prefix. // All possible tokens based on prefix.
if (prefix == '$') { if (prefix == '$') {
options.annotation = token; options.annotation = token;
if (token == 'role') { if (token == 'value') {
// Non-localized role and state obtained by default.
this.addToSpannable_(buff, node.role, options);
} else if (token == 'value') {
var text = node.attributes.value; var text = node.attributes.value;
if (text !== undefined) { if (text !== undefined) {
var offset = buff.getLength(); var offset = buff.getLength();
...@@ -478,6 +516,26 @@ Output.prototype = { ...@@ -478,6 +516,26 @@ Output.prototype = {
new cursors.Cursor(leftmost, 0), new cursors.Cursor(leftmost, 0),
new cursors.Cursor(rightmost, 0)); new cursors.Cursor(rightmost, 0));
this.range_(subrange, null, 'navigate', buff); this.range_(subrange, null, 'navigate', buff);
} else if (token == 'role') {
var msg = node.role;
var earconId = null;
var info = Output.ROLE_INFO_[node.role];
if (info) {
if (this.formatOptions_.braille)
msg = cvox.ChromeVox.msgs.getMsg(info.msgId + '_brl');
else
msg = cvox.ChromeVox.msgs.getMsg(info.msgId);
earconId = info.earcon;
} else {
console.error('Missing role info for ' + node.role);
}
if (earconId) {
options.annotation = new Output.Action(function() {
cvox.ChromeVox.earcons.playEarcon(
cvox.AbstractEarcons[earconId]);
});
}
this.addToSpannable_(buff, msg, options);
} else if (node.attributes[token]) { } else if (node.attributes[token]) {
this.addToSpannable_(buff, node.attributes[token], options); this.addToSpannable_(buff, node.attributes[token], options);
} else if (node.state[token]) { } else if (node.state[token]) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment