| Flutter iOS Embedder |

Classes | Public Member Functions | List of all members
flutter::FlutterPlatformNodeDelegate Class Reference

`#include <flutter_platform_node_delegate.h>`

Inheritance diagram for flutter::FlutterPlatformNodeDelegate:

## Classes
class | OwnerBridge

## Public Member Functions
| 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
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 in the Windows subclass we use a special function to construct a COM object. Subclasses must call super. More...
virtual void | NodeDataChanged (const ui::AXNodeData &old_node_data, const ui::AXNodeData &new_node_data)
ui::AXNode * | GetAXNode () const
| Gets the underlying ax node for this platform node delegate. More...
std::weak_ptr< OwnerBridge > | GetOwnerBridge () 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 platform node delegate to be used in accessibility bridge. This class is responsible for providing native accessibility object with appropriate information, such as accessibility label/value/bounds.

While most methods have default implementations and are ready to be used as-is, the subclasses must override the GetNativeViewAccessible to return native accessibility objects. To do that, subclasses should create and maintain AXPlatformNode[s] which delegate their accessibility attributes to this class.

For desktop platforms, subclasses also need to override the GetBoundsRect to apply window-to-screen transform.

This class transforms bounds assuming the device pixel ratio is 1.0. See the https://github.com/flutter/flutter/issues/74283 for more information.

Definition at line 33 of file flutter_platform_node_delegate.h.

## Constructor & Destructor Documentation

## ◆ FlutterPlatformNodeDelegate()

flutter::FlutterPlatformNodeDelegate::FlutterPlatformNodeDelegate | ( |  | ) |
| default

## ◆ ~FlutterPlatformNodeDelegate()

flutter::FlutterPlatformNodeDelegate::~FlutterPlatformNodeDelegate | ( |  | ) |
| override virtual default

## Member Function Documentation

## ◆ AccessibilityPerformAction()

bool flutter::FlutterPlatformNodeDelegate::AccessibilityPerformAction | ( | const ui::AXActionData & | data | ) |
| override

Definition at line 30 of file flutter_platform_node_delegate.cc.

31 {
32 AccessibilityNodeId target = ax_node_->id();
33 auto bridge_ptr = bridge_.lock();
34 BASE_DCHECK(bridge_ptr);
35 switch (data.action) {
36 case ax::mojom::Action::kDoDefault:
37 bridge_ptr->DispatchAccessibilityAction(
38 target, FlutterSemanticsAction::kFlutterSemanticsActionTap, {});
39 return true;
40 case ax::mojom::Action::kFocus:
41 bridge_ptr->SetLastFocusedId(target);
42 bridge_ptr->DispatchAccessibilityAction(
43 target,
44 FlutterSemanticsAction::
45 kFlutterSemanticsActionDidGainAccessibilityFocus,
46 {});
47 return true;
48 case ax::mojom::Action::kScrollToMakeVisible:
49 bridge_ptr->DispatchAccessibilityAction(
50 target, FlutterSemanticsAction::kFlutterSemanticsActionShowOnScreen,
51 {});
52 return true;
53 // TODO(chunhtai): support more actions.
54 default:
55 return false;
56 }
57 return false;
58 }

## ◆ ChildAtIndex()

gfx::NativeViewAccessible flutter::FlutterPlatformNodeDelegate::ChildAtIndex | ( | int | index | ) |
| override

Definition at line 87 of file flutter_platform_node_delegate.cc.

87 {
88 auto bridge_ptr = bridge_.lock();
89 BASE_DCHECK(bridge_ptr);
90 AccessibilityNodeId child = ax_node_->GetUnignoredChildAtIndex(index)->id();
91 return bridge_ptr->GetNativeAccessibleFromId(child);
92 }

## ◆ CreateTextPositionAt()

ui::AXNodePosition::AXPositionInstance flutter::FlutterPlatformNodeDelegate::CreateTextPositionAt | ( | int | offset | ) | const
| override

Definition at line 136 of file flutter_platform_node_delegate.cc.

136 {
137 return ui::AXNodePosition::CreatePosition(*ax_node_, offset);
138 }

## ◆ GetAXNode()

ui::AXNode * flutter::FlutterPlatformNodeDelegate::GetAXNode | ( |  | ) | const

Gets the underlying ax node for this platform node delegate.

Definition at line 26 of file flutter_platform_node_delegate.cc.

26 {
27 return ax_node_;
28 }

## ◆ GetBoundsRect()

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

Definition at line 94 of file flutter_platform_node_delegate.cc.

97 {
98 auto bridge_ptr = bridge_.lock();
99 BASE_DCHECK(bridge_ptr);
100 // TODO(chunhtai): We need to apply screen dpr in here.
101 // https://github.com/flutter/flutter/issues/74283
102 const bool clip_bounds =
103 clipping_behavior == ui::AXClippingBehavior::kClipped;
104 bool offscreen = false;
105 gfx::RectF bounds =
106 bridge_ptr->RelativeToGlobalBounds(ax_node_, offscreen, clip_bounds);
107 if (offscreen_result != nullptr) {
108 *offscreen_result = offscreen ? ui::AXOffscreenResult::kOffscreen
109 : ui::AXOffscreenResult::kOnscreen;
110 }
111 return gfx::ToEnclosingRect(bounds);
112 }

## ◆ GetChildCount()

int flutter::FlutterPlatformNodeDelegate::GetChildCount | ( |  | ) | const
| override

Definition at line 83 of file flutter_platform_node_delegate.cc.

83 {
84 return static_cast<int>(ax_node_->GetUnignoredChildCount());
85 }

## ◆ GetData()

const ui::AXNodeData & flutter::FlutterPlatformNodeDelegate::GetData | ( |  | ) | const
| override

