Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit d2bd6cf

Browse files
Update FlutterPlatformNodeDelegate
1 parent c5e0f9e commit d2bd6cf

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

shell/platform/common/flutter_platform_node_delegate.cc

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
#include <utility>
88

9+
#include "flutter/shell/platform/common/accessibility_bridge.h"
910
#include "flutter/third_party/accessibility/ax/ax_action_data.h"
11+
#include "flutter/third_party/accessibility/ax/ax_tree_manager_map.h"
1012
#include "flutter/third_party/accessibility/gfx/geometry/rect_conversions.h"
1113

1214
namespace flutter {
@@ -118,4 +120,46 @@ ui::AXPlatformNode* FlutterPlatformNodeDelegate::GetPlatformNode() const {
118120
return nullptr;
119121
}
120122

123+
gfx::NativeViewAccessible
124+
FlutterPlatformNodeDelegate::GetLowestPlatformAncestor() const {
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+
}
134+
135+
ui::AXNodePosition::AXPositionInstance
136+
FlutterPlatformNodeDelegate::CreateTextPositionAt(int offset) const {
137+
return ui::AXNodePosition::CreatePosition(*ax_node_, offset);
138+
}
139+
140+
ui::AXPlatformNode* FlutterPlatformNodeDelegate::GetFromNodeID(
141+
int32_t node_id) {
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+
}
149+
150+
ui::AXPlatformNode* FlutterPlatformNodeDelegate::GetFromTreeIDAndNodeID(
151+
const ui::AXTreeID& tree_id,
152+
int32_t node_id) {
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+
}
159+
160+
const ui::AXTree::Selection FlutterPlatformNodeDelegate::GetUnignoredSelection()
161+
const {
162+
return ax_node_->GetUnignoredSelection();
163+
}
164+
121165
} // namespace flutter

shell/platform/common/flutter_platform_node_delegate.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@ class FlutterPlatformNodeDelegate : public ui::AXPlatformNodeDelegateBase {
125125
const ui::AXClippingBehavior clipping_behavior,
126126
ui::AXOffscreenResult* offscreen_result) const override;
127127

128+
// |ui::AXPlatformNodeDelegateBase|
129+
gfx::NativeViewAccessible GetLowestPlatformAncestor() const override;
130+
131+
// |ui::AXPlatformNodeDelegateBase|
132+
ui::AXNodePosition::AXPositionInstance CreateTextPositionAt(
133+
int offset) const override;
134+
128135
//------------------------------------------------------------------------------
129136
/// @brief Called only once, immediately after construction. The
130137
/// constructor doesn't take any arguments because in the Windows
@@ -147,6 +154,17 @@ class FlutterPlatformNodeDelegate : public ui::AXPlatformNodeDelegateBase {
147154
// Get the platform node represented by this delegate.
148155
virtual ui::AXPlatformNode* GetPlatformNode() const;
149156

157+
// |ui::AXPlatformNodeDelegateBase|
158+
virtual ui::AXPlatformNode* GetFromNodeID(int32_t id) override;
159+
160+
// |ui::AXPlatformNodeDelegateBase|
161+
virtual ui::AXPlatformNode* GetFromTreeIDAndNodeID(
162+
const ui::AXTreeID& tree_id,
163+
int32_t node_id) override;
164+
165+
// |ui::AXPlatformNodeDelegateBase|
166+
virtual const ui::AXTree::Selection GetUnignoredSelection() const override;
167+
150168
private:
151169
ui::AXNode* ax_node_;
152170
std::weak_ptr<OwnerBridge> bridge_;

0 commit comments

Comments
 (0)