| 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 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 if (!str.IsEmpty() && IsHTMLSpace<UChar>(str[0])) | 842 if (!str.IsEmpty() && IsHTMLSpace<UChar>(str[0])) |
| 843 result.Append(' '); | 843 result.Append(' '); |
| 844 result.Append(str.SimplifyWhiteSpace(IsHTMLSpace<UChar>)); | 844 result.Append(str.SimplifyWhiteSpace(IsHTMLSpace<UChar>)); |
| 845 if (!str.IsEmpty() && IsHTMLSpace<UChar>(str[str.length() - 1])) | 845 if (!str.IsEmpty() && IsHTMLSpace<UChar>(str[str.length() - 1])) |
| 846 result.Append(' '); | 846 result.Append(' '); |
| 847 return result.ToString(); | 847 return result.ToString(); |
| 848 } | 848 } |
| 849 | 849 |
| 850 String AXObjectImpl::ComputedName() const { | 850 String AXObjectImpl::ComputedName() const { |
| 851 AXNameFrom name_from; | 851 AXNameFrom name_from; |
| 852 AXObjectImpl::AXObjectVector name_objects; | 852 AXObjectImpl::AXObjectImplVector name_objects; |
| 853 return GetName(name_from, &name_objects); | 853 return GetName(name_from, &name_objects); |
| 854 } | 854 } |
| 855 | 855 |
| 856 String AXObjectImpl::GetName(AXNameFrom& name_from, | 856 String AXObjectImpl::GetName(AXNameFrom& name_from, |
| 857 AXObjectImpl::AXObjectVector* name_objects) const { | 857 AXObject::AXObjectVector* name_objects) const { |
| 858 HeapHashSet<Member<const AXObjectImpl>> visited; | 858 HeapHashSet<Member<const AXObject>> visited; |
| 859 AXRelatedObjectVector related_objects; | 859 AXRelatedObjectVector related_objects; |
| 860 String text = TextAlternative(false, false, visited, name_from, | 860 String text = TextAlternative(false, false, visited, name_from, |
| 861 &related_objects, nullptr); | 861 &related_objects, nullptr); |
| 862 | 862 |
| 863 AccessibilityRole role = RoleValue(); | 863 AccessibilityRole role = RoleValue(); |
| 864 if (!GetNode() || (!isHTMLBRElement(GetNode()) && role != kStaticTextRole && | 864 if (!GetNode() || (!isHTMLBRElement(GetNode()) && role != kStaticTextRole && |
| 865 role != kInlineTextBoxRole)) | 865 role != kInlineTextBoxRole)) |
| 866 text = CollapseWhitespace(text); | 866 text = CollapseWhitespace(text); |
| 867 | 867 |
| 868 if (name_objects) { | 868 if (name_objects) { |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1222 } | 1222 } |
| 1223 return 0; | 1223 return 0; |
| 1224 } | 1224 } |
| 1225 | 1225 |
| 1226 bool AXObjectImpl::IsLiveRegion() const { | 1226 bool AXObjectImpl::IsLiveRegion() const { |
| 1227 const AtomicString& live_region = LiveRegionStatus(); | 1227 const AtomicString& live_region = LiveRegionStatus(); |
| 1228 return EqualIgnoringASCIICase(live_region, "polite") || | 1228 return EqualIgnoringASCIICase(live_region, "polite") || |
| 1229 EqualIgnoringASCIICase(live_region, "assertive"); | 1229 EqualIgnoringASCIICase(live_region, "assertive"); |
| 1230 } | 1230 } |
| 1231 | 1231 |
| 1232 AXObjectImpl* AXObjectImpl::LiveRegionRoot() const { | 1232 AXObject* AXObjectImpl::LiveRegionRoot() const { |
| 1233 UpdateCachedAttributeValuesIfNeeded(); | 1233 UpdateCachedAttributeValuesIfNeeded(); |
| 1234 return cached_live_region_root_; | 1234 return cached_live_region_root_; |
| 1235 } | 1235 } |
| 1236 | 1236 |
| 1237 const AtomicString& AXObjectImpl::ContainerLiveRegionStatus() const { | 1237 const AtomicString& AXObjectImpl::ContainerLiveRegionStatus() const { |
| 1238 UpdateCachedAttributeValuesIfNeeded(); | 1238 UpdateCachedAttributeValuesIfNeeded(); |
| 1239 return cached_live_region_root_ ? cached_live_region_root_->LiveRegionStatus() | 1239 return cached_live_region_root_ ? cached_live_region_root_->LiveRegionStatus() |
| 1240 : g_null_atom; | 1240 : g_null_atom; |
| 1241 } | 1241 } |
| 1242 | 1242 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1263 // Check if there are any mock elements that need to be handled. | 1263 // Check if there are any mock elements that need to be handled. |
| 1264 for (const auto& child : children_) { | 1264 for (const auto& child : children_) { |
| 1265 if (child->IsMockObject() && | 1265 if (child->IsMockObject() && |
| 1266 child->GetBoundsInFrameCoordinates().Contains(point)) | 1266 child->GetBoundsInFrameCoordinates().Contains(point)) |
| 1267 return child->ElementAccessibilityHitTest(point); | 1267 return child->ElementAccessibilityHitTest(point); |
| 1268 } | 1268 } |
| 1269 | 1269 |
| 1270 return const_cast<AXObjectImpl*>(this); | 1270 return const_cast<AXObjectImpl*>(this); |
| 1271 } | 1271 } |
| 1272 | 1272 |
| 1273 const AXObjectImpl::AXObjectVector& AXObjectImpl::Children() { | 1273 const AXObjectImpl::AXObjectImplVector& AXObjectImpl::Children() { |
| 1274 UpdateChildrenIfNecessary(); | 1274 UpdateChildrenIfNecessary(); |
| 1275 | 1275 |
| 1276 return children_; | 1276 return children_; |
| 1277 } | 1277 } |
| 1278 | 1278 |
| 1279 AXObjectImpl* AXObjectImpl::ParentObject() const { | 1279 AXObjectImpl* AXObjectImpl::ParentObject() const { |
| 1280 if (IsDetached()) | 1280 if (IsDetached()) |
| 1281 return 0; | 1281 return 0; |
| 1282 | 1282 |
| 1283 if (parent_) | 1283 if (parent_) |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1446 ScrollableArea* area = GetScrollableAreaIfScrollable(); | 1446 ScrollableArea* area = GetScrollableAreaIfScrollable(); |
| 1447 if (!area) | 1447 if (!area) |
| 1448 return; | 1448 return; |
| 1449 | 1449 |
| 1450 // TODO(bokan): This should potentially be a UserScroll. | 1450 // TODO(bokan): This should potentially be a UserScroll. |
| 1451 area->SetScrollOffset(ScrollOffset(offset.X(), offset.Y()), | 1451 area->SetScrollOffset(ScrollOffset(offset.X(), offset.Y()), |
| 1452 kProgrammaticScroll); | 1452 kProgrammaticScroll); |
| 1453 } | 1453 } |
| 1454 | 1454 |
| 1455 void AXObjectImpl::GetRelativeBounds( | 1455 void AXObjectImpl::GetRelativeBounds( |
| 1456 AXObjectImpl** out_container, | 1456 AXObject** out_container, |
| 1457 FloatRect& out_bounds_in_container, | 1457 FloatRect& out_bounds_in_container, |
| 1458 SkMatrix44& out_container_transform) const { | 1458 SkMatrix44& out_container_transform) const { |
| 1459 *out_container = nullptr; | 1459 *out_container = nullptr; |
| 1460 out_bounds_in_container = FloatRect(); | 1460 out_bounds_in_container = FloatRect(); |
| 1461 out_container_transform.setIdentity(); | 1461 out_container_transform.setIdentity(); |
| 1462 | 1462 |
| 1463 // First check if it has explicit bounds, for example if this element is tied | 1463 // First check if it has explicit bounds, for example if this element is tied |
| 1464 // to a canvas path. When explicit coordinates are provided, the ID of the | 1464 // to a canvas path. When explicit coordinates are provided, the ID of the |
| 1465 // explicit container element that the coordinates are relative to must be | 1465 // explicit container element that the coordinates are relative to must be |
| 1466 // provided too. | 1466 // provided too. |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1845 previous_position = current_position; | 1845 previous_position = current_position; |
| 1846 current_position = PreviousLinePosition(current_position, LayoutUnit(), | 1846 current_position = PreviousLinePosition(current_position, LayoutUnit(), |
| 1847 kHasEditableAXRole); | 1847 kHasEditableAXRole); |
| 1848 ++line_count; | 1848 ++line_count; |
| 1849 } while (current_position.IsNotNull() && | 1849 } while (current_position.IsNotNull() && |
| 1850 !InSameLine(current_position, previous_position)); | 1850 !InSameLine(current_position, previous_position)); |
| 1851 | 1851 |
| 1852 return line_count; | 1852 return line_count; |
| 1853 } | 1853 } |
| 1854 | 1854 |
| 1855 int AXObjectImpl::AriaColumnCount() const { |
| 1856 if (IsDetached()) |
| 1857 return 0; |
| 1858 |
| 1859 if (!IsAXTable()) |
| 1860 return 0; |
| 1861 |
| 1862 return ToAXTable(this)->AriaColumnCount(); |
| 1863 } |
| 1864 |
| 1865 unsigned AXObjectImpl::AriaColumnIndex() const { |
| 1866 if (IsDetached()) |
| 1867 return 0; |
| 1868 |
| 1869 if (!IsTableCell()) |
| 1870 return 0; |
| 1871 |
| 1872 return ToAXTableCell(this)->AriaColumnIndex(); |
| 1873 } |
| 1874 |
| 1875 int AXObjectImpl::AriaRowCount() const { |
| 1876 if (IsDetached()) |
| 1877 return 0; |
| 1878 |
| 1879 if (!IsAXTable()) |
| 1880 return 0; |
| 1881 |
| 1882 return ToAXTable(this)->AriaRowCount(); |
| 1883 } |
| 1884 |
| 1885 unsigned AXObjectImpl::AriaRowIndex() const { |
| 1886 if (IsDetached()) |
| 1887 return 0; |
| 1888 |
| 1889 if (IsTableCell()) |
| 1890 return ToAXTableCell(this)->AriaRowIndex(); |
| 1891 |
| 1892 if (IsTableRow()) |
| 1893 return ToAXTableRow(this)->AriaRowIndex(); |
| 1894 |
| 1895 return 0; |
| 1896 } |
| 1897 |
| 1898 unsigned AXObjectImpl::ColumnCount() const { |
| 1899 if (IsDetached()) |
| 1900 return false; |
| 1901 |
| 1902 if (!IsAXTable()) |
| 1903 return 0; |
| 1904 |
| 1905 return ToAXTable(this)->ColumnCount(); |
| 1906 } |
| 1907 |
| 1908 unsigned AXObjectImpl::RowCount() const { |
| 1909 if (IsDetached()) |
| 1910 return 0; |
| 1911 |
| 1912 if (!IsAXTable()) |
| 1913 return 0; |
| 1914 |
| 1915 return ToAXTable(this)->RowCount(); |
| 1916 } |
| 1917 |
| 1918 WebAXObject AXObjectImpl::CellForColumnAndRow(unsigned column, |
| 1919 unsigned row) const { |
| 1920 if (IsDetached()) |
| 1921 return WebAXObject(); |
| 1922 |
| 1923 if (!IsAXTable()) |
| 1924 return WebAXObject(); |
| 1925 |
| 1926 AXTableCell* cell = ToAXTable(this)->CellForColumnAndRow(column, row); |
| 1927 return WebAXObject(static_cast<AXObjectImpl*>(cell)); |
| 1928 } |
| 1929 |
| 1930 WebAXObject AXObjectImpl::HeaderContainerObject() const { |
| 1931 if (IsDetached()) |
| 1932 return WebAXObject(); |
| 1933 |
| 1934 if (!IsAXTable()) |
| 1935 return WebAXObject(); |
| 1936 |
| 1937 return WebAXObject(ToAXTable(this)->HeaderContainer()); |
| 1938 } |
| 1939 |
| 1940 WebAXObject AXObjectImpl::RowAtIndex(unsigned row_index) const { |
| 1941 if (IsDetached()) |
| 1942 return WebAXObject(); |
| 1943 |
| 1944 if (!IsAXTable()) |
| 1945 return WebAXObject(); |
| 1946 |
| 1947 const AXObject::AXObjectVector& rows = ToAXTable(this)->Rows(); |
| 1948 if (row_index < rows.size()) |
| 1949 return WebAXObject(rows[row_index]); |
| 1950 |
| 1951 return WebAXObject(); |
| 1952 } |
| 1953 |
| 1954 WebAXObject AXObjectImpl::ColumnAtIndex(unsigned column_index) const { |
| 1955 if (IsDetached()) |
| 1956 return WebAXObject(); |
| 1957 |
| 1958 if (!IsAXTable()) |
| 1959 return WebAXObject(); |
| 1960 |
| 1961 const AXObject::AXObjectVector& columns = ToAXTable(this)->Columns(); |
| 1962 if (column_index < columns.size()) |
| 1963 return WebAXObject(columns[column_index]); |
| 1964 |
| 1965 return WebAXObject(); |
| 1966 } |
| 1967 |
| 1968 unsigned AXObjectImpl::RowIndex() const { |
| 1969 if (IsDetached()) |
| 1970 return 0; |
| 1971 |
| 1972 if (!IsTableRow()) |
| 1973 return 0; |
| 1974 |
| 1975 return ToAXTableRow(this)->RowIndex(); |
| 1976 } |
| 1977 |
| 1978 WebAXObject AXObjectImpl::RowHeader() const { |
| 1979 if (IsDetached()) |
| 1980 return WebAXObject(); |
| 1981 |
| 1982 if (!IsTableRow()) |
| 1983 return WebAXObject(); |
| 1984 |
| 1985 return WebAXObject(ToAXTableRow(this)->HeaderObject()); |
| 1986 } |
| 1987 |
| 1988 void AXObjectImpl::RowHeaders( |
| 1989 WebVector<WebAXObject>& row_header_elements) const { |
| 1990 if (IsDetached()) |
| 1991 return; |
| 1992 |
| 1993 if (!IsAXTable()) |
| 1994 return; |
| 1995 |
| 1996 AXObject::AXObjectVector headers; |
| 1997 ToAXTable(this)->RowHeaders(headers); |
| 1998 |
| 1999 size_t header_count = headers.size(); |
| 2000 WebVector<WebAXObject> result(header_count); |
| 2001 |
| 2002 for (size_t i = 0; i < header_count; i++) |
| 2003 result[i] = WebAXObject(headers[i]); |
| 2004 |
| 2005 row_header_elements.Swap(result); |
| 2006 } |
| 2007 |
| 2008 unsigned AXObjectImpl::ColumnIndex() const { |
| 2009 if (IsDetached()) |
| 2010 return 0; |
| 2011 |
| 2012 if (RoleValue() != kColumnRole) |
| 2013 return 0; |
| 2014 |
| 2015 return ToAXTableColumn(this)->ColumnIndex(); |
| 2016 } |
| 2017 |
| 2018 WebAXObject AXObjectImpl::ColumnHeader() const { |
| 2019 if (IsDetached()) |
| 2020 return WebAXObject(); |
| 2021 |
| 2022 if (RoleValue() != kColumnRole) |
| 2023 return WebAXObject(); |
| 2024 |
| 2025 return WebAXObject(ToAXTableColumn(this)->HeaderObject()); |
| 2026 } |
| 2027 |
| 2028 void AXObjectImpl::ColumnHeaders( |
| 2029 WebVector<WebAXObject>& column_header_elements) const { |
| 2030 if (IsDetached()) |
| 2031 return; |
| 2032 |
| 2033 if (!IsAXTable()) |
| 2034 return; |
| 2035 |
| 2036 AXObject::AXObjectVector headers; |
| 2037 ToAXTable(this)->ColumnHeaders(headers); |
| 2038 |
| 2039 size_t header_count = headers.size(); |
| 2040 WebVector<WebAXObject> result(header_count); |
| 2041 |
| 2042 for (size_t i = 0; i < header_count; i++) |
| 2043 result[i] = WebAXObject(headers[i]); |
| 2044 |
| 2045 column_header_elements.Swap(result); |
| 2046 } |
| 2047 |
| 2048 unsigned AXObjectImpl::CellColumnIndex() const { |
| 2049 if (IsDetached()) |
| 2050 return 0; |
| 2051 |
| 2052 if (!IsTableCell()) |
| 2053 return 0; |
| 2054 |
| 2055 std::pair<unsigned, unsigned> column_range; |
| 2056 ToAXTableCell(this)->ColumnIndexRange(column_range); |
| 2057 return column_range.first; |
| 2058 } |
| 2059 |
| 2060 unsigned AXObjectImpl::CellColumnSpan() const { |
| 2061 if (IsDetached()) |
| 2062 return 0; |
| 2063 |
| 2064 if (!IsTableCell()) |
| 2065 return 0; |
| 2066 |
| 2067 std::pair<unsigned, unsigned> column_range; |
| 2068 ToAXTableCell(this)->ColumnIndexRange(column_range); |
| 2069 return column_range.second; |
| 2070 } |
| 2071 |
| 2072 unsigned AXObjectImpl::CellRowIndex() const { |
| 2073 if (IsDetached()) |
| 2074 return 0; |
| 2075 |
| 2076 if (!IsTableCell()) |
| 2077 return 0; |
| 2078 |
| 2079 std::pair<unsigned, unsigned> row_range; |
| 2080 ToAXTableCell(this)->RowIndexRange(row_range); |
| 2081 return row_range.first; |
| 2082 } |
| 2083 |
| 2084 unsigned AXObjectImpl::CellRowSpan() const { |
| 2085 if (IsDetached()) |
| 2086 return 0; |
| 2087 |
| 2088 if (!IsTableCell()) |
| 2089 return 0; |
| 2090 |
| 2091 std::pair<unsigned, unsigned> row_range; |
| 2092 ToAXTableCell(this)->RowIndexRange(row_range); |
| 2093 return row_range.second; |
| 2094 } |
| 2095 |
| 2096 WebAXSortDirection AXObjectImpl::SortDirection() const { |
| 2097 if (IsDetached()) |
| 2098 return kWebAXSortDirectionUndefined; |
| 2099 |
| 2100 return static_cast<WebAXSortDirection>(GetSortDirection()); |
| 2101 } |
| 2102 |
| 1855 bool AXObjectImpl::IsARIAControl(AccessibilityRole aria_role) { | 2103 bool AXObjectImpl::IsARIAControl(AccessibilityRole aria_role) { |
| 1856 return IsARIAInput(aria_role) || aria_role == kButtonRole || | 2104 return IsARIAInput(aria_role) || aria_role == kButtonRole || |
| 1857 aria_role == kComboBoxRole || aria_role == kSliderRole; | 2105 aria_role == kComboBoxRole || aria_role == kSliderRole; |
| 1858 } | 2106 } |
| 1859 | 2107 |
| 1860 bool AXObjectImpl::IsARIAInput(AccessibilityRole aria_role) { | 2108 bool AXObjectImpl::IsARIAInput(AccessibilityRole aria_role) { |
| 1861 return aria_role == kRadioButtonRole || aria_role == kCheckBoxRole || | 2109 return aria_role == kRadioButtonRole || aria_role == kCheckBoxRole || |
| 1862 aria_role == kTextFieldRole || aria_role == kSwitchRole || | 2110 aria_role == kTextFieldRole || aria_role == kSwitchRole || |
| 1863 aria_role == kSearchBoxRole; | 2111 aria_role == kSearchBoxRole; |
| 1864 } | 2112 } |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2066 } | 2314 } |
| 2067 | 2315 |
| 2068 DEFINE_TRACE(AXObjectImpl) { | 2316 DEFINE_TRACE(AXObjectImpl) { |
| 2069 visitor->Trace(children_); | 2317 visitor->Trace(children_); |
| 2070 visitor->Trace(parent_); | 2318 visitor->Trace(parent_); |
| 2071 visitor->Trace(cached_live_region_root_); | 2319 visitor->Trace(cached_live_region_root_); |
| 2072 visitor->Trace(ax_object_cache_); | 2320 visitor->Trace(ax_object_cache_); |
| 2073 } | 2321 } |
| 2074 | 2322 |
| 2075 } // namespace blink | 2323 } // namespace blink |
| OLD | NEW |