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

Side by Side Diff: ui/accessibility/platform/ax_platform_node_win.cc

Issue 2942413003: Forward BrowserAccessibility::get_accSelection to AXPlatformNode. (Closed)
Patch Set: Break up tests and add a case for mutiple selection 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 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_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "base/win/enum_variant.h"
16 #include "base/win/scoped_comptr.h" 17 #include "base/win/scoped_comptr.h"
17 #include "base/win/scoped_variant.h" 18 #include "base/win/scoped_variant.h"
18 #include "third_party/iaccessible2/ia2_api_all.h" 19 #include "third_party/iaccessible2/ia2_api_all.h"
19 #include "third_party/skia/include/core/SkColor.h" 20 #include "third_party/skia/include/core/SkColor.h"
20 #include "ui/accessibility/ax_action_data.h" 21 #include "ui/accessibility/ax_action_data.h"
21 #include "ui/accessibility/ax_node_data.h" 22 #include "ui/accessibility/ax_node_data.h"
22 #include "ui/accessibility/ax_text_utils.h" 23 #include "ui/accessibility/ax_text_utils.h"
23 #include "ui/accessibility/ax_tree_data.h" 24 #include "ui/accessibility/ax_tree_data.h"
24 #include "ui/accessibility/platform/ax_platform_node_delegate.h" 25 #include "ui/accessibility/platform/ax_platform_node_delegate.h"
25 #include "ui/accessibility/platform/ax_platform_node_win.h" 26 #include "ui/accessibility/platform/ax_platform_node_win.h"
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 AXActionData data; 631 AXActionData data;
631 data.action = ui::AX_ACTION_SET_VALUE; 632 data.action = ui::AX_ACTION_SET_VALUE;
632 data.value = new_value; 633 data.value = new_value;
633 if (target->delegate_->AccessibilityPerformAction(data)) 634 if (target->delegate_->AccessibilityPerformAction(data))
634 return S_OK; 635 return S_OK;
635 return E_FAIL; 636 return E_FAIL;
636 } 637 }
637 638
638 STDMETHODIMP AXPlatformNodeWin::get_accSelection(VARIANT* selected) { 639 STDMETHODIMP AXPlatformNodeWin::get_accSelection(VARIANT* selected) {
639 COM_OBJECT_VALIDATE_1_ARG(selected); 640 COM_OBJECT_VALIDATE_1_ARG(selected);
640 if (selected) 641
642 if (GetData().role != ui::AX_ROLE_LIST_BOX)
643 return E_NOTIMPL;
644
645 unsigned long selected_count = 0;
646 for (auto i = 0; i < delegate_->GetChildCount(); ++i) {
647 AXPlatformNodeWin* node = static_cast<AXPlatformNodeWin*>(
648 FromNativeViewAccessible(delegate_->ChildAtIndex(i)));
649
650 if (node && node->GetData().state & (1 << ui::AX_STATE_SELECTED))
651 ++selected_count;
652 }
653
654 if (selected_count == 0) {
641 selected->vt = VT_EMPTY; 655 selected->vt = VT_EMPTY;
642 return E_NOTIMPL; 656 return S_OK;
657 }
658
659 if (selected_count == 1) {
660 for (auto i = 0; i < delegate_->GetChildCount(); ++i) {
661 AXPlatformNodeWin* node = static_cast<AXPlatformNodeWin*>(
662 FromNativeViewAccessible(delegate_->ChildAtIndex(i)));
663
664 if (node && node->GetData().state & (1 << ui::AX_STATE_SELECTED)) {
665 selected->vt = VT_DISPATCH;
666 selected->pdispVal = node;
667 node->AddRef();
668 return S_OK;
669 }
670 }
671 }
672
673 // Multiple items are selected.
674 base::win::EnumVariant* enum_variant =
675 new base::win::EnumVariant(selected_count);
676 enum_variant->AddRef();
677 unsigned long index = 0;
678 for (auto i = 0; i < delegate_->GetChildCount(); ++i) {
679 AXPlatformNodeWin* node = static_cast<AXPlatformNodeWin*>(
680 FromNativeViewAccessible(delegate_->ChildAtIndex(i)));
681
682 if (node && node->GetData().state & (1 << ui::AX_STATE_SELECTED)) {
683 enum_variant->ItemAt(index)->vt = VT_DISPATCH;
684 enum_variant->ItemAt(index)->pdispVal = node;
685 node->AddRef();
686 ++index;
687 }
688 }
689 selected->vt = VT_UNKNOWN;
690 selected->punkVal = static_cast<IUnknown*>(
691 static_cast<base::win::IUnknownImpl*>(enum_variant));
692 return S_OK;
643 } 693 }
644 694
645 STDMETHODIMP AXPlatformNodeWin::accSelect( 695 STDMETHODIMP AXPlatformNodeWin::accSelect(
646 LONG flagsSelect, VARIANT var_id) { 696 LONG flagsSelect, VARIANT var_id) {
647 AXPlatformNodeWin* target; 697 AXPlatformNodeWin* target;
648 COM_OBJECT_VALIDATE_VAR_ID_AND_GET_TARGET(var_id, target); 698 COM_OBJECT_VALIDATE_VAR_ID_AND_GET_TARGET(var_id, target);
649 699
650 if (flagsSelect & SELFLAG_TAKEFOCUS) { 700 if (flagsSelect & SELFLAG_TAKEFOCUS) {
651 ui::AXActionData action_data; 701 ui::AXActionData action_data;
652 action_data.action = ui::AX_ACTION_FOCUS; 702 action_data.action = ui::AX_ACTION_FOCUS;
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after
1699 1749
1700 AXPlatformNodeBase* base = 1750 AXPlatformNodeBase* base =
1701 FromNativeViewAccessible(node->GetNativeViewAccessible()); 1751 FromNativeViewAccessible(node->GetNativeViewAccessible());
1702 if (base && !IsDescendant(base)) 1752 if (base && !IsDescendant(base))
1703 base = nullptr; 1753 base = nullptr;
1704 1754
1705 return static_cast<AXPlatformNodeWin*>(base); 1755 return static_cast<AXPlatformNodeWin*>(base);
1706 } 1756 }
1707 1757
1708 } // namespace ui 1758 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698