From ab78a74247b81231d5b746c71e724db5fc8910c2 Mon Sep 17 00:00:00 2001 From: Simon Fraser Date: Thu, 18 May 2023 12:11:40 -0700 Subject: [PATCH] Avoid running WheelEventTestMonitor-related test-only code when not testing https://bugs.webkit.org/show_bug.cgi?id=256934 rdar://109488666 Reviewed by Wenson Hsieh. RemoteScrollingTreeMac::deferWheelEventTestCompletionForReason() and RemoteScrollingTreeMac::removeWheelEventTestCompletionDeferralForReason() would always trigger the hop to main thread, and IPC with the web process. We only need to do that when running layout tests that use `eventSender.monitorWheelEvents()`, and the RemoteScrollingTree already has a bit for that, so use it. * Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp: (WebKit::RemoteScrollingTree::deferWheelEventTestCompletionForReason): (WebKit::RemoteScrollingTree::removeWheelEventTestCompletionDeferralForReason): * Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteScrollingTreeMac.mm: (WebKit::RemoteScrollingTreeMac::deferWheelEventTestCompletionForReason): (WebKit::RemoteScrollingTreeMac::removeWheelEventTestCompletionDeferralForReason): Canonical link: https://commits.webkit.org/264208@main --- .../UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp | 4 ++-- .../UIProcess/RemoteLayerTree/mac/RemoteScrollingTreeMac.mm | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp b/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp index 1a35ef10578c..94c013b6317e 100644 --- a/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp +++ b/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp @@ -199,7 +199,7 @@ void RemoteScrollingTree::deferWheelEventTestCompletionForReason(ScrollingNodeID { ASSERT(isMainRunLoop()); - if (!m_scrollingCoordinatorProxy) + if (!m_scrollingCoordinatorProxy || !isMonitoringWheelEvents()) return; m_scrollingCoordinatorProxy->deferWheelEventTestCompletionForReason(nodeID, reason); @@ -209,7 +209,7 @@ void RemoteScrollingTree::removeWheelEventTestCompletionDeferralForReason(Scroll { ASSERT(isMainRunLoop()); - if (!m_scrollingCoordinatorProxy) + if (!m_scrollingCoordinatorProxy || !isMonitoringWheelEvents()) return; m_scrollingCoordinatorProxy->removeWheelEventTestCompletionDeferralForReason(nodeID, reason); diff --git a/Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteScrollingTreeMac.mm b/Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteScrollingTreeMac.mm index b375c871e83f..838c42e36fca 100644 --- a/Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteScrollingTreeMac.mm +++ b/Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteScrollingTreeMac.mm @@ -323,6 +323,9 @@ void RemoteScrollingTreeMac::deferWheelEventTestCompletionForReason(ScrollingNodeID nodeID, WheelEventTestMonitor::DeferReason reason) { + if (!isMonitoringWheelEvents()) + return; + RunLoop::main().dispatch([strongThis = Ref { *this }, nodeID, reason] { if (auto* scrollingCoordinatorProxy = strongThis->scrollingCoordinatorProxy()) scrollingCoordinatorProxy->deferWheelEventTestCompletionForReason(nodeID, reason); @@ -331,6 +334,9 @@ void RemoteScrollingTreeMac::removeWheelEventTestCompletionDeferralForReason(ScrollingNodeID nodeID, WheelEventTestMonitor::DeferReason reason) { + if (!isMonitoringWheelEvents()) + return; + RunLoop::main().dispatch([strongThis = Ref { *this }, nodeID, reason] { if (auto* scrollingCoordinatorProxy = strongThis->scrollingCoordinatorProxy()) scrollingCoordinatorProxy->removeWheelEventTestCompletionDeferralForReason(nodeID, reason);