Flutter Windows Embedder
flutter::AccessibilityBridgeWindows Class Reference

#include <accessibility_bridge_windows.h>

Inheritance diagram for flutter::AccessibilityBridgeWindows:
flutter::AccessibilityBridge flutter::FlutterPlatformNodeDelegate::OwnerBridge

Public Member Functions

 AccessibilityBridgeWindows (FlutterWindowsView *view)
 
virtual ~AccessibilityBridgeWindows ()=default
 
void DispatchAccessibilityAction (AccessibilityNodeId target, FlutterSemanticsAction action, fml::MallocMapping data) override
 Dispatch accessibility action back to the Flutter framework. These actions are generated in the native accessibility system when users interact with the assistive technologies. For example, a FlutterSemanticsAction::kFlutterSemanticsActionTap is fired when user click or touch the screen. More...
 
virtual void DispatchWinAccessibilityEvent (std::shared_ptr< FlutterPlatformNodeDelegateWindows > node_delegate, ax::mojom::Event event_type)
 
virtual void SetFocus (std::shared_ptr< FlutterPlatformNodeDelegateWindows > node_delegate)
 
gfx::NativeViewAccessible GetChildOfAXFragmentRoot () override
 
gfx::NativeViewAccessible GetParentOfAXFragmentRoot () override
 
bool IsAXFragmentRootAControlElement () override
 
- Public Member Functions inherited from flutter::AccessibilityBridge
 AccessibilityBridge ()
 Creates a new instance of a accessibility bridge. More...
 
virtual ~AccessibilityBridge ()
 
void AddFlutterSemanticsNodeUpdate (const FlutterSemanticsNode2 &node)
 Adds a semantics node update to the pending semantics update. Calling this method alone will NOT update the semantics tree. To flush the pending updates, call the CommitUpdates(). More...
 
void AddFlutterSemanticsCustomActionUpdate (const FlutterSemanticsCustomAction2 &action)
 Adds a custom semantics action update to the pending semantics update. Calling this method alone will NOT update the semantics tree. To flush the pending updates, call the CommitUpdates(). More...
 
void CommitUpdates ()
 Flushes the pending updates and applies them to this accessibility bridge. Calling this with no pending updates does nothing, and callers should call this method at the end of an atomic batch to avoid leaving the tree in a unstable state. For example if a node reparents from A to B, callers should only call this method when both removal from A and addition to B are in the pending updates. More...
 
std::weak_ptr< FlutterPlatformNodeDelegateGetFlutterPlatformNodeDelegateFromID (AccessibilityNodeId id) const
 Get the flutter platform node delegate with the given id from this accessibility bridge. Returns expired weak_ptr if the delegate associated with the id does not exist or has been removed from the accessibility tree. More...
 
const ui::AXTreeData & GetAXTreeData () const
 Get the ax tree data from this accessibility bridge. The tree data contains information such as the id of the node that has the keyboard focus or the text selection range. More...
 
const std::vector< ui::AXEventGenerator::TargetedEvent > GetPendingEvents () const
 Gets all pending accessibility events generated during semantics updates. This is useful when deciding how to handle events in AccessibilityBridgeDelegate::OnAccessibilityEvent in case one may decide to handle an event differently based on all pending events. More...
 
ui::AXNode * GetNodeFromTree (const ui::AXTreeID tree_id, const ui::AXNode::AXID node_id) const override
 
ui::AXNode * GetNodeFromTree (const ui::AXNode::AXID node_id) const override
 
ui::AXTreeID GetTreeID () const override
 
ui::AXTreeID GetParentTreeID () const override
 
ui::AXNode * GetRootAsAXNode () const override
 
ui::AXNode * GetParentNodeFromParentTreeAsAXNode () const override
 
ui::AXTree * GetTree () const override
 
ui::AXPlatformNode * GetPlatformNodeFromTree (const ui::AXNode::AXID node_id) const override
 
ui::AXPlatformNode * GetPlatformNodeFromTree (const ui::AXNode &node) const override
 
ui::AXPlatformNodeDelegate * RootDelegate () const override
 
- Public Member Functions inherited from flutter::FlutterPlatformNodeDelegate::OwnerBridge
virtual ~OwnerBridge ()=default
 

Protected Member Functions

void OnAccessibilityEvent (ui::AXEventGenerator::TargetedEvent targeted_event) override
 Handle accessibility events generated due to accessibility tree changes. These events are needed to be sent to native accessibility system. See ui::AXEventGenerator::Event for possible events. More...
 
