Changeset 240825 in webkit


Ignore:
Timestamp:
Jan 31, 2019 3:26:38 PM (5 years ago)
Author:
Simon Fraser
Message:

Generalize ScrollingTreeScrollingNodeDelegate for use in macOS too, add a macOS subclass for frame/overflow scrolling
https://bugs.webkit.org/show_bug.cgi?id=194080

Reviewed by Antti Koivisto.

To share code between ScrollingTreeFrameScrollingNodeMac and ScrollingTreeOverflowScrollingNodeMac, build ScrollingTreeScrollingNodeDelegate
for macOS too, and add some helper functions to ScrollingTreeScrollingNodeDelegate.

Add a macOS subclass, ScrollingTreeScrollingNodeDelegateMac, which takes over the basic scrolling, rubber-banding
and scroll snapping functionality from ScrollingTreeFrameScrollingNodeMac. The delegate owns the ScrollController and
implements ScrollControllerClient.

ScrollingTreeFrameScrollingNodeMac now owns a ScrollingTreeScrollingNodeDelegateMac. A future patch
will add one to ScrollingTreeOverflowScrollingNodeMac.

No behavior change.

  • SourcesCocoa.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • page/scrolling/ScrollingTreeFrameScrollingNode.cpp:

(WebCore::ScrollingTreeFrameScrollingNode::scrollBy): Deleted.
(WebCore::ScrollingTreeFrameScrollingNode::scrollByWithoutContentEdgeConstraints): Deleted.

  • page/scrolling/ScrollingTreeFrameScrollingNode.h:

(WebCore::ScrollingTreeFrameScrollingNode::frameScaleFactor const):

  • page/scrolling/ScrollingTreeNode.cpp:

(WebCore::ScrollingTreeNode::isRootNode const):

  • page/scrolling/ScrollingTreeNode.h:
  • page/scrolling/ScrollingTreeScrollingNode.cpp:

(WebCore::ScrollingTreeScrollingNode::commitStateBeforeChildren):
(WebCore::ScrollingTreeScrollingNode::scrollBy):
(WebCore::ScrollingTreeScrollingNode::scrollByWithoutContentEdgeConstraints):

  • page/scrolling/ScrollingTreeScrollingNode.h:

(WebCore::ScrollingTreeScrollingNode::expectsWheelEventTestTrigger const):

  • page/scrolling/ScrollingTreeScrollingNodeDelegate.cpp:
  • page/scrolling/ScrollingTreeScrollingNodeDelegate.h:

(WebCore::ScrollingTreeScrollingNodeDelegate::scrollPosition const):
(WebCore::ScrollingTreeScrollingNodeDelegate::minimumScrollPosition const):
(WebCore::ScrollingTreeScrollingNodeDelegate::maximumScrollPosition const):
(WebCore::ScrollingTreeScrollingNodeDelegate::scrollableAreaSize const):
(WebCore::ScrollingTreeScrollingNodeDelegate::totalContentsSize const):
(WebCore::ScrollingTreeScrollingNodeDelegate::hasEnabledHorizontalScrollbar const):
(WebCore::ScrollingTreeScrollingNodeDelegate::hasEnabledVerticalScrollbar const):
(WebCore::ScrollingTreeScrollingNodeDelegate::horizontalScrollElasticity const):
(WebCore::ScrollingTreeScrollingNodeDelegate::verticalScrollElasticity const):

  • page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h:
  • page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:

(WebCore::ScrollingTreeFrameScrollingNodeMac::ScrollingTreeFrameScrollingNodeMac):
(WebCore::ScrollingTreeFrameScrollingNodeMac::commitStateBeforeChildren):
(WebCore::ScrollingTreeFrameScrollingNodeMac::handleWheelEvent):
(WebCore::ScrollingTreeFrameScrollingNodeMac::minimumScrollPosition const):
(WebCore::ScrollingTreeFrameScrollingNodeMac::maximumScrollPosition const):
(WebCore::newGestureIsStarting): Deleted.
(WebCore::ScrollingTreeFrameScrollingNodeMac::isAlreadyPinnedInDirectionOfGesture): Deleted.
(WebCore::ScrollingTreeFrameScrollingNodeMac::allowsHorizontalStretching): Deleted.
(WebCore::ScrollingTreeFrameScrollingNodeMac::allowsVerticalStretching): Deleted.
(WebCore::ScrollingTreeFrameScrollingNodeMac::stretchAmount): Deleted.
(WebCore::ScrollingTreeFrameScrollingNodeMac::pinnedInDirection): Deleted.
(WebCore::ScrollingTreeFrameScrollingNodeMac::canScrollHorizontally): Deleted.
(WebCore::ScrollingTreeFrameScrollingNodeMac::canScrollVertically): Deleted.
(WebCore::ScrollingTreeFrameScrollingNodeMac::shouldRubberBandInDirection): Deleted.
(WebCore::ScrollingTreeFrameScrollingNodeMac::immediateScrollBy): Deleted.
(WebCore::ScrollingTreeFrameScrollingNodeMac::immediateScrollByWithoutContentEdgeConstraints): Deleted.
(WebCore::ScrollingTreeFrameScrollingNodeMac::stopSnapRubberbandTimer): Deleted.
(WebCore::ScrollingTreeFrameScrollingNodeMac::adjustScrollPositionToBoundsIfNecessary): Deleted.
(WebCore::ScrollingTreeFrameScrollingNodeMac::scrollOffset const): Deleted.
(WebCore::ScrollingTreeFrameScrollingNodeMac::immediateScrollOnAxis): Deleted.
(WebCore::ScrollingTreeFrameScrollingNodeMac::pageScaleFactor const): Deleted.
(WebCore::ScrollingTreeFrameScrollingNodeMac::startScrollSnapTimer): Deleted.
(WebCore::ScrollingTreeFrameScrollingNodeMac::stopScrollSnapTimer): Deleted.
(WebCore::ScrollingTreeFrameScrollingNodeMac::scrollExtent const): Deleted.
(WebCore::ScrollingTreeFrameScrollingNodeMac::viewportSize const): Deleted.
(WebCore::ScrollingTreeFrameScrollingNodeMac::deferTestsForReason const): Deleted.
(WebCore::ScrollingTreeFrameScrollingNodeMac::removeTestDeferralForReason const): Deleted.

  • page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h: Copied from Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h.
  • page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm: Added.

(WebCore::ScrollingTreeScrollingNodeDelegateMac::ScrollingTreeScrollingNodeDelegateMac):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::updateScrollSnapPoints):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::setActiveScrollSnapIndexForAxis):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::activeScrollSnapIndexForAxis const):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::activeScrollSnapIndexDidChange const):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::handleWheelEvent):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::isScrollSnapInProgress const):
(WebCore::newGestureIsStarting):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::isAlreadyPinnedInDirectionOfGesture):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::allowsHorizontalStretching):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::allowsVerticalStretching):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::stretchAmount):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::pinnedInDirection):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::canScrollHorizontally):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::canScrollVertically):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::shouldRubberBandInDirection):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::immediateScrollBy):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::immediateScrollByWithoutContentEdgeConstraints):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::stopSnapRubberbandTimer):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::adjustScrollPositionToBoundsIfNecessary):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::scrollOffset const):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::immediateScrollOnAxis):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::pageScaleFactor const):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::startScrollSnapTimer):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::stopScrollSnapTimer):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::scrollExtent const):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::viewportSize const):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::deferTestsForReason const):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::removeTestDeferralForReason const):

Location:
trunk/Source/WebCore
Files:
1 added
13 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r240822 r240825  
     12019-01-31  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Generalize ScrollingTreeScrollingNodeDelegate for use in macOS too, add a macOS subclass for frame/overflow scrolling
     4        https://bugs.webkit.org/show_bug.cgi?id=194080
     5
     6        Reviewed by Antti Koivisto.
     7
     8        To share code between ScrollingTreeFrameScrollingNodeMac and ScrollingTreeOverflowScrollingNodeMac, build ScrollingTreeScrollingNodeDelegate
     9        for macOS too, and add some helper functions to ScrollingTreeScrollingNodeDelegate.
     10
     11        Add a macOS subclass, ScrollingTreeScrollingNodeDelegateMac, which takes over the basic scrolling, rubber-banding
     12        and scroll snapping functionality from ScrollingTreeFrameScrollingNodeMac. The delegate owns the ScrollController and
     13        implements ScrollControllerClient.
     14
     15        ScrollingTreeFrameScrollingNodeMac now owns a ScrollingTreeScrollingNodeDelegateMac. A future patch
     16        will add one to ScrollingTreeOverflowScrollingNodeMac.
     17
     18        No behavior change.
     19
     20        * SourcesCocoa.txt:
     21        * WebCore.xcodeproj/project.pbxproj:
     22        * page/scrolling/ScrollingTreeFrameScrollingNode.cpp:
     23        (WebCore::ScrollingTreeFrameScrollingNode::scrollBy): Deleted.
     24        (WebCore::ScrollingTreeFrameScrollingNode::scrollByWithoutContentEdgeConstraints): Deleted.
     25        * page/scrolling/ScrollingTreeFrameScrollingNode.h:
     26        (WebCore::ScrollingTreeFrameScrollingNode::frameScaleFactor const):
     27        * page/scrolling/ScrollingTreeNode.cpp:
     28        (WebCore::ScrollingTreeNode::isRootNode const):
     29        * page/scrolling/ScrollingTreeNode.h:
     30        * page/scrolling/ScrollingTreeScrollingNode.cpp:
     31        (WebCore::ScrollingTreeScrollingNode::commitStateBeforeChildren):
     32        (WebCore::ScrollingTreeScrollingNode::scrollBy):
     33        (WebCore::ScrollingTreeScrollingNode::scrollByWithoutContentEdgeConstraints):
     34        * page/scrolling/ScrollingTreeScrollingNode.h:
     35        (WebCore::ScrollingTreeScrollingNode::expectsWheelEventTestTrigger const):
     36        * page/scrolling/ScrollingTreeScrollingNodeDelegate.cpp:
     37        * page/scrolling/ScrollingTreeScrollingNodeDelegate.h:
     38        (WebCore::ScrollingTreeScrollingNodeDelegate::scrollPosition const):
     39        (WebCore::ScrollingTreeScrollingNodeDelegate::minimumScrollPosition const):
     40        (WebCore::ScrollingTreeScrollingNodeDelegate::maximumScrollPosition const):
     41        (WebCore::ScrollingTreeScrollingNodeDelegate::scrollableAreaSize const):
     42        (WebCore::ScrollingTreeScrollingNodeDelegate::totalContentsSize const):
     43        (WebCore::ScrollingTreeScrollingNodeDelegate::hasEnabledHorizontalScrollbar const):
     44        (WebCore::ScrollingTreeScrollingNodeDelegate::hasEnabledVerticalScrollbar const):
     45        (WebCore::ScrollingTreeScrollingNodeDelegate::horizontalScrollElasticity const):
     46        (WebCore::ScrollingTreeScrollingNodeDelegate::verticalScrollElasticity const):
     47        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h:
     48        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
     49        (WebCore::ScrollingTreeFrameScrollingNodeMac::ScrollingTreeFrameScrollingNodeMac):
     50        (WebCore::ScrollingTreeFrameScrollingNodeMac::commitStateBeforeChildren):
     51        (WebCore::ScrollingTreeFrameScrollingNodeMac::handleWheelEvent):
     52        (WebCore::ScrollingTreeFrameScrollingNodeMac::minimumScrollPosition const):
     53        (WebCore::ScrollingTreeFrameScrollingNodeMac::maximumScrollPosition const):
     54        (WebCore::newGestureIsStarting): Deleted.
     55        (WebCore::ScrollingTreeFrameScrollingNodeMac::isAlreadyPinnedInDirectionOfGesture): Deleted.
     56        (WebCore::ScrollingTreeFrameScrollingNodeMac::allowsHorizontalStretching): Deleted.
     57        (WebCore::ScrollingTreeFrameScrollingNodeMac::allowsVerticalStretching): Deleted.
     58        (WebCore::ScrollingTreeFrameScrollingNodeMac::stretchAmount): Deleted.
     59        (WebCore::ScrollingTreeFrameScrollingNodeMac::pinnedInDirection): Deleted.
     60        (WebCore::ScrollingTreeFrameScrollingNodeMac::canScrollHorizontally): Deleted.
     61        (WebCore::ScrollingTreeFrameScrollingNodeMac::canScrollVertically): Deleted.
     62        (WebCore::ScrollingTreeFrameScrollingNodeMac::shouldRubberBandInDirection): Deleted.
     63        (WebCore::ScrollingTreeFrameScrollingNodeMac::immediateScrollBy): Deleted.
     64        (WebCore::ScrollingTreeFrameScrollingNodeMac::immediateScrollByWithoutContentEdgeConstraints): Deleted.
     65        (WebCore::ScrollingTreeFrameScrollingNodeMac::stopSnapRubberbandTimer): Deleted.
     66        (WebCore::ScrollingTreeFrameScrollingNodeMac::adjustScrollPositionToBoundsIfNecessary): Deleted.
     67        (WebCore::ScrollingTreeFrameScrollingNodeMac::scrollOffset const): Deleted.
     68        (WebCore::ScrollingTreeFrameScrollingNodeMac::immediateScrollOnAxis): Deleted.
     69        (WebCore::ScrollingTreeFrameScrollingNodeMac::pageScaleFactor const): Deleted.
     70        (WebCore::ScrollingTreeFrameScrollingNodeMac::startScrollSnapTimer): Deleted.
     71        (WebCore::ScrollingTreeFrameScrollingNodeMac::stopScrollSnapTimer): Deleted.
     72        (WebCore::ScrollingTreeFrameScrollingNodeMac::scrollExtent const): Deleted.
     73        (WebCore::ScrollingTreeFrameScrollingNodeMac::viewportSize const): Deleted.
     74        (WebCore::ScrollingTreeFrameScrollingNodeMac::deferTestsForReason const): Deleted.
     75        (WebCore::ScrollingTreeFrameScrollingNodeMac::removeTestDeferralForReason const): Deleted.
     76        * page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h: Copied from Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h.
     77        * page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm: Added.
     78        (WebCore::ScrollingTreeScrollingNodeDelegateMac::ScrollingTreeScrollingNodeDelegateMac):
     79        (WebCore::ScrollingTreeScrollingNodeDelegateMac::updateScrollSnapPoints):
     80        (WebCore::ScrollingTreeScrollingNodeDelegateMac::setActiveScrollSnapIndexForAxis):
     81        (WebCore::ScrollingTreeScrollingNodeDelegateMac::activeScrollSnapIndexForAxis const):
     82        (WebCore::ScrollingTreeScrollingNodeDelegateMac::activeScrollSnapIndexDidChange const):
     83        (WebCore::ScrollingTreeScrollingNodeDelegateMac::handleWheelEvent):
     84        (WebCore::ScrollingTreeScrollingNodeDelegateMac::isScrollSnapInProgress const):
     85        (WebCore::newGestureIsStarting):
     86        (WebCore::ScrollingTreeScrollingNodeDelegateMac::isAlreadyPinnedInDirectionOfGesture):
     87        (WebCore::ScrollingTreeScrollingNodeDelegateMac::allowsHorizontalStretching):
     88        (WebCore::ScrollingTreeScrollingNodeDelegateMac::allowsVerticalStretching):
     89        (WebCore::ScrollingTreeScrollingNodeDelegateMac::stretchAmount):
     90        (WebCore::ScrollingTreeScrollingNodeDelegateMac::pinnedInDirection):
     91        (WebCore::ScrollingTreeScrollingNodeDelegateMac::canScrollHorizontally):
     92        (WebCore::ScrollingTreeScrollingNodeDelegateMac::canScrollVertically):
     93        (WebCore::ScrollingTreeScrollingNodeDelegateMac::shouldRubberBandInDirection):
     94        (WebCore::ScrollingTreeScrollingNodeDelegateMac::immediateScrollBy):
     95        (WebCore::ScrollingTreeScrollingNodeDelegateMac::immediateScrollByWithoutContentEdgeConstraints):
     96        (WebCore::ScrollingTreeScrollingNodeDelegateMac::stopSnapRubberbandTimer):
     97        (WebCore::ScrollingTreeScrollingNodeDelegateMac::adjustScrollPositionToBoundsIfNecessary):
     98        (WebCore::ScrollingTreeScrollingNodeDelegateMac::scrollOffset const):
     99        (WebCore::ScrollingTreeScrollingNodeDelegateMac::immediateScrollOnAxis):
     100        (WebCore::ScrollingTreeScrollingNodeDelegateMac::pageScaleFactor const):
     101        (WebCore::ScrollingTreeScrollingNodeDelegateMac::startScrollSnapTimer):
     102        (WebCore::ScrollingTreeScrollingNodeDelegateMac::stopScrollSnapTimer):
     103        (WebCore::ScrollingTreeScrollingNodeDelegateMac::scrollExtent const):
     104        (WebCore::ScrollingTreeScrollingNodeDelegateMac::viewportSize const):
     105        (WebCore::ScrollingTreeScrollingNodeDelegateMac::deferTestsForReason const):
     106        (WebCore::ScrollingTreeScrollingNodeDelegateMac::removeTestDeferralForReason const):
     107
    11082019-01-31  Jer Noble  <jer.noble@apple.com>
    2109
  • trunk/Source/WebCore/SourcesCocoa.txt

    r240437 r240825  
    159159page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm
    160160page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm
     161page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm
    161162page/scrolling/mac/ScrollingTreeMac.cpp
    162163page/scrolling/mac/ScrollingTreeStickyNode.mm
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r240807 r240825  
    319319                0F15ED5C1B7EC7C500EDDFEB /* WillChangeData.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F15ED5A1B7EC7C500EDDFEB /* WillChangeData.h */; settings = {ATTRIBUTES = (Private, ); }; };
    320320                0F1774801378B772009DA76A /* ScrollAnimatorIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F17747E1378B771009DA76A /* ScrollAnimatorIOS.h */; };
     321                0F37F0852202BF9800A89C0B /* ScrollingTreeScrollingNodeDelegateMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F37F0842202ACB700A89C0B /* ScrollingTreeScrollingNodeDelegateMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
    321322                0F3DD45012F5EA1B000D9190 /* ShadowBlur.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F3DD44E12F5EA1B000D9190 /* ShadowBlur.h */; };
    322323                0F3F0E5A157030C3006DA57F /* RenderGeometryMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F3F0E58157030C3006DA57F /* RenderGeometryMap.h */; };
     
    57055706                0F36E7361BD1837A002DB891 /* LayoutPoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutPoint.cpp; sourceTree = "<group>"; };
    57065707                0F36E7381BD184B9002DB891 /* LayoutSize.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutSize.cpp; sourceTree = "<group>"; };
     5708                0F37F0832202AC8F00A89C0B /* ScrollingTreeScrollingNodeDelegateMac.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollingTreeScrollingNodeDelegateMac.mm; sourceTree = "<group>"; };
     5709                0F37F0842202ACB700A89C0B /* ScrollingTreeScrollingNodeDelegateMac.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScrollingTreeScrollingNodeDelegateMac.h; sourceTree = "<group>"; };
    57075710                0F3DD44D12F5EA1B000D9190 /* ShadowBlur.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShadowBlur.cpp; sourceTree = "<group>"; };
    57085711                0F3DD44E12F5EA1B000D9190 /* ShadowBlur.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShadowBlur.h; sourceTree = "<group>"; };
     
    1698016983                                0FC0516A219B5EBE0031C39E /* ScrollingTreeOverflowScrollingNodeMac.h */,
    1698116984                                0FC05168219B5EBE0031C39E /* ScrollingTreeOverflowScrollingNodeMac.mm */,
     16985                                0F37F0842202ACB700A89C0B /* ScrollingTreeScrollingNodeDelegateMac.h */,
     16986                                0F37F0832202AC8F00A89C0B /* ScrollingTreeScrollingNodeDelegateMac.mm */,
    1698216987                                0FB88908167D2FA10010CDA5 /* ScrollingTreeStickyNode.h */,
    1698316988                                0FB88909167D2FA10010CDA5 /* ScrollingTreeStickyNode.mm */,
     
    3146231467                                9391A99D1629D70000297330 /* ScrollingTreeScrollingNode.h in Headers */,
    3146331468                                A6D5A99D1629D70000297330 /* ScrollingTreeScrollingNodeDelegate.h in Headers */,
     31469                                0F37F0852202BF9800A89C0B /* ScrollingTreeScrollingNodeDelegateMac.h in Headers */,
    3146431470                                0FB8890A167D2FA10010CDA5 /* ScrollingTreeStickyNode.h in Headers */,
    3146531471                                83C5795D1DA5C301006F9C97 /* ScrollIntoViewOptions.h in Headers */,
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp

    r240787 r240825  
    8383}
    8484
    85 void ScrollingTreeFrameScrollingNode::scrollBy(const FloatSize& delta)
    86 {
    87     setScrollPosition(scrollPosition() + delta);
    88 }
    89 
    90 void ScrollingTreeFrameScrollingNode::scrollByWithoutContentEdgeConstraints(const FloatSize& offset)
    91 {
    92     setScrollPositionWithoutContentEdgeConstraints(scrollPosition() + offset);
    93 }
    94 
    9585void ScrollingTreeFrameScrollingNode::setScrollPosition(const FloatPoint& scrollPosition)
    9686{
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.h

    r240787 r240825  
    6161    FloatRect fixedPositionRect() { return FloatRect(lastCommittedScrollPosition(), scrollableAreaSize()); };
    6262
     63    float frameScaleFactor() const { return m_frameScaleFactor; }
     64
    6365protected:
    6466    ScrollingTreeFrameScrollingNode(ScrollingTree&, ScrollingNodeType, ScrollingNodeID);
    6567
    66     void scrollBy(const FloatSize&);
    67     void scrollByWithoutContentEdgeConstraints(const FloatSize&);
    68 
    69     float frameScaleFactor() const { return m_frameScaleFactor; }
    7068    int headerHeight() const { return m_headerHeight; }
    7169    int footerHeight() const { return m_footerHeight; }
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.cpp

    r240787 r240825  
    3030
    3131#include "ScrollingStateTree.h"
     32#include "ScrollingTree.h"
    3233#include "ScrollingTreeFrameScrollingNode.h"
    3334#include <wtf/text/TextStream.h>
     
    7071    for (auto& child : *m_children)
    7172        child->removeChild(node);
     73}
     74
     75bool ScrollingTreeNode::isRootNode() const
     76{
     77    return m_scrollingTree.rootNode() == this;
    7278}
    7379
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.h

    r240787 r240825  
    3939
    4040class ScrollingStateFixedNode;
    41 class ScrollingStateScrollingNode;
    4241class ScrollingTreeFrameScrollingNode;
    4342class ScrollingTreeScrollingNode;
     
    6463    ScrollingTreeNode* parent() const { return m_parent; }
    6564    void setParent(ScrollingTreeNode* parent) { m_parent = parent; }
     65   
     66    bool isRootNode() const;
    6667
    6768    Vector<RefPtr<ScrollingTreeNode>>* children() { return m_children.get(); }
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp

    r240787 r240825  
    9494    if (state.hasChangedProperty(ScrollingStateScrollingNode::ScrollableAreaParams))
    9595        m_scrollableAreaParameters = state.scrollableAreaParameters();
     96
     97    if (state.hasChangedProperty(ScrollingStateScrollingNode::ExpectsWheelEventTestTrigger))
     98        m_expectsWheelEventTestTrigger = state.expectsWheelEventTestTrigger();
    9699}
    97100
     
    141144    newScrollPosition = newScrollPosition.constrainedBetween(minimumScrollPosition(), maximumScrollPosition());
    142145    return newScrollPosition == oldScrollPosition;
     146}
     147
     148void ScrollingTreeScrollingNode::scrollBy(const FloatSize& delta)
     149{
     150    setScrollPosition(scrollPosition() + delta);
     151}
     152
     153void ScrollingTreeScrollingNode::scrollByWithoutContentEdgeConstraints(const FloatSize& offset)
     154{
     155    setScrollPositionWithoutContentEdgeConstraints(scrollPosition() + offset);
    143156}
    144157
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h

    r240787 r240825  
    3434#include "ScrollingTreeNode.h"
    3535
    36 #if PLATFORM(IOS_FAMILY)
    37 class ScrollingTreeScrollingNodeDelegate;
    38 #endif
    39 
    4036namespace WebCore {
    4137
     
    4440
    4541class ScrollingTreeScrollingNode : public ScrollingTreeNode {
    46 #if PLATFORM(IOS_FAMILY)
    4742    friend class ScrollingTreeScrollingNodeDelegate;
     43#if PLATFORM(MAC)
     44    friend class ScrollingTreeScrollingNodeDelegateMac;
    4845#endif
    4946
     
    5956    WEBCORE_EXPORT virtual void setScrollPosition(const FloatPoint&);
    6057    WEBCORE_EXPORT virtual void setScrollPositionWithoutContentEdgeConstraints(const FloatPoint&);
     58
     59    void scrollBy(const FloatSize&);
     60    void scrollByWithoutContentEdgeConstraints(const FloatSize&);
    6161
    6262    virtual void updateLayersAfterViewportChange(const FloatRect& fixedPositionRect, double scale) = 0;
     
    110110    bool canHaveScrollbars() const { return m_scrollableAreaParameters.horizontalScrollbarMode != ScrollbarAlwaysOff || m_scrollableAreaParameters.verticalScrollbarMode != ScrollbarAlwaysOff; }
    111111
     112    bool expectsWheelEventTestTrigger() const { return m_expectsWheelEventTestTrigger; }
     113
    112114    WEBCORE_EXPORT LayoutPoint parentToLocalPoint(LayoutPoint) const override;
    113115    WEBCORE_EXPORT LayoutPoint localToContentsPoint(LayoutPoint) const override;
     
    129131#endif
    130132    ScrollableAreaParameters m_scrollableAreaParameters;
     133    bool m_expectsWheelEventTestTrigger { false };
    131134};
    132135
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNodeDelegate.cpp

    r237266 r240825  
    2727#import "ScrollingTreeScrollingNodeDelegate.h"
    2828
    29 #if PLATFORM(IOS_FAMILY) && ENABLE(ASYNC_SCROLLING)
     29#if ENABLE(ASYNC_SCROLLING)
    3030
    3131#import "ScrollingTreeScrollingNode.h"
     
    6767} // namespace WebCore
    6868
    69 #endif // PLATFORM(IOS_FAMILY) && ENABLE(ASYNC_SCROLLING)
     69#endif // ENABLE(ASYNC_SCROLLING)
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNodeDelegate.h

    r237266 r240825  
    2626#pragma once
    2727
    28 #if PLATFORM(IOS_FAMILY) && ENABLE(ASYNC_SCROLLING)
     28#if ENABLE(ASYNC_SCROLLING)
     29
     30#include "ScrollingTreeScrollingNode.h"
    2931
    3032namespace WebCore {
    31 
    32 class FloatPoint;
    33 class FloatSize;
    34 class IntPoint;
    35 class ScrollingTreeScrollingNode;
    36 class ScrollingTree;
    3733
    3834class ScrollingTreeScrollingNodeDelegate {
     
    4036    WEBCORE_EXPORT explicit ScrollingTreeScrollingNodeDelegate(ScrollingTreeScrollingNode&);
    4137    WEBCORE_EXPORT virtual ~ScrollingTreeScrollingNodeDelegate();
     38
    4239    ScrollingTreeScrollingNode& scrollingNode() { return m_scrollingNode; }
    4340    const ScrollingTreeScrollingNode& scrollingNode() const { return m_scrollingNode; }
     
    5047    WEBCORE_EXPORT const IntPoint& scrollOrigin() const;
    5148
     49    FloatPoint scrollPosition() const { return m_scrollingNode.scrollPosition(); }
     50    FloatPoint minimumScrollPosition() const { return m_scrollingNode.minimumScrollPosition(); }
     51    FloatPoint maximumScrollPosition() const { return m_scrollingNode.maximumScrollPosition(); }
     52
     53    FloatSize scrollableAreaSize() const { return m_scrollingNode.scrollableAreaSize(); }
     54    FloatSize totalContentsSize() const { return m_scrollingNode.totalContentsSize(); }
     55
     56    bool hasEnabledHorizontalScrollbar() const { return m_scrollingNode.hasEnabledHorizontalScrollbar(); }
     57    bool hasEnabledVerticalScrollbar() const { return m_scrollingNode.hasEnabledVerticalScrollbar(); }
     58
     59    ScrollElasticity horizontalScrollElasticity() const { return m_scrollingNode.horizontalScrollElasticity(); }
     60    ScrollElasticity verticalScrollElasticity() const { return m_scrollingNode.verticalScrollElasticity(); }
     61
    5262private:
    5363    ScrollingTreeScrollingNode& m_scrollingNode;
     
    5666} // namespace WebCore
    5767
    58 #endif // PLATFORM(IOS_FAMILY) && ENABLE(ASYNC_SCROLLING)
     68#endif // ENABLE(ASYNC_SCROLLING)
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h

    r240800 r240825  
    2828#if ENABLE(ASYNC_SCROLLING) && PLATFORM(MAC)
    2929
    30 #include "ScrollController.h"
    3130#include "ScrollbarThemeMac.h"
    3231#include "ScrollingStateFrameScrollingNode.h"
    3332#include "ScrollingTreeFrameScrollingNode.h"
     33#include "ScrollingTreeScrollingNodeDelegateMac.h"
    3434#include <wtf/RetainPtr.h>
    3535
     
    3838namespace WebCore {
    3939
    40 class WEBCORE_EXPORT ScrollingTreeFrameScrollingNodeMac : public ScrollingTreeFrameScrollingNode, private ScrollControllerClient {
     40class WEBCORE_EXPORT ScrollingTreeFrameScrollingNodeMac : public ScrollingTreeFrameScrollingNode {
    4141public:
    4242    static Ref<ScrollingTreeFrameScrollingNode> create(ScrollingTree&, ScrollingNodeType, ScrollingNodeID);
     
    5454    ScrollingEventResult handleWheelEvent(const PlatformWheelEvent&) override;
    5555
    56     // ScrollController member functions.
    57     bool allowsHorizontalStretching(const PlatformWheelEvent&) override;
    58     bool allowsVerticalStretching(const PlatformWheelEvent&) override;
    59     IntSize stretchAmount() override;
    60     bool pinnedInDirection(const FloatSize&) override;
    61     bool canScrollHorizontally() override;
    62     bool canScrollVertically() override;
    63     bool shouldRubberBandInDirection(ScrollDirection) override;
    64     void immediateScrollBy(const FloatSize&) override;
    65     void immediateScrollByWithoutContentEdgeConstraints(const FloatSize&) override;
    66     void stopSnapRubberbandTimer() override;
    67     void adjustScrollPositionToBoundsIfNecessary() override;
    68 
    6956    FloatPoint scrollPosition() const override;
    7057    void setScrollPosition(const FloatPoint&) override;
     
    8067    void updateMainFramePinState(const FloatPoint& scrollPosition);
    8168
    82     bool isAlreadyPinnedInDirectionOfGesture(const PlatformWheelEvent&, ScrollEventAxis);
    83 
    84     void deferTestsForReason(WheelEventTestTrigger::ScrollableAreaIdentifier, WheelEventTestTrigger::DeferTestTriggerReason) const override;
    85     void removeTestDeferralForReason(WheelEventTestTrigger::ScrollableAreaIdentifier, WheelEventTestTrigger::DeferTestTriggerReason) const override;
    86 
    87 #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
    88     FloatPoint scrollOffset() const override;
    89     void immediateScrollOnAxis(ScrollEventAxis, float delta) override;
    90     float pageScaleFactor() const override;
    91     void startScrollSnapTimer() override;
    92     void stopScrollSnapTimer() override;
    93     LayoutSize scrollExtent() const override;
    94     FloatSize viewportSize() const override;
    95 #endif
    96 
    9769    unsigned exposedUnfilledArea() const;
    9870
    9971private:
    100     ScrollController m_scrollController;
    101 
    10272    RetainPtr<CALayer> m_scrollLayer;
    10373    RetainPtr<CALayer> m_rootContentsLayer;
     
    11080    RetainPtr<NSScrollerImp> m_horizontalScrollerImp;
    11181    FloatPoint m_probableMainThreadScrollPosition;
     82   
     83    ScrollingTreeScrollingNodeDelegateMac m_delegate;
     84   
    11285    bool m_lastScrollHadUnfilledPixels { false };
    11386    bool m_hadFirstUpdate { false };
    114     bool m_expectsWheelEventTestTrigger { false };
    11587};
    11688
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm

    r240800 r240825  
    5555ScrollingTreeFrameScrollingNodeMac::ScrollingTreeFrameScrollingNodeMac(ScrollingTree& scrollingTree, ScrollingNodeType nodeType, ScrollingNodeID nodeID)
    5656    : ScrollingTreeFrameScrollingNode(scrollingTree, nodeType, nodeID)
    57     , m_scrollController(*this)
    58     , m_verticalScrollerImp(nullptr)
    59     , m_horizontalScrollerImp(nullptr)
     57    , m_delegate(*this)
    6058{
    6159}
     
    151149#if ENABLE(CSS_SCROLL_SNAP)
    152150    if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::HorizontalSnapOffsets) || scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::HorizontalSnapOffsetRanges))
    153         m_scrollController.updateScrollSnapPoints(ScrollEventAxis::Horizontal, convertToLayoutUnits(scrollingStateNode.horizontalSnapOffsets()), convertToLayoutUnits(scrollingStateNode.horizontalSnapOffsetRanges()));
     151        m_delegate.updateScrollSnapPoints(ScrollEventAxis::Horizontal, convertToLayoutUnits(scrollingStateNode.horizontalSnapOffsets()), convertToLayoutUnits(scrollingStateNode.horizontalSnapOffsetRanges()));
    154152
    155153    if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::VerticalSnapOffsets) || scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::VerticalSnapOffsetRanges))
    156         m_scrollController.updateScrollSnapPoints(ScrollEventAxis::Vertical, convertToLayoutUnits(scrollingStateNode.verticalSnapOffsets()), convertToLayoutUnits(scrollingStateNode.verticalSnapOffsetRanges()));
     154        m_delegate.updateScrollSnapPoints(ScrollEventAxis::Vertical, convertToLayoutUnits(scrollingStateNode.verticalSnapOffsets()), convertToLayoutUnits(scrollingStateNode.verticalSnapOffsetRanges()));
    157155
    158156    if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::CurrentHorizontalSnapOffsetIndex))
    159         m_scrollController.setActiveScrollSnapIndexForAxis(ScrollEventAxis::Horizontal, scrollingStateNode.currentHorizontalSnapPointIndex());
     157        m_delegate.setActiveScrollSnapIndexForAxis(ScrollEventAxis::Horizontal, scrollingStateNode.currentHorizontalSnapPointIndex());
    160158   
    161159    if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::CurrentVerticalSnapOffsetIndex))
    162         m_scrollController.setActiveScrollSnapIndexForAxis(ScrollEventAxis::Vertical, scrollingStateNode.currentVerticalSnapPointIndex());
     160        m_delegate.setActiveScrollSnapIndexForAxis(ScrollEventAxis::Vertical, scrollingStateNode.currentVerticalSnapPointIndex());
    163161#endif
    164 
    165     if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ExpectsWheelEventTestTrigger))
    166         m_expectsWheelEventTestTrigger = scrollingStateNode.expectsWheelEventTestTrigger();
    167162
    168163    m_hadFirstUpdate = true;
     
    200195
    201196#if ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING)
    202     if (m_expectsWheelEventTestTrigger) {
     197    if (expectsWheelEventTestTrigger()) {
    203198        if (scrollingTree().shouldHandleWheelEventSynchronously(wheelEvent))
    204             removeTestDeferralForReason(reinterpret_cast<WheelEventTestTrigger::ScrollableAreaIdentifier>(scrollingNodeID()), WheelEventTestTrigger::ScrollingThreadSyncNeeded);
     199            m_delegate.removeTestDeferralForReason(reinterpret_cast<WheelEventTestTrigger::ScrollableAreaIdentifier>(scrollingNodeID()), WheelEventTestTrigger::ScrollingThreadSyncNeeded);
    205200        else
    206             deferTestsForReason(reinterpret_cast<WheelEventTestTrigger::ScrollableAreaIdentifier>(scrollingNodeID()), WheelEventTestTrigger::ScrollingThreadSyncNeeded);
     201            m_delegate.deferTestsForReason(reinterpret_cast<WheelEventTestTrigger::ScrollableAreaIdentifier>(scrollingNodeID()), WheelEventTestTrigger::ScrollingThreadSyncNeeded);
    207202    }
    208203#endif
    209204
    210     m_scrollController.handleWheelEvent(wheelEvent);
     205    m_delegate.handleWheelEvent(wheelEvent);
     206
    211207#if ENABLE(CSS_SCROLL_SNAP)
    212     scrollingTree().setMainFrameIsScrollSnapping(m_scrollController.isScrollSnapInProgress());
    213     if (m_scrollController.activeScrollSnapIndexDidChange())
    214         scrollingTree().setActiveScrollSnapIndices(scrollingNodeID(), m_scrollController.activeScrollSnapIndexForAxis(ScrollEventAxis::Horizontal), m_scrollController.activeScrollSnapIndexForAxis(ScrollEventAxis::Vertical));
     208    scrollingTree().setMainFrameIsScrollSnapping(m_delegate.isScrollSnapInProgress());
     209    if (m_delegate.activeScrollSnapIndexDidChange())
     210        scrollingTree().setActiveScrollSnapIndices(scrollingNodeID(), m_delegate.activeScrollSnapIndexForAxis(ScrollEventAxis::Horizontal), m_delegate.activeScrollSnapIndexForAxis(ScrollEventAxis::Vertical));
    215211#endif
    216212    scrollingTree().setOrClearLatchedNode(wheelEvent, scrollingNodeID());
     
    219215    // FIXME: This needs to return whether the event was handled.
    220216    return ScrollingEventResult::DidHandleEvent;
    221 }
    222 
    223 // FIXME: We should find a way to share some of the code from newGestureIsStarting(), isAlreadyPinnedInDirectionOfGesture(),
    224 // allowsVerticalStretching(), and allowsHorizontalStretching() with the implementation in ScrollAnimatorMac.
    225 static bool newGestureIsStarting(const PlatformWheelEvent& wheelEvent)
    226 {
    227     return wheelEvent.phase() == PlatformWheelEventPhaseMayBegin || wheelEvent.phase() == PlatformWheelEventPhaseBegan;
    228 }
    229 
    230 bool ScrollingTreeFrameScrollingNodeMac::isAlreadyPinnedInDirectionOfGesture(const PlatformWheelEvent& wheelEvent, ScrollEventAxis axis)
    231 {
    232     switch (axis) {
    233     case ScrollEventAxis::Vertical:
    234         return (wheelEvent.deltaY() > 0 && scrollPosition().y() <= minimumScrollPosition().y()) || (wheelEvent.deltaY() < 0 && scrollPosition().y() >= maximumScrollPosition().y());
    235     case ScrollEventAxis::Horizontal:
    236         return (wheelEvent.deltaX() > 0 && scrollPosition().x() <= minimumScrollPosition().x()) || (wheelEvent.deltaX() < 0 && scrollPosition().x() >= maximumScrollPosition().x());
    237     }
    238 
    239     ASSERT_NOT_REACHED();
    240     return false;
    241 }
    242 
    243 bool ScrollingTreeFrameScrollingNodeMac::allowsHorizontalStretching(const PlatformWheelEvent& wheelEvent)
    244 {
    245     switch (horizontalScrollElasticity()) {
    246     case ScrollElasticityAutomatic: {
    247         bool scrollbarsAllowStretching = hasEnabledHorizontalScrollbar() || !hasEnabledVerticalScrollbar();
    248         bool eventPreventsStretching = newGestureIsStarting(wheelEvent) && isAlreadyPinnedInDirectionOfGesture(wheelEvent, ScrollEventAxis::Horizontal);
    249         return scrollbarsAllowStretching && !eventPreventsStretching;
    250     }
    251     case ScrollElasticityNone:
    252         return false;
    253     case ScrollElasticityAllowed:
    254         return true;
    255     }
    256 
    257     ASSERT_NOT_REACHED();
    258     return false;
    259 }
    260 
    261 bool ScrollingTreeFrameScrollingNodeMac::allowsVerticalStretching(const PlatformWheelEvent& wheelEvent)
    262 {
    263     switch (verticalScrollElasticity()) {
    264     case ScrollElasticityAutomatic: {
    265         bool scrollbarsAllowStretching = hasEnabledVerticalScrollbar() || !hasEnabledHorizontalScrollbar();
    266         bool eventPreventsStretching = newGestureIsStarting(wheelEvent) && isAlreadyPinnedInDirectionOfGesture(wheelEvent, ScrollEventAxis::Vertical);
    267         return scrollbarsAllowStretching && !eventPreventsStretching;
    268     }
    269     case ScrollElasticityNone:
    270         return false;
    271     case ScrollElasticityAllowed:
    272         return true;
    273     }
    274 
    275     ASSERT_NOT_REACHED();
    276     return false;
    277 }
    278 
    279 IntSize ScrollingTreeFrameScrollingNodeMac::stretchAmount()
    280 {
    281     IntSize stretch;
    282 
    283     if (scrollPosition().y() < minimumScrollPosition().y())
    284         stretch.setHeight(scrollPosition().y() - minimumScrollPosition().y());
    285     else if (scrollPosition().y() > maximumScrollPosition().y())
    286         stretch.setHeight(scrollPosition().y() - maximumScrollPosition().y());
    287 
    288     if (scrollPosition().x() < minimumScrollPosition().x())
    289         stretch.setWidth(scrollPosition().x() - minimumScrollPosition().x());
    290     else if (scrollPosition().x() > maximumScrollPosition().x())
    291         stretch.setWidth(scrollPosition().x() - maximumScrollPosition().x());
    292 
    293     if (scrollingTree().rootNode() == this) {
    294         if (stretch.isZero())
    295             scrollingTree().setMainFrameIsRubberBanding(false);
    296         else
    297             scrollingTree().setMainFrameIsRubberBanding(true);
    298     }
    299 
    300     return stretch;
    301 }
    302 
    303 bool ScrollingTreeFrameScrollingNodeMac::pinnedInDirection(const FloatSize& delta)
    304 {
    305     FloatSize limitDelta;
    306 
    307     if (fabsf(delta.height()) >= fabsf(delta.width())) {
    308         if (delta.height() < 0) {
    309             // We are trying to scroll up. Make sure we are not pinned to the top.
    310             limitDelta.setHeight(scrollPosition().y() - minimumScrollPosition().y());
    311         } else {
    312             // We are trying to scroll down. Make sure we are not pinned to the bottom.
    313             limitDelta.setHeight(maximumScrollPosition().y() - scrollPosition().y());
    314         }
    315     } else if (delta.width()) {
    316         if (delta.width() < 0) {
    317             // We are trying to scroll left. Make sure we are not pinned to the left.
    318             limitDelta.setWidth(scrollPosition().x() - minimumScrollPosition().x());
    319         } else {
    320             // We are trying to scroll right. Make sure we are not pinned to the right.
    321             limitDelta.setWidth(maximumScrollPosition().x() - scrollPosition().x());
    322         }
    323     }
    324 
    325     if ((delta.width() || delta.height()) && (limitDelta.width() < 1 && limitDelta.height() < 1))
    326         return true;
    327 
    328     return false;
    329 }
    330 
    331 bool ScrollingTreeFrameScrollingNodeMac::canScrollHorizontally()
    332 {
    333     return hasEnabledHorizontalScrollbar();
    334 }
    335 
    336 bool ScrollingTreeFrameScrollingNodeMac::canScrollVertically()
    337 {
    338     return hasEnabledVerticalScrollbar();
    339 }
    340 
    341 bool ScrollingTreeFrameScrollingNodeMac::shouldRubberBandInDirection(ScrollDirection)
    342 {
    343     return true;
    344 }
    345 
    346 void ScrollingTreeFrameScrollingNodeMac::immediateScrollBy(const FloatSize& delta)
    347 {
    348     scrollBy(delta);
    349 }
    350 
    351 void ScrollingTreeFrameScrollingNodeMac::immediateScrollByWithoutContentEdgeConstraints(const FloatSize& offset)
    352 {
    353     scrollByWithoutContentEdgeConstraints(offset);
    354 }
    355 
    356 void ScrollingTreeFrameScrollingNodeMac::stopSnapRubberbandTimer()
    357 {
    358     scrollingTree().setMainFrameIsRubberBanding(false);
    359 
    360     // Since the rubberband timer has stopped, totalContentsSizeForRubberBand can be synchronized with totalContentsSize.
    361     setTotalContentsSizeForRubberBand(totalContentsSize());
    362 }
    363 
    364 void ScrollingTreeFrameScrollingNodeMac::adjustScrollPositionToBoundsIfNecessary()
    365 {
    366     FloatPoint currentScrollPosition = scrollPosition();
    367     FloatPoint constrainedPosition = currentScrollPosition.constrainedBetween(minimumScrollPosition(), maximumScrollPosition());
    368     immediateScrollBy(constrainedPosition - currentScrollPosition);
    369217}
    370218
     
    505353    FloatPoint position = ScrollableArea::scrollPositionFromOffset(FloatPoint(), toFloatSize(scrollOrigin()));
    506354   
    507     if (scrollingTree().rootNode() == this && scrollingTree().scrollPinningBehavior() == PinToBottom)
     355    if (isRootNode() && scrollingTree().scrollPinningBehavior() == PinToBottom)
    508356        position.setY(maximumScrollPosition().y());
    509357
     
    516364    position = position.expandedTo(FloatPoint());
    517365
    518     if (scrollingTree().rootNode() == this && scrollingTree().scrollPinningBehavior() == PinToTop)
     366    if (isRootNode() && scrollingTree().scrollPinningBehavior() == PinToTop)
    519367        position.setY(minimumScrollPosition().y());
    520368
     
    561409}
    562410
    563 #if ENABLE(CSS_SCROLL_SNAP)
    564 FloatPoint ScrollingTreeFrameScrollingNodeMac::scrollOffset() const
    565 {
    566     return scrollPosition();
    567 }
    568 
    569 void ScrollingTreeFrameScrollingNodeMac::immediateScrollOnAxis(ScrollEventAxis axis, float delta)
    570 {
    571     const FloatPoint& currentPosition = scrollPosition();
    572     FloatPoint change;
    573     if (axis == ScrollEventAxis::Horizontal)
    574         change = FloatPoint(currentPosition.x() + delta, currentPosition.y());
    575     else
    576         change = FloatPoint(currentPosition.x(), currentPosition.y() + delta);
    577 
    578     immediateScrollBy(change - currentPosition);
    579 }
    580 
    581 float ScrollingTreeFrameScrollingNodeMac::pageScaleFactor() const
    582 {
    583     return frameScaleFactor();
    584 }
    585 
    586 void ScrollingTreeFrameScrollingNodeMac::startScrollSnapTimer()
    587 {
    588     scrollingTree().setMainFrameIsScrollSnapping(true);
    589 }
    590 
    591 void ScrollingTreeFrameScrollingNodeMac::stopScrollSnapTimer()
    592 {
    593     scrollingTree().setMainFrameIsScrollSnapping(false);
    594 }
    595    
    596 LayoutSize ScrollingTreeFrameScrollingNodeMac::scrollExtent() const
    597 {
    598     return LayoutSize(totalContentsSize());
    599 }
    600 
    601 FloatSize ScrollingTreeFrameScrollingNodeMac::viewportSize() const
    602 {
    603     return scrollableAreaSize();
    604 }
    605 
    606 #endif
    607 
    608 void ScrollingTreeFrameScrollingNodeMac::deferTestsForReason(WheelEventTestTrigger::ScrollableAreaIdentifier identifier, WheelEventTestTrigger::DeferTestTriggerReason reason) const
    609 {
    610     if (!m_expectsWheelEventTestTrigger)
    611         return;
    612 
    613     LOG(WheelEventTestTriggers, "  ScrollingTreeFrameScrollingNodeMac::deferTestsForReason: STARTING deferral for %p because of %d", identifier, reason);
    614     scrollingTree().deferTestsForReason(identifier, reason);
    615 }
    616    
    617 void ScrollingTreeFrameScrollingNodeMac::removeTestDeferralForReason(WheelEventTestTrigger::ScrollableAreaIdentifier identifier, WheelEventTestTrigger::DeferTestTriggerReason reason) const
    618 {
    619     if (!m_expectsWheelEventTestTrigger)
    620         return;
    621    
    622     LOG(WheelEventTestTriggers, "   ScrollingTreeFrameScrollingNodeMac::deferTestsForReason: ENDING deferral for %p because of %d", identifier, reason);
    623     scrollingTree().removeTestDeferralForReason(identifier, reason);
    624 }
    625 
    626411} // namespace WebCore
    627412
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h

    r240823 r240825  
    11/*
    2  * Copyright (C) 2012, 2014-2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#pragma once
    2727
    28 #if ENABLE(ASYNC_SCROLLING) && PLATFORM(MAC)
     28#include "ScrollingTreeScrollingNodeDelegate.h"
     29
     30#if PLATFORM(MAC) && ENABLE(ASYNC_SCROLLING)
    2931
    3032#include "ScrollController.h"
    31 #include "ScrollbarThemeMac.h"
    32 #include "ScrollingStateFrameScrollingNode.h"
    33 #include "ScrollingTreeFrameScrollingNode.h"
    34 #include <wtf/RetainPtr.h>
    35 
    36 OBJC_CLASS CALayer;
    3733
    3834namespace WebCore {
    3935
    40 class WEBCORE_EXPORT ScrollingTreeFrameScrollingNodeMac : public ScrollingTreeFrameScrollingNode, private ScrollControllerClient {
     36class FloatPoint;
     37class FloatSize;
     38class IntPoint;
     39class ScrollingTreeScrollingNode;
     40class ScrollingTree;
     41
     42class ScrollingTreeScrollingNodeDelegateMac : public ScrollingTreeScrollingNodeDelegate, private ScrollControllerClient {
    4143public:
    42     static Ref<ScrollingTreeFrameScrollingNode> create(ScrollingTree&, ScrollingNodeType, ScrollingNodeID);
    43     virtual ~ScrollingTreeFrameScrollingNodeMac();
     44    explicit ScrollingTreeScrollingNodeDelegateMac(ScrollingTreeScrollingNode&);
     45    virtual ~ScrollingTreeScrollingNodeDelegateMac();
    4446
    45 protected:
    46     ScrollingTreeFrameScrollingNodeMac(ScrollingTree&, ScrollingNodeType, ScrollingNodeID);
     47    bool handleWheelEvent(const PlatformWheelEvent&);
    4748
    48     void releaseReferencesToScrollerImpsOnTheMainThread();
     49#if ENABLE(CSS_SCROLL_SNAP)
     50    void updateScrollSnapPoints(ScrollEventAxis, const Vector<LayoutUnit>&, const Vector<ScrollOffsetRange<LayoutUnit>>&);
     51    void setActiveScrollSnapIndexForAxis(ScrollEventAxis, unsigned);
     52    bool activeScrollSnapIndexDidChange() const;
     53    unsigned activeScrollSnapIndexForAxis(ScrollEventAxis) const;
     54    bool isScrollSnapInProgress() const;
     55#endif
    4956
    50     // ScrollingTreeNode member functions.
    51     void commitStateBeforeChildren(const ScrollingStateNode&) override;
    52     void commitStateAfterChildren(const ScrollingStateNode&) override;
     57    void deferTestsForReason(WheelEventTestTrigger::ScrollableAreaIdentifier, WheelEventTestTrigger::DeferTestTriggerReason) const override;
     58    void removeTestDeferralForReason(WheelEventTestTrigger::ScrollableAreaIdentifier, WheelEventTestTrigger::DeferTestTriggerReason) const override;
    5359
    54     ScrollingEventResult handleWheelEvent(const PlatformWheelEvent&) override;
     60private:
     61    bool isAlreadyPinnedInDirectionOfGesture(const PlatformWheelEvent&, ScrollEventAxis);
    5562
    56     // ScrollController member functions.
     63    // ScrollControllerClient.
    5764    bool allowsHorizontalStretching(const PlatformWheelEvent&) override;
    5865    bool allowsVerticalStretching(const PlatformWheelEvent&) override;
     
    6774    void adjustScrollPositionToBoundsIfNecessary() override;
    6875
    69     FloatPoint scrollPosition() const override;
    70     void setScrollPosition(const FloatPoint&) override;
    71     void setScrollPositionWithoutContentEdgeConstraints(const FloatPoint&) override;
    72 
    73     void updateLayersAfterViewportChange(const FloatRect& fixedPositionRect, double scale) override;
    74 
    75     void setScrollLayerPosition(const FloatPoint&, const FloatRect& layoutViewport) override;
    76 
    77     FloatPoint minimumScrollPosition() const override;
    78     FloatPoint maximumScrollPosition() const override;
    79 
    80     void updateMainFramePinState(const FloatPoint& scrollPosition);
    81 
    82     bool isAlreadyPinnedInDirectionOfGesture(const PlatformWheelEvent&, ScrollEventAxis);
    83 
    84     void deferTestsForReason(WheelEventTestTrigger::ScrollableAreaIdentifier, WheelEventTestTrigger::DeferTestTriggerReason) const override;
    85     void removeTestDeferralForReason(WheelEventTestTrigger::ScrollableAreaIdentifier, WheelEventTestTrigger::DeferTestTriggerReason) const override;
    86 
    87 #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
     76#if ENABLE(CSS_SCROLL_SNAP)
    8877    FloatPoint scrollOffset() const override;
    8978    void immediateScrollOnAxis(ScrollEventAxis, float delta) override;
     
    9584#endif
    9685
    97     unsigned exposedUnfilledArea() const;
    98 
    99 private:
    10086    ScrollController m_scrollController;
    101 
    102     RetainPtr<CALayer> m_scrollLayer;
    103     RetainPtr<CALayer> m_rootContentsLayer;
    104     RetainPtr<CALayer> m_counterScrollingLayer;
    105     RetainPtr<CALayer> m_insetClipLayer;
    106     RetainPtr<CALayer> m_contentShadowLayer;
    107     RetainPtr<CALayer> m_headerLayer;
    108     RetainPtr<CALayer> m_footerLayer;
    109     RetainPtr<NSScrollerImp> m_verticalScrollerImp;
    110     RetainPtr<NSScrollerImp> m_horizontalScrollerImp;
    111     FloatPoint m_probableMainThreadScrollPosition;
    112     bool m_lastScrollHadUnfilledPixels { false };
    113     bool m_hadFirstUpdate { false };
    114     bool m_expectsWheelEventTestTrigger { false };
    11587};
    11688
    11789} // namespace WebCore
    11890
    119 #endif // ENABLE(ASYNC_SCROLLING) && PLATFORM(MAC)
     91#endif // PLATFORM(MAC) && ENABLE(ASYNC_SCROLLING)
Note: See TracChangeset for help on using the changeset viewer.