Mark nodes as kIsLineBreakingObject by default, TODO further distinctions (flutter/engine#38721)

* 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>
This commit is contained in:
yaakovschectman
2023-01-10 11:13:44 -05:00
committed by GitHub
parent 414f8a2f6f
commit 717c8724c6
2 changed files with 25 additions and 0 deletions

View File

@@ -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(

View File

@@ -496,5 +496,24 @@ TEST(AccessibilityBridgeTest, AXTreeManagerTest) {
ASSERT_EQ(manager, static_cast<ui::AXTreeManager*>(bridge.get()));
}
TEST(AccessibilityBridgeTest, LineBreakingObjectTest) {
std::shared_ptr<TestAccessibilityBridge> bridge =
std::make_shared<TestAccessibilityBridge>();
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