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

Commit c4c9702

Browse files
Mark nodes as kIsLineBreakingObject by default, TODO further distinctions (#38721)
* Line breaks * Formatting * Update shell/platform/common/accessibility_bridge.cc Co-authored-by: Loïc Sharma <[email protected]> * Test line breaking object * Formatting * Format Co-authored-by: Loïc Sharma <[email protected]>
1 parent ad9052a commit c4c9702

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

shell/platform/common/accessibility_bridge.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,12 @@ void AccessibilityBridge::SetBooleanAttributesFromFlutterUpdate(
435435
ax::mojom::BoolAttribute::kEditableRoot,
436436
flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField &&
437437
(flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsReadOnly) == 0);
438+
// Mark nodes as line breaking so that screen readers don't
439+
// merge all consecutive objects into one.
440+
// TODO(schectman): When should a node have this attribute set?
441+
// https://github.com/flutter/flutter/issues/118184
442+
node_data.AddBoolAttribute(ax::mojom::BoolAttribute::kIsLineBreakingObject,
443+
true);
438444
}
439445

440446
void AccessibilityBridge::SetIntAttributesFromFlutterUpdate(

shell/platform/common/accessibility_bridge_unittests.cc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,5 +496,24 @@ TEST(AccessibilityBridgeTest, AXTreeManagerTest) {
496496
ASSERT_EQ(manager, static_cast<ui::AXTreeManager*>(bridge.get()));
497497
}
498498

499+
TEST(AccessibilityBridgeTest, LineBreakingObjectTest) {
500+
std::shared_ptr<TestAccessibilityBridge> bridge =
501+
std::make_shared<TestAccessibilityBridge>();
502+
503+
const int32_t root_id = 0;
504+
505+
FlutterSemanticsNode root = CreateSemanticsNode(root_id, "root", {});
506+
507+
bridge->AddFlutterSemanticsNodeUpdate(&root);
508+
bridge->CommitUpdates();
509+
510+
auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(root_id).lock();
511+
auto root_data = root_node->GetData();
512+
EXPECT_TRUE(root_data.HasBoolAttribute(
513+
ax::mojom::BoolAttribute::kIsLineBreakingObject));
514+
EXPECT_TRUE(root_data.GetBoolAttribute(
515+
ax::mojom::BoolAttribute::kIsLineBreakingObject));
516+
}
517+
499518
} // namespace testing
500519
} // namespace flutter

0 commit comments

Comments
 (0)