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 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 | 675 |
676 if (!name) | 676 if (!name) |
677 return E_INVALIDARG; | 677 return E_INVALIDARG; |
678 | 678 |
679 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 679 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
680 if (!target) | 680 if (!target) |
681 return E_INVALIDARG; | 681 return E_INVALIDARG; |
682 | 682 |
683 base::string16 name_str = target->name(); | 683 base::string16 name_str = target->name(); |
684 if (name_str.empty()) { | 684 if (name_str.empty()) { |
685 if (target->ia2_role() == ROLE_SYSTEM_DOCUMENT && GetParent()) { | 685 if (target->ia2_role() == ROLE_SYSTEM_DOCUMENT && |
| 686 GetAccessibilityParent()) { |
686 // Hack: Some versions of JAWS crash if they get an empty name on | 687 // Hack: Some versions of JAWS crash if they get an empty name on |
687 // a document that's the child of an iframe, so always return a | 688 // a document that's the child of an iframe, so always return a |
688 // nonempty string for this role. https://crbug.com/583057 | 689 // nonempty string for this role. https://crbug.com/583057 |
689 name_str = L" "; | 690 name_str = L" "; |
690 } else { | 691 } else { |
691 return S_FALSE; | 692 return S_FALSE; |
692 } | 693 } |
693 } | 694 } |
694 | 695 |
695 *name = SysAllocString(name_str.c_str()); | 696 *name = SysAllocString(name_str.c_str()); |
696 | 697 |
697 DCHECK(*name); | 698 DCHECK(*name); |
698 return S_OK; | 699 return S_OK; |
699 } | 700 } |
700 | 701 |
701 STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) { | 702 STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) { |
702 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_PARENT); | 703 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_PARENT); |
703 if (!instance_active()) | 704 if (!instance_active()) |
704 return E_FAIL; | 705 return E_FAIL; |
705 | 706 |
706 if (!disp_parent) | 707 if (!disp_parent) |
707 return E_INVALIDARG; | 708 return E_INVALIDARG; |
708 | 709 |
709 IAccessible* parent_obj = ToBrowserAccessibilityWin(GetParent()); | 710 IAccessible* parent_obj = ToBrowserAccessibilityWin(GetAccessibilityParent()); |
710 if (parent_obj == NULL) { | 711 if (parent_obj == NULL) { |
711 // This happens if we're the root of the tree; | 712 // This happens if we're the root of the tree; |
712 // return the IAccessible for the window. | 713 // return the IAccessible for the window. |
713 parent_obj = | 714 parent_obj = |
714 manager_->ToBrowserAccessibilityManagerWin()->GetParentIAccessible(); | 715 manager_->ToBrowserAccessibilityManagerWin()->GetParentIAccessible(); |
715 // |parent| can only be NULL if the manager was created before the parent | 716 // |parent| can only be NULL if the manager was created before the parent |
716 // IAccessible was known and it wasn't subsequently set before a client | 717 // IAccessible was known and it wasn't subsequently set before a client |
717 // requested it. This has been fixed. |parent| may also be NULL during | 718 // requested it. This has been fixed. |parent| may also be NULL during |
718 // destruction. Possible cases where this could occur include tabs being | 719 // destruction. Possible cases where this could occur include tabs being |
719 // dragged to a new window, etc. | 720 // dragged to a new window, etc. |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 LONG y) { | 1091 LONG y) { |
1091 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SCROLL_TO_POINT); | 1092 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SCROLL_TO_POINT); |
1092 if (!instance_active()) | 1093 if (!instance_active()) |
1093 return E_FAIL; | 1094 return E_FAIL; |
1094 | 1095 |
1095 gfx::Point scroll_to(x, y); | 1096 gfx::Point scroll_to(x, y); |
1096 | 1097 |
1097 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { | 1098 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { |
1098 scroll_to -= manager_->GetViewBounds().OffsetFromOrigin(); | 1099 scroll_to -= manager_->GetViewBounds().OffsetFromOrigin(); |
1099 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { | 1100 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { |
1100 if (GetParent()) | 1101 if (GetAccessibilityParent()) |
1101 scroll_to += GetParent()->GetFrameBoundsRect().OffsetFromOrigin(); | 1102 scroll_to += |
| 1103 GetAccessibilityParent()->GetFrameBoundsRect().OffsetFromOrigin(); |
1102 } else { | 1104 } else { |
1103 return E_INVALIDARG; | 1105 return E_INVALIDARG; |
1104 } | 1106 } |
1105 | 1107 |
1106 manager_->ScrollToPoint(*this, scroll_to); | 1108 manager_->ScrollToPoint(*this, scroll_to); |
1107 | 1109 |
1108 return S_OK; | 1110 return S_OK; |
1109 } | 1111 } |
1110 | 1112 |
1111 STDMETHODIMP BrowserAccessibilityWin::get_groupPosition( | 1113 STDMETHODIMP BrowserAccessibilityWin::get_groupPosition( |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1293 if (!x || !y) | 1295 if (!x || !y) |
1294 return E_INVALIDARG; | 1296 return E_INVALIDARG; |
1295 | 1297 |
1296 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { | 1298 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { |
1297 gfx::Rect bounds = GetScreenBoundsRect(); | 1299 gfx::Rect bounds = GetScreenBoundsRect(); |
1298 *x = bounds.x(); | 1300 *x = bounds.x(); |
1299 *y = bounds.y(); | 1301 *y = bounds.y(); |
1300 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { | 1302 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { |
1301 gfx::Rect bounds = GetPageBoundsRect(); | 1303 gfx::Rect bounds = GetPageBoundsRect(); |
1302 gfx::Rect parent_bounds = | 1304 gfx::Rect parent_bounds = |
1303 GetParent() ? GetParent()->GetPageBoundsRect() : gfx::Rect(); | 1305 GetAccessibilityParent() ? GetAccessibilityParent()->GetPageBoundsRect() |
| 1306 : gfx::Rect(); |
1304 *x = bounds.x() - parent_bounds.x(); | 1307 *x = bounds.x() - parent_bounds.x(); |
1305 *y = bounds.y() - parent_bounds.y(); | 1308 *y = bounds.y() - parent_bounds.y(); |
1306 } else { | 1309 } else { |
1307 return E_INVALIDARG; | 1310 return E_INVALIDARG; |
1308 } | 1311 } |
1309 | 1312 |
1310 return S_OK; | 1313 return S_OK; |
1311 } | 1314 } |
1312 | 1315 |
1313 STDMETHODIMP BrowserAccessibilityWin::get_imageSize(LONG* height, LONG* width) { | 1316 STDMETHODIMP BrowserAccessibilityWin::get_imageSize(LONG* height, LONG* width) { |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2033 return E_INVALIDARG; | 2036 return E_INVALIDARG; |
2034 | 2037 |
2035 *n_column_header_cells = 0; | 2038 *n_column_header_cells = 0; |
2036 | 2039 |
2037 int column; | 2040 int column; |
2038 if (!GetIntAttribute( | 2041 if (!GetIntAttribute( |
2039 ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX, &column)) { | 2042 ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX, &column)) { |
2040 return S_FALSE; | 2043 return S_FALSE; |
2041 } | 2044 } |
2042 | 2045 |
2043 BrowserAccessibility* table = GetParent(); | 2046 BrowserAccessibility* table = GetAccessibilityParent(); |
2044 while (table && table->GetRole() != ui::AX_ROLE_TABLE) | 2047 while (table && table->GetRole() != ui::AX_ROLE_TABLE) |
2045 table = table->GetParent(); | 2048 table = table->GetAccessibilityParent(); |
2046 if (!table) { | 2049 if (!table) { |
2047 NOTREACHED(); | 2050 NOTREACHED(); |
2048 return S_FALSE; | 2051 return S_FALSE; |
2049 } | 2052 } |
2050 | 2053 |
2051 int columns; | 2054 int columns; |
2052 int rows; | 2055 int rows; |
2053 if (!table->GetIntAttribute( | 2056 if (!table->GetIntAttribute( |
2054 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) || | 2057 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) || |
2055 !table->GetIntAttribute( | 2058 !table->GetIntAttribute( |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2136 return E_INVALIDARG; | 2139 return E_INVALIDARG; |
2137 | 2140 |
2138 *n_row_header_cells = 0; | 2141 *n_row_header_cells = 0; |
2139 | 2142 |
2140 int row; | 2143 int row; |
2141 if (!GetIntAttribute( | 2144 if (!GetIntAttribute( |
2142 ui::AX_ATTR_TABLE_CELL_ROW_INDEX, &row)) { | 2145 ui::AX_ATTR_TABLE_CELL_ROW_INDEX, &row)) { |
2143 return S_FALSE; | 2146 return S_FALSE; |
2144 } | 2147 } |
2145 | 2148 |
2146 BrowserAccessibility* table = GetParent(); | 2149 BrowserAccessibility* table = GetAccessibilityParent(); |
2147 while (table && table->GetRole() != ui::AX_ROLE_TABLE) | 2150 while (table && table->GetRole() != ui::AX_ROLE_TABLE) |
2148 table = table->GetParent(); | 2151 table = table->GetAccessibilityParent(); |
2149 if (!table) { | 2152 if (!table) { |
2150 NOTREACHED(); | 2153 NOTREACHED(); |
2151 return S_FALSE; | 2154 return S_FALSE; |
2152 } | 2155 } |
2153 | 2156 |
2154 int columns; | 2157 int columns; |
2155 int rows; | 2158 int rows; |
2156 if (!table->GetIntAttribute( | 2159 if (!table->GetIntAttribute( |
2157 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) || | 2160 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) || |
2158 !table->GetIntAttribute( | 2161 !table->GetIntAttribute( |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2267 | 2270 |
2268 if (!table) | 2271 if (!table) |
2269 return E_INVALIDARG; | 2272 return E_INVALIDARG; |
2270 | 2273 |
2271 | 2274 |
2272 int row; | 2275 int row; |
2273 int column; | 2276 int column; |
2274 GetIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX, &row); | 2277 GetIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX, &row); |
2275 GetIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX, &column); | 2278 GetIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX, &column); |
2276 | 2279 |
2277 BrowserAccessibility* find_table = GetParent(); | 2280 BrowserAccessibility* find_table = GetAccessibilityParent(); |
2278 while (find_table && find_table->GetRole() != ui::AX_ROLE_TABLE) | 2281 while (find_table && find_table->GetRole() != ui::AX_ROLE_TABLE) |
2279 find_table = find_table->GetParent(); | 2282 find_table = find_table->GetAccessibilityParent(); |
2280 if (!find_table) { | 2283 if (!find_table) { |
2281 NOTREACHED(); | 2284 NOTREACHED(); |
2282 return S_FALSE; | 2285 return S_FALSE; |
2283 } | 2286 } |
2284 | 2287 |
2285 *table = static_cast<IAccessibleTable*>( | 2288 *table = static_cast<IAccessibleTable*>( |
2286 ToBrowserAccessibilityWin(find_table)->NewReference()); | 2289 ToBrowserAccessibilityWin(find_table)->NewReference()); |
2287 | 2290 |
2288 return S_OK; | 2291 return S_OK; |
2289 } | 2292 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2347 const base::string16& text_str = GetText(); | 2350 const base::string16& text_str = GetText(); |
2348 HandleSpecialTextOffset(&offset); | 2351 HandleSpecialTextOffset(&offset); |
2349 if (offset < 0 || offset > static_cast<LONG>(text_str.size())) | 2352 if (offset < 0 || offset > static_cast<LONG>(text_str.size())) |
2350 return E_INVALIDARG; | 2353 return E_INVALIDARG; |
2351 | 2354 |
2352 gfx::Rect character_bounds; | 2355 gfx::Rect character_bounds; |
2353 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { | 2356 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { |
2354 character_bounds = GetScreenBoundsForRange(offset, 1); | 2357 character_bounds = GetScreenBoundsForRange(offset, 1); |
2355 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { | 2358 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { |
2356 character_bounds = GetPageBoundsForRange(offset, 1); | 2359 character_bounds = GetPageBoundsForRange(offset, 1); |
2357 if (GetParent()) | 2360 if (GetAccessibilityParent()) |
2358 character_bounds -= GetParent()->GetPageBoundsRect().OffsetFromOrigin(); | 2361 character_bounds -= |
| 2362 GetAccessibilityParent()->GetPageBoundsRect().OffsetFromOrigin(); |
2359 } else { | 2363 } else { |
2360 return E_INVALIDARG; | 2364 return E_INVALIDARG; |
2361 } | 2365 } |
2362 | 2366 |
2363 *out_x = character_bounds.x(); | 2367 *out_x = character_bounds.x(); |
2364 *out_y = character_bounds.y(); | 2368 *out_y = character_bounds.y(); |
2365 *out_width = character_bounds.width(); | 2369 *out_width = character_bounds.width(); |
2366 *out_height = character_bounds.height(); | 2370 *out_height = character_bounds.height(); |
2367 | 2371 |
2368 return S_OK; | 2372 return S_OK; |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2901 STDMETHODIMP BrowserAccessibilityWin::get_startIndex(long* index) { | 2905 STDMETHODIMP BrowserAccessibilityWin::get_startIndex(long* index) { |
2902 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_START_INDEX); | 2906 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_START_INDEX); |
2903 AddAccessibilityModeFlags(AccessibilityMode::kScreenReader); | 2907 AddAccessibilityModeFlags(AccessibilityMode::kScreenReader); |
2904 if (!instance_active() || !IsHyperlink()) | 2908 if (!instance_active() || !IsHyperlink()) |
2905 return E_FAIL; | 2909 return E_FAIL; |
2906 | 2910 |
2907 if (!index) | 2911 if (!index) |
2908 return E_INVALIDARG; | 2912 return E_INVALIDARG; |
2909 | 2913 |
2910 int32_t hypertext_offset = 0; | 2914 int32_t hypertext_offset = 0; |
2911 auto* parent = GetParent(); | 2915 auto* parent = GetAccessibilityParent(); |
2912 if (parent) { | 2916 if (parent) { |
2913 hypertext_offset = | 2917 hypertext_offset = |
2914 ToBrowserAccessibilityWin(parent)->GetHypertextOffsetFromChild(*this); | 2918 ToBrowserAccessibilityWin(parent)->GetHypertextOffsetFromChild(*this); |
2915 } | 2919 } |
2916 *index = static_cast<LONG>(hypertext_offset); | 2920 *index = static_cast<LONG>(hypertext_offset); |
2917 return S_OK; | 2921 return S_OK; |
2918 } | 2922 } |
2919 | 2923 |
2920 STDMETHODIMP BrowserAccessibilityWin::get_endIndex(long* index) { | 2924 STDMETHODIMP BrowserAccessibilityWin::get_endIndex(long* index) { |
2921 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_END_INDEX); | 2925 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_END_INDEX); |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3382 } | 3386 } |
3383 | 3387 |
3384 STDMETHODIMP BrowserAccessibilityWin::get_parentNode(ISimpleDOMNode** node) { | 3388 STDMETHODIMP BrowserAccessibilityWin::get_parentNode(ISimpleDOMNode** node) { |
3385 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PARENT_NODE); | 3389 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PARENT_NODE); |
3386 if (!instance_active()) | 3390 if (!instance_active()) |
3387 return E_FAIL; | 3391 return E_FAIL; |
3388 | 3392 |
3389 if (!node) | 3393 if (!node) |
3390 return E_INVALIDARG; | 3394 return E_INVALIDARG; |
3391 | 3395 |
3392 *node = ToBrowserAccessibilityWin(GetParent())->NewReference(); | 3396 *node = ToBrowserAccessibilityWin(GetAccessibilityParent())->NewReference(); |
3393 return S_OK; | 3397 return S_OK; |
3394 } | 3398 } |
3395 | 3399 |
3396 STDMETHODIMP BrowserAccessibilityWin::get_firstChild(ISimpleDOMNode** node) { | 3400 STDMETHODIMP BrowserAccessibilityWin::get_firstChild(ISimpleDOMNode** node) { |
3397 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_FIRST_CHILD); | 3401 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_FIRST_CHILD); |
3398 if (!instance_active()) | 3402 if (!instance_active()) |
3399 return E_FAIL; | 3403 return E_FAIL; |
3400 | 3404 |
3401 if (!node) | 3405 if (!node) |
3402 return E_INVALIDARG; | 3406 return E_INVALIDARG; |
(...skipping 27 matching lines...) Expand all Loading... |
3430 | 3434 |
3431 STDMETHODIMP BrowserAccessibilityWin::get_previousSibling( | 3435 STDMETHODIMP BrowserAccessibilityWin::get_previousSibling( |
3432 ISimpleDOMNode** node) { | 3436 ISimpleDOMNode** node) { |
3433 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PREVIOUS_SIBLING); | 3437 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PREVIOUS_SIBLING); |
3434 if (!instance_active()) | 3438 if (!instance_active()) |
3435 return E_FAIL; | 3439 return E_FAIL; |
3436 | 3440 |
3437 if (!node) | 3441 if (!node) |
3438 return E_INVALIDARG; | 3442 return E_INVALIDARG; |
3439 | 3443 |
3440 if (!GetParent() || GetIndexInParent() <= 0) { | 3444 if (!GetAccessibilityParent() || GetIndexInParent() <= 0) { |
3441 *node = NULL; | 3445 *node = NULL; |
3442 return S_FALSE; | 3446 return S_FALSE; |
3443 } | 3447 } |
3444 | 3448 |
3445 *node = ToBrowserAccessibilityWin( | 3449 *node = ToBrowserAccessibilityWin(GetAccessibilityParent()->InternalGetChild( |
3446 GetParent()->InternalGetChild(GetIndexInParent() - 1))->NewReference(); | 3450 GetIndexInParent() - 1)) |
| 3451 ->NewReference(); |
3447 return S_OK; | 3452 return S_OK; |
3448 } | 3453 } |
3449 | 3454 |
3450 STDMETHODIMP BrowserAccessibilityWin::get_nextSibling(ISimpleDOMNode** node) { | 3455 STDMETHODIMP BrowserAccessibilityWin::get_nextSibling(ISimpleDOMNode** node) { |
3451 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NEXT_SIBLING); | 3456 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NEXT_SIBLING); |
3452 if (!instance_active()) | 3457 if (!instance_active()) |
3453 return E_FAIL; | 3458 return E_FAIL; |
3454 | 3459 |
3455 if (!node) | 3460 if (!node) |
3456 return E_INVALIDARG; | 3461 return E_INVALIDARG; |
3457 | 3462 |
3458 if (!GetParent() || | 3463 if (!GetAccessibilityParent() || GetIndexInParent() < 0 || |
3459 GetIndexInParent() < 0 || | 3464 GetIndexInParent() >= |
3460 GetIndexInParent() >= static_cast<int>( | 3465 static_cast<int>(GetAccessibilityParent()->InternalChildCount()) - |
3461 GetParent()->InternalChildCount()) - 1) { | 3466 1) { |
3462 *node = NULL; | 3467 *node = NULL; |
3463 return S_FALSE; | 3468 return S_FALSE; |
3464 } | 3469 } |
3465 | 3470 |
3466 *node = ToBrowserAccessibilityWin( | 3471 *node = ToBrowserAccessibilityWin(GetAccessibilityParent()->InternalGetChild( |
3467 GetParent()->InternalGetChild(GetIndexInParent() + 1))->NewReference(); | 3472 GetIndexInParent() + 1)) |
| 3473 ->NewReference(); |
3468 return S_OK; | 3474 return S_OK; |
3469 } | 3475 } |
3470 | 3476 |
3471 STDMETHODIMP BrowserAccessibilityWin::get_childAt( | 3477 STDMETHODIMP BrowserAccessibilityWin::get_childAt( |
3472 unsigned int child_index, | 3478 unsigned int child_index, |
3473 ISimpleDOMNode** node) { | 3479 ISimpleDOMNode** node) { |
3474 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CHILD_AT); | 3480 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CHILD_AT); |
3475 if (!instance_active()) | 3481 if (!instance_active()) |
3476 return E_FAIL; | 3482 return E_FAIL; |
3477 | 3483 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3646 void** object) { | 3652 void** object) { |
3647 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_QUERY_SERVICE); | 3653 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_QUERY_SERVICE); |
3648 if (!instance_active()) | 3654 if (!instance_active()) |
3649 return E_FAIL; | 3655 return E_FAIL; |
3650 | 3656 |
3651 if (guid_service == GUID_IAccessibleContentDocument) { | 3657 if (guid_service == GUID_IAccessibleContentDocument) { |
3652 // Special Mozilla extension: return the accessible for the root document. | 3658 // Special Mozilla extension: return the accessible for the root document. |
3653 // Screen readers use this to distinguish between a document loaded event | 3659 // Screen readers use this to distinguish between a document loaded event |
3654 // on the root document vs on an iframe. | 3660 // on the root document vs on an iframe. |
3655 BrowserAccessibility* node = this; | 3661 BrowserAccessibility* node = this; |
3656 while (node->GetParent()) | 3662 while (node->GetAccessibilityParent()) |
3657 node = node->GetParent()->manager()->GetRoot(); | 3663 node = node->GetAccessibilityParent()->manager()->GetRoot(); |
3658 return ToBrowserAccessibilityWin(node)->QueryInterface( | 3664 return ToBrowserAccessibilityWin(node)->QueryInterface( |
3659 IID_IAccessible2, object); | 3665 IID_IAccessible2, object); |
3660 } | 3666 } |
3661 | 3667 |
3662 if (guid_service == IID_IAccessible || | 3668 if (guid_service == IID_IAccessible || |
3663 guid_service == IID_IAccessible2 || | 3669 guid_service == IID_IAccessible2 || |
3664 guid_service == IID_IAccessibleAction || | 3670 guid_service == IID_IAccessibleAction || |
3665 guid_service == IID_IAccessibleApplication || | 3671 guid_service == IID_IAccessibleApplication || |
3666 guid_service == IID_IAccessibleHyperlink || | 3672 guid_service == IID_IAccessibleHyperlink || |
3667 guid_service == IID_IAccessibleHypertext || | 3673 guid_service == IID_IAccessibleHypertext || |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4006 win_attributes_->ia2_attributes.push_back(L"current:date"); | 4012 win_attributes_->ia2_attributes.push_back(L"current:date"); |
4007 break; | 4013 break; |
4008 case ui::AX_ARIA_CURRENT_STATE_TIME: | 4014 case ui::AX_ARIA_CURRENT_STATE_TIME: |
4009 win_attributes_->ia2_attributes.push_back(L"current:time"); | 4015 win_attributes_->ia2_attributes.push_back(L"current:time"); |
4010 break; | 4016 break; |
4011 } | 4017 } |
4012 } | 4018 } |
4013 | 4019 |
4014 // Expose table cell index. | 4020 // Expose table cell index. |
4015 if (IsCellOrTableHeaderRole()) { | 4021 if (IsCellOrTableHeaderRole()) { |
4016 BrowserAccessibility* table = GetParent(); | 4022 BrowserAccessibility* table = GetAccessibilityParent(); |
4017 while (table && table->GetRole() != ui::AX_ROLE_TABLE) | 4023 while (table && table->GetRole() != ui::AX_ROLE_TABLE) |
4018 table = table->GetParent(); | 4024 table = table->GetAccessibilityParent(); |
4019 if (table) { | 4025 if (table) { |
4020 const std::vector<int32_t>& unique_cell_ids = | 4026 const std::vector<int32_t>& unique_cell_ids = |
4021 table->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); | 4027 table->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); |
4022 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { | 4028 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { |
4023 if (unique_cell_ids[i] == GetId()) { | 4029 if (unique_cell_ids[i] == GetId()) { |
4024 win_attributes_->ia2_attributes.push_back( | 4030 win_attributes_->ia2_attributes.push_back( |
4025 base::string16(L"table-cell-index:") + base::IntToString16(i)); | 4031 base::string16(L"table-cell-index:") + base::IntToString16(i)); |
4026 } | 4032 } |
4027 } | 4033 } |
4028 } | 4034 } |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4175 FireNativeEvent(EVENT_OBJECT_VALUECHANGE); | 4181 FireNativeEvent(EVENT_OBJECT_VALUECHANGE); |
4176 if (ia_state() != old_win_attributes_->ia_state) | 4182 if (ia_state() != old_win_attributes_->ia_state) |
4177 FireNativeEvent(EVENT_OBJECT_STATECHANGE); | 4183 FireNativeEvent(EVENT_OBJECT_STATECHANGE); |
4178 | 4184 |
4179 // Handle selection being added or removed. | 4185 // Handle selection being added or removed. |
4180 bool is_selected_now = (ia_state() & STATE_SYSTEM_SELECTED) != 0; | 4186 bool is_selected_now = (ia_state() & STATE_SYSTEM_SELECTED) != 0; |
4181 bool was_selected_before = | 4187 bool was_selected_before = |
4182 (old_win_attributes_->ia_state & STATE_SYSTEM_SELECTED) != 0; | 4188 (old_win_attributes_->ia_state & STATE_SYSTEM_SELECTED) != 0; |
4183 if (is_selected_now || was_selected_before) { | 4189 if (is_selected_now || was_selected_before) { |
4184 bool multiselect = false; | 4190 bool multiselect = false; |
4185 if (GetParent() && GetParent()->HasState(ui::AX_STATE_MULTISELECTABLE)) | 4191 if (GetAccessibilityParent() && |
| 4192 GetAccessibilityParent()->HasState(ui::AX_STATE_MULTISELECTABLE)) |
4186 multiselect = true; | 4193 multiselect = true; |
4187 | 4194 |
4188 if (multiselect) { | 4195 if (multiselect) { |
4189 // In a multi-select box, fire SELECTIONADD and SELECTIONREMOVE events. | 4196 // In a multi-select box, fire SELECTIONADD and SELECTIONREMOVE events. |
4190 if (is_selected_now && !was_selected_before) { | 4197 if (is_selected_now && !was_selected_before) { |
4191 FireNativeEvent(EVENT_OBJECT_SELECTIONADD); | 4198 FireNativeEvent(EVENT_OBJECT_SELECTIONADD); |
4192 } else if (!is_selected_now && was_selected_before) { | 4199 } else if (!is_selected_now && was_selected_before) { |
4193 FireNativeEvent(EVENT_OBJECT_SELECTIONREMOVE); | 4200 FireNativeEvent(EVENT_OBJECT_SELECTIONREMOVE); |
4194 } | 4201 } |
4195 } else if (is_selected_now && !was_selected_before) { | 4202 } else if (is_selected_now && !was_selected_before) { |
(...skipping 22 matching lines...) Expand all Loading... |
4218 FireNativeEvent(IA2_EVENT_TEXT_REMOVED); | 4225 FireNativeEvent(IA2_EVENT_TEXT_REMOVED); |
4219 } | 4226 } |
4220 if (new_len > 0) { | 4227 if (new_len > 0) { |
4221 // In-process screen readers may call IAccessibleText::get_newText | 4228 // In-process screen readers may call IAccessibleText::get_newText |
4222 // in reaction to this event to retrieve the text that was inserted. | 4229 // in reaction to this event to retrieve the text that was inserted. |
4223 FireNativeEvent(IA2_EVENT_TEXT_INSERTED); | 4230 FireNativeEvent(IA2_EVENT_TEXT_INSERTED); |
4224 } | 4231 } |
4225 | 4232 |
4226 // Changing a static text node can affect the IAccessibleText hypertext | 4233 // Changing a static text node can affect the IAccessibleText hypertext |
4227 // of the parent node, so force an update on the parent. | 4234 // of the parent node, so force an update on the parent. |
4228 BrowserAccessibilityWin* parent = ToBrowserAccessibilityWin(GetParent()); | 4235 BrowserAccessibilityWin* parent = |
| 4236 ToBrowserAccessibilityWin(GetAccessibilityParent()); |
4229 if (parent && IsTextOnlyObject() && | 4237 if (parent && IsTextOnlyObject() && |
4230 name() != old_win_attributes_->name) { | 4238 name() != old_win_attributes_->name) { |
4231 parent->UpdatePlatformAttributes(); | 4239 parent->UpdatePlatformAttributes(); |
4232 } | 4240 } |
4233 } | 4241 } |
4234 | 4242 |
4235 old_win_attributes_.reset(nullptr); | 4243 old_win_attributes_.reset(nullptr); |
4236 } | 4244 } |
4237 | 4245 |
4238 void BrowserAccessibilityWin::UpdatePlatformAttributes() { | 4246 void BrowserAccessibilityWin::UpdatePlatformAttributes() { |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4583 int value; | 4591 int value; |
4584 if (GetIntAttribute(attribute, &value)) { | 4592 if (GetIntAttribute(attribute, &value)) { |
4585 win_attributes_->ia2_attributes.push_back( | 4593 win_attributes_->ia2_attributes.push_back( |
4586 base::ASCIIToUTF16(ia2_attr) + L":" + | 4594 base::ASCIIToUTF16(ia2_attr) + L":" + |
4587 base::IntToString16(value)); | 4595 base::IntToString16(value)); |
4588 } | 4596 } |
4589 } | 4597 } |
4590 | 4598 |
4591 bool BrowserAccessibilityWin::IsHyperlink() const { | 4599 bool BrowserAccessibilityWin::IsHyperlink() const { |
4592 int32_t hyperlink_index = -1; | 4600 int32_t hyperlink_index = -1; |
4593 auto* parent = GetParent(); | 4601 auto* parent = GetAccessibilityParent(); |
4594 if (parent) { | 4602 if (parent) { |
4595 hyperlink_index = | 4603 hyperlink_index = |
4596 ToBrowserAccessibilityWin(parent)->GetHyperlinkIndexFromChild(*this); | 4604 ToBrowserAccessibilityWin(parent)->GetHyperlinkIndexFromChild(*this); |
4597 } | 4605 } |
4598 | 4606 |
4599 if (hyperlink_index >= 0) | 4607 if (hyperlink_index >= 0) |
4600 return true; | 4608 return true; |
4601 return false; | 4609 return false; |
4602 } | 4610 } |
4603 | 4611 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4637 for (auto& offset_index : hyperlink_offset_to_index()) { | 4645 for (auto& offset_index : hyperlink_offset_to_index()) { |
4638 if (offset_index.second == hyperlink_index) | 4646 if (offset_index.second == hyperlink_index) |
4639 return offset_index.first; | 4647 return offset_index.first; |
4640 } | 4648 } |
4641 | 4649 |
4642 return -1; | 4650 return -1; |
4643 } | 4651 } |
4644 | 4652 |
4645 int32_t BrowserAccessibilityWin::GetHypertextOffsetFromChild( | 4653 int32_t BrowserAccessibilityWin::GetHypertextOffsetFromChild( |
4646 const BrowserAccessibilityWin& child) const { | 4654 const BrowserAccessibilityWin& child) const { |
4647 DCHECK(child.GetParent() == this); | 4655 DCHECK(child.GetAccessibilityParent() == this); |
4648 | 4656 |
4649 // Handle the case when we are dealing with a direct text-only child. | 4657 // Handle the case when we are dealing with a direct text-only child. |
4650 // (Note that this object might be a platform leaf, e.g. an ARIA searchbox, | 4658 // (Note that this object might be a platform leaf, e.g. an ARIA searchbox, |
4651 // and so |InternalChild...| functions need to be used. Also, direct text-only | 4659 // and so |InternalChild...| functions need to be used. Also, direct text-only |
4652 // children should not be present at tree roots and so no cross-tree traversal | 4660 // children should not be present at tree roots and so no cross-tree traversal |
4653 // is necessary.) | 4661 // is necessary.) |
4654 if (child.IsTextOnlyObject()) { | 4662 if (child.IsTextOnlyObject()) { |
4655 int32_t hypertextOffset = 0; | 4663 int32_t hypertextOffset = 0; |
4656 int32_t index_in_parent = child.GetIndexInParent(); | 4664 int32_t index_in_parent = child.GetIndexInParent(); |
4657 DCHECK_GE(index_in_parent, 0); | 4665 DCHECK_GE(index_in_parent, 0); |
(...skipping 12 matching lines...) Expand all Loading... |
4670 | 4678 |
4671 int32_t hyperlink_index = GetHyperlinkIndexFromChild(child); | 4679 int32_t hyperlink_index = GetHyperlinkIndexFromChild(child); |
4672 if (hyperlink_index < 0) | 4680 if (hyperlink_index < 0) |
4673 return -1; | 4681 return -1; |
4674 | 4682 |
4675 return GetHypertextOffsetFromHyperlinkIndex(hyperlink_index); | 4683 return GetHypertextOffsetFromHyperlinkIndex(hyperlink_index); |
4676 } | 4684 } |
4677 | 4685 |
4678 int32_t BrowserAccessibilityWin::GetHypertextOffsetFromDescendant( | 4686 int32_t BrowserAccessibilityWin::GetHypertextOffsetFromDescendant( |
4679 const BrowserAccessibilityWin& descendant) const { | 4687 const BrowserAccessibilityWin& descendant) const { |
4680 auto* parent_object = ToBrowserAccessibilityWin(descendant.GetParent()); | 4688 auto* parent_object = |
| 4689 ToBrowserAccessibilityWin(descendant.GetAccessibilityParent()); |
4681 auto* current_object = const_cast<BrowserAccessibilityWin*>(&descendant); | 4690 auto* current_object = const_cast<BrowserAccessibilityWin*>(&descendant); |
4682 while (parent_object && parent_object != this) { | 4691 while (parent_object && parent_object != this) { |
4683 current_object = parent_object; | 4692 current_object = parent_object; |
4684 parent_object = ToBrowserAccessibilityWin(current_object->GetParent()); | 4693 parent_object = |
| 4694 ToBrowserAccessibilityWin(current_object->GetAccessibilityParent()); |
4685 } | 4695 } |
4686 if (!parent_object) | 4696 if (!parent_object) |
4687 return -1; | 4697 return -1; |
4688 | 4698 |
4689 return parent_object->GetHypertextOffsetFromChild(*current_object); | 4699 return parent_object->GetHypertextOffsetFromChild(*current_object); |
4690 } | 4700 } |
4691 | 4701 |
4692 int BrowserAccessibilityWin::GetHypertextOffsetFromEndpoint( | 4702 int BrowserAccessibilityWin::GetHypertextOffsetFromEndpoint( |
4693 const BrowserAccessibilityWin& endpoint_object, | 4703 const BrowserAccessibilityWin& endpoint_object, |
4694 int endpoint_offset) const { | 4704 int endpoint_offset) const { |
(...skipping 10 matching lines...) Expand all Loading... |
4705 // Case 1. | 4715 // Case 1. |
4706 // | 4716 // |
4707 // IsDescendantOf includes the case when endpoint_object == this. | 4717 // IsDescendantOf includes the case when endpoint_object == this. |
4708 if (IsDescendantOf(&endpoint_object)) | 4718 if (IsDescendantOf(&endpoint_object)) |
4709 return endpoint_offset; | 4719 return endpoint_offset; |
4710 | 4720 |
4711 const BrowserAccessibility* common_parent = this; | 4721 const BrowserAccessibility* common_parent = this; |
4712 int32_t index_in_common_parent = GetIndexInParent(); | 4722 int32_t index_in_common_parent = GetIndexInParent(); |
4713 while (common_parent && !endpoint_object.IsDescendantOf(common_parent)) { | 4723 while (common_parent && !endpoint_object.IsDescendantOf(common_parent)) { |
4714 index_in_common_parent = common_parent->GetIndexInParent(); | 4724 index_in_common_parent = common_parent->GetIndexInParent(); |
4715 common_parent = common_parent->GetParent(); | 4725 common_parent = common_parent->GetAccessibilityParent(); |
4716 } | 4726 } |
4717 if (!common_parent) | 4727 if (!common_parent) |
4718 return -1; | 4728 return -1; |
4719 | 4729 |
4720 DCHECK_GE(index_in_common_parent, 0); | 4730 DCHECK_GE(index_in_common_parent, 0); |
4721 DCHECK(!(common_parent->IsTextOnlyObject())); | 4731 DCHECK(!(common_parent->IsTextOnlyObject())); |
4722 | 4732 |
4723 // Case 2. | 4733 // Case 2. |
4724 // | 4734 // |
4725 // We already checked in case 1 if our endpoint is inside this object. | 4735 // We already checked in case 1 if our endpoint is inside this object. |
4726 // We can safely assume that it is a descendant or in a completely different | 4736 // We can safely assume that it is a descendant or in a completely different |
4727 // part of the tree. | 4737 // part of the tree. |
4728 if (common_parent == this) { | 4738 if (common_parent == this) { |
4729 int32_t hypertext_offset = | 4739 int32_t hypertext_offset = |
4730 GetHypertextOffsetFromDescendant(endpoint_object); | 4740 GetHypertextOffsetFromDescendant(endpoint_object); |
4731 if (endpoint_object.GetParent() == this && | 4741 if (endpoint_object.GetAccessibilityParent() == this && |
4732 endpoint_object.IsTextOnlyObject()) { | 4742 endpoint_object.IsTextOnlyObject()) { |
4733 hypertext_offset += endpoint_offset; | 4743 hypertext_offset += endpoint_offset; |
4734 } | 4744 } |
4735 | 4745 |
4736 return hypertext_offset; | 4746 return hypertext_offset; |
4737 } | 4747 } |
4738 | 4748 |
4739 // Case 3. | 4749 // Case 3. |
4740 // | 4750 // |
4741 // We can safely assume that the endpoint is in another part of the tree or | 4751 // We can safely assume that the endpoint is in another part of the tree or |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4997 return start_offset; | 5007 return start_offset; |
4998 } | 5008 } |
4999 | 5009 |
5000 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromID(int32_t id) const { | 5010 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromID(int32_t id) const { |
5001 if (!instance_active()) | 5011 if (!instance_active()) |
5002 return nullptr; | 5012 return nullptr; |
5003 return ToBrowserAccessibilityWin(manager_->GetFromID(id)); | 5013 return ToBrowserAccessibilityWin(manager_->GetFromID(id)); |
5004 } | 5014 } |
5005 | 5015 |
5006 bool BrowserAccessibilityWin::IsListBoxOptionOrMenuListOption() { | 5016 bool BrowserAccessibilityWin::IsListBoxOptionOrMenuListOption() { |
5007 if (!GetParent()) | 5017 if (!GetAccessibilityParent()) |
5008 return false; | 5018 return false; |
5009 | 5019 |
5010 int32_t role = GetRole(); | 5020 int32_t role = GetRole(); |
5011 int32_t parent_role = GetParent()->GetRole(); | 5021 int32_t parent_role = GetAccessibilityParent()->GetRole(); |
5012 | 5022 |
5013 if (role == ui::AX_ROLE_LIST_BOX_OPTION && | 5023 if (role == ui::AX_ROLE_LIST_BOX_OPTION && |
5014 parent_role == ui::AX_ROLE_LIST_BOX) { | 5024 parent_role == ui::AX_ROLE_LIST_BOX) { |
5015 return true; | 5025 return true; |
5016 } | 5026 } |
5017 | 5027 |
5018 if (role == ui::AX_ROLE_MENU_LIST_OPTION && | 5028 if (role == ui::AX_ROLE_MENU_LIST_OPTION && |
5019 parent_role == ui::AX_ROLE_MENU_LIST_POPUP) { | 5029 parent_role == ui::AX_ROLE_MENU_LIST_POPUP) { |
5020 return true; | 5030 return true; |
5021 } | 5031 } |
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5802 return static_cast<BrowserAccessibilityWin*>(obj); | 5812 return static_cast<BrowserAccessibilityWin*>(obj); |
5803 } | 5813 } |
5804 | 5814 |
5805 const BrowserAccessibilityWin* | 5815 const BrowserAccessibilityWin* |
5806 ToBrowserAccessibilityWin(const BrowserAccessibility* obj) { | 5816 ToBrowserAccessibilityWin(const BrowserAccessibility* obj) { |
5807 DCHECK(!obj || obj->IsNative()); | 5817 DCHECK(!obj || obj->IsNative()); |
5808 return static_cast<const BrowserAccessibilityWin*>(obj); | 5818 return static_cast<const BrowserAccessibilityWin*>(obj); |
5809 } | 5819 } |
5810 | 5820 |
5811 } // namespace content | 5821 } // namespace content |
OLD | NEW |