Flutter Engine
The Flutter Engine
|
#include <accessibility_bridge.h>
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< 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. | |
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. | |
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. | |
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 |
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< AccessibilityBridge > | GetWeakPtr () |
std::shared_ptr< FlutterPlatformViewsController > | GetPlatformViewsController () 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< FlutterPlatformNodeDelegate > | CreateFlutterPlatformNodeDelegate ()=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. | |
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.
flutter::AccessibilityBridge::AccessibilityBridge | ( | ) |
Creates a new instance of a accessibility bridge.
Definition at line 23 of file accessibility_bridge.cc.
|
virtual |
Definition at line 34 of file accessibility_bridge.cc.
flutter::AccessibilityBridge::AccessibilityBridge | ( | FlutterViewController * | view_controller, |
PlatformViewIOS * | platform_view, | ||
std::shared_ptr< FlutterPlatformViewsController > | platform_views_controller, | ||
std::unique_ptr< IosDelegate > | ios_delegate = nullptr |
||
) |
flutter::AccessibilityBridge::~AccessibilityBridge | ( | ) |
|
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.
|
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.
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().
[in] | action | A reference to the custom semantics action update. |
Definition at line 44 of file accessibility_bridge.cc.
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().
[in] | node | A reference to the semantics node update. |
Definition at line 39 of file accessibility_bridge.cc.
void flutter::AccessibilityBridge::clearState | ( | ) |
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.
|
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.
|
overridevirtual |
Implements flutter::AccessibilityBridgeIos.
|
overridevirtual |
Implements flutter::AccessibilityBridgeIos.
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.
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.
[in] | id | The id of the flutter accessibility node you want to retrieve. |
Definition at line 131 of file accessibility_bridge.cc.
|
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.
|
overrideprivatevirtual |
Get the native accessibility node with the given id.
[in] | id | The id of the native accessibility node you want to retrieve. |
Implements flutter::FlutterPlatformNodeDelegate::OwnerBridge.
Definition at line 659 of file accessibility_bridge.cc.
|
overridevirtual |
Implements ui::AXTreeManager.
Definition at line 681 of file accessibility_bridge.cc.
|
overridevirtual |
Implements ui::AXTreeManager.
Definition at line 675 of file accessibility_bridge.cc.
|
overridevirtual |
Implements ui::AXTreeManager.
Definition at line 698 of file accessibility_bridge.cc.
|
overridevirtual |
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.
|
overridevirtual |
Implements ui::AXPlatformTreeManager.
Definition at line 716 of file accessibility_bridge.cc.
|
overridevirtual |
Implements ui::AXPlatformTreeManager.
Definition at line 706 of file accessibility_bridge.cc.
|
inlineoverridevirtual |
Implements flutter::AccessibilityBridgeIos.
Definition at line 76 of file accessibility_bridge.h.
|
overridevirtual |
Implements ui::AXTreeManager.
Definition at line 694 of file accessibility_bridge.cc.
|
overridevirtual |
Implements ui::AXTreeManager.
Definition at line 702 of file accessibility_bridge.cc.
|
overridevirtual |
Implements ui::AXTreeManager.
Definition at line 686 of file accessibility_bridge.cc.
fml::WeakPtr< AccessibilityBridge > flutter::AccessibilityBridge::GetWeakPtr | ( | ) |
void flutter::AccessibilityBridge::HandleEvent | ( | NSDictionary< NSString *, id > * | annotatedEvent | ) |
|
inlineoverridevirtual |
Implements flutter::AccessibilityBridgeIos.
Definition at line 72 of file accessibility_bridge.h.
|
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.
[in] | targeted_event | The object that contains both the generated event and the event target. |
Implemented in flutter::TestAccessibilityBridge, flutter::AccessibilityBridgeMac, and flutter::AccessibilityBridgeWindows.
|
overrideprivatevirtual |
Reimplemented from ui::AXTreeObserver.
Definition at line 183 of file accessibility_bridge.cc.
|
overrideprivatevirtual |
Reimplemented from ui::AXTreeObserver.
Definition at line 166 of file accessibility_bridge.cc.
|
overrideprivatevirtual |
Reimplemented from ui::AXTreeObserver.
Definition at line 175 of file accessibility_bridge.cc.
|
overrideprivatevirtual |
Reimplemented from ui::AXTreeObserver.
Definition at line 158 of file accessibility_bridge.cc.
|
overrideprivatevirtual |
Reimplemented from ui::AXTreeObserver.
Definition at line 152 of file accessibility_bridge.cc.
|
overrideprivatevirtual |
Reimplemented from ui::AXTreeObserver.
Definition at line 161 of file accessibility_bridge.cc.
|
overrideprivatevirtual |
Reimplemented from ui::AXTreeObserver.
Definition at line 155 of file accessibility_bridge.cc.
|
overrideprivatevirtual |
Gets the rectangular bounds of the ax node relative to global coordinate.
[in] | node | The ax node to look up. |
[in] | offscreen | the bool reference to hold the result whether the ax node is outside of its ancestors' bounds. |
[in] | clip_bounds | whether 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.
|
overridevirtual |
Implements ui::AXPlatformTreeManager.
Definition at line 721 of file accessibility_bridge.cc.
|
overrideprivatevirtual |
Update the id of the node that is currently foucsed by the native accessibility system.
[in] | node_id | The id of the focused node. |
Implements flutter::FlutterPlatformNodeDelegate::OwnerBridge.
Definition at line 640 of file accessibility_bridge.cc.
|
overridevirtual |
Implements flutter::AccessibilityBridgeIos.
void flutter::AccessibilityBridge::UpdateSemantics | ( | flutter::SemanticsNodeUpdates | nodes, |
const flutter::CustomAccessibilityActionUpdates & | actions | ||
) |
|
inlineoverridevirtual |
Implements flutter::AccessibilityBridgeIos.
Definition at line 70 of file accessibility_bridge.h.