| 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 1984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1995 // IAccessibleText methods. | 1995 // IAccessibleText methods. |
| 1996 // | 1996 // |
| 1997 | 1997 |
| 1998 STDMETHODIMP BrowserAccessibilityWin::get_nCharacters(LONG* n_characters) { | 1998 STDMETHODIMP BrowserAccessibilityWin::get_nCharacters(LONG* n_characters) { |
| 1999 if (!instance_active()) | 1999 if (!instance_active()) |
| 2000 return E_FAIL; | 2000 return E_FAIL; |
| 2001 | 2001 |
| 2002 if (!n_characters) | 2002 if (!n_characters) |
| 2003 return E_INVALIDARG; | 2003 return E_INVALIDARG; |
| 2004 | 2004 |
| 2005 *n_characters = TextForIAccessibleText().length(); | 2005 *n_characters = hypertext().length(); |
| 2006 return S_OK; | 2006 return S_OK; |
| 2007 } | 2007 } |
| 2008 | 2008 |
| 2009 STDMETHODIMP BrowserAccessibilityWin::get_caretOffset(LONG* offset) { | 2009 STDMETHODIMP BrowserAccessibilityWin::get_caretOffset(LONG* offset) { |
| 2010 if (!instance_active()) | 2010 if (!instance_active()) |
| 2011 return E_FAIL; | 2011 return E_FAIL; |
| 2012 | 2012 |
| 2013 if (!offset) | 2013 if (!offset) |
| 2014 return E_INVALIDARG; | 2014 return E_INVALIDARG; |
| 2015 | 2015 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2032 LONG* out_x, | 2032 LONG* out_x, |
| 2033 LONG* out_y, | 2033 LONG* out_y, |
| 2034 LONG* out_width, | 2034 LONG* out_width, |
| 2035 LONG* out_height) { | 2035 LONG* out_height) { |
| 2036 if (!instance_active()) | 2036 if (!instance_active()) |
| 2037 return E_FAIL; | 2037 return E_FAIL; |
| 2038 | 2038 |
| 2039 if (!out_x || !out_y || !out_width || !out_height) | 2039 if (!out_x || !out_y || !out_width || !out_height) |
| 2040 return E_INVALIDARG; | 2040 return E_INVALIDARG; |
| 2041 | 2041 |
| 2042 const base::string16& text_str = TextForIAccessibleText(); | 2042 const base::string16& text_str = hypertext(); |
| 2043 HandleSpecialTextOffset(text_str, &offset); | 2043 HandleSpecialTextOffset(text_str, &offset); |
| 2044 | 2044 |
| 2045 if (offset < 0 || offset > static_cast<LONG>(text_str.size())) | 2045 if (offset < 0 || offset > static_cast<LONG>(text_str.size())) |
| 2046 return E_INVALIDARG; | 2046 return E_INVALIDARG; |
| 2047 | 2047 |
| 2048 gfx::Rect character_bounds; | 2048 gfx::Rect character_bounds; |
| 2049 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { | 2049 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { |
| 2050 character_bounds = GetGlobalBoundsForRange(offset, 1); | 2050 character_bounds = GetGlobalBoundsForRange(offset, 1); |
| 2051 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { | 2051 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { |
| 2052 character_bounds = GetLocalBoundsForRange(offset, 1); | 2052 character_bounds = GetLocalBoundsForRange(offset, 1); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2115 | 2115 |
| 2116 STDMETHODIMP BrowserAccessibilityWin::get_text(LONG start_offset, | 2116 STDMETHODIMP BrowserAccessibilityWin::get_text(LONG start_offset, |
| 2117 LONG end_offset, | 2117 LONG end_offset, |
| 2118 BSTR* text) { | 2118 BSTR* text) { |
| 2119 if (!instance_active()) | 2119 if (!instance_active()) |
| 2120 return E_FAIL; | 2120 return E_FAIL; |
| 2121 | 2121 |
| 2122 if (!text) | 2122 if (!text) |
| 2123 return E_INVALIDARG; | 2123 return E_INVALIDARG; |
| 2124 | 2124 |
| 2125 const base::string16& text_str = TextForIAccessibleText(); | 2125 const base::string16& text_str = hypertext(); |
| 2126 | 2126 |
| 2127 // Handle special text offsets. | 2127 // Handle special text offsets. |
| 2128 HandleSpecialTextOffset(text_str, &start_offset); | 2128 HandleSpecialTextOffset(text_str, &start_offset); |
| 2129 HandleSpecialTextOffset(text_str, &end_offset); | 2129 HandleSpecialTextOffset(text_str, &end_offset); |
| 2130 | 2130 |
| 2131 // The spec allows the arguments to be reversed. | 2131 // The spec allows the arguments to be reversed. |
| 2132 if (start_offset > end_offset) { | 2132 if (start_offset > end_offset) { |
| 2133 LONG tmp = start_offset; | 2133 LONG tmp = start_offset; |
| 2134 start_offset = end_offset; | 2134 start_offset = end_offset; |
| 2135 end_offset = tmp; | 2135 end_offset = tmp; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2158 enum IA2TextBoundaryType boundary_type, | 2158 enum IA2TextBoundaryType boundary_type, |
| 2159 LONG* start_offset, | 2159 LONG* start_offset, |
| 2160 LONG* end_offset, | 2160 LONG* end_offset, |
| 2161 BSTR* text) { | 2161 BSTR* text) { |
| 2162 if (!instance_active()) | 2162 if (!instance_active()) |
| 2163 return E_FAIL; | 2163 return E_FAIL; |
| 2164 | 2164 |
| 2165 if (!start_offset || !end_offset || !text) | 2165 if (!start_offset || !end_offset || !text) |
| 2166 return E_INVALIDARG; | 2166 return E_INVALIDARG; |
| 2167 | 2167 |
| 2168 const base::string16& text_str = TextForIAccessibleText(); | 2168 const base::string16& text_str = hypertext(); |
| 2169 HandleSpecialTextOffset(text_str, &offset); | 2169 HandleSpecialTextOffset(text_str, &offset); |
| 2170 if (offset < 0) | 2170 if (offset < 0) |
| 2171 return E_INVALIDARG; | 2171 return E_INVALIDARG; |
| 2172 | 2172 |
| 2173 LONG text_len = text_str.length(); | 2173 LONG text_len = text_str.length(); |
| 2174 if (offset > text_len) | 2174 if (offset > text_len) |
| 2175 return E_INVALIDARG; | 2175 return E_INVALIDARG; |
| 2176 | 2176 |
| 2177 // The IAccessible2 spec says we don't have to implement the "sentence" | 2177 // The IAccessible2 spec says we don't have to implement the "sentence" |
| 2178 // boundary type, we can just let the screenreader handle it. | 2178 // boundary type, we can just let the screenreader handle it. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2213 | 2213 |
| 2214 // The IAccessible2 spec says we don't have to implement the "sentence" | 2214 // The IAccessible2 spec says we don't have to implement the "sentence" |
| 2215 // boundary type, we can just let the screenreader handle it. | 2215 // boundary type, we can just let the screenreader handle it. |
| 2216 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { | 2216 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { |
| 2217 *start_offset = 0; | 2217 *start_offset = 0; |
| 2218 *end_offset = 0; | 2218 *end_offset = 0; |
| 2219 *text = NULL; | 2219 *text = NULL; |
| 2220 return S_FALSE; | 2220 return S_FALSE; |
| 2221 } | 2221 } |
| 2222 | 2222 |
| 2223 const base::string16& text_str = TextForIAccessibleText(); | 2223 const base::string16& text_str = hypertext(); |
| 2224 | 2224 |
| 2225 *start_offset = FindBoundary( | 2225 *start_offset = FindBoundary( |
| 2226 text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); | 2226 text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); |
| 2227 *end_offset = offset; | 2227 *end_offset = offset; |
| 2228 return get_text(*start_offset, *end_offset, text); | 2228 return get_text(*start_offset, *end_offset, text); |
| 2229 } | 2229 } |
| 2230 | 2230 |
| 2231 STDMETHODIMP BrowserAccessibilityWin::get_textAfterOffset( | 2231 STDMETHODIMP BrowserAccessibilityWin::get_textAfterOffset( |
| 2232 LONG offset, | 2232 LONG offset, |
| 2233 enum IA2TextBoundaryType boundary_type, | 2233 enum IA2TextBoundaryType boundary_type, |
| 2234 LONG* start_offset, | 2234 LONG* start_offset, |
| 2235 LONG* end_offset, | 2235 LONG* end_offset, |
| 2236 BSTR* text) { | 2236 BSTR* text) { |
| 2237 if (!instance_active()) | 2237 if (!instance_active()) |
| 2238 return E_FAIL; | 2238 return E_FAIL; |
| 2239 | 2239 |
| 2240 if (!start_offset || !end_offset || !text) | 2240 if (!start_offset || !end_offset || !text) |
| 2241 return E_INVALIDARG; | 2241 return E_INVALIDARG; |
| 2242 | 2242 |
| 2243 // The IAccessible2 spec says we don't have to implement the "sentence" | 2243 // The IAccessible2 spec says we don't have to implement the "sentence" |
| 2244 // boundary type, we can just let the screenreader handle it. | 2244 // boundary type, we can just let the screenreader handle it. |
| 2245 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { | 2245 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { |
| 2246 *start_offset = 0; | 2246 *start_offset = 0; |
| 2247 *end_offset = 0; | 2247 *end_offset = 0; |
| 2248 *text = NULL; | 2248 *text = NULL; |
| 2249 return S_FALSE; | 2249 return S_FALSE; |
| 2250 } | 2250 } |
| 2251 | 2251 |
| 2252 const base::string16& text_str = TextForIAccessibleText(); | 2252 const base::string16& text_str = hypertext(); |
| 2253 | 2253 |
| 2254 *start_offset = offset; | 2254 *start_offset = offset; |
| 2255 *end_offset = FindBoundary( | 2255 *end_offset = FindBoundary( |
| 2256 text_str, boundary_type, offset, ui::FORWARDS_DIRECTION); | 2256 text_str, boundary_type, offset, ui::FORWARDS_DIRECTION); |
| 2257 return get_text(*start_offset, *end_offset, text); | 2257 return get_text(*start_offset, *end_offset, text); |
| 2258 } | 2258 } |
| 2259 | 2259 |
| 2260 STDMETHODIMP BrowserAccessibilityWin::get_newText(IA2TextSegment* new_text) { | 2260 STDMETHODIMP BrowserAccessibilityWin::get_newText(IA2TextSegment* new_text) { |
| 2261 if (!instance_active()) | 2261 if (!instance_active()) |
| 2262 return E_FAIL; | 2262 return E_FAIL; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2335 LONG x, LONG y) { | 2335 LONG x, LONG y) { |
| 2336 // TODO(dmazzoni): adjust this for the start and end index, too. | 2336 // TODO(dmazzoni): adjust this for the start and end index, too. |
| 2337 return scrollToPoint(coordinate_type, x, y); | 2337 return scrollToPoint(coordinate_type, x, y); |
| 2338 } | 2338 } |
| 2339 | 2339 |
| 2340 STDMETHODIMP BrowserAccessibilityWin::addSelection(LONG start_offset, | 2340 STDMETHODIMP BrowserAccessibilityWin::addSelection(LONG start_offset, |
| 2341 LONG end_offset) { | 2341 LONG end_offset) { |
| 2342 if (!instance_active()) | 2342 if (!instance_active()) |
| 2343 return E_FAIL; | 2343 return E_FAIL; |
| 2344 | 2344 |
| 2345 const base::string16& text_str = TextForIAccessibleText(); | 2345 const base::string16& text_str = hypertext(); |
| 2346 HandleSpecialTextOffset(text_str, &start_offset); | 2346 HandleSpecialTextOffset(text_str, &start_offset); |
| 2347 HandleSpecialTextOffset(text_str, &end_offset); | 2347 HandleSpecialTextOffset(text_str, &end_offset); |
| 2348 | 2348 |
| 2349 manager()->SetTextSelection(*this, start_offset, end_offset); | 2349 manager()->SetTextSelection(*this, start_offset, end_offset); |
| 2350 return S_OK; | 2350 return S_OK; |
| 2351 } | 2351 } |
| 2352 | 2352 |
| 2353 STDMETHODIMP BrowserAccessibilityWin::removeSelection(LONG selection_index) { | 2353 STDMETHODIMP BrowserAccessibilityWin::removeSelection(LONG selection_index) { |
| 2354 if (!instance_active()) | 2354 if (!instance_active()) |
| 2355 return E_FAIL; | 2355 return E_FAIL; |
| 2356 | 2356 |
| 2357 if (selection_index != 0) | 2357 if (selection_index != 0) |
| 2358 return E_INVALIDARG; | 2358 return E_INVALIDARG; |
| 2359 | 2359 |
| 2360 manager()->SetTextSelection(*this, 0, 0); | 2360 manager()->SetTextSelection(*this, 0, 0); |
| 2361 return S_OK; | 2361 return S_OK; |
| 2362 } | 2362 } |
| 2363 | 2363 |
| 2364 STDMETHODIMP BrowserAccessibilityWin::setCaretOffset(LONG offset) { | 2364 STDMETHODIMP BrowserAccessibilityWin::setCaretOffset(LONG offset) { |
| 2365 if (!instance_active()) | 2365 if (!instance_active()) |
| 2366 return E_FAIL; | 2366 return E_FAIL; |
| 2367 | 2367 |
| 2368 const base::string16& text_str = TextForIAccessibleText(); | 2368 const base::string16& text_str = hypertext(); |
| 2369 HandleSpecialTextOffset(text_str, &offset); | 2369 HandleSpecialTextOffset(text_str, &offset); |
| 2370 manager()->SetTextSelection(*this, offset, offset); | 2370 manager()->SetTextSelection(*this, offset, offset); |
| 2371 return S_OK; | 2371 return S_OK; |
| 2372 } | 2372 } |
| 2373 | 2373 |
| 2374 STDMETHODIMP BrowserAccessibilityWin::setSelection(LONG selection_index, | 2374 STDMETHODIMP BrowserAccessibilityWin::setSelection(LONG selection_index, |
| 2375 LONG start_offset, | 2375 LONG start_offset, |
| 2376 LONG end_offset) { | 2376 LONG end_offset) { |
| 2377 if (!instance_active()) | 2377 if (!instance_active()) |
| 2378 return E_FAIL; | 2378 return E_FAIL; |
| 2379 | 2379 |
| 2380 if (selection_index != 0) | 2380 if (selection_index != 0) |
| 2381 return E_INVALIDARG; | 2381 return E_INVALIDARG; |
| 2382 | 2382 |
| 2383 const base::string16& text_str = TextForIAccessibleText(); | 2383 const base::string16& text_str = hypertext(); |
| 2384 HandleSpecialTextOffset(text_str, &start_offset); | 2384 HandleSpecialTextOffset(text_str, &start_offset); |
| 2385 HandleSpecialTextOffset(text_str, &end_offset); | 2385 HandleSpecialTextOffset(text_str, &end_offset); |
| 2386 | 2386 |
| 2387 manager()->SetTextSelection(*this, start_offset, end_offset); | 2387 manager()->SetTextSelection(*this, start_offset, end_offset); |
| 2388 return S_OK; | 2388 return S_OK; |
| 2389 } | 2389 } |
| 2390 | 2390 |
| 2391 // | 2391 // |
| 2392 // IAccessibleText methods not implemented. | 2392 // IAccessibleText methods not implemented. |
| 2393 // | 2393 // |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2439 | 2439 |
| 2440 STDMETHODIMP BrowserAccessibilityWin::get_hyperlinkIndex( | 2440 STDMETHODIMP BrowserAccessibilityWin::get_hyperlinkIndex( |
| 2441 long char_index, | 2441 long char_index, |
| 2442 long* hyperlink_index) { | 2442 long* hyperlink_index) { |
| 2443 if (!instance_active()) | 2443 if (!instance_active()) |
| 2444 return E_FAIL; | 2444 return E_FAIL; |
| 2445 | 2445 |
| 2446 if (!hyperlink_index) | 2446 if (!hyperlink_index) |
| 2447 return E_INVALIDARG; | 2447 return E_INVALIDARG; |
| 2448 | 2448 |
| 2449 *hyperlink_index = -1; | |
| 2450 | |
| 2451 if (char_index < 0 || | 2449 if (char_index < 0 || |
| 2452 char_index >= static_cast<long>(hypertext().size())) { | 2450 char_index >= static_cast<long>(hypertext().size())) { |
| 2453 return E_INVALIDARG; | 2451 return E_INVALIDARG; |
| 2454 } | 2452 } |
| 2455 | 2453 |
| 2456 std::map<int32, int32>::iterator it = | 2454 std::map<int32, int32>::iterator it = |
| 2457 hyperlink_offset_to_index().find(char_index); | 2455 hyperlink_offset_to_index().find(char_index); |
| 2458 if (it == hyperlink_offset_to_index().end()) | 2456 if (it == hyperlink_offset_to_index().end()) { |
| 2459 return E_FAIL; | 2457 *hyperlink_index = -1; |
| 2458 return S_FALSE; |
| 2459 } |
| 2460 | 2460 |
| 2461 *hyperlink_index = it->second; | 2461 *hyperlink_index = it->second; |
| 2462 return S_OK; | 2462 return S_OK; |
| 2463 } | 2463 } |
| 2464 | 2464 |
| 2465 // | 2465 // |
| 2466 // IAccessibleHyperlink methods. | 2466 // IAccessibleHyperlink methods. |
| 2467 // | 2467 // |
| 2468 | 2468 |
| 2469 // Currently, only text links are supported. | 2469 // Currently, only text links are supported. |
| 2470 STDMETHODIMP BrowserAccessibilityWin::get_anchor(long index, VARIANT* anchor) { | 2470 STDMETHODIMP BrowserAccessibilityWin::get_anchor(long index, VARIANT* anchor) { |
| 2471 if (!instance_active() || !IsHyperlink()) | 2471 if (!instance_active() || !IsHyperlink()) |
| 2472 return E_FAIL; | 2472 return E_FAIL; |
| 2473 | 2473 |
| 2474 // IA2 text links can have only one anchor, that is the text inside them. | 2474 // IA2 text links can have only one anchor, that is the text inside them. |
| 2475 if (index != 0 || !anchor) | 2475 if (index != 0 || !anchor) |
| 2476 return E_INVALIDARG; | 2476 return E_INVALIDARG; |
| 2477 | 2477 |
| 2478 BSTR hypertext = SysAllocString(TextForIAccessibleText().c_str()); | 2478 BSTR ia2_hypertext = SysAllocString(hypertext().c_str()); |
| 2479 DCHECK(hypertext); | 2479 DCHECK(ia2_hypertext); |
| 2480 anchor->vt = VT_BSTR; | 2480 anchor->vt = VT_BSTR; |
| 2481 anchor->bstrVal = hypertext; | 2481 anchor->bstrVal = ia2_hypertext; |
| 2482 | 2482 |
| 2483 // Returning S_FALSE is not mentioned in the IA2 Spec, but it might have been | 2483 // Returning S_FALSE is not mentioned in the IA2 Spec, but it might have been |
| 2484 // an oversight. | 2484 // an oversight. |
| 2485 if (!SysStringLen(hypertext)) | 2485 if (!SysStringLen(ia2_hypertext)) |
| 2486 return S_FALSE; | 2486 return S_FALSE; |
| 2487 | 2487 |
| 2488 return S_OK; | 2488 return S_OK; |
| 2489 } | 2489 } |
| 2490 | 2490 |
| 2491 // Currently, only text links are supported. | 2491 // Currently, only text links are supported. |
| 2492 STDMETHODIMP BrowserAccessibilityWin::get_anchorTarget(long index, | 2492 STDMETHODIMP BrowserAccessibilityWin::get_anchorTarget(long index, |
| 2493 VARIANT* anchor_target) { | 2493 VARIANT* anchor_target) { |
| 2494 if (!instance_active() || !IsHyperlink()) | 2494 if (!instance_active() || !IsHyperlink()) |
| 2495 return E_FAIL; | 2495 return E_FAIL; |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3050 int* out_x, | 3050 int* out_x, |
| 3051 int* out_y, | 3051 int* out_y, |
| 3052 int* out_width, | 3052 int* out_width, |
| 3053 int* out_height) { | 3053 int* out_height) { |
| 3054 if (!instance_active()) | 3054 if (!instance_active()) |
| 3055 return E_FAIL; | 3055 return E_FAIL; |
| 3056 | 3056 |
| 3057 if (!out_x || !out_y || !out_width || !out_height) | 3057 if (!out_x || !out_y || !out_width || !out_height) |
| 3058 return E_INVALIDARG; | 3058 return E_INVALIDARG; |
| 3059 | 3059 |
| 3060 const base::string16& text_str = TextForIAccessibleText(); | 3060 const base::string16& text_str = hypertext(); |
| 3061 if (start_index > text_str.size() || | 3061 if (start_index > text_str.size() || |
| 3062 end_index > text_str.size() || | 3062 end_index > text_str.size() || |
| 3063 start_index > end_index) { | 3063 start_index > end_index) { |
| 3064 return E_INVALIDARG; | 3064 return E_INVALIDARG; |
| 3065 } | 3065 } |
| 3066 | 3066 |
| 3067 gfx::Rect bounds = GetGlobalBoundsForRange( | 3067 gfx::Rect bounds = GetGlobalBoundsForRange( |
| 3068 start_index, end_index - start_index); | 3068 start_index, end_index - start_index); |
| 3069 *out_x = bounds.x(); | 3069 *out_x = bounds.x(); |
| 3070 *out_y = bounds.y(); | 3070 *out_y = bounds.y(); |
| 3071 *out_width = bounds.width(); | 3071 *out_width = bounds.width(); |
| 3072 *out_height = bounds.height(); | 3072 *out_height = bounds.height(); |
| 3073 return S_OK; | 3073 return S_OK; |
| 3074 } | 3074 } |
| 3075 | 3075 |
| 3076 STDMETHODIMP BrowserAccessibilityWin::scrollToSubstring( | 3076 STDMETHODIMP BrowserAccessibilityWin::scrollToSubstring( |
| 3077 unsigned int start_index, | 3077 unsigned int start_index, |
| 3078 unsigned int end_index) { | 3078 unsigned int end_index) { |
| 3079 if (!instance_active()) | 3079 if (!instance_active()) |
| 3080 return E_FAIL; | 3080 return E_FAIL; |
| 3081 | 3081 |
| 3082 const base::string16& text_str = TextForIAccessibleText(); | 3082 const base::string16& text_str = hypertext(); |
| 3083 if (start_index > text_str.size() || | 3083 if (start_index > text_str.size() || |
| 3084 end_index > text_str.size() || | 3084 end_index > text_str.size() || |
| 3085 start_index > end_index) { | 3085 start_index > end_index) { |
| 3086 return E_INVALIDARG; | 3086 return E_INVALIDARG; |
| 3087 } | 3087 } |
| 3088 | 3088 |
| 3089 manager()->ScrollToMakeVisible(*this, GetLocalBoundsForRange( | 3089 manager()->ScrollToMakeVisible(*this, GetLocalBoundsForRange( |
| 3090 start_index, end_index - start_index)); | 3090 start_index, end_index - start_index)); |
| 3091 manager()->ToBrowserAccessibilityManagerWin()->TrackScrollingObject(this); | 3091 manager()->ToBrowserAccessibilityManagerWin()->TrackScrollingObject(this); |
| 3092 | 3092 |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3521 // something other than DOCUMENT so that the fact that it's a separate doc | 3521 // something other than DOCUMENT so that the fact that it's a separate doc |
| 3522 // is not exposed to AT. | 3522 // is not exposed to AT. |
| 3523 if (IsWebAreaForPresentationalIframe()) { | 3523 if (IsWebAreaForPresentationalIframe()) { |
| 3524 win_attributes_->ia_role = ROLE_SYSTEM_GROUPING; | 3524 win_attributes_->ia_role = ROLE_SYSTEM_GROUPING; |
| 3525 win_attributes_->ia2_role = ROLE_SYSTEM_GROUPING; | 3525 win_attributes_->ia2_role = ROLE_SYSTEM_GROUPING; |
| 3526 } | 3526 } |
| 3527 } | 3527 } |
| 3528 | 3528 |
| 3529 void BrowserAccessibilityWin::UpdateStep2ComputeHypertext() { | 3529 void BrowserAccessibilityWin::UpdateStep2ComputeHypertext() { |
| 3530 if (!PlatformChildCount()) { | 3530 if (!PlatformChildCount()) { |
| 3531 win_attributes_->hypertext += name(); | 3531 if (IsTextControl()) |
| 3532 win_attributes_->hypertext += value(); |
| 3533 else |
| 3534 win_attributes_->hypertext += name(); |
| 3535 |
| 3532 return; | 3536 return; |
| 3533 } | 3537 } |
| 3534 | 3538 |
| 3535 // Construct the hypertext for this node, which contains the concatenation | 3539 // Construct the hypertext for this node, which contains the concatenation |
| 3536 // of all of the static text and widespace of this node's children and an | 3540 // of all of the static text and widespace of this node's children and an |
| 3537 // embedded object character for all the other children. Build up a map from | 3541 // embedded object character for all the other children. Build up a map from |
| 3538 // the character index of each embedded object character to the id of the | 3542 // the character index of each embedded object character to the id of the |
| 3539 // child object it points to. | 3543 // child object it points to. |
| 3540 for (unsigned int i = 0; i < PlatformChildCount(); ++i) { | 3544 for (unsigned int i = 0; i < PlatformChildCount(); ++i) { |
| 3541 BrowserAccessibilityWin* child = | 3545 BrowserAccessibilityWin* child = |
| 3542 PlatformGetChild(i)->ToBrowserAccessibilityWin(); | 3546 PlatformGetChild(i)->ToBrowserAccessibilityWin(); |
| 3543 DCHECK(child); | 3547 DCHECK(child); |
| 3548 // Similar to Firefox, we don't expose text-only objects in IA2 hypertext. |
| 3544 if (child->IsTextOnlyObject()) { | 3549 if (child->IsTextOnlyObject()) { |
| 3545 win_attributes_->hypertext += child->name(); | 3550 win_attributes_->hypertext += child->name(); |
| 3546 } else { | 3551 } else { |
| 3547 int32 char_offset = hypertext().size(); | 3552 int32 char_offset = hypertext().size(); |
| 3548 int32 child_id = child->GetId(); | 3553 int32 child_id = child->GetId(); |
| 3549 int32 index = hyperlinks().size(); | 3554 int32 index = hyperlinks().size(); |
| 3550 win_attributes_->hyperlink_offset_to_index[char_offset] = index; | 3555 win_attributes_->hyperlink_offset_to_index[char_offset] = index; |
| 3551 win_attributes_->hyperlinks.push_back(child_id); | 3556 win_attributes_->hyperlinks.push_back(child_id); |
| 3552 win_attributes_->hypertext += kEmbeddedCharacter; | 3557 win_attributes_->hypertext += kEmbeddedCharacter; |
| 3553 } | 3558 } |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3808 if (child.IsTextOnlyObject()) { | 3813 if (child.IsTextOnlyObject()) { |
| 3809 int32 hypertextOffset = 0; | 3814 int32 hypertextOffset = 0; |
| 3810 int32 index_in_parent = child.GetIndexInParent(); | 3815 int32 index_in_parent = child.GetIndexInParent(); |
| 3811 DCHECK_GE(index_in_parent, 0); | 3816 DCHECK_GE(index_in_parent, 0); |
| 3812 DCHECK_LT(index_in_parent, static_cast<int32>(PlatformChildCount())); | 3817 DCHECK_LT(index_in_parent, static_cast<int32>(PlatformChildCount())); |
| 3813 for (uint32 i = 0; i < static_cast<uint32>(index_in_parent); ++i) { | 3818 for (uint32 i = 0; i < static_cast<uint32>(index_in_parent); ++i) { |
| 3814 const BrowserAccessibilityWin* sibling = | 3819 const BrowserAccessibilityWin* sibling = |
| 3815 PlatformGetChild(i)->ToBrowserAccessibilityWin(); | 3820 PlatformGetChild(i)->ToBrowserAccessibilityWin(); |
| 3816 DCHECK(sibling); | 3821 DCHECK(sibling); |
| 3817 if (sibling->IsTextOnlyObject()) | 3822 if (sibling->IsTextOnlyObject()) |
| 3818 hypertextOffset += sibling->TextForIAccessibleText().length(); | 3823 hypertextOffset += sibling->hypertext().length(); |
| 3819 else | 3824 else |
| 3820 ++hypertextOffset; | 3825 ++hypertextOffset; |
| 3821 } | 3826 } |
| 3822 return hypertextOffset; | 3827 return hypertextOffset; |
| 3823 } | 3828 } |
| 3824 | 3829 |
| 3825 int32 hyperlink_index = GetHyperlinkIndexFromChild(child); | 3830 int32 hyperlink_index = GetHyperlinkIndexFromChild(child); |
| 3826 if (hyperlink_index < 0) | 3831 if (hyperlink_index < 0) |
| 3827 return -1; | 3832 return -1; |
| 3828 | 3833 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3900 if (endpoint_object.IsDescendantOf(child)) { | 3905 if (endpoint_object.IsDescendantOf(child)) { |
| 3901 endpoint_index_in_common_parent = child->GetIndexInParent(); | 3906 endpoint_index_in_common_parent = child->GetIndexInParent(); |
| 3902 break; | 3907 break; |
| 3903 } | 3908 } |
| 3904 } | 3909 } |
| 3905 DCHECK_GE(endpoint_index_in_common_parent, 0); | 3910 DCHECK_GE(endpoint_index_in_common_parent, 0); |
| 3906 | 3911 |
| 3907 if (endpoint_index_in_common_parent < index_in_common_parent) | 3912 if (endpoint_index_in_common_parent < index_in_common_parent) |
| 3908 return 0; | 3913 return 0; |
| 3909 if (endpoint_index_in_common_parent > index_in_common_parent) | 3914 if (endpoint_index_in_common_parent > index_in_common_parent) |
| 3910 return TextForIAccessibleText().length(); | 3915 return hypertext().length(); |
| 3911 | 3916 |
| 3912 NOTREACHED(); | 3917 NOTREACHED(); |
| 3913 return -1; | 3918 return -1; |
| 3914 } | 3919 } |
| 3915 | 3920 |
| 3916 int BrowserAccessibilityWin::GetSelectionAnchor() const { | 3921 int BrowserAccessibilityWin::GetSelectionAnchor() const { |
| 3917 int32 anchor_id = manager()->GetTreeData().sel_anchor_object_id; | 3922 int32 anchor_id = manager()->GetTreeData().sel_anchor_object_id; |
| 3918 BrowserAccessibilityWin* anchor_object = manager()->GetFromID( | 3923 BrowserAccessibilityWin* anchor_object = manager()->GetFromID( |
| 3919 anchor_id)->ToBrowserAccessibilityWin(); | 3924 anchor_id)->ToBrowserAccessibilityWin(); |
| 3920 if (!anchor_object) | 3925 if (!anchor_object) |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4014 float fval; | 4019 float fval; |
| 4015 base::string16 value = this->value(); | 4020 base::string16 value = this->value(); |
| 4016 | 4021 |
| 4017 if (value.empty() && | 4022 if (value.empty() && |
| 4018 GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, &fval)) { | 4023 GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, &fval)) { |
| 4019 value = base::UTF8ToUTF16(base::DoubleToString(fval)); | 4024 value = base::UTF8ToUTF16(base::DoubleToString(fval)); |
| 4020 } | 4025 } |
| 4021 return value; | 4026 return value; |
| 4022 } | 4027 } |
| 4023 | 4028 |
| 4024 base::string16 BrowserAccessibilityWin::TextForIAccessibleText() const { | |
| 4025 switch (GetRole()) { | |
| 4026 case ui::AX_ROLE_TEXT_FIELD: | |
| 4027 case ui::AX_ROLE_MENU_LIST_OPTION: | |
| 4028 return value(); | |
| 4029 default: | |
| 4030 return hypertext(); | |
| 4031 } | |
| 4032 } | |
| 4033 | |
| 4034 bool BrowserAccessibilityWin::IsSameHypertextCharacter(size_t old_char_index, | 4029 bool BrowserAccessibilityWin::IsSameHypertextCharacter(size_t old_char_index, |
| 4035 size_t new_char_index) { | 4030 size_t new_char_index) { |
| 4036 CHECK(old_win_attributes_); | 4031 CHECK(old_win_attributes_); |
| 4037 | 4032 |
| 4038 // For anything other than the "embedded character", we just compare the | 4033 // For anything other than the "embedded character", we just compare the |
| 4039 // characters directly. | 4034 // characters directly. |
| 4040 base::char16 old_ch = old_win_attributes_->hypertext[old_char_index]; | 4035 base::char16 old_ch = old_win_attributes_->hypertext[old_char_index]; |
| 4041 base::char16 new_ch = win_attributes_->hypertext[new_char_index]; | 4036 base::char16 new_ch = win_attributes_->hypertext[new_char_index]; |
| 4042 if (old_ch != new_ch) | 4037 if (old_ch != new_ch) |
| 4043 return false; | 4038 return false; |
| (...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4784 ia2_role = ia_role; | 4779 ia2_role = ia_role; |
| 4785 | 4780 |
| 4786 win_attributes_->ia_role = ia_role; | 4781 win_attributes_->ia_role = ia_role; |
| 4787 win_attributes_->ia_state = ia_state; | 4782 win_attributes_->ia_state = ia_state; |
| 4788 win_attributes_->role_name = role_name; | 4783 win_attributes_->role_name = role_name; |
| 4789 win_attributes_->ia2_role = ia2_role; | 4784 win_attributes_->ia2_role = ia2_role; |
| 4790 win_attributes_->ia2_state = ia2_state; | 4785 win_attributes_->ia2_state = ia2_state; |
| 4791 } | 4786 } |
| 4792 | 4787 |
| 4793 } // namespace content | 4788 } // namespace content |
| OLD | NEW |