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.
This commit is contained in:
Chris Bracken 2021-11-22 10:08:31 -08:00 committed by GitHub
parent 10e485ee00
commit 29fd771d30
2 changed files with 10 additions and 5 deletions

View File

@ -100,6 +100,7 @@ class AccessibilityBridge
virtual std::shared_ptr<FlutterPlatformNodeDelegate>
CreateFlutterPlatformNodeDelegate() = 0;
};
//-----------------------------------------------------------------------------
/// @brief Creates a new instance of a accessibility bridge.
///
@ -110,6 +111,11 @@ class AccessibilityBridge
std::unique_ptr<AccessibilityBridgeDelegate> 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.

View File

@ -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,
});
}