Skip to content

Commit

Permalink
Avoid running WheelEventTestMonitor-related test-only code when not t…
Browse files Browse the repository at this point in the history
…esting

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
  • Loading branch information
smfr committed May 18, 2023
1 parent b33b49a commit ab78a74
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Expand Up @@ -199,7 +199,7 @@ void RemoteScrollingTree::deferWheelEventTestCompletionForReason(ScrollingNodeID
{
ASSERT(isMainRunLoop());

if (!m_scrollingCoordinatorProxy)
if (!m_scrollingCoordinatorProxy || !isMonitoringWheelEvents())
return;

m_scrollingCoordinatorProxy->deferWheelEventTestCompletionForReason(nodeID, reason);
Expand All @@ -209,7 +209,7 @@ void RemoteScrollingTree::removeWheelEventTestCompletionDeferralForReason(Scroll
{
ASSERT(isMainRunLoop());

if (!m_scrollingCoordinatorProxy)
if (!m_scrollingCoordinatorProxy || !isMonitoringWheelEvents())
return;

m_scrollingCoordinatorProxy->removeWheelEventTestCompletionDeferralForReason(nodeID, reason);
Expand Down
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit ab78a74

Please sign in to comment.