Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
flutter::AccessibilityBridge Class Referenceabstract

#include <accessibility_bridge.h>

Inheritance diagram for flutter::AccessibilityBridge:
flutter::FlutterPlatformNodeDelegate::OwnerBridge ui::AXPlatformTreeManager ui::AXTreeObserver flutter::AccessibilityBridgeIos ui::AXTreeManager flutter::AccessibilityBridgeMac flutter::AccessibilityBridgeWindows flutter::TestAccessibilityBridge

Classes

class  IosDelegate
 

Public Member Functions

 AccessibilityBridge ()
 Creates a new instance of a accessibility bridge.
 
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().
 
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().
 
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.
 
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.
 
const ui::AXTreeDataGetAXTreeData () 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.
 
const std::vector< ui::AXEventGenerator::TargetedEventGetPendingEvents () 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.
 
ui::AXNodeGetNodeFromTree (const ui::AXTreeID tree_id, const ui::AXNode::AXID node_id) const override
 
ui::AXNodeGetNodeFromTree (const ui::AXNode::AXID node_id) const override
 
ui::AXTreeID GetTreeID () const override
 
ui::AXTreeID GetParentTreeID () const override
 
ui::AXNodeGetRootAsAXNode () const override
 
ui::AXNodeGetParentNodeFromParentTreeAsAXNode () const override
 
ui::AXTreeGetTree () const override
 
ui::AXPlatformNodeGetPlatformNodeFromTree (const ui::AXNode::AXID node_id) const override
 
ui::AXPlatformNodeGetPlatformNodeFromTree (const ui::AXNode &node) const override
 
ui::AXPlatformNodeDelegateRootDelegate () const override
 
 AccessibilityBridge (FlutterViewController *view_controller, PlatformViewIOS *platform_view, std::shared_ptr< FlutterPlatformViewsController > 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< AccessibilityBridgeGetWeakPtr ()
 
std::shared_ptr< FlutterPlatformViewsControllerGetPlatformViewsController () const override
 
void clearState ()
 
- Public Member Functions inherited from flutter::FlutterPlatformNodeDelegate::OwnerBridge
virtual ~OwnerBridge ()=default
 
- Public Member Functions inherited from ui::AXPlatformTreeManager
virtual ~AXPlatformTreeManager ()=default
 
- Public Member Functions inherited from ui::AXTreeManager
virtual ~AXTreeManager ()=default
 
- Public Member Functions inherited from flutter::AccessibilityBridgeIos
virtual ~AccessibilityBridgeIos ()=default
 

Protected Member Functions

virtual void OnAccessibilityEvent (ui::AXEventGenerator::TargetedEvent targeted_event)=0
 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.
 
virtual std::shared_ptr< FlutterPlatformNodeDelegateCreateFlutterPlatformNodeDelegate ()=0
 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.
 
- Protected Member Functions inherited from flutter::FlutterPlatformNodeDelegate::OwnerBridge
virtual void DispatchAccessibilityAction (AccessibilityNodeId target, FlutterSemanticsAction action, fml::MallocMapping data)=0
 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.
 

Private Member Functions

void OnNodeWillBeDeleted (ui::AXTree *tree, ui::AXNode *node) override
 
void OnSubtreeWillBeDeleted (ui::AXTree *tree, ui::AXNode *node) override
 
void OnNodeCreated (ui::AXTree *tree, ui::AXNode *node) override
 
void OnNodeDeleted (ui::AXTree *tree, AccessibilityNodeId node_id) override
 
void OnNodeReparented (ui::AXTree *tree, ui::AXNode *node) override
 
void OnRoleChanged (ui::AXTree *tree, ui::AXNode *node, ax::mojom::Role old_role, ax::mojom::Role new_role) override
 
void OnAtomicUpdateFinished (ui::AXTree *tree, bool root_changed, const std::vector< ui::AXTreeObserver::Change > &changes) override
 
void SetLastFocusedId (AccessibilityNodeId node_id) override
 Update the id of the node that is currently foucsed by the native accessibility system.
 
AccessibilityNodeId GetLastFocusedId () override
 Get the last id of the node that received accessibility focus.
 
gfx::NativeViewAccessible GetNativeAccessibleFromId (AccessibilityNodeId id) override
 Get the native accessibility node with the given id.
 
gfx::RectF RelativeToGlobalBounds (const ui::AXNode *node, bool &offscreen, bool clip_bounds) override
 Gets the rectangular bounds of the ax node relative to global coordinate.
 

Detailed Description

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.

An accessibility instance is bound to one FlutterViewController and FlutterView instance.

It helps populate the UIView's accessibilityElements property from Flutter's semantics nodes.

Definition at line 40 of file accessibility_bridge.h.

Constructor & Destructor Documentation

◆ AccessibilityBridge() [1/2]

flutter::AccessibilityBridge::AccessibilityBridge ( )

Creates a new instance of a accessibility bridge.

Definition at line 23 of file accessibility_bridge.cc.

24 : tree_(std::make_unique<ui::AXTree>()) {
25 event_generator_.SetTree(tree_.get());
26 tree_->AddObserver(static_cast<ui::AXTreeObserver*>(this));
27 ui::AXTreeData data = tree_->data();
29 tree_->UpdateData(data);
31 this);
32}
void SetTree(AXTree *new_tree)
static AXTreeID CreateNewAXTreeID()
Definition ax_tree_id.cc:47
void AddTreeManager(AXTreeID tree_id, AXTreeManager *manager)
static AXTreeManagerMap & GetInstance()
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41

