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

#include <AccessibilityBridgeMac.h>

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

Public Member Functions

 AccessibilityBridgeMac (__weak FlutterEngine *flutter_engine, __weak FlutterViewController *view_controller)
 Creates an AccessibilityBridgeMacDelegate.
 
virtual ~AccessibilityBridgeMac ()=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.
 
- Public Member Functions inherited from flutter::AccessibilityBridge
 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

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.
 
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.
 

Private Member Functions

virtual void DispatchMacOSNotification (gfx::NativeViewAccessible native_node, NSAccessibilityNotificationName mac_notification)
 Posts the given event against the given node to the macOS accessibility notification system.
 

Detailed Description

The macOS implementation of AccessibilityBridge.

This interacts with macOS accessibility APIs, which includes routing accessibility events fired from the framework to macOS, routing native macOS accessibility events to the framework, and creating macOS-specific FlutterPlatformNodeDelegate objects for each node in the semantics tree.

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

Definition at line 28 of file AccessibilityBridgeMac.h.

Constructor & Destructor Documentation

◆ AccessibilityBridgeMac()

flutter::AccessibilityBridgeMac::AccessibilityBridgeMac ( __weak FlutterEngine flutter_engine,
__weak FlutterViewController view_controller 
)
explicit

Creates an AccessibilityBridgeMacDelegate.

Parameters
[in]flutter_engineThe weak reference to the FlutterEngine.
[in]view_controllerThe weak reference to the FlutterViewController.

Definition at line 23 of file AccessibilityBridgeMac.mm.

25 : flutter_engine_(flutter_engine), view_controller_(view_controller) {}

◆ ~AccessibilityBridgeMac()

virtual flutter::AccessibilityBridgeMac::~AccessibilityBridgeMac ( )
virtualdefault

Member Function Documentation

◆ CreateFlutterPlatformNodeDelegate()

std::shared_ptr< FlutterPlatformNodeDelegate > flutter::AccessibilityBridgeMac::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 343 of file AccessibilityBridgeMac.mm.

343 {
344 return std::make_shared<FlutterPlatformNodeDelegateMac>(weak_from_this(), view_controller_);
345}

◆ DispatchAccessibilityAction()

void flutter::AccessibilityBridgeMac::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 332 of file AccessibilityBridgeMac.mm.

334 {
335 NSCAssert(flutter_engine_, @"Flutter engine should not be deallocated");
336 NSCAssert(view_controller_.viewLoaded && view_controller_.view.window,
337 @"The accessibility bridge should not receive accessibility actions if the flutter view"
338 @"is not loaded or attached to a NSWindow.");
339 [flutter_engine_ dispatchSemanticsAction:action toTarget:target withData:std::move(data)];
340}
uint32_t * target
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

◆ DispatchMacOSNotification()

void flutter::AccessibilityBridgeMac::DispatchMacOSNotification ( gfx::NativeViewAccessible  native_node,
NSAccessibilityNotificationName  mac_notification 
)
privatevirtual

Posts the given event against the given node to the macOS accessibility notification system.

Parameters
[in]native_nodeThe event target, must not be nil.
[in]mac_notificationThe event name, must not be nil.

Definition at line 348 of file AccessibilityBridgeMac.mm.

350 {
351 NSCAssert(mac_notification, @"The notification must not be null.");
352 NSCAssert(native_node, @"The notification target must not be null.");
353 NSAccessibilityPostNotification(native_node, mac_notification);
354}

◆ OnAccessibilityEvent()

void flutter::AccessibilityBridgeMac::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 27 of file AccessibilityBridgeMac.mm.

28 {
29 if (!view_controller_.viewLoaded || !view_controller_.view.window) {
30 // Don't need to send accessibility events if the there is no view or window.
31 return;
32 }
33 ui::AXNode* ax_node = targeted_event.node;
34 std::vector<AccessibilityBridgeMac::NSAccessibilityEvent> events =
35 MacOSEventsFromAXEvent(targeted_event.event_params.event, *ax_node);
36 for (const AccessibilityBridgeMac::NSAccessibilityEvent& event : events) {
37 if (event.user_info != nil) {
38 DispatchMacOSNotificationWithUserInfo(event.target, event.name, event.user_info);
39 } else {
41 }
42 }
43}
virtual void DispatchMacOSNotification(gfx::NativeViewAccessible native_node, NSAccessibilityNotificationName mac_notification)
Posts the given event against the given node to the macOS accessibility notification system.
FlKeyEvent * event

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