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

Side by Side Diff: ui/accessibility/platform/ax_platform_node_win.cc

Issue 2965873002: Move IA2 Role handling to AXPlatformNodeWin. (Closed)
Patch Set: Comment IA2Role Created 3 years, 5 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 unified diff | Download patch
« no previous file with comments | « ui/accessibility/platform/ax_platform_node_win.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <atlbase.h> 5 #include <atlbase.h>
6 #include <atlcom.h> 6 #include <atlcom.h>
7 #include <limits.h> 7 #include <limits.h>
8 #include <oleacc.h> 8 #include <oleacc.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 // Deprecated. 735 // Deprecated.
736 return E_NOTIMPL; 736 return E_NOTIMPL;
737 } 737 }
738 738
739 // 739 //
740 // IAccessible2 implementation. 740 // IAccessible2 implementation.
741 // 741 //
742 742
743 STDMETHODIMP AXPlatformNodeWin::role(LONG* role) { 743 STDMETHODIMP AXPlatformNodeWin::role(LONG* role) {
744 COM_OBJECT_VALIDATE_1_ARG(role); 744 COM_OBJECT_VALIDATE_1_ARG(role);
745 *role = MSAARole(); 745
746 *role = IA2Role();
747 // If we didn't explicitly set the IAccessible2 role, make it the same
748 // as the MSAA role.
749 if (!*role)
750 *role = MSAARole();
746 return S_OK; 751 return S_OK;
747 } 752 }
748 753
749 STDMETHODIMP AXPlatformNodeWin::get_states(AccessibleStates* states) { 754 STDMETHODIMP AXPlatformNodeWin::get_states(AccessibleStates* states) {
750 COM_OBJECT_VALIDATE_1_ARG(states); 755 COM_OBJECT_VALIDATE_1_ARG(states);
751 *states = IA2State(); 756 *states = IA2State();
752 return S_OK; 757 return S_OK;
753 } 758 }
754 759
755 STDMETHODIMP AXPlatformNodeWin::get_uniqueID(LONG* unique_id) { 760 STDMETHODIMP AXPlatformNodeWin::get_uniqueID(LONG* unique_id) {
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
1659 ia2_state |= IA2_STATE_SINGLE_LINE; 1664 ia2_state |= IA2_STATE_SINGLE_LINE;
1660 } 1665 }
1661 ia2_state |= IA2_STATE_SELECTABLE_TEXT; 1666 ia2_state |= IA2_STATE_SELECTABLE_TEXT;
1662 break; 1667 break;
1663 default: 1668 default:
1664 break; 1669 break;
1665 } 1670 }
1666 return ia2_state; 1671 return ia2_state;
1667 } 1672 }
1668 1673
1674 // IA2Role() only returns a role if the MSAA role doesn't suffice,
1675 // otherwise this method returns 0. See AXPlatformNodeWin::role().
1676 int32_t AXPlatformNodeWin::IA2Role() {
1677 // If this is a web area for a presentational iframe, give it a role of
1678 // something other than DOCUMENT so that the fact that it's a separate doc
1679 // is not exposed to AT.
1680 if (IsWebAreaForPresentationalIframe()) {
1681 return ROLE_SYSTEM_GROUPING;
1682 }
1683
1684 int32_t ia2_role = 0;
1685
1686 switch (GetData().role) {
1687 case ui::AX_ROLE_BANNER:
1688 ia2_role = IA2_ROLE_HEADER;
1689 break;
1690 case ui::AX_ROLE_BLOCKQUOTE:
1691 ia2_role = IA2_ROLE_SECTION;
1692 break;
1693 case ui::AX_ROLE_CANVAS:
1694 if (GetBoolAttribute(ui::AX_ATTR_CANVAS_HAS_FALLBACK)) {
1695 ia2_role = IA2_ROLE_CANVAS;
1696 }
1697 break;
1698 case ui::AX_ROLE_CAPTION:
1699 ia2_role = IA2_ROLE_CAPTION;
1700 break;
1701 case ui::AX_ROLE_COLOR_WELL:
1702 ia2_role = IA2_ROLE_COLOR_CHOOSER;
1703 break;
1704 case ui::AX_ROLE_COMPLEMENTARY:
1705 ia2_role = IA2_ROLE_NOTE;
1706 break;
1707 case ui::AX_ROLE_CONTENT_INFO:
1708 ia2_role = IA2_ROLE_PARAGRAPH;
1709 break;
1710 case ui::AX_ROLE_DATE:
1711 case ui::AX_ROLE_DATE_TIME:
1712 ia2_role = IA2_ROLE_DATE_EDITOR;
1713 break;
1714 case ui::AX_ROLE_DEFINITION:
1715 ia2_role = IA2_ROLE_PARAGRAPH;
1716 break;
1717 case ui::AX_ROLE_DESCRIPTION_LIST_DETAIL:
1718 ia2_role = IA2_ROLE_PARAGRAPH;
1719 break;
1720 case ui::AX_ROLE_EMBEDDED_OBJECT:
1721 if (!delegate_->GetChildCount()) {
1722 ia2_role = IA2_ROLE_EMBEDDED_OBJECT;
1723 }
1724 break;
1725 case ui::AX_ROLE_FIGCAPTION:
1726 ia2_role = IA2_ROLE_CAPTION;
1727 break;
1728 case ui::AX_ROLE_FORM:
1729 ia2_role = IA2_ROLE_FORM;
1730 break;
1731 case ui::AX_ROLE_FOOTER:
1732 ia2_role = IA2_ROLE_FOOTER;
1733 break;
1734 case ui::AX_ROLE_GENERIC_CONTAINER:
1735 ia2_role = IA2_ROLE_SECTION;
1736 break;
1737 case ui::AX_ROLE_HEADING:
1738 ia2_role = IA2_ROLE_HEADING;
1739 break;
1740 case ui::AX_ROLE_IFRAME:
1741 ia2_role = IA2_ROLE_INTERNAL_FRAME;
1742 break;
1743 case ui::AX_ROLE_IMAGE_MAP:
1744 ia2_role = IA2_ROLE_IMAGE_MAP;
1745 break;
1746 case ui::AX_ROLE_LABEL_TEXT:
1747 case ui::AX_ROLE_LEGEND:
1748 ia2_role = IA2_ROLE_LABEL;
1749 break;
1750 case ui::AX_ROLE_MAIN:
1751 ia2_role = IA2_ROLE_PARAGRAPH;
1752 break;
1753 case ui::AX_ROLE_MARK:
1754 ia2_role = IA2_ROLE_TEXT_FRAME;
1755 break;
1756 case ui::AX_ROLE_MENU_ITEM_CHECK_BOX:
1757 ia2_role = IA2_ROLE_CHECK_MENU_ITEM;
1758 break;
1759 case ui::AX_ROLE_MENU_ITEM_RADIO:
1760 ia2_role = IA2_ROLE_RADIO_MENU_ITEM;
1761 break;
1762 case ui::AX_ROLE_NAVIGATION:
1763 ia2_role = IA2_ROLE_SECTION;
1764 break;
1765 case ui::AX_ROLE_NOTE:
1766 ia2_role = IA2_ROLE_NOTE;
1767 break;
1768 case ui::AX_ROLE_PARAGRAPH:
1769 ia2_role = IA2_ROLE_PARAGRAPH;
1770 break;
1771 case ui::AX_ROLE_PRE:
1772 ia2_role = IA2_ROLE_PARAGRAPH;
1773 break;
1774 case ui::AX_ROLE_REGION: {
1775 base::string16 html_tag = GetString16Attribute(ui::AX_ATTR_HTML_TAG);
1776
1777 if (html_tag == L"section") {
1778 ia2_role = IA2_ROLE_SECTION;
1779 }
1780 } break;
1781 case ui::AX_ROLE_RUBY:
1782 ia2_role = IA2_ROLE_TEXT_FRAME;
1783 break;
1784 case ui::AX_ROLE_RULER:
1785 ia2_role = IA2_ROLE_RULER;
1786 break;
1787 case ui::AX_ROLE_SCROLL_AREA:
1788 ia2_role = IA2_ROLE_SCROLL_PANE;
1789 break;
1790 case ui::AX_ROLE_SEARCH:
1791 ia2_role = IA2_ROLE_SECTION;
1792 break;
1793 case ui::AX_ROLE_SWITCH:
1794 ia2_role = IA2_ROLE_TOGGLE_BUTTON;
1795 break;
1796 case ui::AX_ROLE_TABLE_HEADER_CONTAINER:
1797 ia2_role = IA2_ROLE_SECTION;
1798 break;
1799 case ui::AX_ROLE_TOGGLE_BUTTON:
1800 ia2_role = IA2_ROLE_TOGGLE_BUTTON;
1801 break;
1802 case ui::AX_ROLE_ABBR:
1803 case ui::AX_ROLE_TIME:
1804 ia2_role = IA2_ROLE_TEXT_FRAME;
1805 break;
1806 default:
1807 break;
1808 }
1809 return ia2_role;
1810 }
1811
1669 bool AXPlatformNodeWin::ShouldNodeHaveReadonlyState( 1812 bool AXPlatformNodeWin::ShouldNodeHaveReadonlyState(
1670 const AXNodeData& data) const { 1813 const AXNodeData& data) const {
1671 if (data.GetBoolAttribute(ui::AX_ATTR_ARIA_READONLY)) 1814 if (data.GetBoolAttribute(ui::AX_ATTR_ARIA_READONLY))
1672 return true; 1815 return true;
1673 1816
1674 if (!data.HasState(ui::AX_STATE_READ_ONLY)) 1817 if (!data.HasState(ui::AX_STATE_READ_ONLY))
1675 return false; 1818 return false;
1676 1819
1677 switch (data.role) { 1820 switch (data.role) {
1678 case ui::AX_ROLE_ARTICLE: 1821 case ui::AX_ROLE_ARTICLE:
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
2000 if (container && container->GetData().role == ui::AX_ROLE_GROUP) 2143 if (container && container->GetData().role == ui::AX_ROLE_GROUP)
2001 container = FromNativeViewAccessible(container->GetParent()); 2144 container = FromNativeViewAccessible(container->GetParent());
2002 2145
2003 if (!container) 2146 if (!container)
2004 return false; 2147 return false;
2005 2148
2006 return container->GetData().role == ui::AX_ROLE_TREE_GRID; 2149 return container->GetData().role == ui::AX_ROLE_TREE_GRID;
2007 } 2150 }
2008 2151
2009 } // namespace ui 2152 } // namespace ui
OLDNEW
« no previous file with comments | « ui/accessibility/platform/ax_platform_node_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698