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

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

Issue 2942413003: Forward BrowserAccessibility::get_accSelection to AXPlatformNode. (Closed)
Patch Set: Add impl and tests Created 3 years, 6 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 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 LONG* topic_id) { 678 LONG* topic_id) {
679 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_HELP_TOPIC); 679 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_HELP_TOPIC);
680 return AXPlatformNodeWin::get_accHelpTopic(help_file, var_id, topic_id); 680 return AXPlatformNodeWin::get_accHelpTopic(help_file, var_id, topic_id);
681 } 681 }
682 682
683 STDMETHODIMP BrowserAccessibilityComWin::get_accSelection(VARIANT* selected) { 683 STDMETHODIMP BrowserAccessibilityComWin::get_accSelection(VARIANT* selected) {
684 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_SELECTION); 684 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_SELECTION);
685 if (!owner()) 685 if (!owner())
686 return E_FAIL; 686 return E_FAIL;
687 687
688 if (owner()->GetRole() != ui::AX_ROLE_LIST_BOX) 688 return AXPlatformNodeWin::get_accSelection(selected);
689 return E_NOTIMPL;
690
691 unsigned long selected_count = 0;
692 for (size_t i = 0; i < owner()->InternalChildCount(); ++i) {
693 if (owner()->InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED))
694 ++selected_count;
695 }
696
697 if (selected_count == 0) {
698 selected->vt = VT_EMPTY;
699 return S_OK;
700 }
701
702 if (selected_count == 1) {
703 for (size_t i = 0; i < owner()->InternalChildCount(); ++i) {
704 if (owner()->InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) {
705 selected->vt = VT_DISPATCH;
706 selected->pdispVal =
707 ToBrowserAccessibilityComWin(owner()->InternalGetChild(i))
708 ->NewReference();
709 return S_OK;
710 }
711 }
712 }
713
714 // Multiple items are selected.
715 base::win::EnumVariant* enum_variant =
716 new base::win::EnumVariant(selected_count);
717 enum_variant->AddRef();
718 unsigned long index = 0;
719 for (size_t i = 0; i < owner()->InternalChildCount(); ++i) {
720 if (owner()->InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) {
721 enum_variant->ItemAt(index)->vt = VT_DISPATCH;
722 enum_variant->ItemAt(index)->pdispVal =
723 ToBrowserAccessibilityComWin(owner()->InternalGetChild(i))
724 ->NewReference();
725 ++index;
726 }
727 }
728 selected->vt = VT_UNKNOWN;
729 selected->punkVal = static_cast<IUnknown*>(
730 static_cast<base::win::IUnknownImpl*>(enum_variant));
731 return S_OK;
732 } 689 }
733 690
734 STDMETHODIMP BrowserAccessibilityComWin::accSelect(LONG flags_sel, 691 STDMETHODIMP BrowserAccessibilityComWin::accSelect(LONG flags_sel,
735 VARIANT var_id) { 692 VARIANT var_id) {
736 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_SELECT); 693 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_SELECT);
737 if (!owner()) 694 if (!owner())
738 return E_FAIL; 695 return E_FAIL;
739 696
740 return AXPlatformNodeWin::accSelect(flags_sel, var_id); 697 return AXPlatformNodeWin::accSelect(flags_sel, var_id);
741 } 698 }
(...skipping 4841 matching lines...) Expand 10 before | Expand all | Expand 10 after
5583 5540
5584 BrowserAccessibilityComWin* ToBrowserAccessibilityComWin( 5541 BrowserAccessibilityComWin* ToBrowserAccessibilityComWin(
5585 BrowserAccessibility* obj) { 5542 BrowserAccessibility* obj) {
5586 if (!obj || !obj->IsNative()) 5543 if (!obj || !obj->IsNative())
5587 return nullptr; 5544 return nullptr;
5588 auto* result = static_cast<BrowserAccessibilityWin*>(obj)->GetCOM(); 5545 auto* result = static_cast<BrowserAccessibilityWin*>(obj)->GetCOM();
5589 return result; 5546 return result;
5590 } 5547 }
5591 5548
5592 } // namespace content 5549 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698