Commit 94258d72 authored by Yi Gu's avatar Yi Gu Committed by Commit Bot

[VizHitTesting] Skip checking nested iframe when one iframe is marked as kHitTestAsk

When we have nested main_frame->parent_frame->child_frame and only the
mid-level parent_frame has kHitTestAsk flag, we should not directly
dispatch the event to the child_frame because the parent_frame may have
overlapping regions with main_frame divs. Instead RWHIER should always
ask when it encounters a mid-level kHitTestAsk flag.

To fix the drag and drop issue (crbug.com/804633) in V1, the logic above
was broken as a temporary workaround. Now that the drag and drop bug has
been formally fixed, we should resume the correct logic.

Bug: 995850
Change-Id: Idc380b0249e650d3b73af60f2a1d99f30bee1a3b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1762531Reviewed-by: default avatarRobert Kroeger <rjkroege@chromium.org>
Commit-Queue: Yi Gu <yigu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688771}
parent d2a0ecf2
......@@ -231,9 +231,8 @@ bool HitTestQuery::FindTargetInRegionForLocation(
DCHECK_EQ(!!(flags & HitTestRegionFlags::kHitTestAsk),
!!hit_test_data_[region_index].async_hit_test_reasons);
if (features::IsVizHitTestingSurfaceLayerEnabled() &&
((flags & HitTestRegionFlags::kHitTestAsk) &&
!(flags & HitTestRegionFlags::kHitTestIgnore))) {
if ((flags & HitTestRegionFlags::kHitTestAsk) &&
!(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;
......@@ -260,8 +259,7 @@ bool HitTestQuery::FindTargetInRegionForLocation(
if (!RegionMatchEventSource(event_source, flags))
return false;
if ((flags &
(HitTestRegionFlags::kHitTestMine | HitTestRegionFlags::kHitTestAsk)) &&
if ((flags & HitTestRegionFlags::kHitTestMine) &&
!(flags & HitTestRegionFlags::kHitTestIgnore)) {
target->frame_sink_id = hit_test_data_[region_index].frame_sink_id;
target->location_in_target = location_in_target;
......
......@@ -1090,14 +1090,15 @@ TEST_F(HitTestQueryTest, ChildHitTestAskFlag) {
HitTestRegionFlags::kHitTestMouse);
}
// One embedder with nested OOPIFs.
// One embedder with nested OOPIFs. When the mid-level iframe has kHitTestAsk
// flag we should do async hit test and skip checking its descendants.
//
// +e-------------+
// | +c---------| Point maps to
// | 1 | 2 | ----- -------
// | | | 1 e
// | |+b--------| 2 c
// | || | 3 b
// | || | 3 c
// | || 3 |
// +--------------+
//
......@@ -1143,17 +1144,21 @@ TEST_F(HitTestQueryTest, NestedOOPIFs) {
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::kHitTestAsk |
HitTestRegionFlags::kHitTestMouse);
// b is the deepest OOPIF for point3, return b with ask flag.
// b is the deepest OOPIF for point3, but c has the ask flag. Return c
// accordingly.
Target target3 =
hit_test_query().FindTargetForLocation(EventSource::MOUSE, point3);
EXPECT_EQ(target3.frame_sink_id, b_id);
EXPECT_EQ(target3.location_in_target, gfx::PointF(2, 2));
EXPECT_EQ(target3.flags, HitTestRegionFlags::kHitTestAsk |
EXPECT_EQ(target3.frame_sink_id, c_id);
// point3 + transform_e_to_c = (2, 102).
EXPECT_EQ(target3.location_in_target, gfx::PointF(2, 102));
EXPECT_EQ(target3.flags, HitTestRegionFlags::kHitTestChildSurface |
HitTestRegionFlags::kHitTestAsk |
HitTestRegionFlags::kHitTestMouse);
}
......
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