Commit 8ab706a3 authored by Yi Gu's avatar Yi Gu Committed by Commit Bot

[VizHitTesting] Do not hit test regions with pointer-events: none

HitTesting should skip surface layers that have pointer-events: none as
well as their descendants.

Bug: 1002245, 1002228
Change-Id: I2b471c4a7439857d6eabb1456ec42ed6a3c6b251
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1797092
Commit-Queue: Yi Gu <yigu@chromium.org>
Reviewed-by: default avatarKen Buchanan <kenrb@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#696987}
parent fd3df7e8
...@@ -191,6 +191,13 @@ bool HitTestQuery::FindTargetInRegionForLocation( ...@@ -191,6 +191,13 @@ bool HitTestQuery::FindTargetInRegionForLocation(
Target* target) const { Target* target) const {
gfx::PointF location_transformed(location); gfx::PointF location_transformed(location);
// Exclude a region and all its descendants if the region has the ignore bit
// set.
if (features::IsVizHitTestingSurfaceLayerEnabled() &&
hit_test_data_[region_index].flags & HitTestRegionFlags::kHitTestIgnore) {
return false;
}
if (is_location_relative_to_parent) { if (is_location_relative_to_parent) {
// HasPerspective() is checked for the transform because the point will not // HasPerspective() is checked for the transform because the point will not
// be transformed correctly for a plane with a different normal. // be transformed correctly for a plane with a different normal.
......
...@@ -2805,6 +2805,92 @@ IN_PROC_BROWSER_TEST_P(SitePerProcessHitTestBrowserTest, ...@@ -2805,6 +2805,92 @@ IN_PROC_BROWSER_TEST_P(SitePerProcessHitTestBrowserTest,
kHitTestTolerance); kHitTestTolerance);
} }
IN_PROC_BROWSER_TEST_P(SitePerProcessHitTestBrowserTest,
PointerEventsNoneWithNestedOOPIF) {
GURL main_url(embedded_test_server()->GetURL(
"/frame_tree/page_with_positioned_nested_frames.html"));
EXPECT_TRUE(NavigateToURL(shell(), main_url));
FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
->GetFrameTree()
->root();
ASSERT_EQ(1U, root->child_count());
RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>(
root->current_frame_host()->GetRenderWidgetHost()->GetView());
EXPECT_EQ(
" Site A ------------ proxies for B C\n"
" +--Site B ------- proxies for A C\n"
" +--Site C -- proxies for A B\n"
"Where A = http://127.0.0.1/\n"
" B = http://a.com/\n"
" C = http://baz.com/",
DepictFrameTree(root));
FrameTreeNode* child_node = root->child_at(0);
FrameTreeNode* grandchild_node = child_node->child_at(0);
// This is to make sure that the hit_test_data is clean before running the
// hit_test_data_change_observer.
WaitForHitTestData(child_node->current_frame_host());
WaitForHitTestData(grandchild_node->current_frame_host());
HitTestRegionObserver hit_test_data_change_observer(
root_view->GetRootFrameSinkId());
hit_test_data_change_observer.WaitForHitTestData();
EXPECT_TRUE(ExecuteScript(web_contents(),
"document.getElementsByTagName('iframe')[0].style."
"pointerEvents = 'none';"));
hit_test_data_change_observer.WaitForHitTestDataChange();
MainThreadFrameObserver observer(
root->current_frame_host()->GetRenderWidgetHost());
observer.Wait();
// Create listeners for mouse events.
RenderWidgetHostMouseEventMonitor main_frame_monitor(
root->current_frame_host()->GetRenderWidgetHost());
RenderWidgetHostMouseEventMonitor child_frame_monitor(
child_node->current_frame_host()->GetRenderWidgetHost());
// ------------------------
// root 50px
// ---------------------
// |child 50px |
// 50px| -------------- |
// |50px| grand_child ||
// | | ||
// | |-------------||
// ---------------------
//
// Since child has pointer-events: none, (125, 125) should be claimed by root.
blink::WebMouseEvent mouse_event(
blink::WebInputEvent::kMouseDown, blink::WebInputEvent::kNoModifiers,
blink::WebInputEvent::GetStaticTimeStampForTests());
mouse_event.button = blink::WebPointerProperties::Button::kLeft;
SetWebEventPositions(&mouse_event, gfx::Point(125, 125), root_view);
mouse_event.click_count = 1;
main_frame_monitor.ResetEventReceived();
child_frame_monitor.ResetEventReceived();
InputEventAckWaiter waiter(root->current_frame_host()->GetRenderWidgetHost(),
blink::WebInputEvent::kMouseDown);
RenderWidgetHostInputEventRouter* router =
web_contents()->GetInputEventRouter();
router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo());
waiter.Wait();
EXPECT_TRUE(main_frame_monitor.EventWasReceived());
EXPECT_NEAR(125, main_frame_monitor.event().PositionInWidget().x,
kHitTestTolerance);
EXPECT_NEAR(125, main_frame_monitor.event().PositionInWidget().y,
kHitTestTolerance);
EXPECT_FALSE(child_frame_monitor.EventWasReceived());
}
// This test tests that browser process can successfully hit test on nested // This test tests that browser process can successfully hit test on nested
// OOPIFs that are partially occluded by main frame elements. // OOPIFs that are partially occluded by main frame elements.
IN_PROC_BROWSER_TEST_P(SitePerProcessHitTestBrowserTest, IN_PROC_BROWSER_TEST_P(SitePerProcessHitTestBrowserTest,
......
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