Skip to content

Commit c9a8a86

Browse files
authored
Extract AccessibilityBridge::kRootNodeId (flutter#29856)
The ID of the root semantics node in Flutter's semantics tree is always 0. Since we'll be adding support for Windows, extract this constant to a common location.
1 parent ad00d12 commit c9a8a86

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

shell/platform/common/accessibility_bridge.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ class AccessibilityBridge
100100
virtual std::shared_ptr<FlutterPlatformNodeDelegate>
101101
CreateFlutterPlatformNodeDelegate() = 0;
102102
};
103+
103104
//-----------------------------------------------------------------------------
104105
/// @brief Creates a new instance of a accessibility bridge.
105106
///
@@ -110,6 +111,11 @@ class AccessibilityBridge
110111
std::unique_ptr<AccessibilityBridgeDelegate> delegate);
111112
~AccessibilityBridge();
112113

114+
//-----------------------------------------------------------------------------
115+
/// @brief The ID of the root node in the accessibility tree. In Flutter,
116+
// this is always 0.
117+
static constexpr int32_t kRootNodeId = 0;
118+
113119
//------------------------------------------------------------------------------
114120
/// @brief Adds a semantics node update to the pending semantics update.
115121
/// Calling this method alone will NOT update the semantics tree.

shell/platform/darwin/macos/framework/Source/AccessibilityBridgeMacDelegate.mm

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313
namespace flutter {
1414

15-
inline constexpr int32_t kRootNode = 0;
16-
1715
// Native mac notifications fired. These notifications are not publicly documented.
1816
static NSString* const AccessibilityLoadCompleteNotification = @"AXLoadComplete";
1917
static NSString* const AccessibilityInvalidStatusChangedNotification = @"AXInvalidStatusChanged";
@@ -187,9 +185,10 @@
187185
if (ax_node.data().HasState(ax::mojom::State::kEditable)) {
188186
events.push_back({
189187
.name = NSAccessibilityValueChangedNotification,
190-
.target = bridge->GetFlutterPlatformNodeDelegateFromID(kRootNode)
191-
.lock()
192-
->GetNativeViewAccessible(),
188+
.target =
189+
bridge->GetFlutterPlatformNodeDelegateFromID(AccessibilityBridge::kRootNodeId)
190+
.lock()
191+
->GetNativeViewAccessible(),
193192
.user_info = nil,
194193
});
195194
}

0 commit comments

Comments
 (0)