8#include <wrl/implements.h>
14#include <unordered_set>
35#include "shellscalingapi.h"
58#define COM_OBJECT_VALIDATE() \
61#define COM_OBJECT_VALIDATE_1_ARG(arg) \
65 return E_INVALIDARG; \
67#define COM_OBJECT_VALIDATE_2_ARGS(arg1, arg2) \
71 return E_INVALIDARG; \
74 return E_INVALIDARG; \
76#define COM_OBJECT_VALIDATE_3_ARGS(arg1, arg2, arg3) \
80 return E_INVALIDARG; \
83 return E_INVALIDARG; \
86 return E_INVALIDARG; \
88#define COM_OBJECT_VALIDATE_4_ARGS(arg1, arg2, arg3, arg4) \
92 return E_INVALIDARG; \
95 return E_INVALIDARG; \
98 return E_INVALIDARG; \
101 return E_INVALIDARG; \
103#define COM_OBJECT_VALIDATE_5_ARGS(arg1, arg2, arg3, arg4, arg5) \
104 if (!GetDelegate()) \
107 return E_INVALIDARG; \
110 return E_INVALIDARG; \
113 return E_INVALIDARG; \
116 return E_INVALIDARG; \
119 return E_INVALIDARG; \
121#define COM_OBJECT_VALIDATE_VAR_ID_AND_GET_TARGET(var_id, target) \
122 if (!GetDelegate()) \
124 target = GetTargetFromChildID(var_id); \
126 return E_INVALIDARG; \
127 if (!target->GetDelegate()) \
129#define COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, arg, target) \
130 if (!GetDelegate()) \
133 return E_INVALIDARG; \
135 target = GetTargetFromChildID(var_id); \
137 return E_INVALIDARG; \
138 if (!target->GetDelegate()) \
140#define COM_OBJECT_VALIDATE_VAR_ID_2_ARGS_AND_GET_TARGET(var_id, arg1, arg2, \
142 if (!GetDelegate()) \
145 return E_INVALIDARG; \
148 return E_INVALIDARG; \
150 target = GetTargetFromChildID(var_id); \
152 return E_INVALIDARG; \
153 if (!target->GetDelegate()) \
155#define COM_OBJECT_VALIDATE_VAR_ID_3_ARGS_AND_GET_TARGET(var_id, arg1, arg2, \
157 if (!GetDelegate()) \
160 return E_INVALIDARG; \
163 return E_INVALIDARG; \
166 return E_INVALIDARG; \
168 target = GetTargetFromChildID(var_id); \
170 return E_INVALIDARG; \
171 if (!target->GetDelegate()) \
173#define COM_OBJECT_VALIDATE_VAR_ID_4_ARGS_AND_GET_TARGET(var_id, arg1, arg2, \
174 arg3, arg4, target) \
175 if (!GetDelegate()) \
178 return E_INVALIDARG; \
181 return E_INVALIDARG; \
184 return E_INVALIDARG; \
187 return E_INVALIDARG; \
189 target = GetTargetFromChildID(var_id); \
191 return E_INVALIDARG; \
192 if (!target->GetDelegate()) \
199typedef std::unordered_set<AXPlatformNodeWin*> AXPlatformNodeWinSet;
203constexpr int kLargeChangeScaleFactor = 10;
208constexpr float kSmallScrollIncrement = 40.0f;
211constexpr wchar_t kUIADLLFilename[] = L
"uiautomationcore.dll";
213void AppendTextToString(std::u16string extra_text, std::u16string*
string) {
214 if (extra_text.empty())
217 if (string->empty()) {
218 *
string = extra_text;
222 *
string += std::u16string(u
". ") + extra_text;
228void PatternProvider(AXPlatformNodeWin* node, IUnknown** result) {
230 *result =
static_cast<T*
>(node);
235void AXPlatformNodeWin::AddAttributeToList(
const char*
name,
237 PlatformAttributeList* attributes) {
238 std::string str_value =
value;
239 SanitizeStringAttribute(str_value, &str_value);
259 CComObject<AXPlatformNodeWin>*
instance =
nullptr;
260 HRESULT hr = CComObject<AXPlatformNodeWin>::CreateInstance(&
instance);
272 Microsoft::WRL::ComPtr<AXPlatformNodeWin> ax_platform_node;
273 accessible->QueryInterface(IID_PPV_ARGS(&ax_platform_node));
274 return ax_platform_node.Get();
281AXPlatformNodeWin::AXPlatformNodeWin() {}
283AXPlatformNodeWin::~AXPlatformNodeWin() {}
285void AXPlatformNodeWin::Init(AXPlatformNodeDelegate* delegate) {
290void AXPlatformNodeWin::SanitizeStringAttributeForUIAAriaProperty(
291 const std::u16string&
input,
292 std::u16string* output) {
302void AXPlatformNodeWin::StringAttributeToUIAAriaProperty(
303 std::vector<std::u16string>& properties,
305 const char* uia_aria_property) {
306 std::u16string
value;
307 if (GetString16Attribute(attribute, &value)) {
308 SanitizeStringAttributeForUIAAriaProperty(value, &value);
313void AXPlatformNodeWin::BoolAttributeToUIAAriaProperty(
314 std::vector<std::u16string>& properties,
316 const char* uia_aria_property) {
318 if (GetBoolAttribute(attribute, &value)) {
320 (value ? u
"true" : u
"false"));
324void AXPlatformNodeWin::IntAttributeToUIAAriaProperty(
325 std::vector<std::u16string>& properties,
327 const char* uia_aria_property) {
329 if (GetIntAttribute(attribute, &value)) {
335void AXPlatformNodeWin::FloatAttributeToUIAAriaProperty(
336 std::vector<std::u16string>& properties,
338 const char* uia_aria_property) {
340 if (GetFloatAttribute(attribute, &value)) {
346void AXPlatformNodeWin::StateToUIAAriaProperty(
347 std::vector<std::u16string>& properties,
349 const char* uia_aria_property) {
350 const AXNodeData&
data = GetData();
353 (value ? u
"true" : u
"false"));
356void AXPlatformNodeWin::HtmlAttributeToUIAAriaProperty(
357 std::vector<std::u16string>& properties,
358 const char* html_attribute_name,
359 const char* uia_aria_property) {
360 std::u16string html_attribute_value;
361 if (GetData().GetHtmlAttribute(html_attribute_name, &html_attribute_value)) {
362 SanitizeStringAttributeForUIAAriaProperty(html_attribute_value,
363 &html_attribute_value);
365 html_attribute_value);
369std::vector<AXPlatformNodeWin*>
370AXPlatformNodeWin::CreatePlatformNodeVectorFromRelationIdVector(
371 std::vector<int32_t>& relation_id_list) {
372 std::vector<AXPlatformNodeWin*> platform_node_list;
374 for (int32_t
id : relation_id_list) {
375 AXPlatformNode* platform_node = GetDelegate()->GetFromNodeID(
id);
376 if (IsValidUiaRelationTarget(platform_node)) {
377 platform_node_list.push_back(
378 static_cast<AXPlatformNodeWin*
>(platform_node));
382 return platform_node_list;
385SAFEARRAY* AXPlatformNodeWin::CreateUIAElementsSafeArray(
386 std::vector<AXPlatformNodeWin*>& platform_node_list) {
387 if (platform_node_list.empty())
390 SAFEARRAY* uia_array =
391 SafeArrayCreateVector(VT_UNKNOWN, 0, platform_node_list.size());
394 for (AXPlatformNodeWin* platform_node : platform_node_list) {
398 BASE_DCHECK(IsValidUiaRelationTarget(platform_node));
399 SafeArrayPutElement(uia_array, &
i,
400 static_cast<IRawElementProviderSimple*
>(platform_node));
407SAFEARRAY* AXPlatformNodeWin::CreateUIAControllerForArray() {
408 std::vector<int32_t> relation_id_list =
411 std::vector<AXPlatformNodeWin*> platform_node_list =
412 CreatePlatformNodeVectorFromRelationIdVector(relation_id_list);
415 AXPlatformNodeWin* view_popup_node_win =
static_cast<AXPlatformNodeWin*
>(
418 if (IsValidUiaRelationTarget(view_popup_node_win))
419 platform_node_list.push_back(view_popup_node_win);
422 return CreateUIAElementsSafeArray(platform_node_list);
425SAFEARRAY* AXPlatformNodeWin::CreateUIAElementsArrayForRelation(
427 std::vector<int32_t> relation_id_list = GetIntListAttribute(attribute);
429 std::vector<AXPlatformNodeWin*> platform_node_list =
430 CreatePlatformNodeVectorFromRelationIdVector(relation_id_list);
432 return CreateUIAElementsSafeArray(platform_node_list);
435SAFEARRAY* AXPlatformNodeWin::CreateUIAElementsArrayForReverseRelation(
437 std::set<AXPlatformNode*> reverse_relations =
438 GetDelegate()->GetReverseRelations(attribute);
440 std::vector<int32_t> id_list;
442 reverse_relations.cbegin(), reverse_relations.cend(),
443 std::back_inserter(id_list), [](AXPlatformNode* platform_node) {
444 return static_cast<AXPlatformNodeWin*>(platform_node)->GetData().id;
447 std::vector<AXPlatformNodeWin*> platform_node_list =
448 CreatePlatformNodeVectorFromRelationIdVector(id_list);
450 return CreateUIAElementsSafeArray(platform_node_list);
453SAFEARRAY* AXPlatformNodeWin::CreateClickablePointArray() {
454 SAFEARRAY* clickable_point_array = SafeArrayCreateVector(VT_R8, 0, 2);
460 double* double_array;
461 SafeArrayAccessData(clickable_point_array,
462 reinterpret_cast<void**
>(&double_array));
463 double_array[0] =
center.x();
464 double_array[1] =
center.y();
465 SafeArrayUnaccessData(clickable_point_array);
467 return clickable_point_array;
471 const ScrollAmount horizontal_amount,
472 const ScrollAmount vertical_amount)
const {
473 if (!GetDelegate() || !IsScrollable())
476 const gfx::Rect bounds = GetDelegate()->GetBoundsRect(
478 const int large_horizontal_change = bounds.
width();
479 const int large_vertical_change = bounds.
height();
481 const HWND hwnd = GetDelegate()->GetTargetForNativeAccessibilityEvent();
484 const int small_change =
495 switch (horizontal_amount) {
496 case ScrollAmount_LargeDecrement:
497 x -= large_horizontal_change;
499 case ScrollAmount_LargeIncrement:
500 x += large_horizontal_change;
502 case ScrollAmount_NoAmount:
504 case ScrollAmount_SmallDecrement:
507 case ScrollAmount_SmallIncrement:
511 x = std::min(
x, x_max);
512 x = std::max(
x, x_min);
514 switch (vertical_amount) {
515 case ScrollAmount_LargeDecrement:
516 y -= large_vertical_change;
518 case ScrollAmount_LargeIncrement:
519 y += large_vertical_change;
521 case ScrollAmount_NoAmount:
523 case ScrollAmount_SmallDecrement:
526 case ScrollAmount_SmallIncrement:
530 y = std::min(
y, y_max);
531 y = std::max(
y, y_min);
540void AXPlatformNodeWin::Dispose() {
544void AXPlatformNodeWin::Destroy() {
569 static_cast<AXPlatformNodeWin*
>(FromNativeViewAccessible(GetParent()));
570 int role = MSAARole();
571 if (role == ROLE_SYSTEM_MENUITEM) {
573 }
else if (role == ROLE_SYSTEM_LISTITEM) {
574 if (AXPlatformNodeBase* container = GetSelectionContainer()) {
575 const AXNodeData&
data = container->GetData();
578 GetDelegate()->GetFocus() == GetNativeViewAccessible()) {
583 int parent_role = parent->MSAARole();
584 if (parent_role == ROLE_SYSTEM_MENUPOPUP ||
585 parent_role == ROLE_SYSTEM_LIST) {
596 if (!GetDelegate()->IsWebContent())
597 UpdateComputedHypertext();
600 if (std::optional<DWORD> native_event = MojoEventToMSAAEvent(
event_type)) {
601 HWND hwnd = GetDelegate()->GetTargetForNativeAccessibilityEvent();
605 ::NotifyWinEvent((*native_event), hwnd, OBJID_CLIENT, -GetUniqueId());
608 if (std::optional<PROPERTYID> uia_property =
612 ::VariantInit(old_value.
Receive());
614 ::VariantInit(new_value.
Receive());
615 GetPropertyValueImpl((*uia_property), new_value.
Receive());
616 ::UiaRaiseAutomationPropertyChangedEvent(
this, (*uia_property), old_value,
620 if (std::optional<EVENTID> uia_event = MojoEventToUIAEvent(
event_type))
621 ::UiaRaiseAutomationEvent(
this, (*uia_event));
628bool AXPlatformNodeWin::HasActiveComposition()
const {
629 return active_composition_range_.end() > active_composition_range_.start();
632gfx::Range AXPlatformNodeWin::GetActiveCompositionOffsets()
const {
633 return active_composition_range_;
636void AXPlatformNodeWin::OnActiveComposition(
638 const std::u16string& active_composition_text,
639 bool is_composition_committed) {
643 active_composition_range_ = range;
645 FireUiaTextEditTextChangedEvent(range, active_composition_text,
646 is_composition_committed);
649void AXPlatformNodeWin::FireUiaTextEditTextChangedEvent(
651 const std::u16string& active_composition_text,
652 bool is_composition_committed) {
655 using UiaRaiseTextEditTextChangedEventFunction = HRESULT(
WINAPI*)(
656 IRawElementProviderSimple*, TextEditChangeType, SAFEARRAY*);
657 UiaRaiseTextEditTextChangedEventFunction text_edit_text_changed_func =
658 reinterpret_cast<UiaRaiseTextEditTextChangedEventFunction
>(
659 ::GetProcAddress(GetModuleHandleW(kUIADLLFilename),
660 "UiaRaiseTextEditTextChangedEvent"));
661 if (!text_edit_text_changed_func) {
665 TextEditChangeType text_edit_change_type =
666 is_composition_committed ? TextEditChangeType_CompositionFinalized
667 : TextEditChangeType_Composition;
671 (
wchar_t*)active_composition_text.data());
673 ::SafeArrayCreateVector(VT_BSTR , 0 ,
675 if (!changed_data.Get()) {
681 SafeArrayPutElement(changed_data.Get(), &index, composition_text.Get());
687 text_edit_text_changed_func(
this, text_edit_change_type,
688 changed_data.Release());
692bool AXPlatformNodeWin::IsValidUiaRelationTarget(
693 AXPlatformNode* ax_platform_node) {
694 if (!ax_platform_node)
696 if (!ax_platform_node->GetDelegate())
700 if (!ax_platform_node->GetDelegate()->GetTargetForNativeAccessibilityEvent())
710IFACEMETHODIMP AXPlatformNodeWin::accHitTest(
LONG screen_physical_pixel_x,
711 LONG screen_physical_pixel_y,
715 gfx::Point point(screen_physical_pixel_x, screen_physical_pixel_y);
721 child->vt = VT_EMPTY;
725 AXPlatformNode* current_result =
this;
728 current_result->GetDelegate()->HitTestSync(screen_physical_pixel_x,
729 screen_physical_pixel_y);
731 child->vt = VT_EMPTY;
735 AXPlatformNode* hit_child_node =
741 if (hit_child_node == current_result)
756 bool is_descendant = hit_child_node->IsDescendantOf(current_result);
758 hit_child_node->GetDelegate()->GetTargetForNativeAccessibilityEvent() ==
759 current_result->GetDelegate()->GetTargetForNativeAccessibilityEvent();
760 if (!is_descendant && is_same_hwnd)
767 current_result = hit_child_node;
770 if (current_result ==
this) {
776 child->lVal = CHILDID_SELF;
780 child->vt = VT_DISPATCH;
781 child->pdispVal =
static_cast<AXPlatformNodeWin*
>(current_result);
783 child->pdispVal->AddRef();
787IFACEMETHODIMP AXPlatformNodeWin::accDoDefaultAction(VARIANT var_id) {
788 AXPlatformNodeWin*
target;
793 if (
target->GetDelegate()->AccessibilityPerformAction(data))
798IFACEMETHODIMP AXPlatformNodeWin::accLocation(
LONG* physical_pixel_left,
799 LONG* physical_pixel_top,
803 AXPlatformNodeWin*
target;
810 *physical_pixel_left = bounds.
x();
811 *physical_pixel_top = bounds.
y();
821IFACEMETHODIMP AXPlatformNodeWin::accNavigate(
LONG nav_dir,
824 AXPlatformNodeWin*
target;
827 if ((nav_dir == NAVDIR_FIRSTCHILD || nav_dir == NAVDIR_LASTCHILD) &&
828 V_VT(&start) == VT_I4 && V_I4(&start) != CHILDID_SELF) {
835 case NAVDIR_FIRSTCHILD:
836 if (GetDelegate()->GetChildCount() > 0)
837 result = GetDelegate()->GetFirstChild();
840 case NAVDIR_LASTCHILD:
841 if (GetDelegate()->GetChildCount() > 0)
842 result = GetDelegate()->GetLastChild();
846 AXPlatformNodeBase* next =
target->GetNextSibling();
848 result = next->GetNativeViewAccessible();
852 case NAVDIR_PREVIOUS: {
853 AXPlatformNodeBase* previous =
target->GetPreviousSibling();
855 result = previous->GetNativeViewAccessible();
861 if (!GetTableRow() || !GetTableRowSpan() || !GetTableColumn())
864 AXPlatformNodeBase* next =
target->GetTableCell(
865 *GetTableRow() + *GetTableRowSpan(), *GetTableColumn());
869 result = next->GetNativeViewAccessible();
875 if (!GetTableRow() || !GetTableColumn())
878 AXPlatformNodeBase* next =
879 target->GetTableCell(*GetTableRow() - 1, *GetTableColumn());
883 result = next->GetNativeViewAccessible();
889 if (!GetTableRow() || !GetTableColumn())
892 AXPlatformNodeBase* next =
893 target->GetTableCell(*GetTableRow(), *GetTableColumn() - 1);
897 result = next->GetNativeViewAccessible();
904 if (!GetTableRow() || !GetTableColumn() || !GetTableColumnSpan())
907 AXPlatformNodeBase* next =
target->GetTableCell(
908 *GetTableRow(), *GetTableColumn() + *GetTableColumnSpan());
912 result = next->GetNativeViewAccessible();
920 end->vt = VT_DISPATCH;
921 end->pdispVal = result;
923 end->pdispVal->AddRef();
928IFACEMETHODIMP AXPlatformNodeWin::get_accChild(VARIANT var_child,
929 IDispatch** disp_child) {
930 *disp_child =
nullptr;
931 AXPlatformNodeWin*
target;
935 (*disp_child)->AddRef();
939IFACEMETHODIMP AXPlatformNodeWin::get_accChildCount(
LONG* child_count) {
941 *child_count = GetDelegate()->GetChildCount();
945IFACEMETHODIMP AXPlatformNodeWin::get_accDefaultAction(VARIANT var_id,
947 AXPlatformNodeWin*
target;
954 *def_action =
nullptr;
962 if (action_verb.empty()) {
963 *def_action =
nullptr;
972IFACEMETHODIMP AXPlatformNodeWin::get_accDescription(VARIANT var_id,
974 AXPlatformNodeWin*
target;
977 return target->GetStringAttributeAsBstr(
981IFACEMETHODIMP AXPlatformNodeWin::get_accFocus(VARIANT* focus_child) {
984 if (focus_accessible ==
this) {
985 focus_child->vt = VT_I4;
986 focus_child->lVal = CHILDID_SELF;
987 }
else if (focus_accessible) {
988 Microsoft::WRL::ComPtr<IDispatch> focus_idispatch;
990 focus_accessible->QueryInterface(IID_PPV_ARGS(&focus_idispatch)))) {
991 focus_child->vt = VT_EMPTY;
995 focus_child->vt = VT_DISPATCH;
996 focus_child->pdispVal = focus_idispatch.Detach();
998 focus_child->vt = VT_EMPTY;
1004IFACEMETHODIMP AXPlatformNodeWin::get_accKeyboardShortcut(VARIANT var_id,
1006 AXPlatformNodeWin*
target;
1009 return target->GetStringAttributeAsBstr(
1013IFACEMETHODIMP AXPlatformNodeWin::get_accName(VARIANT var_id, BSTR* name_bstr) {
1014 AXPlatformNodeWin*
target;
1017 if (!IsNameExposed())
1021 std::u16string
name =
target->GetNameAsString16();
1024 const std::u16string tooltip =
1026 if (!tooltip.empty()) {
1027 AppendTextToString(tooltip, &
name);
1030 auto status = GetData().GetImageAnnotationStatus();
1044 GetDelegate()->GetLocalizedStringForImageAnnotationStatus(status),
1055 if (
name.empty() && !has_name)
1062IFACEMETHODIMP AXPlatformNodeWin::get_accParent(IDispatch** disp_parent) {
1064 *disp_parent = GetParent();
1066 (*disp_parent)->AddRef();
1069 IRawElementProviderFragmentRoot* root;
1070 if (
SUCCEEDED(get_FragmentRoot(&root))) {
1072 if (
SUCCEEDED(root->QueryInterface(IID_PPV_ARGS(&parent)))) {
1073 if (parent && parent != GetNativeViewAccessible()) {
1074 *disp_parent = parent;
1083IFACEMETHODIMP AXPlatformNodeWin::get_accRole(VARIANT var_id, VARIANT* role) {
1084 AXPlatformNodeWin*
target;
1088 role->lVal =
target->MSAARole();
1092IFACEMETHODIMP AXPlatformNodeWin::get_accState(VARIANT var_id, VARIANT* state) {
1093 AXPlatformNodeWin*
target;
1096 state->lVal =
target->MSAAState();
1100IFACEMETHODIMP AXPlatformNodeWin::get_accHelp(VARIANT var_id, BSTR* help) {
1105IFACEMETHODIMP AXPlatformNodeWin::get_accValue(VARIANT var_id, BSTR* value) {
1106 AXPlatformNodeWin*
target;
1112IFACEMETHODIMP AXPlatformNodeWin::put_accValue(VARIANT var_id, BSTR new_value) {
1113 AXPlatformNodeWin*
target;
1116 return E_INVALIDARG;
1118 std::u16string new_value_utf16((
char16_t*)new_value);
1122 if (
target->GetDelegate()->AccessibilityPerformAction(data))
1127IFACEMETHODIMP AXPlatformNodeWin::get_accSelection(VARIANT* selected) {
1129 std::vector<Microsoft::WRL::ComPtr<IDispatch>> selected_nodes;
1130 for (
int i = 0;
i < GetDelegate()->GetChildCount(); ++
i) {
1131 auto* node =
static_cast<AXPlatformNodeWin*
>(
1132 FromNativeViewAccessible(GetDelegate()->ChildAtIndex(
i)));
1135 Microsoft::WRL::ComPtr<IDispatch> node_idispatch;
1136 if (
SUCCEEDED(node->QueryInterface(IID_PPV_ARGS(&node_idispatch))))
1137 selected_nodes.push_back(node_idispatch);
1141 if (selected_nodes.empty()) {
1142 selected->vt = VT_EMPTY;
1146 if (selected_nodes.size() == 1) {
1147 selected->vt = VT_DISPATCH;
1148 selected->pdispVal = selected_nodes[0].Detach();
1153 LONG selected_count =
static_cast<LONG>(selected_nodes.size());
1154 Microsoft::WRL::ComPtr<base::win::EnumVariant> enum_variant =
1155 Microsoft::WRL::Make<base::win::EnumVariant>(selected_count);
1156 for (
LONG i = 0;
i < selected_count; ++
i) {
1157 enum_variant->ItemAt(
i)->vt = VT_DISPATCH;
1158 enum_variant->ItemAt(
i)->pdispVal = selected_nodes[
i].Detach();
1160 selected->vt = VT_UNKNOWN;
1161 return enum_variant.CopyTo(IID_PPV_ARGS(&V_UNKNOWN(selected)));
1164IFACEMETHODIMP AXPlatformNodeWin::accSelect(
LONG flagsSelect, VARIANT var_id) {
1165 AXPlatformNodeWin*
target;
1168 if (flagsSelect & SELFLAG_TAKEFOCUS) {
1169 AXActionData action_data;
1171 target->GetDelegate()->AccessibilityPerformAction(action_data);
1178IFACEMETHODIMP AXPlatformNodeWin::get_accHelpTopic(BSTR* help_file,
1181 AXPlatformNodeWin*
target;
1185 *help_file =
nullptr;
1188 *topic_id =
static_cast<LONG>(-1);
1193IFACEMETHODIMP AXPlatformNodeWin::put_accName(VARIANT var_id, BSTR put_name) {
1203IFACEMETHODIMP AXPlatformNodeWin::GetObjectForChild(
LONG child_id,
1204 IAccessibleEx** result) {
1211IFACEMETHODIMP AXPlatformNodeWin::GetIAccessiblePair(IAccessible**
accessible,
1215 (*accessible)->AddRef();
1216 *child_id = CHILDID_SELF;
1222AXPlatformNodeWin::ConvertReturnedElement(IRawElementProviderSimple* element,
1223 IAccessibleEx** acc) {
1231IFACEMETHODIMP AXPlatformNodeWin::Collapse() {
1234 return UIA_E_ELEMENTNOTAVAILABLE;
1237 return UIA_E_INVALIDOPERATION;
1239 AXActionData action_data;
1241 if (GetDelegate()->AccessibilityPerformAction(action_data))
1246IFACEMETHODIMP AXPlatformNodeWin::Expand() {
1249 return UIA_E_ELEMENTNOTAVAILABLE;
1252 return UIA_E_INVALIDOPERATION;
1254 AXActionData action_data;
1256 if (GetDelegate()->AccessibilityPerformAction(action_data))
1261ExpandCollapseState AXPlatformNodeWin::ComputeExpandCollapseState()
const {
1262 const AXNodeData&
data = GetData();
1268 if (
data.IsMenuButton()) {
1269 if (
data.IsButtonPressed())
1270 return ExpandCollapseState_Expanded;
1271 return ExpandCollapseState_Collapsed;
1275 return ExpandCollapseState_Expanded;
1277 return ExpandCollapseState_Collapsed;
1279 return ExpandCollapseState_LeafNode;
1283IFACEMETHODIMP AXPlatformNodeWin::get_ExpandCollapseState(
1284 ExpandCollapseState* result) {
1287 *result = ComputeExpandCollapseState();
1296IFACEMETHODIMP AXPlatformNodeWin::get_Column(
int* result) {
1298 std::optional<int> column = GetTableColumn();
1305IFACEMETHODIMP AXPlatformNodeWin::get_ColumnSpan(
int* result) {
1307 std::optional<int> column_span = GetTableColumnSpan();
1310 *result = *column_span;
1314IFACEMETHODIMP AXPlatformNodeWin::get_ContainingGrid(
1315 IRawElementProviderSimple** result) {
1318 AXPlatformNodeBase* table = GetTable();
1322 auto* node_win =
static_cast<AXPlatformNodeWin*
>(table);
1324 *result =
static_cast<IRawElementProviderSimple*
>(node_win);
1328IFACEMETHODIMP AXPlatformNodeWin::get_Row(
int* result) {
1330 std::optional<int> row = GetTableRow();
1337IFACEMETHODIMP AXPlatformNodeWin::get_RowSpan(
int* result) {
1339 std::optional<int> row_span = GetTableRowSpan();
1342 *result = *row_span;
1350IFACEMETHODIMP AXPlatformNodeWin::GetItem(
int row,
1352 IRawElementProviderSimple** result) {
1355 AXPlatformNodeBase* cell = GetTableCell(row, column);
1357 return E_INVALIDARG;
1359 auto* node_win =
static_cast<AXPlatformNodeWin*
>(cell);
1361 *result =
static_cast<IRawElementProviderSimple*
>(node_win);
1365IFACEMETHODIMP AXPlatformNodeWin::get_RowCount(
int* result) {
1368 std::optional<int> row_count = GetTableAriaRowCount();
1370 row_count = GetTableRowCount();
1373 return E_UNEXPECTED;
1374 *result = *row_count;
1378IFACEMETHODIMP AXPlatformNodeWin::get_ColumnCount(
int* result) {
1381 std::optional<int> column_count = GetTableAriaColumnCount();
1383 column_count = GetTableColumnCount();
1385 if (!column_count ||
1387 return E_UNEXPECTED;
1389 *result = *column_count;
1397IFACEMETHODIMP AXPlatformNodeWin::Invoke() {
1401 return UIA_E_ELEMENTNOTENABLED;
1403 AXActionData action_data;
1405 GetDelegate()->AccessibilityPerformAction(action_data);
1414IFACEMETHODIMP AXPlatformNodeWin::ScrollIntoView() {
1419 AXActionData action_data;
1420 action_data.target_node_id = GetData().id;
1421 action_data.target_rect = r;
1422 action_data.horizontal_scroll_alignment =
1424 action_data.vertical_scroll_alignment =
1426 action_data.scroll_behavior =
1428 if (GetDelegate()->AccessibilityPerformAction(action_data))
1437IFACEMETHODIMP AXPlatformNodeWin::Scroll(ScrollAmount horizontal_amount,
1438 ScrollAmount vertical_amount) {
1440 if (!IsScrollable())
1443 AXActionData action_data;
1444 action_data.target_node_id = GetData().id;
1447 CalculateUIAScrollPoint(horizontal_amount, vertical_amount));
1448 if (GetDelegate()->AccessibilityPerformAction(action_data))
1453IFACEMETHODIMP AXPlatformNodeWin::SetScrollPercent(
double horizontal_percent,
1454 double vertical_percent) {
1456 if (!IsScrollable())
1469 AXActionData action_data;
1470 action_data.target_node_id = GetData().id;
1472 action_data.target_point = scroll_to;
1473 if (GetDelegate()->AccessibilityPerformAction(action_data))
1478IFACEMETHODIMP AXPlatformNodeWin::get_HorizontallyScrollable(
BOOL* result) {
1480 *result = IsHorizontallyScrollable();
1484IFACEMETHODIMP AXPlatformNodeWin::get_HorizontalScrollPercent(
double* result) {
1486 *result = GetHorizontalScrollPercent();
1492IFACEMETHODIMP AXPlatformNodeWin::get_HorizontalViewSize(
double* result) {
1494 if (!IsHorizontallyScrollable()) {
1499 gfx::RectF clipped_bounds(GetDelegate()->GetBoundsRect(
1503 float total_width = clipped_bounds.width() + x_max - x_min;
1504 BASE_DCHECK(clipped_bounds.width() <= total_width);
1505 *result = 100.0 * clipped_bounds.width() / total_width;
1509IFACEMETHODIMP AXPlatformNodeWin::get_VerticallyScrollable(
BOOL* result) {
1511 *result = IsVerticallyScrollable();
1515IFACEMETHODIMP AXPlatformNodeWin::get_VerticalScrollPercent(
double* result) {
1517 *result = GetVerticalScrollPercent();
1523IFACEMETHODIMP AXPlatformNodeWin::get_VerticalViewSize(
double* result) {
1525 if (!IsVerticallyScrollable()) {
1530 gfx::RectF clipped_bounds(GetDelegate()->GetBoundsRect(
1534 float total_height = clipped_bounds.height() + y_max - y_min;
1535 BASE_DCHECK(clipped_bounds.height() <= total_height);
1536 *result = 100.0 * clipped_bounds.height() / total_height;
1544HRESULT AXPlatformNodeWin::ISelectionItemProviderSetSelected(
1545 bool selected)
const {
1548 return UIA_E_ELEMENTNOTENABLED;
1565 if (selected == ISelectionItemProviderIsSelected() &&
1571 if (GetDelegate()->AccessibilityPerformAction(data))
1573 return UIA_E_INVALIDOPERATION;
1576bool AXPlatformNodeWin::ISelectionItemProviderIsSelected()
const {
1590IFACEMETHODIMP AXPlatformNodeWin::AddToSelection() {
1591 return ISelectionItemProviderSetSelected(
true);
1594IFACEMETHODIMP AXPlatformNodeWin::RemoveFromSelection() {
1595 return ISelectionItemProviderSetSelected(
false);
1598IFACEMETHODIMP AXPlatformNodeWin::Select() {
1599 return ISelectionItemProviderSetSelected(
true);
1602IFACEMETHODIMP AXPlatformNodeWin::get_IsSelected(
BOOL* result) {
1604 *result = ISelectionItemProviderIsSelected();
1608IFACEMETHODIMP AXPlatformNodeWin::get_SelectionContainer(
1609 IRawElementProviderSimple** result) {
1612 auto* node_win =
static_cast<AXPlatformNodeWin*
>(GetSelectionContainer());
1617 *result =
static_cast<IRawElementProviderSimple*
>(node_win);
1625IFACEMETHODIMP AXPlatformNodeWin::GetSelection(SAFEARRAY** result) {
1628 std::vector<AXPlatformNodeBase*> selected_children;
1629 int max_items = GetMaxSelectableItems();
1631 GetSelectedItems(max_items, &selected_children);
1633 LONG selected_children_count = selected_children.size();
1634 *result = SafeArrayCreateVector(VT_UNKNOWN, 0, selected_children_count);
1636 return E_OUTOFMEMORY;
1638 for (
LONG i = 0;
i < selected_children_count; ++
i) {
1639 AXPlatformNodeWin* children =
1640 static_cast<AXPlatformNodeWin*
>(selected_children[
i]);
1641 HRESULT hr = SafeArrayPutElement(
1642 *result, &
i,
static_cast<IRawElementProviderSimple*
>(children));
1644 SafeArrayDestroy(*result);
1652IFACEMETHODIMP AXPlatformNodeWin::get_CanSelectMultiple(
BOOL* result) {
1658IFACEMETHODIMP AXPlatformNodeWin::get_IsSelectionRequired(
BOOL* result) {
1668IFACEMETHODIMP AXPlatformNodeWin::GetColumnHeaderItems(SAFEARRAY** result) {
1671 std::optional<int> column = GetTableColumn();
1675 std::vector<int32_t> column_header_ids =
1676 GetDelegate()->GetColHeaderNodeIds(*column);
1678 std::vector<AXPlatformNodeWin*> platform_node_list =
1679 CreatePlatformNodeVectorFromRelationIdVector(column_header_ids);
1681 *result = CreateUIAElementsSafeArray(platform_node_list);
1685IFACEMETHODIMP AXPlatformNodeWin::GetRowHeaderItems(SAFEARRAY** result) {
1688 std::optional<int> row = GetTableRow();
1692 std::vector<int32_t> row_header_ids =
1693 GetDelegate()->GetRowHeaderNodeIds(*row);
1695 std::vector<AXPlatformNodeWin*> platform_node_list =
1696 CreatePlatformNodeVectorFromRelationIdVector(row_header_ids);
1698 *result = CreateUIAElementsSafeArray(platform_node_list);
1706IFACEMETHODIMP AXPlatformNodeWin::GetColumnHeaders(SAFEARRAY** result) {
1709 std::vector<int32_t> column_header_ids = GetDelegate()->GetColHeaderNodeIds();
1711 std::vector<AXPlatformNodeWin*> platform_node_list =
1712 CreatePlatformNodeVectorFromRelationIdVector(column_header_ids);
1714 *result = CreateUIAElementsSafeArray(platform_node_list);
1718IFACEMETHODIMP AXPlatformNodeWin::GetRowHeaders(SAFEARRAY** result) {
1721 std::vector<int32_t> row_header_ids = GetDelegate()->GetRowHeaderNodeIds();
1723 std::vector<AXPlatformNodeWin*> platform_node_list =
1724 CreatePlatformNodeVectorFromRelationIdVector(row_header_ids);
1726 *result = CreateUIAElementsSafeArray(platform_node_list);
1730IFACEMETHODIMP AXPlatformNodeWin::get_RowOrColumnMajor(
1731 RowOrColumnMajor* result) {
1736 *result = RowOrColumnMajor_RowMajor;
1744IFACEMETHODIMP AXPlatformNodeWin::Toggle() {
1746 AXActionData action_data;
1749 if (GetDelegate()->AccessibilityPerformAction(action_data))
1754IFACEMETHODIMP AXPlatformNodeWin::get_ToggleState(ToggleState* result) {
1756 const auto checked_state = GetData().GetCheckedState();
1758 *result = ToggleState_On;
1760 *result = ToggleState_Indeterminate;
1762 *result = ToggleState_Off;
1771IFACEMETHODIMP AXPlatformNodeWin::SetValue(LPCWSTR value) {
1774 return E_INVALIDARG;
1776 if (GetData().IsReadOnlyOrDisabled())
1777 return UIA_E_ELEMENTNOTENABLED;
1782 if (GetDelegate()->AccessibilityPerformAction(data))
1787IFACEMETHODIMP AXPlatformNodeWin::get_IsReadOnly(
BOOL* result) {
1789 *result = GetData().IsReadOnlyOrDisabled();
1793IFACEMETHODIMP AXPlatformNodeWin::get_Value(BSTR* result) {
1795 *result = GetValueAttributeAsBstr(
this);
1803IFACEMETHODIMP AXPlatformNodeWin::SetVisualState(
1804 WindowVisualState window_visual_state) {
1806 return UIA_E_NOTSUPPORTED;
1809IFACEMETHODIMP AXPlatformNodeWin::Close() {
1811 return UIA_E_NOTSUPPORTED;
1814IFACEMETHODIMP AXPlatformNodeWin::WaitForInputIdle(
int milliseconds,
1817 return UIA_E_NOTSUPPORTED;
1820IFACEMETHODIMP AXPlatformNodeWin::get_CanMaximize(
BOOL* result) {
1822 return UIA_E_NOTSUPPORTED;
1825IFACEMETHODIMP AXPlatformNodeWin::get_CanMinimize(
BOOL* result) {
1827 return UIA_E_NOTSUPPORTED;
1830IFACEMETHODIMP AXPlatformNodeWin::get_IsModal(
BOOL* result) {
1838IFACEMETHODIMP AXPlatformNodeWin::get_WindowVisualState(
1839 WindowVisualState* result) {
1841 return UIA_E_NOTSUPPORTED;
1844IFACEMETHODIMP AXPlatformNodeWin::get_WindowInteractionState(
1845 WindowInteractionState* result) {
1847 return UIA_E_NOTSUPPORTED;
1850IFACEMETHODIMP AXPlatformNodeWin::get_IsTopmost(
BOOL* result) {
1852 return UIA_E_NOTSUPPORTED;
1859IFACEMETHODIMP AXPlatformNodeWin::SetValue(
double value) {
1864 if (GetDelegate()->AccessibilityPerformAction(data))
1869IFACEMETHODIMP AXPlatformNodeWin::get_LargeChange(
double* result) {
1874 *result = attribute * kLargeChangeScaleFactor;
1880IFACEMETHODIMP AXPlatformNodeWin::get_Maximum(
double* result) {
1885 *result = attribute;
1891IFACEMETHODIMP AXPlatformNodeWin::get_Minimum(
double* result) {
1896 *result = attribute;
1902IFACEMETHODIMP AXPlatformNodeWin::get_SmallChange(
double* result) {
1907 *result = attribute;
1913IFACEMETHODIMP AXPlatformNodeWin::get_Value(
double* result) {
1918 *result = attribute;
1928IFACEMETHODIMP AXPlatformNodeWin::Navigate(
1929 NavigateDirection direction,
1930 IRawElementProviderFragment** element_provider) {
1933 *element_provider =
nullptr;
1983 switch (direction) {
1984 case NavigateDirection_Parent: {
1987 AXFragmentRootWin* fragment_root =
1990 neighbor = fragment_root->GetNativeViewAccessible();
1992 neighbor = GetParent();
1996 case NavigateDirection_FirstChild:
1997 if (GetChildCount() > 0)
1998 neighbor = GetFirstChild()->GetNativeViewAccessible();
2001 case NavigateDirection_LastChild:
2002 if (GetChildCount() > 0)
2003 neighbor = GetLastChild()->GetNativeViewAccessible();
2006 case NavigateDirection_NextSibling:
2009 GetNativeViewAccessible()) ==
nullptr) {
2010 AXPlatformNodeBase* neighbor_node = GetNextSibling();
2012 neighbor = neighbor_node->GetNativeViewAccessible();
2016 case NavigateDirection_PreviousSibling:
2019 GetNativeViewAccessible()) ==
nullptr) {
2020 AXPlatformNodeBase* neighbor_node = GetPreviousSibling();
2022 neighbor = neighbor_node->GetNativeViewAccessible();
2032 if (direction != NavigateDirection_Parent) {
2035 AXFragmentRootWin* fragment_root =
2037 if (
BASE_UNLIKELY(fragment_root && fragment_root != GetDelegate()))
2038 neighbor = fragment_root->GetNativeViewAccessible();
2040 neighbor->QueryInterface(IID_PPV_ARGS(element_provider));
2046void AXPlatformNodeWin::GetRuntimeIdArray(
2047 AXPlatformNodeWin::RuntimeIdArray& runtime_id) {
2048 runtime_id[0] = UiaAppendRuntimeId;
2049 runtime_id[1] = GetUniqueId();
2052IFACEMETHODIMP AXPlatformNodeWin::GetRuntimeId(SAFEARRAY** runtime_id) {
2055 RuntimeIdArray id_array;
2056 GetRuntimeIdArray(id_array);
2057 *runtime_id = ::SafeArrayCreateVector(VT_I4, 0, id_array.size());
2059 int* array_data =
nullptr;
2060 ::SafeArrayAccessData(*runtime_id,
reinterpret_cast<void**
>(&array_data));
2062 size_t runtime_id_byte_count = id_array.size() *
sizeof(int);
2063 memcpy_s(array_data, runtime_id_byte_count, id_array.data(),
2064 runtime_id_byte_count);
2066 ::SafeArrayUnaccessData(*runtime_id);
2071IFACEMETHODIMP AXPlatformNodeWin::get_BoundingRectangle(
2072 UiaRect* screen_physical_pixel_bounds) {
2078 screen_physical_pixel_bounds->left = bounds.
x();
2079 screen_physical_pixel_bounds->top = bounds.
y();
2080 screen_physical_pixel_bounds->width = bounds.
width();
2081 screen_physical_pixel_bounds->height = bounds.
height();
2085IFACEMETHODIMP AXPlatformNodeWin::GetEmbeddedFragmentRoots(
2086 SAFEARRAY** embedded_fragment_roots) {
2089 *embedded_fragment_roots =
nullptr;
2093IFACEMETHODIMP AXPlatformNodeWin::SetFocus() {
2096 AXActionData action_data;
2098 delegate_->AccessibilityPerformAction(action_data);
2102IFACEMETHODIMP AXPlatformNodeWin::get_FragmentRoot(
2103 IRawElementProviderFragmentRoot** fragment_root) {
2106 gfx::AcceleratedWidget widget =
2107 delegate_->GetTargetForNativeAccessibilityEvent();
2109 AXFragmentRootWin* root =
2111 if (root !=
nullptr) {
2112 root->GetNativeViewAccessible()->QueryInterface(
2113 IID_PPV_ARGS(fragment_root));
2119 *fragment_root =
nullptr;
2120 return UIA_E_ELEMENTNOTAVAILABLE;
2127IFACEMETHODIMP AXPlatformNodeWin::GetPatternProvider(PATTERNID pattern_id,
2128 IUnknown** result) {
2129 return GetPatternProviderImpl(pattern_id, result);
2132HRESULT AXPlatformNodeWin::GetPatternProviderImpl(PATTERNID pattern_id,
2133 IUnknown** result) {
2138 PatternProviderFactoryMethod factory_method =
2139 GetPatternProviderFactoryMethod(pattern_id);
2141 (*factory_method)(
this, result);
2146IFACEMETHODIMP AXPlatformNodeWin::GetPropertyValue(PROPERTYID property_id,
2148 return GetPropertyValueImpl(property_id, result);
2151HRESULT AXPlatformNodeWin::GetPropertyValueImpl(PROPERTYID property_id,
2155 result->vt = VT_EMPTY;
2158 const AXNodeData&
data = GetData();
2161 switch (property_id) {
2162 case UIA_AriaPropertiesPropertyId:
2163 result->vt = VT_BSTR;
2164 result->bstrVal = ::SysAllocString(
2168 case UIA_AriaRolePropertyId:
2169 result->vt = VT_BSTR;
2174 case UIA_AutomationIdPropertyId:
2175 V_VT(result) = VT_BSTR;
2176 V_BSTR(result) = ::SysAllocString(
2180 case UIA_ClassNamePropertyId:
2181 result->vt = VT_BSTR;
2186 case UIA_ClickablePointPropertyId:
2187 result->vt = VT_ARRAY | VT_R8;
2188 result->parray = CreateClickablePointArray();
2191 case UIA_ControllerForPropertyId:
2192 result->vt = VT_ARRAY | VT_UNKNOWN;
2193 result->parray = CreateUIAControllerForArray();
2196 case UIA_ControlTypePropertyId:
2198 result->lVal = ComputeUIAControlType();
2201 case UIA_CulturePropertyId: {
2202 std::optional<LCID> lcid = GetCultureAttributeAsLCID();
2206 result->lVal = lcid.value();
2210 case UIA_DescribedByPropertyId:
2211 result->vt = VT_ARRAY | VT_UNKNOWN;
2212 result->parray = CreateUIAElementsArrayForRelation(
2216 case UIA_FlowsFromPropertyId:
2217 V_VT(result) = VT_ARRAY | VT_UNKNOWN;
2218 V_ARRAY(result) = CreateUIAElementsArrayForReverseRelation(
2222 case UIA_FlowsToPropertyId:
2223 result->vt = VT_ARRAY | VT_UNKNOWN;
2224 result->parray = CreateUIAElementsArrayForRelation(
2228 case UIA_FrameworkIdPropertyId:
2229 V_VT(result) = VT_BSTR;
2230 V_BSTR(result) = SysAllocString(FRAMEWORK_ID);
2233 case UIA_HasKeyboardFocusPropertyId:
2234 result->vt = VT_BOOL;
2235 result->boolVal = (
delegate_->GetFocus() == GetNativeViewAccessible())
2240 case UIA_FullDescriptionPropertyId:
2241 result->vt = VT_BSTR;
2246 case UIA_HelpTextPropertyId:
2248 V_VT(result) = VT_BSTR;
2253 V_VT(result) = VT_BSTR;
2254 GetNameAsBstr(&V_BSTR(result));
2256 V_VT(result) = VT_BSTR;
2262 case UIA_IsContentElementPropertyId:
2263 case UIA_IsControlElementPropertyId:
2264 result->vt = VT_BOOL;
2265 result->boolVal = IsUIAControl() ? VARIANT_TRUE : VARIANT_FALSE;
2268 case UIA_IsDataValidForFormPropertyId:
2271 result->vt = VT_BOOL;
2279 case UIA_IsDialogPropertyId:
2280 result->vt = VT_BOOL;
2281 result->boolVal =
IsDialog(
data.role) ? VARIANT_TRUE : VARIANT_FALSE;
2284 case UIA_IsKeyboardFocusablePropertyId:
2285 result->vt = VT_BOOL;
2287 ShouldNodeHaveFocusableState(data) ? VARIANT_TRUE : VARIANT_FALSE;
2290 case UIA_IsOffscreenPropertyId:
2291 result->vt = VT_BOOL;
2293 GetDelegate()->IsOffscreen() ? VARIANT_TRUE : VARIANT_FALSE;
2296 case UIA_IsRequiredForFormPropertyId:
2297 result->vt = VT_BOOL;
2299 result->boolVal = VARIANT_TRUE;
2301 result->boolVal = VARIANT_FALSE;
2305 case UIA_ItemStatusPropertyId: {
2309 int32_t sort_direction;
2318 V_VT(result) = VT_BSTR;
2319 V_BSTR(result) = SysAllocString(L
"ascending");
2322 V_VT(result) = VT_BSTR;
2323 V_BSTR(result) = SysAllocString(L
"descending");
2326 V_VT(result) = VT_BSTR;
2327 V_BSTR(result) = SysAllocString(L
"other");
2334 case UIA_LabeledByPropertyId:
2335 if (AXPlatformNodeWin* node = ComputeUIALabeledBy()) {
2336 result->vt = VT_UNKNOWN;
2337 result->punkVal = node->GetNativeViewAccessible();
2338 result->punkVal->AddRef();
2342 case UIA_LocalizedControlTypePropertyId: {
2343 std::u16string localized_control_type = GetRoleDescription();
2344 if (!localized_control_type.empty()) {
2345 result->vt = VT_BSTR;
2346 result->bstrVal = ::SysAllocString(
2355 case UIA_NamePropertyId:
2356 if (IsNameExposed()) {
2357 result->vt = VT_BSTR;
2358 GetNameAsBstr(&result->bstrVal);
2362 case UIA_OrientationPropertyId:
2372 result->intVal = OrientationType_Horizontal;
2376 result->intVal = OrientationType_Vertical;
2380 result->intVal = OrientationType_None;
2384 case UIA_IsEnabledPropertyId:
2385 V_VT(result) = VT_BOOL;
2386 switch (
data.GetRestriction()) {
2388 V_BOOL(result) = VARIANT_FALSE;
2393 V_BOOL(result) = VARIANT_TRUE;
2398 case UIA_IsPasswordPropertyId:
2399 result->vt = VT_BOOL;
2405 case UIA_AcceleratorKeyPropertyId:
2407 result->vt = VT_BSTR;
2413 case UIA_AccessKeyPropertyId:
2415 result->vt = VT_BSTR;
2421 case UIA_IsPeripheralPropertyId:
2422 result->vt = VT_BOOL;
2423 result->boolVal = VARIANT_FALSE;
2426 case UIA_LevelPropertyId:
2430 result->intVal = int_attribute;
2434 case UIA_LiveSettingPropertyId: {
2436 result->intVal = LiveSetting::Off;
2438 std::string string_attribute;
2440 &string_attribute)) {
2441 if (string_attribute ==
"polite")
2442 result->intVal = LiveSetting::Polite;
2443 else if (string_attribute ==
"assertive")
2444 result->intVal = LiveSetting::Assertive;
2449 case UIA_OptimizeForVisualContentPropertyId:
2450 result->vt = VT_BOOL;
2451 result->boolVal = VARIANT_FALSE;
2454 case UIA_PositionInSetPropertyId: {
2455 std::optional<int> pos_in_set = GetPosInSet();
2458 result->intVal = *pos_in_set;
2462 case UIA_ScrollHorizontalScrollPercentPropertyId: {
2463 V_VT(result) = VT_R8;
2464 V_R8(result) = GetHorizontalScrollPercent();
2468 case UIA_ScrollVerticalScrollPercentPropertyId: {
2469 V_VT(result) = VT_R8;
2470 V_R8(result) = GetVerticalScrollPercent();
2474 case UIA_SizeOfSetPropertyId: {
2475 std::optional<int> set_size = GetSetSize();
2478 result->intVal = *set_size;
2483 case UIA_LandmarkTypePropertyId: {
2484 std::optional<LONG> landmark_type = ComputeUIALandmarkType();
2485 if (landmark_type) {
2487 result->intVal = landmark_type.value();
2492 case UIA_LocalizedLandmarkTypePropertyId: {
2493 std::u16string localized_landmark_type =
2494 GetDelegate()->GetLocalizedStringForLandmarkType();
2495 if (!localized_landmark_type.empty()) {
2496 result->vt = VT_BSTR;
2497 result->bstrVal = ::SysAllocString(
2503 case UIA_ExpandCollapseExpandCollapseStatePropertyId:
2505 result->intVal =
static_cast<int>(ComputeExpandCollapseState());
2508 case UIA_ToggleToggleStatePropertyId: {
2510 get_ToggleState(&state);
2512 result->lVal = state;
2516 case UIA_ValueValuePropertyId:
2517 result->vt = VT_BSTR;
2518 result->bstrVal = GetValueAttributeAsBstr(
this);
2522 case UIA_AnnotationObjectsPropertyId:
2523 case UIA_AnnotationTypesPropertyId:
2524 case UIA_CenterPointPropertyId:
2525 case UIA_FillColorPropertyId:
2526 case UIA_FillTypePropertyId:
2527 case UIA_HeadingLevelPropertyId:
2528 case UIA_ItemTypePropertyId:
2529 case UIA_OutlineColorPropertyId:
2530 case UIA_OutlineThicknessPropertyId:
2531 case UIA_RotationPropertyId:
2532 case UIA_SizePropertyId:
2533 case UIA_VisualEffectsPropertyId:
2537 case UIA_BoundingRectanglePropertyId:
2538 case UIA_NativeWindowHandlePropertyId:
2539 case UIA_ProcessIdPropertyId:
2540 case UIA_ProviderDescriptionPropertyId:
2541 case UIA_RuntimeIdPropertyId:
2555 result->vt = VT_BSTR;
2556 result->bstrVal = ::SysAllocString(
2563IFACEMETHODIMP AXPlatformNodeWin::get_ProviderOptions(ProviderOptions* ret) {
2566 *ret = ProviderOptions_ServerSideProvider | ProviderOptions_UseComThreading |
2567 ProviderOptions_RefuseNonClientSupport |
2568 ProviderOptions_HasNativeIAccessible;
2572IFACEMETHODIMP AXPlatformNodeWin::get_HostRawElementProvider(
2573 IRawElementProviderSimple** provider) {
2576 *provider =
nullptr;
2584IFACEMETHODIMP AXPlatformNodeWin::ShowContextMenu() {
2587 AXActionData action_data;
2589 delegate_->AccessibilityPerformAction(action_data);
2597IFACEMETHODIMP AXPlatformNodeWin::QueryService(
REFGUID guidService,
2602 if (guidService == IID_IAccessible || (guidService == IID_IAccessibleEx &&
delegate_->IsIAccessibleExEnabled())) {
2603 return QueryInterface(riid,
object);
2618STDMETHODIMP AXPlatformNodeWin::InternalQueryInterface(
2620 const _ATL_INTMAP_ENTRY* entries,
2624 return E_INVALIDARG;
2627 reinterpret_cast<AXPlatformNodeWin*
>(this_ptr);
2630 return CComObjectRootBase::InternalQueryInterface(this_ptr, entries, riid,
2634HRESULT AXPlatformNodeWin::GetTextAttributeValue(
2635 TEXTATTRIBUTEID attribute_id,
2636 const std::optional<int>& start_offset,
2637 const std::optional<int>& end_offset,
2639 BASE_DCHECK(!start_offset || start_offset.value() >= 0);
2640 BASE_DCHECK(!end_offset || end_offset.value() >= 0);
2642 switch (attribute_id) {
2643 case UIA_AnnotationTypesAttributeId:
2644 return GetAnnotationTypesAttribute(start_offset, end_offset, result);
2645 case UIA_BackgroundColorAttributeId:
2649 case UIA_BulletStyleAttributeId:
2650 result->
Insert<VT_I4>(ComputeUIABulletStyle());
2652 case UIA_CultureAttributeId: {
2653 std::optional<LCID> lcid = GetCultureAttributeAsLCID();
2656 result->
Insert<VT_I4>(lcid.value());
2659 case UIA_FontNameAttributeId:
2660 result->
Insert<VT_BSTR>(GetFontNameAttributeAsBSTR());
2662 case UIA_FontSizeAttributeId: {
2663 std::optional<float> font_size_in_points = GetFontSizeInPoints();
2664 if (font_size_in_points) {
2665 result->
Insert<VT_R8>(*font_size_in_points);
2669 case UIA_FontWeightAttributeId:
2673 case UIA_ForegroundColorAttributeId:
2677 case UIA_IsHiddenAttributeId:
2678 result->
Insert<VT_BOOL>(IsInvisibleOrIgnored());
2680 case UIA_IsItalicAttributeId:
2684 case UIA_IsReadOnlyAttributeId:
2686 if (IsPlaceholderText()) {
2687 AXPlatformNodeWin* parent_platform_node =
2688 static_cast<AXPlatformNodeWin*
>(
2689 FromNativeViewAccessible(GetParent()));
2690 return parent_platform_node->GetTextAttributeValue(
2691 attribute_id, start_offset, end_offset, result);
2693 result->
Insert<VT_BOOL>(GetData().IsReadOnlyOrDisabled());
2695 case UIA_IsSubscriptAttributeId:
2696 result->
Insert<VT_BOOL>(GetData().GetTextPosition() ==
2699 case UIA_IsSuperscriptAttributeId:
2700 result->
Insert<VT_BOOL>(GetData().GetTextPosition() ==
2703 case UIA_OverlineStyleAttributeId:
2704 result->
Insert<VT_I4>(GetUIATextDecorationStyle(
2707 case UIA_StrikethroughStyleAttributeId:
2708 result->
Insert<VT_I4>(GetUIATextDecorationStyle(
2711 case UIA_StyleNameAttributeId:
2712 result->
Insert<VT_BSTR>(GetStyleNameAttributeAsBSTR());
2714 case UIA_StyleIdAttributeId:
2715 result->
Insert<VT_I4>(ComputeUIAStyleId());
2717 case UIA_HorizontalTextAlignmentAttributeId: {
2718 std::optional<HorizontalTextAlignment> horizontal_text_alignment =
2719 AXTextAlignToUIAHorizontalTextAlignment(GetData().GetTextAlign());
2720 if (horizontal_text_alignment)
2721 result->
Insert<VT_I4>(*horizontal_text_alignment);
2724 case UIA_UnderlineStyleAttributeId:
2725 result->
Insert<VT_I4>(GetUIATextDecorationStyle(
2728 case UIA_TextFlowDirectionsAttributeId:
2730 TextDirectionToFlowDirections(GetData().GetTextDirection()));
2733 Microsoft::WRL::ComPtr<IUnknown> not_supported_value;
2734 HRESULT hr = ::UiaGetReservedNotSupportedValue(¬_supported_value);
2736 result->
Insert<VT_UNKNOWN>(not_supported_value.Get());
2744HRESULT AXPlatformNodeWin::GetAnnotationTypesAttribute(
2745 const std::optional<int>& start_offset,
2746 const std::optional<int>& end_offset,
2750 MarkerTypeRangeResult grammar_result = MarkerTypeRangeResult::kNone;
2751 MarkerTypeRangeResult spelling_result = MarkerTypeRangeResult::kNone;
2753 if (
IsText() || IsPlainTextField()) {
2754 grammar_result = GetMarkerTypeFromRange(start_offset, end_offset,
2756 spelling_result = GetMarkerTypeFromRange(start_offset, end_offset,
2760 if (grammar_result == MarkerTypeRangeResult::kMixed ||
2761 spelling_result == MarkerTypeRangeResult::kMixed) {
2762 Microsoft::WRL::ComPtr<IUnknown> mixed_attribute_value;
2763 HRESULT hr = ::UiaGetReservedMixedAttributeValue(&mixed_attribute_value);
2765 result->
Insert<VT_UNKNOWN>(mixed_attribute_value.Get());
2769 if (spelling_result == MarkerTypeRangeResult::kMatch)
2770 result->
Insert<VT_I4>(AnnotationType_SpellingError);
2771 if (grammar_result == MarkerTypeRangeResult::kMatch)
2772 result->
Insert<VT_I4>(AnnotationType_GrammarError);
2777std::optional<LCID> AXPlatformNodeWin::GetCultureAttributeAsLCID()
const {
2778 const std::u16string language =
2781 LocaleNameToLCID((
wchar_t*)language.c_str(), LOCALE_ALLOW_NEUTRAL_NAMES);
2783 return std::nullopt;
2788COLORREF AXPlatformNodeWin::GetIntAttributeAsCOLORREF(
2790 uint32_t color = GetIntAttribute(attribute);
2792 return (_byteswap_ulong(color) >> 8);
2795BulletStyle AXPlatformNodeWin::ComputeUIABulletStyle()
const {
2800 const AXPlatformNodeBase* current_node =
this;
2801 while (current_node &&
2803 current_node = FromNativeViewAccessible(current_node->GetParent());
2807 current_node ? current_node->GetData().GetListStyle()
2810 switch (list_style) {
2812 return BulletStyle::BulletStyle_None;
2814 return BulletStyle::BulletStyle_HollowRoundBullet;
2816 return BulletStyle::BulletStyle_FilledRoundBullet;
2818 return BulletStyle::BulletStyle_Other;
2821 return BulletStyle::BulletStyle_None;
2823 return BulletStyle::BulletStyle_FilledSquareBullet;
2827LONG AXPlatformNodeWin::ComputeUIAStyleId()
const {
2828 const AXPlatformNodeBase* current_node =
this;
2830 switch (current_node->GetData().role) {
2832 return AXHierarchicalLevelToUIAStyleId(current_node->GetIntAttribute(
2835 return AXListStyleToUIAStyleId(current_node->GetData().GetListStyle());
2837 return StyleId_Custom;
2839 return StyleId_Quote;
2843 current_node = FromNativeViewAccessible(current_node->GetParent());
2844 }
while (current_node);
2846 return StyleId_Normal;
2850std::optional<HorizontalTextAlignment>
2851AXPlatformNodeWin::AXTextAlignToUIAHorizontalTextAlignment(
2853 switch (text_align) {
2855 return std::nullopt;
2857 return HorizontalTextAlignment_Left;
2859 return HorizontalTextAlignment_Right;
2861 return HorizontalTextAlignment_Centered;
2863 return HorizontalTextAlignment_Justified;
2868LONG AXPlatformNodeWin::AXHierarchicalLevelToUIAStyleId(
2869 int32_t hierarchical_level) {
2870 switch (hierarchical_level) {
2872 return StyleId_Normal;
2874 return StyleId_Heading1;
2876 return StyleId_Heading2;
2878 return StyleId_Heading3;
2880 return StyleId_Heading4;
2882 return StyleId_Heading5;
2884 return StyleId_Heading6;
2886 return StyleId_Heading7;
2888 return StyleId_Heading8;
2890 return StyleId_Heading9;
2892 return StyleId_Custom;
2897LONG AXPlatformNodeWin::AXListStyleToUIAStyleId(
2899 switch (list_style) {
2901 return StyleId_Normal;
2906 return StyleId_BulletedList;
2909 return StyleId_NumberedList;
2914FlowDirections AXPlatformNodeWin::TextDirectionToFlowDirections(
2918 return FlowDirections::FlowDirections_Default;
2920 return FlowDirections::FlowDirections_Default;
2922 return FlowDirections::FlowDirections_RightToLeft;
2924 return FlowDirections::FlowDirections_Vertical;
2926 return FlowDirections::FlowDirections_BottomToTop;
2931void AXPlatformNodeWin::AggregateRangesForMarkerType(
2932 AXPlatformNodeBase* node,
2934 int offset_ranges_amount,
2935 std::vector<std::pair<int, int>>* ranges) {
2937 const std::vector<int32_t>& marker_types =
2939 const std::vector<int>& marker_starts =
2941 const std::vector<int>& marker_ends =
2944 for (
size_t i = 0;
i < marker_types.size(); ++
i) {
2948 const int marker_start = marker_starts[
i] + offset_ranges_amount;
2949 const int marker_end = marker_ends[
i] + offset_ranges_amount;
2950 ranges->emplace_back(std::make_pair(marker_start, marker_end));
2954AXPlatformNodeWin::MarkerTypeRangeResult
2955AXPlatformNodeWin::GetMarkerTypeFromRange(
2956 const std::optional<int>& start_offset,
2957 const std::optional<int>& end_offset,
2960 std::vector<std::pair<int, int>> relevant_ranges;
2963 AggregateRangesForMarkerType(
this, marker_type, 0,
2965 }
else if (IsPlainTextField()) {
2966 int offset_ranges_amount = 0;
2967 for (AXPlatformNodeBase* static_text = GetFirstTextOnlyDescendant();
2968 static_text; static_text = static_text->GetNextSibling()) {
2969 const int child_offset_ranges_amount = offset_ranges_amount;
2970 if (start_offset || end_offset) {
2972 if (end_offset && child_offset_ranges_amount > end_offset.value())
2976 offset_ranges_amount += static_text->GetHypertext().length();
2977 if (start_offset && offset_ranges_amount < start_offset.value())
2981 AggregateRangesForMarkerType(static_text, marker_type,
2982 child_offset_ranges_amount,
2988 const auto sort_ranges_by_start_offset = [](
const std::pair<int, int>& a,
2989 const std::pair<int, int>&
b) {
2990 return a.first <
b.first;
2992 std::sort(relevant_ranges.begin(), relevant_ranges.end(),
2993 sort_ranges_by_start_offset);
2996 std::optional<std::pair<int, int>> contiguous_range;
2997 for (
const std::pair<int, int>& range : relevant_ranges) {
2998 if (end_offset && range.first > end_offset.value())
3000 if (start_offset && range.second < start_offset.value())
3003 if (!contiguous_range) {
3004 contiguous_range = range;
3009 if ((range.first - contiguous_range->second) > 1)
3010 return MarkerTypeRangeResult::kMixed;
3013 contiguous_range->second = std::max(contiguous_range->second, range.second);
3017 if (!contiguous_range)
3018 return MarkerTypeRangeResult::kNone;
3022 if (!start_offset && contiguous_range->first > 0)
3023 return MarkerTypeRangeResult::kMixed;
3025 if (!end_offset && contiguous_range->second < GetHypertext().
length())
3026 return MarkerTypeRangeResult::kMixed;
3028 if (start_offset && start_offset.value() < contiguous_range->first)
3029 return MarkerTypeRangeResult::kMixed;
3031 if (end_offset && end_offset.value() > contiguous_range->second)
3032 return MarkerTypeRangeResult::kMixed;
3035 return MarkerTypeRangeResult::kMatch;
3040bool AXPlatformNodeWin::IsPatternProviderSupported(PATTERNID pattern_id) {
3041 return GetPatternProviderFactoryMethod(pattern_id);
3047int AXPlatformNodeWin::MSAARole() {
3051 if (IsWebAreaForPresentationalIframe())
3052 return ROLE_SYSTEM_GROUPING;
3054 switch (GetData().role) {
3056 return ROLE_SYSTEM_ALERT;
3059 return ROLE_SYSTEM_DIALOG;
3062 return ROLE_SYSTEM_LINK;
3066 return ROLE_SYSTEM_GROUPING;
3069 return ROLE_SYSTEM_APPLICATION;
3072 return ROLE_SYSTEM_DOCUMENT;
3075 return ROLE_SYSTEM_GROUPING;
3079 return ROLE_SYSTEM_GROUPING;
3082 return ROLE_SYSTEM_GROUPING;
3085 return ROLE_SYSTEM_PUSHBUTTON;
3088 return ROLE_SYSTEM_GRAPHIC;
3091 return ROLE_SYSTEM_TEXT;
3094 return ROLE_SYSTEM_CARET;
3097 return ROLE_SYSTEM_CELL;
3100 return ROLE_SYSTEM_CHECKBUTTON;
3103 return ROLE_SYSTEM_PANE;
3106 return ROLE_SYSTEM_TEXT;
3109 return ROLE_SYSTEM_COLUMN;
3112 return ROLE_SYSTEM_COLUMNHEADER;
3116 return ROLE_SYSTEM_COMBOBOX;
3119 return ROLE_SYSTEM_GROUPING;
3123 return ROLE_SYSTEM_GROUPING;
3127 return ROLE_SYSTEM_GROUPING;
3131 return ROLE_SYSTEM_DROPLIST;
3134 return ROLE_SYSTEM_GROUPING;
3137 return ROLE_SYSTEM_TEXT;
3140 return ROLE_SYSTEM_LIST;
3143 return ROLE_SYSTEM_LISTITEM;
3146 return ROLE_SYSTEM_PANE;
3149 return ROLE_SYSTEM_GROUPING;
3152 return ROLE_SYSTEM_DIALOG;
3155 return ROLE_SYSTEM_PUSHBUTTON;
3158 return ROLE_SYSTEM_LIST;
3161 return ROLE_SYSTEM_GRAPHIC;
3167 return ROLE_SYSTEM_LINK;
3172 return ROLE_SYSTEM_LISTITEM;
3175 return ROLE_SYSTEM_SEPARATOR;
3207 return ROLE_SYSTEM_GROUPING;
3212 return ROLE_SYSTEM_DOCUMENT;
3224 if (GetDelegate()->GetChildCount()) {
3225 return ROLE_SYSTEM_GROUPING;
3227 return ROLE_SYSTEM_CLIENT;
3231 return ROLE_SYSTEM_GROUPING;
3234 return ROLE_SYSTEM_GROUPING;
3237 return ROLE_SYSTEM_GROUPING;
3241 return ROLE_SYSTEM_GROUPING;
3244 return ROLE_SYSTEM_GROUPING;
3247 return ROLE_SYSTEM_GROUPING;
3250 return ROLE_SYSTEM_DOCUMENT;
3253 return ROLE_SYSTEM_PANE;
3256 return ROLE_SYSTEM_GRAPHIC;
3259 return ROLE_SYSTEM_TABLE;
3262 return ROLE_SYSTEM_GROUPING;
3265 return ROLE_SYSTEM_GROUPING;
3268 return ROLE_SYSTEM_DOCUMENT;
3271 return ROLE_SYSTEM_GROUPING;
3275 return ROLE_SYSTEM_GRAPHIC;
3278 return ROLE_SYSTEM_GROUPING;
3281 return ROLE_SYSTEM_STATICTEXT;
3285 return ROLE_SYSTEM_TEXT;
3288 return ROLE_SYSTEM_TABLE;
3291 return ROLE_SYSTEM_CELL;
3294 return ROLE_SYSTEM_ROW;
3297 return ROLE_SYSTEM_LINK;
3300 return ROLE_SYSTEM_LIST;
3303 return ROLE_SYSTEM_LIST;
3306 return ROLE_SYSTEM_LISTITEM;
3309 return ROLE_SYSTEM_LIST;
3312 return ROLE_SYSTEM_LISTITEM;
3315 if (!GetDelegate()->GetChildCount()) {
3320 return ROLE_SYSTEM_STATICTEXT;
3322 return ROLE_SYSTEM_GROUPING;
3325 return ROLE_SYSTEM_GROUPING;
3328 return ROLE_SYSTEM_GROUPING;
3331 return ROLE_SYSTEM_GROUPING;
3334 return ROLE_SYSTEM_ANIMATION;
3337 return ROLE_SYSTEM_EQUATION;
3340 return ROLE_SYSTEM_MENUPOPUP;
3343 return ROLE_SYSTEM_MENUBAR;
3348 return ROLE_SYSTEM_MENUITEM;
3351 return ROLE_SYSTEM_LIST;
3354 return ROLE_SYSTEM_LISTITEM;
3357 return ROLE_SYSTEM_PROGRESSBAR;
3360 return ROLE_SYSTEM_GROUPING;
3363 return ROLE_SYSTEM_GROUPING;
3366 return ROLE_SYSTEM_GROUPING;
3369 return ROLE_SYSTEM_PUSHBUTTON;
3373 if (GetDelegate()->GetChildCount()) {
3374 return ROLE_SYSTEM_GROUPING;
3376 return ROLE_SYSTEM_CLIENT;
3380 std::string html_tag =
3382 if (html_tag ==
"select")
3383 return ROLE_SYSTEM_COMBOBOX;
3384 return ROLE_SYSTEM_BUTTONMENU;
3388 return ROLE_SYSTEM_PUSHBUTTON;
3391 return ROLE_SYSTEM_TEXT;
3394 return ROLE_SYSTEM_PROGRESSBAR;
3397 return ROLE_SYSTEM_RADIOBUTTON;
3400 return ROLE_SYSTEM_GROUPING;
3403 return ROLE_SYSTEM_PANE;
3408 return IsInTreeGrid() ? ROLE_SYSTEM_OUTLINEITEM : ROLE_SYSTEM_ROW;
3412 return ROLE_SYSTEM_GROUPING;
3415 return ROLE_SYSTEM_ROWHEADER;
3418 return ROLE_SYSTEM_TEXT;
3421 if (GetNameAsString16().empty()) {
3423 return ROLE_SYSTEM_GROUPING;
3426 return ROLE_SYSTEM_PANE;
3430 return ROLE_SYSTEM_SCROLLBAR;
3433 return ROLE_SYSTEM_PANE;
3436 return ROLE_SYSTEM_GROUPING;
3439 return ROLE_SYSTEM_SLIDER;
3442 return ROLE_SYSTEM_SLIDER;
3445 return ROLE_SYSTEM_SPINBUTTON;
3448 return ROLE_SYSTEM_CHECKBUTTON;
3452 return ROLE_SYSTEM_STATICTEXT;
3455 return ROLE_SYSTEM_STATUSBAR;
3458 return ROLE_SYSTEM_SEPARATOR;
3461 return ROLE_SYSTEM_GRAPHIC;
3464 return ROLE_SYSTEM_PAGETAB;
3467 return ROLE_SYSTEM_TABLE;
3470 return ROLE_SYSTEM_GROUPING;
3473 return ROLE_SYSTEM_PAGETABLIST;
3476 return ROLE_SYSTEM_PROPERTYPAGE;
3479 return ROLE_SYSTEM_LISTITEM;
3482 return ROLE_SYSTEM_TITLEBAR;
3485 return ROLE_SYSTEM_CHECKBUTTON;
3489 return ROLE_SYSTEM_TEXT;
3492 return ROLE_SYSTEM_COMBOBOX;
3499 return ROLE_SYSTEM_TEXT;
3502 return ROLE_SYSTEM_CLOCK;
3505 return ROLE_SYSTEM_TOOLBAR;
3508 return ROLE_SYSTEM_TOOLTIP;
3511 return ROLE_SYSTEM_OUTLINE;
3514 return ROLE_SYSTEM_OUTLINE;
3517 return ROLE_SYSTEM_OUTLINEITEM;
3520 return ROLE_SYSTEM_WHITESPACE;
3523 return ROLE_SYSTEM_GROUPING;
3526 return ROLE_SYSTEM_CLIENT;
3534 return ROLE_SYSTEM_PANE;
3542 return ROLE_SYSTEM_PANE;
3546 return ROLE_SYSTEM_GROUPING;
3549bool AXPlatformNodeWin::IsWebAreaForPresentationalIframe() {
3555 AXPlatformNodeBase* parent = FromNativeViewAccessible(GetParent());
3562std::u16string AXPlatformNodeWin::UIAAriaRole() {
3566 if (IsWebAreaForPresentationalIframe())
3569 switch (GetData().role) {
3588 return u
"application";
3610 return u
"description";
3634 return u
"columnheader";
3641 return u
"complementary";
3649 return u
"contentinfo";
3656 return u
"definition";
3659 return u
"description";
3680 return u
"directory";
3697 return u
"separator";
3737 if (GetDelegate()->GetChildCount()) {
3750 return u
"description";
3810 return u
"description";
3840 if (!GetDelegate()->GetChildCount()) {
3845 return u
"description";
3856 return u
"description";
3874 return u
"menuitemcheckbox";
3877 return u
"menuitemradio";
3886 return u
"progressbar";
3889 return u
"navigation";
3901 if (GetDelegate()->GetChildCount()) {
3908 std::string html_tag =
3910 if (html_tag ==
"select")
3922 return u
"progressbar";
3928 return u
"radiogroup";
3936 return IsInTreeGrid() ? u
"treeitem" : u
"row";
3943 return u
"rowheader";
3949 if (GetNameAsString16().empty()) {
3958 return u
"scrollbar";
3973 return u
"spinbutton";
3983 return u
"description";
3989 return u
"separator";
4022 return u
"searchbox";
4028 return u
"description";
4052 return u
"separator";
4073std::u16string AXPlatformNodeWin::ComputeUIAProperties() {
4074 std::vector<std::u16string> properties;
4075 const AXNodeData&
data = GetData();
4077 BoolAttributeToUIAAriaProperty(
4082 switch (
data.GetCheckedState()) {
4087 properties.emplace_back(u
"pressed=false");
4092 properties.emplace_back(u
"pressed=false");
4093 properties.emplace_back(u
"checked=false");
4095 properties.emplace_back(u
"checked=false");
4100 properties.emplace_back(u
"pressed=true");
4105 properties.emplace_back(u
"pressed=true");
4106 properties.emplace_back(u
"checked=true");
4108 properties.emplace_back(u
"checked=true");
4113 properties.emplace_back(u
"pressed=mixed");
4118 properties.emplace_back(u
"checked=mixed");
4126 properties.push_back(u
"disabled=true");
4132 if (GetData().IsReadOnlyOrDisabled())
4133 properties.push_back(u
"readonly=true");
4138 properties.push_back(u
"dropeffect=" +
4150 properties.push_back(u
"haspopup=true");
4153 properties.push_back(u
"haspopup=menu");
4156 properties.push_back(u
"haspopup=listbox");
4159 properties.push_back(u
"haspopup=tree");
4162 properties.push_back(u
"haspopup=grid");
4165 properties.push_back(u
"haspopup=dialog");
4169 if (IsInvisibleOrIgnored())
4170 properties.push_back(u
"hidden=true");
4175 properties.push_back(u
"invalid=true");
4178 IntAttributeToUIAAriaProperty(
4180 StringAttributeToUIAAriaProperty(
4187 StringAttributeToUIAAriaProperty(
4190 BoolAttributeToUIAAriaProperty(
4195 int32_t sort_direction;
4203 properties.push_back(u
"sort=none");
4206 properties.push_back(u
"sort=ascending");
4209 properties.push_back(u
"sort=descending");
4212 properties.push_back(u
"sort=other");
4217 if (
data.IsRangeValueSupported()) {
4218 FloatAttributeToUIAAriaProperty(
4220 FloatAttributeToUIAAriaProperty(
4222 StringAttributeToUIAAriaProperty(
4225 std::u16string value_now = GetRangeValueText();
4226 SanitizeStringAttributeForUIAAriaProperty(value_now, &value_now);
4227 if (!value_now.empty())
4228 properties.push_back(u
"valuenow=" + value_now);
4235LONG AXPlatformNodeWin::ComputeUIAControlType() {
4239 if (IsWebAreaForPresentationalIframe())
4240 return UIA_GroupControlTypeId;
4242 switch (GetData().role) {
4244 return UIA_TextControlTypeId;
4251 return UIA_TextControlTypeId;
4254 return UIA_HyperlinkControlTypeId;
4258 return ROLE_SYSTEM_GROUPING;
4261 return UIA_PaneControlTypeId;
4264 return UIA_GroupControlTypeId;
4267 return UIA_GroupControlTypeId;
4271 return UIA_GroupControlTypeId;
4274 return UIA_GroupControlTypeId;
4277 return UIA_ButtonControlTypeId;
4280 return UIA_ImageControlTypeId;
4283 return UIA_TextControlTypeId;
4286 return UIA_PaneControlTypeId;
4289 return UIA_DataItemControlTypeId;
4292 return UIA_CheckBoxControlTypeId;
4295 return UIA_PaneControlTypeId;
4298 return UIA_TextControlTypeId;
4301 return UIA_ButtonControlTypeId;
4304 return UIA_PaneControlTypeId;
4307 return UIA_DataItemControlTypeId;
4311 return UIA_ComboBoxControlTypeId;
4314 return UIA_GroupControlTypeId;
4318 return UIA_GroupControlTypeId;
4322 return UIA_GroupControlTypeId;
4326 return UIA_EditControlTypeId;
4329 return UIA_GroupControlTypeId;
4332 return UIA_TextControlTypeId;
4335 return UIA_ListControlTypeId;
4338 return UIA_ListItemControlTypeId;
4341 return UIA_DocumentControlTypeId;
4344 return UIA_GroupControlTypeId;
4347 return UIA_PaneControlTypeId;
4350 return UIA_ButtonControlTypeId;
4353 return UIA_ListControlTypeId;
4356 return UIA_ImageControlTypeId;
4362 return UIA_HyperlinkControlTypeId;
4367 return UIA_ListItemControlTypeId;
4370 return UIA_SeparatorControlTypeId;
4402 return UIA_GroupControlTypeId;
4407 return UIA_DocumentControlTypeId;
4410 return UIA_PaneControlTypeId;
4413 return UIA_TextControlTypeId;
4416 return UIA_GroupControlTypeId;
4419 return UIA_TextControlTypeId;
4422 return UIA_GroupControlTypeId;
4426 return UIA_GroupControlTypeId;
4429 return UIA_GroupControlTypeId;
4432 return UIA_GroupControlTypeId;
4435 return UIA_DocumentControlTypeId;
4438 return UIA_PaneControlTypeId;
4441 return UIA_ImageControlTypeId;
4444 return UIA_DataGridControlTypeId;
4447 return UIA_GroupControlTypeId;
4450 return UIA_TextControlTypeId;
4453 return UIA_DocumentControlTypeId;
4456 return UIA_GroupControlTypeId;
4459 return UIA_ImageControlTypeId;
4462 return UIA_DocumentControlTypeId;
4465 return UIA_GroupControlTypeId;
4468 return UIA_DocumentControlTypeId;
4472 return UIA_TextControlTypeId;
4475 return UIA_TableControlTypeId;
4478 return UIA_DataItemControlTypeId;
4481 return UIA_DataItemControlTypeId;
4484 return UIA_HyperlinkControlTypeId;
4487 return UIA_ListControlTypeId;
4490 return UIA_ListControlTypeId;
4493 return UIA_ListItemControlTypeId;
4496 return UIA_DataGridControlTypeId;
4499 return UIA_ListItemControlTypeId;
4502 if (!GetDelegate()->GetChildCount()) {
4507 return UIA_TextControlTypeId;
4509 return UIA_GroupControlTypeId;
4512 return UIA_GroupControlTypeId;
4515 return UIA_GroupControlTypeId;
4518 return UIA_TextControlTypeId;
4521 return UIA_TextControlTypeId;
4524 return UIA_GroupControlTypeId;
4527 return UIA_MenuControlTypeId;
4530 return UIA_MenuBarControlTypeId;
4533 return UIA_MenuItemControlTypeId;
4536 return UIA_CheckBoxControlTypeId;
4539 return UIA_RadioButtonControlTypeId;
4542 return UIA_ListControlTypeId;
4545 return UIA_ListItemControlTypeId;
4548 return UIA_ProgressBarControlTypeId;
4551 return UIA_GroupControlTypeId;
4554 return UIA_GroupControlTypeId;
4557 return UIA_GroupControlTypeId;
4560 return UIA_CustomControlTypeId;
4563 if (GetDelegate()->GetChildCount()) {
4564 return UIA_GroupControlTypeId;
4566 return UIA_DocumentControlTypeId;
4570 std::string html_tag =
4572 if (html_tag ==
"select")
4573 return UIA_ComboBoxControlTypeId;
4574 return UIA_ButtonControlTypeId;
4578 return UIA_ButtonControlTypeId;
4581 return UIA_PaneControlTypeId;
4584 return UIA_ProgressBarControlTypeId;
4587 return UIA_RadioButtonControlTypeId;
4590 return UIA_GroupControlTypeId;
4593 return UIA_GroupControlTypeId;
4598 return IsInTreeGrid() ? UIA_TreeItemControlTypeId
4599 : UIA_DataItemControlTypeId;
4603 return UIA_GroupControlTypeId;
4606 return UIA_DataItemControlTypeId;
4609 return UIA_PaneControlTypeId;
4612 return UIA_GroupControlTypeId;
4615 return UIA_ScrollBarControlTypeId;
4618 return UIA_PaneControlTypeId;
4621 return UIA_GroupControlTypeId;
4624 return UIA_SliderControlTypeId;
4627 return UIA_SliderControlTypeId;
4630 return UIA_SpinnerControlTypeId;
4633 return UIA_ButtonControlTypeId;
4637 return UIA_TextControlTypeId;
4640 return UIA_StatusBarControlTypeId;
4643 return UIA_TextControlTypeId;
4646 return UIA_SeparatorControlTypeId;
4649 return UIA_ImageControlTypeId;
4652 return UIA_TabItemControlTypeId;
4655 return UIA_TableControlTypeId;
4658 return UIA_GroupControlTypeId;
4661 return UIA_TabControlTypeId;
4664 return UIA_PaneControlTypeId;
4667 return UIA_ListItemControlTypeId;
4670 return UIA_DocumentControlTypeId;
4673 return UIA_ButtonControlTypeId;
4677 return UIA_EditControlTypeId;
4680 return UIA_ComboBoxControlTypeId;
4684 return UIA_TextControlTypeId;
4687 return UIA_PaneControlTypeId;
4690 return UIA_ToolBarControlTypeId;
4693 return UIA_ToolTipControlTypeId;
4696 return UIA_TreeControlTypeId;
4699 return UIA_DataGridControlTypeId;
4702 return UIA_TreeItemControlTypeId;
4705 return UIA_SeparatorControlTypeId;
4708 return UIA_GroupControlTypeId;
4711 return UIA_DocumentControlTypeId;
4721 return UIA_PaneControlTypeId;
4725 return UIA_DocumentControlTypeId;
4728AXPlatformNodeWin* AXPlatformNodeWin::ComputeUIALabeledBy() {
4730 if (!CanHaveUIALabeledBy())
4735 for (int32_t
id : GetData().GetIntListAttribute(
4738 static_cast<AXPlatformNodeWin*
>(GetDelegate()->GetFromNodeID(
id));
4743 if (IsValidUiaRelationTarget(node_win) &&
4749 for (
auto iter = node_win->GetDelegate()->ChildrenBegin();
4750 *iter != *node_win->GetDelegate()->ChildrenEnd(); ++(*iter)) {
4751 AXPlatformNodeWin* child =
static_cast<AXPlatformNodeWin*
>(
4753 iter->GetNativeViewAccessible()));
4754 if (IsValidUiaRelationTarget(child) &&
4764bool AXPlatformNodeWin::CanHaveUIALabeledBy() {
4769 switch (ComputeUIAControlType()) {
4770 case UIA_ButtonControlTypeId:
4771 case UIA_CheckBoxControlTypeId:
4772 case UIA_DataItemControlTypeId:
4773 case UIA_MenuControlTypeId:
4774 case UIA_MenuBarControlTypeId:
4775 case UIA_RadioButtonControlTypeId:
4776 case UIA_ScrollBarControlTypeId:
4777 case UIA_SeparatorControlTypeId:
4778 case UIA_StatusBarControlTypeId:
4779 case UIA_TabItemControlTypeId:
4780 case UIA_TextControlTypeId:
4781 case UIA_ToolBarControlTypeId:
4782 case UIA_ToolTipControlTypeId:
4783 case UIA_TreeItemControlTypeId:
4790bool AXPlatformNodeWin::IsNameExposed()
const {
4791 const AXNodeData&
data = GetData();
4792 switch (
data.role) {
4794 return !GetDelegate()->GetChildCount();
4800bool AXPlatformNodeWin::IsUIAControl()
const {
4805 if (GetDelegate()->IsWebContent()) {
4807 if (IsInvisibleOrIgnored())
4816 auto* parent = FromNativeViewAccessible(GetDelegate()->GetParent());
4818 const AXNodeData&
data = parent->GetData();
4821 switch (
data.role) {
4847 parent = FromNativeViewAccessible(parent->GetParent());
4851 const AXNodeData&
data = GetData();
4863 data.GetNameFrom() ==
4869 switch (
data.role) {
4896 GetNameAsString16().empty() &&
4906 const AXNodeData&
data = GetData();
4912std::optional<LONG> AXPlatformNodeWin::ComputeUIALandmarkType()
const {
4913 const AXNodeData&
data = GetData();
4914 switch (
data.role) {
4920 return UIA_CustomLandmarkTypeId;
4933 return UIA_FormLandmarkTypeId;
4938 return UIA_MainLandmarkTypeId;
4941 return UIA_NavigationLandmarkTypeId;
4944 return UIA_SearchLandmarkTypeId;
4949 return UIA_CustomLandmarkTypeId;
4957bool AXPlatformNodeWin::IsInaccessibleDueToAncestor()
const {
4958 AXPlatformNodeWin* parent =
static_cast<AXPlatformNodeWin*
>(
4961 if (parent->ShouldHideChildrenForUIA())
4963 parent =
static_cast<AXPlatformNodeWin*
>(
4964 FromNativeViewAccessible(parent->GetParent()));
4969bool AXPlatformNodeWin::ShouldHideChildrenForUIA()
const {
4970 if (IsPlainTextField())
4973 auto role = GetData().role;
4990 if (GetChildCount() == 1) {
4991 AXPlatformNodeBase* only_child = GetFirstChild();
4992 return only_child && only_child->IsText();
5002std::u16string AXPlatformNodeWin::GetValue()
const {
5010 if (
value.empty() && (MSAAState() & STATE_SYSTEM_LINKED))
5016bool AXPlatformNodeWin::IsPlatformCheckable()
const {
5023bool AXPlatformNodeWin::ShouldNodeHaveFocusableState(
5024 const AXNodeData& data)
const {
5025 switch (
data.role) {
5032 AXPlatformNodeBase* parent = FromNativeViewAccessible(GetParent());
5052int AXPlatformNodeWin::MSAAState()
const {
5053 const AXNodeData&
data = GetData();
5060 msaa_state |= STATE_SYSTEM_BUSY;
5063 msaa_state |= STATE_SYSTEM_COLLAPSED;
5066 msaa_state |= STATE_SYSTEM_DEFAULT;
5071 msaa_state |= STATE_SYSTEM_EXPANDED;
5073 if (ShouldNodeHaveFocusableState(data))
5074 msaa_state |= STATE_SYSTEM_FOCUSABLE;
5078 msaa_state |= STATE_SYSTEM_HASPOPUP;
5086 if (GetDelegate()->ShouldIgnoreHoveredStateForTesting())
5087 msaa_state |= STATE_SYSTEM_HOTTRACKED;
5092 if (IsInvisibleOrIgnored())
5093 msaa_state |= STATE_SYSTEM_INVISIBLE;
5096 msaa_state |= STATE_SYSTEM_LINKED;
5101 msaa_state |= STATE_SYSTEM_EXTSELECTABLE;
5102 msaa_state |= STATE_SYSTEM_MULTISELECTABLE;
5105 if (GetDelegate()->IsOffscreen())
5106 msaa_state |= STATE_SYSTEM_OFFSCREEN;
5109 msaa_state |= STATE_SYSTEM_PROTECTED;
5114 if (
data.IsSelectable())
5115 msaa_state |= STATE_SYSTEM_SELECTABLE;
5118 msaa_state |= STATE_SYSTEM_SELECTED;
5123 msaa_state |= STATE_SYSTEM_TRAVERSED;
5129 switch (
data.GetCheckedState()) {
5135 msaa_state |= STATE_SYSTEM_PRESSED;
5140 msaa_state |= STATE_SYSTEM_PRESSED | STATE_SYSTEM_CHECKED;
5142 msaa_state |= STATE_SYSTEM_CHECKED;
5146 msaa_state |= STATE_SYSTEM_MIXED;
5152 switch (restriction) {
5154 msaa_state |= STATE_SYSTEM_UNAVAILABLE;
5157 msaa_state |= STATE_SYSTEM_READONLY;
5166 msaa_state |= STATE_SYSTEM_READONLY;
5176 msaa_state |= STATE_SYSTEM_UNAVAILABLE;
5183 if (focus ==
const_cast<AXPlatformNodeWin*
>(
this)->GetNativeViewAccessible())
5184 msaa_state |= STATE_SYSTEM_FOCUSED;
5190 AXPlatformNodeBase* container = FromNativeViewAccessible(GetParent());
5191 if (container && container->GetParent() == focus) {
5192 AXNodeData container_data = container->GetData();
5196 msaa_state |= STATE_SYSTEM_FOCUSED;
5209 msaa_state |= STATE_SYSTEM_FOCUSED;
5214 msaa_state |= STATE_SYSTEM_LINKED;
5219 msaa_state |= STATE_SYSTEM_MIXED;
5225std::optional<DWORD> AXPlatformNodeWin::MojoEventToMSAAEvent(
5229 return EVENT_SYSTEM_ALERT;
5233 return EVENT_OBJECT_STATECHANGE;
5236 return EVENT_OBJECT_FOCUS;
5238 return EVENT_OBJECT_LIVEREGIONCHANGED;
5240 return EVENT_SYSTEM_MENUSTART;
5242 return EVENT_SYSTEM_MENUEND;
5244 return EVENT_SYSTEM_MENUPOPUPSTART;
5246 return EVENT_SYSTEM_MENUPOPUPEND;
5248 return EVENT_OBJECT_SELECTION;
5250 return EVENT_OBJECT_SELECTIONADD;
5252 return EVENT_OBJECT_SELECTIONREMOVE;
5254 return EVENT_OBJECT_NAMECHANGE;
5256 return EVENT_OBJECT_HIDE;
5258 return EVENT_OBJECT_SHOW;
5260 return EVENT_OBJECT_VALUECHANGE;
5262 return EVENT_OBJECT_TEXTSELECTIONCHANGED;
5264 return std::nullopt;
5269std::optional<EVENTID> AXPlatformNodeWin::MojoEventToUIAEvent(
5273 return UIA_SystemAlertEventId;
5275 return UIA_Text_TextChangedEventId;
5279 return UIA_AutomationFocusChangedEventId;
5281 return UIA_LiveRegionChangedEventId;
5283 return UIA_SelectionItem_ElementSelectedEventId;
5285 return UIA_SelectionItem_ElementAddedToSelectionEventId;
5287 return UIA_SelectionItem_ElementRemovedFromSelectionEventId;
5289 return UIA_ToolTipClosedEventId;
5291 return UIA_ToolTipOpenedEventId;
5293 return std::nullopt;
5297std::optional<PROPERTYID> AXPlatformNodeWin::MojoEventToUIAProperty(
5301 return UIA_ControllerForPropertyId;
5303 return UIA_ToggleToggleStatePropertyId;
5306 return UIA_ExpandCollapseExpandCollapseStatePropertyId;
5310 return UIA_SelectionItemIsSelectedPropertyId;
5313 return UIA_ToggleToggleStatePropertyId;
5315 return std::nullopt;
5317 return std::nullopt;
5322BSTR AXPlatformNodeWin::GetValueAttributeAsBstr(AXPlatformNodeWin*
target) {
5332 std::u16string result;
5339 unsigned int color =
static_cast<unsigned int>(
5343 unsigned int red = (((color) >> 16) & 0xFF);
5344 unsigned int green = (((color) >> 8) & 0xFF);
5345 unsigned int blue = (((color) >> 0) & 0xFF);
5346 std::u16string value_text;
5381 if (result.empty() &&
target->GetData().IsRangeValueSupported()) {
5392 if (result.empty() &&
target->IsRichTextField())
5393 result =
target->GetInnerText();
5400HRESULT AXPlatformNodeWin::GetStringAttributeAsBstr(
5402 BSTR* value_bstr)
const {
5405 if (!GetString16Attribute(attribute, &str))
5414HRESULT AXPlatformNodeWin::GetNameAsBstr(BSTR* value_bstr)
const {
5415 std::u16string str = GetNameAsString16();
5423void AXPlatformNodeWin::AddAlertTarget() {}
5425void AXPlatformNodeWin::RemoveAlertTarget() {}
5427AXPlatformNodeWin* AXPlatformNodeWin::GetTargetFromChildID(
5428 const VARIANT& var_id) {
5429 if (V_VT(&var_id) != VT_I4)
5432 LONG child_id = V_I4(&var_id);
5433 if (child_id == CHILDID_SELF)
5436 if (child_id >= 1 && child_id <= GetDelegate()->GetChildCount()) {
5439 AXPlatformNodeBase*
base =
5440 FromNativeViewAccessible(GetDelegate()->ChildAtIndex(child_id - 1));
5441 return static_cast<AXPlatformNodeWin*
>(
base);
5448 AXPlatformNode* node = GetFromUniqueId(-child_id);
5452 AXPlatformNodeBase*
base =
5453 FromNativeViewAccessible(node->GetNativeViewAccessible());
5454 if (
base && !
base->IsDescendantOf(
this))
5457 return static_cast<AXPlatformNodeWin*
>(
base);
5460bool AXPlatformNodeWin::IsInTreeGrid() {
5461 AXPlatformNodeBase* container = FromNativeViewAccessible(GetParent());
5465 container = FromNativeViewAccessible(container->GetParent());
5473HRESULT AXPlatformNodeWin::AllocateComArrayFromVector(
5474 std::vector<LONG>& results,
5482 auto count = std::min((
LONG)results.size(), max);
5483 *n_selected = count;
5484 *selected =
static_cast<LONG*
>(CoTaskMemAlloc(
sizeof(
LONG) * count));
5486 for (
LONG i = 0;
i < count;
i++)
5487 (*selected)[
i] = results[
i];
5491bool AXPlatformNodeWin::IsPlaceholderText()
const {
5494 AXPlatformNodeWin* parent =
5495 static_cast<AXPlatformNodeWin*
>(FromNativeViewAccessible(GetParent()));
5498 return parent->IsTextField() &&
5502double AXPlatformNodeWin::GetHorizontalScrollPercent() {
5503 if (!IsHorizontallyScrollable())
5504 return UIA_ScrollPatternNoScroll;
5509 return 100.0 * (
x - x_min) / (x_max - x_min);
5512double AXPlatformNodeWin::GetVerticalScrollPercent() {
5513 if (!IsVerticallyScrollable())
5514 return UIA_ScrollPatternNoScroll;
5519 return 100.0 * (
y - y_min) / (y_max - y_min);
5522BSTR AXPlatformNodeWin::GetFontNameAttributeAsBSTR()
const {
5523 const std::u16string
string =
5529BSTR AXPlatformNodeWin::GetStyleNameAttributeAsBSTR()
const {
5530 std::u16string style_name =
5531 GetDelegate()->GetStyleNameAttributeAsLocalizedString();
5536TextDecorationLineStyle AXPlatformNodeWin::GetUIATextDecorationStyle(
5540 GetIntAttribute(int_attribute));
5542 switch (text_decoration_style) {
5544 return TextDecorationLineStyle::TextDecorationLineStyle_None;
5546 return TextDecorationLineStyle::TextDecorationLineStyle_Dot;
5548 return TextDecorationLineStyle::TextDecorationLineStyle_Dash;
5550 return TextDecorationLineStyle::TextDecorationLineStyle_Single;
5552 return TextDecorationLineStyle::TextDecorationLineStyle_Double;
5554 return TextDecorationLineStyle::TextDecorationLineStyle_Wavy;
5560AXPlatformNodeWin::PatternProviderFactoryMethod
5561AXPlatformNodeWin::GetPatternProviderFactoryMethod(PATTERNID pattern_id) {
5562 const AXNodeData&
data = GetData();
5564 switch (pattern_id) {
5565 case UIA_ExpandCollapsePatternId:
5566 if (
data.SupportsExpandCollapse()) {
5567 return &PatternProvider<IExpandCollapseProvider>;
5571 case UIA_GridPatternId:
5573 return &PatternProvider<IGridProvider>;
5577 case UIA_GridItemPatternId:
5579 return &PatternProvider<IGridItemProvider>;
5583 case UIA_InvokePatternId:
5584 if (
data.IsInvocable()) {
5585 return &PatternProvider<IInvokeProvider>;
5589 case UIA_RangeValuePatternId:
5590 if (
data.IsRangeValueSupported()) {
5591 return &PatternProvider<IRangeValueProvider>;
5595 case UIA_ScrollPatternId:
5596 if (IsScrollable()) {
5597 return &PatternProvider<IScrollProvider>;
5601 case UIA_ScrollItemPatternId:
5602 return &PatternProvider<IScrollItemProvider>;
5605 case UIA_SelectionItemPatternId:
5606 if (IsSelectionItemSupported()) {
5607 return &PatternProvider<ISelectionItemProvider>;
5611 case UIA_SelectionPatternId:
5613 return &PatternProvider<ISelectionProvider>;
5617 case UIA_TablePatternId:
5623 std::optional<bool> table_has_headers =
5624 GetDelegate()->GetTableHasColumnOrRowHeaderNode();
5625 if (table_has_headers.has_value() && table_has_headers.value()) {
5626 return &PatternProvider<ITableProvider>;
5631 case UIA_TableItemPatternId:
5638 std::optional<bool> table_has_headers =
5639 GetDelegate()->GetTableHasColumnOrRowHeaderNode();
5640 if (table_has_headers.has_value() && table_has_headers.value()) {
5641 return &PatternProvider<ITableItemProvider>;
5646 case UIA_TextEditPatternId:
5647 case UIA_TextPatternId:
5648 if (
IsText() || IsTextField() ||
5650 return &AXPlatformNodeTextProviderWin::CreateIUnknown;
5654 case UIA_TogglePatternId:
5656 return &PatternProvider<IToggleProvider>;
5660 case UIA_ValuePatternId:
5662 return &PatternProvider<IValueProvider>;
5666 case UIA_WindowPatternId:
5668 return &PatternProvider<IWindowProvider>;
5673 case UIA_AnnotationPatternId:
5674 case UIA_CustomNavigationPatternId:
5675 case UIA_DockPatternId:
5676 case UIA_DragPatternId:
5677 case UIA_DropTargetPatternId:
5678 case UIA_ItemContainerPatternId:
5679 case UIA_MultipleViewPatternId:
5680 case UIA_ObjectModelPatternId:
5681 case UIA_SpreadsheetPatternId:
5682 case UIA_SpreadsheetItemPatternId:
5683 case UIA_StylesPatternId:
5684 case UIA_SynchronizedInputPatternId:
5685 case UIA_TextPattern2Id:
5686 case UIA_TransformPatternId:
5687 case UIA_TransformPattern2Id:
5688 case UIA_VirtualizedItemPatternId:
5692 case UIA_LegacyIAccessiblePatternId:
5698void AXPlatformNodeWin::FireLiveRegionChangeRecursive() {
5700 if (HasStringAttribute(live_status_attr) &&
5701 GetStringAttribute(live_status_attr) !=
"off") {
5703 ::UiaRaiseAutomationEvent(
this, UIA_LiveRegionChangedEventId);
5707 for (
int index = 0; index < GetChildCount(); ++index) {
5708 auto* child =
static_cast<AXPlatformNodeWin*
>(
5709 FromNativeViewAccessible(ChildAtIndex(index)));
5714 if (child->GetDelegate()->IsWebContent())
5715 child->FireLiveRegionChangeRecursive();
5719AXPlatformNodeWin* AXPlatformNodeWin::GetLowestAccessibleElement() {
5720 if (!IsInaccessibleDueToAncestor())
5723 AXPlatformNodeWin* parent =
static_cast<AXPlatformNodeWin*
>(
5726 if (parent->ShouldHideChildrenForUIA())
5728 parent =
static_cast<AXPlatformNodeWin*
>(
5736AXPlatformNodeWin* AXPlatformNodeWin::GetFirstTextOnlyDescendant() {
5737 for (
auto* child =
static_cast<AXPlatformNodeWin*
>(GetFirstChild()); child;
5738 child =
static_cast<AXPlatformNodeWin*
>(child->GetNextSibling())) {
5739 if (child->IsText())
5741 if (AXPlatformNodeWin* descendant = child->GetFirstTextOnlyDescendant())
5747bool AXPlatformNodeWin::IsDescendantOf(AXPlatformNode* ancestor)
const {
5758 IRawElementProviderFragmentRoot* root;
5760 const_cast<AXPlatformNodeWin*
>(
this)->get_FragmentRoot(&root))) {
5761 AXPlatformNodeWin* root_win;
5762 if (
SUCCEEDED(root->QueryInterface(__uuidof(AXPlatformNodeWin),
5763 reinterpret_cast<void**
>(&root_win)))) {
5764 return ancestor ==
static_cast<AXPlatformNode*
>(root_win);
ax::mojom::Event event_type
void Insert(typename internal::VariantUtil< ExpectedVartype >::Type value)
constexpr int height() const
Vector2d OffsetFromOrigin() const
constexpr int width() const
static AXFragmentRootWin * GetForAcceleratedWidget(gfx::AcceleratedWidget widget)
static AXFragmentRootWin * GetFragmentRootParentOf(gfx::NativeViewAccessible accessible)
static constexpr uint32_t kScreenReader
static constexpr uint32_t kHTML
static const UiaRegistrarWin & GetInstance()
FlViewAccessible * accessible
const char FlTextDirection text_direction
@ kPdfActionableHighlight
@ kAttributeExplicitlyEmpty
const int32_t kUnknownAriaColumnOrRowCount
@ kDocumentSelectionChanged
@ kSilentlyEligibleForAnnotation
@ kAnnotationProcessFailed
@ kIneligibleForAnnotation
@ kWillNotAnnotateDueToScheme
@ kTextStrikethroughStyle
float GetScaleFactorForHWND(HWND hwnd)
std::string UTF16ToUTF8(std::u16string src)
void ReplaceChars(std::string in, std::string from, std::string to, std::string *out)
std::u16string UTF8ToUTF16(std::string src)
std::u16string ASCIIToUTF16(std::string src)
std::string JoinString(std::vector< std::string > tokens, std::string delimiter)
Dst ClampRound(Src value)
bool Contains(const Container &container, const Value &value)
std::string NumberToString(int32_t number)
std::u16string NumberToString16(float number)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
std::u16string WideStringToUtf16(const std::wstring_view str)
std::wstring Utf16ToWideString(const std::u16string_view str)
Point PointAtOffsetFromOrigin(const Vector2d &offset_from_origin)
Rect ToEnclosingRect(const RectF &r)
UnimplementedNativeViewAccessible * NativeViewAccessible
void CreateATLModuleIfNeeded()
bool IsImage(const ax::mojom::Role role)
const uint32_t kScreenReaderAndHTMLAccessibilityModes
bool IsValuePatternSupported(AXPlatformNodeDelegate *delegate)
bool IsContainerWithSelectableChildren(const ax::mojom::Role role)
bool IsControl(const ax::mojom::Role role)
bool IsReadOnlySupported(const ax::mojom::Role role)
const char * ToString(ax::mojom::Event event)
bool IsCellOrTableHeader(const ax::mojom::Role role)
bool HasPresentationalChildren(const ax::mojom::Role role)
bool IsMenuItem(ax::mojom::Role role)
bool IsTableLike(const ax::mojom::Role role)
bool SupportsOrientation(const ax::mojom::Role role)
bool IsTableHeader(ax::mojom::Role role)
bool SupportsToggle(const ax::mojom::Role role)
bool ShouldHaveReadonlyStateByDefault(const ax::mojom::Role role)
bool IsList(const ax::mojom::Role role)
bool IsDialog(const ax::mojom::Role role)
std::optional< int32_t > GetActivePopupAxUniqueId()
bool IsText(ax::mojom::Role role)
#define BASE_DCHECK(condition)
#define BASE_UNREACHABLE()