| OLD | NEW |
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 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_com_win.h" | 5 #include "content/browser/accessibility/browser_accessibility_com_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 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 return false; | 658 return false; |
| 659 } | 659 } |
| 660 } | 660 } |
| 661 | 661 |
| 662 STDMETHODIMP BrowserAccessibilityComWin::get_accValue(VARIANT var_id, | 662 STDMETHODIMP BrowserAccessibilityComWin::get_accValue(VARIANT var_id, |
| 663 BSTR* value) { | 663 BSTR* value) { |
| 664 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_VALUE); | 664 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_VALUE); |
| 665 if (!owner()) | 665 if (!owner()) |
| 666 return E_FAIL; | 666 return E_FAIL; |
| 667 | 667 |
| 668 if (!value) | 668 return AXPlatformNodeWin::get_accValue(var_id, value); |
| 669 return E_INVALIDARG; | |
| 670 | |
| 671 BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); | |
| 672 if (!target) | |
| 673 return E_INVALIDARG; | |
| 674 | |
| 675 if (target->IsRangeValueSupported()) { | |
| 676 base::string16 value_text = target->GetRangeValueText(); | |
| 677 *value = SysAllocString(value_text.c_str()); | |
| 678 DCHECK(*value); | |
| 679 return S_OK; | |
| 680 } | |
| 681 | |
| 682 // Expose color well value. | |
| 683 if (target->ia2_role() == IA2_ROLE_COLOR_CHOOSER) { | |
| 684 unsigned int color = static_cast<unsigned int>( | |
| 685 target->owner()->GetIntAttribute(ui::AX_ATTR_COLOR_VALUE)); | |
| 686 unsigned int red = SkColorGetR(color); | |
| 687 unsigned int green = SkColorGetG(color); | |
| 688 unsigned int blue = SkColorGetB(color); | |
| 689 base::string16 value_text; | |
| 690 value_text = base::UintToString16(red * 100 / 255) + L"% red " + | |
| 691 base::UintToString16(green * 100 / 255) + L"% green " + | |
| 692 base::UintToString16(blue * 100 / 255) + L"% blue"; | |
| 693 *value = SysAllocString(value_text.c_str()); | |
| 694 DCHECK(*value); | |
| 695 return S_OK; | |
| 696 } | |
| 697 | |
| 698 *value = SysAllocString(target->value().c_str()); | |
| 699 DCHECK(*value); | |
| 700 return S_OK; | |
| 701 } | 669 } |
| 702 | 670 |
| 703 STDMETHODIMP BrowserAccessibilityComWin::get_accHelpTopic(BSTR* help_file, | 671 STDMETHODIMP BrowserAccessibilityComWin::get_accHelpTopic(BSTR* help_file, |
| 704 VARIANT var_id, | 672 VARIANT var_id, |
| 705 LONG* topic_id) { | 673 LONG* topic_id) { |
| 706 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_HELP_TOPIC); | 674 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_HELP_TOPIC); |
| 707 return E_NOTIMPL; | 675 return AXPlatformNodeWin::get_accHelpTopic(help_file, var_id, topic_id); |
| 708 } | 676 } |
| 709 | 677 |
| 710 STDMETHODIMP BrowserAccessibilityComWin::get_accSelection(VARIANT* selected) { | 678 STDMETHODIMP BrowserAccessibilityComWin::get_accSelection(VARIANT* selected) { |
| 711 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_SELECTION); | 679 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_SELECTION); |
| 712 if (!owner()) | 680 if (!owner()) |
| 713 return E_FAIL; | 681 return E_FAIL; |
| 714 | 682 |
| 715 if (owner()->GetRole() != ui::AX_ROLE_LIST_BOX) | 683 if (owner()->GetRole() != ui::AX_ROLE_LIST_BOX) |
| 716 return E_NOTIMPL; | 684 return E_NOTIMPL; |
| 717 | 685 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 VARIANT var_id) { | 730 VARIANT var_id) { |
| 763 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_SELECT); | 731 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_SELECT); |
| 764 if (!owner()) | 732 if (!owner()) |
| 765 return E_FAIL; | 733 return E_FAIL; |
| 766 | 734 |
| 767 return AXPlatformNodeWin::accSelect(flags_sel, var_id); | 735 return AXPlatformNodeWin::accSelect(flags_sel, var_id); |
| 768 } | 736 } |
| 769 | 737 |
| 770 STDMETHODIMP | 738 STDMETHODIMP |
| 771 BrowserAccessibilityComWin::put_accName(VARIANT var_id, BSTR put_name) { | 739 BrowserAccessibilityComWin::put_accName(VARIANT var_id, BSTR put_name) { |
| 772 return E_NOTIMPL; | 740 if (!owner()) |
| 741 return E_FAIL; |
| 742 |
| 743 return AXPlatformNodeWin::put_accName(var_id, put_name); |
| 773 } | 744 } |
| 774 STDMETHODIMP | 745 STDMETHODIMP |
| 775 BrowserAccessibilityComWin::put_accValue(VARIANT var_id, BSTR put_val) { | 746 BrowserAccessibilityComWin::put_accValue(VARIANT var_id, BSTR put_val) { |
| 776 return E_NOTIMPL; | 747 if (!owner()) |
| 748 return E_FAIL; |
| 749 |
| 750 return AXPlatformNodeWin::put_accValue(var_id, put_val); |
| 777 } | 751 } |
| 778 | 752 |
| 779 // | 753 // |
| 780 // IAccessible2 methods. | 754 // IAccessible2 methods. |
| 781 // | 755 // |
| 782 | 756 |
| 783 STDMETHODIMP BrowserAccessibilityComWin::role(LONG* role) { | 757 STDMETHODIMP BrowserAccessibilityComWin::role(LONG* role) { |
| 784 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ROLE); | 758 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ROLE); |
| 785 if (!owner()) | 759 if (!owner()) |
| 786 return E_FAIL; | 760 return E_FAIL; |
| (...skipping 4804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5591 | 5565 |
| 5592 BrowserAccessibilityComWin* ToBrowserAccessibilityComWin( | 5566 BrowserAccessibilityComWin* ToBrowserAccessibilityComWin( |
| 5593 BrowserAccessibility* obj) { | 5567 BrowserAccessibility* obj) { |
| 5594 if (!obj || !obj->IsNative()) | 5568 if (!obj || !obj->IsNative()) |
| 5595 return nullptr; | 5569 return nullptr; |
| 5596 auto* result = static_cast<BrowserAccessibilityWin*>(obj)->GetCOM(); | 5570 auto* result = static_cast<BrowserAccessibilityWin*>(obj)->GetCOM(); |
| 5597 return result; | 5571 return result; |
| 5598 } | 5572 } |
| 5599 | 5573 |
| 5600 } // namespace content | 5574 } // namespace content |
| OLD | NEW |