Flutter macOS Embedder
flutter::FlutterPlatformNodeDelegateMac Class Reference

#include <FlutterPlatformNodeDelegateMac.h>

Inheritance diagram for flutter::FlutterPlatformNodeDelegateMac:
flutter::FlutterPlatformNodeDelegate

Public Member Functions

 FlutterPlatformNodeDelegateMac (std::weak_ptr< AccessibilityBridge > bridge, __weak FlutterViewController *view_controller)
 
virtual ~FlutterPlatformNodeDelegateMac ()
 
void Init (std::weak_ptr< OwnerBridge > bridge, ui::AXNode *node) override
 Called only once, immediately after construction. The constructor doesn't take any arguments because in the Windows subclass we use a special function to construct a COM object. Subclasses must call super. More...
 
std::string GetLiveRegionText () const
 Gets the live region text of this node in UTF-8 format. This is useful to determine the changes in between semantics updates when generating accessibility events. More...
 
gfx::NativeViewAccessible GetNativeViewAccessible () override
 
gfx::NativeViewAccessible GetNSWindow () override
 
gfx::NativeViewAccessible GetParent () override
 
gfx::Rect GetBoundsRect (const ui::AXCoordinateSystem coordinate_system, const ui::AXClippingBehavior clipping_behavior, ui::AXOffscreenResult *offscreen_result) const override
 
- Public Member Functions inherited from flutter::FlutterPlatformNodeDelegate
 FlutterPlatformNodeDelegate ()
 
virtual ~FlutterPlatformNodeDelegate () override
 
const ui::AXUniqueId & GetUniqueId () const override
 
const ui::AXNodeData & GetData () const override
 
bool AccessibilityPerformAction (const ui::AXActionData &data) override
 
gfx::NativeViewAccessible GetParent () override
 
gfx::NativeViewAccessible GetFocus () override
 
int GetChildCount () const override
 
gfx::NativeViewAccessible ChildAtIndex (int index) override
 
gfx::Rect GetBoundsRect (const ui::AXCoordinateSystem coordinate_system, const ui::AXClippingBehavior clipping_behavior, ui::AXOffscreenResult *offscreen_result) const override
 
gfx::NativeViewAccessible GetLowestPlatformAncestor () const override
 
ui::AXNodePosition::AXPositionInstance CreateTextPositionAt (int offset) const override
 
ui::AXNode * GetAXNode () const
 Gets the underlying ax node for this platform node delegate. More...
 
std::weak_ptr< OwnerBridgeGetOwnerBridge () const
 Gets the owner of this platform node delegate. This is useful when you want to get the information about surrounding nodes of this platform node delegate, e.g. the global rect of this platform node delegate. This pointer is only safe in the platform thread. More...
 
virtual ui::AXPlatformNode * GetPlatformNode () const
 
virtual ui::AXPlatformNode * GetFromNodeID (int32_t id) override
 
virtual ui::AXPlatformNode * GetFromTreeIDAndNodeID (const ui::AXTreeID &tree_id, int32_t node_id) override
 
virtual const ui::AXTree::Selection GetUnignoredSelection () const override
 

Detailed Description

The macOS implementation of FlutterPlatformNodeDelegate. This class uses AXPlatformNodeMac to manage the macOS-specific accessibility objects.

Definition at line 22 of file FlutterPlatformNodeDelegateMac.h.

Constructor & Destructor Documentation

◆ FlutterPlatformNodeDelegateMac()

flutter::FlutterPlatformNodeDelegateMac::FlutterPlatformNodeDelegateMac ( std::weak_ptr< AccessibilityBridge bridge,
__weak FlutterViewController view_controller 
)

Definition at line 23 of file FlutterPlatformNodeDelegateMac.mm.

26  : bridge_(std::move(bridge)), view_controller_(view_controller) {}

◆ ~FlutterPlatformNodeDelegateMac()

flutter::FlutterPlatformNodeDelegateMac::~FlutterPlatformNodeDelegateMac ( )
virtual

Definition at line 38 of file FlutterPlatformNodeDelegateMac.mm.

38  {
39  // Destroy() also calls delete on itself.
40  ax_platform_node_->Destroy();
41 }

Member Function Documentation

◆ GetBoundsRect()

gfx::Rect flutter::FlutterPlatformNodeDelegateMac::GetBoundsRect ( const ui::AXCoordinateSystem  coordinate_system,
const ui::AXClippingBehavior  clipping_behavior,
ui::AXOffscreenResult *  offscreen_result 
) const
override

Definition at line 57 of file FlutterPlatformNodeDelegateMac.mm.

60  {
61  gfx::Rect local_bounds = FlutterPlatformNodeDelegate::GetBoundsRect(
62  coordinate_system, clipping_behavior, offscreen_result);
63  gfx::RectF local_bounds_f(local_bounds);
64  gfx::RectF screen_bounds = ConvertBoundsFromLocalToScreen(local_bounds_f);
65  return gfx::ToEnclosingRect(ConvertBoundsFromScreenToGlobal(screen_bounds));
66 }