◆ ~AccessibilityBridge() [1/2]

flutter::AccessibilityBridge::~AccessibilityBridge ( )
virtual

Definition at line 34 of file accessibility_bridge.cc.

34 {
35 event_generator_.ReleaseTree();
36 tree_->RemoveObserver(static_cast<ui::AXTreeObserver*>(this));
37}

◆ AccessibilityBridge() [2/2]

flutter::AccessibilityBridge::AccessibilityBridge ( FlutterViewController view_controller,
PlatformViewIOS platform_view,
std::shared_ptr< FlutterPlatformViewsController platform_views_controller,
std::unique_ptr< IosDelegate ios_delegate = nullptr 
)

◆ ~AccessibilityBridge() [2/2]

flutter::AccessibilityBridge::~AccessibilityBridge ( )

Member Function Documentation

◆ AccessibilityObjectDidBecomeFocused()

void flutter::AccessibilityBridge::AccessibilityObjectDidBecomeFocused ( int32_t  id)
overridevirtual

A callback that is called when a SemanticObject receives focus.

The input id is the uid of the newly focused SemanticObject.

Implements flutter::AccessibilityBridgeIos.

◆ AccessibilityObjectDidLoseFocus()

void flutter::AccessibilityBridge::AccessibilityObjectDidLoseFocus ( int32_t  id)
overridevirtual

A callback that is called when a SemanticObject loses focus

The input id is the uid of the newly focused SemanticObject.

Implements flutter::AccessibilityBridgeIos.

◆ AddFlutterSemanticsCustomActionUpdate()

void flutter::AccessibilityBridge::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().

Parameters
[in]actionA reference to the custom semantics action update.

Definition at line 44 of file accessibility_bridge.cc.

45 {
46 pending_semantics_custom_action_updates_[action.id] =
47 FromFlutterSemanticsCustomAction(action);
48}

◆ AddFlutterSemanticsNodeUpdate()

void flutter::AccessibilityBridge::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().

Parameters
[in]nodeA reference to the semantics node update.

Definition at line 39 of file accessibility_bridge.cc.

40 {
41 pending_semantics_node_updates_[node.id] = FromFlutterSemanticsNode(node);
42}
int32_t id
The unique identifier for this node.
Definition embedder.h:1335

◆ clearState()

void flutter::AccessibilityBridge::clearState ( )

◆ CommitUpdates()

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.