std::shared_ptr< FlutterPlatformNodeDelegateCreateFlutterPlatformNodeDelegate () override
 Creates a platform specific FlutterPlatformNodeDelegate. Ownership passes to the caller. This method will be called whenever a new AXNode is created in AXTree. Each platform needs to implement this method in order to inject its subclass into the accessibility bridge. More...
 
virtual std::weak_ptr< FlutterPlatformNodeDelegateGetFocusedNode ()
 

Detailed Description

AccessibilityBridgeWindows must be created as a shared_ptr, since some methods acquires its weak_ptr.

Definition at line 27 of file accessibility_bridge_windows.h.

Constructor & Destructor Documentation

◆ AccessibilityBridgeWindows()

flutter::AccessibilityBridgeWindows::AccessibilityBridgeWindows ( FlutterWindowsView view)

Definition at line 13 of file accessibility_bridge_windows.cc.

14  : view_(view) {
15  FML_DCHECK(view_);
16 }

◆ ~AccessibilityBridgeWindows()

virtual flutter::AccessibilityBridgeWindows::~AccessibilityBridgeWindows ( )
virtualdefault

Member Function Documentation

◆ CreateFlutterPlatformNodeDelegate()

std::shared_ptr< FlutterPlatformNodeDelegate > flutter::AccessibilityBridgeWindows::CreateFlutterPlatformNodeDelegate ( )
overrideprotectedvirtual

Creates a platform specific FlutterPlatformNodeDelegate. Ownership passes to the caller. This method will be called whenever a new AXNode is created in AXTree. Each platform needs to implement this method in order to inject its subclass into the accessibility bridge.

Implements flutter::AccessibilityBridge.

Definition at line 170 of file accessibility_bridge_windows.cc.

170  {
171  return std::make_shared<FlutterPlatformNodeDelegateWindows>(
172  shared_from_this(), view_);
173 }

◆ DispatchAccessibilityAction()

void flutter::AccessibilityBridgeWindows::DispatchAccessibilityAction ( AccessibilityNodeId  target,
FlutterSemanticsAction  action,
fml::MallocMapping  data 
)
overridevirtual

Dispatch accessibility action back to the Flutter framework. These actions are generated in the native accessibility system when users interact with the assistive technologies. For example, a FlutterSemanticsAction::kFlutterSemanticsActionTap is fired when user click or touch the screen.

Parameters
[in]targetThe semantics node id of the action target.
[in]actionThe generated flutter semantics action.
[in]dataAdditional data associated with the action.

Implements flutter::FlutterPlatformNodeDelegate::OwnerBridge.

Definition at line 162 of file accessibility_bridge_windows.cc.

165  {
166  view_->GetEngine()->DispatchSemanticsAction(target, action, std::move(data));
167 }

References action, flutter::FlutterWindowsEngine::DispatchSemanticsAction(), and flutter::FlutterWindowsView::GetEngine().

Referenced by flutter::testing::TEST().

◆ DispatchWinAccessibilityEvent()

void flutter::AccessibilityBridgeWindows::DispatchWinAccessibilityEvent ( std::shared_ptr< FlutterPlatformNodeDelegateWindows node_delegate,
ax::mojom::Event  event_type 
)
virtual

Definition at line 175 of file accessibility_bridge_windows.cc.

177  {
178  node_delegate->DispatchWinAccessibilityEvent(event_type);
179 }

References event_type, and node_delegate.

Referenced by OnAccessibilityEvent().

◆ GetChildOfAXFragmentRoot()

gfx::NativeViewAccessible flutter::AccessibilityBridgeWindows::GetChildOfAXFragmentRoot ( )
override

Definition at line 187 of file accessibility_bridge_windows.cc.

187  {
188  ui::AXPlatformNodeDelegate* root_delegate = RootDelegate();
189  if (!root_delegate) {
190  return nullptr;
191  }
192 
193  return root_delegate->GetNativeViewAccessible();
194 }

References flutter::AccessibilityBridge::RootDelegate().

◆ GetFocusedNode()

std::weak_ptr< FlutterPlatformNodeDelegate > flutter::AccessibilityBridgeWindows::GetFocusedNode ( )
protectedvirtual

Definition at line 206 of file accessibility_bridge_windows.cc.

