Skip to content

Commit

Permalink
Make basic scrolling work with ui-side compositing on macOS
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=246640
<rdar://problem/101254817>

Reviewed by Tim Horton.

We already send wheel events to the scrolling tree, but there was no layer movement
because we never changed layer positions; this is because with web process scrolling
there is coordination with the main thread in the form of scroll synchronization.

So add code to manually update layer positions with UI-side compositing. This will
be refined as we bring up a scrolling thread in the UI process.

* Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp:
(WebKit::RemoteScrollingCoordinatorProxy::handleWheelEvent):
* Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h:
(WebKit::RemoteScrollingCoordinatorProxy::scrollingTree const):
(WebKit::RemoteScrollingCoordinatorProxy::didReceiveWheelEvent):
* Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteScrollingCoordinatorProxyMac.h:
* Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteScrollingCoordinatorProxyMac.mm:
(WebKit::RemoteScrollingCoordinatorProxyMac::didReceiveWheelEvent):

Canonical link: https://commits.webkit.org/255643@main
  • Loading branch information
smfr committed Oct 17, 2022
1 parent d34e00e commit f306cd3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
Expand Up @@ -188,6 +188,7 @@ bool RemoteScrollingCoordinatorProxy::handleWheelEvent(const PlatformWheelEvent&
return false;

auto result = m_scrollingTree->handleWheelEvent(wheelEvent);
didReceiveWheelEvent(result.wasHandled);
return result.wasHandled;
}

Expand Down
Expand Up @@ -117,13 +117,18 @@ class RemoteScrollingCoordinatorProxy : public CanMakeWeakPtr<RemoteScrollingCoo
const HashSet<WebCore::GraphicsLayer::PlatformLayerID>& fixedScrollingNodeLayerIDs() const { return m_fixedScrollingNodeLayerIDs; }
#endif

protected:
RemoteScrollingTree* scrollingTree() const { return m_scrollingTree.get(); }

private:
void connectStateNodeLayers(WebCore::ScrollingStateTree&, const RemoteLayerTreeHost&);
void establishLayerTreeScrollingRelations(const RemoteLayerTreeHost&);

bool shouldSnapForMainFrameScrolling(WebCore::ScrollEventAxis) const;
std::pair<float, std::optional<unsigned>> closestSnapOffsetForMainFrameScrolling(WebCore::ScrollEventAxis, float currentScrollOffset, WebCore::FloatPoint scrollDestination, float velocity) const;

virtual void didReceiveWheelEvent(bool /* wasHandled */) { }

void sendUIStateChangedIfNecessary();
void sendScrollingTreeNodeDidScroll();
void receivedLastScrollingTreeNodeDidScrollReply();
Expand Down
Expand Up @@ -34,6 +34,9 @@ namespace WebKit {
class RemoteScrollingCoordinatorProxyMac final : public RemoteScrollingCoordinatorProxy {
public:
explicit RemoteScrollingCoordinatorProxyMac(WebPageProxy&);

private:
void didReceiveWheelEvent(bool) override;
};

} // namespace WebKit
Expand Down
Expand Up @@ -36,6 +36,11 @@
{
}

void RemoteScrollingCoordinatorProxyMac::didReceiveWheelEvent(bool /* wasHandled */)
{
scrollingTree()->applyLayerPositions();
}

} // namespace WebKit

#endif // PLATFORM(MAC) && ENABLE(UI_SIDE_COMPOSITING)

0 comments on commit f306cd3

Please sign in to comment.