|
| AccessibilityBridge (FlutterViewController *view_controller, PlatformViewIOS *platform_view, std::shared_ptr< PlatformViewsController > platform_views_controller, std::unique_ptr< IosDelegate > ios_delegate=nullptr) |
|
| ~AccessibilityBridge () |
|
void | UpdateSemantics (flutter::SemanticsNodeUpdates nodes, const flutter::CustomAccessibilityActionUpdates &actions) |
|
void | HandleEvent (NSDictionary< NSString *, id > *annotatedEvent) |
|
void | DispatchSemanticsAction (int32_t id, flutter::SemanticsAction action) override |
|
void | DispatchSemanticsAction (int32_t id, flutter::SemanticsAction action, fml::MallocMapping args) override |
|
void | AccessibilityObjectDidBecomeFocused (int32_t id) override |
|
void | AccessibilityObjectDidLoseFocus (int32_t id) override |
|
UIView< UITextInput > * | textInputView () override |
|
UIView * | view () const override |
|
bool | isVoiceOverRunning () const override |
|
fml::WeakPtr< AccessibilityBridge > | GetWeakPtr () |
|
std::shared_ptr< PlatformViewsController > | GetPlatformViewsController () const override |
|
void | clearState () |
|
| 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< FlutterPlatformNodeDelegate > | GetFlutterPlatformNodeDelegateFromID (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 |
|
virtual | ~AccessibilityBridgeIos ()=default |
|
An accessibility instance is bound to one FlutterViewController
and FlutterView
instance.
It helps populate the UIView's accessibilityElements property from Flutter's semantics nodes.
Use this class to maintain an accessibility tree. This class consumes semantics updates from the embedder API and produces an accessibility tree in the native format.
The bridge creates an AXTree to hold the semantics data that comes from Flutter semantics updates. The tree holds AXNode[s] which contain the semantics information for semantics node. The AXTree resemble the Flutter semantics tree in the Flutter framework. The bridge also uses FlutterPlatformNodeDelegate to wrap each AXNode in order to provide an accessibility tree in the native format.
To use this class, one must subclass this class and provide their own implementation of FlutterPlatformNodeDelegate.
AccessibilityBridge must be created as a shared_ptr, since some methods acquires its weak_ptr.
Definition at line 38 of file accessibility_bridge.h.
void flutter::AccessibilityBridge::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.
Definition at line 50 of file accessibility_bridge.cc.
58 std::optional<ui::AXTreeUpdate> remove_reparented =
59 CreateRemoveReparentedNodesUpdate();
60 if (remove_reparented.has_value()) {
61 tree_->Unserialize(remove_reparented.value());
63 std::string error = tree_->error();
65 FML_LOG(ERROR) <<
"Failed to update ui::AXTree, error: " << error;
73 ui::AXTreeUpdate update{.tree_data = tree_->data()};
83 std::vector<std::vector<SemanticsNode>> results;
84 while (!pending_semantics_node_updates_.empty()) {
85 auto begin = pending_semantics_node_updates_.begin();
86 SemanticsNode target = begin->second;
87 std::vector<SemanticsNode> sub_tree_list;
88 GetSubTreeList(target, sub_tree_list);
89 results.push_back(sub_tree_list);
90 pending_semantics_node_updates_.erase(begin);
93 for (
size_t i = results.size(); i > 0; i--) {
94 for (
const SemanticsNode& node : results[i - 1]) {
95 ConvertFlutterUpdate(node, update);
102 if (!results.empty() &&
GetRootAsAXNode()->
id() == ui::AXNode::kInvalidAXID) {
103 FML_DCHECK(!results.back().empty());
105 update.root_id = results.back().front().id;
108 tree_->Unserialize(update);
109 pending_semantics_node_updates_.clear();
110 pending_semantics_custom_action_updates_.clear();
112 std::string error = tree_->error();
113 if (!error.empty()) {
114 FML_LOG(ERROR) <<
"Failed to update ui::AXTree, error: " << error;
118 for (
const auto& targeted_event : event_generator_) {
121 if (event_target.expired()) {
127 event_generator_.ClearEvents();
References GetFlutterPlatformNodeDelegateFromID(), GetRootAsAXNode(), and OnAccessibilityEvent().