206  {
207  ui::AXNode::AXID focus_id = GetAXTreeData().sel_focus_object_id;
208  return GetFlutterPlatformNodeDelegateFromID(focus_id);
209 }

References flutter::AccessibilityBridge::GetAXTreeData(), and flutter::AccessibilityBridge::GetFlutterPlatformNodeDelegateFromID().

Referenced by OnAccessibilityEvent().

◆ GetParentOfAXFragmentRoot()

gfx::NativeViewAccessible flutter::AccessibilityBridgeWindows::GetParentOfAXFragmentRoot ( )
override

Definition at line 197 of file accessibility_bridge_windows.cc.

197  {
198  return nullptr;
199 }

◆ IsAXFragmentRootAControlElement()

bool flutter::AccessibilityBridgeWindows::IsAXFragmentRootAControlElement ( )
override

Definition at line 201 of file accessibility_bridge_windows.cc.

201  {
202  return true;
203 }

◆ OnAccessibilityEvent()

void flutter::AccessibilityBridgeWindows::OnAccessibilityEvent ( ui::AXEventGenerator::TargetedEvent  targeted_event)
overrideprotectedvirtual

Handle accessibility events generated due to accessibility tree changes. These events are needed to be sent to native accessibility system. See ui::AXEventGenerator::Event for possible events.

Parameters
[in]targeted_eventThe object that contains both the generated event and the event target.

Implements flutter::AccessibilityBridge.

Definition at line 18 of file accessibility_bridge_windows.cc.

