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

Unified Diff: ui/accessibility/platform/ax_platform_node_win.cc

Issue 2968833002: Move IA2 State handling to AXPlatformNodeWin. (Closed)
Patch Set: rebase Created 3 years, 6 months 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 side-by-side diff with in-line comments
Download patch
Index: ui/accessibility/platform/ax_platform_node_win.cc
diff --git a/ui/accessibility/platform/ax_platform_node_win.cc b/ui/accessibility/platform/ax_platform_node_win.cc
index cb94df0acdc23b5035f45d103f881004b352bf9d..8f5bd2aa37616a879808a86a3093f92ffdc51a18 100644
--- a/ui/accessibility/platform/ax_platform_node_win.cc
+++ b/ui/accessibility/platform/ax_platform_node_win.cc
@@ -747,15 +747,7 @@ STDMETHODIMP AXPlatformNodeWin::role(LONG* role) {
STDMETHODIMP AXPlatformNodeWin::get_states(AccessibleStates* states) {
COM_OBJECT_VALIDATE_1_ARG(states);
- // There are only a couple of states we need to support
- // in IAccessible2. If any more are added, we may want to
- // add a helper function like MSAAState.
- *states = IA2_STATE_OPAQUE;
- if (GetData().state & (1 << ui::AX_STATE_EDITABLE))
- *states |= IA2_STATE_EDITABLE;
- if (GetData().state & (1 << ui::AX_STATE_VERTICAL))
- *states |= IA2_STATE_VERTICAL;
-
+ *states = MSAA_IA2State();
return S_OK;
}
@@ -1605,6 +1597,60 @@ bool AXPlatformNodeWin::IsWebAreaForPresentationalIframe() {
return parent->GetData().role == ui::AX_ROLE_IFRAME_PRESENTATIONAL;
}
+int32_t AXPlatformNodeWin::MSAA_IA2State() {
+ const AXNodeData& data = GetData();
dmazzoni 2017/07/06 22:54:57 Not sure how significant this is, but we're callin
dougt 2017/07/11 20:59:27 Acknowledged. Do you think we should measure the
+
+ int32_t ia2_state = IA2_STATE_OPAQUE;
+
+ const auto checked_state = static_cast<ui::AXCheckedState>(
+ GetIntAttribute(ui::AX_ATTR_CHECKED_STATE));
+ if (checked_state) {
+ ia2_state |= IA2_STATE_CHECKABLE;
+ }
+
+ if (HasIntAttribute(ui::AX_ATTR_INVALID_STATE) &&
+ GetIntAttribute(ui::AX_ATTR_INVALID_STATE) != ui::AX_INVALID_STATE_FALSE)
+ ia2_state |= IA2_STATE_INVALID_ENTRY;
+ if (data.HasState(ui::AX_STATE_REQUIRED))
+ ia2_state |= IA2_STATE_REQUIRED;
+ if (data.HasState(ui::AX_STATE_VERTICAL))
+ ia2_state |= IA2_STATE_VERTICAL;
+ if (data.HasState(ui::AX_STATE_HORIZONTAL))
+ ia2_state |= IA2_STATE_HORIZONTAL;
+ if (data.HasState(ui::AX_STATE_EDITABLE))
+ ia2_state |= IA2_STATE_EDITABLE;
+
+ if (!GetStringAttribute(ui::AX_ATTR_AUTO_COMPLETE).empty())
+ ia2_state |= IA2_STATE_SUPPORTS_AUTOCOMPLETION;
+
+ if (GetBoolAttribute(ui::AX_ATTR_MODAL))
+ ia2_state |= IA2_STATE_MODAL;
+
+ switch (data.role) {
+ case ui::AX_ROLE_MENU_LIST_POPUP:
+ ia2_state &= ~(IA2_STATE_EDITABLE);
+ break;
+ case ui::AX_ROLE_MENU_LIST_OPTION:
+ ia2_state &= ~(IA2_STATE_EDITABLE);
+ break;
+ case ui::AX_ROLE_SCROLL_AREA:
+ ia2_state &= ~(IA2_STATE_EDITABLE);
+ break;
+ case ui::AX_ROLE_TEXT_FIELD:
+ case ui::AX_ROLE_SEARCH_BOX:
+ if (data.HasState(ui::AX_STATE_MULTILINE)) {
+ ia2_state |= IA2_STATE_MULTI_LINE;
+ } else {
+ ia2_state |= IA2_STATE_SINGLE_LINE;
+ }
+ ia2_state |= IA2_STATE_SELECTABLE_TEXT;
+ break;
+ default:
+ break;
+ }
+ return ia2_state;
+}
+
bool AXPlatformNodeWin::ShouldNodeHaveReadonlyState(
const AXNodeData& data) const {
if (data.GetBoolAttribute(ui::AX_ATTR_ARIA_READONLY))

Powered by Google App Engine
This is Rietveld 408576698