50 {
51 // AXTree cannot move a node in a single update.
52 // This must be split across two updates:
53 //
54 // * Update 1: remove nodes from their old parents.
55 // * Update 2: re-add nodes (including their children) to their new parents.
56 //
57 // First, start by removing nodes if necessary.
58 std::optional<ui::AXTreeUpdate> remove_reparented =
59 CreateRemoveReparentedNodesUpdate();
60 if (remove_reparented.has_value()) {
61 tree_->Unserialize(remove_reparented.value());
62
63 std::string error = tree_->error();
64 if (!error.empty()) {
65 FML_LOG(ERROR) << "Failed to update ui::AXTree, error: " << error;
66 assert(false);
67 return;
68 }
69 }
70
71 // Second, apply the pending node updates. This also moves reparented nodes to
72 // their new parents if needed.
73 ui::AXTreeUpdate update{.tree_data = tree_->data()};
74
75 // Figure out update order, ui::AXTree only accepts update in tree order,
76 // where parent node must come before the child node in
77 // ui::AXTreeUpdate.nodes. We start with picking a random node and turn the
78 // entire subtree into a list. We pick another node from the remaining update,
79 // and keep doing so until the update map is empty. We then concatenate the
80 // lists in the reversed order, this guarantees parent updates always come
81 // before child updates. If the root is in the update, it is guaranteed to
82 // be the first node of the last list.
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);
91 }
92
93 for (size_t i = results.size(); i > 0; i--) {
94 for (const SemanticsNode& node : results[i - 1]) {
95 ConvertFlutterUpdate(node, update);
96 }
97 }
98
99 // The first update must set the tree's root, which is guaranteed to be the
100 // last list's first node. A tree's root node never changes, though it can be
101 // modified.
102 if (!results.empty() && GetRootAsAXNode()->id() == ui::AXNode::kInvalidAXID) {
103 FML_DCHECK(!results.back().empty());
104
105 update.root_id = results.back().front().id;
106 }
107
108 tree_->Unserialize(update);
109 pending_semantics_node_updates_.clear();
110 pending_semantics_custom_action_updates_.clear();
111
112 std::string error = tree_->error();
113 if (!error.empty()) {
114 FML_LOG(ERROR) << "Failed to update ui::AXTree, error: " << error;
115 return;
116 }
117 // Handles accessibility events as the result of the semantics update.
118 for (const auto& targeted_event : event_generator_) {
119 auto event_target =
120 GetFlutterPlatformNodeDelegateFromID(targeted_event.node->id());
121 if (event_target.expired()) {
122 continue;
123 }
124
125 OnAccessibilityEvent(targeted_event);
126 }
127 event_generator_.ClearEvents();
128}
std::weak_ptr< FlutterPlatformNodeDelegate > GetFlutterPlatformNodeDelegateFromID(AccessibilityNodeId id) const
Get the flutter platform node delegate with the given id from this accessibility bridge....
ui::AXNode * GetRootAsAXNode() const override
virtual void OnAccessibilityEvent(ui::AXEventGenerator::TargetedEvent targeted_event)=0
Handle accessibility events generated due to accessibility tree changes. These events are needed to b...
static constexpr AXID kInvalidAXID
Definition ax_node.h:41
static const char * begin(const StringSlice &s)
Definition editor.cpp:252
const uint8_t uint32_t uint32_t GError ** error
uint32_t * target
#define FML_LOG(severity)
Definition logging.h:82
#define FML_DCHECK(condition)
Definition logging.h:103
#define ERROR(message)

◆ CreateFlutterPlatformNodeDelegate()

virtual std::shared_ptr< FlutterPlatformNodeDelegate > flutter::AccessibilityBridge::CreateFlutterPlatformNodeDelegate ( )
protectedpure virtual

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.

Implemented in flutter::TestAccessibilityBridge, flutter::AccessibilityBridgeMac, and flutter::AccessibilityBridgeWindows.

◆ DispatchSemanticsAction() [1/2]

void flutter::AccessibilityBridge::DispatchSemanticsAction ( int32_t  id,
flutter::SemanticsAction  action 
)
overridevirtual

◆ DispatchSemanticsAction() [2/2]

void flutter::AccessibilityBridge::DispatchSemanticsAction ( int32_t  id,
flutter::SemanticsAction  action,
fml::MallocMapping  args 
)
overridevirtual

◆ GetAXTreeData()

const ui::AXTreeData & flutter::AccessibilityBridge::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.

Definition at line 141 of file accessibility_bridge.cc.

141 {
142 return tree_->data();
143}

◆ GetFlutterPlatformNodeDelegateFromID()

std::weak_ptr< FlutterPlatformNodeDelegate > flutter::AccessibilityBridge::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.

Parameters
[in]idThe id of the flutter accessibility node you want to retrieve.

Definition at line 131 of file accessibility_bridge.cc.

132 {
133 const auto iter = id_wrapper_map_.find(id);
134 if (iter != id_wrapper_map_.end()) {
135 return iter->second;
136 }
137
138 return std::weak_ptr<FlutterPlatformNodeDelegate>();
139}

◆ GetLastFocusedId()

AccessibilityNodeId flutter::AccessibilityBridge::GetLastFocusedId ( )
overrideprivatevirtual

