WebKit Bugzilla
Attachment 358266 Details for
Bug 193106
: UI process side scrollbars for UI side compositing on Mac
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
wip
ui-side-scrollbars-13.patch (text/plain), 55.56 KB, created by
Antti Koivisto
on 2019-01-03 11:32:02 PST
(
hide
)
Description:
wip
Filename:
MIME Type:
Creator:
Antti Koivisto
Created:
2019-01-03 11:32:02 PST
Size:
55.56 KB
patch
obsolete
>Index: Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp >=================================================================== >--- Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp (revision 239591) >+++ Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp (working copy) >@@ -136,6 +136,7 @@ void AsyncScrollingCoordinator::frameVie > auto* verticalScrollbar = frameView.verticalScrollbar(); > auto* horizontalScrollbar = frameView.horizontalScrollbar(); > node->setScrollerImpsFromScrollbars(verticalScrollbar, horizontalScrollbar); >+ node->setScrollbarLayers(verticalScrollbarLayerForFrameView(frameView), horizontalScrollbarLayerForFrameView(frameView)); > > node->setFrameScaleFactor(frameView.frame().frameScaleFactor()); > node->setHeaderHeight(frameView.headerHeight()); >Index: Source/WebCore/page/scrolling/ScrollingCoordinator.cpp >=================================================================== >--- Source/WebCore/page/scrolling/ScrollingCoordinator.cpp (revision 239591) >+++ Source/WebCore/page/scrolling/ScrollingCoordinator.cpp (working copy) >@@ -267,6 +267,20 @@ GraphicsLayer* ScrollingCoordinator::roo > return nullptr; > } > >+GraphicsLayer* ScrollingCoordinator::verticalScrollbarLayerForFrameView(FrameView& frameView) >+{ >+ if (auto* renderView = frameView.frame().contentRenderer()) >+ return renderView->compositor().layerForVerticalScrollbar(); >+ return nullptr; >+} >+ >+GraphicsLayer* ScrollingCoordinator::horizontalScrollbarLayerForFrameView(FrameView& frameView) >+{ >+ if (auto* renderView = frameView.frame().contentRenderer()) >+ return renderView->compositor().layerForHorizontalScrollbar(); >+ return nullptr; >+} >+ > void ScrollingCoordinator::frameViewRootLayerDidChange(FrameView& frameView) > { > ASSERT(isMainThread()); >Index: Source/WebCore/page/scrolling/ScrollingCoordinator.h >=================================================================== >--- Source/WebCore/page/scrolling/ScrollingCoordinator.h (revision 239591) >+++ Source/WebCore/page/scrolling/ScrollingCoordinator.h (working copy) >@@ -240,6 +240,8 @@ protected: > GraphicsLayer* contentShadowLayerForFrameView(FrameView&); > GraphicsLayer* headerLayerForFrameView(FrameView&); > GraphicsLayer* footerLayerForFrameView(FrameView&); >+ GraphicsLayer* verticalScrollbarLayerForFrameView(FrameView&); >+ GraphicsLayer* horizontalScrollbarLayerForFrameView(FrameView&); > > virtual void willCommitTree() { } > >Index: Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.cpp >=================================================================== >--- Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.cpp (revision 239591) >+++ Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.cpp (working copy) >@@ -79,6 +79,11 @@ ScrollingStateFrameScrollingNode::Scroll > > if (hasChangedProperty(FooterLayer)) > setFooterLayer(stateNode.footerLayer().toRepresentation(adoptiveTree.preferredLayerRepresentation())); >+ >+ if (hasChangedProperty(ScrollbarLayers)) { >+ setScrollbarLayers(stateNode.verticalScrollbarLayer().toRepresentation(adoptiveTree.preferredLayerRepresentation()), >+ stateNode.horizontalScrollbarLayer().toRepresentation(adoptiveTree.preferredLayerRepresentation())); >+ } > } > > ScrollingStateFrameScrollingNode::~ScrollingStateFrameScrollingNode() = default; >@@ -224,6 +229,16 @@ void ScrollingStateFrameScrollingNode::s > setPropertyChanged(FooterLayer); > } > >+void ScrollingStateFrameScrollingNode::setScrollbarLayers(const LayerRepresentation& vertical, const LayerRepresentation& horizontal) >+{ >+ if (vertical == m_verticalScrollbarLayer && horizontal == m_horizontalScrollbarLayer) >+ return; >+ >+ m_verticalScrollbarLayer = vertical; >+ m_horizontalScrollbarLayer = horizontal; >+ setPropertyChanged(ScrollbarLayers); >+} >+ > void ScrollingStateFrameScrollingNode::setFixedElementsLayoutRelativeToFrame(bool fixedElementsLayoutRelativeToFrame) > { > if (fixedElementsLayoutRelativeToFrame == m_fixedElementsLayoutRelativeToFrame) >Index: Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.h >=================================================================== >--- Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.h (revision 239591) >+++ Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.h (working copy) >@@ -57,6 +57,7 @@ public: > FooterHeight, > HeaderLayer, > FooterLayer, >+ ScrollbarLayers, > PainterForScrollbar, > BehaviorForFixedElements, > TopContentInset, >@@ -119,6 +120,10 @@ public: > const LayerRepresentation& footerLayer() const { return m_footerLayer; } > WEBCORE_EXPORT void setFooterLayer(const LayerRepresentation&); > >+ const LayerRepresentation& verticalScrollbarLayer() const { return m_verticalScrollbarLayer; } >+ const LayerRepresentation& horizontalScrollbarLayer() const { return m_horizontalScrollbarLayer; } >+ WEBCORE_EXPORT void setScrollbarLayers(const LayerRepresentation& vertical, const LayerRepresentation& horizontal); >+ > bool fixedElementsLayoutRelativeToFrame() const { return m_fixedElementsLayoutRelativeToFrame; } > WEBCORE_EXPORT void setFixedElementsLayoutRelativeToFrame(bool); > >@@ -142,6 +147,8 @@ private: > LayerRepresentation m_contentShadowLayer; > LayerRepresentation m_headerLayer; > LayerRepresentation m_footerLayer; >+ LayerRepresentation m_verticalScrollbarLayer; >+ LayerRepresentation m_horizontalScrollbarLayer; > > #if PLATFORM(MAC) > RetainPtr<NSScrollerImp> m_verticalScrollerImp; >Index: Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.h >=================================================================== >--- Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.h (revision 239591) >+++ Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.h (working copy) >@@ -80,7 +80,7 @@ protected: > ScrollBehaviorForFixedElements scrollBehaviorForFixedElements() const { return m_behaviorForFixed; } > > private: >- void dumpProperties(WTF::TextStream&, ScrollingStateTreeAsTextBehavior) const override; >+ WEBCORE_EXPORT void dumpProperties(WTF::TextStream&, ScrollingStateTreeAsTextBehavior) const override; > > FloatRect m_layoutViewport; > FloatPoint m_minLayoutViewportOrigin; >Index: Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h >=================================================================== >--- Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h (revision 239591) >+++ Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h (working copy) >@@ -63,6 +63,8 @@ public: > virtual void updateLayersAfterDelegatedScroll(const FloatPoint&) { } > > virtual FloatPoint scrollPosition() const = 0; >+ const FloatSize& scrollableAreaSize() const { return m_scrollableAreaSize; } >+ const FloatSize& totalContentsSize() const { return m_totalContentsSize; } > > #if ENABLE(CSS_SCROLL_SNAP) > const Vector<float>& horizontalSnapOffsets() const { return m_snapOffsetsInfo.horizontalSnapOffsets; } >@@ -84,8 +86,6 @@ protected: > virtual void setScrollLayerPosition(const FloatPoint&, const FloatRect& layoutViewport) = 0; > > FloatPoint lastCommittedScrollPosition() const { return m_lastCommittedScrollPosition; } >- const FloatSize& scrollableAreaSize() const { return m_scrollableAreaSize; } >- const FloatSize& totalContentsSize() const { return m_totalContentsSize; } > const FloatSize& reachableContentsSize() const { return m_reachableContentsSize; } > const LayoutRect& parentRelativeScrollableRect() const { return m_parentRelativeScrollableRect; } > const IntPoint& scrollOrigin() const { return m_scrollOrigin; } >Index: Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h >=================================================================== >--- Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h (revision 239591) >+++ Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h (working copy) >@@ -37,12 +37,12 @@ OBJC_CLASS CALayer; > > namespace WebCore { > >-class ScrollingTreeFrameScrollingNodeMac : public ScrollingTreeFrameScrollingNode, private ScrollControllerClient { >+class WEBCORE_EXPORT ScrollingTreeFrameScrollingNodeMac : public ScrollingTreeFrameScrollingNode, private ScrollControllerClient { > public: >- WEBCORE_EXPORT static Ref<ScrollingTreeFrameScrollingNode> create(ScrollingTree&, ScrollingNodeType, ScrollingNodeID); >+ static Ref<ScrollingTreeFrameScrollingNode> create(ScrollingTree&, ScrollingNodeType, ScrollingNodeID); > virtual ~ScrollingTreeFrameScrollingNodeMac(); > >-private: >+protected: > ScrollingTreeFrameScrollingNodeMac(ScrollingTree&, ScrollingNodeType, ScrollingNodeID); > > void releaseReferencesToScrollerImpsOnTheMainThread(); >@@ -96,6 +96,7 @@ private: > > unsigned exposedUnfilledArea() const; > >+private: > ScrollController m_scrollController; > > RetainPtr<CALayer> m_scrollLayer; >Index: Source/WebCore/platform/ScrollableArea.h >=================================================================== >--- Source/WebCore/platform/ScrollableArea.h (revision 239591) >+++ Source/WebCore/platform/ScrollableArea.h (working copy) >@@ -279,7 +279,7 @@ public: > > // Computes the double value for the scrollbar's current position and the current overhang amount. > // This function is static so that it can be called from the main thread or the scrolling thread. >- static void computeScrollbarValueAndOverhang(float currentPosition, float totalSize, float visibleSize, float& doubleValue, float& overhangAmount); >+ WEBCORE_EXPORT static void computeScrollbarValueAndOverhang(float currentPosition, float totalSize, float visibleSize, float& doubleValue, float& overhangAmount); > > // Let subclasses provide a way of asking for and servicing scroll > // animations. >Index: Source/WebCore/platform/mac/NSScrollerImpDetails.h >=================================================================== >--- Source/WebCore/platform/mac/NSScrollerImpDetails.h (revision 239591) >+++ Source/WebCore/platform/mac/NSScrollerImpDetails.h (working copy) >@@ -31,11 +31,11 @@ > > namespace WebCore { > >-class ScrollerStyle { >+class WEBCORE_EXPORT ScrollerStyle { > public: > static NSScrollerStyle recommendedScrollerStyle(); > >- WEBCORE_EXPORT static void setUseOverlayScrollbars(bool); >+ static void setUseOverlayScrollbars(bool); > > private: > static Optional<bool> m_useOverlayScrollbars; >Index: Source/WebCore/platform/mac/ScrollbarThemeMac.h >=================================================================== >--- Source/WebCore/platform/mac/ScrollbarThemeMac.h (revision 239591) >+++ Source/WebCore/platform/mac/ScrollbarThemeMac.h (working copy) >@@ -29,6 +29,8 @@ > > #if PLATFORM(MAC) > >+OBJC_CLASS CALayer; >+ > namespace WebCore { > > class ScrollbarThemeMac : public ScrollbarThemeComposite { >Index: Source/WebKit/Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp >=================================================================== >--- Source/WebKit/Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp (revision 239591) >+++ Source/WebKit/Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp (working copy) >@@ -164,6 +164,11 @@ void ArgumentCoder<ScrollingStateFrameSc > > if (node.hasChangedProperty(ScrollingStateFrameScrollingNode::ContentShadowLayer)) > encoder << static_cast<GraphicsLayer::PlatformLayerID>(node.contentShadowLayer()); >+ >+ if (node.hasChangedProperty(ScrollingStateFrameScrollingNode::ScrollbarLayers)) { >+ encoder << static_cast<GraphicsLayer::PlatformLayerID>(node.verticalScrollbarLayer()); >+ encoder << static_cast<GraphicsLayer::PlatformLayerID>(node.horizontalScrollbarLayer()); >+ } > } > > void ArgumentCoder<ScrollingStateOverflowScrollingNode>::encode(Encoder& encoder, const ScrollingStateOverflowScrollingNode& node) >@@ -269,6 +274,16 @@ bool ArgumentCoder<ScrollingStateFrameSc > node.setContentShadowLayer(layerID); > } > >+ if (node.hasChangedProperty(ScrollingStateFrameScrollingNode::ScrollbarLayers)) { >+ GraphicsLayer::PlatformLayerID verticalLayerID; >+ if (!decoder.decode(verticalLayerID)) >+ return false; >+ GraphicsLayer::PlatformLayerID horizontalLayerID; >+ if (!decoder.decode(horizontalLayerID)) >+ return false; >+ node.setScrollbarLayers(verticalLayerID, horizontalLayerID); >+ } >+ > return true; > } > >Index: Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeNode.h >=================================================================== >--- Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeNode.h (revision 239591) >+++ Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeNode.h (working copy) >@@ -35,6 +35,8 @@ OBJC_CLASS UIView; > > namespace WebKit { > >+class RemoteLayerTreeScrollbars; >+ > class RemoteLayerTreeNode { > WTF_MAKE_FAST_ALLOCATED; > public: >Index: Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp >=================================================================== >--- Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp (revision 239591) >+++ Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp (working copy) >@@ -125,6 +125,9 @@ void RemoteScrollingCoordinatorProxy::co > > if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::FooterLayer)) > scrollingStateNode.setFooterLayer(layerTreeHost.layerForID(scrollingStateNode.footerLayer())); >+ >+ if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::ScrollbarLayers)) >+ scrollingStateNode.setScrollbarLayers(layerTreeHost.layerForID(scrollingStateNode.verticalScrollbarLayer()), layerTreeHost.layerForID(scrollingStateNode.horizontalScrollbarLayer())); > break; > } > case ScrollingNodeType::Overflow: { >Index: Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp >=================================================================== >--- Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp (revision 239591) >+++ Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp (working copy) >@@ -37,7 +37,7 @@ > #include "ScrollingTreeOverflowScrollingNodeIOS.h" > #include <WebCore/ScrollingTreeFrameScrollingNodeIOS.h> > #else >-#include <WebCore/ScrollingTreeFrameScrollingNodeMac.h> >+#include "ScrollingTreeFrameScrollingNodeRemoteMac.h" > #endif > > namespace WebKit { >@@ -117,7 +117,7 @@ Ref<ScrollingTreeNode> RemoteScrollingTr > #if PLATFORM(IOS_FAMILY) > return ScrollingTreeFrameScrollingNodeIOS::create(*this, nodeType, nodeID); > #else >- return ScrollingTreeFrameScrollingNodeMac::create(*this, nodeType, nodeID); >+ return ScrollingTreeFrameScrollingNodeRemoteMac::create(*this, nodeType, nodeID); > #endif > case ScrollingNodeType::Overflow: > #if PLATFORM(IOS_FAMILY) >Index: Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollerMac.h >=================================================================== >--- Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollerMac.h (nonexistent) >+++ Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollerMac.h (working copy) >@@ -0,0 +1,65 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include <wtf/RetainPtr.h> >+ >+OBJC_CLASS CALayer; >+OBJC_CLASS NSScrollerImp; >+OBJC_CLASS WKScrollerImpDelegate; >+ >+namespace WebKit { >+ >+class ScrollerPairMac; >+ >+class ScrollerMac { >+public: >+ enum class Type { Vertical, Horizontal }; >+ ScrollerMac(ScrollerPairMac&, Type); >+ >+ void attach(); >+ >+ ScrollerPairMac& pair() { return m_pair; } >+ Type type() const { return m_type; } >+ >+ CALayer *hostLayer() const { return m_hostLayer.get(); } >+ void setHostLayer(CALayer *); >+ >+ NSScrollerImp *scrollerImp() { return m_scrollerImp.get(); } >+ >+ void updatePosition(); >+ >+private: >+ >+ ScrollerPairMac& m_pair; >+ const Type m_type; >+ >+ RetainPtr<CALayer> m_hostLayer; >+ RetainPtr<NSScrollerImp> m_scrollerImp; >+ RetainPtr<WKScrollerImpDelegate> m_scrollerImpDelegate; >+}; >+ >+} >Index: Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollerMac.mm >=================================================================== >--- Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollerMac.mm (nonexistent) >+++ Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollerMac.mm (working copy) >@@ -0,0 +1,459 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "ScrollerMac.h" >+ >+#include "ScrollerPairMac.h" >+#include <QuartzCore/CALayer.h> >+#include <WebCore/FloatPoint.h> >+#include <WebCore/IntRect.h> >+#include <WebCore/NSScrollerImpDetails.h> >+#include <WebCore/PlatformWheelEvent.h> >+#include <WebCore/ScrollTypes.h> >+#include <WebCore/ScrollableArea.h> >+#include <pal/spi/mac/NSScrollerImpSPI.h> >+#include <wtf/BlockObjCExceptions.h> >+ >+using WebKit::ScrollerMac; >+using WebKit::ScrollerPairMac; >+ >+enum FeatureToAnimate { >+ ThumbAlpha, >+ TrackAlpha, >+ UIStateTransition, >+ ExpansionTransition >+}; >+ >+@interface WKScrollbarPartAnimation : NSAnimation { >+ ScrollerMac* _scroller; >+ RetainPtr<NSScrollerImp> _scrollerImp; >+ FeatureToAnimate _featureToAnimate; >+ CGFloat _startValue; >+ CGFloat _endValue; >+} >+- (id)initWithScroller:(ScrollerMac*)scroller featureToAnimate:(FeatureToAnimate)featureToAnimate animateFrom:(CGFloat)startValue animateTo:(CGFloat)endValue duration:(NSTimeInterval)duration; >+@end >+ >+@implementation WKScrollbarPartAnimation >+ >+- (id)initWithScroller:(ScrollerMac*)scroller featureToAnimate:(FeatureToAnimate)featureToAnimate animateFrom:(CGFloat)startValue animateTo:(CGFloat)endValue duration:(NSTimeInterval)duration >+{ >+ self = [super initWithDuration:duration animationCurve:NSAnimationEaseInOut]; >+ if (!self) >+ return nil; >+ >+ _scroller = scroller; >+ _featureToAnimate = featureToAnimate; >+ _startValue = startValue; >+ _endValue = endValue; >+ >+ [self setAnimationBlockingMode:NSAnimationNonblocking]; >+ >+ return self; >+} >+ >+- (void)startAnimation >+{ >+ ASSERT(_scroller); >+ >+ _scrollerImp = _scroller->scrollerImp(); >+ >+ [super startAnimation]; >+} >+ >+- (void)setStartValue:(CGFloat)startValue >+{ >+ _startValue = startValue; >+} >+ >+- (void)setEndValue:(CGFloat)endValue >+{ >+ _endValue = endValue; >+} >+ >+- (void)setCurrentProgress:(NSAnimationProgress)progress >+{ >+ [super setCurrentProgress:progress]; >+ >+ ASSERT(_scroller); >+ >+ CGFloat currentValue; >+ if (_startValue > _endValue) >+ currentValue = 1 - progress; >+ else >+ currentValue = progress; >+ >+ switch (_featureToAnimate) { >+ case ThumbAlpha: >+ [_scrollerImp setKnobAlpha:currentValue]; >+ break; >+ case TrackAlpha: >+ [_scrollerImp setTrackAlpha:currentValue]; >+ break; >+ case UIStateTransition: >+ [_scrollerImp setUiStateTransitionProgress:currentValue]; >+ break; >+ case ExpansionTransition: >+ [_scrollerImp setExpansionTransitionProgress:currentValue]; >+ break; >+ } >+ >+// if (!_scroller->supportsUpdateOnSecondaryThread()) >+// _scroller->invalidate(); >+} >+ >+- (void)invalidate >+{ >+ BEGIN_BLOCK_OBJC_EXCEPTIONS; >+ [self stopAnimation]; >+ END_BLOCK_OBJC_EXCEPTIONS; >+ _scroller = nullptr; >+} >+ >+@end >+ >+@interface WKScrollerImpDelegate : NSObject<NSAnimationDelegate, NSScrollerImpDelegate> { >+ ScrollerMac* _scroller; >+ >+ RetainPtr<WKScrollbarPartAnimation> _knobAlphaAnimation; >+ RetainPtr<WKScrollbarPartAnimation> _trackAlphaAnimation; >+ RetainPtr<WKScrollbarPartAnimation> _uiStateTransitionAnimation; >+ RetainPtr<WKScrollbarPartAnimation> _expansionTransitionAnimation; >+} >+- (id)initWithScroller:(ScrollerMac*)scroller; >+- (void)cancelAnimations; >+@end >+ >+@implementation WKScrollerImpDelegate >+ >+- (id)initWithScroller:(ScrollerMac*)scroller >+{ >+ self = [super init]; >+ if (!self) >+ return nil; >+ >+ _scroller = scroller; >+ return self; >+} >+ >+- (void)cancelAnimations >+{ >+ BEGIN_BLOCK_OBJC_EXCEPTIONS; >+ [_knobAlphaAnimation stopAnimation]; >+ [_trackAlphaAnimation stopAnimation]; >+ [_uiStateTransitionAnimation stopAnimation]; >+ [_expansionTransitionAnimation stopAnimation]; >+ END_BLOCK_OBJC_EXCEPTIONS; >+} >+ >+- (ScrollerPairMac*)scrollerPair >+{ >+ return &_scroller->pair(); >+} >+ >+- (NSRect)convertRectToBacking:(NSRect)aRect >+{ >+ return aRect; >+} >+ >+- (NSRect)convertRectFromBacking:(NSRect)aRect >+{ >+ return aRect; >+} >+ >+- (CALayer *)layer >+{ >+// if (!_scroller) >+// return nil; >+// >+//// if (!ScrollbarThemeMac::isCurrentlyDrawingIntoLayer()) >+//// return nil; >+// >+// CALayer *layer; >+// if (_scroller->orientation == VerticalScrollbar) >+// layer = _scroller->scrollableArea().layerForVerticalScrollbar(); >+// else >+// layer = _scroller->scrollableArea().layerForHorizontalScrollbar(); >+// >+// static CALayer *dummyLayer = [[CALayer alloc] init]; >+// return layer ? layer->platformLayer() : dummyLayer; >+ >+ return nil; >+} >+ >+- (NSPoint)mouseLocationInScrollerForScrollerImp:(NSScrollerImp *)scrollerImp >+{ >+ if (!_scroller) >+ return NSZeroPoint; >+ >+ ASSERT_UNUSED(scrollerImp, scrollerImp == _scroller->scrollerImp()); >+ >+ return NSZeroPoint; >+// return _scroller->convertFromContainingView(_scroller->scrollableArea().lastKnownMousePosition()); >+} >+ >+- (NSRect)convertRectToLayer:(NSRect)rect >+{ >+ return rect; >+} >+ >+- (BOOL)shouldUseLayerPerPartForScrollerImp:(NSScrollerImp *)scrollerImp >+{ >+ UNUSED_PARAM(scrollerImp); >+ >+ return true; >+ >+// if (!_scroller) >+// return false; >+// >+// return _scroller->supportsUpdateOnSecondaryThread(); >+} >+ >+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 >+- (NSAppearance *)effectiveAppearanceForScrollerImp:(NSScrollerImp *)scrollerImp >+{ >+ UNUSED_PARAM(scrollerImp); >+ >+ if (!_scroller) >+ return [NSAppearance currentAppearance]; >+ >+ // If dark appearance is used or the overlay style is light (because of a dark page background), return the dark apppearance. >+ // Keep this in sync with FrameView::paintScrollCorner. >+// bool useDarkAppearance = _scroller->scrollableArea().useDarkAppearance() || _scroller->scrollableArea().scrollbarOverlayStyle() == WebCore::ScrollbarOverlayStyleLight; >+// return [NSAppearance appearanceNamed:useDarkAppearance ? NSAppearanceNameDarkAqua : NSAppearanceNameAqua]; >+ return [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]; >+} >+#endif >+ >+- (void)setUpAlphaAnimation:(RetainPtr<WKScrollbarPartAnimation>&)scrollbarPartAnimation scrollerPainter:(NSScrollerImp *)scrollerPainter part:(WebCore::ScrollbarPart)part animateAlphaTo:(CGFloat)newAlpha duration:(NSTimeInterval)duration >+{ >+ // If the user has scrolled the page, then the scrollbars must be animated here. >+ // This overrides the early returns. >+// bool mustAnimate = _scroller->scrollbars->haveScrolledSincePageLoad(); >+ >+// if (_scroller->scrollbars->scrollbarPaintTimerIsActive() && !mustAnimate) >+// return; >+// >+// if (_scroller->scrollbars->shouldSuspendScrollAnimations() && !mustAnimate) { >+// _scroller->scrollbars->startScrollbarPaintTimer(); >+// return; >+// } >+ >+ // At this point, we are definitely going to animate now, so stop the timer. >+// _scroller->scrollbars->stopScrollbarPaintTimer(); >+ >+ // If we are currently animating, Â stop >+ if (scrollbarPartAnimation) { >+ [scrollbarPartAnimation stopAnimation]; >+ scrollbarPartAnimation = nil; >+ } >+ >+// if (ScrollbarThemeMac* macTheme = macScrollbarTheme()) >+// macTheme->setPaintCharacteristicsForScrollbar(*_scroller); >+ >+// if (part == WebCore::ThumbPart && _scroller->orientation() == VerticalScrollbar) { >+// if (newAlpha == 1) { >+// IntRect thumbRect = IntRect([scrollerPainter rectForPart:NSScrollerKnob]); >+// _scroller->scrollbars.setVisibleScrollerThumbRect(thumbRect); >+// } else >+// _scroller->scrollbars.setVisibleScrollerThumbRect(IntRect()); >+// } >+ >+ _scroller->updatePosition(); >+ >+ scrollbarPartAnimation = adoptNS([[WKScrollbarPartAnimation alloc] initWithScroller:_scroller >+ featureToAnimate:part == WebCore::ThumbPart ? ThumbAlpha : TrackAlpha >+ animateFrom:part == WebCore::ThumbPart ? [scrollerPainter knobAlpha] : [scrollerPainter trackAlpha] >+ animateTo:newAlpha >+ duration:duration]); >+ [scrollbarPartAnimation startAnimation]; >+} >+ >+- (void)scrollerImp:(NSScrollerImp *)scrollerImp animateKnobAlphaTo:(CGFloat)newKnobAlpha duration:(NSTimeInterval)duration >+{ >+ if (!_scroller) >+ return; >+ >+ ASSERT(scrollerImp == _scroller->scrollerImp()); >+ >+ // If we are fading the scrollbar away, that is a good indication that we are no longer going to >+ // be moving it around on the scrolling thread. Calling [scrollerPainter setUsePresentationValue:NO] >+ // will pass that information on to the NSScrollerImp API. >+ if (!newKnobAlpha) >+ [scrollerImp setUsePresentationValue:NO]; >+ >+ [self setUpAlphaAnimation:_knobAlphaAnimation scrollerPainter:scrollerImp part:WebCore::ThumbPart animateAlphaTo:newKnobAlpha duration:duration]; >+} >+ >+- (void)scrollerImp:(NSScrollerImp *)scrollerImp animateTrackAlphaTo:(CGFloat)newTrackAlpha duration:(NSTimeInterval)duration >+{ >+ if (!_scroller) >+ return; >+ >+ ASSERT(scrollerImp == _scroller->scrollerImp()); >+ >+ NSScrollerImp *scrollerPainter = (NSScrollerImp *)scrollerImp; >+ [self setUpAlphaAnimation:_trackAlphaAnimation scrollerPainter:scrollerPainter part:WebCore::BackTrackPart animateAlphaTo:newTrackAlpha duration:duration]; >+} >+ >+- (void)scrollerImp:(NSScrollerImp *)scrollerImp animateUIStateTransitionWithDuration:(NSTimeInterval)duration >+{ >+ if (!_scroller) >+ return; >+ >+ ASSERT(scrollerImp == _scroller->scrollerImp()); >+ >+ // UIStateTransition always animates to 1. In case an animation is in progress this avoids a hard transition. >+ [scrollerImp setUiStateTransitionProgress:1 - [scrollerImp uiStateTransitionProgress]]; >+ >+ [scrollerImp setUsePresentationValue:NO]; >+ >+ if (!_uiStateTransitionAnimation) { >+ _uiStateTransitionAnimation = adoptNS([[WKScrollbarPartAnimation alloc] initWithScroller:_scroller >+ featureToAnimate:UIStateTransition >+ animateFrom:[scrollerImp uiStateTransitionProgress] >+ animateTo:1.0 >+ duration:duration]); >+ } else { >+ // If we don't need to initialize the animation, just reset the values in case they have changed. >+ [_uiStateTransitionAnimation setStartValue:[scrollerImp uiStateTransitionProgress]]; >+ [_uiStateTransitionAnimation setEndValue:1.0]; >+ [_uiStateTransitionAnimation setDuration:duration]; >+ } >+ [_uiStateTransitionAnimation startAnimation]; >+} >+ >+- (void)scrollerImp:(NSScrollerImp *)scrollerImp animateExpansionTransitionWithDuration:(NSTimeInterval)duration >+{ >+ if (!_scroller) >+ return; >+ >+ ASSERT(scrollerImp == _scroller->scrollerImp()); >+ >+ // ExpansionTransition always animates to 1. In case an animation is in progress this avoids a hard transition. >+ [scrollerImp setExpansionTransitionProgress:1 - [scrollerImp expansionTransitionProgress]]; >+ >+ if (!_expansionTransitionAnimation) { >+ _expansionTransitionAnimation = adoptNS([[WKScrollbarPartAnimation alloc] initWithScroller:_scroller >+ featureToAnimate:ExpansionTransition >+ animateFrom:[scrollerImp expansionTransitionProgress] >+ animateTo:1.0 >+ duration:duration]); >+ } else { >+ // If we don't need to initialize the animation, just reset the values in case they have changed. >+ [_expansionTransitionAnimation setStartValue:[scrollerImp uiStateTransitionProgress]]; >+ [_expansionTransitionAnimation setEndValue:1.0]; >+ [_expansionTransitionAnimation setDuration:duration]; >+ } >+ [_expansionTransitionAnimation startAnimation]; >+} >+ >+- (void)scrollerImp:(NSScrollerImp *)scrollerImp overlayScrollerStateChangedTo:(NSOverlayScrollerState)newOverlayScrollerState >+{ >+ UNUSED_PARAM(scrollerImp); >+ UNUSED_PARAM(newOverlayScrollerState); >+} >+ >+- (void)invalidate >+{ >+ _scroller = nil; >+ BEGIN_BLOCK_OBJC_EXCEPTIONS; >+ [_knobAlphaAnimation invalidate]; >+ [_trackAlphaAnimation invalidate]; >+ [_uiStateTransitionAnimation invalidate]; >+ [_expansionTransitionAnimation invalidate]; >+ END_BLOCK_OBJC_EXCEPTIONS; >+} >+ >+@end >+ >+namespace WebKit { >+ >+ScrollerMac::ScrollerMac(ScrollerPairMac& pair, Type type) >+ : m_pair(pair) >+ , m_type(type) >+{ >+} >+ >+void ScrollerMac::attach() >+{ >+ m_scrollerImpDelegate = adoptNS([[WKScrollerImpDelegate alloc] initWithScroller:this]); >+ >+ NSScrollerStyle newStyle = [m_pair.scrollerImpPair() scrollerStyle]; >+ m_scrollerImp = [NSScrollerImp scrollerImpWithStyle:newStyle controlSize:NSControlSizeSmall horizontal:m_type == Type::Horizontal replacingScrollerImp:nil]; >+ [m_scrollerImp setDelegate:m_scrollerImpDelegate.get()]; >+} >+ >+void ScrollerMac::setHostLayer(CALayer *layer) >+{ >+ if (m_hostLayer == layer) >+ return; >+ >+ m_hostLayer = layer; >+ >+ [m_scrollerImp setLayer:layer]; >+ >+ if (m_type == Type::Vertical) >+ [m_pair.scrollerImpPair() setVerticalScrollerImp:layer ? m_scrollerImp.get() : nil]; >+ else >+ [m_pair.scrollerImpPair() setHorizontalScrollerImp:layer ? m_scrollerImp.get() : nil]; >+} >+ >+void ScrollerMac::updatePosition() >+{ >+ BEGIN_BLOCK_OBJC_EXCEPTIONS; >+ >+ float position; >+ float totalSize; >+ float visibleSize; >+ if (m_type == Type::Vertical) { >+ position = m_pair.visibleContentsRect().y(); >+ totalSize = m_pair.contentsSize().height(); >+ visibleSize = m_pair.visibleContentsRect().height(); >+ } else { >+ position = m_pair.visibleContentsRect().x(); >+ totalSize = m_pair.contentsSize().width(); >+ visibleSize = m_pair.visibleContentsRect().width(); >+ } >+ >+ float value; >+ float overhang; >+ WebCore::ScrollableArea::computeScrollbarValueAndOverhang(position, totalSize, visibleSize, value, overhang); >+ >+ float proportion = totalSize ? (visibleSize - overhang) / totalSize : 1; >+ >+ [m_scrollerImp setEnabled:!!m_hostLayer]; >+ [m_scrollerImp setBoundsSize:[m_hostLayer bounds].size]; >+ [m_scrollerImp setDoubleValue:value]; >+#if ENABLE(ASYNC_SCROLLING) && PLATFORM(MAC) >+ [m_scrollerImp setPresentationValue:value]; >+#endif >+ [m_scrollerImp setKnobProportion:proportion]; >+ >+ END_BLOCK_OBJC_EXCEPTIONS; >+} >+ >+} >Index: Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollerPairMac.h >=================================================================== >--- Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollerPairMac.h (nonexistent) >+++ Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollerPairMac.h (working copy) >@@ -0,0 +1,75 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include "ScrollerMac.h" >+#include <WebCore/FloatRect.h> >+#include <WebCore/FloatSize.h> >+#include <WebCore/PlatformWheelEvent.h> >+ >+OBJC_CLASS NSScrollerImpPair; >+OBJC_CLASS WKScrollerImpPairDelegate; >+ >+namespace WebCore { >+class ScrollingTreeScrollingNode; >+} >+ >+namespace WebKit { >+ >+class ScrollerPairMac { >+public: >+ ScrollerPairMac(WebCore::ScrollingTreeScrollingNode&); >+ >+ ScrollerMac& verticalScroller() { return m_verticalScroller; } >+ ScrollerMac& horizontalScroller() { return m_horizontalScroller; } >+ >+ WebCore::FloatSize contentsSize() const; >+ WebCore::FloatRect visibleContentsRect() const; >+ >+ NSScrollerImpPair *scrollerImpPair() { return m_scrollerImpPair.get(); } >+ >+ void handleWheelEventPhase(WebCore::PlatformWheelEventPhase); >+ void updatePositions(); >+ >+private: >+ void didBeginScrollGesture(); >+ void didEndScrollGesture(); >+ void mayBeginScrollGesture(); >+ >+ WebCore::ScrollingTreeScrollingNode& m_scrollingNode; >+ >+ ScrollerMac m_verticalScroller; >+ ScrollerMac m_horizontalScroller; >+ >+ WebCore::FloatSize m_contentSize; >+ WebCore::FloatRect m_visibleContentRect; >+ >+ RetainPtr<NSScrollerImpPair> m_scrollerImpPair; >+ RetainPtr<WKScrollerImpPairDelegate> m_scrollerImpPairDelegate; >+}; >+ >+} >+ >Index: Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollerPairMac.mm >=================================================================== >--- Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollerPairMac.mm (nonexistent) >+++ Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollerPairMac.mm (working copy) >@@ -0,0 +1,200 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "ScrollerPairMac.h" >+ >+#include <WebCore/FloatPoint.h> >+#include <WebCore/IntRect.h> >+#include <WebCore/NSScrollerImpDetails.h> >+#include <WebCore/ScrollTypes.h> >+#include <WebCore/ScrollingTreeScrollingNode.h> >+#include <pal/spi/mac/NSScrollerImpSPI.h> >+ >+using WebKit::ScrollerMac; >+using WebKit::ScrollerPairMac; >+ >+@interface WKScrollerImpPairDelegate : NSObject <NSScrollerImpPairDelegate> { >+ ScrollerPairMac* _scrollerPair; >+} >+- (id)initWithScrollerPair:(ScrollerPairMac*)scrollerPair; >+@end >+ >+@implementation WKScrollerImpPairDelegate >+ >+- (id)initWithScrollerPair:(ScrollerPairMac*)scrollerPair >+{ >+ self = [super init]; >+ if (!self) >+ return nil; >+ >+ _scrollerPair = scrollerPair; >+ return self; >+} >+ >+- (void)invalidate >+{ >+ _scrollerPair = nullptr; >+} >+ >+- (NSRect)contentAreaRectForScrollerImpPair:(NSScrollerImpPair *)scrollerImpPair >+{ >+ UNUSED_PARAM(scrollerImpPair); >+ if (!_scrollerPair) >+ return NSZeroRect; >+ >+ auto contentsSize = _scrollerPair->contentsSize(); >+ return NSMakeRect(0, 0, contentsSize.width(), contentsSize.height()); >+} >+ >+- (BOOL)inLiveResizeForScrollerImpPair:(NSScrollerImpPair *)scrollerImpPair >+{ >+ UNUSED_PARAM(scrollerImpPair); >+ if (!_scrollerPair) >+ return NO; >+ >+ return NO; >+// return _scrollerPair->inLiveResize(); >+} >+ >+- (NSPoint)mouseLocationInContentAreaForScrollerImpPair:(NSScrollerImpPair *)scrollerImpPair >+{ >+ UNUSED_PARAM(scrollerImpPair); >+ if (!_scrollerPair) >+ return NSZeroPoint; >+ >+ return NSZeroPoint; // _scrollerPair->lastKnownMousePosition(); >+} >+ >+- (NSPoint)scrollerImpPair:(NSScrollerImpPair *)scrollerImpPair convertContentPoint:(NSPoint)pointInContentArea toScrollerImp:(NSScrollerImp *)scrollerImp >+{ >+ UNUSED_PARAM(scrollerImpPair); >+ >+ if (!_scrollerPair || !scrollerImp) >+ return NSZeroPoint; >+ >+ ScrollerMac* scroller = nullptr; >+ if ([scrollerImp isHorizontal]) >+ scroller = &_scrollerPair->horizontalScroller(); >+ else >+ scroller = &_scrollerPair->verticalScroller(); >+ >+// ASSERT(scrollerImp == scrollerImpForScrollbar(*scrollbar)); >+ >+ return pointInContentArea; >+// return scrollbar->convertFromContainingView(WebCore::IntPoint(pointInContentArea)); >+} >+ >+- (void)scrollerImpPair:(NSScrollerImpPair *)scrollerImpPair setContentAreaNeedsDisplayInRect:(NSRect)rect >+{ >+ UNUSED_PARAM(scrollerImpPair); >+ UNUSED_PARAM(rect); >+ >+ if (!_scrollerPair) >+ return; >+ >+// _scrollerPair->contentAreaWillPaint(); >+} >+ >+- (void)scrollerImpPair:(NSScrollerImpPair *)scrollerImpPair updateScrollerStyleForNewRecommendedScrollerStyle:(NSScrollerStyle)newRecommendedScrollerStyle >+{ >+ if (!_scrollerPair) >+ return; >+ >+ [scrollerImpPair setScrollerStyle:newRecommendedScrollerStyle]; >+ >+ WTFReportBacktrace(); >+ >+// _scrollerPair->updateScrollerStyle(); >+} >+ >+@end >+ >+namespace WebKit { >+ >+ScrollerPairMac::ScrollerPairMac(WebCore::ScrollingTreeScrollingNode& node) >+ : m_scrollingNode(node) >+ , m_verticalScroller(*this, ScrollerMac::Type::Vertical) >+ , m_horizontalScroller(*this, ScrollerMac::Type::Horizontal) >+{ >+ m_scrollerImpPairDelegate = adoptNS([[WKScrollerImpPairDelegate alloc] initWithScrollerPair:this]); >+ >+ m_scrollerImpPair = adoptNS([[NSScrollerImpPair alloc] init]); >+ [m_scrollerImpPair.get() setDelegate:m_scrollerImpPairDelegate.get()]; >+ [m_scrollerImpPair setScrollerStyle:WebCore::ScrollerStyle::recommendedScrollerStyle()]; >+ >+ m_verticalScroller.attach(); >+ m_horizontalScroller.attach(); >+} >+ >+void ScrollerPairMac::handleWheelEventPhase(WebCore::PlatformWheelEventPhase phase) >+{ >+ if (phase == WebCore::PlatformWheelEventPhaseBegan) >+ didBeginScrollGesture(); >+ else if (phase == WebCore::PlatformWheelEventPhaseEnded || phase == WebCore::PlatformWheelEventPhaseCancelled) >+ didEndScrollGesture(); >+ else if (phase == WebCore::PlatformWheelEventPhaseMayBegin) >+ mayBeginScrollGesture(); >+} >+ >+void ScrollerPairMac::didBeginScrollGesture() >+{ >+ fprintf(stderr, "didBeginScrollGesture\n"); >+ >+ [m_scrollerImpPair beginScrollGesture]; >+} >+ >+void ScrollerPairMac::didEndScrollGesture() >+{ >+ fprintf(stderr, "didEndScrollGesture\n"); >+ >+ [m_scrollerImpPair endScrollGesture]; >+} >+ >+void ScrollerPairMac::mayBeginScrollGesture() >+{ >+ fprintf(stderr, "mayBeginScrollGesture\n"); >+ >+ [m_scrollerImpPair beginScrollGesture]; >+ [m_scrollerImpPair contentAreaScrolled]; >+} >+ >+void ScrollerPairMac::updatePositions() >+{ >+ m_verticalScroller.updatePosition(); >+ m_horizontalScroller.updatePosition(); >+} >+ >+WebCore::FloatSize ScrollerPairMac::contentsSize() const >+{ >+ return m_scrollingNode.totalContentsSize(); >+} >+ >+WebCore::FloatRect ScrollerPairMac::visibleContentsRect() const >+{ >+ return { m_scrollingNode.scrollPosition(), m_scrollingNode.scrollableAreaSize() }; >+} >+ >+} >Index: Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.cpp >=================================================================== >--- Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.cpp (nonexistent) >+++ Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.cpp (working copy) >@@ -0,0 +1,79 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "ScrollingTreeFrameScrollingNodeRemoteMac.h" >+ >+#include "ScrollerMac.h" >+ >+namespace WebKit { >+ >+ScrollingTreeFrameScrollingNodeRemoteMac::ScrollingTreeFrameScrollingNodeRemoteMac(WebCore::ScrollingTree& tree, WebCore::ScrollingNodeType nodeType, WebCore::ScrollingNodeID nodeID) >+ : WebCore::ScrollingTreeFrameScrollingNodeMac(tree, nodeType, nodeID) >+ , m_scrollerPair(*this) >+{ >+} >+ >+ScrollingTreeFrameScrollingNodeRemoteMac::~ScrollingTreeFrameScrollingNodeRemoteMac() >+{ >+} >+ >+Ref<ScrollingTreeFrameScrollingNodeRemoteMac> ScrollingTreeFrameScrollingNodeRemoteMac::create(WebCore::ScrollingTree& tree, WebCore::ScrollingNodeType nodeType, WebCore::ScrollingNodeID nodeID) >+{ >+ return adoptRef(*new ScrollingTreeFrameScrollingNodeRemoteMac(tree, nodeType, nodeID)); >+} >+ >+void ScrollingTreeFrameScrollingNodeRemoteMac::commitStateBeforeChildren(const WebCore::ScrollingStateNode& stateNode) >+{ >+ WebCore::ScrollingTreeFrameScrollingNodeMac::commitStateBeforeChildren(stateNode); >+ const auto& scrollingStateNode = downcast<WebCore::ScrollingStateFrameScrollingNode>(stateNode); >+ >+ if (scrollingStateNode.hasChangedProperty(WebCore::ScrollingStateFrameScrollingNode::ScrollbarLayers)) { >+ m_scrollerPair.verticalScroller().setHostLayer(scrollingStateNode.verticalScrollbarLayer()); >+ m_scrollerPair.horizontalScroller().setHostLayer(scrollingStateNode.horizontalScrollbarLayer()); >+ fprintf(stderr, "m_verticalScrollbarLayer %d m_horizontalScrollbarLayer %d\n", !!m_scrollerPair.verticalScroller().hostLayer(), !!m_scrollerPair.horizontalScroller().hostLayer()); >+ >+// setVerticalScrollerImp(m_scrollerPair.verticalScroller().scrollerImp()); >+// setHorizontalScrollerImp(m_scrollerPair.horizontalScroller().scrollerImp()); >+ } >+ >+ m_scrollerPair.updatePositions(); >+} >+ >+void ScrollingTreeFrameScrollingNodeRemoteMac::setScrollLayerPosition(const WebCore::FloatPoint& position, const WebCore::FloatRect& layoutViewport) >+{ >+ ScrollingTreeFrameScrollingNodeMac::setScrollLayerPosition(position, layoutViewport); >+ >+ m_scrollerPair.updatePositions(); >+} >+ >+void ScrollingTreeFrameScrollingNodeRemoteMac::handleWheelEvent(const WebCore::PlatformWheelEvent& wheelEvent) >+{ >+ ScrollingTreeFrameScrollingNodeMac::handleWheelEvent(wheelEvent); >+ >+ m_scrollerPair.handleWheelEventPhase(wheelEvent.phase()); >+} >+ >+} >Index: Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.h >=================================================================== >--- Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.h (nonexistent) >+++ Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.h (working copy) >@@ -0,0 +1,52 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(ASYNC_SCROLLING) && PLATFORM(MAC) >+ >+#include "ScrollerPairMac.h" >+#include <WebCore/ScrollingTreeFrameScrollingNodeMac.h> >+ >+namespace WebKit { >+ >+class ScrollingTreeFrameScrollingNodeRemoteMac : public WebCore::ScrollingTreeFrameScrollingNodeMac { >+public: >+ WEBCORE_EXPORT static Ref<ScrollingTreeFrameScrollingNodeRemoteMac> create(WebCore::ScrollingTree&, WebCore::ScrollingNodeType, WebCore::ScrollingNodeID); >+ virtual ~ScrollingTreeFrameScrollingNodeRemoteMac(); >+ >+private: >+ ScrollingTreeFrameScrollingNodeRemoteMac(WebCore::ScrollingTree&, WebCore::ScrollingNodeType, WebCore::ScrollingNodeID); >+ >+ void commitStateBeforeChildren(const WebCore::ScrollingStateNode&) override; >+ void handleWheelEvent(const WebCore::PlatformWheelEvent&) override; >+ void setScrollLayerPosition(const WebCore::FloatPoint& position, const WebCore::FloatRect& layoutViewport) override; >+ >+ ScrollerPairMac m_scrollerPair; >+}; >+ >+} >+ >+#endif // ENABLE(ASYNC_SCROLLING) && PLATFORM(MAC) >Index: Source/WebKit/WebKit.xcodeproj/project.pbxproj >=================================================================== >--- Source/WebKit/WebKit.xcodeproj/project.pbxproj (revision 239591) >+++ Source/WebKit/WebKit.xcodeproj/project.pbxproj (working copy) >@@ -1593,6 +1593,9 @@ > E1D26A53175964D90095BFD1 /* WebContentProcess.xib in Resources */ = {isa = PBXBuildFile; fileRef = E1D26A4C1759634E0095BFD1 /* WebContentProcess.xib */; }; > E1E552C516AE065F004ED653 /* SandboxInitializationParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = E1E552C316AE065E004ED653 /* SandboxInitializationParameters.h */; }; > E1EE53E311F8CFC000CCBEE4 /* InjectedBundlePageEditorClient.h in Headers */ = {isa = PBXBuildFile; fileRef = E1EE53DC11F8CF9F00CCBEE4 /* InjectedBundlePageEditorClient.h */; }; >+ E404907621DE65FF0037F0DB /* ScrollerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = E404907421DE65F70037F0DB /* ScrollerMac.mm */; }; >+ E404907721DE66020037F0DB /* ScrollerPairMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = E404907221DE65F70037F0DB /* ScrollerPairMac.mm */; }; >+ E404907821DE66070037F0DB /* ScrollingTreeFrameScrollingNodeRemoteMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E404907121DE65F70037F0DB /* ScrollingTreeFrameScrollingNodeRemoteMac.cpp */; }; > E413F59D1AC1ADC400345360 /* NetworkCacheEntry.h in Headers */ = {isa = PBXBuildFile; fileRef = E413F59B1AC1ADB600345360 /* NetworkCacheEntry.h */; }; > E42E06101AA7523B00B11699 /* NetworkCacheIOChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = E42E060B1AA7440D00B11699 /* NetworkCacheIOChannel.h */; }; > E42E06121AA75ABD00B11699 /* NetworkCacheData.h in Headers */ = {isa = PBXBuildFile; fileRef = E42E06111AA75ABD00B11699 /* NetworkCacheData.h */; }; >@@ -4463,6 +4466,12 @@ > E1E552C316AE065E004ED653 /* SandboxInitializationParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SandboxInitializationParameters.h; sourceTree = "<group>"; }; > E1EE53DC11F8CF9F00CCBEE4 /* InjectedBundlePageEditorClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundlePageEditorClient.h; sourceTree = "<group>"; }; > E1EE53E611F8CFFB00CCBEE4 /* InjectedBundlePageEditorClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundlePageEditorClient.cpp; sourceTree = "<group>"; }; >+ E404907021DE65F70037F0DB /* ScrollerPairMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollerPairMac.h; sourceTree = "<group>"; }; >+ E404907121DE65F70037F0DB /* ScrollingTreeFrameScrollingNodeRemoteMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollingTreeFrameScrollingNodeRemoteMac.cpp; sourceTree = "<group>"; }; >+ E404907221DE65F70037F0DB /* ScrollerPairMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollerPairMac.mm; sourceTree = "<group>"; }; >+ E404907321DE65F70037F0DB /* ScrollingTreeFrameScrollingNodeRemoteMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollingTreeFrameScrollingNodeRemoteMac.h; sourceTree = "<group>"; }; >+ E404907421DE65F70037F0DB /* ScrollerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollerMac.mm; sourceTree = "<group>"; }; >+ E404907521DE65F70037F0DB /* ScrollerMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollerMac.h; sourceTree = "<group>"; }; > E413F59B1AC1ADB600345360 /* NetworkCacheEntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkCacheEntry.h; sourceTree = "<group>"; }; > E413F59E1AC1AF9D00345360 /* NetworkCacheEntry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkCacheEntry.cpp; sourceTree = "<group>"; }; > E42E060B1AA7440D00B11699 /* NetworkCacheIOChannel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkCacheIOChannel.h; sourceTree = "<group>"; }; >@@ -5517,6 +5526,7 @@ > 2D1551A91F5A9B420006E3FE /* RemoteLayerTree */ = { > isa = PBXGroup; > children = ( >+ E404906F21DE65D70037F0DB /* mac */, > 2D1551AA1F5A9BA70006E3FE /* ios */, > 1AB16AE01648656D00290D62 /* RemoteLayerTreeDrawingAreaProxy.h */, > 0FF24A2F1879E4FE003ABF0C /* RemoteLayerTreeDrawingAreaProxy.messages.in */, >@@ -8713,6 +8723,19 @@ > name = PDF; > sourceTree = "<group>"; > }; >+ E404906F21DE65D70037F0DB /* mac */ = { >+ isa = PBXGroup; >+ children = ( >+ E404907521DE65F70037F0DB /* ScrollerMac.h */, >+ E404907421DE65F70037F0DB /* ScrollerMac.mm */, >+ E404907021DE65F70037F0DB /* ScrollerPairMac.h */, >+ E404907221DE65F70037F0DB /* ScrollerPairMac.mm */, >+ E404907121DE65F70037F0DB /* ScrollingTreeFrameScrollingNodeRemoteMac.cpp */, >+ E404907321DE65F70037F0DB /* ScrollingTreeFrameScrollingNodeRemoteMac.h */, >+ ); >+ path = mac; >+ sourceTree = "<group>"; >+ }; > E489D2821A0A2BE80078C06A /* cache */ = { > isa = PBXGroup; > children = ( >@@ -10885,6 +10908,7 @@ > 2D11B7902126A283006F8878 /* UnifiedSource32.cpp in Sources */, > 2D11B7912126A283006F8878 /* UnifiedSource33-mm.mm in Sources */, > 2D11B7922126A283006F8878 /* UnifiedSource33.cpp in Sources */, >+ E404907721DE66020037F0DB /* ScrollerPairMac.mm in Sources */, > 2D11B7942126A283006F8878 /* UnifiedSource34.cpp in Sources */, > 2D11B7932126A283006F8878 /* UnifiedSource34-mm.mm in Sources */, > 2D11B7962126A283006F8878 /* UnifiedSource35.cpp in Sources */, >@@ -10934,6 +10958,7 @@ > 2D11B7C12126A283006F8878 /* UnifiedSource57-mm.mm in Sources */, > 2D11B7C22126A283006F8878 /* UnifiedSource57.cpp in Sources */, > 2D11B7C32126A283006F8878 /* UnifiedSource58-mm.mm in Sources */, >+ E404907621DE65FF0037F0DB /* ScrollerMac.mm in Sources */, > 2D11B7C42126A283006F8878 /* UnifiedSource58.cpp in Sources */, > 2D11B7C62126A283006F8878 /* UnifiedSource59.cpp in Sources */, > 2D11B7C52126A283006F8878 /* UnifiedSource59-mm.mm in Sources */, >@@ -10970,6 +10995,7 @@ > 2D11B7D82126A283006F8878 /* UnifiedSource75.cpp in Sources */, > 2D54C312212F3B330049C174 /* UnifiedSource75-mm.mm in Sources */, > 2D11B7D92126A283006F8878 /* UnifiedSource76.cpp in Sources */, >+ E404907821DE66070037F0DB /* ScrollingTreeFrameScrollingNodeRemoteMac.cpp in Sources */, > 2D54C30A212F3B330049C174 /* UnifiedSource76-mm.mm in Sources */, > 2D11B7DA2126A283006F8878 /* UnifiedSource77.cpp in Sources */, > 2D54C316212F3B330049C174 /* UnifiedSource77-mm.mm in Sources */,
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
ews-watchlist
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193106
:
358266
|
358272
|
358325
|
358339
|
358344
|
358353
|
358433
|
358437
|
358438
|
358492
|
358493