Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
ui::AXFragmentRootPlatformNodeWin Class Reference
Inheritance diagram for ui::AXFragmentRootPlatformNodeWin:

Public Member Functions

IFACEMETHODIMP FindItemByProperty (IRawElementProviderSimple *start_after_element, PROPERTYID property_id, VARIANT value, IRawElementProviderSimple **result) override
 
IFACEMETHODIMP get_HostRawElementProvider (IRawElementProviderSimple **host_element_provider) override
 
IFACEMETHODIMP GetPatternProvider (PATTERNID pattern_id, IUnknown **result) override
 
IFACEMETHODIMP GetPropertyValue (PROPERTYID property_id, VARIANT *result) override
 
IFACEMETHODIMP get_FragmentRoot (IRawElementProviderFragmentRoot **fragment_root) override
 
IFACEMETHODIMP ElementProviderFromPoint (double screen_physical_pixel_x, double screen_physical_pixel_y, IRawElementProviderFragment **element_provider) override
 
IFACEMETHODIMP GetFocus (IRawElementProviderFragment **focus) override
 
IFACEMETHODIMP AdviseEventAdded (EVENTID event_id, SAFEARRAY *property_ids) override
 
IFACEMETHODIMP AdviseEventRemoved (EVENTID event_id, SAFEARRAY *property_ids) override
 

Static Public Member Functions

static AXFragmentRootPlatformNodeWinCreate (AXPlatformNodeDelegate *delegate)
 

Detailed Description

Definition at line 16 of file ax_fragment_root_win.cc.

Member Function Documentation

◆ AdviseEventAdded()

IFACEMETHODIMP ui::AXFragmentRootPlatformNodeWin::AdviseEventAdded ( EVENTID  event_id,
SAFEARRAY *  property_ids 
)
inlineoverride

Definition at line 219 of file ax_fragment_root_win.cc.

220 {
221 if (event_id == UIA_LiveRegionChangedEventId) {
222 live_region_change_listeners_++;
223
224 if (live_region_change_listeners_ == 1) {
225 // Fire a LiveRegionChangedEvent for each live-region to tell the
226 // newly-attached assistive technology about the regions.
227 //
228 // Ideally we'd be able to direct these events to only the
229 // newly-attached AT, but we don't have that capability, so we only
230 // fire events when the *first* AT attaches. (A common scenario will
231 // be an attached screen-reader, then a software-keyboard attaches to
232 // handle an input field; we don't want the screen-reader to announce
233 // that every live-region has changed.) There isn't a perfect solution,
234 // but this heuristic seems to work well in practice.
235 FireLiveRegionChangeRecursive();
236 }
237 }
238 return S_OK;
239 }

◆ AdviseEventRemoved()

IFACEMETHODIMP ui::AXFragmentRootPlatformNodeWin::AdviseEventRemoved ( EVENTID  event_id,
SAFEARRAY *  property_ids 
)
inlineoverride

Definition at line 241 of file ax_fragment_root_win.cc.

242 {
243 if (event_id == UIA_LiveRegionChangedEventId) {
244 BASE_DCHECK(live_region_change_listeners_ > 0);
245 live_region_change_listeners_--;
246 }
247 return S_OK;
248 }
#define BASE_DCHECK(condition)
Definition: logging.h:63

◆ Create()

static AXFragmentRootPlatformNodeWin * ui::AXFragmentRootPlatformNodeWin::Create ( AXPlatformNodeDelegate delegate)
inlinestatic

Definition at line 28 of file ax_fragment_root_win.cc.

29 {
30 // Make sure ATL is initialized in this module.
32
33 CComObject<AXFragmentRootPlatformNodeWin>* instance = nullptr;
34 HRESULT hr =
35 CComObject<AXFragmentRootPlatformNodeWin>::CreateInstance(&instance);
37 instance->Init(delegate);
38 instance->AddRef();
39 return instance;
40 }
VkInstance instance
Definition: main.cc:48
void CreateATLModuleIfNeeded()
Definition: atl_module.h:22
#define SUCCEEDED(hr)

◆ ElementProviderFromPoint()

IFACEMETHODIMP ui::AXFragmentRootPlatformNodeWin::ElementProviderFromPoint ( double  screen_physical_pixel_x,
double  screen_physical_pixel_y,
IRawElementProviderFragment **  element_provider 
)
inlineoverride

Definition at line 157 of file ax_fragment_root_win.cc.

160 {
161 UIA_VALIDATE_CALL_1_ARG(element_provider);
162
163 *element_provider = nullptr;
164
165 gfx::NativeViewAccessible hit_element = nullptr;
166
167 // Descend the tree until we get a non-hit or can't go any further.
168 AXPlatformNode* node_to_test = this;
169 do {
170 gfx::NativeViewAccessible test_result =
171 node_to_test->GetDelegate()->HitTestSync(screen_physical_pixel_x,
172 screen_physical_pixel_y);
173 if (test_result != nullptr && test_result != hit_element) {
174 hit_element = test_result;
175 node_to_test = AXPlatformNode::FromNativeViewAccessible(test_result);
176 } else {
177 node_to_test = nullptr;
178 }
179 } while (node_to_test);
180
181 if (hit_element)
182 hit_element->QueryInterface(element_provider);
183
184 return S_OK;
185 }
#define UIA_VALIDATE_CALL_1_ARG(arg)
static AXPlatformNode * FromNativeViewAccessible(gfx::NativeViewAccessible accessible)
UnimplementedNativeViewAccessible * NativeViewAccessible

◆ FindItemByProperty()

IFACEMETHODIMP ui::AXFragmentRootPlatformNodeWin::FindItemByProperty ( IRawElementProviderSimple *  start_after_element,
PROPERTYID  property_id,
VARIANT  value,
IRawElementProviderSimple **  result 
)
inlineoverride

