OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2011 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 {kDateRole, "Date"}, | 168 {kDateRole, "Date"}, |
169 {kDateTimeRole, "DateTime"}, | 169 {kDateTimeRole, "DateTime"}, |
170 {kDefinitionRole, "Definition"}, | 170 {kDefinitionRole, "Definition"}, |
171 {kDescriptionListDetailRole, "DescriptionListDetail"}, | 171 {kDescriptionListDetailRole, "DescriptionListDetail"}, |
172 {kDescriptionListRole, "DescriptionList"}, | 172 {kDescriptionListRole, "DescriptionList"}, |
173 {kDescriptionListTermRole, "DescriptionListTerm"}, | 173 {kDescriptionListTermRole, "DescriptionListTerm"}, |
174 {kDetailsRole, "Details"}, | 174 {kDetailsRole, "Details"}, |
175 {kDialogRole, "Dialog"}, | 175 {kDialogRole, "Dialog"}, |
176 {kDirectoryRole, "Directory"}, | 176 {kDirectoryRole, "Directory"}, |
177 {kDisclosureTriangleRole, "DisclosureTriangle"}, | 177 {kDisclosureTriangleRole, "DisclosureTriangle"}, |
178 {kDivRole, "Div"}, | |
179 {kDocumentRole, "Document"}, | 178 {kDocumentRole, "Document"}, |
180 {kEmbeddedObjectRole, "EmbeddedObject"}, | 179 {kEmbeddedObjectRole, "EmbeddedObject"}, |
181 {kFeedRole, "feed"}, | 180 {kFeedRole, "feed"}, |
182 {kFigcaptionRole, "Figcaption"}, | 181 {kFigcaptionRole, "Figcaption"}, |
183 {kFigureRole, "Figure"}, | 182 {kFigureRole, "Figure"}, |
184 {kFooterRole, "Footer"}, | 183 {kFooterRole, "Footer"}, |
185 {kFormRole, "Form"}, | 184 {kFormRole, "Form"}, |
| 185 {kGenericContainerRole, "GenericContainer"}, |
186 {kGridRole, "Grid"}, | 186 {kGridRole, "Grid"}, |
187 {kGroupRole, "Group"}, | 187 {kGroupRole, "Group"}, |
188 {kHeadingRole, "Heading"}, | 188 {kHeadingRole, "Heading"}, |
189 {kIframePresentationalRole, "IframePresentational"}, | 189 {kIframePresentationalRole, "IframePresentational"}, |
190 {kIframeRole, "Iframe"}, | 190 {kIframeRole, "Iframe"}, |
191 {kIgnoredRole, "Ignored"}, | 191 {kIgnoredRole, "Ignored"}, |
192 {kImageMapLinkRole, "ImageMapLink"}, | 192 {kImageMapLinkRole, "ImageMapLink"}, |
193 {kImageMapRole, "ImageMap"}, | 193 {kImageMapRole, "ImageMap"}, |
194 {kImageRole, "Image"}, | 194 {kImageRole, "Image"}, |
195 {kInlineTextBoxRole, "InlineTextBox"}, | 195 {kInlineTextBoxRole, "InlineTextBox"}, |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 bool AXObjectImpl::HasInheritedPresentationalRole() const { | 712 bool AXObjectImpl::HasInheritedPresentationalRole() const { |
713 UpdateCachedAttributeValuesIfNeeded(); | 713 UpdateCachedAttributeValuesIfNeeded(); |
714 return cached_has_inherited_presentational_role_; | 714 return cached_has_inherited_presentational_role_; |
715 } | 715 } |
716 | 716 |
717 bool AXObjectImpl::IsPresentationalChild() const { | 717 bool AXObjectImpl::IsPresentationalChild() const { |
718 UpdateCachedAttributeValuesIfNeeded(); | 718 UpdateCachedAttributeValuesIfNeeded(); |
719 return cached_is_presentational_child_; | 719 return cached_is_presentational_child_; |
720 } | 720 } |
721 | 721 |
| 722 bool AXObjectImpl::CanReceiveAccessibilityFocus() const { |
| 723 const Node* node = this->GetNode(); |
| 724 if (!node) |
| 725 return false; |
| 726 |
| 727 const Element* elem = ToElement(node); |
| 728 if (!elem) |
| 729 return false; |
| 730 |
| 731 // Focusable, and not forwarding the focus somewhere else |
| 732 if (elem->IsFocusable() && !elem->FastHasAttribute(aria_activedescendantAttr)) |
| 733 return true; |
| 734 |
| 735 // aria-activedescendant focus |
| 736 return elem->FastHasAttribute(idAttr) && AncestorExposesActiveDescendant(); |
| 737 } |
| 738 |
722 bool AXObjectImpl::AncestorExposesActiveDescendant() const { | 739 bool AXObjectImpl::AncestorExposesActiveDescendant() const { |
723 UpdateCachedAttributeValuesIfNeeded(); | 740 UpdateCachedAttributeValuesIfNeeded(); |
724 return cached_ancestor_exposes_active_descendant_; | 741 return cached_ancestor_exposes_active_descendant_; |
725 } | 742 } |
726 | 743 |
727 bool AXObjectImpl::ComputeAncestorExposesActiveDescendant() const { | 744 bool AXObjectImpl::ComputeAncestorExposesActiveDescendant() const { |
728 const AXObjectImpl* parent = ParentObjectUnignored(); | 745 const AXObjectImpl* parent = ParentObjectUnignored(); |
729 if (!parent) | 746 if (!parent) |
730 return false; | 747 return false; |
731 | 748 |
(...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1796 | 1813 |
1797 Vector<String> role_vector; | 1814 Vector<String> role_vector; |
1798 role.Split(' ', role_vector); | 1815 role.Split(' ', role_vector); |
1799 for (const auto& child : role_vector) { | 1816 for (const auto& child : role_vector) { |
1800 if (role_set->Contains(child)) | 1817 if (role_set->Contains(child)) |
1801 return true; | 1818 return true; |
1802 } | 1819 } |
1803 return false; | 1820 return false; |
1804 } | 1821 } |
1805 | 1822 |
1806 bool AXObjectImpl::NameFromContents() const { | 1823 bool AXObjectImpl::NameFromContents(const bool recursive) const { |
1807 // ARIA 1.1, section 5.2.7.5. | 1824 // ARIA 1.1, section 5.2.7.5. |
| 1825 bool result = false; |
| 1826 |
1808 switch (RoleValue()) { | 1827 switch (RoleValue()) { |
| 1828 // ----- NameFrom: contents ------------------------- |
| 1829 // Get their own name from contents, or contribute to ancestors |
1809 case kAnchorRole: | 1830 case kAnchorRole: |
1810 case kButtonRole: | 1831 case kButtonRole: |
1811 case kCellRole: | 1832 case kCellRole: |
1812 case kCheckBoxRole: | 1833 case kCheckBoxRole: |
1813 case kColumnHeaderRole: | 1834 case kColumnHeaderRole: |
1814 case kDirectoryRole: | |
1815 case kDisclosureTriangleRole: | 1835 case kDisclosureTriangleRole: |
1816 case kHeadingRole: | 1836 case kHeadingRole: |
1817 case kLineBreakRole: | 1837 case kLineBreakRole: |
1818 case kLinkRole: | 1838 case kLinkRole: |
1819 case kListBoxOptionRole: | 1839 case kListBoxOptionRole: |
1820 case kListItemRole: | 1840 case kMenuButtonRole: |
1821 case kMenuItemRole: | 1841 case kMenuItemRole: |
1822 case kMenuItemCheckBoxRole: | 1842 case kMenuItemCheckBoxRole: |
1823 case kMenuItemRadioRole: | 1843 case kMenuItemRadioRole: |
1824 case kMenuListOptionRole: | 1844 case kMenuListOptionRole: |
1825 case kPopUpButtonRole: | 1845 case kPopUpButtonRole: |
1826 case kRadioButtonRole: | 1846 case kRadioButtonRole: |
1827 case kRowHeaderRole: | 1847 case kRowHeaderRole: |
1828 case kStaticTextRole: | 1848 case kStaticTextRole: |
1829 case kStatusRole: | |
1830 case kSwitchRole: | 1849 case kSwitchRole: |
1831 case kTabRole: | 1850 case kTabRole: |
1832 case kToggleButtonRole: | 1851 case kToggleButtonRole: |
1833 case kTreeItemRole: | 1852 case kTreeItemRole: |
1834 case kUserInterfaceTooltipRole: | 1853 case kUserInterfaceTooltipRole: |
1835 return true; | 1854 result = true; |
1836 case kRowRole: { | 1855 break; |
1837 // Spec says we should always expose the name on rows, | 1856 |
1838 // but for performance reasons we only do it | 1857 // ----- No name from contents ------------------------- |
1839 // if the row might receive focus | 1858 // These never have or contribute a name from contents, as they are |
1840 if (AncestorExposesActiveDescendant()) { | 1859 // containers for many subobjects. Superset of nameFrom:author ARIA roles. |
1841 return true; | 1860 case kAlertRole: |
1842 } | 1861 case kAlertDialogRole: |
1843 const Node* node = this->GetNode(); | 1862 case kApplicationRole: |
1844 return node && node->IsElementNode() && ToElement(node)->IsFocusable(); | 1863 case kAudioRole: |
1845 } | 1864 case kArticleRole: |
1846 default: | 1865 case kBannerRole: |
1847 return false; | 1866 case kBlockquoteRole: |
| 1867 case kColorWellRole: |
| 1868 case kColumnRole: |
| 1869 case kComboBoxRole: |
| 1870 case kComplementaryRole: |
| 1871 case kContentInfoRole: |
| 1872 case kDateRole: |
| 1873 case kDateTimeRole: |
| 1874 case kDefinitionRole: |
| 1875 case kDialogRole: |
| 1876 case kDirectoryRole: |
| 1877 case kDocumentRole: |
| 1878 case kEmbeddedObjectRole: |
| 1879 case kFeedRole: |
| 1880 case kFigureRole: |
| 1881 case kFormRole: |
| 1882 case kGridRole: |
| 1883 case kGroupRole: |
| 1884 case kIframePresentationalRole: |
| 1885 case kIframeRole: |
| 1886 case kImageRole: |
| 1887 case kInputTimeRole: |
| 1888 case kListBoxRole: |
| 1889 case kLogRole: |
| 1890 case kMainRole: |
| 1891 case kMarqueeRole: |
| 1892 case kMathRole: |
| 1893 case kMenuListPopupRole: |
| 1894 case kMenuRole: |
| 1895 case kMenuBarRole: |
| 1896 case kMeterRole: |
| 1897 case kNavigationRole: |
| 1898 case kNoteRole: |
| 1899 case kOutlineRole: |
| 1900 case kProgressIndicatorRole: |
| 1901 case kRadioGroupRole: |
| 1902 case kRegionRole: |
| 1903 case kRootWebAreaRole: |
| 1904 case kScrollBarRole: |
| 1905 case kSearchRole: |
| 1906 case kSearchBoxRole: |
| 1907 case kSplitterRole: |
| 1908 case kSliderRole: |
| 1909 case kSpinButtonRole: |
| 1910 case kStatusRole: |
| 1911 case kScrollAreaRole: |
| 1912 case kSeamlessWebAreaRole: |
| 1913 case kSliderThumbRole: |
| 1914 case kSpinButtonPartRole: |
| 1915 case kSVGRootRole: |
| 1916 case kTableRole: |
| 1917 case kTableHeaderContainerRole: |
| 1918 case kTabGroupRole: |
| 1919 case kTabListRole: |
| 1920 case kTabPanelRole: |
| 1921 case kTermRole: |
| 1922 case kTextFieldRole: |
| 1923 case kTimeRole: |
| 1924 case kTimerRole: |
| 1925 case kToolbarRole: |
| 1926 case kTreeRole: |
| 1927 case kTreeGridRole: |
| 1928 case kVideoRole: |
| 1929 case kWebAreaRole: |
| 1930 case kWindowRole: |
| 1931 result = false; |
| 1932 break; |
| 1933 |
| 1934 // ----- Conditional: contribute to ancestor only, unless focusable ------- |
| 1935 // Some objects can contribute their contents to ancestor names, but |
| 1936 // only have their own name if they are focusable |
| 1937 case kAbbrRole: |
| 1938 case kAnnotationRole: |
| 1939 case kBusyIndicatorRole: |
| 1940 case kCanvasRole: |
| 1941 case kCaptionRole: |
| 1942 case kDescriptionListDetailRole: |
| 1943 case kDescriptionListRole: |
| 1944 case kDescriptionListTermRole: |
| 1945 case kDetailsRole: |
| 1946 case kFigcaptionRole: |
| 1947 case kFooterRole: |
| 1948 case kGenericContainerRole: |
| 1949 case kIgnoredRole: |
| 1950 case kImageMapLinkRole: |
| 1951 case kImageMapRole: |
| 1952 case kInlineTextBoxRole: |
| 1953 case kLabelRole: |
| 1954 case kLegendRole: |
| 1955 case kListRole: |
| 1956 case kListItemRole: |
| 1957 case kListMarkerRole: |
| 1958 case kMarkRole: |
| 1959 case kNoneRole: |
| 1960 case kParagraphRole: |
| 1961 case kPreRole: |
| 1962 case kPresentationalRole: |
| 1963 // Spec says we should always expose the name on rows, |
| 1964 // but for performance reasons we only do it |
| 1965 // if the row might receive focus |
| 1966 case kRowRole: |
| 1967 case kRubyRole: |
| 1968 case kRulerRole: |
| 1969 case kUnknownRole: |
| 1970 case kNumRoles: |
| 1971 result = recursive || (CanReceiveAccessibilityFocus() && !IsEditable()); |
| 1972 break; |
1848 } | 1973 } |
| 1974 |
| 1975 return result; |
1849 } | 1976 } |
1850 | 1977 |
1851 AccessibilityRole AXObjectImpl::ButtonRoleType() const { | 1978 AccessibilityRole AXObjectImpl::ButtonRoleType() const { |
1852 // If aria-pressed is present, then it should be exposed as a toggle button. | 1979 // If aria-pressed is present, then it should be exposed as a toggle button. |
1853 // http://www.w3.org/TR/wai-aria/states_and_properties#aria-pressed | 1980 // http://www.w3.org/TR/wai-aria/states_and_properties#aria-pressed |
1854 if (AriaPressedIsPresent()) | 1981 if (AriaPressedIsPresent()) |
1855 return kToggleButtonRole; | 1982 return kToggleButtonRole; |
1856 if (AriaHasPopup()) | 1983 if (AriaHasPopup()) |
1857 return kPopUpButtonRole; | 1984 return kPopUpButtonRole; |
1858 // We don't contemplate RadioButtonRole, as it depends on the input | 1985 // We don't contemplate RadioButtonRole, as it depends on the input |
(...skipping 16 matching lines...) Expand all Loading... |
1875 } | 2002 } |
1876 | 2003 |
1877 DEFINE_TRACE(AXObjectImpl) { | 2004 DEFINE_TRACE(AXObjectImpl) { |
1878 visitor->Trace(children_); | 2005 visitor->Trace(children_); |
1879 visitor->Trace(parent_); | 2006 visitor->Trace(parent_); |
1880 visitor->Trace(cached_live_region_root_); | 2007 visitor->Trace(cached_live_region_root_); |
1881 visitor->Trace(ax_object_cache_); | 2008 visitor->Trace(ax_object_cache_); |
1882 } | 2009 } |
1883 | 2010 |
1884 } // namespace blink | 2011 } // namespace blink |
OLD | NEW |