Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions shell/platform/fuchsia/flutter/accessibility_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,13 @@ std::optional<int32_t> AccessibilityBridge::GetHitNode(int32_t node_id,
!node.screen_rect.contains(x, y)) {
return {};
}
auto hit = node_id;
for (int32_t child_id : node.children_in_hit_test_order) {
hit = GetHitNode(child_id, x, y).value_or(hit);
auto candidate = GetHitNode(child_id, x, y);
if (candidate) {
return candidate;
}
}
return hit;
return node_id;
}

// |fuchsia::accessibility::semantics::SemanticListener|
Expand Down
35 changes: 35 additions & 0 deletions shell/platform/fuchsia/flutter/accessibility_bridge_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,41 @@ TEST_F(AccessibilityBridgeTest, HitTest) {
EXPECT_EQ(hit_node_id, 4u);
}

TEST_F(AccessibilityBridgeTest, HitTestOverlapping) {
// Tests that the first node in hit test order wins, even if a later node
// would be able to recieve the hit.
flutter::SemanticsNode node0;
node0.id = 0;
node0.rect.setLTRB(0, 0, 100, 100);

flutter::SemanticsNode node1;
node1.id = 1;
node1.rect.setLTRB(0, 0, 100, 100);

flutter::SemanticsNode node2;
node2.id = 2;
node2.rect.setLTRB(25, 10, 45, 20);

node0.childrenInTraversalOrder = {1, 2};
node0.childrenInHitTestOrder = {2, 1};

accessibility_bridge_->AddSemanticsNodeUpdate({
{0, node0},
{1, node1},
{2, node2},
});
RunLoopUntilIdle();

uint32_t hit_node_id;
auto callback = [&hit_node_id](fuchsia::accessibility::semantics::Hit hit) {
EXPECT_TRUE(hit.has_node_id());
hit_node_id = hit.node_id();
};

accessibility_bridge_->HitTest({30, 15}, callback);
EXPECT_EQ(hit_node_id, 2u);
}

TEST_F(AccessibilityBridgeTest, Actions) {
flutter::SemanticsNode node0;
node0.id = 0;
Expand Down