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

Changeset 185681 in webkit


Ignore:
Timestamp:
Jun 17, 2015, 5:32:33 PM (11 years ago)
Author:
Brent Fulgham
Message:

Overflow regions with scroll snap points are not reliably rubber banding
https://bugs.webkit.org/show_bug.cgi?id=142522
<rdar://problem/20100726>

Reviewed by Darin Adler.

Source/WebCore:

When computing the target scroll destination, update the nearest snap point index
and other bookkeeping, but keep the original gesture target if it would have taken
us beyond either limit of the scroll container.

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

(WebCore::ScrollingTreeFrameScrollingNodeMac::scrollExtents): Add new method
to support client API.

  • platform/ScrollAnimator.cpp:

(WebCore::ScrollAnimator::scrollExtents): Add new method to support client API.

  • platform/ScrollAnimator.h:
  • platform/cocoa/ScrollController.h:

(WebCore::ScrollControllerClient::scrollExtents): Added new pure virtual method to API.

  • platform/cocoa/ScrollController.mm:

(WebCore::ScrollController::beginScrollSnapAnimation): Hold onto original user gesture
target, and use that instead of our nearest snap point if the gesture takes us past
either extreme of the scroll container.

Source/WebKit2:

Make sure we don't block rubberbanding behavior when a scroll gesture should take us past
the end of the scroll container.

  • UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:

(-[WKOverflowScrollViewDelegate scrollViewWillEndDragging:withVelocity:targetContentOffset:]): Don't adjust
target point if we were going to scroll past the edges of the scroll container.

