Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
41 changed files
with
682 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
LayoutTests/fast/scrolling/mac/slow-scrolling-overflow-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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
78
LayoutTests/fast/scrolling/mac/slow-scrolling-overflow.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
LayoutTests/fast/scrolling/mac/wheel-event-listener-region-window-scrollable-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
) | ||
) | ||
) | ||
) | ||
) | ||
|
34 changes: 34 additions & 0 deletions
34
LayoutTests/fast/scrolling/mac/wheel-event-listener-region-window-scrollable.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 23 additions & 1 deletion
24
LayoutTests/tiled-drawing/scrolling/non-fast-region/handlers-in-iframes-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
) | ||
) | ||
) | ||
) | ||
) | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,3 @@ | |
before: 10, 10 - 310, 160 | ||
after hide: | ||
after show: 10, 10 - 310, 160 | ||
|
Oops, something went wrong.