diff options
author | mhm@chromium.org <mhm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-09 04:00:49 +0000 |
---|---|---|
committer | mhm@chromium.org <mhm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-09 04:00:49 +0000 |
commit | 70d38b09d6f504b6a47b4d0e8f0a9b2f5d615373 (patch) | |
tree | efcc27929e40b9e71d0284d8094dab970945214d /views/accessibility | |
parent | 7f265f9db6a502cb8909636d350afd0dbf6c5539 (diff) | |
download | chromium_src-70d38b09d6f504b6a47b4d0e8f0a9b2f5d615373.zip chromium_src-70d38b09d6f504b6a47b4d0e8f0a9b2f5d615373.tar.gz chromium_src-70d38b09d6f504b6a47b4d0e8f0a9b2f5d615373.tar.bz2 |
[accessibility] Allow views to have multiple accessibility states and add correct roles.
Allow views to contain multiple accessibility states since states are not mutually exclusive, we treat them as an uint32. Add missing roles to couple of views.
BUG=None
TEST=Run unit tests, and check accessibility tree.
Review URL: http://codereview.chromium.org/1527019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44054 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/accessibility')
-rw-r--r-- | views/accessibility/accessibility_types.h | 33 | ||||
-rw-r--r-- | views/accessibility/view_accessibility.cc | 35 |
2 files changed, 49 insertions, 19 deletions
diff --git a/views/accessibility/accessibility_types.h b/views/accessibility/accessibility_types.h index 79b9e03..83c7aa7 100644 --- a/views/accessibility/accessibility_types.h +++ b/views/accessibility/accessibility_types.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -15,6 +15,21 @@ //////////////////////////////////////////////////////////////////////////////// class AccessibilityTypes { public: + + + // This defines states of the supported accessibility roles in our + // Views (e.g. used in View::GetAccessibleState). Any interface using roles + // must provide a conversion to its own roles (see e.g. + // ViewAccessibility::get_accState and ViewAccessibility::MSAAState). + typedef uint32 State; + enum StateFlag { + STATE_CHECKED = 1 << 0, + STATE_HASPOPUP = 1 << 1, + STATE_LINKED = 1 << 2, + STATE_PROTECTED = 1 << 3, + STATE_READONLY = 1 << 4 + }; + // This defines an enumeration of the supported accessibility roles in our // Views (e.g. used in View::GetAccessibleRole). Any interface using roles // must provide a conversion to its own roles (see e.g. @@ -29,26 +44,24 @@ class AccessibilityTypes { ROLE_GRAPHIC, ROLE_GROUPING, ROLE_LINK, + ROLE_MENUITEM, + ROLE_MENUPOPUP, + ROLE_OUTLINE, + ROLE_OUTLINEITEM, ROLE_PAGETAB, ROLE_PAGETABLIST, ROLE_PANE, + ROLE_PROGRESSBAR, ROLE_PUSHBUTTON, + ROLE_SCROLLBAR, ROLE_SEPARATOR, + ROLE_STATICTEXT, ROLE_TEXT, ROLE_TITLEBAR, ROLE_TOOLBAR, ROLE_WINDOW }; - // This defines an enumeration of the supported accessibility roles in our - // Views (e.g. used in View::GetAccessibleState). Any interface using roles - // must provide a conversion to its own roles (see e.g. - // ViewAccessibility::get_accState and ViewAccessibility::MSAAState). - enum State { - STATE_HASPOPUP, - STATE_READONLY - }; - private: // Do not instantiate this class. AccessibilityTypes() {} diff --git a/views/accessibility/view_accessibility.cc b/views/accessibility/view_accessibility.cc index 9d8861a..f9dc5c6 100644 --- a/views/accessibility/view_accessibility.cc +++ b/views/accessibility/view_accessibility.cc @@ -717,16 +717,30 @@ int32 ViewAccessibility::MSAARole(AccessibilityTypes::Role role) { return ROLE_SYSTEM_GROUPING; case AccessibilityTypes::ROLE_LINK: return ROLE_SYSTEM_LINK; + case AccessibilityTypes::ROLE_MENUITEM: + return ROLE_SYSTEM_MENUITEM; + case AccessibilityTypes::ROLE_MENUPOPUP: + return ROLE_SYSTEM_MENUPOPUP; + case AccessibilityTypes::ROLE_OUTLINE: + return ROLE_SYSTEM_OUTLINE; + case AccessibilityTypes::ROLE_OUTLINEITEM: + return ROLE_SYSTEM_OUTLINEITEM; case AccessibilityTypes::ROLE_PAGETAB: return ROLE_SYSTEM_PAGETAB; case AccessibilityTypes::ROLE_PAGETABLIST: return ROLE_SYSTEM_PAGETABLIST; case AccessibilityTypes::ROLE_PANE: return ROLE_SYSTEM_PANE; + case AccessibilityTypes::ROLE_PROGRESSBAR: + return ROLE_SYSTEM_PROGRESSBAR; case AccessibilityTypes::ROLE_PUSHBUTTON: return ROLE_SYSTEM_PUSHBUTTON; + case AccessibilityTypes::ROLE_SCROLLBAR: + return ROLE_SYSTEM_SCROLLBAR; case AccessibilityTypes::ROLE_SEPARATOR: return ROLE_SYSTEM_SEPARATOR; + case AccessibilityTypes::ROLE_STATICTEXT: + return ROLE_SYSTEM_STATICTEXT; case AccessibilityTypes::ROLE_TEXT: return ROLE_SYSTEM_TEXT; case AccessibilityTypes::ROLE_TITLEBAR: @@ -743,15 +757,18 @@ int32 ViewAccessibility::MSAARole(AccessibilityTypes::Role role) { } int32 ViewAccessibility::MSAAState(AccessibilityTypes::State state) { - switch (state) { - case AccessibilityTypes::STATE_HASPOPUP : - return STATE_SYSTEM_HASPOPUP; - case AccessibilityTypes::STATE_READONLY : - return STATE_SYSTEM_READONLY; - default : - // No default state in MSAA. - return 0; - } + int32 msaa_state = 0; + if (state & AccessibilityTypes::STATE_CHECKED) + msaa_state |= STATE_SYSTEM_CHECKED; + if (state & AccessibilityTypes::STATE_HASPOPUP) + msaa_state |= STATE_SYSTEM_HASPOPUP; + if (state & AccessibilityTypes::STATE_LINKED) + msaa_state |= STATE_SYSTEM_LINKED; + if (state & AccessibilityTypes::STATE_PROTECTED) + msaa_state |= STATE_SYSTEM_PROTECTED; + if (state & AccessibilityTypes::STATE_READONLY) + msaa_state |= STATE_SYSTEM_READONLY; + return msaa_state; } // IAccessible functions not supported. |