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