| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <atlbase.h> | 5 #include <atlbase.h> |
| 6 #include <atlcom.h> | 6 #include <atlcom.h> |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 #include <oleacc.h> | 8 #include <oleacc.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/strings/string_util.h" |
| 13 #include "base/win/scoped_comptr.h" | 14 #include "base/win/scoped_comptr.h" |
| 14 #include "base/win/scoped_variant.h" | 15 #include "base/win/scoped_variant.h" |
| 15 #include "third_party/iaccessible2/ia2_api_all.h" | 16 #include "third_party/iaccessible2/ia2_api_all.h" |
| 16 #include "ui/accessibility/ax_action_data.h" | 17 #include "ui/accessibility/ax_action_data.h" |
| 17 #include "ui/accessibility/ax_node_data.h" | 18 #include "ui/accessibility/ax_node_data.h" |
| 18 #include "ui/accessibility/ax_text_utils.h" | 19 #include "ui/accessibility/ax_text_utils.h" |
| 19 #include "ui/accessibility/platform/ax_platform_node_delegate.h" | 20 #include "ui/accessibility/platform/ax_platform_node_delegate.h" |
| 20 #include "ui/accessibility/platform/ax_platform_node_win.h" | 21 #include "ui/accessibility/platform/ax_platform_node_win.h" |
| 21 #include "ui/base/win/atl_module.h" | 22 #include "ui/base/win/atl_module.h" |
| 22 #include "ui/gfx/geometry/rect_conversions.h" | 23 #include "ui/gfx/geometry/rect_conversions.h" |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 } | 497 } |
| 497 | 498 |
| 498 STDMETHODIMP AXPlatformNodeWin::get_accRole( | 499 STDMETHODIMP AXPlatformNodeWin::get_accRole( |
| 499 VARIANT var_id, VARIANT* role) { | 500 VARIANT var_id, VARIANT* role) { |
| 500 AXPlatformNodeWin* target; | 501 AXPlatformNodeWin* target; |
| 501 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, role, target); | 502 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, role, target); |
| 502 | 503 |
| 503 // For historical reasons, we return a string (typically | 504 // For historical reasons, we return a string (typically |
| 504 // containing the HTML tag name) as the MSAA role, rather | 505 // containing the HTML tag name) as the MSAA role, rather |
| 505 // than a int. | 506 // than a int. |
| 506 std::string role_string = target->StringOverrideForMSAARole(); | 507 std::string role_string = |
| 508 base::ToUpperASCII(target->StringOverrideForMSAARole()); |
| 507 if (!role_string.empty()) { | 509 if (!role_string.empty()) { |
| 508 role->vt = VT_BSTR; | 510 role->vt = VT_BSTR; |
| 509 std::wstring wsTmp(role_string.begin(), role_string.end()); | 511 std::wstring wsTmp(role_string.begin(), role_string.end()); |
| 510 role->bstrVal = SysAllocString(wsTmp.c_str()); | 512 role->bstrVal = SysAllocString(wsTmp.c_str()); |
| 511 return S_OK; | 513 return S_OK; |
| 512 } | 514 } |
| 513 | 515 |
| 514 role->vt = VT_I4; | 516 role->vt = VT_I4; |
| 515 role->lVal = target->MSAARole(); | 517 role->lVal = target->MSAARole(); |
| 516 return S_OK; | 518 return S_OK; |
| (...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1373 std::string html_tag = GetData().GetStringAttribute(ui::AX_ATTR_HTML_TAG); | 1375 std::string html_tag = GetData().GetStringAttribute(ui::AX_ATTR_HTML_TAG); |
| 1374 | 1376 |
| 1375 switch (GetData().role) { | 1377 switch (GetData().role) { |
| 1376 case ui::AX_ROLE_BLOCKQUOTE: | 1378 case ui::AX_ROLE_BLOCKQUOTE: |
| 1377 case ui::AX_ROLE_DEFINITION: | 1379 case ui::AX_ROLE_DEFINITION: |
| 1378 case ui::AX_ROLE_IMAGE_MAP: | 1380 case ui::AX_ROLE_IMAGE_MAP: |
| 1379 return html_tag; | 1381 return html_tag; |
| 1380 | 1382 |
| 1381 case ui::AX_ROLE_CANVAS: | 1383 case ui::AX_ROLE_CANVAS: |
| 1382 if (GetData().GetBoolAttribute(ui::AX_ATTR_CANVAS_HAS_FALLBACK)) { | 1384 if (GetData().GetBoolAttribute(ui::AX_ATTR_CANVAS_HAS_FALLBACK)) { |
| 1383 // TODO(dougt) why not just use the html_tag? | 1385 return html_tag; |
| 1384 return "canvas"; | |
| 1385 } | 1386 } |
| 1386 break; | 1387 break; |
| 1387 | 1388 |
| 1388 case ui::AX_ROLE_FORM: | 1389 case ui::AX_ROLE_FORM: |
| 1389 // TODO(dougt) why not just use the html_tag? | 1390 // This could be a div with the role of form |
| 1391 // so we return just the string "form". |
| 1390 return "form"; | 1392 return "form"; |
| 1391 | 1393 |
| 1392 case ui::AX_ROLE_HEADING: | 1394 case ui::AX_ROLE_HEADING: |
| 1393 if (!html_tag.empty()) | 1395 if (!html_tag.empty()) |
| 1394 return html_tag; | 1396 return html_tag; |
| 1395 break; | 1397 break; |
| 1396 | 1398 |
| 1397 case ui::AX_ROLE_PARAGRAPH: | 1399 case ui::AX_ROLE_PARAGRAPH: |
| 1398 // TODO(dougt) why not just use the html_tag and why upper case? | 1400 return html_tag; |
| 1399 return "P"; | |
| 1400 | 1401 |
| 1401 case ui::AX_ROLE_GENERIC_CONTAINER: | 1402 case ui::AX_ROLE_GENERIC_CONTAINER: |
| 1402 // TODO(dougt) why can't we always use div in this case? | 1403 // TODO(dougt) why can't we always use div in this case? |
| 1403 if (html_tag.empty()) | 1404 if (html_tag.empty()) |
| 1404 return "div"; | 1405 return "div"; |
| 1405 return html_tag; | 1406 return html_tag; |
| 1406 | 1407 |
| 1407 case ui::AX_ROLE_SWITCH: | 1408 case ui::AX_ROLE_SWITCH: |
| 1408 return "switch"; | 1409 return "switch"; |
| 1409 | 1410 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1607 | 1608 |
| 1608 AXPlatformNodeBase* base = | 1609 AXPlatformNodeBase* base = |
| 1609 FromNativeViewAccessible(node->GetNativeViewAccessible()); | 1610 FromNativeViewAccessible(node->GetNativeViewAccessible()); |
| 1610 if (base && !IsDescendant(base)) | 1611 if (base && !IsDescendant(base)) |
| 1611 base = nullptr; | 1612 base = nullptr; |
| 1612 | 1613 |
| 1613 return static_cast<AXPlatformNodeWin*>(base); | 1614 return static_cast<AXPlatformNodeWin*>(base); |
| 1614 } | 1615 } |
| 1615 | 1616 |
| 1616 } // namespace ui | 1617 } // namespace ui |
| OLD | NEW |