References flutter::FlutterPlatformNodeDelegate::GetBoundsRect().

◆ GetLiveRegionText()

std::string flutter::FlutterPlatformNodeDelegateMac::GetLiveRegionText ( ) const

Gets the live region text of this node in UTF-8 format. This is useful to determine the changes in between semantics updates when generating accessibility events.

Definition at line 73 of file FlutterPlatformNodeDelegateMac.mm.

73  {
74  if (GetAXNode()->IsIgnored()) {
75  return "";
76  }
77 
78  std::string text = GetData().GetStringAttribute(ax::mojom::StringAttribute::kName);
79  if (!text.empty()) {
80  return text;
81  };
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) {
87  continue;
88  }
89  text += std::static_pointer_cast<FlutterPlatformNodeDelegateMac>(delegate_child)
90  ->GetLiveRegionText();
91  }
92  return text;
93 }

References flutter::FlutterPlatformNodeDelegate::GetAXNode(), and flutter::FlutterPlatformNodeDelegate::GetData().

◆ GetNativeViewAccessible()

gfx::NativeViewAccessible flutter::FlutterPlatformNodeDelegateMac::GetNativeViewAccessible ( )
override

Definition at line 43 of file FlutterPlatformNodeDelegateMac.mm.

43  {
44  NSCAssert(ax_platform_node_, @"Platform node does not exist.");
45  return ax_platform_node_->GetNativeViewAccessible();
46 }

◆ GetNSWindow()

gfx::NativeViewAccessible flutter::FlutterPlatformNodeDelegateMac::GetNSWindow ( )
override

Definition at line 68 of file FlutterPlatformNodeDelegateMac.mm.

68  {
69  FlutterAppDelegate* appDelegate = (FlutterAppDelegate*)[NSApp delegate];
70  return appDelegate.mainFlutterWindow;
71 }

References FlutterAppDelegate::mainFlutterWindow.

◆ GetParent()

gfx::NativeViewAccessible flutter::FlutterPlatformNodeDelegateMac::GetParent ( )
override

Definition at line 48 of file FlutterPlatformNodeDelegateMac.mm.

48  {
49  gfx::NativeViewAccessible parent = FlutterPlatformNodeDelegate::GetParent();
50  if (!parent) {
51  NSCAssert(view_controller_.viewLoaded, @"Flutter view must be loaded");
52  return view_controller_.flutterView;
53  }
54  return parent;
55 }

References flutter::FlutterPlatformNodeDelegate::GetParent().

◆ Init()

void flutter::FlutterPlatformNodeDelegateMac::Init ( std::weak_ptr< OwnerBridge bridge,
ui::AXNode *  node 
)
overridevirtual

Called only once, immediately after construction. The constructor doesn't take any arguments because in the Windows subclass we use a special function to construct a COM object. Subclasses must call super.

Reimplemented from flutter::FlutterPlatformNodeDelegate.

Definition at line 28 of file FlutterPlatformNodeDelegateMac.mm.

28  {
30  if (GetData().IsTextField()) {
31  ax_platform_node_ = new FlutterTextPlatformNode(this, view_controller_);
32  } else {
33  ax_platform_node_ = ui::AXPlatformNode::Create(this);
34  }
35  NSCAssert(ax_platform_node_, @"Failed to create platform node.");
36 }

References flutter::FlutterPlatformNodeDelegate::GetData(), and flutter::FlutterPlatformNodeDelegate::Init().

Referenced by flutter::testing::TEST().


The documentation for this class was generated from the following files:
flutter::FlutterPlatformNodeDelegate::Init
virtual void Init(std::weak_ptr< OwnerBridge > bridge, ui::AXNode *node)
Called only once, immediately after construction. The constructor doesn't take any arguments because ...
Definition: flutter_platform_node_delegate.cc:20
flutter::FlutterPlatformNodeDelegate::GetData
const ui::AXNodeData & GetData() const override
Definition: flutter_platform_node_delegate.cc:60
flutter::FlutterPlatformNodeDelegate::GetBoundsRect
gfx::Rect GetBoundsRect(const ui::AXCoordinateSystem coordinate_system, const ui::AXClippingBehavior clipping_behavior, ui::AXOffscreenResult *offscreen_result) const override
Definition: flutter_platform_node_delegate.cc:94
FlutterAppDelegate
Definition: FlutterAppDelegate.h:54
FlutterAppDelegate::mainFlutterWindow
IBOutlet NSWindow * mainFlutterWindow
Definition: FlutterAppDelegate.h:65
flutter::FlutterPlatformNodeDelegate::GetAXNode
ui::AXNode * GetAXNode() const
Gets the underlying ax node for this platform node delegate.
Definition: flutter_platform_node_delegate.cc:26
flutter::FlutterPlatformNodeDelegate::GetParent
gfx::NativeViewAccessible GetParent() override
Definition: flutter_platform_node_delegate.cc:64