5#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterPlatformNodeDelegateMac.h"
7#import "flutter/shell/platform/darwin/macos/framework/Headers/FlutterAppDelegate.h"
8#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h"
9#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterTextInputSemanticsObject.h"
10#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewController_Internal.h"
12#include "flutter/shell/platform/common/accessibility_bridge.h"
13#include "flutter/third_party/accessibility/ax/ax_action_data.h"
14#include "flutter/third_party/accessibility/ax/ax_node_position.h"
15#include "flutter/third_party/accessibility/ax/platform/ax_platform_node.h"
16#include "flutter/third_party/accessibility/ax/platform/ax_platform_node_base.h"
17#include "flutter/third_party/accessibility/base/string_utils.h"
18#include "flutter/third_party/accessibility/gfx/geometry/rect_conversions.h"
19#include "flutter/third_party/accessibility/gfx/mac/coordinate_conversion.h"
24 std::weak_ptr<AccessibilityBridge> bridge,
26 : bridge_(
std::move(bridge)), view_controller_(view_controller) {}
35 NSCAssert(ax_platform_node_,
@"Failed to create platform node.");
44 NSCAssert(ax_platform_node_,
@"Platform node does not exist.");
51 NSCAssert(view_controller_.viewLoaded,
@"Flutter view must be loaded");
52 return view_controller_.flutterView;
62 coordinate_system, clipping_behavior, offscreen_result);
64 gfx::RectF screen_bounds = ConvertBoundsFromLocalToScreen(local_bounds_f);
82 auto bridge_ptr = bridge_.lock();
83 NSCAssert(bridge_ptr,
@"Accessibility bridge in flutter engine must not be null.");
84 for (int32_t child :
GetData().child_ids) {
85 auto delegate_child = bridge_ptr->GetFlutterPlatformNodeDelegateFromID(child).lock();
86 if (!delegate_child) {
89 text += std::static_pointer_cast<FlutterPlatformNodeDelegateMac>(delegate_child)
90 ->GetLiveRegionText();
95gfx::RectF FlutterPlatformNodeDelegateMac::ConvertBoundsFromLocalToScreen(
98 NSRect ns_local_bounds =
99 NSMakeRect(local_bounds.
x(), local_bounds.
y(), local_bounds.
width(), local_bounds.
height());
104 ns_local_bounds.origin.y = -ns_local_bounds.origin.y - ns_local_bounds.size.height;
106 NSCAssert(view_controller_.viewLoaded,
@"Flutter view must be loaded.");
107 NSRect ns_view_bounds = [view_controller_.flutterView convertRectFromBacking:ns_local_bounds];
108 NSRect ns_window_bounds = [view_controller_.flutterView convertRect:ns_view_bounds toView:nil];
109 NSRect ns_screen_bounds =
110 [[view_controller_.flutterView
window] convertRectToScreen:ns_window_bounds];
111 gfx::RectF screen_bounds(ns_screen_bounds.origin.x, ns_screen_bounds.origin.y,
112 ns_screen_bounds.size.width, ns_screen_bounds.size.height);
113 return screen_bounds;
116gfx::RectF FlutterPlatformNodeDelegateMac::ConvertBoundsFromScreenToGlobal(
120 NSScreen* screen = [[NSScreen screens] firstObject];
121 NSRect primary_screen_bounds = [screen
frame];
123 float flipped_y = primary_screen_bounds.
size.
height - screen_bounds.
y() - screen_bounds.
height();
124 return {screen_bounds.
x(), flipped_y, screen_bounds.
width(), screen_bounds.
height()};
The ax platform node for a text field.
constexpr float y() const
constexpr float width() const
constexpr float height() const
constexpr const SizeF & size() const
constexpr float x() const
constexpr float height() const
IBOutlet NSWindow * mainFlutterWindow
Rect ToEnclosingRect(const RectF &r)
UnimplementedNativeViewAccessible * NativeViewAccessible
const std::string & GetStringAttribute(ax::mojom::StringAttribute attribute) const