Location:
trunk/Source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r185679 r185681  
     12015-06-17  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Overflow regions with scroll snap points are not reliably rubber banding
     4        https://bugs.webkit.org/show_bug.cgi?id=142522
     5        <rdar://problem/20100726>
     6
     7        Reviewed by Darin Adler.
     8
     9        When computing the target scroll destination, update the nearest snap point index
     10        and other bookkeeping, but keep the original gesture target if it would have taken
     11        us beyond either limit of the scroll container.
     12
     13        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h:
     14        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
     15        (WebCore::ScrollingTreeFrameScrollingNodeMac::scrollExtents): Add new method
     16        to support client API.
     17        * platform/ScrollAnimator.cpp:
     18        (WebCore::ScrollAnimator::scrollExtents): Add new method to support client API.
     19        * platform/ScrollAnimator.h:
     20        * platform/cocoa/ScrollController.h:
     21        (WebCore::ScrollControllerClient::scrollExtents): Added new pure virtual method to API.
     22        * platform/cocoa/ScrollController.mm:
     23        (WebCore::ScrollController::beginScrollSnapAnimation): Hold onto original user gesture
     24        target, and use that instead of our nearest snap point if the gesture takes us past
     25        either extreme of the scroll container.
     26
    1272015-06-17  Tim Horton  <timothy_horton@apple.com>
    228
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h

    r184596 r185681  
    8989    void startScrollSnapTimer(ScrollEventAxis) override;
    9090    void stopScrollSnapTimer(ScrollEventAxis) override;
     91    LayoutSize scrollExtent() const override;
    9192#endif
    9293
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm

    r184596 r185681  
    3030
    3131#import "FrameView.h"
     32#import "LayoutSize.h"
    3233#import "Logging.h"
    3334#import "NSScrollerImpDetails.h"
     
    588589        scrollingTree().setMainFrameIsScrollSnapping(false);
    589590}
     591   
     592LayoutSize ScrollingTreeFrameScrollingNodeMac::scrollExtent() const
     593{
     594    return LayoutSize(totalContentsSize());
     595}
    590596#endif
    591597
  • trunk/Source/WebCore/platform/ScrollAnimator.cpp

    r184728 r185681  
    3434
    3535#include "FloatPoint.h"
     36#include "LayoutSize.h"
    3637#include "PlatformWheelEvent.h"
    3738#include "ScrollableArea.h"
     
    214215        scrollToOffsetWithoutAnimation(FloatPoint(currentPosition.x(), currentPosition.y() + delta));
    215216}
     217
     218LayoutSize ScrollAnimator::scrollExtent() const
     219{
     220    return m_scrollableArea.contentsSize();
     221}
    216222#endif
    217223
  • trunk/Source/WebCore/platform/ScrollAnimator.h

    r185431 r185681  
    136136    bool activeScrollSnapIndexDidChange() const;
    137137    unsigned activeScrollSnapIndexForAxis(ScrollEventAxis) const;
     138    LayoutSize scrollExtent() const override;
    138139#endif
    139140
  • trunk/Source/WebCore/platform/cocoa/ScrollController.h

    r184728 r185681  
    4242namespace WebCore {
    4343
     44class LayoutSize;
    4445class PlatformWheelEvent;
    4546class ScrollableArea;
     
    103104        return 0;
    104105    }
     106
     107    virtual LayoutSize scrollExtent() const = 0;
    105108#endif
    106109};
  • trunk/Source/WebCore/platform/cocoa/ScrollController.mm

    r184728 r185681  
    2727#include "ScrollController.h"
    2828
     29#include "LayoutSize.h"
    2930#include "PlatformWheelEvent.h"
    3031#include "WebCoreSystemInterface.h"
     
    753754    LayoutUnit offset = m_client.scrollOffsetOnAxis(axis);
    754755    float initialWheelDelta = newState == ScrollSnapState::Gliding ? snapState.averageInitialWheelDelta() : 0;
    755     LayoutUnit projectedScrollDestination = newState == ScrollSnapState::Gliding ? snapState.m_beginTrackingWheelDeltaOffset + LayoutUnit(projectedInertialScrollDistance(initialWheelDelta)) : offset;
     756    LayoutUnit scaledProjectedScrollDestination = newState == ScrollSnapState::Gliding ? snapState.m_beginTrackingWheelDeltaOffset + LayoutUnit(projectedInertialScrollDistance(initialWheelDelta)) : offset;
    756757    if (snapState.m_snapOffsets.isEmpty())
    757758        return;
    758759
    759760    float scaleFactor = m_client.pageScaleFactor();
    760    
    761     projectedScrollDestination = std::min(std::max(LayoutUnit(projectedScrollDestination / scaleFactor), snapState.m_snapOffsets.first()), snapState.m_snapOffsets.last());
     761    LayoutUnit originalProjectedScrollDestination = scaledProjectedScrollDestination / scaleFactor;
     762   
     763    LayoutUnit clampedScrollDestination = std::min(std::max(originalProjectedScrollDestination, snapState.m_snapOffsets.first()), snapState.m_snapOffsets.last());
    762764    snapState.m_initialOffset = offset;
    763765    m_activeScrollSnapIndexDidChange = false;
    764     snapState.m_targetOffset = scaleFactor * closestSnapOffset<LayoutUnit, float>(snapState.m_snapOffsets, projectedScrollDestination, initialWheelDelta, snapState.m_activeSnapIndex);
     766    snapState.m_targetOffset = scaleFactor * closestSnapOffset<LayoutUnit, float>(snapState.m_snapOffsets, clampedScrollDestination, initialWheelDelta, snapState.m_activeSnapIndex);
    765767    if (snapState.m_initialOffset == snapState.m_targetOffset)
    766768        return;
     769
     770    LayoutUnit scrollExtent = (axis == ScrollEventAxis::Horizontal) ? m_client.scrollExtent().width() : m_client.scrollExtent().height();
     771    LayoutUnit projectedScrollDestination = clampedScrollDestination;
     772    if (originalProjectedScrollDestination < 0 || originalProjectedScrollDestination > scrollExtent)
     773        projectedScrollDestination = originalProjectedScrollDestination;
    767774   
    768775    m_activeScrollSnapIndexDidChange = true;
  • trunk/Source/WebKit2/ChangeLog

    r185680 r185681  
     12015-06-17  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Overflow regions with scroll snap points are not reliably rubber banding
     4        https://bugs.webkit.org/show_bug.cgi?id=142522
     5        <rdar://problem/20100726>
     6
     7        Reviewed by Darin Adler.
     8
     9        Make sure we don't block rubberbanding behavior when a scroll gesture should take us past
     10        the end of the scroll container.
     11
     12        * UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:
     13        (-[WKOverflowScrollViewDelegate scrollViewWillEndDragging:withVelocity:targetContentOffset:]): Don't adjust
     14        target point if we were going to scroll past the edges of the scroll container.
     15
    1162015-06-17  Anders Carlsson  <andersca@apple.com>
    217
  • trunk/Source/WebKit2/UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm

    r184139 r185681  
    8181- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
    8282{
     83    CGFloat horizontalTarget = targetContentOffset->x;
     84    CGFloat verticalTarget = targetContentOffset->y;
     85
    8386    unsigned ignore;
    84     if (!_scrollingTreeNode->horizontalSnapOffsets().isEmpty())
    85         targetContentOffset->x = closestSnapOffset<float, CGFloat>(_scrollingTreeNode->horizontalSnapOffsets(), targetContentOffset->x, velocity.x, ignore);
    86     if (!_scrollingTreeNode->verticalSnapOffsets().isEmpty())
    87         targetContentOffset->y = closestSnapOffset<float, CGFloat>(_scrollingTreeNode->verticalSnapOffsets(), targetContentOffset->y, velocity.y, 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);
    8891}
    8992#endif
Note: See TracChangeset for help on using the changeset viewer.