Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow passive mouse wheel event listeners to not force synchronous sc…
…rolling

https://bugs.webkit.org/show_bug.cgi?id=158439
<rdar://problem/28265360>

Reviewed by Tim Horton.
Source/WebCore:

Turn on ENABLE_WHEEL_EVENT_REGIONS for macOS, and hit-test the passive and active regions
in ScrollingTree::determineWheelEventProcessin() to determine whether scrolling needs to
happen on the main thread, communicating via WheelEventProcessingSteps.

Now that we use EventRegion to store wheel event region information, we no longer need
to consult wheel event targets im ScrollingCoordinator::absoluteEventTrackingRegionsForFrame(),
but the non-fast region does still contain rectangles for non-fast-scrollable overflow
if async overflow scrolling is disabled.

Frame::invalidateContentEventRegionsIfNeeded() needs a fix to ensure that when wheel
event handlers in non-fast-scrollable subframes change we invalidate event regions.

RenderLayerBacking::updateEventRegion() needs a fix so that the event region for the root
(for handlers registered on the document or window) covers the entire root layer; painting
code only covered the RenderView, which is too small (and root background painting is complex).

Finally, when the processing steps given to EventHandler::handleWheelEvent() do not
include MainThreadForScrolling, then we shouldn't scroll here. The check in
EventHandler::handleWheelEvent() applies to frames, and the one in EventHandler::defaultWheelEventHandler()
applies to overflow:scroll.

Test: fast/scrolling/mac/slow-scrolling-overflow.html

* page/EventHandler.cpp:
(WebCore::EventHandler::handleWheelEvent):
(WebCore::EventHandler::defaultWheelEventHandler):
* page/Frame.cpp:
(WebCore::Frame::invalidateContentEventRegionsIfNeeded):
* page/scrolling/ScrollingCoordinator.cpp:
(WebCore::ScrollingCoordinator::absoluteEventTrackingRegionsForFrame const):
* page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::determineWheelEventProcessing):

Source/WTF:

Define ENABLE_WHEEL_EVENT_REGIONS for macOS.

* wtf/PlatformEnableCocoa.h:

LayoutTests:

Change tests that relied on dumping the non-fast scrollable rects for wheel handlers
to dump layer trees with event regions instead. They also need to wait for a
rendering update, since wheel event regions are updated once per frame.

slow-scrolling-overflow.html tests that an overflow:scroll that's forced into slow
scrolling because of background-attachment:fixed still scrolls.

* fast/scrolling/mac/slow-scrolling-overflow-expected.txt: Added.
* fast/scrolling/mac/slow-scrolling-overflow.html: Added.
* fast/scrolling/mac/wheel-event-listener-region-inside-overflow-scroll-clipped-out-expected.txt:
* fast/scrolling/mac/wheel-event-listener-region-inside-overflow-scroll-expected.txt:
* platform/mac-wk2/TestExpectations:
* tiled-drawing/scrolling/non-fast-region/fixed-div-in-scrollable-page.html:
* tiled-drawing/scrolling/non-fast-region/handlers-in-iframes-expected.txt:
* tiled-drawing/scrolling/non-fast-region/handlers-in-iframes.html:
* tiled-drawing/scrolling/non-fast-region/non-fast-scrollable-region-hide-show-iframe-expected.txt:
* tiled-drawing/scrolling/non-fast-region/non-fast-scrollable-region-hide-show-iframe.html:
* tiled-drawing/scrolling/non-fast-region/resources/wheel-handler-region-helper.js:
(nonFastScrollableRects):
(dumpNonFastScrollableRects):
(async dumpRegionAndNotifyDone):
(rectsAsString): Deleted.
(dumpRegion): Deleted.
* tiled-drawing/scrolling/non-fast-region/top-content-inset-expected.txt:
* tiled-drawing/scrolling/non-fast-region/top-content-inset-header-expected.txt:
* tiled-drawing/scrolling/non-fast-region/top-content-inset-header.html:
* tiled-drawing/scrolling/non-fast-region/top-content-inset.html:
* tiled-drawing/scrolling/non-fast-region/wheel-event-plugin.html:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-fixed-child-expected.txt:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-fixed-child.html:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-in-columns-expected.txt:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-in-columns.html:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-in-overflow-scroll-expected.txt:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-in-overflow-scroll.html:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-inside-fixed-expected.txt:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-inside-fixed.html:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-on-document-expected.txt:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-on-document.html:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-on-fixed-expected.txt:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-on-fixed.html:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-region-basic-expected.txt:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-region-basic.html:

Canonical link: https://commits.webkit.org/230457@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268476 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
smfr committed Oct 14, 2020
1 parent eae47eb commit 9e66fdb
Show file tree
Hide file tree
Showing 41 changed files with 682 additions and 121 deletions.
51 changes: 51 additions & 0 deletions LayoutTests/ChangeLog
@@ -1,3 +1,54 @@
2020-10-13 Simon Fraser <simon.fraser@apple.com>

Allow passive mouse wheel event listeners to not force synchronous scrolling
https://bugs.webkit.org/show_bug.cgi?id=158439
<rdar://problem/28265360>

Reviewed by Tim Horton.

Change tests that relied on dumping the non-fast scrollable rects for wheel handlers
to dump layer trees with event regions instead. They also need to wait for a
rendering update, since wheel event regions are updated once per frame.

slow-scrolling-overflow.html tests that an overflow:scroll that's forced into slow
scrolling because of background-attachment:fixed still scrolls.

* fast/scrolling/mac/slow-scrolling-overflow-expected.txt: Added.
* fast/scrolling/mac/slow-scrolling-overflow.html: Added.
* fast/scrolling/mac/wheel-event-listener-region-inside-overflow-scroll-clipped-out-expected.txt:
* fast/scrolling/mac/wheel-event-listener-region-inside-overflow-scroll-expected.txt:
* platform/mac-wk2/TestExpectations:
* tiled-drawing/scrolling/non-fast-region/fixed-div-in-scrollable-page.html:
* tiled-drawing/scrolling/non-fast-region/handlers-in-iframes-expected.txt:
* tiled-drawing/scrolling/non-fast-region/handlers-in-iframes.html:
* tiled-drawing/scrolling/non-fast-region/non-fast-scrollable-region-hide-show-iframe-expected.txt:
* tiled-drawing/scrolling/non-fast-region/non-fast-scrollable-region-hide-show-iframe.html:
* tiled-drawing/scrolling/non-fast-region/resources/wheel-handler-region-helper.js:
(nonFastScrollableRects):
(dumpNonFastScrollableRects):
(async dumpRegionAndNotifyDone):
(rectsAsString): Deleted.
(dumpRegion): Deleted.
* tiled-drawing/scrolling/non-fast-region/top-content-inset-expected.txt:
* tiled-drawing/scrolling/non-fast-region/top-content-inset-header-expected.txt:
* tiled-drawing/scrolling/non-fast-region/top-content-inset-header.html:
* tiled-drawing/scrolling/non-fast-region/top-content-inset.html:
* tiled-drawing/scrolling/non-fast-region/wheel-event-plugin.html:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-fixed-child-expected.txt:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-fixed-child.html:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-in-columns-expected.txt:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-in-columns.html:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-in-overflow-scroll-expected.txt:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-in-overflow-scroll.html:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-inside-fixed-expected.txt:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-inside-fixed.html:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-on-document-expected.txt:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-on-document.html:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-on-fixed-expected.txt:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-on-fixed.html:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-region-basic-expected.txt:
* tiled-drawing/scrolling/non-fast-region/wheel-handler-region-basic.html:

2020-10-14 Kate Cheney <katherine_cheney@apple.com>

Remove ResourceLoadStatistics telemetry
Expand Down
@@ -0,0 +1,7 @@

Test that scroll over scroller with background-attachment:fixed content works.
PASS overflowScrollEventCount > 0 is true
PASS successfullyParsed is true

TEST COMPLETE

78 changes: 78 additions & 0 deletions LayoutTests/fast/scrolling/mac/slow-scrolling-overflow.html
@@ -0,0 +1,78 @@
<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncOverflowScrollingEnabled=true ] -->
<html>
<head>
<style>
body {
height: 2000px;
}
.scroller {
position: absolute;
top: 310px;
left: 10px;
height: 300px;
width: 300px;
border: 20px solid gray;
padding: 5px;
overflow: scroll;
}
.content {
width: 200%;
height: 300%;
background-image: linear-gradient(green, orange);
background-attachment: fixed;
}
</style>
<script src="../../../resources/js-test-pre.js"></script>
<script src="../../../resources/ui-helper.js"></script>
<script>
var jsTestIsAsync = true;