Get the last id of the node that received accessibility focus.

Implements flutter::FlutterPlatformNodeDelegate::OwnerBridge.

Definition at line 655 of file accessibility_bridge.cc.

655 {
656 return last_focused_id_;
657}

◆ GetNativeAccessibleFromId()

gfx::NativeViewAccessible flutter::AccessibilityBridge::GetNativeAccessibleFromId ( AccessibilityNodeId  id)
overrideprivatevirtual

Get the native accessibility node with the given id.

Parameters
[in]idThe id of the native accessibility node you want to retrieve.

Implements flutter::FlutterPlatformNodeDelegate::OwnerBridge.

Definition at line 659 of file accessibility_bridge.cc.

660 {
661 auto platform_node_delegate = GetFlutterPlatformNodeDelegateFromID(id).lock();
662 if (!platform_node_delegate) {
663 return nullptr;
664 }
665 return platform_node_delegate->GetNativeViewAccessible();
666}

◆ GetNodeFromTree() [1/2]

ui::AXNode * flutter::AccessibilityBridge::GetNodeFromTree ( const ui::AXNode::AXID  node_id) const
overridevirtual

Implements ui::AXTreeManager.

Definition at line 681 of file accessibility_bridge.cc.

682 {
683 return tree_->GetFromId(node_id);
684}

◆ GetNodeFromTree() [2/2]

ui::AXNode * flutter::AccessibilityBridge::GetNodeFromTree ( const ui::AXTreeID  tree_id,
const ui::AXNode::AXID  node_id 
) const
overridevirtual

Implements ui::AXTreeManager.

Definition at line 675 of file accessibility_bridge.cc.

677 {
678 return GetNodeFromTree(node_id);
679}
ui::AXNode * GetNodeFromTree(const ui::AXTreeID tree_id, const ui::AXNode::AXID node_id) const override

◆ GetParentNodeFromParentTreeAsAXNode()

ui::AXNode * flutter::AccessibilityBridge::GetParentNodeFromParentTreeAsAXNode ( ) const
overridevirtual

Implements ui::AXTreeManager.

Definition at line 698 of file accessibility_bridge.cc.

698 {
699 return nullptr;
700}

◆ GetParentTreeID()

ui::AXTreeID flutter::AccessibilityBridge::GetParentTreeID ( ) const
overridevirtual

Implements ui::AXTreeManager.

Definition at line 690 of file accessibility_bridge.cc.

690 {
691 return ui::AXTreeIDUnknown();
692}
const AXTreeID & AXTreeIDUnknown()

◆ GetPendingEvents()

const std::vector< ui::AXEventGenerator::TargetedEvent > flutter::AccessibilityBridge::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.

Definition at line 146 of file accessibility_bridge.cc.

146 {
147 std::vector<ui::AXEventGenerator::TargetedEvent> result(
148 event_generator_.begin(), event_generator_.end());
149 return result;
150}
GAsyncResult * result

◆ GetPlatformNodeFromTree() [1/2]

ui::AXPlatformNode * flutter::AccessibilityBridge::GetPlatformNodeFromTree ( const ui::AXNode node) const
overridevirtual

Implements ui::AXPlatformTreeManager.

Definition at line 716 of file accessibility_bridge.cc.

717 {
718 return GetPlatformNodeFromTree(node.id());
719}
ui::AXPlatformNode * GetPlatformNodeFromTree(const ui::AXNode::AXID node_id) const override
AXID id() const
Definition ax_node.h:110

◆ GetPlatformNodeFromTree() [2/2]

ui::AXPlatformNode * flutter::AccessibilityBridge::GetPlatformNodeFromTree ( const ui::AXNode::AXID  node_id) const
overridevirtual

Implements ui::AXPlatformTreeManager.

Definition at line 706 of file accessibility_bridge.cc.

707 {
708 auto platform_delegate_weak = GetFlutterPlatformNodeDelegateFromID(node_id);
709 auto platform_delegate = platform_delegate_weak.lock();
710 if (!platform_delegate) {
711 return nullptr;
712 }
713 return platform_delegate->GetPlatformNode();
714}

◆ GetPlatformViewsController()

std::shared_ptr< FlutterPlatformViewsController > flutter::AccessibilityBridge::GetPlatformViewsController ( ) const
inlineoverridevirtual

Implements flutter::AccessibilityBridgeIos.

Definition at line 76 of file accessibility_bridge.h.

