5 #ifndef FLUTTER_SHELL_PLATFORM_COMMON_ACCESSIBILITY_BRIDGE_H_
6 #define FLUTTER_SHELL_PLATFORM_COMMON_ACCESSIBILITY_BRIDGE_H_
8 #include <unordered_map>
10 #include "flutter/fml/mapping.h"
11 #include "flutter/shell/platform/embedder/embedder.h"
13 #include "flutter/third_party/accessibility/ax/ax_event_generator.h"
14 #include "flutter/third_party/accessibility/ax/ax_tree.h"
15 #include "flutter/third_party/accessibility/ax/ax_tree_observer.h"
16 #include "flutter/third_party/accessibility/ax/platform/ax_platform_node_delegate.h"
17 #include "flutter/third_party/accessibility/ax/platform/ax_platform_tree_manager.h"
41 :
public std::enable_shared_from_this<AccessibilityBridge>,
43 public ui::AXPlatformTreeManager,
44 private ui::AXTreeObserver {
68 const FlutterSemanticsCustomAction2& action);
88 std::weak_ptr<FlutterPlatformNodeDelegate>
108 const ui::AXNode::AXID node_id)
const override;
111 ui::AXNode*
GetNodeFromTree(
const ui::AXNode::AXID node_id)
const override;
126 ui::AXTree*
GetTree()
const override;
130 const ui::AXNode::AXID node_id)
const override;
134 const ui::AXNode& node)
const override;
137 ui::AXPlatformNodeDelegate*
RootDelegate()
const override;
149 ui::AXEventGenerator::TargetedEvent targeted_event) = 0;
157 virtual std::shared_ptr<FlutterPlatformNodeDelegate>
164 FlutterSemanticsFlag
flags;
165 FlutterSemanticsAction actions;
166 int32_t text_selection_base;
167 int32_t text_selection_extent;
168 int32_t scroll_child_count;
169 int32_t scroll_index;
170 double scroll_position;
171 double scroll_extent_max;
172 double scroll_extent_min;
178 std::string increased_value;
179 std::string decreased_value;
181 FlutterTextDirection text_direction;
183 FlutterTransformation transform;
184 std::vector<int32_t> children_in_traversal_order;
185 std::vector<int32_t> custom_accessibility_actions;
191 FlutterSemanticsAction override_action;
194 } SemanticsCustomAction;
197 std::shared_ptr<FlutterPlatformNodeDelegate>>
199 std::unique_ptr<ui::AXTree> tree_;
200 ui::AXEventGenerator event_generator_;
201 std::unordered_map<int32_t, SemanticsNode> pending_semantics_node_updates_;
202 std::unordered_map<int32_t, SemanticsCustomAction>
203 pending_semantics_custom_action_updates_;
206 void InitAXTree(
const ui::AXTreeUpdate& initial_state);
210 std::optional<ui::AXTreeUpdate> CreateRemoveReparentedNodesUpdate();
212 void GetSubTreeList(
const SemanticsNode&
target,
213 std::vector<SemanticsNode>&
result);
214 void ConvertFlutterUpdate(
const SemanticsNode& node,
215 ui::AXTreeUpdate& tree_update);
216 void SetRoleFromFlutterUpdate(ui::AXNodeData& node_data,
217 const SemanticsNode& node);
218 void SetStateFromFlutterUpdate(ui::AXNodeData& node_data,
219 const SemanticsNode& node);
220 void SetActionsFromFlutterUpdate(ui::AXNodeData& node_data,
221 const SemanticsNode& node);
222 void SetBooleanAttributesFromFlutterUpdate(ui::AXNodeData& node_data,
223 const SemanticsNode& node);
224 void SetIntAttributesFromFlutterUpdate(ui::AXNodeData& node_data,
225 const SemanticsNode& node);
226 void SetIntListAttributesFromFlutterUpdate(ui::AXNodeData& node_data,
227 const SemanticsNode& node);
228 void SetStringListAttributesFromFlutterUpdate(ui::AXNodeData& node_data,
229 const SemanticsNode& node);
230 void SetNameFromFlutterUpdate(ui::AXNodeData& node_data,
231 const SemanticsNode& node);
232 void SetValueFromFlutterUpdate(ui::AXNodeData& node_data,
233 const SemanticsNode& node);
234 void SetTooltipFromFlutterUpdate(ui::AXNodeData& node_data,
235 const SemanticsNode& node);
236 void SetTreeData(
const SemanticsNode& node, ui::AXTreeUpdate& tree_update);
237 SemanticsNode FromFlutterSemanticsNode(
238 const FlutterSemanticsNode2& flutter_node);
239 SemanticsCustomAction FromFlutterSemanticsCustomAction(
240 const FlutterSemanticsCustomAction2& flutter_custom_action);
243 void OnNodeWillBeDeleted(ui::AXTree* tree, ui::AXNode* node)
override;
246 void OnSubtreeWillBeDeleted(ui::AXTree* tree, ui::AXNode* node)
override;
249 void OnNodeCreated(ui::AXTree* tree, ui::AXNode* node)
override;
255 void OnNodeReparented(ui::AXTree* tree, ui::AXNode* node)
override;
258 void OnRoleChanged(ui::AXTree* tree,
260 ax::mojom::Role old_role,
261 ax::mojom::Role new_role)
override;
264 void OnNodeDataChanged(ui::AXTree* tree,
265 const ui::AXNodeData& old_node_data,
266 const ui::AXNodeData& new_node_data)
override;
269 void OnAtomicUpdateFinished(
272 const std::vector<ui::AXTreeObserver::Change>& changes)
override;
281 gfx::NativeViewAccessible GetNativeAccessibleFromId(
285 gfx::RectF RelativeToGlobalBounds(
const ui::AXNode* node,
287 bool clip_bounds)
override;
294 #endif // FLUTTER_SHELL_PLATFORM_COMMON_ACCESSIBILITY_BRIDGE_H_