Commit 950c0238 authored by David Tseng's avatar David Tseng Committed by Commit Bot

Hook up support for ax::mojom::HasPopup

Unfortunately,
https://chromium-review.googlesource.com/896672

only incompletely hooked up support for this attribute within chrome.automation.

This change completes this hookup.

Test: in various menus with popups, verify AutomationNode.hasPopup is correctly exposed. Furthermore, verify that ChromeVox indicates a menu item has a submenu (e.g. for the Google image labeling submenu).
Change-Id: I44694cccbb827ddb8df5803779adb6b2e1d89034
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1532662Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: David Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#642731}
parent aa2ec569
...@@ -493,7 +493,7 @@ Output.RULES = { ...@@ -493,7 +493,7 @@ Output.RULES = {
$description $state $restriction` $description $state $restriction`
}, },
menuItem: { menuItem: {
speak: `$name $role $if($haspopup, @has_submenu) speak: `$name $role $if($hasPopup, @has_submenu)
@describe_index($if($posInSet, $posInSet, $indexInParent(menuItem, menuItemCheckBox, menuItemRadio)), @describe_index($if($posInSet, $posInSet, $indexInParent(menuItem, menuItemCheckBox, menuItemRadio)),
$if($setSize, $setSize, $parentChildCount(menuItem, menuItemCheckBox, menuItemRadio))) $if($setSize, $setSize, $parentChildCount(menuItem, menuItemCheckBox, menuItemRadio)))
$description $state $restriction` $description $state $restriction`
...@@ -726,6 +726,8 @@ Output.isTruthy = function(node, attrib) { ...@@ -726,6 +726,8 @@ Output.isTruthy = function(node, attrib) {
switch (attrib) { switch (attrib) {
case 'checked': case 'checked':
return node.checked && node.checked !== 'false'; return node.checked && node.checked !== 'false';
case 'hasPopup':
return node.hasPopup && node.hasPopup !== 'false';
// Chrome automatically calculates these attributes. // Chrome automatically calculates these attributes.
case 'posInSet': case 'posInSet':
......
...@@ -1122,6 +1122,16 @@ void AutomationInternalCustomBindings::AddRoutes() { ...@@ -1122,6 +1122,16 @@ void AutomationInternalCustomBindings::AddRoutes() {
v8::NewStringType::kNormal) v8::NewStringType::kNormal)
.ToLocalChecked()); .ToLocalChecked());
}); });
RouteNodeIDFunction(
"GetHasPopup",
[](v8::Isolate* isolate, v8::ReturnValue<v8::Value> result,
AutomationAXTreeWrapper* tree_wrapper, ui::AXNode* node) {
ax::mojom::HasPopup has_popup = node->data().GetHasPopup();
std::string has_popup_str = ui::ToString(has_popup);
result.Set(v8::String::NewFromUtf8(isolate, has_popup_str.c_str(),
v8::NewStringType::kNormal)
.ToLocalChecked());
});
RouteNodeIDPlusStringBoolFunction( RouteNodeIDPlusStringBoolFunction(
"GetNextTextMatch", "GetNextTextMatch",
[this](v8::Isolate* isolate, v8::ReturnValue<v8::Value> result, [this](v8::Isolate* isolate, v8::ReturnValue<v8::Value> result,
......
...@@ -349,6 +349,14 @@ var GetStandardActions = natives.GetStandardActions; ...@@ -349,6 +349,14 @@ var GetStandardActions = natives.GetStandardActions;
var GetDefaultActionVerb = natives.GetDefaultActionVerb; var GetDefaultActionVerb = natives.GetDefaultActionVerb;
/**
* @param {string} axTreeID The id of the accessibility tree.
* @param {number} nodeID The id of a node.
* @return {automation.HasPopup}
*/
var GetHasPopup = natives.GetHasPopup;
/** /**
* @param {string} axTreeID The id of the accessibility tree. * @param {string} axTreeID The id of the accessibility tree.
* @param {number} nodeID The id of a node. * @param {number} nodeID The id of a node.
...@@ -599,6 +607,10 @@ AutomationNodeImpl.prototype = { ...@@ -599,6 +607,10 @@ AutomationNodeImpl.prototype = {
return GetDefaultActionVerb(this.treeID, this.id); return GetDefaultActionVerb(this.treeID, this.id);
}, },
get hasPopup() {
return GetHasPopup(this.treeID, this.id);
},
get tableCellColumnHeaders() { get tableCellColumnHeaders() {
var ids = GetTableCellColumnHeaders(this.treeID, this.id); var ids = GetTableCellColumnHeaders(this.treeID, this.id);
if (ids && this.rootImpl) { if (ids && this.rootImpl) {
...@@ -1564,6 +1576,7 @@ utils.expose(AutomationNode, AutomationNodeImpl, { ...@@ -1564,6 +1576,7 @@ utils.expose(AutomationNode, AutomationNodeImpl, {
'role', 'role',
'checked', 'checked',
'defaultActionVerb', 'defaultActionVerb',
'hasPopup',
'restriction', 'restriction',
'state', 'state',
'location', 'location',
......
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