From 717c8724c6b56b106658338a952d7ea0bda6484d Mon Sep 17 00:00:00 2001 From: yaakovschectman <109111084+yaakovschectman@users.noreply.github.com> Date: Tue, 10 Jan 2023 11:13:44 -0500 Subject: [PATCH] Mark nodes as `kIsLineBreakingObject` by default, TODO further distinctions (flutter/engine#38721) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Line breaks * Formatting * Update shell/platform/common/accessibility_bridge.cc Co-authored-by: Loïc Sharma <737941+loic-sharma@users.noreply.github.com> * Test line breaking object * Formatting * Format Co-authored-by: Loïc Sharma <737941+loic-sharma@users.noreply.github.com> --- .../platform/common/accessibility_bridge.cc | 6 ++++++ .../common/accessibility_bridge_unittests.cc | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/engine/src/flutter/shell/platform/common/accessibility_bridge.cc b/engine/src/flutter/shell/platform/common/accessibility_bridge.cc index 8a98f3d724..e6b47d4ae6 100644 --- a/engine/src/flutter/shell/platform/common/accessibility_bridge.cc +++ b/engine/src/flutter/shell/platform/common/accessibility_bridge.cc @@ -435,6 +435,12 @@ void AccessibilityBridge::SetBooleanAttributesFromFlutterUpdate( ax::mojom::BoolAttribute::kEditableRoot, flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField && (flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsReadOnly) == 0); + // Mark nodes as line breaking so that screen readers don't + // merge all consecutive objects into one. + // TODO(schectman): When should a node have this attribute set? + // https://github.com/flutter/flutter/issues/118184 + node_data.AddBoolAttribute(ax::mojom::BoolAttribute::kIsLineBreakingObject, + true); } void AccessibilityBridge::SetIntAttributesFromFlutterUpdate( diff --git a/engine/src/flutter/shell/platform/common/accessibility_bridge_unittests.cc b/engine/src/flutter/shell/platform/common/accessibility_bridge_unittests.cc index 0aa078f925..7b5a4924e0 100644 --- a/engine/src/flutter/shell/platform/common/accessibility_bridge_unittests.cc +++ b/engine/src/flutter/shell/platform/common/accessibility_bridge_unittests.cc @@ -496,5 +496,24 @@ TEST(AccessibilityBridgeTest, AXTreeManagerTest) { ASSERT_EQ(manager, static_cast(bridge.get())); } +TEST(AccessibilityBridgeTest, LineBreakingObjectTest) { + std::shared_ptr bridge = + std::make_shared(); + + const int32_t root_id = 0; + + FlutterSemanticsNode root = CreateSemanticsNode(root_id, "root", {}); + + bridge->AddFlutterSemanticsNodeUpdate(&root); + bridge->CommitUpdates(); + + auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(root_id).lock(); + auto root_data = root_node->GetData(); + EXPECT_TRUE(root_data.HasBoolAttribute( + ax::mojom::BoolAttribute::kIsLineBreakingObject)); + EXPECT_TRUE(root_data.GetBoolAttribute( + ax::mojom::BoolAttribute::kIsLineBreakingObject)); +} + } // namespace testing } // namespace flutter