Commit 78f195db authored by Yi Gu's avatar Yi Gu Committed by Commit Bot

[VizHitTesting] Fix root_view_overlapped logic in HitTestQuery

crrev.com/c/1787118 skipped kHitTestAsk for root_view. However, it did
not reset the flag and async_hit_test_reasons when the target is
returned.

Bug: 999576
Change-Id: I9ba111af29687b2c86b0a69c8cd7e3df83686de1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1818432Reviewed-by: default avatarRobert Kroeger <rjkroege@chromium.org>
Commit-Queue: Yi Gu <yigu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699463}
parent 59633ee4
......@@ -285,10 +285,18 @@ bool HitTestQuery::FindTargetInRegionForLocation(
!(flags & HitTestRegionFlags::kHitTestIgnore)) {
target->frame_sink_id = hit_test_data_[region_index].frame_sink_id;
target->location_in_target = location_in_target;
target->flags = flags;
uint32_t async_hit_test_reasons =
hit_test_data_[region_index].async_hit_test_reasons;
uint32_t target_flags = flags;
if (root_view_overlapped) {
DCHECK_EQ(hit_test_data_[region_index].async_hit_test_reasons,
AsyncHitTestReasons::kOverlappedRegion);
target_flags &= ~HitTestRegionFlags::kHitTestAsk;
async_hit_test_reasons = AsyncHitTestReasons::kNotAsyncHitTest;
}
target->flags = target_flags;
// We record fast path hit testing instances with reason kNotAsyncHitTest.
RecordSlowPathHitTestReasons(
hit_test_data_[region_index].async_hit_test_reasons);
RecordSlowPathHitTestReasons(async_hit_test_reasons);
return true;
}
return false;
......
......@@ -1348,5 +1348,59 @@ TEST_F(HitTestQueryTest, FindTargetForLocationStartingFrom) {
HitTestRegionFlags::kHitTestMouse);
}
// One embedder with nested OOPIFs. When the root view is overlapped we should
// continue checking its descendants rather than doing async hit test.
//
// +e-------------+
// | +c---------| Point maps to
// | 1 | 2 | ----- -------
// | | | 1 e
// | | | 2 c
// | | |
// | | |
// +--------------+
//
TEST_F(HitTestQueryTest, OverlappedRootView) {
FrameSinkId e_id = FrameSinkId(1, 1);
FrameSinkId c_id = FrameSinkId(2, 2);
gfx::Rect e_bounds_in_e = gfx::Rect(0, 0, 600, 600);
gfx::Rect c_bounds_in_e = gfx::Rect(0, 0, 800, 800);
gfx::Transform transform_e_to_e, transform_e_to_c;
transform_e_to_c.Translate(-200, -100);
active_data_.push_back(AggregatedHitTestRegion(
e_id,
HitTestRegionFlags::kHitTestMine | HitTestRegionFlags::kHitTestMouse |
HitTestRegionFlags::kHitTestAsk,
e_bounds_in_e, transform_e_to_e, 1,
AsyncHitTestReasons::kOverlappedRegion)); // e
active_data_.push_back(AggregatedHitTestRegion(
c_id,
HitTestRegionFlags::kHitTestChildSurface | kHitTestMine |
HitTestRegionFlags::kHitTestMouse,
c_bounds_in_e, transform_e_to_c, 0)); // c
SendHitTestData();
// All points are in e's coordinate system when we reach this case.
gfx::PointF point1(1, 1);
gfx::PointF point2(202, 102);
Target target1 =
hit_test_query().FindTargetForLocation(EventSource::MOUSE, point1);
EXPECT_EQ(target1.frame_sink_id, e_id);
EXPECT_EQ(target1.location_in_target, point1);
// kHitTestAsk should be dropped for overlapped root view.
EXPECT_EQ(target1.flags, HitTestRegionFlags::kHitTestMine |
HitTestRegionFlags::kHitTestMouse);
Target target2 =
hit_test_query().FindTargetForLocation(EventSource::MOUSE, point2);
EXPECT_EQ(target2.frame_sink_id, c_id);
// point2 + transform_e_to_c = (2, 2).
EXPECT_EQ(target2.location_in_target, gfx::PointF(2, 2));
EXPECT_EQ(target2.flags, HitTestRegionFlags::kHitTestChildSurface |
HitTestRegionFlags::kHitTestMine |
HitTestRegionFlags::kHitTestMouse);
}
} // namespace test
} // namespace viz
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment