Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: content/browser/accessibility/browser_accessibility_com_win.cc

Issue 2981083002: Migrate BrowserAccessibility windows unique id handling to AXPlatformNodeWin. (Closed)
Patch Set: Android fix. I was hoping I could get rid of this. Someday though! Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_STATES); 669 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_STATES);
670 if (!owner()) 670 if (!owner())
671 return E_FAIL; 671 return E_FAIL;
672 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); 672 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes);
673 673
674 return AXPlatformNodeWin::get_states(states); 674 return AXPlatformNodeWin::get_states(states);
675 } 675 }
676 676
677 STDMETHODIMP BrowserAccessibilityComWin::get_uniqueID(LONG* unique_id) { 677 STDMETHODIMP BrowserAccessibilityComWin::get_uniqueID(LONG* unique_id) {
678 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_UNIQUE_ID); 678 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_UNIQUE_ID);
679 if (!owner()) 679 return AXPlatformNodeWin::get_uniqueID(unique_id);
680 return E_FAIL;
681
682 if (!unique_id)
683 return E_INVALIDARG;
684
685 *unique_id = -owner()->unique_id();
686 return S_OK;
687 } 680 }
688 681
689 STDMETHODIMP BrowserAccessibilityComWin::get_windowHandle(HWND* window_handle) { 682 STDMETHODIMP BrowserAccessibilityComWin::get_windowHandle(HWND* window_handle) {
690 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_WINDOW_HANDLE); 683 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_WINDOW_HANDLE);
691 if (!owner()) 684 if (!owner())
692 return E_FAIL; 685 return E_FAIL;
693 686
694 if (!window_handle) 687 if (!window_handle)
695 return E_INVALIDARG; 688 return E_INVALIDARG;
696 689
(...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after
2033 if (!owner()) 2026 if (!owner())
2034 return E_FAIL; 2027 return E_FAIL;
2035 2028
2036 if (!hyperlink || index < 0 || 2029 if (!hyperlink || index < 0 ||
2037 index >= static_cast<long>(hyperlinks().size())) { 2030 index >= static_cast<long>(hyperlinks().size())) {
2038 return E_INVALIDARG; 2031 return E_INVALIDARG;
2039 } 2032 }
2040 2033
2041 int32_t id = hyperlinks()[index]; 2034 int32_t id = hyperlinks()[index];
2042 BrowserAccessibilityComWin* link = 2035 BrowserAccessibilityComWin* link =
2043 ToBrowserAccessibilityComWin(owner()->GetFromUniqueID(id)); 2036 static_cast<BrowserAccessibilityComWin*>(GetFromUniqueId(id));
2044 if (!link) 2037 if (!link)
2045 return E_FAIL; 2038 return E_FAIL;
2046 2039 link->AddRef();
2047 *hyperlink = static_cast<IAccessibleHyperlink*>(link->NewReference()); 2040 *hyperlink = static_cast<IAccessibleHyperlink*>(link);
2048 return S_OK; 2041 return S_OK;
2049 } 2042 }
2050 2043
2051 STDMETHODIMP BrowserAccessibilityComWin::get_hyperlinkIndex( 2044 STDMETHODIMP BrowserAccessibilityComWin::get_hyperlinkIndex(
2052 long char_index, 2045 long char_index,
2053 long* hyperlink_index) { 2046 long* hyperlink_index) {
2054 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_HYPERLINK_INDEX); 2047 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_HYPERLINK_INDEX);
2055 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); 2048 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes);
2056 if (!owner()) 2049 if (!owner())
2057 return E_FAIL; 2050 return E_FAIL;
(...skipping 1485 matching lines...) Expand 10 before | Expand all | Expand 10 after
3543 // Detach BrowserAccessibilityWin from us. 3536 // Detach BrowserAccessibilityWin from us.
3544 owner_ = nullptr; 3537 owner_ = nullptr;
3545 AXPlatformNodeWin::Destroy(); 3538 AXPlatformNodeWin::Destroy();
3546 } 3539 }
3547 3540
3548 void BrowserAccessibilityComWin::Init(ui::AXPlatformNodeDelegate* delegate) { 3541 void BrowserAccessibilityComWin::Init(ui::AXPlatformNodeDelegate* delegate) {
3549 owner_ = static_cast<BrowserAccessibilityWin*>(delegate); 3542 owner_ = static_cast<BrowserAccessibilityWin*>(delegate);
3550 AXPlatformNodeBase::Init(delegate); 3543 AXPlatformNodeBase::Init(delegate);
3551 } 3544 }
3552 3545
3553 ui::AXPlatformNode* BrowserAccessibilityComWin::GetFromUniqueId(
3554 int32_t unique_id) {
3555 return ToBrowserAccessibilityComWin(
3556 BrowserAccessibility::GetFromUniqueID(unique_id));
3557 }
3558
3559 std::vector<base::string16> BrowserAccessibilityComWin::ComputeTextAttributes() 3546 std::vector<base::string16> BrowserAccessibilityComWin::ComputeTextAttributes()
3560 const { 3547 const {
3561 std::vector<base::string16> attributes; 3548 std::vector<base::string16> attributes;
3562 3549
3563 // We include list markers for now, but there might be other objects that are 3550 // We include list markers for now, but there might be other objects that are
3564 // auto generated. 3551 // auto generated.
3565 // TODO(nektar): Compute what objects are auto-generated in Blink. 3552 // TODO(nektar): Compute what objects are auto-generated in Blink.
3566 if (owner()->GetRole() == ui::AX_ROLE_LIST_MARKER) 3553 if (owner()->GetRole() == ui::AX_ROLE_LIST_MARKER)
3567 attributes.push_back(L"auto-generated:true"); 3554 attributes.push_back(L"auto-generated:true");
3568 else 3555 else
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
3797 3784
3798 LONG child_id = var_id.lVal; 3785 LONG child_id = var_id.lVal;
3799 if (child_id == CHILDID_SELF) 3786 if (child_id == CHILDID_SELF)
3800 return this; 3787 return this;
3801 3788
3802 if (child_id >= 1 && 3789 if (child_id >= 1 &&
3803 child_id <= static_cast<LONG>(owner()->PlatformChildCount())) 3790 child_id <= static_cast<LONG>(owner()->PlatformChildCount()))
3804 return ToBrowserAccessibilityComWin( 3791 return ToBrowserAccessibilityComWin(
3805 owner()->PlatformGetChild(child_id - 1)); 3792 owner()->PlatformGetChild(child_id - 1));
3806 3793
3807 BrowserAccessibilityComWin* child = ToBrowserAccessibilityComWin( 3794 BrowserAccessibilityComWin* child =
3808 BrowserAccessibility::GetFromUniqueID(-child_id)); 3795 static_cast<BrowserAccessibilityComWin*>(GetFromUniqueId(-child_id));
3809 if (child && child->owner()->IsDescendantOf(owner())) 3796 if (child && child->owner()->IsDescendantOf(owner()))
3810 return child; 3797 return child;
3811 3798
3812 return nullptr; 3799 return nullptr;
3813 } 3800 }
3814 3801
3815 HRESULT BrowserAccessibilityComWin::GetStringAttributeAsBstr( 3802 HRESULT BrowserAccessibilityComWin::GetStringAttributeAsBstr(
3816 ui::AXStringAttribute attribute, 3803 ui::AXStringAttribute attribute,
3817 BSTR* value_bstr) { 3804 BSTR* value_bstr) {
3818 base::string16 str; 3805 base::string16 str;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
3903 std::map<int32_t, int32_t>::iterator iterator = 3890 std::map<int32_t, int32_t>::iterator iterator =
3904 hyperlink_offset_to_index().find(offset); 3891 hyperlink_offset_to_index().find(offset);
3905 if (iterator == hyperlink_offset_to_index().end()) 3892 if (iterator == hyperlink_offset_to_index().end())
3906 return nullptr; 3893 return nullptr;
3907 3894
3908 int32_t index = iterator->second; 3895 int32_t index = iterator->second;
3909 DCHECK_GE(index, 0); 3896 DCHECK_GE(index, 0);
3910 DCHECK_LT(index, static_cast<int32_t>(hyperlinks().size())); 3897 DCHECK_LT(index, static_cast<int32_t>(hyperlinks().size()));
3911 int32_t id = hyperlinks()[index]; 3898 int32_t id = hyperlinks()[index];
3912 BrowserAccessibilityComWin* hyperlink = 3899 BrowserAccessibilityComWin* hyperlink =
3913 ToBrowserAccessibilityComWin(owner()->GetFromUniqueID(id)); 3900 static_cast<BrowserAccessibilityComWin*>(GetFromUniqueId(id));
3901
3914 if (!hyperlink) 3902 if (!hyperlink)
3915 return nullptr; 3903 return nullptr;
3916 return hyperlink; 3904 return hyperlink;
3917 } 3905 }
3918 3906
3919 int32_t BrowserAccessibilityComWin::GetHyperlinkIndexFromChild( 3907 int32_t BrowserAccessibilityComWin::GetHyperlinkIndexFromChild(
3920 const BrowserAccessibilityComWin& child) const { 3908 const BrowserAccessibilityComWin& child) const {
3921 if (hyperlinks().empty()) 3909 if (hyperlinks().empty())
3922 return -1; 3910 return -1;
3923 3911
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
4583 4571
4584 BrowserAccessibilityComWin* ToBrowserAccessibilityComWin( 4572 BrowserAccessibilityComWin* ToBrowserAccessibilityComWin(
4585 BrowserAccessibility* obj) { 4573 BrowserAccessibility* obj) {
4586 if (!obj || !obj->IsNative()) 4574 if (!obj || !obj->IsNative())
4587 return nullptr; 4575 return nullptr;
4588 auto* result = static_cast<BrowserAccessibilityWin*>(obj)->GetCOM(); 4576 auto* result = static_cast<BrowserAccessibilityWin*>(obj)->GetCOM();
4589 return result; 4577 return result;
4590 } 4578 }
4591 4579
4592 } // namespace content 4580 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698