Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
AccessibilityBridgeMac.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_ACCESSIBILITYBRIDGEMAC_H_
6#define FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_ACCESSIBILITYBRIDGEMAC_H_
7
8#import <Cocoa/Cocoa.h>
9
10#include "flutter/fml/macros.h"
11#include "flutter/shell/platform/common/accessibility_bridge.h"
12
13@class FlutterEngine;
15
16namespace flutter {
17
18//------------------------------------------------------------------------------
19/// The macOS implementation of AccessibilityBridge.
20///
21/// This interacts with macOS accessibility APIs, which includes routing
22/// accessibility events fired from the framework to macOS, routing native
23/// macOS accessibility events to the framework, and creating macOS-specific
24/// FlutterPlatformNodeDelegate objects for each node in the semantics tree.
25///
26/// AccessibilityBridgeMac must be created as a shared_ptr, since some methods
27/// acquires its weak_ptr.
29 public:
30 //---------------------------------------------------------------------------
31 /// @brief Creates an AccessibilityBridgeMacDelegate.
32 /// @param[in] flutter_engine The weak reference to the FlutterEngine.
33 /// @param[in] view_controller The weak reference to the FlutterViewController.
34 explicit AccessibilityBridgeMac(__weak FlutterEngine* flutter_engine,
35 __weak FlutterViewController* view_controller);
36 virtual ~AccessibilityBridgeMac() = default;
37
38 // |FlutterPlatformNodeDelegate::OwnerBridge|
41 fml::MallocMapping data) override;
42
43 protected:
44 // |AccessibilityBridge|
46
47 // |AccessibilityBridge|
48 std::shared_ptr<FlutterPlatformNodeDelegate> CreateFlutterPlatformNodeDelegate() override;
49
50 private:
51 /// A wrapper structure to wraps macOS native accessibility events.
52 struct NSAccessibilityEvent {
53 NSAccessibilityNotificationName name;
55 NSDictionary* user_info;
56 };
57
58 //---------------------------------------------------------------------------
59 /// @brief Posts the given event against the given node to the macOS
60 /// accessibility notification system.
61 /// @param[in] native_node The event target, must not be nil.
62 /// @param[in] mac_notification The event name, must not be nil.
64 NSAccessibilityNotificationName mac_notification);
65
66 //---------------------------------------------------------------------------
67 /// @brief Posts the given event against the given node with the
68 /// additional attributes to the macOS accessibility notification
69 /// system.
70 /// @param[in] native_node The event target, must not be nil.
71 /// @param[in] mac_notification The event name, must not be nil.
72 /// @param[in] user_info The additional attributes, must not be nil.
73 void DispatchMacOSNotificationWithUserInfo(gfx::NativeViewAccessible native_node,
74 NSAccessibilityNotificationName mac_notification,
75 NSDictionary* user_info);
76
77 //---------------------------------------------------------------------------
78 /// @brief Whether the given event is in current pending events.
79 /// @param[in] event_type The event to look up.
80 bool HasPendingEvent(ui::AXEventGenerator::Event event) const;
81
82 //---------------------------------------------------------------------------
83 /// @brief Converts the give ui::AXEventGenerator::Event into
84 /// macOS native accessibility event[s]
85 /// @param[in] event_type The original event type.
86 /// @param[in] ax_node The original event target.
87 std::vector<NSAccessibilityEvent> MacOSEventsFromAXEvent(ui::AXEventGenerator::Event event_type,
88 const ui::AXNode& ax_node) const;
89
90 __weak FlutterEngine* flutter_engine_;
91 __weak FlutterViewController* view_controller_;
92
94};
95
96} // namespace flutter
97
98#endif // FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_ACCESSIBILITYBRIDGEMAC_H_
ax::mojom::Event event_type
void OnAccessibilityEvent(ui::AXEventGenerator::TargetedEvent targeted_event) override
Handle accessibility events generated due to accessibility tree changes. These events are needed to b...
std::shared_ptr< FlutterPlatformNodeDelegate > CreateFlutterPlatformNodeDelegate() override
Creates a platform specific FlutterPlatformNodeDelegate. Ownership passes to the caller....
virtual void DispatchMacOSNotification(gfx::NativeViewAccessible native_node, NSAccessibilityNotificationName mac_notification)
Posts the given event against the given node to the macOS accessibility notification system.
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 nativ...
A Mapping like NonOwnedMapping, but uses Free as its release proc.
Definition mapping.h:144
FlutterSemanticsAction
Definition embedder.h:113
FlKeyEvent * event
uint32_t * target
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
DEF_SWITCHES_START aot vmservice shared library name
Definition switches.h:32
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
ui::AXNode::AXID AccessibilityNodeId
UnimplementedNativeViewAccessible * NativeViewAccessible