76 {
77 return platform_views_controller_;
78 };

◆ GetRootAsAXNode()

ui::AXNode * flutter::AccessibilityBridge::GetRootAsAXNode ( ) const
overridevirtual

Implements ui::AXTreeManager.

Definition at line 694 of file accessibility_bridge.cc.

694 {
695 return tree_->root();
696}

◆ GetTree()

ui::AXTree * flutter::AccessibilityBridge::GetTree ( ) const
overridevirtual

Implements ui::AXTreeManager.

Definition at line 702 of file accessibility_bridge.cc.

702 {
703 return tree_.get();
704}

◆ GetTreeID()

ui::AXTreeID flutter::AccessibilityBridge::GetTreeID ( ) const
overridevirtual

Implements ui::AXTreeManager.

Definition at line 686 of file accessibility_bridge.cc.

686 {
687 return tree_->GetAXTreeID();
688}

◆ GetWeakPtr()

fml::WeakPtr< AccessibilityBridge > flutter::AccessibilityBridge::GetWeakPtr ( )

◆ HandleEvent()

void flutter::AccessibilityBridge::HandleEvent ( NSDictionary< NSString *, id > *  annotatedEvent)

◆ isVoiceOverRunning()

bool flutter::AccessibilityBridge::isVoiceOverRunning ( ) const
inlineoverridevirtual

Implements flutter::AccessibilityBridgeIos.

Definition at line 72 of file accessibility_bridge.h.

72{ return view_controller_.isVoiceOverRunning; }

◆ OnAccessibilityEvent()

virtual void flutter::AccessibilityBridge::OnAccessibilityEvent ( ui::AXEventGenerator::TargetedEvent  targeted_event)
protectedpure virtual

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.

Implemented in flutter::TestAccessibilityBridge, flutter::AccessibilityBridgeMac, and flutter::AccessibilityBridgeWindows.

◆ OnAtomicUpdateFinished()

void flutter::AccessibilityBridge::OnAtomicUpdateFinished ( ui::AXTree tree,
bool  root_changed,
const std::vector< ui::AXTreeObserver::Change > &  changes 
)
overrideprivatevirtual

Reimplemented from ui::AXTreeObserver.

Definition at line 183 of file accessibility_bridge.cc.

186 {
187 // The Flutter semantics update does not include child->parent relationship
188 // We have to update the relative bound offset container id here in order
189 // to calculate the screen bound correctly.
190 for (const auto& change : changes) {
191 ui::AXNode* node = change.node;
192 const ui::AXNodeData& data = node->data();
193 AccessibilityNodeId offset_container_id = -1;
194 if (node->parent()) {
195 offset_container_id = node->parent()->id();
196 }
197 node->SetLocation(offset_container_id, data.relative_bounds.bounds,
198 data.relative_bounds.transform.get());
199 }
200}
void SetLocation(int32_t offset_container_id, const gfx::RectF &location, gfx::Transform *transform)
Definition ax_node.cc:377
AXNode * parent() const
Definition ax_node.h:111
const AXNodeData & data() const
Definition ax_node.h:112
ui::AXNode::AXID AccessibilityNodeId

◆ OnNodeCreated()

void flutter::AccessibilityBridge::OnNodeCreated ( ui::AXTree tree,
ui::AXNode node 
)
overrideprivatevirtual

Reimplemented from ui::AXTreeObserver.

Definition at line 166 of file accessibility_bridge.cc.

166 {
167 BASE_DCHECK(node);
168 id_wrapper_map_[node->id()] = CreateFlutterPlatformNodeDelegate();
169 id_wrapper_map_[node->id()]->Init(
170 std::static_pointer_cast<FlutterPlatformNodeDelegate::OwnerBridge>(
171 shared_from_this()),
172 node);
173}
virtual std::shared_ptr< FlutterPlatformNodeDelegate > CreateFlutterPlatformNodeDelegate()=0
Creates a platform specific FlutterPlatformNodeDelegate. Ownership passes to the caller....
#define BASE_DCHECK(condition)
Definition logging.h:63

◆ OnNodeDeleted()

void flutter::AccessibilityBridge::OnNodeDeleted ( ui::AXTree tree,
AccessibilityNodeId  node_id 
)
overrideprivatevirtual

Reimplemented from ui::AXTreeObserver.

Definition at line 175 of file accessibility_bridge.cc.

