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 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 return false; | 663 return false; |
664 } | 664 } |
665 } | 665 } |
666 | 666 |
667 STDMETHODIMP BrowserAccessibilityComWin::get_accValue(VARIANT var_id, | 667 STDMETHODIMP BrowserAccessibilityComWin::get_accValue(VARIANT var_id, |
668 BSTR* value) { | 668 BSTR* value) { |
669 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_VALUE); | 669 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_VALUE); |
670 if (!owner()) | 670 if (!owner()) |
671 return E_FAIL; | 671 return E_FAIL; |
672 | 672 |
673 if (!value) | 673 return AXPlatformNodeWin::get_accValue(var_id, value); |
674 return E_INVALIDARG; | |
675 | |
676 BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); | |
677 if (!target) | |
678 return E_INVALIDARG; | |
679 | |
680 if (target->IsRangeValueSupported()) { | |
681 base::string16 value_text = target->GetRangeValueText(); | |
682 *value = SysAllocString(value_text.c_str()); | |
683 DCHECK(*value); | |
684 return S_OK; | |
685 } | |
686 | |
687 // Expose color well value. | |
688 if (target->ia2_role() == IA2_ROLE_COLOR_CHOOSER) { | |
689 unsigned int color = static_cast<unsigned int>( | |
690 target->owner()->GetIntAttribute(ui::AX_ATTR_COLOR_VALUE)); | |
691 unsigned int red = SkColorGetR(color); | |
692 unsigned int green = SkColorGetG(color); | |
693 unsigned int blue = SkColorGetB(color); | |
694 base::string16 value_text; | |
695 value_text = base::UintToString16(red * 100 / 255) + L"% red " + | |
696 base::UintToString16(green * 100 / 255) + L"% green " + | |
697 base::UintToString16(blue * 100 / 255) + L"% blue"; | |
698 *value = SysAllocString(value_text.c_str()); | |
699 DCHECK(*value); | |
700 return S_OK; | |
701 } | |
702 | |
703 *value = SysAllocString(target->value().c_str()); | |
704 DCHECK(*value); | |
705 return S_OK; | |
706 } | 674 } |
707 | 675 |
708 STDMETHODIMP BrowserAccessibilityComWin::get_accHelpTopic(BSTR* help_file, | 676 STDMETHODIMP BrowserAccessibilityComWin::get_accHelpTopic(BSTR* help_file, |
709 VARIANT var_id, | 677 VARIANT var_id, |
710 LONG* topic_id) { | 678 LONG* topic_id) { |
711 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_HELP_TOPIC); | 679 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_HELP_TOPIC); |
712 return E_NOTIMPL; | 680 return AXPlatformNodeWin::get_accHelpTopic(help_file, var_id, topic_id); |
713 } | 681 } |
714 | 682 |
715 STDMETHODIMP BrowserAccessibilityComWin::get_accSelection(VARIANT* selected) { | 683 STDMETHODIMP BrowserAccessibilityComWin::get_accSelection(VARIANT* selected) { |
716 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_SELECTION); | 684 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_SELECTION); |
717 if (!owner()) | 685 if (!owner()) |
718 return E_FAIL; | 686 return E_FAIL; |
719 | 687 |
720 if (owner()->GetRole() != ui::AX_ROLE_LIST_BOX) | 688 if (owner()->GetRole() != ui::AX_ROLE_LIST_BOX) |
721 return E_NOTIMPL; | 689 return E_NOTIMPL; |
722 | 690 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 VARIANT var_id) { | 735 VARIANT var_id) { |
768 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_SELECT); | 736 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_SELECT); |
769 if (!owner()) | 737 if (!owner()) |
770 return E_FAIL; | 738 return E_FAIL; |
771 | 739 |
772 return AXPlatformNodeWin::accSelect(flags_sel, var_id); | 740 return AXPlatformNodeWin::accSelect(flags_sel, var_id); |
773 } | 741 } |
774 | 742 |
775 STDMETHODIMP | 743 STDMETHODIMP |
776 BrowserAccessibilityComWin::put_accName(VARIANT var_id, BSTR put_name) { | 744 BrowserAccessibilityComWin::put_accName(VARIANT var_id, BSTR put_name) { |
777 return E_NOTIMPL; | 745 if (!owner()) |
| 746 return E_FAIL; |
| 747 |
| 748 return AXPlatformNodeWin::put_accName(var_id, put_name); |
778 } | 749 } |
779 STDMETHODIMP | 750 STDMETHODIMP |
780 BrowserAccessibilityComWin::put_accValue(VARIANT var_id, BSTR put_val) { | 751 BrowserAccessibilityComWin::put_accValue(VARIANT var_id, BSTR put_val) { |
781 return E_NOTIMPL; | 752 if (!owner()) |
| 753 return E_FAIL; |
| 754 |
| 755 return AXPlatformNodeWin::put_accValue(var_id, put_val); |
782 } | 756 } |
783 | 757 |
784 // | 758 // |
785 // IAccessible2 methods. | 759 // IAccessible2 methods. |
786 // | 760 // |
787 | 761 |
788 STDMETHODIMP BrowserAccessibilityComWin::role(LONG* role) { | 762 STDMETHODIMP BrowserAccessibilityComWin::role(LONG* role) { |
789 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ROLE); | 763 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ROLE); |
790 if (!owner()) | 764 if (!owner()) |
791 return E_FAIL; | 765 return E_FAIL; |
(...skipping 4804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5596 | 5570 |
5597 BrowserAccessibilityComWin* ToBrowserAccessibilityComWin( | 5571 BrowserAccessibilityComWin* ToBrowserAccessibilityComWin( |
5598 BrowserAccessibility* obj) { | 5572 BrowserAccessibility* obj) { |
5599 if (!obj || !obj->IsNative()) | 5573 if (!obj || !obj->IsNative()) |
5600 return nullptr; | 5574 return nullptr; |
5601 auto* result = static_cast<BrowserAccessibilityWin*>(obj)->GetCOM(); | 5575 auto* result = static_cast<BrowserAccessibilityWin*>(obj)->GetCOM(); |
5602 return result; | 5576 return result; |
5603 } | 5577 } |
5604 | 5578 |
5605 } // namespace content | 5579 } // namespace content |
OLD | NEW |