Commit aa22b502 authored by David Bokan's avatar David Bokan Committed by Commit Bot

[RLS] Adjust document rect for scrolling when hit testing

When kIgnoreClipping is passed as a parameter to HitTesting code we
should ignore overflow clipping on the root layer. We pass a hit test
rect into clipping code that we intersect with the usual rects.
Normally this will be the frame rect but when kIgnoreOverflow is used,
the hit test rect is unioned with the entire document rect to ensure
we can hit anywhere in the document.

However, when RLS is turned on hit testing occurs on absolute points,
rather than document points. This means that the scroll offset must be
accounted for in the hit test rect.

Bug: 828815
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I97e78d931685db1227fc975de8a3ed55783dd3e7
Reviewed-on: https://chromium-review.googlesource.com/1007889
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550134}
parent 79eb11b0
......@@ -11686,6 +11686,57 @@ class WebFrameSimTest : public testing::WithParamInterface<bool>,
INSTANTIATE_TEST_CASE_P(All, WebFrameSimTest, testing::Bool());
TEST_P(WebFrameSimTest, HitTestWithIgnoreClippingAtNegativeOffset) {
WebView().Resize(WebSize(500, 300));
WebView().GetPage()->GetSettings().SetTextAutosizingEnabled(false);
SimRequest r("https://example.com/test.html", "text/html");
LoadURL("https://example.com/test.html");
r.Complete(R"HTML(
<!DOCTYPE html>
<style>
body, html {
width: 100%;
height: 1000px;
margin: 0;
}
#top {
position: absolute;
top: 500px;
height: 100px;
width: 100%;
}
#bottom {
position: absolute;
top: 600px;
width: 100%;
height: 500px;
}
</style>
<div id="top"></div>
<div id="bottom"></div>
)HTML");
Compositor().BeginFrame();
LocalFrameView* frame_view =
ToLocalFrame(WebView().GetPage()->MainFrame())->View();
frame_view->GetScrollableArea()->SetScrollOffset(ScrollOffset(0, 600),
kProgrammaticScroll);
Compositor().BeginFrame();
HitTestRequest request = HitTestRequest::kMove | HitTestRequest::kReadOnly |
HitTestRequest::kActive |
HitTestRequest::kIgnoreClipping;
HitTestResult result(request,
frame_view->RootFrameToAbsolute(LayoutPoint(100, -50)));
frame_view->GetLayoutView()->HitTest(result);
EXPECT_EQ(GetDocument().getElementById("top"), result.InnerNode());
}
TEST_P(WebFrameSimTest, TickmarksDocumentRelative) {
WebView().Resize(WebSize(500, 300));
WebView().GetPage()->GetSettings().SetTextAutosizingEnabled(false);
......
......@@ -1742,8 +1742,12 @@ bool PaintLayer::HitTest(HitTestResult& result) {
// Start with frameVisibleRect to ensure we include the scrollbars.
LayoutRect hit_test_area = FrameVisibleRect(GetLayoutObject());
if (request.IgnoreClipping())
hit_test_area.Unite(LayoutRect(GetLayoutObject().View()->DocumentRect()));
if (request.IgnoreClipping()) {
if (LocalFrameView* frame_view = GetLayoutObject().GetDocument().View()) {
hit_test_area.Unite(frame_view->DocumentToAbsolute(
LayoutRect(GetLayoutObject().View()->DocumentRect())));
}
}
PaintLayer* inside_layer = HitTestLayer(this, nullptr, result, hit_test_area,
hit_test_location, false);
......
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