176 {
178 if (id_wrapper_map_.find(node_id) != id_wrapper_map_.end()) {
179 id_wrapper_map_.erase(node_id);
180 }
181}

◆ OnNodeReparented()

void flutter::AccessibilityBridge::OnNodeReparented ( ui::AXTree tree,
ui::AXNode node 
)
overrideprivatevirtual

Reimplemented from ui::AXTreeObserver.

Definition at line 158 of file accessibility_bridge.cc.

158 {
159}

◆ OnNodeWillBeDeleted()

void flutter::AccessibilityBridge::OnNodeWillBeDeleted ( ui::AXTree tree,
ui::AXNode node 
)
overrideprivatevirtual

Reimplemented from ui::AXTreeObserver.

Definition at line 152 of file accessibility_bridge.cc.

153 {}

◆ OnRoleChanged()

void flutter::AccessibilityBridge::OnRoleChanged ( ui::AXTree tree,
ui::AXNode node,
ax::mojom::Role  old_role,
ax::mojom::Role  new_role 
)
overrideprivatevirtual

Reimplemented from ui::AXTreeObserver.

Definition at line 161 of file accessibility_bridge.cc.

164 {}

◆ OnSubtreeWillBeDeleted()

void flutter::AccessibilityBridge::OnSubtreeWillBeDeleted ( ui::AXTree tree,
ui::AXNode node 
)
overrideprivatevirtual

Reimplemented from ui::AXTreeObserver.

Definition at line 155 of file accessibility_bridge.cc.

156 {}

◆ RelativeToGlobalBounds()

gfx::RectF flutter::AccessibilityBridge::RelativeToGlobalBounds ( const ui::AXNode node,
bool &  offscreen,
bool  clip_bounds 
)
overrideprivatevirtual

Gets the rectangular bounds of the ax node relative to global coordinate.

Parameters
[in]nodeThe ax node to look up.
[in]offscreenthe bool reference to hold the result whether the ax node is outside of its ancestors' bounds.
[in]clip_boundswhether to clip the result if the ax node cannot be fully contained in its ancestors' bounds.

Implements flutter::FlutterPlatformNodeDelegate::OwnerBridge.

Definition at line 668 of file accessibility_bridge.cc.

670 {
671 return tree_->RelativeToTreeBounds(node, gfx::RectF(), &offscreen,
672 clip_bounds);
673}

◆ RootDelegate()

ui::AXPlatformNodeDelegate * flutter::AccessibilityBridge::RootDelegate ( ) const
overridevirtual

Implements ui::AXPlatformTreeManager.

Definition at line 721 of file accessibility_bridge.cc.

721 {
723 .lock()
724 .get();
725}

◆ SetLastFocusedId()

void flutter::AccessibilityBridge::SetLastFocusedId ( AccessibilityNodeId  node_id)
overrideprivatevirtual

Update the id of the node that is currently foucsed by the native accessibility system.

Parameters
[in]node_idThe id of the focused node.

Implements flutter::FlutterPlatformNodeDelegate::OwnerBridge.

Definition at line 640 of file accessibility_bridge.cc.

640 {
641 if (last_focused_id_ != node_id) {
642 auto last_focused_child =
643 GetFlutterPlatformNodeDelegateFromID(last_focused_id_);
644 if (!last_focused_child.expired()) {
646 last_focused_id_,
649 {});
650 }
651 last_focused_id_ = node_id;
652 }
653}
virtual void DispatchAccessibilityAction(AccessibilityNodeId target, FlutterSemanticsAction action, fml::MallocMapping data)=0
Dispatch accessibility action back to the Flutter framework. These actions are generated in the nativ...
FlutterSemanticsAction
Definition embedder.h:113
@ kFlutterSemanticsActionDidLoseAccessibilityFocus
Indicate that the node has lost accessibility focus.
Definition embedder.h:154

◆ textInputView()

UIView< UITextInput > * flutter::AccessibilityBridge::textInputView ( )
overridevirtual

◆ UpdateSemantics()

void flutter::AccessibilityBridge::UpdateSemantics ( flutter::SemanticsNodeUpdates  nodes,
const flutter::CustomAccessibilityActionUpdates actions 
)

◆ view()

UIView * flutter::AccessibilityBridge::view ( ) const
inlineoverridevirtual

Implements flutter::AccessibilityBridgeIos.

Definition at line 70 of file accessibility_bridge.h.

70{ return view_controller_.view; }

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