fune/testing/web-platform/tests/css/css-overflow/scroll-with-border-radius.html
Xianzhu Wang e918aa2ca2 Bug 1892370 [wpt PR 45797] - Fall back to main thread if scroll hit test is affected by rounded corners, a=testonly
Automatic update from web-platform-tests
Fall back to main thread if scroll hit test is affected by rounded corners

We had two issues:
1.  Before we had fast rounded corners, we always created mask layers
for rounded corner clips, and the mask layer made the scroll begin
unreliable and fall back to the main thread. With fast rounded corners,
the scrolls were treated as reliable without checking if the point is
in or out of the rounded corners.
2. If the scroller has a rounded corner by itself (instead of from an
ancestor), as we only create InnerBorderRadiusClip for the contents,
the compositor doesn't actually know which part of the layer bounds
is transparent to hit test (e.g. if the scroller has a border which
is outside of the InnerBorderRadiusClip). Now with HitTestOpaqueness,
such layers have HitTestOpaqueness::kMixed.

This CL changes the behavior of
LayerTreeImpl::FindLayersUpToFirstOpaqueToHitTest (renamed from
FindLayerUpToFirstScrollableOrOpaqueToHitTest):
- For issue #1: LayerImpl::OpaqueToHitTest() also checks whether the
  layer is affected by any fast rounded corners;
- For issue #2: FindLayerUpToFirstOpaqueToHitTest checks only
  OpaqueToHitTest() (without checking IsScrollerOrScrollbar())
  because a hit test on a scrollable layer is reliable only if it's
  opaque to hit test.

Bug: 40277896
Change-Id: I1acb16f2c6790760661e8239ea1599035f83ea51
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5466909
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: Steve Kobes <skobes@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1291538}

--

wpt-commits: 9e7e1bd19fecd541ce4192e24039b746a88ce3df
wpt-pr: 45797
2024-04-29 07:27:37 +00:00

51 lines
1.5 KiB
HTML

<!doctype html>
<meta charset=utf-8>
<title>Should not scroll out of rounded corner</title>
<link rel="help" href="https://crbug.com/40277896">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/dom/events/scrolling/scroll_support.js"></script>
<style>
#scroller {
border-radius: 100px;
overflow: auto;
width: 300px;
height: 300px;
border: 2px solid blue;
will-change: scroll-position;
}
.spacer {
height: 200vh;
}
</style>
<div id="scroller">
<div class="spacer"></div>
</div>
<div class="spacer"></div>
<script>
promise_test(async (t) => {
await waitForCompositorCommit();
let scrolled = new Promise((resolve) => {
let scrollers = [window, document.getElementById("scroller")];
let onscroll = (evt) => {
for (const scroller of scrollers) {
scroller.removeEventListener("scroll", onscroll);
}
resolve(evt.target.id || "root");
}
for (const scroller of scrollers) {
scroller.addEventListener("scroll", onscroll);
}
});
const actions = new test_driver.Actions().scroll(20, 20, 0, 50, { duration: 50 });
actions.send();
assert_equals(await scrolled, "root", "Incorrect element scrolled");
}, "Wheel-scroll out of rounded corner skips that scroller");
</script>