Changeset 224260 in webkit


Ignore:
Timestamp:
Oct 31, 2017 4:26:52 PM (6 years ago)
Author:
Simon Fraser
Message:

Make it possible to test rubber-banding in overflow scroll
https://bugs.webkit.org/show_bug.cgi?id=179078

Reviewed by Sam Weinig.

Source/WebCore:

Test: fast/scrolling/unconstrained-scrollto.html

Add internals.unconstrainedScrollTo(element, x, y) and plumb through ScrollClamping
(which replaces RenderLayer::ScrollOffsetClamping) to support it.

Flip the default from unclamped to clamped for various RenderLayer scrolling-related
functions, since most callers want clamped.

  • accessibility/AccessibilityRenderObject.cpp:

(WebCore::AccessibilityRenderObject::scrollTo const):

  • dom/Element.cpp:

(WebCore::Element::scrollTo):

  • dom/Element.h:
  • html/HTMLBodyElement.cpp:

(WebCore::HTMLBodyElement::scrollTo):

  • html/HTMLBodyElement.h:
  • html/TextFieldInputType.cpp:

(WebCore::TextFieldInputType::elementDidBlur):

  • page/DOMWindow.cpp:

(WebCore::DOMWindow::scrollTo const):

  • page/DOMWindow.h:
  • page/Frame.cpp:

(WebCore::Frame::scrollOverflowLayer):
(WebCore::Frame::checkOverflowScroll):

  • platform/ScrollAnimator.cpp:

(WebCore::ScrollAnimator::scrollToOffsetWithoutAnimation):

  • platform/ScrollAnimator.h:
  • platform/ScrollTypes.h:
  • platform/ScrollableArea.cpp:

(WebCore::ScrollableArea::scrollToOffsetWithoutAnimation):

  • platform/ScrollableArea.h:
  • platform/cocoa/ScrollController.h:
  • platform/mac/ScrollAnimatorMac.h:
  • platform/mac/ScrollAnimatorMac.mm:

(WebCore::ScrollAnimatorMac::scrollToOffsetWithoutAnimation):
(WebCore::ScrollAnimatorMac::immediateScrollToPosition):

  • platform/mock/ScrollAnimatorMock.h:
  • rendering/RenderBox.cpp:

(WebCore::RenderBox::setScrollLeft):
(WebCore::RenderBox::setScrollTop):

  • rendering/RenderBox.h:
  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::panScrollFromPoint):
(WebCore::RenderLayer::scrollByRecursively):
(WebCore::RenderLayer::applyPostLayoutScrollPositionIfNeeded):
(WebCore::RenderLayer::scrollToXPosition):
(WebCore::RenderLayer::scrollToYPosition):
(WebCore::RenderLayer::scrollToOffset):

  • rendering/RenderLayer.h:
  • rendering/RenderListBox.cpp:

(WebCore::RenderListBox::setScrollLeft):
(WebCore::RenderListBox::setScrollTop):

  • rendering/RenderListBox.h:
  • rendering/RenderTextControlSingleLine.cpp:

(WebCore::RenderTextControlSingleLine::setScrollLeft):
(WebCore::RenderTextControlSingleLine::setScrollTop):

  • rendering/RenderTextControlSingleLine.h:
  • testing/Internals.cpp:

(WebCore::Internals::unconstrainedScrollTo):

  • testing/Internals.h:
  • testing/Internals.idl:

Source/WebKitLegacy/mac:

Add internals.unconstrainedScrollTo(element, x, y) and plumb through ScrollClamping
(which replaces RenderLayer::ScrollOffsetClamping) to support it.

Flip the default from unclamped to clamped for various RenderLayer scrolling-related
functions, since most callers want clamped.

  • DOM/DOMHTML.mm:

(-[DOMHTMLElement setScrollXOffset:scrollYOffset:adjustForIOSCaret:]):

LayoutTests:

Test that internals.unconstrainedScrollTo() works.

  • fast/scrolling/unconstrained-scrollto-expected.txt: Added.
  • fast/scrolling/unconstrained-scrollto.html: Added.
