UI process side scrollbars for UI side compositing on Mac
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Jan 2019 20:10:55 +0000 (20:10 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Jan 2019 20:10:55 +0000 (20:10 +0000)
commit382defba88bd0fbb7785f6645748e467b3638325
treeae91173c08b8185b71b9d5e1bb5c0daf6216a27d
parent0a86c8b6adcc41c18ccf00684bfdaaef3c808572
UI process side scrollbars for UI side compositing on Mac
https://bugs.webkit.org/show_bug.cgi?id=193106

Reviewed by Tim Horton.

Source/WebCore:

* page/FrameView.cpp:
(WebCore::FrameView::paintScrollCorner):
* page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::frameViewLayoutUpdated):

Pass scrollbar host layers and the dark appearance bit to the scrolling tree.

* page/scrolling/ScrollingCoordinator.cpp:
(WebCore::ScrollingCoordinator::verticalScrollbarLayerForFrameView):
(WebCore::ScrollingCoordinator::horizontalScrollbarLayerForFrameView):
* page/scrolling/ScrollingCoordinator.h:
(WebCore::ScrollableAreaParameters::ScrollableAreaParameters):
(WebCore::ScrollableAreaParameters::operator== const):
* page/scrolling/ScrollingStateFrameScrollingNode.cpp:
(WebCore::ScrollingStateFrameScrollingNode::ScrollingStateFrameScrollingNode):
(WebCore::ScrollingStateFrameScrollingNode::setScrollbarLayers):
* page/scrolling/ScrollingStateFrameScrollingNode.h:
* page/scrolling/ScrollingTreeFrameScrollingNode.h:
* page/scrolling/ScrollingTreeScrollingNode.h:
(WebCore::ScrollingTreeScrollingNode::scrollableAreaSize const):
(WebCore::ScrollingTreeScrollingNode::totalContentsSize const):
(WebCore::ScrollingTreeScrollingNode::useDarkAppearanceForScrollbars const):
(WebCore::ScrollingTreeScrollingNode::lastCommittedScrollPosition const):
* page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h:
* platform/ScrollableArea.cpp:
(WebCore::ScrollableArea::useDarkAppearanceForScrollbars const):

Factor into a function as this is used in several places.

* platform/ScrollableArea.h:
* platform/mac/NSScrollerImpDetails.h:
* platform/mac/ScrollAnimatorMac.mm:
(-[WebScrollerImpDelegate effectiveAppearanceForScrollerImp:]):
* platform/mac/ScrollbarThemeMac.h:

Source/WebKit:

This patch implements Mac scrollbars on UI process side using the low level NSScrollerImp/NSScrollerPairImp
SPIs. With this patch scrollbars mostly work for the main frame and also render (but can't be interacted with)
for the subframes.

This is based on the similar code for web process side scrollbars in ScrollAnimatorMac. There is quite a bit of
copy code as there is no way to share nicely. One of these will eventually go away anyway.

* Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp:
(ArgumentCoder<ScrollingStateFrameScrollingNode>::encode):
(ArgumentCoder<ScrollingStateFrameScrollingNode>::decode):
* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<ScrollableAreaParameters>::encode):
(IPC::ArgumentCoder<ScrollableAreaParameters>::decode):
* UIProcess/RemoteLayerTree/RemoteLayerTreeNode.h:
* UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp:
(WebKit::RemoteScrollingCoordinatorProxy::connectStateNodeLayers):
(WebKit::RemoteScrollingCoordinatorProxy::handleMouseEvent):
* UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h:
* UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp:
(WebKit::RemoteScrollingTree::createScrollingTreeNode):
(WebKit::RemoteScrollingTree::handleMouseEvent):
* UIProcess/RemoteLayerTree/RemoteScrollingTree.h:
* UIProcess/RemoteLayerTree/mac: Added.
* UIProcess/RemoteLayerTree/mac/ScrollerMac.h: Added.

Wraps NSScrollerImp for vertical or horizontal scrollbar.