Definition at line 45 of file ax_fragment_root_win.cc.

49 {
51 *result = nullptr;
52
53 // We currently only support the custom UIA property ID for unique id.
54 if (property_id ==
55 UiaRegistrarWin::GetInstance().GetUiaUniqueIdPropertyId() &&
56 value.vt == VT_BSTR) {
57 int32_t ax_unique_id;
58
59 // TODO(gw280): https://github.com/flutter/flutter/issues/78802
60 // detect and handle errors
61 ax_unique_id = std::stoi(value.bstrVal);
62
63 // In the Windows accessibility platform implementation, id 0 represents
64 // self; a positive id represents the immediate descendants; and a
65 // negative id represents a unique id that can be mapped to any node.
66 if (AXPlatformNodeWin* result_platform_node =
67 static_cast<AXPlatformNodeWin*>(GetFromUniqueId(-ax_unique_id))) {
68 if (start_after_element) {
69 Microsoft::WRL::ComPtr<AXPlatformNodeWin> start_after_platform_node;
70 if (!SUCCEEDED(start_after_element->QueryInterface(
71 IID_PPV_ARGS(&start_after_platform_node))))
72 return E_INVALIDARG;
73
74 // We want |result| to be nullptr if it comes before or is equal to
75 // |start_after_element|.
76 if (start_after_platform_node->CompareTo(*result_platform_node) >= 0)
77 return S_OK;
78 }
79
80 return result_platform_node->QueryInterface(IID_PPV_ARGS(result));
81 }
82 }
83
84 return E_INVALIDARG;
85 }
static const UiaRegistrarWin & GetInstance()
uint8_t value
GAsyncResult * result
bool stoi(std::string_view s, SKSL_INT *value)
Definition: SkSLString.cpp:66

◆ get_FragmentRoot()

IFACEMETHODIMP ui::AXFragmentRootPlatformNodeWin::get_FragmentRoot ( IRawElementProviderFragmentRoot **  fragment_root)
inlineoverride

Definition at line 146 of file ax_fragment_root_win.cc.

147 {
148 UIA_VALIDATE_CALL_1_ARG(fragment_root);
149
150 QueryInterface(IID_PPV_ARGS(fragment_root));
151 return S_OK;
152 }

◆ get_HostRawElementProvider()

IFACEMETHODIMP ui::AXFragmentRootPlatformNodeWin::get_HostRawElementProvider ( IRawElementProviderSimple **  host_element_provider)
inlineoverride

Definition at line 91 of file ax_fragment_root_win.cc.

92 {
93 UIA_VALIDATE_CALL_1_ARG(host_element_provider);
94
95 HWND hwnd = GetDelegate()->GetTargetForNativeAccessibilityEvent();
96 return UiaHostProviderFromHwnd(hwnd, host_element_provider);
97 }

◆ GetFocus()

IFACEMETHODIMP ui::AXFragmentRootPlatformNodeWin::GetFocus ( IRawElementProviderFragment **  focus)
inlineoverride

Definition at line 187 of file ax_fragment_root_win.cc.

187 {
189
190 *focus = nullptr;
191
192 gfx::NativeViewAccessible focused_element = nullptr;
193
194 // GetFocus() can return a node at the root of a subtree, for example when
195 // transitioning from Views into web content. In such cases we want to
196 // continue drilling to retrieve the actual focused element.
197 AXPlatformNode* node_to_test = this;
198 do {
199 gfx::NativeViewAccessible test_result =
200 node_to_test->GetDelegate()->GetFocus();
201 if (test_result != nullptr && test_result != focused_element) {
202 focused_element = test_result;
203 node_to_test =
205 } else {
206 node_to_test = nullptr;
207 }
208 } while (node_to_test);
209
210 if (focused_element)
211 focused_element->QueryInterface(IID_PPV_ARGS(focus));
212
213 return S_OK;
214 }

◆ GetPatternProvider()

IFACEMETHODIMP ui::AXFragmentRootPlatformNodeWin::GetPatternProvider ( PATTERNID  pattern_id,
IUnknown **  result 
)
inlineoverride

Definition at line 99 of file ax_fragment_root_win.cc.

100 {
102 *result = nullptr;
103
104 if (pattern_id == UIA_ItemContainerPatternId) {
105 AddRef();
106 *result = static_cast<IItemContainerProvider*>(this);
107 return S_OK;
108 }
109
110 return AXPlatformNodeWin::GetPatternProviderImpl(pattern_id, result);
111 }

◆ GetPropertyValue()

IFACEMETHODIMP ui::AXFragmentRootPlatformNodeWin::GetPropertyValue ( PROPERTYID  property_id,
VARIANT *  result 
)
inlineoverride

Definition at line 113 of file ax_fragment_root_win.cc.

114 {
116
117 switch (property_id) {
118 default:
119 // UIA has a built-in provider that will expose values for several
120 // properties based on the HWND. This information is useful to someone
121 // examining the accessibility tree using tools such as Inspect. Return
122 // VT_EMPTY for most properties so that we don't override values from
123 // the default provider with blank data.
124 result->vt = VT_EMPTY;
125 break;
126
127 case UIA_IsControlElementPropertyId:
128 case UIA_IsContentElementPropertyId:
129 // Override IsControlElement and IsContentElement to fine tune which
130 // fragment roots appear in the control and content views.
131 result->vt = VT_BOOL;
132 result->boolVal =
133 static_cast<AXFragmentRootWin*>(GetDelegate())->IsControlElement()
134 ? VARIANT_TRUE
135 : VARIANT_FALSE;
136 break;
137 }
138
139 return S_OK;
140 }

The documentation for this class was generated from the following file: