⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 185762 in webkit


Ignore:
Timestamp:
Jun 19, 2015, 12:24:59 PM (11 years ago)
Author:
Brent Fulgham
Message:

[iOS] scrollIntoViewIfNeeded is not working with scroll-snap points
https://bugs.webkit.org/show_bug.cgi?id=145318
<rdar://problem/21081501>

Reviewed by Simon Fraser.

Source/WebCore:

Use the ScrollController in iOS to track the scroll snap point state.
We do not need the animation implementation or timers since the actual
animation is handled by UIKit.

This change lets us communicate the current offset into the scroll snap
offset vector between the WebProcess and RemoteScrollingTree so that
both sides stay in sync regardless of whether user gestures or style
updates have caused us to shift to a different snap point.

  • page/scrolling/AsyncScrollingCoordinator.cpp:

(WebCore::AsyncScrollingCoordinator::frameViewLayoutUpdated): Set the
current horizontal and vertical scroll snap offset indices.
(WebCore::AsyncScrollingCoordinator::updateOverflowScrollingNode): Ditto.

  • page/scrolling/AsyncScrollingCoordinator.h: Mark the setActiveScrollSnapIndices

for export so that it can be reached by the UIProcess.

  • page/scrolling/ScrollingCoordinator.h: Keep track of horizontal and

vertical scroll snap offset indices.

  • page/scrolling/ScrollingStateScrollingNode.cpp:

(WebCore::ScrollingStateScrollingNode::setCurrentHorizontalSnapPointIndex): Added.
(WebCore::ScrollingStateScrollingNode::setCurrentVerticalSnapPointIndex): Added.

  • page/scrolling/ScrollingStateScrollingNode.h:

(WebCore::ScrollingStateScrollingNode::currentHorizontalSnapPointIndex): Added.
(WebCore::ScrollingStateScrollingNode::currentVerticalSnapPointIndex): Added.

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

(WebCore::ScrollingTreeScrollingNode::updateBeforeChildren): Update the scroll snap
point offset indices if either has changed.

  • page/scrolling/ScrollingTreeScrollingNode.h:

(WebCore::ScrollingTreeScrollingNode::currentHorizontalSnapPointIndex): Added.
(WebCore::ScrollingTreeScrollingNode::currentVerticalSnapPointIndex): Added.
(WebCore::ScrollingTreeScrollingNode::setCurrentHorizontalSnapPointIndex): Added.
(WebCore::ScrollingTreeScrollingNode::setCurrentVerticalSnapPointIndex): Added.

  • page/scrolling/ThreadedScrollingTree.cpp:

(WebCore::ThreadedScrollingTree::currentSnapPointIndicesDidChange): New method
to handle notifications about scroll snap index changes from the UIProcess.

  • page/scrolling/ThreadedScrollingTree.h:
  • page/scrolling/ios/ScrollingTreeIOS.cpp:

(WebCore::ScrollingTreeIOS::currentSnapPointIndicesDidChange): New method
to handle notifications about scroll snap index changes from the UIProcess.

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

(WebCore::ScrollingTreeFrameScrollingNodeMac::updateBeforeChildren): Update scroll
snap point current offset indices if they have changed.
(WebCore::ScrollingTreeFrameScrollingNodeMac::scrollOffsetOnAxis): Remove unneeded
PLATFORM(MAC) macro.

  • platform/ScrollAnimator.cpp:

(WebCore::ScrollAnimator::ScrollAnimator): We have a ScrollController if we are
supporting scroll snap points or rubber banding.
(WebCore::ScrollAnimator::processWheelEventForScrollSnap): This method is not needed
for iOS builds.
(WebCore::ScrollAnimator::updateActiveScrollSnapIndexForOffset): Enable this on iOS.
(WebCore::ScrollAnimator::updateScrollSnapState): Renamed from 'updateScrollAnimatorsAndTimers'
and enabled on iOS.
(WebCore::ScrollAnimator::updateScrollAnimatorsAndTimers): Deleted.

  • platform/ScrollAnimator.h: Enable some scroll snap methods on iOS.
  • platform/ScrollableArea.cpp:

(WebCore::ScrollableArea::handleWheelEvent): Enable scroll snap index bookkeeping on iOS, too.
(WebCore::ScrollableArea::updateScrollSnapState): Revise to call 'updateScrollSnapState' instead
of 'updateScrollAnimatorsAndTimers'.

  • platform/cocoa/ScrollController.h: Enable some methods on iOS. Reorder methods to

reduce the number of macros needed to do so.

  • platform/cocoa/ScrollController.mm:

(systemUptime): Only build for Mac.
(WebCore::ScrollController::ScrollController): Disable rubber band-specific members on iOS.
(WebCore::ScrollController::handleWheelEvent): Only build this on Mac.
(WebCore::ScrollController::isRubberBandInProgress): Always return 'false' on iOS.
(WebCore::ScrollController::startSnapRubberbandTimer): Only build this on Mac.
(WebCore::ScrollController::shouldRubberBandInHorizontalDirection): Ditto.
(WebCore::ScrollController::scrollSnapPointState): Enable on iOS.
(WebCore::ScrollController::hasActiveScrollSnapTimerForAxis): Only build on Mac.
(WebCore::ScrollController::updateScrollSnapState): renamed from 'updateScrollAnimatorsAndTimers'
(WebCore::ScrollController::startScrollSnapTimer): Only build on Mac.
(WebCore::ScrollController::initializeGlideParameters): Ditto.
(WebCore::ScrollController::activeScrollSnapIndexForAxis): Enable on iOS.
(WebCore::ScrollController::setActiveScrollSnapIndicesForOffset): Ditto.
(WebCore::ScrollController::beginScrollSnapAnimation): Only build on Mac.
(WebCore::ScrollController::computeGlideDelta): Ditto.
(WebCore::ScrollController::updateScrollAnimatorsAndTimers): Deleted.

  • rendering/RenderLayerCompositor.cpp:

(WebCore::RenderLayerCompositor::updateScrollCoordinatedLayer): Capture any changes in scroll
snap offset indices.

Source/WebKit2:

  • Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp:

(ArgumentCoder<ScrollingStateScrollingNode>::encode): Handle scroll snap point offset indices.
(ArgumentCoder<ScrollingStateScrollingNode>::decode): Ditto.

  • UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp:

(WebKit::RemoteScrollingCoordinatorProxy::currentSnapPointIndicesDidChange): Added. Send message
to WebProcess when scroll snap indices have changed.

  • UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h:
  • UIProcess/Scrolling/RemoteScrollingTree.cpp:

(WebKit::RemoteScrollingTree::currentSnapPointIndicesDidChange): Added. Notify the
RemoteScrollingCoordinatorProxy when scroll snap indices have changed.

  • UIProcess/Scrolling/RemoteScrollingTree.h:
  • UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.h:
  • UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:

(-[WKOverflowScrollViewDelegate scrollViewWillEndDragging:withVelocity:targetContentOffset:]): Revised.
Identify changes in the current scroll snap point offset index (in either the horizontal or vertical
directions), and send a notification when this happens.
(WebKit::ScrollingTreeOverflowScrollingNodeIOS::currentSnapPointIndicesDidChange): Added. Notify the
Scrolling Tree when indices changed.

  • UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm:

(WebKit::RemoteScrollingCoordinatorProxy::adjustTargetContentOffsetForSnapping): Revised. Always compute
the new scroll snap offset index (even when we will rubber band).

  • WebProcess/Scrolling/RemoteScrollingCoordinator.h:
  • WebProcess/Scrolling/RemoteScrollingCoordinator.messages.in: Add a new message to relay changes in scroll

snap index.

  • WebProcess/Scrolling/RemoteScrollingCoordinator.mm:

(WebKit::RemoteScrollingCoordinator::currentSnapPointIndicesChangedForNode): Added.

Location:
trunk/Source
Files:
32 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r185761 r185762  
     12015-06-18  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [iOS] scrollIntoViewIfNeeded is not working with scroll-snap points
     4        https://bugs.webkit.org/show_bug.cgi?id=145318
     5        <rdar://problem/21081501>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Use the ScrollController in iOS to track the scroll snap point state.
     10        We do not need the animation implementation or timers since the actual
     11        animation is handled by UIKit.
     12
     13        This change lets us communicate the current offset into the scroll snap
     14        offset vector between the WebProcess and RemoteScrollingTree so that
     15        both sides stay in sync regardless of whether user gestures or style
     16        updates have caused us to shift to a different snap point.
     17
     18        * page/scrolling/AsyncScrollingCoordinator.cpp:
     19        (WebCore::AsyncScrollingCoordinator::frameViewLayoutUpdated): Set the
     20        current horizontal and vertical scroll snap offset indices.
     21        (WebCore::AsyncScrollingCoordinator::updateOverflowScrollingNode): Ditto.
     22        * page/scrolling/AsyncScrollingCoordinator.h: Mark the setActiveScrollSnapIndices
     23        for export so that it can be reached by the UIProcess.
     24        * page/scrolling/ScrollingCoordinator.h: Keep track of horizontal and
     25        vertical scroll snap offset indices.
     26        * page/scrolling/ScrollingStateScrollingNode.cpp:
     27        (WebCore::ScrollingStateScrollingNode::setCurrentHorizontalSnapPointIndex): Added.
     28        (WebCore::ScrollingStateScrollingNode::setCurrentVerticalSnapPointIndex): Added.
     29        * page/scrolling/ScrollingStateScrollingNode.h:
     30        (WebCore::ScrollingStateScrollingNode::currentHorizontalSnapPointIndex): Added.
     31        (WebCore::ScrollingStateScrollingNode::currentVerticalSnapPointIndex): Added.
     32        * page/scrolling/ScrollingTree.h:
     33        * page/scrolling/ScrollingTreeScrollingNode.cpp:
     34        (WebCore::ScrollingTreeScrollingNode::updateBeforeChildren): Update the scroll snap
     35        point offset indices if either has changed.
     36        * page/scrolling/ScrollingTreeScrollingNode.h:
     37        (WebCore::ScrollingTreeScrollingNode::currentHorizontalSnapPointIndex): Added.
     38        (WebCore::ScrollingTreeScrollingNode::currentVerticalSnapPointIndex): Added.
     39        (WebCore::ScrollingTreeScrollingNode::setCurrentHorizontalSnapPointIndex): Added.
     40        (WebCore::ScrollingTreeScrollingNode::setCurrentVerticalSnapPointIndex): Added.
     41        * page/scrolling/ThreadedScrollingTree.cpp:
     42        (WebCore::ThreadedScrollingTree::currentSnapPointIndicesDidChange): New method
     43        to handle notifications about scroll snap index changes from the UIProcess.
     44        * page/scrolling/ThreadedScrollingTree.h:
     45        * page/scrolling/ios/ScrollingTreeIOS.cpp:
     46        (WebCore::ScrollingTreeIOS::currentSnapPointIndicesDidChange): New method
     47        to handle notifications about scroll snap index changes from the UIProcess.
     48        * page/scrolling/ios/ScrollingTreeIOS.h:
     49        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
     50        (WebCore::ScrollingTreeFrameScrollingNodeMac::updateBeforeChildren): Update scroll
     51        snap point current offset indices if they have changed.
     52        (WebCore::ScrollingTreeFrameScrollingNodeMac::scrollOffsetOnAxis): Remove unneeded
     53        PLATFORM(MAC) macro.
     54        * platform/ScrollAnimator.cpp:
     55        (WebCore::ScrollAnimator::ScrollAnimator): We have a ScrollController if we are
     56        supporting scroll snap points or rubber banding.
     57        (WebCore::ScrollAnimator::processWheelEventForScrollSnap): This method is not needed
     58        for iOS builds.
     59        (WebCore::ScrollAnimator::updateActiveScrollSnapIndexForOffset): Enable this on iOS.
     60        (WebCore::ScrollAnimator::updateScrollSnapState): Renamed from 'updateScrollAnimatorsAndTimers'
     61        and enabled on iOS.
     62        (WebCore::ScrollAnimator::updateScrollAnimatorsAndTimers): Deleted.
     63        * platform/ScrollAnimator.h: Enable some scroll snap methods on iOS.
     64        * platform/ScrollableArea.cpp:
     65        (WebCore::ScrollableArea::handleWheelEvent): Enable scroll snap index bookkeeping on iOS, too.
     66        (WebCore::ScrollableArea::updateScrollSnapState): Revise to call 'updateScrollSnapState' instead
     67        of 'updateScrollAnimatorsAndTimers'.
     68        * platform/cocoa/ScrollController.h: Enable some methods on iOS. Reorder methods to
     69        reduce the number of macros needed to do so.
     70        * platform/cocoa/ScrollController.mm:
     71        (systemUptime): Only build for Mac.
     72        (WebCore::ScrollController::ScrollController): Disable rubber band-specific members on iOS.
     73        (WebCore::ScrollController::handleWheelEvent): Only build this on Mac.
     74        (WebCore::ScrollController::isRubberBandInProgress): Always return 'false' on iOS.
     75        (WebCore::ScrollController::startSnapRubberbandTimer): Only build this on Mac.
     76        (WebCore::ScrollController::shouldRubberBandInHorizontalDirection): Ditto.
     77        (WebCore::ScrollController::scrollSnapPointState): Enable on iOS.
     78        (WebCore::ScrollController::hasActiveScrollSnapTimerForAxis): Only build on Mac.
     79        (WebCore::ScrollController::updateScrollSnapState): renamed from 'updateScrollAnimatorsAndTimers'
     80        (WebCore::ScrollController::startScrollSnapTimer): Only build on Mac.
     81        (WebCore::ScrollController::initializeGlideParameters): Ditto.
     82        (WebCore::ScrollController::activeScrollSnapIndexForAxis): Enable on iOS.
     83        (WebCore::ScrollController::setActiveScrollSnapIndicesForOffset): Ditto.
     84        (WebCore::ScrollController::beginScrollSnapAnimation): Only build on Mac.
     85        (WebCore::ScrollController::computeGlideDelta): Ditto.
     86        (WebCore::ScrollController::updateScrollAnimatorsAndTimers): Deleted.
     87        * rendering/RenderLayerCompositor.cpp:
     88        (WebCore::RenderLayerCompositor::updateScrollCoordinatedLayer): Capture any changes in scroll
     89        snap offset indices.
     90
    1912015-06-19  Jeremy Jones  <jeremyj@apple.com>
    292
  • trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp

    r185167 r185762  
    147147    if (const Vector<LayoutUnit>* verticalSnapOffsets = frameView.verticalSnapOffsets())
    148148        setStateScrollingNodeSnapOffsetsAsFloat(*node, ScrollEventAxis::Vertical, *verticalSnapOffsets, m_page->deviceScaleFactor());
     149
     150    node->setCurrentHorizontalSnapPointIndex(frameView.currentHorizontalSnapPointIndex());
     151    node->setCurrentVerticalSnapPointIndex(frameView.currentVerticalSnapPointIndex());
    149152#endif
    150153
     
    485488        setStateScrollingNodeSnapOffsetsAsFloat(*node, ScrollEventAxis::Horizontal, scrollingGeometry->horizontalSnapOffsets, m_page->deviceScaleFactor());
    486489        setStateScrollingNodeSnapOffsetsAsFloat(*node, ScrollEventAxis::Vertical, scrollingGeometry->verticalSnapOffsets, m_page->deviceScaleFactor());
     490        node->setCurrentHorizontalSnapPointIndex(scrollingGeometry->currentHorizontalSnapPointIndex);
     491        node->setCurrentVerticalSnapPointIndex(scrollingGeometry->currentVerticalSnapPointIndex);
    487492#endif
    488493    }
  • trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h

    r184596 r185762  
    5858
    5959#if PLATFORM(COCOA)
    60     void setActiveScrollSnapIndices(ScrollingNodeID, unsigned horizontalIndex, unsigned verticalIndex);
     60    WEBCORE_EXPORT void setActiveScrollSnapIndices(ScrollingNodeID, unsigned horizontalIndex, unsigned verticalIndex);
    6161    void deferTestsForReason(WheelEventTestTrigger::ScrollableAreaIdentifier, WheelEventTestTrigger::DeferTestTriggerReason) const;
    6262    void removeTestDeferralForReason(WheelEventTestTrigger::ScrollableAreaIdentifier, WheelEventTestTrigger::DeferTestTriggerReason) const;
  • trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h

    r184596 r185762  
    169169        Vector<LayoutUnit> horizontalSnapOffsets;
    170170        Vector<LayoutUnit> verticalSnapOffsets;
     171        unsigned currentHorizontalSnapPointIndex;
     172        unsigned currentVerticalSnapPointIndex;
    171173#endif
    172174    };
  • trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp

    r183702 r185762  
    124124    setPropertyChanged(VerticalSnapOffsets);
    125125}
     126
     127void ScrollingStateScrollingNode::setCurrentHorizontalSnapPointIndex(unsigned index)
     128{
     129    if (m_currentHorizontalSnapPointIndex == index)
     130        return;
     131   
     132    m_currentHorizontalSnapPointIndex = index;
     133    setPropertyChanged(CurrentHorizontalSnapOffsetIndex);
     134}
     135
     136void ScrollingStateScrollingNode::setCurrentVerticalSnapPointIndex(unsigned index)
     137{
     138    if (m_currentVerticalSnapPointIndex == index)
     139        return;
     140   
     141    m_currentVerticalSnapPointIndex = index;
     142    setPropertyChanged(CurrentVerticalSnapOffsetIndex);
     143}
    126144#endif
    127145
  • trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h

    r183702 r185762  
    5151        HorizontalSnapOffsets,
    5252        VerticalSnapOffsets,
     53        CurrentHorizontalSnapOffsetIndex,
     54        CurrentVerticalSnapOffsetIndex,
    5355#endif
    5456        ExpectsWheelEventTestTrigger,
     
    7678    const Vector<float>& verticalSnapOffsets() const { return m_verticalSnapOffsets; }
    7779    WEBCORE_EXPORT void setVerticalSnapOffsets(const Vector<float>&);
     80
     81    unsigned currentHorizontalSnapPointIndex() const { return m_currentHorizontalSnapPointIndex; }
     82    WEBCORE_EXPORT void setCurrentHorizontalSnapPointIndex(unsigned);
     83
     84    unsigned currentVerticalSnapPointIndex() const { return m_currentVerticalSnapPointIndex; }
     85    WEBCORE_EXPORT void setCurrentVerticalSnapPointIndex(unsigned);
    7886#endif
    7987
     
    104112    Vector<float> m_horizontalSnapOffsets;
    105113    Vector<float> m_verticalSnapOffsets;
     114    unsigned m_currentHorizontalSnapPointIndex { 0 };
     115    unsigned m_currentVerticalSnapPointIndex { 0 };
    106116#endif
    107117    ScrollableAreaParameters m_scrollableAreaParameters;
  • trunk/Source/WebCore/page/scrolling/ScrollingTree.h

    r184596 r185762  
    8989    // and call scrollingTreeNodeDidScroll().
    9090    WEBCORE_EXPORT virtual void scrollPositionChangedViaDelegatedScrolling(ScrollingNodeID, const WebCore::FloatPoint& scrollPosition, bool inUserInteration);
     91
     92    WEBCORE_EXPORT virtual void currentSnapPointIndicesDidChange(ScrollingNodeID, unsigned horizontal, unsigned vertical) = 0;
    9193
    9294    FloatPoint mainFrameScrollPosition();
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp

    r174340 r185762  
    7474    if (state.hasChangedProperty(ScrollingStateScrollingNode::VerticalSnapOffsets))
    7575        m_verticalSnapOffsets = state.verticalSnapOffsets();
     76
     77    if (state.hasChangedProperty(ScrollingStateScrollingNode::CurrentHorizontalSnapOffsetIndex))
     78        m_currentHorizontalSnapPointIndex = state.currentHorizontalSnapPointIndex();
     79
     80    if (state.hasChangedProperty(ScrollingStateScrollingNode::CurrentVerticalSnapOffsetIndex))
     81        m_currentVerticalSnapPointIndex = state.currentVerticalSnapPointIndex();
    7682#endif
    7783
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h

    r180493 r185762  
    6060    const Vector<float>& horizontalSnapOffsets() const { return m_horizontalSnapOffsets; }
    6161    const Vector<float>& verticalSnapOffsets() const { return m_verticalSnapOffsets; }
     62    unsigned currentHorizontalSnapPointIndex() const { return m_currentHorizontalSnapPointIndex; }
     63    unsigned currentVerticalSnapPointIndex() const { return m_currentVerticalSnapPointIndex; }
     64    void setCurrentHorizontalSnapPointIndex(unsigned index) { m_currentHorizontalSnapPointIndex = index; }
     65    void setCurrentVerticalSnapPointIndex(unsigned index) { m_currentVerticalSnapPointIndex = index; }
    6266#endif
    6367
     
    100104    Vector<float> m_horizontalSnapOffsets;
    101105    Vector<float> m_verticalSnapOffsets;
     106    unsigned m_currentHorizontalSnapPointIndex { 0 };
     107    unsigned m_currentVerticalSnapPointIndex { 0 };
    102108#endif
    103109    ScrollableAreaParameters m_scrollableAreaParameters;
  • trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp

    r184139 r185762  
    112112}
    113113
     114void ThreadedScrollingTree::currentSnapPointIndicesDidChange(ScrollingNodeID nodeID, unsigned horizontal, unsigned vertical)
     115{
     116    if (!m_scrollingCoordinator)
     117        return;
     118
     119    RefPtr<AsyncScrollingCoordinator> scrollingCoordinator = m_scrollingCoordinator;
     120    RunLoop::main().dispatch([scrollingCoordinator, nodeID, horizontal, vertical] {
     121        scrollingCoordinator->setActiveScrollSnapIndices(nodeID, horizontal, vertical);
     122    });
     123}
     124
    114125#if PLATFORM(MAC)
    115126void ThreadedScrollingTree::handleWheelEventPhase(PlatformWheelEventPhase phase)
  • trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.h

    r184139 r185762  
    6161
    6262    virtual void scrollingTreeNodeDidScroll(ScrollingNodeID, const FloatPoint& scrollPosition, SetOrSyncScrollingLayerPosition = SyncScrollingLayerPosition) override;
     63    void currentSnapPointIndicesDidChange(ScrollingNodeID, unsigned horizontal, unsigned vertical) override;
    6364#if PLATFORM(MAC)
    6465    void handleWheelEventPhase(PlatformWheelEventPhase) override;
  • trunk/Source/WebCore/page/scrolling/ios/ScrollingTreeIOS.cpp

    r184066 r185762  
    119119}
    120120
     121void ScrollingTreeIOS::currentSnapPointIndicesDidChange(WebCore::ScrollingNodeID nodeID, unsigned horizontal, unsigned vertical)
     122{
     123    if (!m_scrollingCoordinator)
     124        return;
     125   
     126    RefPtr<AsyncScrollingCoordinator> scrollingCoordinator = m_scrollingCoordinator;
     127    callOnMainThread([scrollingCoordinator, nodeID, horizontal, vertical] {
     128        scrollingCoordinator->setActiveScrollSnapIndices(nodeID, horizontal, vertical);
     129    });
     130}
     131
    121132} // namespace WebCore
    122133
  • trunk/Source/WebCore/page/scrolling/ios/ScrollingTreeIOS.h

    r184066 r185762  
    5959    virtual void scrollingTreeNodeDidScroll(ScrollingNodeID, const FloatPoint& scrollPosition, SetOrSyncScrollingLayerPosition = SyncScrollingLayerPosition) override;
    6060
     61    void currentSnapPointIndicesDidChange(WebCore::ScrollingNodeID, unsigned horizontal, unsigned vertical) override;
     62
    6163    virtual FloatRect fixedPositionRect() override;
    6264
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm

    r185681 r185762  
    138138    if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::VerticalSnapOffsets))
    139139        m_scrollController.updateScrollSnapPoints(ScrollEventAxis::Vertical, convertToLayoutUnits(scrollingStateNode.verticalSnapOffsets()));
     140
     141    if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::CurrentHorizontalSnapOffsetIndex))
     142        m_scrollController.setActiveScrollSnapIndexForAxis(ScrollEventAxis::Horizontal, scrollingStateNode.currentHorizontalSnapPointIndex());
     143   
     144    if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::CurrentVerticalSnapOffsetIndex))
     145        m_scrollController.setActiveScrollSnapIndexForAxis(ScrollEventAxis::Vertical, scrollingStateNode.currentVerticalSnapPointIndex());
    140146#endif
    141147
     
    554560}
    555561
    556 #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
     562#if ENABLE(CSS_SCROLL_SNAP)
    557563LayoutUnit ScrollingTreeFrameScrollingNodeMac::scrollOffsetOnAxis(ScrollEventAxis axis) const
    558564{
  • trunk/Source/WebCore/platform/ScrollAnimator.cpp

    r185681 r185762  
    5050ScrollAnimator::ScrollAnimator(ScrollableArea& scrollableArea)
    5151    : m_scrollableArea(scrollableArea)
    52 #if (ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING)) && PLATFORM(MAC)
     52#if ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING)
    5353    , m_scrollController(*this)
    5454#endif
     
    8585}
    8686
    87 #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
     87#if ENABLE(CSS_SCROLL_SNAP)
     88#if PLATFORM(MAC)
    8889bool ScrollAnimator::processWheelEventForScrollSnap(const PlatformWheelEvent& wheelEvent)
    8990{
    9091    return m_scrollController.processWheelEventForScrollSnap(wheelEvent);
    9192}
     93#endif
    9294
    9395bool ScrollAnimator::activeScrollSnapIndexDidChange() const
     
    181183void ScrollAnimator::updateActiveScrollSnapIndexForOffset()
    182184{
    183 #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
     185#if ENABLE(CSS_SCROLL_SNAP)
    184186    m_scrollController.setActiveScrollSnapIndicesForOffset(m_currentPosX, m_currentPosY);
    185187    if (m_scrollController.activeScrollSnapIndexDidChange()) {
     
    196198}
    197199
    198 #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
    199 void ScrollAnimator::updateScrollAnimatorsAndTimers()
    200 {
    201     m_scrollController.updateScrollAnimatorsAndTimers(m_scrollableArea);
     200#if ENABLE(CSS_SCROLL_SNAP)
     201void ScrollAnimator::updateScrollSnapState()
     202{
     203    m_scrollController.updateScrollSnapState(m_scrollableArea);
    202204}
    203205
  • trunk/Source/WebCore/platform/ScrollAnimator.h

    r185681 r185762  
    4141#include <wtf/Forward.h>
    4242
    43 #if (ENABLE(RUBBER_BANDING) || ENABLE(CSS_SCROLL_SNAP)) && PLATFORM(MAC)
     43#if ENABLE(RUBBER_BANDING) || ENABLE(CSS_SCROLL_SNAP)
    4444#include "ScrollController.h"
    4545#endif
     
    5353class WheelEventTestTrigger;
    5454
    55 #if (ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING)) && PLATFORM(MAC)
     55#if ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING)
    5656class ScrollAnimator : private ScrollControllerClient {
    5757#else
     
    129129#endif
    130130   
    131 #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
     131#if ENABLE(CSS_SCROLL_SNAP)
     132#if PLATFORM(MAC)
    132133    bool processWheelEventForScrollSnap(const PlatformWheelEvent&);
    133     void updateScrollAnimatorsAndTimers();
     134#endif
     135    void updateScrollSnapState();
    134136    LayoutUnit scrollOffsetOnAxis(ScrollEventAxis) const override;
    135137    void immediateScrollOnAxis(ScrollEventAxis, float delta) override;
     
    145147    ScrollableArea& m_scrollableArea;
    146148    RefPtr<WheelEventTestTrigger> m_wheelEventTestTrigger;
    147 #if (ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING)) && PLATFORM(MAC)
     149#if ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING)
    148150    ScrollController m_scrollController;
    149151#endif
  • trunk/Source/WebCore/platform/ScrollableArea.cpp

    r185431 r185762  
    191191
    192192    bool handledEvent = scrollAnimator().handleWheelEvent(wheelEvent);
    193 #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
     193#if ENABLE(CSS_SCROLL_SNAP)
    194194    if (scrollAnimator().activeScrollSnapIndexDidChange()) {
    195195        setCurrentHorizontalSnapPointIndex(scrollAnimator().activeScrollSnapIndexForAxis(ScrollEventAxis::Horizontal));
     
    462462void ScrollableArea::updateScrollSnapState()
    463463{
    464 #if PLATFORM(MAC)
    465     if (ScrollAnimator* scrollAnimator = existingScrollAnimator())
    466         scrollAnimator->updateScrollAnimatorsAndTimers();
    467 #endif
     464    if (ScrollAnimator* scrollAnimator = existingScrollAnimator())
     465        scrollAnimator->updateScrollSnapState();
    468466
    469467    if (isScrollSnapInProgress())
  • trunk/Source/WebCore/platform/cocoa/ScrollController.h

    r185681 r185762  
    2727#define ScrollController_h
    2828
    29 #if ENABLE(RUBBER_BANDING)
     29#if ENABLE(RUBBER_BANDING) || ENABLE(CSS_SCROLL_SNAP)
    3030
    3131#include "FloatPoint.h"
     
    5252
    5353public:
     54#if ENABLE(RUBBER_BANDING)
    5455    virtual bool allowsHorizontalStretching(const PlatformWheelEvent&) = 0;
    5556    virtual bool allowsVerticalStretching(const PlatformWheelEvent&) = 0;
     
    7879    // the page to scroll to the nearest boundary point.
    7980    virtual void adjustScrollPositionToBoundsIfNecessary() = 0;
     81#endif
    8082
    8183    virtual void deferTestsForReason(WheelEventTestTrigger::ScrollableAreaIdentifier, WheelEventTestTrigger::DeferTestTriggerReason) const { /* Do nothing */ }
    8284    virtual void removeTestDeferralForReason(WheelEventTestTrigger::ScrollableAreaIdentifier, WheelEventTestTrigger::DeferTestTriggerReason) const { /* Do nothing */ }
    8385
    84 #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
     86#if ENABLE(CSS_SCROLL_SNAP)
    8587    virtual LayoutUnit scrollOffsetOnAxis(ScrollEventAxis) const = 0;
    8688    virtual void immediateScrollOnAxis(ScrollEventAxis, float delta) = 0;
     
    115117    explicit ScrollController(ScrollControllerClient&);
    116118
     119#if PLATFORM(MAC)
    117120    bool handleWheelEvent(const PlatformWheelEvent&);
     121#endif
    118122
    119123    bool isRubberBandInProgress() const;
    120124    bool isScrollSnapInProgress() const;
    121125
    122 #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
    123     bool processWheelEventForScrollSnap(const PlatformWheelEvent&);
    124     void updateScrollAnimatorsAndTimers(const ScrollableArea&);
     126#if ENABLE(CSS_SCROLL_SNAP)
    125127    void updateScrollSnapPoints(ScrollEventAxis, const Vector<LayoutUnit>&);
    126     unsigned activeScrollSnapIndexForAxis(ScrollEventAxis) const;
    127128    void setActiveScrollSnapIndexForAxis(ScrollEventAxis, unsigned);
    128129    void setActiveScrollSnapIndicesForOffset(int x, int y);
    129130    bool activeScrollSnapIndexDidChange() const { return m_activeScrollSnapIndexDidChange; }
    130131    void setScrollSnapIndexDidChange(bool state) { m_activeScrollSnapIndexDidChange = state; }
     132    unsigned activeScrollSnapIndexForAxis(ScrollEventAxis) const;
     133    void updateScrollSnapState(const ScrollableArea&);
     134#if PLATFORM(MAC)
     135    bool processWheelEventForScrollSnap(const PlatformWheelEvent&);
    131136    bool hasActiveScrollSnapTimerForAxis(ScrollEventAxis) const;
    132137#endif
     138#endif
    133139
    134140private:
     141#if ENABLE(RUBBER_BANDING)
    135142    void startSnapRubberbandTimer();
    136143    void stopSnapRubberbandTimer();
     
    139146
    140147    bool shouldRubberBandInHorizontalDirection(const PlatformWheelEvent&);
    141 
    142 #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
     148#endif
     149
     150#if ENABLE(CSS_SCROLL_SNAP)
     151    LayoutUnit scrollOffsetOnAxis(ScrollEventAxis) const;
     152    void setNearestScrollSnapIndexForAxisAndOffset(ScrollEventAxis, int);
     153    ScrollSnapAnimatorState& scrollSnapPointState(ScrollEventAxis);
     154    const ScrollSnapAnimatorState& scrollSnapPointState(ScrollEventAxis) const;
     155#if PLATFORM(MAC)
    143156    void horizontalScrollSnapTimerFired();
    144157    void verticalScrollSnapTimerFired();
     
    146159    void stopScrollSnapTimer(ScrollEventAxis);
    147160
    148     LayoutUnit scrollOffsetOnAxis(ScrollEventAxis) const;
    149161    void processWheelEventForScrollSnapOnAxis(ScrollEventAxis, const PlatformWheelEvent&);
    150162    bool shouldOverrideWheelEvent(ScrollEventAxis, const PlatformWheelEvent&) const;
    151     void setNearestScrollSnapIndexForAxisAndOffset(ScrollEventAxis, int);
    152163
    153164    void beginScrollSnapAnimation(ScrollEventAxis, ScrollSnapState);
     
    158169    float computeSnapDelta(ScrollEventAxis) const;
    159170    float computeGlideDelta(ScrollEventAxis) const;
    160 
    161     ScrollSnapAnimatorState& scrollSnapPointState(ScrollEventAxis);
    162     const ScrollSnapAnimatorState& scrollSnapPointState(ScrollEventAxis) const;
     171#endif
    163172#endif
    164173
    165174    ScrollControllerClient& m_client;
    166175   
    167     CFTimeInterval m_lastMomentumScrollTimestamp;
     176    CFTimeInterval m_lastMomentumScrollTimestamp { 0 };
    168177    FloatSize m_overflowScrollDelta;
    169178    FloatSize m_stretchScrollForce;
    170179    FloatSize m_momentumVelocity;
    171180
     181#if ENABLE(RUBBER_BANDING)
    172182    // Rubber band state.
    173     CFTimeInterval m_startTime;
     183    CFTimeInterval m_startTime { 0 };
    174184    FloatSize m_startStretch;
    175185    FloatPoint m_origOrigin;
    176186    FloatSize m_origVelocity;
    177187    RunLoop::Timer<ScrollController> m_snapRubberbandTimer;
    178 
    179 #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
    180     // FIXME: Find a way to consolidate both timers into one variable.
     188#endif
     189
     190#if ENABLE(CSS_SCROLL_SNAP)
    181191    std::unique_ptr<ScrollSnapAnimatorState> m_horizontalScrollSnapState;
    182192    std::unique_ptr<ScrollSnapAnimatorState> m_verticalScrollSnapState;
     193#if PLATFORM(MAC)
     194    // FIXME: Find a way to consolidate both timers into one variable.
    183195    RunLoop::Timer<ScrollController> m_horizontalScrollSnapTimer;
    184196    RunLoop::Timer<ScrollController> m_verticalScrollSnapTimer;
     197#endif
    185198#endif
    186199
  • trunk/Source/WebCore/platform/cocoa/ScrollController.mm

    r185681 r185762  
    3939#endif
    4040
    41 #if ENABLE(RUBBER_BANDING)
    42 
     41#if ENABLE(RUBBER_BANDING) || ENABLE(CSS_SCROLL_SNAP)
     42
     43#if PLATFORM(MAC)
    4344static NSTimeInterval systemUptime()
    4445{
     
    6364    return 0;
    6465}
    65 
     66#endif
    6667
    6768namespace WebCore {
    6869
     70#if ENABLE(RUBBER_BANDING)
    6971static const float scrollVelocityZeroingTimeout = 0.10f;
    7072static const float rubberbandDirectionLockStretchRatio = 1;
    7173static const float rubberbandMinimumRequiredDeltaBeforeStretch = 10;
     74#endif
    7275
    7376#if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
     
    8689#endif
    8790
     91#if PLATFORM(MAC)
    8892enum class WheelEventStatus {
    8993    UserScrollBegin,
     
    122126    return multiplier;
    123127}
     128#endif
    124129
    125130ScrollController::ScrollController(ScrollControllerClient& client)
    126131    : m_client(client)
    127     , m_lastMomentumScrollTimestamp(0)
    128     , m_startTime(0)
     132#if ENABLE(RUBBER_BANDING)
    129133    , m_snapRubberbandTimer(RunLoop::current(), this, &ScrollController::snapRubberBandTimerFired)
     134#endif
    130135#if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
    131136    , m_horizontalScrollSnapTimer(RunLoop::current(), this, &ScrollController::horizontalScrollSnapTimerFired)
     
    135140}
    136141
     142#if PLATFORM(MAC)
    137143bool ScrollController::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
    138144{
    139 #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
     145#if ENABLE(CSS_SCROLL_SNAP)
    140146    if (!processWheelEventForScrollSnap(wheelEvent))
    141147        return false;
     
    321327    return true;
    322328}
    323 
     329#endif
     330
     331#if ENABLE(RUBBER_BANDING)
    324332static inline float roundTowardZero(float num)
    325333{
     
    397405    }
    398406}
     407#endif
    399408
    400409bool ScrollController::isRubberBandInProgress() const
    401410{
     411#if ENABLE(RUBBER_BANDING) && PLATFORM(MAC)
    402412    if (!m_inScrollGesture && !m_momentumScrollInProgress && !m_snapRubberbandTimerIsActive)
    403413        return false;
    404414
    405415    return !m_client.stretchAmount().isZero();
     416#else
     417    return false;
     418#endif
    406419}
    407420
     
    415428}
    416429
     430#if ENABLE(RUBBER_BANDING)
    417431void ScrollController::startSnapRubberbandTimer()
    418432{
     
    461475    return true;
    462476}
    463 
    464 #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
     477#endif
     478
     479#if ENABLE(CSS_SCROLL_SNAP)
    465480ScrollSnapAnimatorState& ScrollController::scrollSnapPointState(ScrollEventAxis axis)
    466481{
     
    479494}
    480495
     496#if PLATFORM(MAC)
    481497bool ScrollController::hasActiveScrollSnapTimerForAxis(ScrollEventAxis axis) const
    482498{
     
    598614    return true;
    599615}
    600 
    601 void ScrollController::updateScrollAnimatorsAndTimers(const ScrollableArea& scrollableArea)
     616#endif
     617
     618void ScrollController::updateScrollSnapState(const ScrollableArea& scrollableArea)
    602619{
    603620    // FIXME: Currently, scroll snap animators are recreated even though the snap offsets alone can be updated.
     
    623640}
    624641
     642#if PLATFORM(MAC)
    625643void ScrollController::startScrollSnapTimer(ScrollEventAxis axis)
    626644{
     
    700718    snapState.m_glidePhaseShift = acos((snapState.m_glideInitialWheelDelta - targetFinalWheelDelta) / (snapState.m_glideInitialWheelDelta + targetFinalWheelDelta));
    701719}
     720#endif
    702721
    703722unsigned ScrollController::activeScrollSnapIndexForAxis(ScrollEventAxis axis) const
     
    746765}
    747766
     767#if PLATFORM(MAC)
    748768void ScrollController::beginScrollSnapAnimation(ScrollEventAxis axis, ScrollSnapState newState)
    749769{
     
    887907}
    888908#endif
     909#endif
    889910
    890911} // namespace WebCore
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r185288 r185762  
    39343934            if (const Vector<LayoutUnit>* offsets = layer.verticalSnapOffsets())
    39353935                scrollingGeometry.verticalSnapOffsets = *offsets;
     3936            scrollingGeometry.currentHorizontalSnapPointIndex = layer.currentHorizontalSnapPointIndex();
     3937            scrollingGeometry.currentVerticalSnapPointIndex = layer.currentVerticalSnapPointIndex();
    39363938#endif
    39373939            scrollingCoordinator->updateOverflowScrollingNode(nodeID, backing->scrollingLayer(), backing->scrollingContentsLayer(), &scrollingGeometry);
  • trunk/Source/WebKit2/ChangeLog

    r185760 r185762  
     12015-06-18  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [iOS] scrollIntoViewIfNeeded is not working with scroll-snap points
     4        https://bugs.webkit.org/show_bug.cgi?id=145318
     5        <rdar://problem/21081501>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp:
     10        (ArgumentCoder<ScrollingStateScrollingNode>::encode): Handle scroll snap point offset indices.
     11        (ArgumentCoder<ScrollingStateScrollingNode>::decode): Ditto.
     12        * UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp:
     13        (WebKit::RemoteScrollingCoordinatorProxy::currentSnapPointIndicesDidChange): Added. Send message
     14        to WebProcess when scroll snap indices have changed.
     15        * UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h:
     16        * UIProcess/Scrolling/RemoteScrollingTree.cpp:
     17        (WebKit::RemoteScrollingTree::currentSnapPointIndicesDidChange): Added. Notify the
     18        RemoteScrollingCoordinatorProxy when scroll snap indices have changed.
     19        * UIProcess/Scrolling/RemoteScrollingTree.h:
     20        * UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.h:
     21        * UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:
     22        (-[WKOverflowScrollViewDelegate scrollViewWillEndDragging:withVelocity:targetContentOffset:]): Revised.
     23        Identify changes in the current scroll snap point offset index (in either the horizontal or vertical
     24        directions), and send a notification when this happens.
     25        (WebKit::ScrollingTreeOverflowScrollingNodeIOS::currentSnapPointIndicesDidChange): Added. Notify the
     26        Scrolling Tree when indices changed.
     27        * UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm:
     28        (WebKit::RemoteScrollingCoordinatorProxy::adjustTargetContentOffsetForSnapping): Revised. Always compute
     29        the new scroll snap offset index (even when we will rubber band).
     30        * WebProcess/Scrolling/RemoteScrollingCoordinator.h:
     31        * WebProcess/Scrolling/RemoteScrollingCoordinator.messages.in: Add a new message to relay changes in scroll
     32        snap index.
     33        * WebProcess/Scrolling/RemoteScrollingCoordinator.mm:
     34        (WebKit::RemoteScrollingCoordinator::currentSnapPointIndicesChangedForNode): Added.
     35
    1362015-06-19  Jeremy Jones  <jeremyj@apple.com>
    237
  • trunk/Source/WebKit2/Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp

    r183655 r185762  
    132132    SCROLLING_NODE_ENCODE(ScrollingStateScrollingNode::HorizontalSnapOffsets, horizontalSnapOffsets)
    133133    SCROLLING_NODE_ENCODE(ScrollingStateScrollingNode::VerticalSnapOffsets, verticalSnapOffsets)
     134    SCROLLING_NODE_ENCODE(ScrollingStateScrollingNode::CurrentHorizontalSnapOffsetIndex, currentHorizontalSnapPointIndex)
     135    SCROLLING_NODE_ENCODE(ScrollingStateScrollingNode::CurrentVerticalSnapOffsetIndex, currentVerticalSnapPointIndex)
    134136#endif
    135137    SCROLLING_NODE_ENCODE(ScrollingStateScrollingNode::ScrollableAreaParams, scrollableAreaParameters)
     
    201203    SCROLLING_NODE_DECODE(ScrollingStateScrollingNode::HorizontalSnapOffsets, Vector<float>, setHorizontalSnapOffsets);
    202204    SCROLLING_NODE_DECODE(ScrollingStateScrollingNode::VerticalSnapOffsets, Vector<float>, setVerticalSnapOffsets);
     205    SCROLLING_NODE_DECODE(ScrollingStateScrollingNode::CurrentHorizontalSnapOffsetIndex, unsigned, setCurrentHorizontalSnapPointIndex);
     206    SCROLLING_NODE_DECODE(ScrollingStateScrollingNode::CurrentVerticalSnapOffsetIndex, unsigned, setCurrentVerticalSnapPointIndex);
    203207#endif
    204208    SCROLLING_NODE_DECODE(ScrollingStateScrollingNode::ScrollableAreaParams, ScrollableAreaParameters, setScrollableAreaParameters);
  • trunk/Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp

    r177835 r185762  
    160160}
    161161
     162void RemoteScrollingCoordinatorProxy::currentSnapPointIndicesDidChange(WebCore::ScrollingNodeID nodeID, unsigned horizontal, unsigned vertical)
     163{
     164    m_webPageProxy.send(Messages::RemoteScrollingCoordinator::CurrentSnapPointIndicesChangedForNode(nodeID, horizontal, vertical));
     165}
     166
    162167// This comes from the scrolling tree.
    163168void RemoteScrollingCoordinatorProxy::scrollingTreeNodeDidScroll(ScrollingNodeID scrolledNodeID, const FloatPoint& newScrollPosition, SetOrSyncScrollingLayerPosition scrollingLayerPositionAction)
  • trunk/Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h

    r184439 r185762  
    6262    void viewportChangedViaDelegatedScrolling(WebCore::ScrollingNodeID, const WebCore::FloatRect& fixedPositionRect, double scale);
    6363
     64    void currentSnapPointIndicesDidChange(WebCore::ScrollingNodeID, unsigned horizontal, unsigned vertical);
     65
    6466    // FIXME: expose the tree and pass this to that?
    6567    bool handleWheelEvent(const WebCore::PlatformWheelEvent&);
  • trunk/Source/WebKit2/UIProcess/Scrolling/RemoteScrollingTree.cpp

    r171370 r185762  
    135135}
    136136
     137void RemoteScrollingTree::currentSnapPointIndicesDidChange(ScrollingNodeID nodeID, unsigned horizontal, unsigned vertical)
     138{
     139    m_scrollingCoordinatorProxy.currentSnapPointIndicesDidChange(nodeID, horizontal, vertical);
     140}
     141
    137142} // namespace WebKit
    138143
  • trunk/Source/WebKit2/UIProcess/Scrolling/RemoteScrollingTree.h

    r174351 r185762  
    4949    virtual void scrollingTreeNodeDidScroll(WebCore::ScrollingNodeID, const WebCore::FloatPoint& scrollPosition, WebCore::SetOrSyncScrollingLayerPosition = WebCore::SyncScrollingLayerPosition) override;
    5050    virtual void scrollingTreeNodeRequestsScroll(WebCore::ScrollingNodeID, const WebCore::FloatPoint& scrollPosition, bool representsProgrammaticScroll) override;
     51    void currentSnapPointIndicesDidChange(WebCore::ScrollingNodeID, unsigned horizontal, unsigned vertical) override;
    5152
    5253private:
  • trunk/Source/WebKit2/UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.h

    r176915 r185762  
    4545    void overflowScrollViewWillStartPanGesture();
    4646    void scrollViewDidScroll(const WebCore::FloatPoint&, bool inUserInteration);
     47    void currentSnapPointIndicesDidChange(unsigned horizontal, unsigned vertical);
    4748
    4849    CALayer *scrollLayer() const { return m_scrollLayer.get(); }
  • trunk/Source/WebKit2/UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm

    r185681 r185762  
    8484    CGFloat verticalTarget = targetContentOffset->y;
    8585
    86     unsigned ignore;
    87     if (!_scrollingTreeNode->horizontalSnapOffsets().isEmpty() && horizontalTarget >= 0 && horizontalTarget <= scrollView.contentSize.width)
    88         targetContentOffset->x = closestSnapOffset<float, CGFloat>(_scrollingTreeNode->horizontalSnapOffsets(), horizontalTarget, velocity.x, ignore);
    89     if (!_scrollingTreeNode->verticalSnapOffsets().isEmpty() && verticalTarget >= 0 && verticalTarget <= scrollView.contentSize.height)
    90         targetContentOffset->y = closestSnapOffset<float, CGFloat>(_scrollingTreeNode->verticalSnapOffsets(), verticalTarget, velocity.y, ignore);
     86    unsigned originalHorizontalSnapPosition = _scrollingTreeNode->currentHorizontalSnapPointIndex();
     87    unsigned originalVerticalSnapPosition = _scrollingTreeNode->currentVerticalSnapPointIndex();
     88
     89    if (!_scrollingTreeNode->horizontalSnapOffsets().isEmpty()) {
     90        unsigned index;
     91        float potentialSnapPosition = closestSnapOffset<float, CGFloat>(_scrollingTreeNode->horizontalSnapOffsets(), horizontalTarget, velocity.x, index);
     92        _scrollingTreeNode->setCurrentHorizontalSnapPointIndex(index);
     93        if (horizontalTarget >= 0 && horizontalTarget <= scrollView.contentSize.width)
     94            targetContentOffset->x = potentialSnapPosition;
     95    }
     96
     97    if (!_scrollingTreeNode->verticalSnapOffsets().isEmpty()) {
     98        unsigned index;
     99        float potentialSnapPosition = closestSnapOffset<float, CGFloat>(_scrollingTreeNode->verticalSnapOffsets(), verticalTarget, velocity.y, index);
     100        _scrollingTreeNode->setCurrentVerticalSnapPointIndex(index);
     101        if (verticalTarget >= 0 && verticalTarget <= scrollView.contentSize.height)
     102            targetContentOffset->y = potentialSnapPosition;
     103    }
     104
     105    if (originalHorizontalSnapPosition != _scrollingTreeNode->currentHorizontalSnapPointIndex()
     106        || originalVerticalSnapPosition != _scrollingTreeNode->currentVerticalSnapPointIndex()) {
     107        _scrollingTreeNode->currentSnapPointIndicesDidChange(_scrollingTreeNode->currentHorizontalSnapPointIndex(), _scrollingTreeNode->currentVerticalSnapPointIndex());
     108    }
    91109}
    92110#endif
     
    284302}
    285303
     304void ScrollingTreeOverflowScrollingNodeIOS::currentSnapPointIndicesDidChange(unsigned horizontal, unsigned vertical)
     305{
     306    if (m_updatingFromStateNode)
     307        return;
     308   
     309    scrollingTree().currentSnapPointIndicesDidChange(scrollingNodeID(), horizontal, vertical);
     310}
     311
    286312} // namespace WebCore
    287313
  • trunk/Source/WebKit2/UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm

    r184439 r185762  
    117117{
    118118    // The bounds checking with maxScrollOffsets is to ensure that we won't interfere with rubber-banding when scrolling to the edge of the page.
    119     if (shouldSnapForMainFrameScrolling(WebCore::ScrollEventAxis::Horizontal) && targetContentOffset->x > 0 && targetContentOffset->x < maxScrollOffsets.width) {
     119    if (shouldSnapForMainFrameScrolling(WebCore::ScrollEventAxis::Horizontal)) {
    120120        float potentialSnapPosition = closestSnapOffsetForMainFrameScrolling(WebCore::ScrollEventAxis::Horizontal, targetContentOffset->x, velocity.x, m_currentHorizontalSnapPointIndex);
    121         targetContentOffset->x = std::min<float>(maxScrollOffsets.width, potentialSnapPosition);
    122     }
    123 
    124     if (shouldSnapForMainFrameScrolling(WebCore::ScrollEventAxis::Vertical) && targetContentOffset->y > 0 && targetContentOffset->y < maxScrollOffsets.height) {
     121        if (targetContentOffset->x > 0 && targetContentOffset->x < maxScrollOffsets.width)
     122            targetContentOffset->x = std::min<float>(maxScrollOffsets.width, potentialSnapPosition);
     123    }
     124
     125    if (shouldSnapForMainFrameScrolling(WebCore::ScrollEventAxis::Vertical)) {
    125126        float potentialSnapPosition = closestSnapOffsetForMainFrameScrolling(WebCore::ScrollEventAxis::Vertical, targetContentOffset->y, velocity.y, m_currentVerticalSnapPointIndex);
    126127        potentialSnapPosition -= topInset;
    127         targetContentOffset->y = std::min<float>(maxScrollOffsets.height, potentialSnapPosition);
     128        if (targetContentOffset->y > 0 && targetContentOffset->y < maxScrollOffsets.height)
     129            targetContentOffset->y = std::min<float>(maxScrollOffsets.height, potentialSnapPosition);
    128130    }
    129131}
  • trunk/Source/WebKit2/WebProcess/Scrolling/RemoteScrollingCoordinator.h

    r184596 r185762  
    7474    // Respond to UI process changes.
    7575    void scrollPositionChangedForNode(WebCore::ScrollingNodeID, const WebCore::FloatPoint& scrollPosition, bool syncLayerPosition);
     76    void currentSnapPointIndicesChangedForNode(WebCore::ScrollingNodeID, unsigned horizontal, unsigned vertical);
    7677
    7778    WebPage* m_webPage;
  • trunk/Source/WebKit2/WebProcess/Scrolling/RemoteScrollingCoordinator.messages.in

    r168338 r185762  
    1 # Copyright (C) 2014 Apple Inc. All rights reserved.
     1# Copyright (C) 2014-2015 Apple Inc. All rights reserved.
    22#
    33# Redistribution and use in source and binary forms, with or without
     
    2525messages -> RemoteScrollingCoordinator {
    2626    ScrollPositionChangedForNode(uint64_t nodeID, WebCore::FloatPoint scrollPosition, bool syncLayerPosition);
     27    CurrentSnapPointIndicesChangedForNode(uint64_t nodeID, unsigned horizontal, unsigned vertical);
    2728}
    2829
  • trunk/Source/WebKit2/WebProcess/Scrolling/RemoteScrollingCoordinator.mm

    r184596 r185762  
    103103}
    104104
     105void RemoteScrollingCoordinator::currentSnapPointIndicesChangedForNode(ScrollingNodeID nodeID, unsigned horizontal, unsigned vertical)
     106{
     107    setActiveScrollSnapIndices(nodeID, horizontal, vertical);
     108}
     109
    105110} // namespace WebKit
    106111
Note: See TracChangeset for help on using the changeset viewer.