(WebKit::ScrollerMac::pair):
(WebKit::ScrollerMac::orientation const):
(WebKit::ScrollerMac::hostLayer const):
(WebKit::ScrollerMac::scrollerImp):
* UIProcess/RemoteLayerTree/mac/ScrollerMac.mm: Added.
(-[WKScrollbarPartAnimation initWithScroller:featureToAnimate:animateFrom:animateTo:duration:]):
(-[WKScrollbarPartAnimation startAnimation]):
(-[WKScrollbarPartAnimation setStartValue:]):
(-[WKScrollbarPartAnimation setEndValue:]):
(-[WKScrollbarPartAnimation setCurrentProgress:]):
(-[WKScrollbarPartAnimation invalidate]):
(-[WKScrollerImpDelegate initWithScroller:]):
(-[WKScrollerImpDelegate cancelAnimations]):
(-[WKScrollerImpDelegate scrollerPair]):
(-[WKScrollerImpDelegate convertRectToBacking:]):
(-[WKScrollerImpDelegate convertRectFromBacking:]):
(-[WKScrollerImpDelegate layer]):
(-[WKScrollerImpDelegate mouseLocationInScrollerForScrollerImp:]):
(-[WKScrollerImpDelegate convertRectToLayer:]):
(-[WKScrollerImpDelegate shouldUseLayerPerPartForScrollerImp:]):
(-[WKScrollerImpDelegate effectiveAppearanceForScrollerImp:]):
(-[WKScrollerImpDelegate setUpAlphaAnimation:scrollerPainter:part:animateAlphaTo:duration:]):
(-[WKScrollerImpDelegate scrollerImp:animateKnobAlphaTo:duration:]):
(-[WKScrollerImpDelegate scrollerImp:animateTrackAlphaTo:duration:]):
(-[WKScrollerImpDelegate scrollerImp:animateUIStateTransitionWithDuration:]):
(-[WKScrollerImpDelegate scrollerImp:animateExpansionTransitionWithDuration:]):
(-[WKScrollerImpDelegate scrollerImp:overlayScrollerStateChangedTo:]):
(-[WKScrollerImpDelegate invalidate]):
(WebKit::ScrollerMac::ScrollerMac):
(WebKit::ScrollerMac::~ScrollerMac):
(WebKit::ScrollerMac::attach):
(WebKit::ScrollerMac::setHostLayer):
(WebKit::ScrollerMac::updatePosition):
(WebKit::ScrollerMac::convertFromContent const):
* UIProcess/RemoteLayerTree/mac/ScrollerPairMac.h: Added.
(WebKit::ScrollerPairMac::verticalScroller):
(WebKit::ScrollerPairMac::horizontalScroller):
(WebKit::ScrollerPairMac::scrollerImpPair):
(WebKit::ScrollerPairMac::lastKnownMousePosition const):
* UIProcess/RemoteLayerTree/mac/ScrollerPairMac.mm: Added.

Wraps NSScrollerPairImp and owns the vertical and horizontal scrollers.

(-[WKScrollerImpPairDelegate initWithScrollerPair:]):
(-[WKScrollerImpPairDelegate invalidate]):
(-[WKScrollerImpPairDelegate contentAreaRectForScrollerImpPair:]):
(-[WKScrollerImpPairDelegate inLiveResizeForScrollerImpPair:]):
(-[WKScrollerImpPairDelegate mouseLocationInContentAreaForScrollerImpPair:]):
(-[WKScrollerImpPairDelegate scrollerImpPair:convertContentPoint:toScrollerImp:]):
(-[WKScrollerImpPairDelegate scrollerImpPair:setContentAreaNeedsDisplayInRect:]):
(-[WKScrollerImpPairDelegate scrollerImpPair:updateScrollerStyleForNewRecommendedScrollerStyle:]):
(WebKit::ScrollerPairMac::ScrollerPairMac):
(WebKit::ScrollerPairMac::~ScrollerPairMac):
(WebKit::ScrollerPairMac::handleWheelEvent):
(WebKit::ScrollerPairMac::handleMouseEvent):
(WebKit::ScrollerPairMac::updatePositions):
(WebKit::ScrollerPairMac::contentsSize const):
(WebKit::ScrollerPairMac::visibleContentsRect const):
(WebKit::ScrollerPairMac::useDarkAppearance const):
* UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.cpp: Added.

Special node for UI side Mac scrolling. Owns ScrollerPairMac instance.

(WebKit::ScrollingTreeFrameScrollingNodeRemoteMac::ScrollingTreeFrameScrollingNodeRemoteMac):
(WebKit::ScrollingTreeFrameScrollingNodeRemoteMac::~ScrollingTreeFrameScrollingNodeRemoteMac):
(WebKit::ScrollingTreeFrameScrollingNodeRemoteMac::create):
(WebKit::ScrollingTreeFrameScrollingNodeRemoteMac::commitStateBeforeChildren):
(WebKit::ScrollingTreeFrameScrollingNodeRemoteMac::setScrollLayerPosition):
(WebKit::ScrollingTreeFrameScrollingNodeRemoteMac::handleWheelEvent):
(WebKit::ScrollingTreeFrameScrollingNodeRemoteMac::handleMouseEvent):
(WebKit::ScrollingTreeFrameScrollingNodeRemoteMac::scrollingTree const):
* UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.h: Added.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::handleMouseEvent):
* WebKit.xcodeproj/project.pbxproj:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239689 268f45cc-cd09-0410-ab3c-d52691b4dbfc
35 files changed:
Source/WebCore/ChangeLog
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/FrameView.h
Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp
Source/WebCore/page/scrolling/ScrollingCoordinator.h
Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.cpp
Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.h
Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.h
Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h
Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h
Source/WebCore/platform/ScrollableArea.cpp
Source/WebCore/platform/ScrollableArea.h
Source/WebCore/platform/mac/NSScrollerImpDetails.h
Source/WebCore/platform/mac/ScrollAnimatorMac.mm
Source/WebCore/platform/mac/ScrollbarThemeMac.h
Source/WebKit/ChangeLog
Source/WebKit/Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp
Source/WebKit/Shared/WebCoreArgumentCoders.cpp
Source/WebKit/SourcesCocoa.txt
Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeNode.h
Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp
Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h
Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp
Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.h
Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollerMac.h [new file with mode: 0644]
Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollerMac.mm [new file with mode: 0644]
Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollerPairMac.h [new file with mode: 0644]
Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollerPairMac.mm [new file with mode: 0644]
Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.cpp [new file with mode: 0644]
Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.h [new file with mode: 0644]
Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalService.mm
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/mac/PageClientImplMac.mm
Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm
Source/WebKit/WebKit.xcodeproj/project.pbxproj