OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/accessibility/browser_accessibility_win.h" | 5 #include "content/browser/accessibility/browser_accessibility_win.h" |
6 | 6 |
7 #include <UIAutomationClient.h> | 7 #include <UIAutomationClient.h> |
8 #include <UIAutomationCoreApi.h> | 8 #include <UIAutomationCoreApi.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
819 return S_FALSE; | 819 return S_FALSE; |
820 | 820 |
821 for (long i = 0; i < count; ++i) { | 821 for (long i = 0; i < count; ++i) { |
822 relations_[i]->AddRef(); | 822 relations_[i]->AddRef(); |
823 relations[i] = relations_[i]; | 823 relations[i] = relations_[i]; |
824 } | 824 } |
825 | 825 |
826 return S_OK; | 826 return S_OK; |
827 } | 827 } |
828 | 828 |
829 STDMETHODIMP BrowserAccessibilityWin::scrollTo(enum IA2ScrollType scroll_type) { | 829 STDMETHODIMP BrowserAccessibilityWin::scrollTo(IA2ScrollType scroll_type) { |
830 if (!instance_active()) | 830 if (!instance_active()) |
831 return E_FAIL; | 831 return E_FAIL; |
832 | 832 |
833 gfx::Rect r = GetLocation(); | 833 gfx::Rect r = GetLocation(); |
834 switch(scroll_type) { | 834 switch(scroll_type) { |
835 case IA2_SCROLL_TYPE_TOP_LEFT: | 835 case IA2_SCROLL_TYPE_TOP_LEFT: |
836 manager()->ScrollToMakeVisible(*this, gfx::Rect(r.x(), r.y(), 0, 0)); | 836 manager()->ScrollToMakeVisible(*this, gfx::Rect(r.x(), r.y(), 0, 0)); |
837 break; | 837 break; |
838 case IA2_SCROLL_TYPE_BOTTOM_RIGHT: | 838 case IA2_SCROLL_TYPE_BOTTOM_RIGHT: |
839 manager()->ScrollToMakeVisible( | 839 manager()->ScrollToMakeVisible( |
(...skipping 20 matching lines...) Expand all Loading... | |
860 manager()->ScrollToMakeVisible(*this, r); | 860 manager()->ScrollToMakeVisible(*this, r); |
861 break; | 861 break; |
862 } | 862 } |
863 | 863 |
864 manager()->ToBrowserAccessibilityManagerWin()->TrackScrollingObject(this); | 864 manager()->ToBrowserAccessibilityManagerWin()->TrackScrollingObject(this); |
865 | 865 |
866 return S_OK; | 866 return S_OK; |
867 } | 867 } |
868 | 868 |
869 STDMETHODIMP BrowserAccessibilityWin::scrollToPoint( | 869 STDMETHODIMP BrowserAccessibilityWin::scrollToPoint( |
870 enum IA2CoordinateType coordinate_type, | 870 IA2CoordinateType coordinate_type, |
871 LONG x, | 871 LONG x, |
872 LONG y) { | 872 LONG y) { |
873 if (!instance_active()) | 873 if (!instance_active()) |
874 return E_FAIL; | 874 return E_FAIL; |
875 | 875 |
876 gfx::Point scroll_to(x, y); | 876 gfx::Point scroll_to(x, y); |
877 | 877 |
878 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { | 878 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { |
879 scroll_to -= manager()->GetViewBounds().OffsetFromOrigin(); | 879 scroll_to -= manager()->GetViewBounds().OffsetFromOrigin(); |
880 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { | 880 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
948 // global, and doesn't depend on any local state. | 948 // global, and doesn't depend on any local state. |
949 | 949 |
950 if (!app_name) | 950 if (!app_name) |
951 return E_INVALIDARG; | 951 return E_INVALIDARG; |
952 | 952 |
953 // GetProduct() returns a string like "Chrome/aa.bb.cc.dd", split out | 953 // GetProduct() returns a string like "Chrome/aa.bb.cc.dd", split out |
954 // the part before the "/". | 954 // the part before the "/". |
955 std::vector<std::string> product_components = base::SplitString( | 955 std::vector<std::string> product_components = base::SplitString( |
956 GetContentClient()->GetProduct(), "/", | 956 GetContentClient()->GetProduct(), "/", |
957 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 957 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
958 DCHECK_EQ(2U, product_components.size()); | 958 // DCHECK_EQ(2U, product_components.size()); |
dmazzoni
2016/01/20 01:10:43
Remove this? Where did this fail, can you fix it i
| |
959 if (product_components.size() != 2) | 959 if (product_components.size() != 2) |
960 return E_FAIL; | 960 return E_FAIL; |
961 *app_name = SysAllocString(base::UTF8ToUTF16(product_components[0]).c_str()); | 961 *app_name = SysAllocString(base::UTF8ToUTF16(product_components[0]).c_str()); |
962 DCHECK(*app_name); | 962 DCHECK(*app_name); |
963 return *app_name ? S_OK : E_FAIL; | 963 return *app_name ? S_OK : E_FAIL; |
964 } | 964 } |
965 | 965 |
966 STDMETHODIMP BrowserAccessibilityWin::get_appVersion(BSTR* app_version) { | 966 STDMETHODIMP BrowserAccessibilityWin::get_appVersion(BSTR* app_version) { |
967 // No need to check |instance_active()| because this interface is | 967 // No need to check |instance_active()| because this interface is |
968 // global, and doesn't depend on any local state. | 968 // global, and doesn't depend on any local state. |
969 | 969 |
970 if (!app_version) | 970 if (!app_version) |
971 return E_INVALIDARG; | 971 return E_INVALIDARG; |
972 | 972 |
973 // GetProduct() returns a string like "Chrome/aa.bb.cc.dd", split out | 973 // GetProduct() returns a string like "Chrome/aa.bb.cc.dd", split out |
974 // the part after the "/". | 974 // the part after the "/". |
975 std::vector<std::string> product_components = base::SplitString( | 975 std::vector<std::string> product_components = base::SplitString( |
976 GetContentClient()->GetProduct(), "/", | 976 GetContentClient()->GetProduct(), "/", |
977 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 977 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
978 DCHECK_EQ(2U, product_components.size()); | 978 // DCHECK_EQ(2U, product_components.size()); |
979 if (product_components.size() != 2) | 979 if (product_components.size() != 2) |
980 return E_FAIL; | 980 return E_FAIL; |
981 *app_version = | 981 *app_version = |
982 SysAllocString(base::UTF8ToUTF16(product_components[1]).c_str()); | 982 SysAllocString(base::UTF8ToUTF16(product_components[1]).c_str()); |
983 DCHECK(*app_version); | 983 DCHECK(*app_version); |
984 return *app_version ? S_OK : E_FAIL; | 984 return *app_version ? S_OK : E_FAIL; |
985 } | 985 } |
986 | 986 |
987 STDMETHODIMP BrowserAccessibilityWin::get_toolkitName(BSTR* toolkit_name) { | 987 STDMETHODIMP BrowserAccessibilityWin::get_toolkitName(BSTR* toolkit_name) { |
988 // No need to check |instance_active()| because this interface is | 988 // No need to check |instance_active()| because this interface is |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1027 if (description().empty()) | 1027 if (description().empty()) |
1028 return S_FALSE; | 1028 return S_FALSE; |
1029 | 1029 |
1030 *desc = SysAllocString(description().c_str()); | 1030 *desc = SysAllocString(description().c_str()); |
1031 | 1031 |
1032 DCHECK(*desc); | 1032 DCHECK(*desc); |
1033 return S_OK; | 1033 return S_OK; |
1034 } | 1034 } |
1035 | 1035 |
1036 STDMETHODIMP BrowserAccessibilityWin::get_imagePosition( | 1036 STDMETHODIMP BrowserAccessibilityWin::get_imagePosition( |
1037 enum IA2CoordinateType coordinate_type, | 1037 IA2CoordinateType coordinate_type, |
1038 LONG* x, | 1038 LONG* x, |
1039 LONG* y) { | 1039 LONG* y) { |
1040 if (!instance_active()) | 1040 if (!instance_active()) |
1041 return E_FAIL; | 1041 return E_FAIL; |
1042 | 1042 |
1043 if (!x || !y) | 1043 if (!x || !y) |
1044 return E_INVALIDARG; | 1044 return E_INVALIDARG; |
1045 | 1045 |
1046 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { | 1046 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { |
1047 HWND parent_hwnd = | 1047 HWND parent_hwnd = |
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1971 // IAccessibleText methods. | 1971 // IAccessibleText methods. |
1972 // | 1972 // |
1973 | 1973 |
1974 STDMETHODIMP BrowserAccessibilityWin::get_nCharacters(LONG* n_characters) { | 1974 STDMETHODIMP BrowserAccessibilityWin::get_nCharacters(LONG* n_characters) { |
1975 if (!instance_active()) | 1975 if (!instance_active()) |
1976 return E_FAIL; | 1976 return E_FAIL; |
1977 | 1977 |
1978 if (!n_characters) | 1978 if (!n_characters) |
1979 return E_INVALIDARG; | 1979 return E_INVALIDARG; |
1980 | 1980 |
1981 *n_characters = hypertext().length(); | 1981 *n_characters = static_cast<LONG>(GetText().size()); |
1982 return S_OK; | 1982 return S_OK; |
1983 } | 1983 } |
1984 | 1984 |
1985 STDMETHODIMP BrowserAccessibilityWin::get_caretOffset(LONG* offset) { | 1985 STDMETHODIMP BrowserAccessibilityWin::get_caretOffset(LONG* offset) { |
1986 if (!instance_active()) | 1986 if (!instance_active()) |
1987 return E_FAIL; | 1987 return E_FAIL; |
1988 | 1988 |
1989 if (!offset) | 1989 if (!offset) |
1990 return E_INVALIDARG; | 1990 return E_INVALIDARG; |
1991 | 1991 |
1992 if (!HasCaret()) | 1992 if (!HasCaret()) |
1993 return S_FALSE; | 1993 return S_FALSE; |
1994 | 1994 |
1995 int selection_start, selection_end; | 1995 int selection_start, selection_end; |
1996 GetSelectionOffsets(&selection_start, &selection_end); | 1996 GetSelectionOffsets(&selection_start, &selection_end); |
1997 // The caret is always at the end of the selection. | 1997 // The caret is always at the end of the selection. |
1998 *offset = selection_end; | 1998 *offset = selection_end; |
1999 if (*offset < 0) | 1999 if (*offset < 0) |
2000 return S_FALSE; | 2000 return S_FALSE; |
2001 | 2001 |
2002 return S_OK; | 2002 return S_OK; |
2003 } | 2003 } |
2004 | 2004 |
2005 STDMETHODIMP BrowserAccessibilityWin::get_characterExtents( | 2005 STDMETHODIMP BrowserAccessibilityWin::get_characterExtents( |
2006 LONG offset, | 2006 LONG offset, |
2007 enum IA2CoordinateType coordinate_type, | 2007 IA2CoordinateType coordinate_type, |
2008 LONG* out_x, | 2008 LONG* out_x, |
2009 LONG* out_y, | 2009 LONG* out_y, |
2010 LONG* out_width, | 2010 LONG* out_width, |
2011 LONG* out_height) { | 2011 LONG* out_height) { |
2012 if (!instance_active()) | 2012 if (!instance_active()) |
2013 return E_FAIL; | 2013 return E_FAIL; |
2014 | 2014 |
2015 if (!out_x || !out_y || !out_width || !out_height) | 2015 if (!out_x || !out_y || !out_width || !out_height) |
2016 return E_INVALIDARG; | 2016 return E_INVALIDARG; |
2017 | 2017 |
2018 const base::string16& text_str = hypertext(); | 2018 const base::string16& text_str = GetText(); |
2019 HandleSpecialTextOffset(text_str, &offset); | 2019 HandleSpecialTextOffset(text_str, &offset); |
2020 | 2020 |
2021 if (offset < 0 || offset > static_cast<LONG>(text_str.size())) | 2021 if (offset < 0 || offset > static_cast<LONG>(text_str.size())) |
2022 return E_INVALIDARG; | 2022 return E_INVALIDARG; |
2023 | 2023 |
2024 gfx::Rect character_bounds; | 2024 gfx::Rect character_bounds; |
2025 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { | 2025 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { |
2026 character_bounds = GetGlobalBoundsForRange(offset, 1); | 2026 character_bounds = GetGlobalBoundsForRange(offset, 1); |
2027 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { | 2027 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { |
2028 character_bounds = GetLocalBoundsForRange(offset, 1); | 2028 character_bounds = GetLocalBoundsForRange(offset, 1); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2091 | 2091 |
2092 STDMETHODIMP BrowserAccessibilityWin::get_text(LONG start_offset, | 2092 STDMETHODIMP BrowserAccessibilityWin::get_text(LONG start_offset, |
2093 LONG end_offset, | 2093 LONG end_offset, |
2094 BSTR* text) { | 2094 BSTR* text) { |
2095 if (!instance_active()) | 2095 if (!instance_active()) |
2096 return E_FAIL; | 2096 return E_FAIL; |
2097 | 2097 |
2098 if (!text) | 2098 if (!text) |
2099 return E_INVALIDARG; | 2099 return E_INVALIDARG; |
2100 | 2100 |
2101 const base::string16& text_str = hypertext(); | 2101 const base::string16& text_str = GetText(); |
2102 | |
2103 // Handle special text offsets. | |
2104 HandleSpecialTextOffset(text_str, &start_offset); | 2102 HandleSpecialTextOffset(text_str, &start_offset); |
2105 HandleSpecialTextOffset(text_str, &end_offset); | 2103 HandleSpecialTextOffset(text_str, &end_offset); |
2106 | 2104 |
2107 // The spec allows the arguments to be reversed. | 2105 // The spec allows the arguments to be reversed. |
2108 if (start_offset > end_offset) { | 2106 if (start_offset > end_offset) { |
2109 LONG tmp = start_offset; | 2107 LONG tmp = start_offset; |
2110 start_offset = end_offset; | 2108 start_offset = end_offset; |
2111 end_offset = tmp; | 2109 end_offset = tmp; |
2112 } | 2110 } |
2113 | 2111 |
(...skipping 11 matching lines...) Expand all Loading... | |
2125 if (substr.empty()) | 2123 if (substr.empty()) |
2126 return S_FALSE; | 2124 return S_FALSE; |
2127 | 2125 |
2128 *text = SysAllocString(substr.c_str()); | 2126 *text = SysAllocString(substr.c_str()); |
2129 DCHECK(*text); | 2127 DCHECK(*text); |
2130 return S_OK; | 2128 return S_OK; |
2131 } | 2129 } |
2132 | 2130 |
2133 STDMETHODIMP BrowserAccessibilityWin::get_textAtOffset( | 2131 STDMETHODIMP BrowserAccessibilityWin::get_textAtOffset( |
2134 LONG offset, | 2132 LONG offset, |
2135 enum IA2TextBoundaryType boundary_type, | 2133 IA2TextBoundaryType boundary_type, |
2136 LONG* start_offset, | 2134 LONG* start_offset, |
2137 LONG* end_offset, | 2135 LONG* end_offset, |
2138 BSTR* text) { | 2136 BSTR* text) { |
2139 if (!instance_active()) | 2137 if (!instance_active()) |
2140 return E_FAIL; | 2138 return E_FAIL; |
2141 | 2139 |
2142 if (!start_offset || !end_offset || !text) | 2140 if (!start_offset || !end_offset || !text) |
2143 return E_INVALIDARG; | 2141 return E_INVALIDARG; |
2144 | 2142 |
2145 const base::string16& text_str = hypertext(); | 2143 const base::string16& text_str = GetText(); |
2146 HandleSpecialTextOffset(text_str, &offset); | 2144 HandleSpecialTextOffset(text_str, &offset); |
2147 if (offset < 0) | 2145 if (offset < 0) |
2148 return E_INVALIDARG; | 2146 return E_INVALIDARG; |
2149 | 2147 |
2150 LONG text_len = text_str.length(); | 2148 LONG text_len = text_str.length(); |
2151 if (offset > text_len) | 2149 if (offset > text_len) |
2152 return E_INVALIDARG; | 2150 return E_INVALIDARG; |
2153 | 2151 |
2154 // The IAccessible2 spec says we don't have to implement the "sentence" | 2152 // The IAccessible2 spec says we don't have to implement the "sentence" |
2155 // boundary type, we can just let the screenreader handle it. | 2153 // boundary type, we can just let the screenreader handle it. |
(...skipping 15 matching lines...) Expand all Loading... | |
2171 | 2169 |
2172 *start_offset = FindBoundary( | 2170 *start_offset = FindBoundary( |
2173 text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); | 2171 text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); |
2174 *end_offset = FindBoundary( | 2172 *end_offset = FindBoundary( |
2175 text_str, boundary_type, offset, ui::FORWARDS_DIRECTION); | 2173 text_str, boundary_type, offset, ui::FORWARDS_DIRECTION); |
2176 return get_text(*start_offset, *end_offset, text); | 2174 return get_text(*start_offset, *end_offset, text); |
2177 } | 2175 } |
2178 | 2176 |
2179 STDMETHODIMP BrowserAccessibilityWin::get_textBeforeOffset( | 2177 STDMETHODIMP BrowserAccessibilityWin::get_textBeforeOffset( |
2180 LONG offset, | 2178 LONG offset, |
2181 enum IA2TextBoundaryType boundary_type, | 2179 IA2TextBoundaryType boundary_type, |
2182 LONG* start_offset, | 2180 LONG* start_offset, |
2183 LONG* end_offset, | 2181 LONG* end_offset, |
2184 BSTR* text) { | 2182 BSTR* text) { |
2185 if (!instance_active()) | 2183 if (!instance_active()) |
2186 return E_FAIL; | 2184 return E_FAIL; |
2187 | 2185 |
2188 if (!start_offset || !end_offset || !text) | 2186 if (!start_offset || !end_offset || !text) |
2189 return E_INVALIDARG; | 2187 return E_INVALIDARG; |
2190 | 2188 |
2191 // The IAccessible2 spec says we don't have to implement the "sentence" | 2189 // The IAccessible2 spec says we don't have to implement the "sentence" |
2192 // boundary type, we can just let the screenreader handle it. | 2190 // boundary type, we can just let the screenreader handle it. |
2193 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { | 2191 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { |
2194 *start_offset = 0; | 2192 *start_offset = 0; |
2195 *end_offset = 0; | 2193 *end_offset = 0; |
2196 *text = NULL; | 2194 *text = NULL; |
2197 return S_FALSE; | 2195 return S_FALSE; |
2198 } | 2196 } |
2199 | 2197 |
2200 const base::string16& text_str = hypertext(); | 2198 const base::string16& text_str = GetText(); |
2201 | 2199 |
2202 *start_offset = FindBoundary( | 2200 *start_offset = FindBoundary( |
2203 text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); | 2201 text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); |
2204 *end_offset = offset; | 2202 *end_offset = offset; |
2205 return get_text(*start_offset, *end_offset, text); | 2203 return get_text(*start_offset, *end_offset, text); |
2206 } | 2204 } |
2207 | 2205 |
2208 STDMETHODIMP BrowserAccessibilityWin::get_textAfterOffset( | 2206 STDMETHODIMP BrowserAccessibilityWin::get_textAfterOffset( |
2209 LONG offset, | 2207 LONG offset, |
2210 enum IA2TextBoundaryType boundary_type, | 2208 IA2TextBoundaryType boundary_type, |
2211 LONG* start_offset, | 2209 LONG* start_offset, |
2212 LONG* end_offset, | 2210 LONG* end_offset, |
2213 BSTR* text) { | 2211 BSTR* text) { |
2214 if (!instance_active()) | 2212 if (!instance_active()) |
2215 return E_FAIL; | 2213 return E_FAIL; |
2216 | 2214 |
2217 if (!start_offset || !end_offset || !text) | 2215 if (!start_offset || !end_offset || !text) |
2218 return E_INVALIDARG; | 2216 return E_INVALIDARG; |
2219 | 2217 |
2220 // The IAccessible2 spec says we don't have to implement the "sentence" | 2218 // The IAccessible2 spec says we don't have to implement the "sentence" |
2221 // boundary type, we can just let the screenreader handle it. | 2219 // boundary type, we can just let the screenreader handle it. |
2222 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { | 2220 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { |
2223 *start_offset = 0; | 2221 *start_offset = 0; |
2224 *end_offset = 0; | 2222 *end_offset = 0; |
2225 *text = NULL; | 2223 *text = NULL; |
2226 return S_FALSE; | 2224 return S_FALSE; |
2227 } | 2225 } |
2228 | 2226 |
2229 const base::string16& text_str = hypertext(); | 2227 const base::string16& text_str = GetText(); |
2230 | 2228 |
2231 *start_offset = offset; | 2229 *start_offset = offset; |
2232 *end_offset = FindBoundary( | 2230 *end_offset = FindBoundary( |
2233 text_str, boundary_type, offset, ui::FORWARDS_DIRECTION); | 2231 text_str, boundary_type, offset, ui::FORWARDS_DIRECTION); |
2234 return get_text(*start_offset, *end_offset, text); | 2232 return get_text(*start_offset, *end_offset, text); |
2235 } | 2233 } |
2236 | 2234 |
2237 STDMETHODIMP BrowserAccessibilityWin::get_newText(IA2TextSegment* new_text) { | 2235 STDMETHODIMP BrowserAccessibilityWin::get_newText(IA2TextSegment* new_text) { |
2238 if (!instance_active()) | 2236 if (!instance_active()) |
2239 return E_FAIL; | 2237 return E_FAIL; |
2240 | 2238 |
2241 if (!new_text) | 2239 if (!new_text) |
2242 return E_INVALIDARG; | 2240 return E_INVALIDARG; |
2243 | 2241 |
2244 if (!old_win_attributes_) | 2242 if (!old_win_attributes_) |
2245 return E_FAIL; | 2243 return E_FAIL; |
2246 | 2244 |
2247 int start, old_len, new_len; | 2245 int start, old_len, new_len; |
2248 ComputeHypertextRemovedAndInserted(&start, &old_len, &new_len); | 2246 ComputeHypertextRemovedAndInserted(&start, &old_len, &new_len); |
2249 if (new_len == 0) | 2247 if (new_len == 0) |
2250 return E_FAIL; | 2248 return E_FAIL; |
2251 | 2249 |
2252 base::string16 substr = hypertext().substr(start, new_len); | 2250 base::string16 substr = GetText().substr(start, new_len); |
2253 new_text->text = SysAllocString(substr.c_str()); | 2251 new_text->text = SysAllocString(substr.c_str()); |
2254 new_text->start = static_cast<long>(start); | 2252 new_text->start = static_cast<long>(start); |
2255 new_text->end = static_cast<long>(start + new_len); | 2253 new_text->end = static_cast<long>(start + new_len); |
2256 return S_OK; | 2254 return S_OK; |
2257 } | 2255 } |
2258 | 2256 |
2259 STDMETHODIMP BrowserAccessibilityWin::get_oldText(IA2TextSegment* old_text) { | 2257 STDMETHODIMP BrowserAccessibilityWin::get_oldText(IA2TextSegment* old_text) { |
2260 if (!instance_active()) | 2258 if (!instance_active()) |
2261 return E_FAIL; | 2259 return E_FAIL; |
2262 | 2260 |
(...skipping 12 matching lines...) Expand all Loading... | |
2275 base::string16 substr = old_hypertext.substr(start, old_len); | 2273 base::string16 substr = old_hypertext.substr(start, old_len); |
2276 old_text->text = SysAllocString(substr.c_str()); | 2274 old_text->text = SysAllocString(substr.c_str()); |
2277 old_text->start = static_cast<long>(start); | 2275 old_text->start = static_cast<long>(start); |
2278 old_text->end = static_cast<long>(start + old_len); | 2276 old_text->end = static_cast<long>(start + old_len); |
2279 return S_OK; | 2277 return S_OK; |
2280 } | 2278 } |
2281 | 2279 |
2282 STDMETHODIMP BrowserAccessibilityWin::get_offsetAtPoint( | 2280 STDMETHODIMP BrowserAccessibilityWin::get_offsetAtPoint( |
2283 LONG x, | 2281 LONG x, |
2284 LONG y, | 2282 LONG y, |
2285 enum IA2CoordinateType coord_type, | 2283 IA2CoordinateType coord_type, |
2286 LONG* offset) { | 2284 LONG* offset) { |
2287 if (!instance_active()) | 2285 if (!instance_active()) |
2288 return E_FAIL; | 2286 return E_FAIL; |
2289 | 2287 |
2290 if (!offset) | 2288 if (!offset) |
2291 return E_INVALIDARG; | 2289 return E_INVALIDARG; |
2292 | 2290 |
2293 // TODO(dmazzoni): implement this. We're returning S_OK for now so that | 2291 // TODO(dmazzoni): implement this. We're returning S_OK for now so that |
2294 // screen readers still return partially accurate results rather than | 2292 // screen readers still return partially accurate results rather than |
2295 // completely failing. | 2293 // completely failing. |
2296 *offset = 0; | 2294 *offset = 0; |
2297 return S_OK; | 2295 return S_OK; |
2298 } | 2296 } |
2299 | 2297 |
2300 STDMETHODIMP BrowserAccessibilityWin::scrollSubstringTo( | 2298 STDMETHODIMP BrowserAccessibilityWin::scrollSubstringTo( |
2301 LONG start_index, | 2299 LONG start_index, |
2302 LONG end_index, | 2300 LONG end_index, |
2303 enum IA2ScrollType scroll_type) { | 2301 IA2ScrollType scroll_type) { |
2304 // TODO(dmazzoni): adjust this for the start and end index, too. | 2302 // TODO(dmazzoni): adjust this for the start and end index, too. |
2305 return scrollTo(scroll_type); | 2303 return scrollTo(scroll_type); |
2306 } | 2304 } |
2307 | 2305 |
2308 STDMETHODIMP BrowserAccessibilityWin::scrollSubstringToPoint( | 2306 STDMETHODIMP BrowserAccessibilityWin::scrollSubstringToPoint( |
2309 LONG start_index, | 2307 LONG start_index, |
2310 LONG end_index, | 2308 LONG end_index, |
2311 enum IA2CoordinateType coordinate_type, | 2309 IA2CoordinateType coordinate_type, |
2312 LONG x, LONG y) { | 2310 LONG x, |
2311 LONG y) { | |
2313 // TODO(dmazzoni): adjust this for the start and end index, too. | 2312 // TODO(dmazzoni): adjust this for the start and end index, too. |
2314 return scrollToPoint(coordinate_type, x, y); | 2313 return scrollToPoint(coordinate_type, x, y); |
2315 } | 2314 } |
2316 | 2315 |
2317 STDMETHODIMP BrowserAccessibilityWin::addSelection(LONG start_offset, | 2316 STDMETHODIMP BrowserAccessibilityWin::addSelection(LONG start_offset, |
2318 LONG end_offset) { | 2317 LONG end_offset) { |
2319 if (!instance_active()) | 2318 if (!instance_active()) |
2320 return E_FAIL; | 2319 return E_FAIL; |
2321 | 2320 |
2322 const base::string16& text_str = hypertext(); | 2321 const base::string16& text_str = GetText(); |
2323 HandleSpecialTextOffset(text_str, &start_offset); | 2322 HandleSpecialTextOffset(text_str, &start_offset); |
2324 HandleSpecialTextOffset(text_str, &end_offset); | 2323 HandleSpecialTextOffset(text_str, &end_offset); |
2325 | 2324 |
2326 manager()->SetTextSelection(*this, start_offset, end_offset); | 2325 manager()->SetTextSelection(*this, start_offset, end_offset); |
2327 return S_OK; | 2326 return S_OK; |
2328 } | 2327 } |
2329 | 2328 |
2330 STDMETHODIMP BrowserAccessibilityWin::removeSelection(LONG selection_index) { | 2329 STDMETHODIMP BrowserAccessibilityWin::removeSelection(LONG selection_index) { |
2331 if (!instance_active()) | 2330 if (!instance_active()) |
2332 return E_FAIL; | 2331 return E_FAIL; |
2333 | 2332 |
2334 if (selection_index != 0) | 2333 if (selection_index != 0) |
2335 return E_INVALIDARG; | 2334 return E_INVALIDARG; |
2336 | 2335 |
2337 manager()->SetTextSelection(*this, 0, 0); | 2336 manager()->SetTextSelection(*this, 0, 0); |
2338 return S_OK; | 2337 return S_OK; |
2339 } | 2338 } |
2340 | 2339 |
2341 STDMETHODIMP BrowserAccessibilityWin::setCaretOffset(LONG offset) { | 2340 STDMETHODIMP BrowserAccessibilityWin::setCaretOffset(LONG offset) { |
2342 if (!instance_active()) | 2341 if (!instance_active()) |
2343 return E_FAIL; | 2342 return E_FAIL; |
2344 | 2343 |
2345 const base::string16& text_str = hypertext(); | 2344 const base::string16& text_str = GetText(); |
2346 HandleSpecialTextOffset(text_str, &offset); | 2345 HandleSpecialTextOffset(text_str, &offset); |
2347 manager()->SetTextSelection(*this, offset, offset); | 2346 manager()->SetTextSelection(*this, offset, offset); |
2348 return S_OK; | 2347 return S_OK; |
2349 } | 2348 } |
2350 | 2349 |
2351 STDMETHODIMP BrowserAccessibilityWin::setSelection(LONG selection_index, | 2350 STDMETHODIMP BrowserAccessibilityWin::setSelection(LONG selection_index, |
2352 LONG start_offset, | 2351 LONG start_offset, |
2353 LONG end_offset) { | 2352 LONG end_offset) { |
2354 if (!instance_active()) | 2353 if (!instance_active()) |
2355 return E_FAIL; | 2354 return E_FAIL; |
2356 | 2355 |
2357 if (selection_index != 0) | 2356 if (selection_index != 0) |
2358 return E_INVALIDARG; | 2357 return E_INVALIDARG; |
2359 | 2358 |
2360 const base::string16& text_str = hypertext(); | 2359 const base::string16& text_str = GetText(); |
2361 HandleSpecialTextOffset(text_str, &start_offset); | 2360 HandleSpecialTextOffset(text_str, &start_offset); |
2362 HandleSpecialTextOffset(text_str, &end_offset); | 2361 HandleSpecialTextOffset(text_str, &end_offset); |
2363 | 2362 |
2364 manager()->SetTextSelection(*this, start_offset, end_offset); | 2363 manager()->SetTextSelection(*this, start_offset, end_offset); |
2365 return S_OK; | 2364 return S_OK; |
2366 } | 2365 } |
2367 | 2366 |
2368 // | 2367 // |
2369 // IAccessibleText methods not implemented. | 2368 // IAccessibleText methods not implemented. |
2370 // | 2369 // |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2416 | 2415 |
2417 STDMETHODIMP BrowserAccessibilityWin::get_hyperlinkIndex( | 2416 STDMETHODIMP BrowserAccessibilityWin::get_hyperlinkIndex( |
2418 long char_index, | 2417 long char_index, |
2419 long* hyperlink_index) { | 2418 long* hyperlink_index) { |
2420 if (!instance_active()) | 2419 if (!instance_active()) |
2421 return E_FAIL; | 2420 return E_FAIL; |
2422 | 2421 |
2423 if (!hyperlink_index) | 2422 if (!hyperlink_index) |
2424 return E_INVALIDARG; | 2423 return E_INVALIDARG; |
2425 | 2424 |
2426 if (char_index < 0 || | 2425 if (char_index < 0 || char_index >= static_cast<long>(GetText().size())) { |
2427 char_index >= static_cast<long>(hypertext().size())) { | |
2428 return E_INVALIDARG; | 2426 return E_INVALIDARG; |
2429 } | 2427 } |
2430 | 2428 |
2431 std::map<int32_t, int32_t>::iterator it = | 2429 std::map<int32_t, int32_t>::iterator it = |
2432 hyperlink_offset_to_index().find(char_index); | 2430 hyperlink_offset_to_index().find(char_index); |
2433 if (it == hyperlink_offset_to_index().end()) { | 2431 if (it == hyperlink_offset_to_index().end()) { |
2434 *hyperlink_index = -1; | 2432 *hyperlink_index = -1; |
2435 return S_FALSE; | 2433 return S_FALSE; |
2436 } | 2434 } |
2437 | 2435 |
2438 *hyperlink_index = it->second; | 2436 *hyperlink_index = it->second; |
2439 return S_OK; | 2437 return S_OK; |
2440 } | 2438 } |
2441 | 2439 |
2442 // | 2440 // |
2443 // IAccessibleHyperlink methods. | 2441 // IAccessibleHyperlink methods. |
2444 // | 2442 // |
2445 | 2443 |
2446 // Currently, only text links are supported. | 2444 // Currently, only text links are supported. |
2447 STDMETHODIMP BrowserAccessibilityWin::get_anchor(long index, VARIANT* anchor) { | 2445 STDMETHODIMP BrowserAccessibilityWin::get_anchor(long index, VARIANT* anchor) { |
2448 if (!instance_active() || !IsHyperlink()) | 2446 if (!instance_active() || !IsHyperlink()) |
2449 return E_FAIL; | 2447 return E_FAIL; |
2450 | 2448 |
2451 // IA2 text links can have only one anchor, that is the text inside them. | 2449 // IA2 text links can have only one anchor, that is the text inside them. |
2452 if (index != 0 || !anchor) | 2450 if (index != 0 || !anchor) |
2453 return E_INVALIDARG; | 2451 return E_INVALIDARG; |
2454 | 2452 |
2455 BSTR ia2_hypertext = SysAllocString(hypertext().c_str()); | 2453 BSTR ia2_hypertext = SysAllocString(GetText().c_str()); |
2456 DCHECK(ia2_hypertext); | 2454 DCHECK(ia2_hypertext); |
2457 anchor->vt = VT_BSTR; | 2455 anchor->vt = VT_BSTR; |
2458 anchor->bstrVal = ia2_hypertext; | 2456 anchor->bstrVal = ia2_hypertext; |
2459 | 2457 |
2460 // Returning S_FALSE is not mentioned in the IA2 Spec, but it might have been | 2458 // Returning S_FALSE is not mentioned in the IA2 Spec, but it might have been |
2461 // an oversight. | 2459 // an oversight. |
2462 if (!SysStringLen(ia2_hypertext)) | 2460 if (!SysStringLen(ia2_hypertext)) |
2463 return S_FALSE; | 2461 return S_FALSE; |
2464 | 2462 |
2465 return S_OK; | 2463 return S_OK; |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3027 int* out_x, | 3025 int* out_x, |
3028 int* out_y, | 3026 int* out_y, |
3029 int* out_width, | 3027 int* out_width, |
3030 int* out_height) { | 3028 int* out_height) { |
3031 if (!instance_active()) | 3029 if (!instance_active()) |
3032 return E_FAIL; | 3030 return E_FAIL; |
3033 | 3031 |
3034 if (!out_x || !out_y || !out_width || !out_height) | 3032 if (!out_x || !out_y || !out_width || !out_height) |
3035 return E_INVALIDARG; | 3033 return E_INVALIDARG; |
3036 | 3034 |
3037 const base::string16& text_str = hypertext(); | 3035 unsigned int text_length = static_cast<unsigned int>(GetText().size()); |
3038 if (start_index > text_str.size() || | 3036 if (start_index > text_length || end_index > text_length || |
3039 end_index > text_str.size() || | |
3040 start_index > end_index) { | 3037 start_index > end_index) { |
3041 return E_INVALIDARG; | 3038 return E_INVALIDARG; |
3042 } | 3039 } |
3043 | 3040 |
3044 gfx::Rect bounds = GetGlobalBoundsForRange( | 3041 gfx::Rect bounds = GetGlobalBoundsForRange( |
3045 start_index, end_index - start_index); | 3042 start_index, end_index - start_index); |
3046 *out_x = bounds.x(); | 3043 *out_x = bounds.x(); |
3047 *out_y = bounds.y(); | 3044 *out_y = bounds.y(); |
3048 *out_width = bounds.width(); | 3045 *out_width = bounds.width(); |
3049 *out_height = bounds.height(); | 3046 *out_height = bounds.height(); |
3050 return S_OK; | 3047 return S_OK; |
3051 } | 3048 } |
3052 | 3049 |
3053 STDMETHODIMP BrowserAccessibilityWin::scrollToSubstring( | 3050 STDMETHODIMP BrowserAccessibilityWin::scrollToSubstring( |
3054 unsigned int start_index, | 3051 unsigned int start_index, |
3055 unsigned int end_index) { | 3052 unsigned int end_index) { |
3056 if (!instance_active()) | 3053 if (!instance_active()) |
3057 return E_FAIL; | 3054 return E_FAIL; |
3058 | 3055 |
3059 const base::string16& text_str = hypertext(); | 3056 unsigned int text_length = static_cast<unsigned int>(GetText().size()); |
3060 if (start_index > text_str.size() || | 3057 if (start_index > text_length || end_index > text_length || |
3061 end_index > text_str.size() || | |
3062 start_index > end_index) { | 3058 start_index > end_index) { |
3063 return E_INVALIDARG; | 3059 return E_INVALIDARG; |
3064 } | 3060 } |
3065 | 3061 |
3066 manager()->ScrollToMakeVisible(*this, GetLocalBoundsForRange( | 3062 manager()->ScrollToMakeVisible(*this, GetLocalBoundsForRange( |
3067 start_index, end_index - start_index)); | 3063 start_index, end_index - start_index)); |
3068 manager()->ToBrowserAccessibilityManagerWin()->TrackScrollingObject(this); | 3064 manager()->ToBrowserAccessibilityManagerWin()->TrackScrollingObject(this); |
3069 | 3065 |
3070 return S_OK; | 3066 return S_OK; |
3071 } | 3067 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3154 return E_NOTIMPL; | 3150 return E_NOTIMPL; |
3155 } | 3151 } |
3156 | 3152 |
3157 STDMETHODIMP BrowserAccessibilityWin::GetPatternProvider(PATTERNID id, | 3153 STDMETHODIMP BrowserAccessibilityWin::GetPatternProvider(PATTERNID id, |
3158 IUnknown** provider) { | 3154 IUnknown** provider) { |
3159 DVLOG(1) << "In Function: " | 3155 DVLOG(1) << "In Function: " |
3160 << __FUNCTION__ | 3156 << __FUNCTION__ |
3161 << " for pattern id: " | 3157 << " for pattern id: " |
3162 << id; | 3158 << id; |
3163 if (id == UIA_ValuePatternId || id == UIA_TextPatternId) { | 3159 if (id == UIA_ValuePatternId || id == UIA_TextPatternId) { |
3164 if (IsEditableText()) { | 3160 if (HasState(ui::AX_STATE_EDITABLE)) { |
3165 DVLOG(1) << "Returning UIA text provider"; | 3161 DVLOG(1) << "Returning UIA text provider"; |
3166 base::win::UIATextProvider::CreateTextProvider( | 3162 base::win::UIATextProvider::CreateTextProvider( |
3167 GetValueText(), true, provider); | 3163 GetValueText(), true, provider); |
3168 return S_OK; | 3164 return S_OK; |
3169 } | 3165 } |
3170 } | 3166 } |
3171 return E_NOTIMPL; | 3167 return E_NOTIMPL; |
3172 } | 3168 } |
3173 | 3169 |
3174 STDMETHODIMP BrowserAccessibilityWin::GetPropertyValue(PROPERTYID id, | 3170 STDMETHODIMP BrowserAccessibilityWin::GetPropertyValue(PROPERTYID id, |
3175 VARIANT* ret) { | 3171 VARIANT* ret) { |
3176 DVLOG(1) << "In Function: " | 3172 DVLOG(1) << "In Function: " |
3177 << __FUNCTION__ | 3173 << __FUNCTION__ |
3178 << " for property id: " | 3174 << " for property id: " |
3179 << id; | 3175 << id; |
3180 V_VT(ret) = VT_EMPTY; | 3176 V_VT(ret) = VT_EMPTY; |
3181 if (id == UIA_ControlTypePropertyId) { | 3177 if (id == UIA_ControlTypePropertyId) { |
3182 if (IsEditableText()) { | 3178 if (HasState(ui::AX_STATE_EDITABLE)) { |
3183 V_VT(ret) = VT_I4; | 3179 V_VT(ret) = VT_I4; |
3184 ret->lVal = UIA_EditControlTypeId; | 3180 ret->lVal = UIA_EditControlTypeId; |
3185 DVLOG(1) << "Returning Edit control type"; | 3181 DVLOG(1) << "Returning Edit control type"; |
3186 } else { | 3182 } else { |
3187 DVLOG(1) << "Returning empty control type"; | 3183 DVLOG(1) << "Returning empty control type"; |
3188 } | 3184 } |
3189 } | 3185 } |
3190 return S_OK; | 3186 return S_OK; |
3191 } | 3187 } |
3192 | 3188 |
3193 STDMETHODIMP BrowserAccessibilityWin::get_ProviderOptions( | 3189 STDMETHODIMP BrowserAccessibilityWin::get_ProviderOptions( |
3194 enum ProviderOptions* ret) { | 3190 ProviderOptions* ret) { |
3195 return E_NOTIMPL; | 3191 return E_NOTIMPL; |
3196 } | 3192 } |
3197 | 3193 |
3198 STDMETHODIMP BrowserAccessibilityWin::get_HostRawElementProvider( | 3194 STDMETHODIMP BrowserAccessibilityWin::get_HostRawElementProvider( |
3199 IRawElementProviderSimple** provider) { | 3195 IRawElementProviderSimple** provider) { |
3200 return E_NOTIMPL; | 3196 return E_NOTIMPL; |
3201 } | 3197 } |
3202 | 3198 |
3203 // | 3199 // |
3204 // CComObjectRootEx methods. | 3200 // CComObjectRootEx methods. |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3439 // the character index of each embedded object character to the id of the | 3435 // the character index of each embedded object character to the id of the |
3440 // child object it points to. | 3436 // child object it points to. |
3441 for (unsigned int i = 0; i < PlatformChildCount(); ++i) { | 3437 for (unsigned int i = 0; i < PlatformChildCount(); ++i) { |
3442 BrowserAccessibilityWin* child = | 3438 BrowserAccessibilityWin* child = |
3443 PlatformGetChild(i)->ToBrowserAccessibilityWin(); | 3439 PlatformGetChild(i)->ToBrowserAccessibilityWin(); |
3444 DCHECK(child); | 3440 DCHECK(child); |
3445 // Similar to Firefox, we don't expose text-only objects in IA2 hypertext. | 3441 // Similar to Firefox, we don't expose text-only objects in IA2 hypertext. |
3446 if (child->IsTextOnlyObject()) { | 3442 if (child->IsTextOnlyObject()) { |
3447 win_attributes_->hypertext += child->name(); | 3443 win_attributes_->hypertext += child->name(); |
3448 } else { | 3444 } else { |
3449 int32_t char_offset = hypertext().size(); | 3445 int32_t char_offset = static_cast<int32_t>(GetText().size()); |
3450 int32_t child_id = child->GetId(); | 3446 int32_t child_id = child->GetId(); |
3451 int32_t index = hyperlinks().size(); | 3447 int32_t index = hyperlinks().size(); |
3452 win_attributes_->hyperlink_offset_to_index[char_offset] = index; | 3448 win_attributes_->hyperlink_offset_to_index[char_offset] = index; |
3453 win_attributes_->hyperlinks.push_back(child_id); | 3449 win_attributes_->hyperlinks.push_back(child_id); |
3454 win_attributes_->hypertext += kEmbeddedCharacter; | 3450 win_attributes_->hypertext += kEmbeddedCharacter; |
3455 } | 3451 } |
3456 } | 3452 } |
3457 } | 3453 } |
3458 | 3454 |
3459 void BrowserAccessibilityWin::UpdateStep3FireEvents(bool is_subtree_creation) { | 3455 void BrowserAccessibilityWin::UpdateStep3FireEvents(bool is_subtree_creation) { |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3712 if (child.IsTextOnlyObject()) { | 3708 if (child.IsTextOnlyObject()) { |
3713 int32_t hypertextOffset = 0; | 3709 int32_t hypertextOffset = 0; |
3714 int32_t index_in_parent = child.GetIndexInParent(); | 3710 int32_t index_in_parent = child.GetIndexInParent(); |
3715 DCHECK_GE(index_in_parent, 0); | 3711 DCHECK_GE(index_in_parent, 0); |
3716 DCHECK_LT(index_in_parent, static_cast<int32_t>(InternalChildCount())); | 3712 DCHECK_LT(index_in_parent, static_cast<int32_t>(InternalChildCount())); |
3717 for (uint32_t i = 0; i < static_cast<uint32_t>(index_in_parent); ++i) { | 3713 for (uint32_t i = 0; i < static_cast<uint32_t>(index_in_parent); ++i) { |
3718 const BrowserAccessibilityWin* sibling = | 3714 const BrowserAccessibilityWin* sibling = |
3719 InternalGetChild(i)->ToBrowserAccessibilityWin(); | 3715 InternalGetChild(i)->ToBrowserAccessibilityWin(); |
3720 DCHECK(sibling); | 3716 DCHECK(sibling); |
3721 if (sibling->IsTextOnlyObject()) | 3717 if (sibling->IsTextOnlyObject()) |
3722 hypertextOffset += sibling->hypertext().length(); | 3718 hypertextOffset += sibling->GetText().size(); |
3723 else | 3719 else |
3724 ++hypertextOffset; | 3720 ++hypertextOffset; |
3725 } | 3721 } |
3726 return hypertextOffset; | 3722 return hypertextOffset; |
3727 } | 3723 } |
3728 | 3724 |
3729 int32_t hyperlink_index = GetHyperlinkIndexFromChild(child); | 3725 int32_t hyperlink_index = GetHyperlinkIndexFromChild(child); |
3730 if (hyperlink_index < 0) | 3726 if (hyperlink_index < 0) |
3731 return -1; | 3727 return -1; |
3732 | 3728 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3805 if (endpoint_object.IsDescendantOf(child)) { | 3801 if (endpoint_object.IsDescendantOf(child)) { |
3806 endpoint_index_in_common_parent = child->GetIndexInParent(); | 3802 endpoint_index_in_common_parent = child->GetIndexInParent(); |
3807 break; | 3803 break; |
3808 } | 3804 } |
3809 } | 3805 } |
3810 DCHECK_GE(endpoint_index_in_common_parent, 0); | 3806 DCHECK_GE(endpoint_index_in_common_parent, 0); |
3811 | 3807 |
3812 if (endpoint_index_in_common_parent < index_in_common_parent) | 3808 if (endpoint_index_in_common_parent < index_in_common_parent) |
3813 return 0; | 3809 return 0; |
3814 if (endpoint_index_in_common_parent > index_in_common_parent) | 3810 if (endpoint_index_in_common_parent > index_in_common_parent) |
3815 return hypertext().length(); | 3811 return GetText().size(); |
3816 | 3812 |
3817 NOTREACHED(); | 3813 NOTREACHED(); |
3818 return -1; | 3814 return -1; |
3819 } | 3815 } |
3820 | 3816 |
3821 int BrowserAccessibilityWin::GetSelectionAnchor() const { | 3817 int BrowserAccessibilityWin::GetSelectionAnchor() const { |
3822 int32_t anchor_id = manager()->GetTreeData().sel_anchor_object_id; | 3818 int32_t anchor_id = manager()->GetTreeData().sel_anchor_object_id; |
3823 const auto anchor_object = | 3819 const auto anchor_object = |
3824 manager()->GetFromID(anchor_id)->ToBrowserAccessibilityWin(); | 3820 manager()->GetFromID(anchor_id)->ToBrowserAccessibilityWin(); |
3825 if (!anchor_object) | 3821 if (!anchor_object) |
(...skipping 11 matching lines...) Expand all Loading... | |
3837 return -1; | 3833 return -1; |
3838 | 3834 |
3839 int focus_offset = manager()->GetTreeData().sel_focus_offset; | 3835 int focus_offset = manager()->GetTreeData().sel_focus_offset; |
3840 return GetHypertextOffsetFromEndpoint(*focus_object, focus_offset); | 3836 return GetHypertextOffsetFromEndpoint(*focus_object, focus_offset); |
3841 } | 3837 } |
3842 | 3838 |
3843 void BrowserAccessibilityWin::GetSelectionOffsets( | 3839 void BrowserAccessibilityWin::GetSelectionOffsets( |
3844 int* selection_start, int* selection_end) const { | 3840 int* selection_start, int* selection_end) const { |
3845 DCHECK(selection_start && selection_end); | 3841 DCHECK(selection_start && selection_end); |
3846 | 3842 |
3847 if (IsEditableText() && !HasState(ui::AX_STATE_RICHLY_EDITABLE) && | 3843 if (HasState(ui::AX_STATE_EDITABLE) && |
3844 !HasState(ui::AX_STATE_RICHLY_EDITABLE) && | |
3848 GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START, selection_start) && | 3845 GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START, selection_start) && |
3849 GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END, selection_end)) { | 3846 GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END, selection_end)) { |
3850 return; | 3847 return; |
3851 } | 3848 } |
3852 | 3849 |
3853 *selection_start = GetSelectionAnchor(); | 3850 *selection_start = GetSelectionAnchor(); |
3854 *selection_end = GetSelectionFocus(); | 3851 *selection_end = GetSelectionFocus(); |
3855 if (*selection_start < 0 || *selection_end < 0) | 3852 if (*selection_start < 0 || *selection_end < 0) |
3856 return; | 3853 return; |
3857 | 3854 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3952 | 3949 |
3953 void BrowserAccessibilityWin::ComputeHypertextRemovedAndInserted( | 3950 void BrowserAccessibilityWin::ComputeHypertextRemovedAndInserted( |
3954 int* start, int* old_len, int* new_len) { | 3951 int* start, int* old_len, int* new_len) { |
3955 CHECK(old_win_attributes_); | 3952 CHECK(old_win_attributes_); |
3956 | 3953 |
3957 *start = 0; | 3954 *start = 0; |
3958 *old_len = 0; | 3955 *old_len = 0; |
3959 *new_len = 0; | 3956 *new_len = 0; |
3960 | 3957 |
3961 const base::string16& old_text = old_win_attributes_->hypertext; | 3958 const base::string16& old_text = old_win_attributes_->hypertext; |
3962 const base::string16& new_text = hypertext(); | 3959 const base::string16& new_text = GetText(); |
3963 | 3960 |
3964 size_t common_prefix = 0; | 3961 size_t common_prefix = 0; |
3965 while (common_prefix < old_text.size() && | 3962 while (common_prefix < old_text.size() && |
3966 common_prefix < new_text.size() && | 3963 common_prefix < new_text.size() && |
3967 IsSameHypertextCharacter(common_prefix, common_prefix)) { | 3964 IsSameHypertextCharacter(common_prefix, common_prefix)) { |
3968 ++common_prefix; | 3965 ++common_prefix; |
3969 } | 3966 } |
3970 | 3967 |
3971 size_t common_suffix = 0; | 3968 size_t common_suffix = 0; |
3972 while (common_prefix + common_suffix < old_text.size() && | 3969 while (common_prefix + common_suffix < old_text.size() && |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4011 } | 4008 } |
4012 return ui::CHAR_BOUNDARY; | 4009 return ui::CHAR_BOUNDARY; |
4013 } | 4010 } |
4014 | 4011 |
4015 LONG BrowserAccessibilityWin::FindBoundary( | 4012 LONG BrowserAccessibilityWin::FindBoundary( |
4016 const base::string16& text, | 4013 const base::string16& text, |
4017 IA2TextBoundaryType ia2_boundary, | 4014 IA2TextBoundaryType ia2_boundary, |
4018 LONG start_offset, | 4015 LONG start_offset, |
4019 ui::TextBoundaryDirection direction) { | 4016 ui::TextBoundaryDirection direction) { |
4020 HandleSpecialTextOffset(text, &start_offset); | 4017 HandleSpecialTextOffset(text, &start_offset); |
4021 if (ia2_boundary == IA2_TEXT_BOUNDARY_WORD && IsSimpleTextControl()) | 4018 if (ia2_boundary == IA2_TEXT_BOUNDARY_WORD) |
4022 return GetWordStartBoundary(static_cast<int>(start_offset), direction); | 4019 return GetWordStartBoundary(static_cast<int>(start_offset), direction); |
4023 | 4020 |
4024 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); | 4021 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); |
4025 const std::vector<int32_t>& line_breaks = | 4022 const std::vector<int32_t>& line_breaks = |
4026 GetIntListAttribute(ui::AX_ATTR_LINE_BREAKS); | 4023 GetIntListAttribute(ui::AX_ATTR_LINE_BREAKS); |
4027 return ui::FindAccessibleTextBoundary( | 4024 return ui::FindAccessibleTextBoundary( |
4028 text, line_breaks, boundary, start_offset, direction); | 4025 text, line_breaks, boundary, start_offset, direction); |
4029 } | 4026 } |
4030 | 4027 |
4031 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromID(int32_t id) { | 4028 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromID(int32_t id) { |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4191 // Expose whether or not the mouse is over an element, but suppress | 4188 // Expose whether or not the mouse is over an element, but suppress |
4192 // this for tests because it can make the test results flaky depending | 4189 // this for tests because it can make the test results flaky depending |
4193 // on the position of the mouse. | 4190 // on the position of the mouse. |
4194 BrowserAccessibilityStateImpl* accessibility_state = | 4191 BrowserAccessibilityStateImpl* accessibility_state = |
4195 BrowserAccessibilityStateImpl::GetInstance(); | 4192 BrowserAccessibilityStateImpl::GetInstance(); |
4196 if (!accessibility_state->disable_hot_tracking_for_testing()) { | 4193 if (!accessibility_state->disable_hot_tracking_for_testing()) { |
4197 if (HasState(ui::AX_STATE_HOVERED)) | 4194 if (HasState(ui::AX_STATE_HOVERED)) |
4198 ia_state |= STATE_SYSTEM_HOTTRACKED; | 4195 ia_state |= STATE_SYSTEM_HOTTRACKED; |
4199 } | 4196 } |
4200 | 4197 |
4201 if (IsEditableText()) | 4198 if (HasState(ui::AX_STATE_EDITABLE)) |
4202 ia2_state |= IA2_STATE_EDITABLE; | 4199 ia2_state |= IA2_STATE_EDITABLE; |
4203 | 4200 |
4204 if (GetBoolAttribute(ui::AX_ATTR_STATE_MIXED)) | 4201 if (GetBoolAttribute(ui::AX_ATTR_STATE_MIXED)) |
4205 ia_state |= STATE_SYSTEM_MIXED; | 4202 ia_state |= STATE_SYSTEM_MIXED; |
4206 | 4203 |
4207 if (GetBoolAttribute(ui::AX_ATTR_CAN_SET_VALUE)) | 4204 if (GetBoolAttribute(ui::AX_ATTR_CAN_SET_VALUE)) |
4208 ia2_state |= IA2_STATE_EDITABLE; | 4205 ia2_state |= IA2_STATE_EDITABLE; |
4209 | 4206 |
4210 if (!GetStringAttribute(ui::AX_ATTR_AUTO_COMPLETE).empty()) | 4207 if (!GetStringAttribute(ui::AX_ATTR_AUTO_COMPLETE).empty()) |
4211 ia2_state |= IA2_STATE_SUPPORTS_AUTOCOMPLETION; | 4208 ia2_state |= IA2_STATE_SUPPORTS_AUTOCOMPLETION; |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4681 ia2_role = ia_role; | 4678 ia2_role = ia_role; |
4682 | 4679 |
4683 win_attributes_->ia_role = ia_role; | 4680 win_attributes_->ia_role = ia_role; |
4684 win_attributes_->ia_state = ia_state; | 4681 win_attributes_->ia_state = ia_state; |
4685 win_attributes_->role_name = role_name; | 4682 win_attributes_->role_name = role_name; |
4686 win_attributes_->ia2_role = ia2_role; | 4683 win_attributes_->ia2_role = ia2_role; |
4687 win_attributes_->ia2_state = ia2_state; | 4684 win_attributes_->ia2_state = ia2_state; |
4688 } | 4685 } |
4689 | 4686 |
4690 } // namespace content | 4687 } // namespace content |
OLD | NEW |