var scroller;
var overflowScrollEventCount = 0;

async function resetScrollPositions()
{
window.scrollTo(0, 300);
scroller.scrollTop = 0;

// Wait for scroll events to fire.
await UIHelper.renderingUpdate();

overflowScrollEventCount = 0;
}

async function testScrollOverContent()
{
debug('');
debug('Test that scroll over scroller with background-attachment:fixed content works.');
await resetScrollPositions();
await UIHelper.mouseWheelScrollAt(100, 100);

shouldBe('overflowScrollEventCount > 0', 'true');
}

async function scrollTest()
{
await testScrollOverContent();

finishJSTest();
}

window.addEventListener('load', () => {
scroller = document.querySelector('.scroller');
scroller.addEventListener('scroll', () => {
++overflowScrollEventCount;
}, false);

setTimeout(scrollTest, 0);
}, false);
</script>
</head>
<body>
<div class="scroller">
<div class="content"></div>
</div>
<div class="overlapper"></div>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>
Expand Up @@ -18,7 +18,6 @@
(bounds 500.00 500.00)
(event region
(rect (0,0) width=500 height=500)
(rect (0,500) width=485 height=2500)
)
(children 2
(GraphicsLayer
Expand All @@ -32,8 +31,7 @@
(bounds 485.00 3000.00)
(drawsContent 1)
(event region
(rect (0,0) width=500 height=500)
(rect (0,500) width=485 height=2500)
(rect (0,0) width=485 height=3000)
(wheel event listener region
(rect (20,528) width=100 height=100)
(non-passive
Expand All @@ -51,6 +49,9 @@
(position 485.00 0.00)
(bounds 15.00 500.00)
(drawsContent 1)
(event region
(rect (0,0) width=15 height=500)
)
)
)
)
Expand Down
Expand Up @@ -15,14 +15,6 @@
(drawsContent 1)
(event region
(rect (0,0) width=204 height=204)
(rect (2,204) width=185 height=188)
(rect (22,392) width=100 height=30)
(wheel event listener region
(rect (22,22) width=100 height=400)
(non-passive
(rect (22,22) width=100 height=400)
)
)
)
(children 2
(GraphicsLayer
Expand All @@ -39,8 +31,7 @@
(bounds 185.00 420.00)
(drawsContent 1)
(event region
(rect (-2,-2) width=204 height=204)
(rect (0,202) width=185 height=218)
(rect (0,0) width=185 height=420)
(wheel event listener region
(rect (20,20) width=100 height=400)
(non-passive
Expand All @@ -59,16 +50,25 @@
(position 0.00 185.00)
(bounds 185.00 15.00)
(drawsContent 1)
(event region
(rect (0,0) width=185 height=15)
)
)
(GraphicsLayer
(position 185.00 0.00)
(bounds 15.00 185.00)
(drawsContent 1)
(event region
(rect (0,0) width=15 height=185)
)
)
(GraphicsLayer
(position 185.00 185.00)
(bounds 15.00 15.00)
(drawsContent 1)
(event region
(rect (0,0) width=15 height=15)
)
)
)
)
Expand Down
@@ -0,0 +1,19 @@
(GraphicsLayer
(anchor 0.00 0.00)
(bounds 785.00 2000.00)
(children 1
(GraphicsLayer
(bounds 785.00 2000.00)
(contentsOpaque 1)
(drawsContent 1)
(backgroundColor #C0C0C0)
(event region
(rect (0,0) width=785 height=2000)
(wheel event listener region
(rect (0,0) width=785 height=2000)
)
)
)
)
)

@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html>
<style>
html {
background-color: white;
}
body {
background-color: silver;
margin: 0;
}

.tall {
position: absolute;
top: 0;
background-color: gray;
height: 2000px;
width: 20px;
}
</style>
<script>
window.onload = () => {
window.addEventListener('wheel', () => { results.textContent += 'passive wheel\n' }, { passive: true });
if (window.testRunner)
testRunner.dumpAsText();

if (window.internals)
results.innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_EVENT_REGION | internals.LAYER_TREE_INCLUDES_ROOT_LAYER_PROPERTIES);
}
</script>
<body>
<div class="tall"></div>
<pre id="results"></pre>
</body>
</html>
9 changes: 0 additions & 9 deletions LayoutTests/platform/mac-wk2/TestExpectations
Expand Up @@ -1066,15 +1066,6 @@ webkit.org/b/214286 imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-con

webkit.org/b/213804 fast/scrolling/mac/scroll-snapping-in-progress.html [ Pass Failure ]

webkit.org/b/215586 fast/scrolling/mac/wheel-event-listener-region-basic.html [ Skip ]
webkit.org/b/215586 fast/scrolling/mac/wheel-event-listener-region-document.html [ Skip ]
webkit.org/b/215586 fast/scrolling/mac/wheel-event-listener-region-element-invalidation.html [ Skip ]
webkit.org/b/215586 fast/scrolling/mac/wheel-event-listener-region-inside-overflow-scroll-clipped-out.html [ Skip ]
webkit.org/b/215586 fast/scrolling/mac/wheel-event-listener-region-inside-overflow-scroll.html [ Skip ]
webkit.org/b/215586 fast/scrolling/mac/wheel-event-listener-region-layer-offset.html [ Skip ]
webkit.org/b/215586 fast/scrolling/mac/wheel-event-listener-region-root-invalidation.html [ Skip ]
webkit.org/b/215586 fast/scrolling/mac/wheel-event-listener-region-window.html [ Skip ]

webkit.org/b/214478 [ Debug ] http/wpt/webrtc/generateCertificate.html [ Skip ]
webkit.org/b/214478 [ Debug ] imported/w3c/web-platform-tests/webrtc/RTCCertificate-postMessage.html [ Skip ]
webkit.org/b/214478 [ Debug ] imported/w3c/web-platform-tests/webrtc/RTCCertificate.html [ Skip ]
Expand Down
@@ -1,6 +1,5 @@
<html>
<head>
<script src="resources/wheel-handler-region-helper.js"></script>
<style>
body {
margin: 0;
Expand All @@ -22,17 +21,13 @@
width: 2000px;
}
</style>
<script src="../../../resources/ui-helper.js"></script>
<script src="resources/wheel-handler-region-helper.js"></script>
<script>
function dumpRegion()
{
if (window.internals) {
var rects = window.internals.nonFastScrollableRects();
document.getElementById('output').textContent = rectsAsString(rects);
}
}
window.addEventListener('load', dumpNonFastScrollableRects, false);
</script>
</head>
<body onload="dumpRegion()">
<body>
<div class="fixed">
<div class="tall"></div>
</div>
Expand Down
@@ -1,2 +1,24 @@

32, 24 - 132, 124

(GraphicsLayer
(anchor 0.00 0.00)
(bounds 800.00 600.00)
(children 1
(GraphicsLayer
(bounds 800.00 600.00)
(contentsOpaque 1)
(drawsContent 1)
(backgroundColor #FFFFFF)
(event region
(rect (0,0) width=800 height=600)
(wheel event listener region
(rect (28,20) width=108 height=108)
(non-passive
(rect (28,20) width=108 height=108)
)
)
)
)
)
)

Expand Up @@ -8,11 +8,9 @@
margin: 10px;
}
</style>
<script src="../../../resources/ui-helper.js"></script>
<script src="resources/wheel-handler-region-helper.js"></script>
<script>
if (window.testRunner)
testRunner.waitUntilDone();

var notificationsPending = 3;

// Called from subframes.
Expand All @@ -28,11 +26,8 @@

function receivedNotification()
{
if (!--notificationsPending) {
dumpRegion();
if (window.testRunner)
testRunner.notifyDone();
}
if (!--notificationsPending)
dumpRegionAndNotifyDone();
}

window.addEventListener('load', mainFrameLoaded, false);
Expand Down
Expand Up @@ -2,4 +2,3 @@
before: 10, 10 - 310, 160
after hide:
after show: 10, 10 - 310, 160

0 comments on commit 9e66fdb

Please sign in to comment.