From 29fd771d30b0c8033f3067108a37282eb0d4e27f Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Mon, 22 Nov 2021 10:08:31 -0800 Subject: [PATCH] Extract AccessibilityBridge::kRootNodeId (flutter/engine#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. --- .../flutter/shell/platform/common/accessibility_bridge.h | 6 ++++++ .../framework/Source/AccessibilityBridgeMacDelegate.mm | 9 ++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/engine/src/flutter/shell/platform/common/accessibility_bridge.h b/engine/src/flutter/shell/platform/common/accessibility_bridge.h index b9ef87719eb..32b4fcb2711 100644 --- a/engine/src/flutter/shell/platform/common/accessibility_bridge.h +++ b/engine/src/flutter/shell/platform/common/accessibility_bridge.h @@ -100,6 +100,7 @@ class AccessibilityBridge virtual std::shared_ptr CreateFlutterPlatformNodeDelegate() = 0; }; + //----------------------------------------------------------------------------- /// @brief Creates a new instance of a accessibility bridge. /// @@ -110,6 +111,11 @@ class AccessibilityBridge std::unique_ptr delegate); ~AccessibilityBridge(); + //----------------------------------------------------------------------------- + /// @brief The ID of the root node in the accessibility tree. In Flutter, + // this is always 0. + static constexpr int32_t kRootNodeId = 0; + //------------------------------------------------------------------------------ /// @brief Adds a semantics node update to the pending semantics update. /// Calling this method alone will NOT update the semantics tree. diff --git a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/AccessibilityBridgeMacDelegate.mm b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/AccessibilityBridgeMacDelegate.mm index 36659708c84..8e5e315a0cb 100644 --- a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/AccessibilityBridgeMacDelegate.mm +++ b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/AccessibilityBridgeMacDelegate.mm @@ -12,8 +12,6 @@ namespace flutter { -inline constexpr int32_t kRootNode = 0; - // Native mac notifications fired. These notifications are not publicly documented. static NSString* const AccessibilityLoadCompleteNotification = @"AXLoadComplete"; static NSString* const AccessibilityInvalidStatusChangedNotification = @"AXInvalidStatusChanged"; @@ -187,9 +185,10 @@ AccessibilityBridgeMacDelegate::MacOSEventsFromAXEvent(ui::AXEventGenerator::Eve if (ax_node.data().HasState(ax::mojom::State::kEditable)) { events.push_back({ .name = NSAccessibilityValueChangedNotification, - .target = bridge->GetFlutterPlatformNodeDelegateFromID(kRootNode) - .lock() - ->GetNativeViewAccessible(), + .target = + bridge->GetFlutterPlatformNodeDelegateFromID(AccessibilityBridge::kRootNodeId) + .lock() + ->GetNativeViewAccessible(), .user_info = nil, }); }