Definition at line 60 of file flutter_platform_node_delegate.cc.

60 {
61 return ax_node_->data();
62 }

## ◆ GetFocus()

gfx::NativeViewAccessible flutter::FlutterPlatformNodeDelegate::GetFocus | ( |  | ) |
| override

Definition at line 73 of file flutter_platform_node_delegate.cc.

73 {
74 auto bridge_ptr = bridge_.lock();
75 BASE_DCHECK(bridge_ptr);
76 AccessibilityNodeId last_focused = bridge_ptr->GetLastFocusedId();
77 if (last_focused == ui::AXNode::kInvalidAXID) {
78 return nullptr;
79 }
80 return bridge_ptr->GetNativeAccessibleFromId(last_focused);
81 }

## ◆ GetFromNodeID()

ui::AXPlatformNode * flutter::FlutterPlatformNodeDelegate::GetFromNodeID | ( | int32_t | id | ) |
| override virtual

Definition at line 140 of file flutter_platform_node_delegate.cc.

141 {
142 ui::AXTreeManager* tree_manager =
143 ui::AXTreeManagerMap::GetInstance().GetManager(
144 ax_node_->tree()->GetAXTreeID());
145 AccessibilityBridge* platform_manager =
146 static_cast<AccessibilityBridge*>(tree_manager);
147 return platform_manager->GetPlatformNodeFromTree(node_id);
148 }

References flutter::AccessibilityBridge::GetPlatformNodeFromTree().

## ◆ GetFromTreeIDAndNodeID()

ui::AXPlatformNode * flutter::FlutterPlatformNodeDelegate::GetFromTreeIDAndNodeID | ( | const ui::AXTreeID & | tree_id,
|  | int32_t | node_id
| ) |  |
| override virtual

Definition at line 150 of file flutter_platform_node_delegate.cc.

152 {
153 ui::AXTreeManager* tree_manager =
154 ui::AXTreeManagerMap::GetInstance().GetManager(tree_id);
155 AccessibilityBridge* platform_manager =
156 static_cast<AccessibilityBridge*>(tree_manager);
157 return platform_manager->GetPlatformNodeFromTree(node_id);
158 }

References flutter::AccessibilityBridge::GetPlatformNodeFromTree().

## ◆ GetLowestPlatformAncestor()

gfx::NativeViewAccessible flutter::FlutterPlatformNodeDelegate::GetLowestPlatformAncestor | ( |  | ) | const
| override

Definition at line 124 of file flutter_platform_node_delegate.cc.

124 {
125 auto bridge_ptr = bridge_.lock();
126 BASE_DCHECK(bridge_ptr);
127 auto lowest_platform_ancestor = ax_node_->GetLowestPlatformAncestor();
128 if (lowest_platform_ancestor) {
129 return bridge_ptr->GetNativeAccessibleFromId(
130 ax_node_->GetLowestPlatformAncestor()->id());
131 }
132 return nullptr;
133 }

## ◆ GetOwnerBridge()

std::weak_ptr< FlutterPlatformNodeDelegate::OwnerBridge > flutter::FlutterPlatformNodeDelegate::GetOwnerBridge | ( |  | ) | 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.

Definition at line 115 of file flutter_platform_node_delegate.cc.

115 {
116 return bridge_;
117 }

## ◆ GetParent()

gfx::NativeViewAccessible flutter::FlutterPlatformNodeDelegate::GetParent | ( |  | ) |
| override

Definition at line 64 of file flutter_platform_node_delegate.cc.

64 {
65 if (!ax_node_->parent()) {
66 return nullptr;
67 }
68 auto bridge_ptr = bridge_.lock();
69 BASE_DCHECK(bridge_ptr);
70 return bridge_ptr->GetNativeAccessibleFromId(ax_node_->parent()->id());
71 }

## ◆ GetPlatformNode()

ui::AXPlatformNode * flutter::FlutterPlatformNodeDelegate::GetPlatformNode | ( |  | ) | const
| virtual

Definition at line 119 of file flutter_platform_node_delegate.cc.

119 {
120 return nullptr;
121 }

## ◆ GetUnignoredSelection()

const ui::AXTree::Selection flutter::FlutterPlatformNodeDelegate::GetUnignoredSelection | ( |  | ) | const
| override virtual

Definition at line 160 of file flutter_platform_node_delegate.cc.

161 {
162 return ax_node_->GetUnignoredSelection();
163 }

## ◆ GetUniqueId()

const ui::AXUniqueId& flutter::FlutterPlatformNodeDelegate::GetUniqueId | ( |  | ) | const
| inline override

Definition at line 102 of file flutter_platform_node_delegate.h.

102 { return unique_id_; }

## ◆ Init()

void flutter::FlutterPlatformNodeDelegate::Init | ( | std::weak_ptr< OwnerBridge > | bridge,
|  | ui::AXNode * | node
| ) |  |
| virtual

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.

Definition at line 20 of file flutter_platform_node_delegate.cc.

21 {
22 bridge_ = std::move(bridge);
23 ax_node_ = node;
24 }

## ◆ NodeDataChanged()

virtual void flutter::FlutterPlatformNodeDelegate::NodeDataChanged | ( | const ui::AXNodeData & | old_node_data,
|  | const ui::AXNodeData & | new_node_data
| ) |  |
| inline virtual

Definition at line 145 of file flutter_platform_node_delegate.h.

146 {}

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

- shell/platform/common/flutter_platform_node_delegate.h
- shell/platform/common/flutter_platform_node_delegate.cc

flutter::AccessibilityNodeId
ui::AXNode::AXID AccessibilityNodeId
Definition: flutter_platform_node_delegate.h:15