19  {
20  ui::AXNode* ax_node = targeted_event.node;
21  ui::AXEventGenerator::Event event_type = targeted_event.event_params.event;
22 
23  auto node_delegate =
24  GetFlutterPlatformNodeDelegateFromID(ax_node->id()).lock();
25  FML_DCHECK(node_delegate)
26  << "No FlutterPlatformNodeDelegate found for node ID " << ax_node->id();
27  std::shared_ptr<FlutterPlatformNodeDelegateWindows> win_delegate =
28  std::static_pointer_cast<FlutterPlatformNodeDelegateWindows>(
30 
31  switch (event_type) {
32  case ui::AXEventGenerator::Event::ALERT:
33  DispatchWinAccessibilityEvent(win_delegate, ax::mojom::Event::kAlert);
34  break;
35  case ui::AXEventGenerator::Event::CHECKED_STATE_CHANGED:
36  DispatchWinAccessibilityEvent(win_delegate,
37  ax::mojom::Event::kValueChanged);
38  break;
39  case ui::AXEventGenerator::Event::CHILDREN_CHANGED:
40  DispatchWinAccessibilityEvent(win_delegate,
41  ax::mojom::Event::kChildrenChanged);
42  break;
43  case ui::AXEventGenerator::Event::DOCUMENT_SELECTION_CHANGED: {
44  // An event indicating a change in document selection should be fired
45  // only for the focused node whose selection has changed. If a valid
46  // caret and selection exist in the app tree, they must both be within
47  // the focus node.
48  auto focus_delegate = GetFocusedNode().lock();
49  if (focus_delegate) {
50  win_delegate =
51  std::static_pointer_cast<FlutterPlatformNodeDelegateWindows>(
52  focus_delegate);
53  }
55  win_delegate, ax::mojom::Event::kDocumentSelectionChanged);
56  break;
57  }
58  case ui::AXEventGenerator::Event::FOCUS_CHANGED:
59  DispatchWinAccessibilityEvent(win_delegate, ax::mojom::Event::kFocus);
60  SetFocus(win_delegate);
61  break;
62  case ui::AXEventGenerator::Event::IGNORED_CHANGED:
63  if (ax_node->IsIgnored()) {
64  DispatchWinAccessibilityEvent(win_delegate, ax::mojom::Event::kHide);
65  }
66  break;
67  case ui::AXEventGenerator::Event::IMAGE_ANNOTATION_CHANGED:
68  DispatchWinAccessibilityEvent(win_delegate,
69  ax::mojom::Event::kTextChanged);
70  break;
71  case ui::AXEventGenerator::Event::LIVE_REGION_CHANGED:
72  DispatchWinAccessibilityEvent(win_delegate,
73  ax::mojom::Event::kLiveRegionChanged);
74  break;
75  case ui::AXEventGenerator::Event::NAME_CHANGED:
76  DispatchWinAccessibilityEvent(win_delegate,
77  ax::mojom::Event::kTextChanged);
78  break;
79  case ui::AXEventGenerator::Event::SCROLL_HORIZONTAL_POSITION_CHANGED:
80  DispatchWinAccessibilityEvent(win_delegate,
81  ax::mojom::Event::kScrollPositionChanged);
82  break;
83  case ui::AXEventGenerator::Event::SCROLL_VERTICAL_POSITION_CHANGED:
84  DispatchWinAccessibilityEvent(win_delegate,
85  ax::mojom::Event::kScrollPositionChanged);
86  break;
87  case ui::AXEventGenerator::Event::SELECTED_CHANGED:
88  DispatchWinAccessibilityEvent(win_delegate,
89  ax::mojom::Event::kValueChanged);
90  break;
91  case ui::AXEventGenerator::Event::SELECTED_CHILDREN_CHANGED:
92  DispatchWinAccessibilityEvent(win_delegate,
93  ax::mojom::Event::kSelectedChildrenChanged);
94  break;
95  case ui::AXEventGenerator::Event::SUBTREE_CREATED:
96  DispatchWinAccessibilityEvent(win_delegate, ax::mojom::Event::kShow);
97  break;
98  case ui::AXEventGenerator::Event::VALUE_CHANGED:
99  DispatchWinAccessibilityEvent(win_delegate,
100  ax::mojom::Event::kValueChanged);
101  break;
102  case ui::AXEventGenerator::Event::WIN_IACCESSIBLE_STATE_CHANGED:
103  DispatchWinAccessibilityEvent(win_delegate,
104  ax::mojom::Event::kStateChanged);
105  break;
106  case ui::AXEventGenerator::Event::ACCESS_KEY_CHANGED:
107  case ui::AXEventGenerator::Event::ACTIVE_DESCENDANT_CHANGED:
108  case ui::AXEventGenerator::Event::ATK_TEXT_OBJECT_ATTRIBUTE_CHANGED:
109  case ui::AXEventGenerator::Event::ATOMIC_CHANGED:
110  case ui::AXEventGenerator::Event::AUTO_COMPLETE_CHANGED:
111  case ui::AXEventGenerator::Event::BUSY_CHANGED:
112  case ui::AXEventGenerator::Event::CLASS_NAME_CHANGED:
113  case ui::AXEventGenerator::Event::COLLAPSED:
114  case ui::AXEventGenerator::Event::CONTROLS_CHANGED:
115  case ui::AXEventGenerator::Event::DESCRIBED_BY_CHANGED:
116  case ui::AXEventGenerator::Event::DESCRIPTION_CHANGED:
117  case ui::AXEventGenerator::Event::DOCUMENT_TITLE_CHANGED:
118  case ui::AXEventGenerator::Event::DROPEFFECT_CHANGED:
119  case ui::AXEventGenerator::Event::ENABLED_CHANGED:
120  case ui::AXEventGenerator::Event::EXPANDED:
121  case ui::AXEventGenerator::Event::FLOW_FROM_CHANGED:
122  case ui::AXEventGenerator::Event::FLOW_TO_CHANGED:
123  case ui::AXEventGenerator::Event::GRABBED_CHANGED:
124  case ui::AXEventGenerator::Event::HASPOPUP_CHANGED:
125  case ui::AXEventGenerator::Event::HIERARCHICAL_LEVEL_CHANGED:
126  case ui::AXEventGenerator::Event::INVALID_STATUS_CHANGED:
127  case ui::AXEventGenerator::Event::KEY_SHORTCUTS_CHANGED:
128  case ui::AXEventGenerator::Event::LABELED_BY_CHANGED:
129  case ui::AXEventGenerator::Event::LANGUAGE_CHANGED:
130  case ui::AXEventGenerator::Event::LAYOUT_INVALIDATED:
131  case ui::AXEventGenerator::Event::LIVE_REGION_CREATED:
132  case ui::AXEventGenerator::Event::LIVE_REGION_NODE_CHANGED:
133  case ui::AXEventGenerator::Event::LIVE_RELEVANT_CHANGED:
134  case ui::AXEventGenerator::Event::LIVE_STATUS_CHANGED:
135  case ui::AXEventGenerator::Event::LOAD_COMPLETE:
136  case ui::AXEventGenerator::Event::LOAD_START:
137  case ui::AXEventGenerator::Event::MENU_ITEM_SELECTED:
138  case ui::AXEventGenerator::Event::MULTILINE_STATE_CHANGED:
139  case ui::AXEventGenerator::Event::MULTISELECTABLE_STATE_CHANGED:
140  case ui::AXEventGenerator::Event::OBJECT_ATTRIBUTE_CHANGED:
141  case ui::AXEventGenerator::Event::OTHER_ATTRIBUTE_CHANGED:
142  case ui::AXEventGenerator::Event::PLACEHOLDER_CHANGED:
143  case ui::AXEventGenerator::Event::PORTAL_ACTIVATED:
144  case ui::AXEventGenerator::Event::POSITION_IN_SET_CHANGED:
145  case ui::AXEventGenerator::Event::READONLY_CHANGED:
146  case ui::AXEventGenerator::Event::RELATED_NODE_CHANGED:
147  case ui::AXEventGenerator::Event::REQUIRED_STATE_CHANGED:
148  case ui::AXEventGenerator::Event::ROLE_CHANGED:
149  case ui::AXEventGenerator::Event::ROW_COUNT_CHANGED:
150  case ui::AXEventGenerator::Event::SET_SIZE_CHANGED:
151  case ui::AXEventGenerator::Event::SORT_CHANGED:
152  case ui::AXEventGenerator::Event::STATE_CHANGED:
153  case ui::AXEventGenerator::Event::TEXT_ATTRIBUTE_CHANGED:
154  case ui::AXEventGenerator::Event::VALUE_MAX_CHANGED:
155  case ui::AXEventGenerator::Event::VALUE_MIN_CHANGED:
156  case ui::AXEventGenerator::Event::VALUE_STEP_CHANGED:
157  // Unhandled event type.
158  break;
159  }
160 }

