Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
ax_platform_node_win.h
Go to the documentation of this file.
1//
2// Copyright 2015 The Chromium Authors. All rights reserved.
3// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5
6#ifndef UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_WIN_H_
7#define UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_WIN_H_
8
9#include <atlbase.h>
10#include <atlcom.h>
11#include <objbase.h>
12#include <oleacc.h>
13#include <oleauto.h>
14#include <uiautomation.h>
15#include <wrl/client.h>
16
17#include <array>
18#include <map>
19#include <string>
20#include <vector>
21
22#include "ax/ax_export.h"
25#include "gfx/range/range.h"
26
27//
28// Macros to use at the top of any AXPlatformNodeWin (or derived class) method
29// that implements a UIA COM interface. The error code UIA_E_ELEMENTNOTAVAILABLE
30// signals to the OS that the object is no longer valid and no further methods
31// should be called on it.
32//
33#define UIA_VALIDATE_CALL() \
34 if (!AXPlatformNodeBase::GetDelegate()) \
35 return UIA_E_ELEMENTNOTAVAILABLE;
36#define UIA_VALIDATE_CALL_1_ARG(arg) \
37 if (!AXPlatformNodeBase::GetDelegate()) \
38 return UIA_E_ELEMENTNOTAVAILABLE; \
39 if (!arg) \
40 return E_INVALIDARG; \
41 *arg = {};
42
43namespace base {
44namespace win {
45class VariantVector;
46} // namespace win
47} // namespace base
48
49namespace ui {
50
51class AXPlatformNodeWin;
52// TODO(nektar): Remove multithread superclass since we don't support it.
53class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
54 AXPlatformNodeWin : public CComObjectRootEx<CComMultiThreadModel>,
55 public IDispatchImpl<IAccessible>,
56 public IAccessibleEx,
57 public IExpandCollapseProvider,
58 public IGridItemProvider,
59 public IGridProvider,
60 public IInvokeProvider,
61 public IRangeValueProvider,
62 public IRawElementProviderFragment,
63 public IRawElementProviderSimple2,
64 public IScrollItemProvider,
65 public IScrollProvider,
66 public ISelectionItemProvider,
67 public ISelectionProvider,
68 public IServiceProvider,
69 public ITableItemProvider,
70 public ITableProvider,
71 public IToggleProvider,
72 public IValueProvider,
73 public IWindowProvider,
74 public AXPlatformNodeBase {
75 using IDispatchImpl::Invoke;
76
77 public:
78 BEGIN_COM_MAP(AXPlatformNodeWin)
79 // TODO(nektar): Find a way to remove the following entry because it's not
80 // an interface.
81 COM_INTERFACE_ENTRY(AXPlatformNodeWin)
82 COM_INTERFACE_ENTRY(IAccessible)
83 COM_INTERFACE_ENTRY(IAccessibleEx)
84 COM_INTERFACE_ENTRY(IDispatch)
85 COM_INTERFACE_ENTRY(IExpandCollapseProvider)
86 COM_INTERFACE_ENTRY(IGridItemProvider)
87 COM_INTERFACE_ENTRY(IGridProvider)
88 COM_INTERFACE_ENTRY(IInvokeProvider)
89 COM_INTERFACE_ENTRY(IRangeValueProvider)
90 COM_INTERFACE_ENTRY(IRawElementProviderFragment)
91 COM_INTERFACE_ENTRY(IRawElementProviderSimple)
92 COM_INTERFACE_ENTRY(IRawElementProviderSimple2)
93 COM_INTERFACE_ENTRY(IScrollItemProvider)
94 COM_INTERFACE_ENTRY(IScrollProvider)
95 COM_INTERFACE_ENTRY(ISelectionItemProvider)
96 COM_INTERFACE_ENTRY(ISelectionProvider)
97 COM_INTERFACE_ENTRY(ITableItemProvider)
98 COM_INTERFACE_ENTRY(ITableProvider)
99 COM_INTERFACE_ENTRY(IToggleProvider)
100 COM_INTERFACE_ENTRY(IValueProvider)
101 COM_INTERFACE_ENTRY(IWindowProvider)
102 COM_INTERFACE_ENTRY(IServiceProvider)
103 END_COM_MAP()
104
105 ~AXPlatformNodeWin() override;
106
107 void Init(AXPlatformNodeDelegate* delegate) override;
108
109 // AXPlatformNode overrides.
110 gfx::NativeViewAccessible GetNativeViewAccessible() override;
111 void NotifyAccessibilityEvent(ax::mojom::Event event_type) override;
112
113 // AXPlatformNodeBase overrides.
114 void Destroy() override;
115 std::u16string GetValue() const override;
116 bool IsPlatformCheckable() const override;
117
118 //
119 // IAccessible methods.
120 //
121
122 // Retrieves the child element or child object at a given point on the screen.
123 IFACEMETHODIMP accHitTest(LONG screen_physical_pixel_x,
124 LONG screen_physical_pixel_y,
125 VARIANT* child) override;
126
127 // Performs the object's default action.
128 IFACEMETHODIMP accDoDefaultAction(VARIANT var_id) override;
129
130 // Retrieves the specified object's current screen location.
131 IFACEMETHODIMP accLocation(LONG* physical_pixel_left,
132 LONG* physical_pixel_top,
133 LONG* width,
134 LONG* height,
135 VARIANT var_id) override;
136
137 // Traverses to another UI element and retrieves the object.
138 IFACEMETHODIMP accNavigate(LONG nav_dir,
139 VARIANT start,
140 VARIANT* end) override;
141
142 // Retrieves an IDispatch interface pointer for the specified child.
143 IFACEMETHODIMP get_accChild(VARIANT var_child,
144 IDispatch** disp_child) override;
145
146 // Retrieves the number of accessible children.
147 IFACEMETHODIMP get_accChildCount(LONG* child_count) override;
148
149 // Retrieves a string that describes the object's default action.
150 IFACEMETHODIMP get_accDefaultAction(VARIANT var_id,
151 BSTR* default_action) override;
152
153 // Retrieves the tooltip description.
154 IFACEMETHODIMP get_accDescription(VARIANT var_id, BSTR* desc) override;
155
156 // Retrieves the object that has the keyboard focus.
157 IFACEMETHODIMP get_accFocus(VARIANT* focus_child) override;
158
159 // Retrieves the specified object's shortcut.
160 IFACEMETHODIMP get_accKeyboardShortcut(VARIANT var_id,
161 BSTR* access_key) override;
162
163 // Retrieves the name of the specified object.
164 IFACEMETHODIMP get_accName(VARIANT var_id, BSTR* name) override;
165
166 // Retrieves the IDispatch interface of the object's parent.
167 IFACEMETHODIMP get_accParent(IDispatch** disp_parent) override;
168
169 // Retrieves information describing the role of the specified object.
170 IFACEMETHODIMP get_accRole(VARIANT var_id, VARIANT* role) override;
171
172 // Retrieves the current state of the specified object.
173 IFACEMETHODIMP get_accState(VARIANT var_id, VARIANT* state) override;
174
175 // Gets the help string for the specified object.
176 IFACEMETHODIMP get_accHelp(VARIANT var_id, BSTR* help) override;
177
178 // Retrieve or set the string value associated with the specified object.
179 // Setting the value is not typically used by screen readers, but it's
180 // used frequently by automation software.
181 IFACEMETHODIMP get_accValue(VARIANT var_id, BSTR* value) override;
182 IFACEMETHODIMP put_accValue(VARIANT var_id, BSTR new_value) override;
183
184 // IAccessible methods not implemented.
185 IFACEMETHODIMP get_accSelection(VARIANT* selected) override;
186 IFACEMETHODIMP accSelect(LONG flags_sel, VARIANT var_id) override;
187 IFACEMETHODIMP get_accHelpTopic(BSTR* help_file,
188 VARIANT var_id,
189 LONG* topic_id) override;
190 IFACEMETHODIMP put_accName(VARIANT var_id, BSTR put_name) override;
191
192 //
193 // IAccessibleEx methods.
194 //
195
196 IFACEMETHODIMP GetObjectForChild(LONG child_id,
197 IAccessibleEx** result) override;
198
199 IFACEMETHODIMP GetIAccessiblePair(IAccessible** accessible,
200 LONG* child_id) override;
201
202 // IAccessibleEx methods not implemented.
203 IFACEMETHODIMP
204 ConvertReturnedElement(IRawElementProviderSimple* element,
205 IAccessibleEx** acc) override;
206
207 //
208 // IExpandCollapseProvider methods.
209 //
210
211 IFACEMETHODIMP Collapse() override;
212
213 IFACEMETHODIMP Expand() override;
214
215 IFACEMETHODIMP get_ExpandCollapseState(ExpandCollapseState* result) override;
216
217 //
218 // IGridItemProvider methods.
219 //
220
221 IFACEMETHODIMP get_Column(int* result) override;
222
223 IFACEMETHODIMP get_ColumnSpan(int* result) override;
224
225 IFACEMETHODIMP get_ContainingGrid(
226 IRawElementProviderSimple** result) override;
227
228 IFACEMETHODIMP get_Row(int* result) override;
229
230 IFACEMETHODIMP get_RowSpan(int* result) override;
231
232 //
233 // IGridProvider methods.
234 //
235
236 IFACEMETHODIMP GetItem(int row,
237 int column,
238 IRawElementProviderSimple** result) override;
239
240 IFACEMETHODIMP get_RowCount(int* result) override;
241
242 IFACEMETHODIMP get_ColumnCount(int* result) override;
243
244 //
245 // IInvokeProvider methods.
246 //
247
248 IFACEMETHODIMP Invoke() override;
249
250 //
251 // IScrollItemProvider methods.
252 //
253
254 IFACEMETHODIMP ScrollIntoView() override;
255
256 //
257 // IScrollProvider methods.
258 //
259
260 IFACEMETHODIMP Scroll(ScrollAmount horizontal_amount,
261 ScrollAmount vertical_amount) override;
262
263 IFACEMETHODIMP SetScrollPercent(double horizontal_percent,
264 double vertical_percent) override;
265
266 IFACEMETHODIMP get_HorizontallyScrollable(BOOL* result) override;
267
268 IFACEMETHODIMP get_HorizontalScrollPercent(double* result) override;
269
270 // Horizontal size of the viewable region as a percentage of the total content
271 // area.
272 IFACEMETHODIMP get_HorizontalViewSize(double* result) override;
273
274 IFACEMETHODIMP get_VerticallyScrollable(BOOL* result) override;
275
276 IFACEMETHODIMP get_VerticalScrollPercent(double* result) override;
277
278 // Vertical size of the viewable region as a percentage of the total content
279 // area.
280 IFACEMETHODIMP get_VerticalViewSize(double* result) override;
281
282 //
283 // ISelectionItemProvider methods.
284 //
285
286 IFACEMETHODIMP AddToSelection() override;
287
288 IFACEMETHODIMP RemoveFromSelection() override;
289
290 IFACEMETHODIMP Select() override;
291
292 IFACEMETHODIMP get_IsSelected(BOOL* result) override;
293
294 IFACEMETHODIMP get_SelectionContainer(
295 IRawElementProviderSimple** result) override;
296
297 //
298 // ISelectionProvider methods.
299 //
300
301 IFACEMETHODIMP GetSelection(SAFEARRAY** result) override;
302
303 IFACEMETHODIMP get_CanSelectMultiple(BOOL* result) override;
304
305 IFACEMETHODIMP get_IsSelectionRequired(BOOL* result) override;
306
307 //
308 // ITableItemProvider methods.
309 //
310
311 IFACEMETHODIMP GetColumnHeaderItems(SAFEARRAY** result) override;
312
313 IFACEMETHODIMP GetRowHeaderItems(SAFEARRAY** result) override;
314
315 //
316 // ITableProvider methods.
317 //
318
319 IFACEMETHODIMP GetColumnHeaders(SAFEARRAY** result) override;
320
321 IFACEMETHODIMP GetRowHeaders(SAFEARRAY** result) override;
322
323 IFACEMETHODIMP get_RowOrColumnMajor(RowOrColumnMajor* result) override;
324
325 //
326 // IToggleProvider methods.
327 //
328
329 IFACEMETHODIMP Toggle() override;
330
331 IFACEMETHODIMP get_ToggleState(ToggleState* result) override;
332
333 //
334 // IValueProvider methods.
335 //
336
337 IFACEMETHODIMP SetValue(LPCWSTR val) override;
338
339 IFACEMETHODIMP get_IsReadOnly(BOOL* result) override;
340
341 IFACEMETHODIMP get_Value(BSTR* result) override;
342
343 //
344 // IWindowProvider methods.
345 //
346
347 IFACEMETHODIMP SetVisualState(WindowVisualState window_visual_state) override;
348
349 IFACEMETHODIMP Close() override;
350
351 IFACEMETHODIMP WaitForInputIdle(int milliseconds, BOOL* result) override;
352
353 IFACEMETHODIMP get_CanMaximize(BOOL* result) override;
354
355 IFACEMETHODIMP get_CanMinimize(BOOL* result) override;
356
357 IFACEMETHODIMP get_IsModal(BOOL* result) override;
358
359 IFACEMETHODIMP get_WindowVisualState(WindowVisualState* result) override;
360
361 IFACEMETHODIMP get_WindowInteractionState(
362 WindowInteractionState* result) override;
363
364 IFACEMETHODIMP get_IsTopmost(BOOL* result) override;
365
366 //
367 // IRangeValueProvider methods.
368 //
369
370 IFACEMETHODIMP SetValue(double val) override;
371
372 IFACEMETHODIMP get_LargeChange(double* result) override;
373
374 IFACEMETHODIMP get_Maximum(double* result) override;
375
376 IFACEMETHODIMP get_Minimum(double* result) override;
377
378 IFACEMETHODIMP get_SmallChange(double* result) override;
379
380 IFACEMETHODIMP get_Value(double* result) override;
381
382 //
383 // IRawElementProviderFragment methods.
384 //
385
386 IFACEMETHODIMP Navigate(
387 NavigateDirection direction,
388 IRawElementProviderFragment** element_provider) override;
389 IFACEMETHODIMP GetRuntimeId(SAFEARRAY** runtime_id) override;
390 IFACEMETHODIMP get_BoundingRectangle(
391 UiaRect* screen_physical_pixel_bounds) override;
392 IFACEMETHODIMP GetEmbeddedFragmentRoots(
393 SAFEARRAY** embedded_fragment_roots) override;
394 IFACEMETHODIMP SetFocus() override;
395 IFACEMETHODIMP get_FragmentRoot(
396 IRawElementProviderFragmentRoot** fragment_root) override;
397
398 //
399 // IRawElementProviderSimple methods.
400 //
401
402 IFACEMETHODIMP GetPatternProvider(PATTERNID pattern_id,
403 IUnknown** result) override;
404
405 IFACEMETHODIMP GetPropertyValue(PROPERTYID property_id,
406 VARIANT* result) override;
407
408 IFACEMETHODIMP
409 get_ProviderOptions(enum ProviderOptions* ret) override;
410
411 IFACEMETHODIMP
412 get_HostRawElementProvider(IRawElementProviderSimple** provider) override;
413
414 //
415 // IRawElementProviderSimple2 methods.
416 //
417
418 IFACEMETHODIMP ShowContextMenu() override;
419
420 //
421 // IServiceProvider methods.
422 //
423
424 IFACEMETHODIMP QueryService(REFGUID guidService,
425 REFIID riid,
426 void** object) override;
427
428 //
429 // Methods used by the ATL COM map.
430 //
431
432 // Called by BEGIN_COM_MAP() / END_COM_MAP().
433 static STDMETHODIMP InternalQueryInterface(void* this_ptr,
434 const _ATL_INTMAP_ENTRY* entries,
435 REFIID riid,
436 void** object);
437
438 // Support method for ITextRangeProvider::GetAttributeValue.
439 // If either |start_offset| or |end_offset| are not provided then the
440 // endpoint is treated as the start or end of the node respectively.
441 HRESULT GetTextAttributeValue(TEXTATTRIBUTEID attribute_id,
442 const std::optional<int>& start_offset,
443 const std::optional<int>& end_offset,
445
446 // IRawElementProviderSimple support method.
447 bool IsPatternProviderSupported(PATTERNID pattern_id);
448
449 // Prefer GetPatternProviderImpl when calling internally. We should avoid
450 // calling external APIs internally as it will cause the histograms to become
451 // innaccurate.
452 HRESULT GetPatternProviderImpl(PATTERNID pattern_id, IUnknown** result);
453
454 // Prefer GetPropertyValueImpl when calling internally. We should avoid
455 // calling external APIs internally as it will cause the histograms to become
456 // innaccurate.
457 HRESULT GetPropertyValueImpl(PROPERTYID property_id, VARIANT* result);
458
459 // Helper to return the runtime id (without going through a SAFEARRAY)
460 using RuntimeIdArray = std::array<int, 2>;
461 void GetRuntimeIdArray(RuntimeIdArray& runtime_id);
462
463 // Updates the active composition range and fires UIA text edit event about
464 // composition (active or committed)
465 void OnActiveComposition(const gfx::Range& range,
466 const std::u16string& active_composition_text,
467 bool is_composition_committed);
468 // Returns true if there is an active composition
469 bool HasActiveComposition() const;
470 // Returns the start/end offsets of the active composition
471 gfx::Range GetActiveCompositionOffsets() const;
472
473 // Helper to recursively find live-regions and fire a change event on them
474 void FireLiveRegionChangeRecursive();
475
476 // Returns the parent node that makes this node inaccessible.
477 AXPlatformNodeWin* GetLowestAccessibleElement();
478
479 // Returns the first |IsTextOnlyObject| descendant using
480 // depth-first pre-order traversal.
481 AXPlatformNodeWin* GetFirstTextOnlyDescendant();
482
483 // Convert a mojo event to an MSAA event. Exposed for testing.
484 static std::optional<DWORD> MojoEventToMSAAEvent(ax::mojom::Event event);
485
486 // Convert a mojo event to a UIA event. Exposed for testing.
487 static std::optional<EVENTID> MojoEventToUIAEvent(ax::mojom::Event event);
488
489 // Convert a mojo event to a UIA property id. Exposed for testing.
490 std::optional<PROPERTYID> MojoEventToUIAProperty(ax::mojom::Event event);
491
492 // |AXPlatformNodeBase|
493 bool IsDescendantOf(AXPlatformNode* ancestor) const override;
494
495 protected:
496 // This is hard-coded; all products based on the Chromium engine will have the
497 // same framework name, so that assistive technology can detect any
498 // Chromium-based product.
499 static constexpr const wchar_t* FRAMEWORK_ID = L"Chrome";
500
501 AXPlatformNodeWin();
502
503 int MSAAState() const;
504
505 int MSAARole();
506
507 std::u16string UIAAriaRole();
508
509 std::u16string ComputeUIAProperties();
510
511 LONG ComputeUIAControlType();
512
513 AXPlatformNodeWin* ComputeUIALabeledBy();
514
515 bool CanHaveUIALabeledBy();
516
517 bool IsNameExposed() const;
518
519 bool IsUIAControl() const;
520
521 std::optional<LONG> ComputeUIALandmarkType() const;
522
523 bool IsInaccessibleDueToAncestor() const;
524
525 bool ShouldHideChildrenForUIA() const;
526
527 ExpandCollapseState ComputeExpandCollapseState() const;
528
529 // AXPlatformNodeBase overrides.
530 void Dispose() override;
531
532 AXHypertext old_hypertext_;
533
534 // These protected methods are still used by BrowserAccessibilityComWin. At
535 // some point post conversion, we can probably move these to be private
536 // methods.
537
538 // A helper to add the given string value to |attributes|.
539 void AddAttributeToList(const char* name,
540 const char* value,
541 PlatformAttributeList* attributes) override;
542
543 private:
544 bool IsWebAreaForPresentationalIframe();
545 bool ShouldNodeHaveFocusableState(const AXNodeData& data) const;
546
547 // Get the value attribute as a Bstr, this means something different depending
548 // on the type of element being queried. (e.g. kColorWell uses kColorValue).
549 static BSTR GetValueAttributeAsBstr(AXPlatformNodeWin* target);
550
551 HRESULT GetStringAttributeAsBstr(ax::mojom::StringAttribute attribute,
552 BSTR* value_bstr) const;
553
554 HRESULT GetNameAsBstr(BSTR* value_bstr) const;
555
556 // Escapes characters in string attributes as required by the UIA Aria
557 // Property Spec. It's okay for input to be the same as output.
558 static void SanitizeStringAttributeForUIAAriaProperty(
559 const std::u16string& input,
560 std::u16string* output);
561
562 // If the string attribute |attribute| is present, add its value as a
563 // UIA AriaProperties Property with the name |uia_aria_property|.
564 void StringAttributeToUIAAriaProperty(std::vector<std::u16string>& properties,
566 const char* uia_aria_property);
567
568 // If the bool attribute |attribute| is present, add its value as a
569 // UIA AriaProperties Property with the name |uia_aria_property|.
570 void BoolAttributeToUIAAriaProperty(std::vector<std::u16string>& properties,
571 ax::mojom::BoolAttribute attribute,
572 const char* uia_aria_property);
573
574 // If the int attribute |attribute| is present, add its value as a
575 // UIA AriaProperties Property with the name |uia_aria_property|.
576 void IntAttributeToUIAAriaProperty(std::vector<std::u16string>& properties,
577 ax::mojom::IntAttribute attribute,
578 const char* uia_aria_property);
579
580 // If the float attribute |attribute| is present, add its value as a
581 // UIA AriaProperties Property with the name |uia_aria_property|.
582 void FloatAttributeToUIAAriaProperty(std::vector<std::u16string>& properties,
584 const char* uia_aria_property);
585
586 // If the state |state| exists, set the
587 // UIA AriaProperties Property with the name |uia_aria_property| to "true".
588 // Otherwise set the AriaProperties Property to "false".
589 void StateToUIAAriaProperty(std::vector<std::u16string>& properties,
590 ax::mojom::State state,
591 const char* uia_aria_property);
592
593 // If the Html attribute |html_attribute_name| is present, add its value as a
594 // UIA AriaProperties Property with the name |uia_aria_property|.
595 void HtmlAttributeToUIAAriaProperty(std::vector<std::u16string>& properties,
596 const char* html_attribute_name,
597 const char* uia_aria_property);
598
599 // If the IntList attribute |attribute| is present, return an array
600 // of automation elements referenced by the ids in the
601 // IntList attribute. Otherwise return an empty array.
602 // The function will skip over any ids that cannot be resolved.
603 SAFEARRAY* CreateUIAElementsArrayForRelation(
604 const ax::mojom::IntListAttribute& attribute);
605
606 // Return an array of automation elements based on the attribute
607 // IntList::kControlsIds for web content and IntAttribute::kViewPopupId. These
608 // two attributes denote the controllees, web content elements and view popup
609 // element respectively.
610 // The function will skip over any ids that cannot be resolved.
611 SAFEARRAY* CreateUIAControllerForArray();
612
613 // Return an unordered array of automation elements which reference this node
614 // for the given attribute.
615 SAFEARRAY* CreateUIAElementsArrayForReverseRelation(
616 const ax::mojom::IntListAttribute& attribute);
617
618 // Return a vector of AXPlatformNodeWin referenced by the ids in function
619 // argument. The function will skip over any ids that cannot be resolved as
620 // valid relation target.
621 std::vector<AXPlatformNodeWin*> CreatePlatformNodeVectorFromRelationIdVector(
622 std::vector<int32_t>& relation_id_list);
623
624 // Create a safearray of automation elements from a vector of
625 // AXPlatformNodeWin.
626 // The caller should validate that all of the given ax platform nodes are
627 // valid relation targets.
628 SAFEARRAY* CreateUIAElementsSafeArray(
629 std::vector<AXPlatformNodeWin*>& platform_node_list);
630
631 // Return an array that contains the center x, y coordinates of the
632 // clickable point.
633 SAFEARRAY* CreateClickablePointArray();
634
635 // Returns the scroll offsets to which UI Automation should scroll an
636 // accessible object, given the horizontal and vertical scroll amounts.
637 gfx::Vector2d CalculateUIAScrollPoint(
638 const ScrollAmount horizontal_amount,
639 const ScrollAmount vertical_amount) const;
640
641 void AddAlertTarget();
642 void RemoveAlertTarget();
643
644 // Enum used to specify whether IAccessibleText is requesting text
645 // At, Before, or After a specified offset.
646 enum class TextOffsetType { kAtOffset, kBeforeOffset, kAfterOffset };
647
648 // Many MSAA methods take a var_id parameter indicating that the operation
649 // should be performed on a particular child ID, rather than this object.
650 // This method tries to figure out the target object from |var_id| and
651 // returns a pointer to the target object if it exists, otherwise nullptr.
652 // Does not return a new reference.
653 AXPlatformNodeWin* GetTargetFromChildID(const VARIANT& var_id);
654
655 // Returns true if this node is in a treegrid.
656 bool IsInTreeGrid();
657
658 // Helper method for returning selected indicies. It is expected that the
659 // caller ensures that the input has been validated.
660 HRESULT AllocateComArrayFromVector(std::vector<LONG>& results,
661 LONG max,
662 LONG** selected,
663 LONG* n_selected);
664
665 // Helper method for mutating the ISelectionItemProvider selected state
666 HRESULT ISelectionItemProviderSetSelected(bool selected) const;
667
668 // Helper method getting the selected status.
669 bool ISelectionItemProviderIsSelected() const;
670
671 //
672 // Getters for UIA GetTextAttributeValue
673 //
674
675 // Computes the AnnotationTypes Attribute for the current node.
676 HRESULT GetAnnotationTypesAttribute(const std::optional<int>& start_offset,
677 const std::optional<int>& end_offset,
679 // Lookup the LCID for the language this node is using.
680 // Returns base::nullopt if there was an error.
681 std::optional<LCID> GetCultureAttributeAsLCID() const;
682 // Converts an int attribute to a COLORREF
683 COLORREF GetIntAttributeAsCOLORREF(ax::mojom::IntAttribute attribute) const;
684 // Converts the ListStyle to UIA BulletStyle
685 BulletStyle ComputeUIABulletStyle() const;
686 // Helper to get the UIA StyleId enumeration for this node
687 LONG ComputeUIAStyleId() const;
688 // Convert mojom TextAlign to UIA HorizontalTextAlignment enumeration
689 static std::optional<HorizontalTextAlignment>
690 AXTextAlignToUIAHorizontalTextAlignment(ax::mojom::TextAlign text_align);
691 // Converts IntAttribute::kHierarchicalLevel to UIA StyleId enumeration
692 static LONG AXHierarchicalLevelToUIAStyleId(int32_t hierarchical_level);
693 // Converts a ListStyle to UIA StyleId enumeration
694 static LONG AXListStyleToUIAStyleId(ax::mojom::ListStyle list_style);
695 // Convert mojom TextDirection to UIA FlowDirections enumeration
696 static FlowDirections TextDirectionToFlowDirections(
698
699 // Helper method for |GetMarkerTypeFromRange| which aggregates all
700 // of the ranges for |marker_type| attached to |node|.
701 static void AggregateRangesForMarkerType(
702 AXPlatformNodeBase* node,
703 ax::mojom::MarkerType marker_type,
704 int offset_ranges_amount,
705 std::vector<std::pair<int, int>>* ranges);
706
707 enum class MarkerTypeRangeResult {
708 // The MarkerType does not overlap the range.
709 kNone,
710 // The MarkerType overlaps the entire range.
711 kMatch,
712 // The MarkerType partially overlaps the range.
713 kMixed,
714 };
715
716 // Determine if a text range overlaps a |marker_type|, and whether
717 // the overlap is a partial or complete match.
718 MarkerTypeRangeResult GetMarkerTypeFromRange(
719 const std::optional<int>& start_offset,
720 const std::optional<int>& end_offset,
721 ax::mojom::MarkerType marker_type);
722
723 bool IsAncestorComboBox();
724
725 bool IsPlaceholderText() const;
726
727 // Helper method for getting the horizontal scroll percent.
728 double GetHorizontalScrollPercent();
729
730 // Helper method for getting the vertical scroll percent.
731 double GetVerticalScrollPercent();
732
733 // Helper to get the UIA FontName for this node as a BSTR.
734 BSTR GetFontNameAttributeAsBSTR() const;
735
736 // Helper to get the UIA StyleName for this node as a BSTR.
737 BSTR GetStyleNameAttributeAsBSTR() const;
738
739 // Gets the TextDecorationLineStyle based on the provided int attribute.
740 TextDecorationLineStyle GetUIATextDecorationStyle(
741 const ax::mojom::IntAttribute int_attribute) const;
742
743 // IRawElementProviderSimple support methods.
744
745 using PatternProviderFactoryMethod = void (*)(AXPlatformNodeWin*, IUnknown**);
746
747 PatternProviderFactoryMethod GetPatternProviderFactoryMethod(
748 PATTERNID pattern_id);
749
750 // Fires UIA text edit event about composition (active or committed)
751 void FireUiaTextEditTextChangedEvent(
752 const gfx::Range& range,
753 const std::u16string& active_composition_text,
754 bool is_composition_committed);
755
756 // Return true if the given element is valid enough to be returned as a value
757 // for a UIA relation property (e.g. ControllerFor).
758 static bool IsValidUiaRelationTarget(AXPlatformNode* ax_platform_node);
759
760 // Start and end offsets of an active composition
761 gfx::Range active_composition_range_;
762};
763
764} // namespace ui
765
766#endif // UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_WIN_H_
ax::mojom::Event event_type
#define AX_EXPORT
Definition ax_export.h:29
static int input(yyscan_t yyscanner)
FlViewAccessible * accessible
uint32_t * target
const char * name
Definition fuchsia.cc:50
@ kNone
Definition layer.h:43
UnimplementedNativeViewAccessible * NativeViewAccessible
int32_t height
int32_t width
const size_t end
int BOOL
long LONG
#define REFGUID