Location:
trunk
Files:
2 added
37 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r224250 r224260  
     12017-10-31  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Make it possible to test rubber-banding in overflow scroll
     4        https://bugs.webkit.org/show_bug.cgi?id=179078
     5
     6        Reviewed by Sam Weinig.
     7
     8        Test that internals.unconstrainedScrollTo() works.
     9
     10        * fast/scrolling/unconstrained-scrollto-expected.txt: Added.
     11        * fast/scrolling/unconstrained-scrollto.html: Added.
     12
    1132017-10-31  Youenn Fablet  <youenn@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r224255 r224260  
     12017-10-31  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Make it possible to test rubber-banding in overflow scroll
     4        https://bugs.webkit.org/show_bug.cgi?id=179078
     5
     6        Reviewed by Sam Weinig.
     7
     8        Test: fast/scrolling/unconstrained-scrollto.html
     9       
     10        Add internals.unconstrainedScrollTo(element, x, y) and plumb through ScrollClamping
     11        (which replaces RenderLayer::ScrollOffsetClamping) to support it.
     12
     13        Flip the default from unclamped to clamped for various RenderLayer scrolling-related
     14        functions, since most callers want clamped.
     15
     16        * accessibility/AccessibilityRenderObject.cpp:
     17        (WebCore::AccessibilityRenderObject::scrollTo const):
     18        * dom/Element.cpp:
     19        (WebCore::Element::scrollTo):
     20        * dom/Element.h:
     21        * html/HTMLBodyElement.cpp:
     22        (WebCore::HTMLBodyElement::scrollTo):
     23        * html/HTMLBodyElement.h:
     24        * html/TextFieldInputType.cpp:
     25        (WebCore::TextFieldInputType::elementDidBlur):
     26        * page/DOMWindow.cpp:
     27        (WebCore::DOMWindow::scrollTo const):
     28        * page/DOMWindow.h:
     29        * page/Frame.cpp:
     30        (WebCore::Frame::scrollOverflowLayer):
     31        (WebCore::Frame::checkOverflowScroll):
     32        * platform/ScrollAnimator.cpp:
     33        (WebCore::ScrollAnimator::scrollToOffsetWithoutAnimation):
     34        * platform/ScrollAnimator.h:
     35        * platform/ScrollTypes.h:
     36        * platform/ScrollableArea.cpp:
     37        (WebCore::ScrollableArea::scrollToOffsetWithoutAnimation):
     38        * platform/ScrollableArea.h:
     39        * platform/cocoa/ScrollController.h:
     40        * platform/mac/ScrollAnimatorMac.h:
     41        * platform/mac/ScrollAnimatorMac.mm:
     42        (WebCore::ScrollAnimatorMac::scrollToOffsetWithoutAnimation):
     43        (WebCore::ScrollAnimatorMac::immediateScrollToPosition):
     44        * platform/mock/ScrollAnimatorMock.h:
     45        * rendering/RenderBox.cpp:
     46        (WebCore::RenderBox::setScrollLeft):
     47        (WebCore::RenderBox::setScrollTop):
     48        * rendering/RenderBox.h:
     49        * rendering/RenderLayer.cpp:
     50        (WebCore::RenderLayer::panScrollFromPoint):
     51        (WebCore::RenderLayer::scrollByRecursively):
     52        (WebCore::RenderLayer::applyPostLayoutScrollPositionIfNeeded):
     53        (WebCore::RenderLayer::scrollToXPosition):
     54        (WebCore::RenderLayer::scrollToYPosition):
     55        (WebCore::RenderLayer::scrollToOffset):
     56        * rendering/RenderLayer.h:
     57        * rendering/RenderListBox.cpp:
     58        (WebCore::RenderListBox::setScrollLeft):
     59        (WebCore::RenderListBox::setScrollTop):
     60        * rendering/RenderListBox.h:
     61        * rendering/RenderTextControlSingleLine.cpp:
     62        (WebCore::RenderTextControlSingleLine::setScrollLeft):
     63        (WebCore::RenderTextControlSingleLine::setScrollTop):
     64        * rendering/RenderTextControlSingleLine.h:
     65        * testing/Internals.cpp:
     66        (WebCore::Internals::unconstrainedScrollTo):
     67        * testing/Internals.h:
     68        * testing/Internals.idl:
     69
    1702017-10-31  Dean Jackson  <dino@apple.com>
    271
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp

    r224213 r224260  
    37233723
    37243724    // FIXME: is point a ScrollOffset or ScrollPosition? Test in RTL overflow.
    3725     box.layer()->scrollToOffset(point, RenderLayer::ScrollOffsetClamped);
     3725    box.layer()->scrollToOffset(point);
    37263726}
    37273727
  • trunk/Source/WebCore/dom/Element.cpp

    r224213 r224260  
    704704}
    705705
    706 void Element::scrollTo(const ScrollToOptions& options)
     706void Element::scrollTo(const ScrollToOptions& options, ScrollClamping clamping)
    707707{
    708708    // If the element is the root element and document is in quirks mode, terminate these steps.
     
    723723    double y = options.top ? normalizeNonFiniteValue(options.top.value()) : adjustForAbsoluteZoom(renderer->scrollTop(), *renderer);
    724724
    725     renderer->setScrollLeft(clampToInteger(x * renderer->style().effectiveZoom()));
    726     renderer->setScrollTop(clampToInteger(y * renderer->style().effectiveZoom()));
     725    renderer->setScrollLeft(clampToInteger(x * renderer->style().effectiveZoom()), clamping);
     726    renderer->setScrollTop(clampToInteger(y * renderer->style().effectiveZoom()), clamping);
    727727}
    728728
  • trunk/Source/WebCore/dom/Element.h

    r224053 r224260  
    138138    void scrollBy(const ScrollToOptions&);
    139139    void scrollBy(double x, double y);
    140     virtual void scrollTo(const ScrollToOptions&);
     140    virtual void scrollTo(const ScrollToOptions&, ScrollClamping = ScrollClamping::Clamped);
    141141    void scrollTo(double x, double y);
    142142
  • trunk/Source/WebCore/html/HTMLBodyElement.cpp

    r224213 r224260  
    300300}
    301301
    302 void HTMLBodyElement::scrollTo(const ScrollToOptions& options)
     302void HTMLBodyElement::scrollTo(const ScrollToOptions& options, ScrollClamping clamping)
    303303{
    304304    if (isFirstBodyElementOfDocument()) {
     
    314314        return;
    315315    }
    316     return HTMLElement::scrollTo(options);
     316    return HTMLElement::scrollTo(options, clamping);
    317317}
    318318
  • trunk/Source/WebCore/html/HTMLBodyElement.h

    r223802 r224260  
    5858    void setScrollTop(int) final;
    5959
    60     void scrollTo(const ScrollToOptions&) final;
     60    void scrollTo(const ScrollToOptions&, ScrollClamping) final;
    6161   
    6262    int scrollHeight() final;
  • trunk/Source/WebCore/html/TextFieldInputType.cpp

    r223644 r224260  
    213213    bool isLeftToRightDirection = downcast<RenderTextControlSingleLine>(*renderer).style().isLeftToRightDirection();
    214214    ScrollOffset scrollOffset(isLeftToRightDirection ? 0 : innerLayer->scrollWidth(), 0);
    215     innerLayer->scrollToOffset(scrollOffset, RenderLayer::ScrollOffsetClamped);
     215    innerLayer->scrollToOffset(scrollOffset);
    216216}
    217217
  • trunk/Source/WebCore/page/DOMWindow.cpp

    r224236 r224260  
    15521552}
    15531553
    1554 void DOMWindow::scrollTo(const ScrollToOptions& options) const
     1554void DOMWindow::scrollTo(const ScrollToOptions& options, ScrollClamping clamping) const
    15551555{
    15561556    if (!isCurrentlyDisplayedInFrame())
     
    15631563    double x = options.left ? options.left.value() : view->contentsScrollPosition().x();
    15641564    double y = options.top ? options.top.value() : view->contentsScrollPosition().y();
    1565     return scrollTo(x, y);
    1566 }
    1567 
    1568 void DOMWindow::scrollTo(double x, double y) const
     1565    return scrollTo(x, y, clamping);
     1566}
     1567
     1568void DOMWindow::scrollTo(double x, double y, ScrollClamping) const
    15691569{
    15701570    if (!isCurrentlyDisplayedInFrame())
  • trunk/Source/WebCore/page/DOMWindow.h

    r223775 r224260  
    3434#include "ImageBitmap.h"
    3535#include "ScrollToOptions.h"
     36#include "ScrollTypes.h"
    3637#include "Supplementable.h"
    3738#include <heap/HandleTypes.h>
     
    233234    void scrollBy(const ScrollToOptions&) const;
    234235    void scrollBy(double x, double y) const;
    235     void scrollTo(const ScrollToOptions&) const;
    236     void scrollTo(double x, double y) const;
     236    void scrollTo(const ScrollToOptions&, ScrollClamping = ScrollClamping::Clamped) const;
     237    void scrollTo(double x, double y, ScrollClamping = ScrollClamping::Clamped) const;
    237238
    238239    void moveBy(float x, float y) const;
  • trunk/Source/WebCore/page/Frame.cpp

    r224150 r224260  
    531531        scrollOffset.setY(std::min(box->scrollHeight() - clientHeight, scrollOffset.y() + clientHeight / 2));
    532532
    533     layer->scrollToOffset(scrollOffset);
     533    layer->scrollToOffset(scrollOffset, ScrollClamping::Unclamped);
    534534    selection().setCaretRectNeedsUpdate();
    535535    selection().updateAppearance();
     
    627627
    628628    if (action == PerformOverflowScroll && (deltaX || deltaY)) {
    629         layer->scrollToOffset(layer->scrollOffset() + IntSize(deltaX, deltaY));
     629        layer->scrollToOffset(layer->scrollOffset() + IntSize(deltaX, deltaY), ScrollClamping::Unclamped);
    630630
    631631        // Handle making selection.
  • trunk/Source/WebCore/platform/ScrollAnimator.cpp

    r223728 r224260  
    7676}
    7777
    78 void ScrollAnimator::scrollToOffsetWithoutAnimation(const FloatPoint& offset)
     78void ScrollAnimator::scrollToOffsetWithoutAnimation(const FloatPoint& offset, ScrollClamping)
    7979{
    8080    FloatPoint newPositon = ScrollableArea::scrollPositionFromOffset(offset, toFloatSize(m_scrollableArea.scrollOrigin()));
  • trunk/Source/WebCore/platform/ScrollAnimator.h

    r218799 r224260  
    3030 */
    3131
    32 #ifndef ScrollAnimator_h
    33 #define ScrollAnimator_h
     32#pragma once
    3433
    3534#include "FloatPoint.h"
     
    7069    virtual bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier);
    7170
    72     virtual void scrollToOffsetWithoutAnimation(const FloatPoint&);
     71    virtual void scrollToOffsetWithoutAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped);
    7372
    7473    ScrollableArea& scrollableArea() const { return m_scrollableArea; }
     
    156155} // namespace WebCore
    157156
    158 #endif // ScrollAnimator_h
  • trunk/Source/WebCore/platform/ScrollTypes.h

    r215566 r224260  
    178178};
    179179
     180enum class ScrollClamping {
     181    Unclamped,
     182    Clamped
     183};
     184
    180185enum ScrollBehaviorForFixedElements {
    181186    StickToDocumentBounds,
  • trunk/Source/WebCore/platform/ScrollableArea.cpp

    r223728 r224260  
    140140}
    141141
    142 void ScrollableArea::scrollToOffsetWithoutAnimation(const FloatPoint& offset)
     142void ScrollableArea::scrollToOffsetWithoutAnimation(const FloatPoint& offset, ScrollClamping clamping)
    143143{
    144144    LOG_WITH_STREAM(Scrolling, stream << "ScrollableArea " << this << " scrollToOffsetWithoutAnimation " << offset);
    145     scrollAnimator().scrollToOffsetWithoutAnimation(offset);
     145    scrollAnimator().scrollToOffsetWithoutAnimation(offset, clamping);
    146146}
    147147
  • trunk/Source/WebCore/platform/ScrollableArea.h

    r222422 r224260  
    2727
    2828#include "ScrollSnapOffsetsInfo.h"
     29#include "ScrollTypes.h"
    2930#include "Scrollbar.h"
    3031#include <wtf/Forward.h>
     
    5152public:
    5253    WEBCORE_EXPORT bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1);
    53     WEBCORE_EXPORT void scrollToOffsetWithoutAnimation(const FloatPoint&);
     54    WEBCORE_EXPORT void scrollToOffsetWithoutAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped);
    5455    void scrollToOffsetWithoutAnimation(ScrollbarOrientation, float offset);
    5556
  • trunk/Source/WebCore/platform/cocoa/ScrollController.h

    r223728 r224260  
    6262    virtual bool shouldRubberBandInDirection(ScrollDirection) = 0;
    6363
     64    // FIXME: use ScrollClamping to collapse these to one.
    6465    virtual void immediateScrollBy(const FloatSize&) = 0;
    6566    virtual void immediateScrollByWithoutContentEdgeConstraints(const FloatSize&) = 0;
  • trunk/Source/WebCore/platform/gtk/ScrollAnimatorGtk.cpp

    r223728 r224260  
    9292#endif
    9393
    94 void ScrollAnimatorGtk::scrollToOffsetWithoutAnimation(const FloatPoint& offset)
     94void ScrollAnimatorGtk::scrollToOffsetWithoutAnimation(const FloatPoint& offset, ScrollClamping)
    9595{
    9696    FloatPoint position = ScrollableArea::scrollPositionFromOffset(offset, toFloatSize(m_scrollableArea.scrollOrigin()));
  • trunk/Source/WebCore/platform/gtk/ScrollAnimatorGtk.h

    r217971 r224260  
    4848    bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier) override;
    4949#endif
    50     void scrollToOffsetWithoutAnimation(const FloatPoint&) override;
     50    void scrollToOffsetWithoutAnimation(const FloatPoint&, ScrollClamping) override;
    5151    void willEndLiveResize() override;
    5252
  • trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h

    r198787 r224260  
    2525 */
    2626
    27 #ifndef ScrollAnimatorMac_h
    28 #define ScrollAnimatorMac_h
     27#pragma once
    2928
    3029#if ENABLE(SMOOTH_SCROLLING)
     
    8382
    8483    bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier) override;
    85     void scrollToOffsetWithoutAnimation(const FloatPoint&) override;
     84    void scrollToOffsetWithoutAnimation(const FloatPoint&, ScrollClamping) override;
    8685
    8786#if ENABLE(RUBBER_BANDING)
     
    135134    FloatPoint adjustScrollPositionIfNecessary(const FloatPoint&) const;
    136135
    137     void immediateScrollToPosition(const FloatPoint&);
     136    void immediateScrollToPosition(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped);
    138137
    139138    bool isRubberBandInProgress() const override;
     
    165164#endif // ENABLE(SMOOTH_SCROLLING)
    166165
    167 #endif // ScrollAnimatorMac_h
  • trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm

    r223476 r224260  
    710710
    711711// FIXME: Maybe this should take a position.
    712 void ScrollAnimatorMac::scrollToOffsetWithoutAnimation(const FloatPoint& offset)
     712void ScrollAnimatorMac::scrollToOffsetWithoutAnimation(const FloatPoint& offset, ScrollClamping clamping)
    713713{
    714714    [m_scrollAnimationHelper _stopRun];
    715     immediateScrollToPosition(ScrollableArea::scrollPositionFromOffset(offset, toFloatSize(m_scrollableArea.scrollOrigin())));
     715    immediateScrollToPosition(ScrollableArea::scrollPositionFromOffset(offset, toFloatSize(m_scrollableArea.scrollOrigin())), clamping);
    716716}
    717717
     
    736736}
    737737
    738 void ScrollAnimatorMac::immediateScrollToPosition(const FloatPoint& newPosition)
     738void ScrollAnimatorMac::immediateScrollToPosition(const FloatPoint& newPosition, ScrollClamping clamping)
    739739{
    740740    FloatPoint currentPosition = this->currentPosition();
    741     FloatPoint adjustedPosition = adjustScrollPositionIfNecessary(newPosition);
     741    FloatPoint adjustedPosition = clamping == ScrollClamping::Clamped ? adjustScrollPositionIfNecessary(newPosition) : newPosition;
    742742 
    743743    bool positionChanged = adjustedPosition != currentPosition;
  • trunk/Source/WebCore/platform/mock/ScrollAnimatorMock.h

    r218615 r224260  
    2929 */
    3030
    31 #ifndef ScrollAnimatorMock_h
    32 #define ScrollAnimatorMock_h
     31#pragma once
    3332
    3433#include "ScrollAnimator.h"
     
    4342    ScrollAnimatorMock(ScrollableArea&, WTF::Function<void(const String&)>&&);
    4443    virtual ~ScrollAnimatorMock();
     44
     45private:
    4546
    4647#if ENABLE(RUBBER_BANDING)
     
    5758#endif
    5859
    59 private:
    6060    void didAddVerticalScrollbar(Scrollbar*) override;
    6161    void didAddHorizontalScrollbar(Scrollbar*) override;
     
    7676} // namespace WebCore
    7777
    78 #endif // ScrollAnimatorMock_h
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r224150 r224260  
    573573}
    574574
    575 void RenderBox::setScrollLeft(int newLeft)
     575void RenderBox::setScrollLeft(int newLeft, ScrollClamping clamping)
    576576{
    577577    if (!hasOverflowClip() || !layer())
    578578        return;
    579579    setupWheelEventTestTrigger(*layer());
    580     layer()->scrollToXPosition(newLeft, RenderLayer::ScrollOffsetClamped);
    581 }
    582 
    583 void RenderBox::setScrollTop(int newTop)
     580    layer()->scrollToXPosition(newLeft, clamping);
     581}
     582
     583void RenderBox::setScrollTop(int newTop, ScrollClamping clamping)
    584584{
    585585    if (!hasOverflowClip() || !layer())
    586586        return;
    587587    setupWheelEventTestTrigger(*layer());
    588     layer()->scrollToYPosition(newTop, RenderLayer::ScrollOffsetClamped);
     588    layer()->scrollToYPosition(newTop, clamping);
    589589}
    590590
  • trunk/Source/WebCore/rendering/RenderBox.h

    r222823 r224260  
    241241    virtual int scrollWidth() const;
    242242    virtual int scrollHeight() const;
    243     virtual void setScrollLeft(int);
    244     virtual void setScrollTop(int);
     243    virtual void setScrollLeft(int, ScrollClamping = ScrollClamping::Clamped);
     244    virtual void setScrollTop(int, ScrollClamping = ScrollClamping::Clamped);
    245245
    246246    LayoutUnit marginTop() const override { return m_marginBox.top(); }
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r224150 r224260  
    22712271        delta.setHeight(0);
    22722272
    2273     scrollByRecursively(adjustedScrollDelta(delta), ScrollOffsetClamped);
     2273    scrollByRecursively(adjustedScrollDelta(delta));
    22742274}
    22752275
    22762276// FIXME: unify with the scrollRectToVisible() code below.
    2277 void RenderLayer::scrollByRecursively(const IntSize& delta, ScrollOffsetClamping clamp, ScrollableArea** scrolledArea)
     2277void RenderLayer::scrollByRecursively(const IntSize& delta, ScrollableArea** scrolledArea)
    22782278{
    22792279    if (delta.isZero())
     
    22862286    if (renderer().hasOverflowClip() && !restrictedByLineClamp) {
    22872287        ScrollOffset newScrollOffset = scrollOffset() + delta;
    2288         scrollToOffset(newScrollOffset, clamp);
     2288        scrollToOffset(newScrollOffset);
    22892289        if (scrolledArea)
    22902290            *scrolledArea = this;
     
    22942294        if (!remainingScrollOffset.isZero() && renderer().parent()) {
    22952295            if (RenderLayer* scrollableLayer = enclosingScrollableLayer())
    2296                 scrollableLayer->scrollByRecursively(remainingScrollOffset, clamp, scrolledArea);
     2296                scrollableLayer->scrollByRecursively(remainingScrollOffset, scrolledArea);
    22972297
    22982298            renderer().frame().eventHandler().updateAutoscrollRenderer();
     
    23202320        return;
    23212321
    2322     scrollToOffset(scrollOffsetFromPosition(m_postLayoutScrollPosition.value()), ScrollOffsetClamped);
     2322    scrollToOffset(scrollOffsetFromPosition(m_postLayoutScrollPosition.value()));
    23232323    m_postLayoutScrollPosition = std::nullopt;
    23242324}
    23252325
    2326 void RenderLayer::scrollToXPosition(int x, ScrollOffsetClamping clamp)
     2326void RenderLayer::scrollToXPosition(int x, ScrollClamping clamping)
    23272327{
    23282328    ScrollPosition position(x, m_scrollPosition.y());
    2329     scrollToOffset(scrollOffsetFromPosition(position), clamp);
    2330 }
    2331 
    2332 void RenderLayer::scrollToYPosition(int y, ScrollOffsetClamping clamp)
     2329    scrollToOffset(scrollOffsetFromPosition(position), clamping);
     2330}
     2331
     2332void RenderLayer::scrollToYPosition(int y, ScrollClamping clamping)
    23332333{
    23342334    ScrollPosition position(m_scrollPosition.x(), y);
    2335     scrollToOffset(scrollOffsetFromPosition(position), clamp);
     2335    scrollToOffset(scrollOffsetFromPosition(position), clamping);
    23362336}
    23372337
     
    23412341}
    23422342
    2343 void RenderLayer::scrollToOffset(const ScrollOffset& scrollOffset, ScrollOffsetClamping clamp)
    2344 {
    2345     ScrollOffset newScrollOffset = clamp == ScrollOffsetClamped ? clampScrollOffset(scrollOffset) : scrollOffset;
     2343void RenderLayer::scrollToOffset(const ScrollOffset& scrollOffset, ScrollClamping clamping)
     2344{
     2345    ScrollOffset newScrollOffset = clamping == ScrollClamping::Clamped ? clampScrollOffset(scrollOffset) : scrollOffset;
    23462346    if (newScrollOffset != this->scrollOffset())
    2347         scrollToOffsetWithoutAnimation(newScrollOffset);
     2347        scrollToOffsetWithoutAnimation(newScrollOffset, clamping);
    23482348}
    23492349
  • trunk/Source/WebCore/rendering/RenderLayer.h

    r223210 r224260  
    198198    void panScrollFromPoint(const IntPoint&);
    199199
    200     enum ScrollOffsetClamping {
    201         ScrollOffsetUnclamped,
    202         ScrollOffsetClamped
    203     };
    204 
    205200    // Scrolling methods for layers that can scroll their overflow.
    206     void scrollByRecursively(const IntSize& delta, ScrollOffsetClamping = ScrollOffsetUnclamped, ScrollableArea** scrolledArea = nullptr);
    207 
    208     WEBCORE_EXPORT void scrollToOffset(const ScrollOffset&, ScrollOffsetClamping = ScrollOffsetUnclamped);
    209     void scrollToXOffset(int x, ScrollOffsetClamping clamp = ScrollOffsetUnclamped) { scrollToOffset(ScrollOffset(x, scrollOffset().y()), clamp); }
    210     void scrollToYOffset(int y, ScrollOffsetClamping clamp = ScrollOffsetUnclamped) { scrollToOffset(ScrollOffset(scrollOffset().x(), y), clamp); }
    211 
    212     void scrollToXPosition(int x, ScrollOffsetClamping = ScrollOffsetUnclamped);
    213     void scrollToYPosition(int y, ScrollOffsetClamping = ScrollOffsetUnclamped);
     201    void scrollByRecursively(const IntSize& delta, ScrollableArea** scrolledArea = nullptr);
     202
     203    WEBCORE_EXPORT void scrollToOffset(const ScrollOffset&, ScrollClamping = ScrollClamping::Clamped);
     204    void scrollToXOffset(int x, ScrollClamping clamping = ScrollClamping::Clamped) { scrollToOffset(ScrollOffset(x, scrollOffset().y()), clamping); }
     205    void scrollToYOffset(int y, ScrollClamping clamping = ScrollClamping::Clamped) { scrollToOffset(ScrollOffset(scrollOffset().x(), y), clamping); }
     206
     207    void scrollToXPosition(int x, ScrollClamping = ScrollClamping::Clamped);
     208    void scrollToYPosition(int y, ScrollClamping = ScrollClamping::Clamped);
    214209
    215210    void setPostLayoutScrollPosition(std::optional<ScrollPosition>);
  • trunk/Source/WebCore/rendering/RenderListBox.cpp

    r223720 r224260  
    735735}
    736736
    737 void RenderListBox::setScrollLeft(int)
     737void RenderListBox::setScrollLeft(int, ScrollClamping)
    738738{
    739739}
     
    752752}
    753753
    754 void RenderListBox::setScrollTop(int newTop)
     754void RenderListBox::setScrollTop(int newTop, ScrollClamping)
    755755{
    756756    // Determine an index and scroll to it.   
  • trunk/Source/WebCore/rendering/RenderListBox.h

    r218615 r224260  
    106106    int scrollWidth() const override;
    107107    int scrollHeight() const override;
    108     void setScrollLeft(int) override;
    109     void setScrollTop(int) override;
     108    void setScrollLeft(int, ScrollClamping) override;
     109    void setScrollTop(int, ScrollClamping) override;
    110110
    111111    bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) override;
  • trunk/Source/WebCore/rendering/RenderMarquee.cpp

    r223728 r224260  
    5858
    5959RenderMarquee::RenderMarquee(RenderLayer* l)
    60     : m_layer(l), m_currentLoop(0)
    61     , m_totalLoops(0)
     60    : m_layer(l)
    6261    , m_timer(*this, &RenderMarquee::timerFired)
    63     , m_start(0), m_end(0), m_speed(0), m_reset(false)
    64     , m_suspended(false), m_stopped(false), m_direction(MAUTO)
     62    , m_reset(false)
     63    , m_suspended(false)
     64    , m_stopped(false)
     65    , m_direction(MAUTO)
    6566{
    6667    l->setConstrainsScrollingToContentEdge(false);
     
    158159    if (!m_suspended && !m_stopped) {
    159160        if (isHorizontal())
    160             m_layer->scrollToOffset(ScrollOffset(m_start, 0));
     161            m_layer->scrollToOffset(ScrollOffset(m_start, 0), ScrollClamping::Unclamped);
    161162        else
    162             m_layer->scrollToOffset(ScrollOffset(0, m_start));
     163            m_layer->scrollToOffset(ScrollOffset(0, m_start), ScrollClamping::Unclamped);
    163164    }
    164165    else {
     
    233234        m_reset = false;
    234235        if (isHorizontal())
    235             m_layer->scrollToXOffset(m_start);
     236            m_layer->scrollToXOffset(m_start, ScrollClamping::Unclamped);
    236237        else
    237             m_layer->scrollToYOffset(m_start);
     238            m_layer->scrollToYOffset(m_start, ScrollClamping::Unclamped);
    238239        return;
    239240    }
     
    275276   
    276277    if (isHorizontal())
    277         m_layer->scrollToXOffset(newPos);
     278        m_layer->scrollToXOffset(newPos, ScrollClamping::Unclamped);
    278279    else
    279         m_layer->scrollToYOffset(newPos);
     280        m_layer->scrollToYOffset(newPos, ScrollClamping::Unclamped);
    280281}
    281282
  • trunk/Source/WebCore/rendering/RenderMarquee.h

    r208668 r224260  
    8282
    8383    RenderLayer* m_layer;
    84     int m_currentLoop;
    85     int m_totalLoops;
    8684    Timer m_timer;
    87     int m_start;
    88     int m_end;
    89     int m_speed;
     85    int m_currentLoop { 0 };
     86    int m_totalLoops { 0 };
     87    int m_start { 0 };
     88    int m_end { 0 };
     89    int m_speed { 0 };
    9090    Length m_height;
    9191    bool m_reset: 1;
  • trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp

    r223728 r224260  
    341341}
    342342
    343 void RenderTextControlSingleLine::setScrollLeft(int newLeft)
     343void RenderTextControlSingleLine::setScrollLeft(int newLeft, ScrollClamping)
    344344{
    345345    if (innerTextElement())
     
    347347}
    348348
    349 void RenderTextControlSingleLine::setScrollTop(int newTop)
     349void RenderTextControlSingleLine::setScrollTop(int newTop, ScrollClamping)
    350350{
    351351    if (innerTextElement())
  • trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h

    r217418 r224260  
    5757    int scrollWidth() const override;
    5858    int scrollHeight() const override;
    59     void setScrollLeft(int) override;
    60     void setScrollTop(int) override;
     59    void setScrollLeft(int, ScrollClamping) override;
     60    void setScrollTop(int, ScrollClamping) override;
    6161    bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = nullptr, RenderBox* startBox = nullptr, const IntPoint& wheelEventAbsolutePoint = IntPoint()) final;
    6262    bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = 0) final;
  • trunk/Source/WebCore/testing/Internals.cpp

    r224150 r224260  
    15111511}
    15121512
     1513ExceptionOr<void> Internals::unconstrainedScrollTo(Element& element, double x, double y)
     1514{
     1515    Document* document = contextDocument();
     1516    if (!document || !document->view())
     1517        return Exception { InvalidAccessError };
     1518
     1519    element.scrollTo({ x, y }, ScrollClamping::Unclamped);
     1520    return { };
     1521}
     1522
    15131523ExceptionOr<Ref<DOMRect>> Internals::layoutViewportRect()
    15141524{
  • trunk/Source/WebCore/testing/Internals.h

    r224128 r224260  
    212212
    213213    ExceptionOr<void> setScrollViewPosition(int x, int y);
     214    ExceptionOr<void> unconstrainedScrollTo(Element&, double x, double y);
    214215
    215216    ExceptionOr<Ref<DOMRect>> layoutViewportRect();
  • trunk/Source/WebCore/testing/Internals.idl

    r224128 r224260  
    168168    [MayThrowException] void setScrollViewPosition(long x, long y);
    169169
     170    // Like Element.scrollTo(), but without constaints, for testing rubber-banding.
     171    [MayThrowException] void unconstrainedScrollTo(Element element, unrestricted double x, unrestricted double y);
     172
    170173    [MayThrowException] DOMRect layoutViewportRect();
    171174    [MayThrowException] DOMRect visualViewportRect();
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r224254 r224260  
     12017-10-31  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Make it possible to test rubber-banding in overflow scroll
     4        https://bugs.webkit.org/show_bug.cgi?id=179078
     5
     6        Reviewed by Sam Weinig.
     7
     8        Add internals.unconstrainedScrollTo(element, x, y) and plumb through ScrollClamping
     9        (which replaces RenderLayer::ScrollOffsetClamping) to support it.
     10
     11        Flip the default from unclamped to clamped for various RenderLayer scrolling-related
     12        functions, since most callers want clamped.
     13
     14        * DOM/DOMHTML.mm:
     15        (-[DOMHTMLElement setScrollXOffset:scrollYOffset:adjustForIOSCaret:]):
     16
    1172017-10-31  Tim Horton  <timothy_horton@apple.com>
    218
  • trunk/Source/WebKitLegacy/mac/DOM/DOMHTML.mm

    r211468 r224260  
    116116    if (adjustForIOSCaret)
    117117        layer->setAdjustForIOSCaretWhenScrolling(true);
    118     layer->scrollToOffset(ScrollOffset(x, y));
     118    layer->scrollToOffset(ScrollOffset(x, y), ScrollClamping::Unclamped);
    119119    if (adjustForIOSCaret)
    120120        layer->setAdjustForIOSCaretWhenScrolling(false);
Note: See TracChangeset for help on using the changeset viewer.