References DispatchWinAccessibilityEvent(), event_type, flutter::AccessibilityBridge::GetFlutterPlatformNodeDelegateFromID(), GetFocusedNode(), node_delegate, and SetFocus().

◆ SetFocus()

void flutter::AccessibilityBridgeWindows::SetFocus ( std::shared_ptr< FlutterPlatformNodeDelegateWindows node_delegate)
virtual

Definition at line 181 of file accessibility_bridge_windows.cc.

182  {
183  node_delegate->SetFocus();
184 }

References node_delegate.

Referenced by OnAccessibilityEvent().


The documentation for this class was generated from the following files:
flutter::FlutterWindowsEngine::DispatchSemanticsAction
bool DispatchSemanticsAction(uint64_t id, FlutterSemanticsAction action, fml::MallocMapping data)
Definition: flutter_windows_engine.cc:755
flutter::AccessibilityBridge::GetFlutterPlatformNodeDelegateFromID
std::weak_ptr< FlutterPlatformNodeDelegate > GetFlutterPlatformNodeDelegateFromID(AccessibilityNodeId id) const
Get the flutter platform node delegate with the given id from this accessibility bridge....
Definition: accessibility_bridge.cc:131
flutter::AccessibilityBridgeWindows::DispatchWinAccessibilityEvent
virtual void DispatchWinAccessibilityEvent(std::shared_ptr< FlutterPlatformNodeDelegateWindows > node_delegate, ax::mojom::Event event_type)
Definition: accessibility_bridge_windows.cc:175
flutter::FlutterWindowsView::GetEngine
FlutterWindowsEngine * GetEngine() const
Definition: flutter_windows_view.cc:731
flutter::AccessibilityBridge::GetAXTreeData
const ui::AXTreeData & GetAXTreeData() const
Get the ax tree data from this accessibility bridge. The tree data contains information such as the i...
Definition: accessibility_bridge.cc:141
flutter::AccessibilityBridgeWindows::SetFocus
virtual void SetFocus(std::shared_ptr< FlutterPlatformNodeDelegateWindows > node_delegate)
Definition: accessibility_bridge_windows.cc:181
flutter::AccessibilityBridgeWindows::GetFocusedNode
virtual std::weak_ptr< FlutterPlatformNodeDelegate > GetFocusedNode()
Definition: accessibility_bridge_windows.cc:206
action
int action
Definition: keyboard_key_handler_unittests.cc:116
flutter::AccessibilityBridge::RootDelegate
ui::AXPlatformNodeDelegate * RootDelegate() const override
Definition: accessibility_bridge.cc:721
event_type
ax::mojom::Event event_type
Definition: accessibility_bridge_windows_unittests.cc:34
node_delegate
std::shared_ptr< FlutterPlatformNodeDelegateWindows > node_delegate
Definition: accessibility_bridge_windows_unittests.cc:33