| Summary: | Incorrect wheel event behavior with Shadow DOM | ||||||
|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Bretislav Wajtr <bretislav> | ||||
| Component: | Scrolling | Assignee: | Simon Fraser (smfr) <simon.fraser> | ||||
| Status: | RESOLVED FIXED | ||||||
| Severity: | Normal | CC: | nmouchtaris, rniwa, simon.fraser, webkit-bug-importer | ||||
| Priority: | P2 | Keywords: | InRadar | ||||
| Version: | Safari 17 | ||||||
| Hardware: | Mac (Apple Silicon) | ||||||
| OS: | macOS 14 | ||||||
| Bug Depends on: | |||||||
| Bug Blocks: | 148695 | ||||||
| Attachments: |
|
||||||
|
Description
Bretislav Wajtr
2023-11-08 23:47:30 PST
Adding a wheel event listener changes everything about how scrolling works, as every event now has to hop across processes. What you are describing looks like a bug, however I expect that there will always be performance implications from having event listeners. Does this reproduce without the Shadow DOM stuff in the test page? @Simon No, it cannot be reproduced if I use simple <div> instead of that web-component with a Shadow DOM and <slot> in it. So using the web component in the DOM structure is required to reproduce this issue. In the real use-case, where we noticed the bug, we use much more complicated structure of web components and other elements... however, I was able to narrow down the test case to what is in the attachment. This fixes it, but I'm not entirely sure if it's correct:
diff --git a/Source/WebCore/page/mac/EventHandlerMac.mm b/Source/WebCore/page/mac/EventHandlerMac.mm
index c13fcc320751735a86565b8e3e67f8d9c9984608..97e4eb43530930df997f462d942da55b4dde4404 100644
--- a/Source/WebCore/page/mac/EventHandlerMac.mm
+++ b/Source/WebCore/page/mac/EventHandlerMac.mm
@@ -800,7 +800,7 @@ static ContainerNode* findEnclosingScrollableContainer(ContainerNode* node, cons
{
// Find the first node with a valid scrollable area starting with the current
// node and traversing its parents (or shadow hosts).
- for (ContainerNode* candidate = node; candidate; candidate = candidate->parentOrShadowHostNode()) {
+ for (auto* candidate = node; candidate; candidate = candidate->parentInComposedTree()) {
if (is<HTMLIFrameElement>(*candidate))
continue;
Pull request: https://github.com/WebKit/WebKit/pull/22892 Committed 273181@main (bd33a8e97f27): <https://commits.webkit.org/273181@main> Reviewed commits have been landed. Closing PR #22892 and removing active labels. |