Commit 37f7a151 authored by dougt's avatar dougt Committed by Commit Bot

Move two BrowserAccessibility role predicates to ax_role_properties.

BUG=703369

Review-Url: https://codereview.chromium.org/2969603002
Cr-Commit-Position: refs/heads/master@{#485462}
parent c7d6bd3d
...@@ -900,55 +900,6 @@ bool BrowserAccessibility::IsClickable() const { ...@@ -900,55 +900,6 @@ bool BrowserAccessibility::IsClickable() const {
return ui::IsRoleClickable(GetRole()); return ui::IsRoleClickable(GetRole());
} }
bool BrowserAccessibility::IsControl() const {
switch (GetRole()) {
case ui::AX_ROLE_BUTTON:
case ui::AX_ROLE_CHECK_BOX:
case ui::AX_ROLE_COLOR_WELL:
case ui::AX_ROLE_COMBO_BOX:
case ui::AX_ROLE_DISCLOSURE_TRIANGLE:
case ui::AX_ROLE_LIST_BOX:
case ui::AX_ROLE_MENU:
case ui::AX_ROLE_MENU_BAR:
case ui::AX_ROLE_MENU_BUTTON:
case ui::AX_ROLE_MENU_ITEM:
case ui::AX_ROLE_MENU_ITEM_CHECK_BOX:
case ui::AX_ROLE_MENU_ITEM_RADIO:
case ui::AX_ROLE_MENU_LIST_OPTION:
case ui::AX_ROLE_MENU_LIST_POPUP:
case ui::AX_ROLE_POP_UP_BUTTON:
case ui::AX_ROLE_RADIO_BUTTON:
case ui::AX_ROLE_SCROLL_BAR:
case ui::AX_ROLE_SEARCH_BOX:
case ui::AX_ROLE_SLIDER:
case ui::AX_ROLE_SPIN_BUTTON:
case ui::AX_ROLE_SWITCH:
case ui::AX_ROLE_TAB:
case ui::AX_ROLE_TEXT_FIELD:
case ui::AX_ROLE_TOGGLE_BUTTON:
case ui::AX_ROLE_TREE:
return true;
default:
return false;
}
}
bool BrowserAccessibility::IsMenuRelated() const {
switch (GetRole()) {
case ui::AX_ROLE_MENU:
case ui::AX_ROLE_MENU_BAR:
case ui::AX_ROLE_MENU_BUTTON:
case ui::AX_ROLE_MENU_ITEM:
case ui::AX_ROLE_MENU_ITEM_CHECK_BOX:
case ui::AX_ROLE_MENU_ITEM_RADIO:
case ui::AX_ROLE_MENU_LIST_OPTION:
case ui::AX_ROLE_MENU_LIST_POPUP:
return true;
default:
return false;
}
}
bool BrowserAccessibility::IsNativeTextControl() const { bool BrowserAccessibility::IsNativeTextControl() const {
const std::string& html_tag = GetStringAttribute(ui::AX_ATTR_HTML_TAG); const std::string& html_tag = GetStringAttribute(ui::AX_ATTR_HTML_TAG);
if (html_tag == "input") { if (html_tag == "input") {
......
...@@ -355,8 +355,6 @@ class CONTENT_EXPORT BrowserAccessibility : public ui::AXPlatformNodeDelegate { ...@@ -355,8 +355,6 @@ class CONTENT_EXPORT BrowserAccessibility : public ui::AXPlatformNodeDelegate {
bool IsWebAreaForPresentationalIframe() const; bool IsWebAreaForPresentationalIframe() const;
virtual bool IsClickable() const; virtual bool IsClickable() const;
bool IsControl() const;
bool IsMenuRelated() const;
bool IsNativeTextControl() const; bool IsNativeTextControl() const;
bool IsSimpleTextControl() const; bool IsSimpleTextControl() const;
// Indicates if this object is at the root of a rich edit text control. // Indicates if this object is at the root of a rich edit text control.
......
...@@ -292,7 +292,7 @@ bool BrowserAccessibilityAndroid::IsInterestingOnAndroid() const { ...@@ -292,7 +292,7 @@ bool BrowserAccessibilityAndroid::IsInterestingOnAndroid() const {
return true; return true;
// If it's not focusable but has a control role, then it's interesting. // If it's not focusable but has a control role, then it's interesting.
if (IsControl()) if (ui::IsControl(GetRole()))
return true; return true;
// Otherwise, the interesting nodes are leaf nodes with non-whitespace text. // Otherwise, the interesting nodes are leaf nodes with non-whitespace text.
......
...@@ -882,8 +882,7 @@ NSString* const NSAccessibilityRequiredAttribute = @"AXRequired"; ...@@ -882,8 +882,7 @@ NSString* const NSAccessibilityRequiredAttribute = @"AXRequired";
// from its descendants. // from its descendants.
base::string16 value = browserAccessibility_->GetValue(); base::string16 value = browserAccessibility_->GetValue();
if (browserAccessibility_->HasState(ui::AX_STATE_FOCUSABLE) && if (browserAccessibility_->HasState(ui::AX_STATE_FOCUSABLE) &&
!browserAccessibility_->IsControl() && !IsControl(browserAccessibility_->GetRole()) && value.empty() &&
value.empty() &&
[self internalRole] != ui::AX_ROLE_DATE_TIME && [self internalRole] != ui::AX_ROLE_DATE_TIME &&
[self internalRole] != ui::AX_ROLE_WEB_AREA && [self internalRole] != ui::AX_ROLE_WEB_AREA &&
[self internalRole] != ui::AX_ROLE_ROOT_WEB_AREA) { [self internalRole] != ui::AX_ROLE_ROOT_WEB_AREA) {
...@@ -1303,7 +1302,7 @@ NSString* const NSAccessibilityRequiredAttribute = @"AXRequired"; ...@@ -1303,7 +1302,7 @@ NSString* const NSAccessibilityRequiredAttribute = @"AXRequired";
// internal // internal
- (BOOL)shouldExposeTitleUIElement { - (BOOL)shouldExposeTitleUIElement {
// VoiceOver ignores TitleUIElement if the element isn't a control. // VoiceOver ignores TitleUIElement if the element isn't a control.
if (!browserAccessibility_->IsControl()) if (!IsControl(browserAccessibility_->GetRole()))
return false; return false;
ui::AXNameFrom nameFrom = static_cast<ui::AXNameFrom>( ui::AXNameFrom nameFrom = static_cast<ui::AXNameFrom>(
...@@ -2506,7 +2505,7 @@ NSString* const NSAccessibilityRequiredAttribute = @"AXRequired"; ...@@ -2506,7 +2505,7 @@ NSString* const NSAccessibilityRequiredAttribute = @"AXRequired";
if (browserAccessibility_->IsClickable()) if (browserAccessibility_->IsClickable())
[actions insertObject:NSAccessibilityPressAction atIndex:0]; [actions insertObject:NSAccessibilityPressAction atIndex:0];
if (browserAccessibility_->IsMenuRelated()) if (IsMenuRelated(browserAccessibility_->GetRole()))
[actions addObject:NSAccessibilityCancelAction]; [actions addObject:NSAccessibilityCancelAction];
if ([self internalRole] == ui::AX_ROLE_SLIDER) { if ([self internalRole] == ui::AX_ROLE_SLIDER) {
......
...@@ -253,7 +253,7 @@ bool AccessibilityComboboxPredicate( ...@@ -253,7 +253,7 @@ bool AccessibilityComboboxPredicate(
bool AccessibilityControlPredicate( bool AccessibilityControlPredicate(
BrowserAccessibility* start, BrowserAccessibility* node) { BrowserAccessibility* start, BrowserAccessibility* node) {
if (node->IsControl()) if (ui::IsControl(node->GetRole()))
return true; return true;
if (node->HasState(ui::AX_STATE_FOCUSABLE) && if (node->HasState(ui::AX_STATE_FOCUSABLE) &&
node->GetRole() != ui::AX_ROLE_IFRAME && node->GetRole() != ui::AX_ROLE_IFRAME &&
......
...@@ -84,4 +84,53 @@ bool IsRowContainer(ui::AXRole role) { ...@@ -84,4 +84,53 @@ bool IsRowContainer(ui::AXRole role) {
} }
} }
bool IsControl(ui::AXRole role) {
switch (role) {
case ui::AX_ROLE_BUTTON:
case ui::AX_ROLE_CHECK_BOX:
case ui::AX_ROLE_COLOR_WELL:
case ui::AX_ROLE_COMBO_BOX:
case ui::AX_ROLE_DISCLOSURE_TRIANGLE:
case ui::AX_ROLE_LIST_BOX:
case ui::AX_ROLE_MENU:
case ui::AX_ROLE_MENU_BAR:
case ui::AX_ROLE_MENU_BUTTON:
case ui::AX_ROLE_MENU_ITEM:
case ui::AX_ROLE_MENU_ITEM_CHECK_BOX:
case ui::AX_ROLE_MENU_ITEM_RADIO:
case ui::AX_ROLE_MENU_LIST_OPTION:
case ui::AX_ROLE_MENU_LIST_POPUP:
case ui::AX_ROLE_POP_UP_BUTTON:
case ui::AX_ROLE_RADIO_BUTTON:
case ui::AX_ROLE_SCROLL_BAR:
case ui::AX_ROLE_SEARCH_BOX:
case ui::AX_ROLE_SLIDER:
case ui::AX_ROLE_SPIN_BUTTON:
case ui::AX_ROLE_SWITCH:
case ui::AX_ROLE_TAB:
case ui::AX_ROLE_TEXT_FIELD:
case ui::AX_ROLE_TOGGLE_BUTTON:
case ui::AX_ROLE_TREE:
return true;
default:
return false;
}
}
bool IsMenuRelated(ui::AXRole role) {
switch (role) {
case ui::AX_ROLE_MENU:
case ui::AX_ROLE_MENU_BAR:
case ui::AX_ROLE_MENU_BUTTON:
case ui::AX_ROLE_MENU_ITEM:
case ui::AX_ROLE_MENU_ITEM_CHECK_BOX:
case ui::AX_ROLE_MENU_ITEM_RADIO:
case ui::AX_ROLE_MENU_LIST_OPTION:
case ui::AX_ROLE_MENU_LIST_POPUP:
return true;
default:
return false;
}
}
} // namespace ui } // namespace ui
...@@ -26,6 +26,12 @@ AX_EXPORT bool IsContainerWithSelectableChildrenRole(ui::AXRole role); ...@@ -26,6 +26,12 @@ AX_EXPORT bool IsContainerWithSelectableChildrenRole(ui::AXRole role);
// Returns true if this node is a row container. // Returns true if this node is a row container.
AX_EXPORT bool IsRowContainer(ui::AXRole role); AX_EXPORT bool IsRowContainer(ui::AXRole role);
// Returns true if this node is a control.
AX_EXPORT bool IsControl(ui::AXRole role);
// Returns true if this node is a menu or related role.
AX_EXPORT bool IsMenuRelated(ui::AXRole role);
} // namespace ui } // namespace ui
#endif // UI_ACCESSIBILITY_AX_ROLE_PROPERTIES_H_ #endif // UI_ACCESSIBILITY_AX_ROLE_PROPERTIES_H_
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