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

Changeset 286115 in webkit


Ignore:
Timestamp:
Nov 22, 2021, 12:01:09 PM (5 years ago)
Author:
Simon Fraser
Message:

Clarify the behavior of ScrollAnimator::scroll()
https://bugs.webkit.org/show_bug.cgi?id=233403

Reviewed by Sam Weinig.

ScrollAnimator::scroll() was hard to reason about. It used ScrollbarOrientation but didn't
do anything with scrollbars. It took ScrollGranularity, "step" and "multiplier" and it
wasn't clear whether step had already accounted for ScrollGranularity, and whether
multiplier was anything other than 1 or -1. One of the behaviors was DoDirectionalSnapping
but it wasn't clear if the "directional" or "snapping" part of that was important. It also
called itself.

Bring clarity by using 'unsigned stepCount' in all the callers, using ScrollEventAxis
instead of ScrollbarOrientation, and having a single "delta" argument. It no longer
calls itself, instead just continuing from the snapping branch.

Add some helpers that ease interactions with FloatPoint/FloatSize and ScrollEventAxis.

  • dom/Element.cpp:

(WebCore::Element::scrollByUnits):

  • dom/Element.h:
  • page/FrameView.cpp:

(WebCore::FrameView::adjustScrollStepForFixedContent):

  • page/FrameView.h:
  • platform/ScrollAnimator.cpp:

(WebCore::ScrollAnimator::scroll):
(WebCore::ScrollAnimator::deltaFromStep):
(WebCore::ScrollAnimator::handleWheelEvent):

  • platform/ScrollAnimator.h:
  • platform/ScrollSnapAnimatorState.cpp:

(WebCore::ScrollSnapAnimatorState::adjustedScrollDestination const):

  • platform/ScrollTypes.h:

(WebCore::axisFromDirection):
(WebCore::valueForAxis):
(WebCore::setValueForAxis):

  • platform/ScrollableArea.cpp:

(WebCore::ScrollableArea::adjustScrollStepForFixedContent):
(WebCore::ScrollableArea::scroll):

  • platform/ScrollableArea.h:
  • rendering/RenderBox.cpp:

(WebCore::RenderBox::scrollLayer):
(WebCore::RenderBox::scroll):
(WebCore::RenderBox::logicalScroll):

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

(WebCore::RenderEmbeddedObject::scroll):
(WebCore::RenderEmbeddedObject::logicalScroll):

  • rendering/RenderEmbeddedObject.h:
  • rendering/RenderLayerScrollableArea.cpp:

(WebCore::RenderLayerScrollableArea::scroll):

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

(WebCore::RenderListBox::scroll):
(WebCore::RenderListBox::logicalScroll):

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

(WebCore::RenderTextControlSingleLine::scroll):
(WebCore::RenderTextControlSingleLine::logicalScroll):

  • rendering/RenderTextControlSingleLine.h:
Location:
trunk/Source/WebCore
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r286113 r286115  
     12021-11-20  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Clarify the behavior of ScrollAnimator::scroll()
     4        https://bugs.webkit.org/show_bug.cgi?id=233403
     5
     6        Reviewed by Sam Weinig.
     7
     8        ScrollAnimator::scroll() was hard to reason about. It used ScrollbarOrientation but didn't
     9        do anything with scrollbars. It took ScrollGranularity, "step" and "multiplier" and it
     10        wasn't clear whether step had already accounted for ScrollGranularity, and whether
     11        multiplier was anything other than 1 or -1. One of the behaviors was DoDirectionalSnapping
     12        but it wasn't clear if the "directional" or "snapping" part of that was important. It also
     13        called itself.
     14
     15        Bring clarity by using 'unsigned stepCount' in all the callers, using ScrollEventAxis
     16        instead of ScrollbarOrientation, and having a single "delta" argument. It no longer
     17        calls itself, instead just continuing from the snapping branch.
     18       
     19        Add some helpers that ease interactions with FloatPoint/FloatSize and ScrollEventAxis.
     20
     21        * dom/Element.cpp:
     22        (WebCore::Element::scrollByUnits):
     23        * dom/Element.h:
     24        * page/FrameView.cpp:
     25        (WebCore::FrameView::adjustScrollStepForFixedContent):
     26        * page/FrameView.h:
     27        * platform/ScrollAnimator.cpp:
     28        (WebCore::ScrollAnimator::scroll):
     29        (WebCore::ScrollAnimator::deltaFromStep):
     30        (WebCore::ScrollAnimator::handleWheelEvent):
     31        * platform/ScrollAnimator.h:
     32        * platform/ScrollSnapAnimatorState.cpp:
     33        (WebCore::ScrollSnapAnimatorState::adjustedScrollDestination const):
     34        * platform/ScrollTypes.h:
     35        (WebCore::axisFromDirection):
     36        (WebCore::valueForAxis):
     37        (WebCore::setValueForAxis):
     38        * platform/ScrollableArea.cpp:
     39        (WebCore::ScrollableArea::adjustScrollStepForFixedContent):
     40        (WebCore::ScrollableArea::scroll):
     41        * platform/ScrollableArea.h:
     42        * rendering/RenderBox.cpp:
     43        (WebCore::RenderBox::scrollLayer):
     44        (WebCore::RenderBox::scroll):
     45        (WebCore::RenderBox::logicalScroll):
     46        * rendering/RenderBox.h:
     47        * rendering/RenderEmbeddedObject.cpp:
     48        (WebCore::RenderEmbeddedObject::scroll):
     49        (WebCore::RenderEmbeddedObject::logicalScroll):
     50        * rendering/RenderEmbeddedObject.h:
     51        * rendering/RenderLayerScrollableArea.cpp:
     52        (WebCore::RenderLayerScrollableArea::scroll):
     53        * rendering/RenderLayerScrollableArea.h:
     54        * rendering/RenderListBox.cpp:
     55        (WebCore::RenderListBox::scroll):
     56        (WebCore::RenderListBox::logicalScroll):
     57        * rendering/RenderListBox.h:
     58        * rendering/RenderTextControlSingleLine.cpp:
     59        (WebCore::RenderTextControlSingleLine::scroll):
     60        (WebCore::RenderTextControlSingleLine::logicalScroll):
     61        * rendering/RenderTextControlSingleLine.h:
     62
    1632021-11-22  Antti Koivisto  <antti@apple.com>
    264
  • trunk/Source/WebCore/dom/Element.cpp

    r286112 r286115  
    11201120
    11211121    ScrollDirection direction = ScrollDown;
    1122     if (units < 0) {
     1122    if (units < 0)
    11231123        direction = ScrollUp;
    1124         units = -units;
    1125     }
    1126     Element* stopElement = this;
    1127     downcast<RenderBox>(*renderer).scroll(direction, granularity, units, &stopElement);
     1124
     1125    auto* stopElement = this;
     1126    downcast<RenderBox>(*renderer).scroll(direction, granularity, std::abs(units), &stopElement);
    11281127}
    11291128
  • trunk/Source/WebCore/dom/Element.h

    r286112 r286115  
    176176    void scrollTo(double x, double y);
    177177
     178    // These are only used by WebKitLegacy DOM API.
    178179    WEBCORE_EXPORT void scrollByLines(int lines);
    179180    WEBCORE_EXPORT void scrollByPages(int pages);
  • trunk/Source/WebCore/page/EventHandler.cpp

    r286021 r286115  
    43014301float EventHandler::scrollDistance(ScrollDirection direction, ScrollGranularity granularity)
    43024302{
    4303     auto scrollbar = [&] {
    4304         if (direction == ScrollDirection::ScrollUp || direction == ScrollDirection::ScrollDown)
    4305             return m_frame.view()->verticalScrollbar();
    4306         return m_frame.view()->horizontalScrollbar();
    4307     }();
     4303    auto scrollbar = m_frame.view()->scrollbarForDirection(direction);
    43084304
    43094305    switch (granularity) {
  • trunk/Source/WebCore/page/FrameView.cpp

    r285893 r286115  
    38353835}
    38363836
    3837 float FrameView::adjustScrollStepForFixedContent(float step, ScrollbarOrientation orientation, ScrollGranularity granularity)
    3838 {
    3839     if (granularity != ScrollGranularity::Page || orientation == ScrollbarOrientation::Horizontal)
     3837float FrameView::adjustScrollStepForFixedContent(float step, ScrollEventAxis axis, ScrollGranularity granularity)
     3838{
     3839    if (granularity != ScrollGranularity::Page || axis == ScrollEventAxis::Horizontal)
    38403840        return step;
    38413841
  • trunk/Source/WebCore/page/FrameView.h

    r285893 r286115  
    662662    void updateScrollingCoordinatorScrollSnapProperties() const;
    663663
    664     float adjustScrollStepForFixedContent(float step, ScrollbarOrientation, ScrollGranularity) final;
     664    float adjustScrollStepForFixedContent(float step, ScrollEventAxis, ScrollGranularity) final;
    665665
    666666    void didChangeScrollOffset();
  • trunk/Source/WebCore/platform/KeyboardScrollingAnimator.cpp

    r285640 r286115  
    148148float KeyboardScrollingAnimator::scrollDistance(ScrollDirection direction, ScrollGranularity granularity) const
    149149{
    150     auto scrollbar = [&] {
    151         if (direction == ScrollDirection::ScrollUp || direction == ScrollDirection::ScrollDown)
    152             return m_scrollAnimator.scrollableArea().verticalScrollbar();
    153         return m_scrollAnimator.scrollableArea().horizontalScrollbar();
    154     }();
    155 
     150    auto scrollbar = m_scrollAnimator.scrollableArea().scrollbarForDirection(direction);
    156151    if (scrollbar) {
    157152        switch (granularity) {
  • trunk/Source/WebCore/platform/ScrollAnimator.cpp

    r285640 r286115  
    6464}
    6565
    66 bool ScrollAnimator::scroll(ScrollbarOrientation orientation, ScrollGranularity granularity, float step, float multiplier, OptionSet<ScrollBehavior> behavior)
     66bool ScrollAnimator::singleAxisScroll(ScrollEventAxis axis, float scrollDelta, OptionSet<ScrollBehavior> behavior)
    6767{
    6868    m_scrollableArea.scrollbarsController().setScrollbarAnimationsUnsuspendedByUserInteraction(true);
    6969
    70     auto delta = deltaFromStep(orientation, step, multiplier);
    71     if (behavior.contains(ScrollBehavior::DoDirectionalSnapping)) {
    72         behavior.remove(ScrollBehavior::DoDirectionalSnapping);
    73         if (!m_scrollController.usesScrollSnap())
    74             return ScrollAnimator::scroll(orientation, granularity, step, multiplier, behavior);
    75 
    76         auto currentOffset = offsetFromPosition(currentPosition());
    77         auto newOffset = currentOffset + delta;
    78         if (orientation == ScrollbarOrientation::Horizontal)
    79             newOffset.setX(m_scrollController.adjustedScrollDestination(ScrollEventAxis::Horizontal, newOffset, multiplier, currentOffset.x()));
    80         else
    81             newOffset.setY(m_scrollController.adjustedScrollDestination(ScrollEventAxis::Vertical, newOffset, multiplier, currentOffset.y()));
    82 
    83         auto newDelta = newOffset - currentOffset;
    84         if (orientation == ScrollbarOrientation::Horizontal)
    85             return scroll(ScrollbarOrientation::Horizontal, granularity, newDelta.width(), 1.0, behavior);
    86 
    87         return scroll(ScrollbarOrientation::Vertical, granularity, newDelta.height(), 1.0, behavior);
     70    auto delta = setValueForAxis(FloatSize { }, axis, scrollDelta);
     71
     72    if (behavior.contains(ScrollBehavior::RespectScrollSnap)) {
     73        behavior.remove(ScrollBehavior::RespectScrollSnap);
     74        if (m_scrollController.usesScrollSnap()) {
     75            auto currentOffset = offsetFromPosition(currentPosition());
     76            auto newOffset = currentOffset + delta;
     77            auto velocity = copysignf(1.0f, scrollDelta);
     78            auto newOffsetOnAxis = m_scrollController.adjustedScrollDestination(axis, newOffset, velocity, valueForAxis(currentOffset, axis));
     79            newOffset = setValueForAxis(newOffset, axis, newOffsetOnAxis);
     80            delta = newOffset - currentOffset;
     81        }
    8882    }
    8983
     
    140134{
    141135    return ScrollableArea::scrollPositionFromOffset(offset, toFloatSize(m_scrollableArea.scrollOrigin()));
    142 }
    143 
    144 FloatSize ScrollAnimator::deltaFromStep(ScrollbarOrientation orientation, float step, float multiplier)
    145 {
    146     FloatSize delta;
    147     if (orientation == ScrollbarOrientation::Horizontal)
    148         delta.setWidth(step * multiplier);
    149     else
    150         delta.setHeight(step * multiplier);
    151     return delta;
    152136}
    153137
     
    207191        handled = true;
    208192
    209         OptionSet<ScrollBehavior> behavior(ScrollBehavior::DoDirectionalSnapping);
     193        OptionSet<ScrollBehavior> behavior = { ScrollBehavior::RespectScrollSnap };
    210194        if (e.hasPreciseScrollingDeltas())
    211195            behavior.add(ScrollBehavior::NeverAnimate);
    212196
    213197        if (deltaY) {
    214             if (e.granularity() == ScrollByPageWheelEvent) {
    215                 bool negative = deltaY < 0;
    216                 deltaY = Scrollbar::pageStepDelta(m_scrollableArea.visibleHeight());
    217                 if (negative)
    218                     deltaY = -deltaY;
    219             }
    220             scroll(ScrollbarOrientation::Vertical, ScrollGranularity::Pixel, verticalScrollbar->pixelStep(), -deltaY, behavior);
     198            if (e.granularity() == ScrollByPageWheelEvent)
     199                deltaY = std::copysign(Scrollbar::pageStepDelta(m_scrollableArea.visibleHeight()), deltaY);
     200
     201            auto scrollDelta = verticalScrollbar->pixelStep() * -deltaY; // Wheel deltas are reversed from scrolling direction.
     202            singleAxisScroll(ScrollEventAxis::Vertical, scrollDelta, behavior);
    221203        }
    222204
    223205        if (deltaX) {
    224             if (e.granularity() == ScrollByPageWheelEvent) {
    225                 bool negative = deltaX < 0;
    226                 deltaX = Scrollbar::pageStepDelta(m_scrollableArea.visibleWidth());
    227                 if (negative)
    228                     deltaX = -deltaX;
    229             }
    230             scroll(ScrollbarOrientation::Horizontal, ScrollGranularity::Pixel, horizontalScrollbar->pixelStep(), -deltaX, behavior);
     206            if (e.granularity() == ScrollByPageWheelEvent)
     207                deltaX = std::copysign(Scrollbar::pageStepDelta(m_scrollableArea.visibleWidth()), deltaX);
     208
     209            auto scrollDelta = horizontalScrollbar->pixelStep() * -deltaX; // Wheel deltas are reversed from scrolling direction.
     210            singleAxisScroll(ScrollEventAxis::Horizontal, scrollDelta, behavior);
    231211        }
    232212    }
  • trunk/Source/WebCore/platform/ScrollAnimator.h

    r285205 r286115  
    6767
    6868    enum ScrollBehavior {
    69         DoDirectionalSnapping = 1 << 0,
    70         NeverAnimate = 1 << 1,
     69        RespectScrollSnap  = 1 << 0,
     70        NeverAnimate        = 1 << 1,
    7171    };
    7272
    7373    // Computes a scroll destination for the given parameters.  Returns false if
    74     // already at the destination.  Otherwise, starts scrolling towards the
    75     // destination and returns true.  Scrolling may be immediate or animated.
     74    // already at the destination. Otherwise, starts scrolling towards the
     75    // destination and returns true. Scrolling may be immediate or animated.
    7676    // The base class implementation always scrolls immediately, never animates.
    77     bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier, OptionSet<ScrollBehavior>);
     77    bool singleAxisScroll(ScrollEventAxis, float delta, OptionSet<ScrollBehavior>);
    7878
    7979    virtual bool scrollToPositionWithoutAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped);
     
    172172#endif
    173173
    174     static FloatSize deltaFromStep(ScrollbarOrientation, float step, float multiplier);
    175 
    176174protected:
    177175    ScrollableArea& m_scrollableArea;
  • trunk/Source/WebCore/platform/ScrollSnapAnimatorState.cpp

    r283851 r286115  
    8484    auto snapOffsets = snapOffsetsForAxis(axis);
    8585    if (!snapOffsets.size())
    86         return axis == ScrollEventAxis::Horizontal ? destinationOffset.x() : destinationOffset.y();
     86        return valueForAxis(destinationOffset, axis);
    8787
    8888    std::optional<LayoutUnit> originalOffsetInLayoutUnits;
  • trunk/Source/WebCore/platform/ScrollTypes.h

    r285640 r286115  
    2626#pragma once
    2727
     28#include "FloatPoint.h"
     29#include "FloatSize.h"
    2830#include <wtf/EnumTraits.h>
    2931
     
    169171    Vertical
    170172};
     173
     174inline constexpr ScrollEventAxis axisFromDirection(ScrollDirection direction)
     175{
     176    switch (direction) {
     177    case ScrollUp: return ScrollEventAxis::Vertical;
     178    case ScrollDown: return ScrollEventAxis::Vertical;
     179    case ScrollLeft: return ScrollEventAxis::Horizontal;
     180    case ScrollRight: return ScrollEventAxis::Horizontal;
     181    }
     182    return ScrollEventAxis::Vertical;
     183}
     184
     185inline float valueForAxis(FloatSize size, ScrollEventAxis axis)
     186{
     187    switch (axis) {
     188    case ScrollEventAxis::Horizontal: return size.width();
     189    case ScrollEventAxis::Vertical: return size.height();
     190    }
     191    return 0;
     192}
     193
     194inline FloatSize setValueForAxis(FloatSize size, ScrollEventAxis axis, float value)
     195{
     196    switch (axis) {
     197    case ScrollEventAxis::Horizontal:
     198        size.setWidth(value);
     199        return size;
     200    case ScrollEventAxis::Vertical:
     201        size.setHeight(value);
     202        return size;
     203    }
     204    return size;
     205}
     206
     207inline float valueForAxis(FloatPoint point, ScrollEventAxis axis)
     208{
     209    switch (axis) {
     210    case ScrollEventAxis::Horizontal: return point.x();
     211    case ScrollEventAxis::Vertical: return point.y();
     212    }
     213    return 0;
     214}
     215
     216inline FloatPoint setValueForAxis(FloatPoint point, ScrollEventAxis axis, float value)
     217{
     218    switch (axis) {
     219    case ScrollEventAxis::Horizontal:
     220        point.setX(value);
     221        return point;
     222    case ScrollEventAxis::Vertical: point.setY(value);
     223        return point;
     224    }
     225    return point;
     226}
    171227
    172228enum ScrollbarControlStateMask {
  • trunk/Source/WebCore/platform/ScrollableArea.cpp

    r285640 r286115  
    9292}
    9393
    94 float ScrollableArea::adjustScrollStepForFixedContent(float step, ScrollbarOrientation, ScrollGranularity)
     94float ScrollableArea::adjustScrollStepForFixedContent(float step, ScrollEventAxis, ScrollGranularity)
    9595{
    9696    return step;
    9797}
    9898
    99 bool ScrollableArea::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier)
    100 {
    101     ScrollbarOrientation orientation;
    102     Scrollbar* scrollbar;
    103     if (direction == ScrollUp || direction == ScrollDown) {
    104         orientation = ScrollbarOrientation::Vertical;
    105         scrollbar = verticalScrollbar();
    106     } else {
    107         orientation = ScrollbarOrientation::Horizontal;
    108         scrollbar = horizontalScrollbar();
    109     }
    110 
     99bool ScrollableArea::scroll(ScrollDirection direction, ScrollGranularity granularity, unsigned stepCount)
     100{
     101    auto* scrollbar = scrollbarForDirection(direction);
    111102    if (!scrollbar)
    112103        return false;
     
    128119    }
    129120
     121    auto axis = axisFromDirection(direction);
     122    step = adjustScrollStepForFixedContent(step, axis, granularity);
     123    auto scrollDelta = step * stepCount;
     124   
    130125    if (direction == ScrollUp || direction == ScrollLeft)
    131         multiplier = -multiplier;
    132 
    133     step = adjustScrollStepForFixedContent(step, orientation, granularity);
    134     return scrollAnimator().scroll(orientation, granularity, step, multiplier, ScrollAnimator::ScrollBehavior::DoDirectionalSnapping);
     126        scrollDelta = -scrollDelta;
     127
     128    return scrollAnimator().singleAxisScroll(axis, scrollDelta, ScrollAnimator::ScrollBehavior::RespectScrollSnap);
    135129}
    136130
  • trunk/Source/WebCore/platform/ScrollableArea.h

    r285893 r286115  
    6969    virtual bool isPDFPlugin() const { return false; }
    7070
    71     WEBCORE_EXPORT bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1);
     71    WEBCORE_EXPORT bool scroll(ScrollDirection, ScrollGranularity, unsigned stepCount = 1);
    7272    WEBCORE_EXPORT void scrollToPositionWithAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped);
    7373    WEBCORE_EXPORT void scrollToPositionWithoutAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped);
     
    216216    virtual Scrollbar* horizontalScrollbar() const { return nullptr; }
    217217    virtual Scrollbar* verticalScrollbar() const { return nullptr; }
     218
     219    Scrollbar* scrollbarForDirection(ScrollDirection direction) const
     220    {
     221        switch (direction) {
     222        case ScrollUp:
     223        case ScrollDown:
     224            return verticalScrollbar();
     225        case ScrollLeft:
     226        case ScrollRight:
     227            return horizontalScrollbar();
     228        }
     229        return nullptr;
     230    }
    218231
    219232    const IntPoint& scrollOrigin() const { return m_scrollOrigin; }
     
    366379    void resetScrollOriginChanged() { m_scrollOriginChanged = false; }
    367380
    368     WEBCORE_EXPORT virtual float adjustScrollStepForFixedContent(float step, ScrollbarOrientation, ScrollGranularity);
     381    WEBCORE_EXPORT virtual float adjustScrollStepForFixedContent(float step, ScrollEventAxis, ScrollGranularity);
    369382    virtual void invalidateScrollbarRect(Scrollbar&, const IntRect&) = 0;
    370383    virtual void invalidateScrollCornerRect(const IntRect&) = 0;
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r286086 r286115  
    894894}
    895895
    896 bool RenderBox::scrollLayer(ScrollDirection direction, ScrollGranularity granularity, float multiplier, Element** stopElement)
     896bool RenderBox::scrollLayer(ScrollDirection direction, ScrollGranularity granularity, unsigned stepCount, Element** stopElement)
    897897{
    898898    auto* scrollableArea = layer() ? layer()->scrollableArea() : nullptr;
    899     if (scrollableArea && scrollableArea->scroll(direction, granularity, multiplier)) {
     899    if (scrollableArea && scrollableArea->scroll(direction, granularity, stepCount)) {
    900900        if (stopElement)
    901901            *stopElement = element();
     
    907907}
    908908
    909 bool RenderBox::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, Element** stopElement, RenderBox* startBox, const IntPoint& wheelEventAbsolutePoint)
    910 {
    911     if (scrollLayer(direction, granularity, multiplier, stopElement))
     909bool RenderBox::scroll(ScrollDirection direction, ScrollGranularity granularity, unsigned stepCount, Element** stopElement, RenderBox* startBox, const IntPoint& wheelEventAbsolutePoint)
     910{
     911    if (scrollLayer(direction, granularity, stepCount, stopElement))
    912912        return true;
    913913
     
    918918
    919919    if (nextScrollBlock && !nextScrollBlock->isRenderView())
    920         return nextScrollBlock->scroll(direction, granularity, multiplier, stopElement, startBox, wheelEventAbsolutePoint);
     920        return nextScrollBlock->scroll(direction, granularity, stepCount, stopElement, startBox, wheelEventAbsolutePoint);
    921921
    922922    return false;
    923923}
    924924
    925 bool RenderBox::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, float multiplier, Element** stopElement)
     925bool RenderBox::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, unsigned stepCount, Element** stopElement)
    926926{
    927927    bool scrolled = false;
     
    931931        // On Mac only we reset the inline direction position when doing a document scroll (e.g., hitting Home/End).
    932932        if (granularity == ScrollGranularity::Document)
    933             scrolled = scrollableArea->scroll(logicalToPhysical(ScrollInlineDirectionBackward, isHorizontalWritingMode(), style().isFlippedBlocksWritingMode()), ScrollGranularity::Document, multiplier);
     933            scrolled = scrollableArea->scroll(logicalToPhysical(ScrollInlineDirectionBackward, isHorizontalWritingMode(), style().isFlippedBlocksWritingMode()), ScrollGranularity::Document, stepCount);
    934934#endif
    935         if (scrollableArea->scroll(logicalToPhysical(direction, isHorizontalWritingMode(), style().isFlippedBlocksWritingMode()), granularity, multiplier))
     935        if (scrollableArea->scroll(logicalToPhysical(direction, isHorizontalWritingMode(), style().isFlippedBlocksWritingMode()), granularity, stepCount))
    936936            scrolled = true;
    937937       
     
    948948    RenderBlock* b = containingBlock();
    949949    if (b && !b->isRenderView())
    950         return b->logicalScroll(direction, granularity, multiplier, stopElement);
     950        return b->logicalScroll(direction, granularity, stepCount, stopElement);
    951951    return false;
    952952}
  • trunk/Source/WebCore/rendering/RenderBox.h

    r285623 r286115  
    493493    int scrollbarLogicalWidth() const { return style().isHorizontalWritingMode() ? verticalScrollbarWidth() : horizontalScrollbarHeight(); }
    494494    int scrollbarLogicalHeight() const { return style().isHorizontalWritingMode() ? horizontalScrollbarHeight() : verticalScrollbarWidth(); }
    495     virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = nullptr, RenderBox* startBox = nullptr, const IntPoint& wheelEventAbsolutePoint = IntPoint());
    496     virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = nullptr);
     495    virtual bool scroll(ScrollDirection, ScrollGranularity, unsigned stepCount = 1, Element** stopElement = nullptr, RenderBox* startBox = nullptr, const IntPoint& wheelEventAbsolutePoint = IntPoint());
     496    virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, unsigned stepCount = 1, Element** stopElement = nullptr);
    497497    WEBCORE_EXPORT bool canBeScrolledAndHasScrollableArea() const;
    498498    virtual bool canBeProgramaticallyScrolled() const;
     
    745745    void updateGridPositionAfterStyleChange(const RenderStyle&, const RenderStyle* oldStyle);
    746746
    747     bool scrollLayer(ScrollDirection, ScrollGranularity, float multiplier, Element** stopElement);
     747    bool scrollLayer(ScrollDirection, ScrollGranularity, unsigned stepCount, Element** stopElement);
    748748
    749749    bool fixedElementLaysOutRelativeToFrame(const FrameView&) const;
  • trunk/Source/WebCore/rendering/RenderEmbeddedObject.cpp

    r283237 r286115  
    384384}
    385385
    386 bool RenderEmbeddedObject::scroll(ScrollDirection direction, ScrollGranularity granularity, float, Element**, RenderBox*, const IntPoint&)
     386bool RenderEmbeddedObject::scroll(ScrollDirection direction, ScrollGranularity granularity, unsigned, Element**, RenderBox*, const IntPoint&)
    387387{
    388388    if (!is<PluginViewBase>(widget()))
     
    392392}
    393393
    394 bool RenderEmbeddedObject::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, float multiplier, Element** stopElement)
     394bool RenderEmbeddedObject::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, unsigned stepCount, Element** stopElement)
    395395{
    396396    // Plugins don't expose a writing direction, so assuming horizontal LTR.
    397     return scroll(logicalToPhysical(direction, true, false), granularity, multiplier, stopElement);
     397    return scroll(logicalToPhysical(direction, true, false), granularity, stepCount, stopElement);
    398398}
    399399
  • trunk/Source/WebCore/rendering/RenderEmbeddedObject.h

    r269785 r286115  
    8080    bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) final;
    8181
    82     bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = nullptr, RenderBox* startBox = nullptr, const IntPoint& wheelEventAbsolutePoint = IntPoint()) final;
    83     bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier, Element** stopElement) final;
     82    bool scroll(ScrollDirection, ScrollGranularity, unsigned stepCount = 1, Element** stopElement = nullptr, RenderBox* startBox = nullptr, const IntPoint& wheelEventAbsolutePoint = IntPoint()) final;
     83    bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, unsigned stepCount, Element** stopElement) final;
    8484
    8585    void setUnavailablePluginIndicatorIsPressed(bool);
  • trunk/Source/WebCore/rendering/RenderLayerScrollableArea.cpp

    r285893 r286115  
    14921492}
    14931493
    1494 bool RenderLayerScrollableArea::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier)
    1495 {
    1496     return ScrollableArea::scroll(direction, granularity, multiplier);
     1494bool RenderLayerScrollableArea::scroll(ScrollDirection direction, ScrollGranularity granularity, unsigned stepCount)
     1495{
     1496    return ScrollableArea::scroll(direction, granularity, stepCount);
    14971497}
    14981498
  • trunk/Source/WebCore/rendering/RenderLayerScrollableArea.h

    r285893 r286115  
    131131    void updateScrollbarSteps();
    132132
    133     bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1);
     133    bool scroll(ScrollDirection, ScrollGranularity, unsigned stepCount = 1);
    134134
    135135public:
  • trunk/Source/WebCore/rendering/RenderListBox.cpp

    r285316 r286115  
    616616}
    617617
    618 bool RenderListBox::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, Element**, RenderBox*, const IntPoint&)
    619 {
    620     return ScrollableArea::scroll(direction, granularity, multiplier);
    621 }
    622 
    623 bool RenderListBox::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, float multiplier, Element**)
    624 {
    625     return ScrollableArea::scroll(logicalToPhysical(direction, style().isHorizontalWritingMode(), style().isFlippedBlocksWritingMode()), granularity, multiplier);
     618bool RenderListBox::scroll(ScrollDirection direction, ScrollGranularity granularity, unsigned stepCount, Element**, RenderBox*, const IntPoint&)
     619{
     620    return ScrollableArea::scroll(direction, granularity, stepCount);
     621}
     622
     623bool RenderListBox::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, unsigned stepCount, Element**)
     624{
     625    return ScrollableArea::scroll(logicalToPhysical(direction, style().isHorizontalWritingMode(), style().isFlippedBlocksWritingMode()), granularity, stepCount);
    626626}
    627627
  • trunk/Source/WebCore/rendering/RenderListBox.h

    r285205 r286115  
    6060    int size() const;
    6161
    62     bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = nullptr, RenderBox* startBox = nullptr, const IntPoint& wheelEventAbsolutePoint = IntPoint()) override;
     62    bool scroll(ScrollDirection, ScrollGranularity, unsigned stepCount = 1, Element** stopElement = nullptr, RenderBox* startBox = nullptr, const IntPoint& wheelEventAbsolutePoint = IntPoint()) override;
    6363
    6464    bool scrolledToTop() const final;
     
    8383    bool isPointInOverflowControl(HitTestResult&, const LayoutPoint& locationInContainer, const LayoutPoint& accumulatedOffset) override;
    8484
    85     bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = nullptr) override;
     85    bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, unsigned stepCount = 1, Element** stopElement = nullptr) override;
    8686
    8787    void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const override;
  • trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp

    r279918 r286115  
    397397}
    398398
    399 bool RenderTextControlSingleLine::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, Element** stopElement, RenderBox* startBox, const IntPoint& wheelEventAbsolutePoint)
     399bool RenderTextControlSingleLine::scroll(ScrollDirection direction, ScrollGranularity granularity, unsigned stepCount, Element** stopElement, RenderBox* startBox, const IntPoint& wheelEventAbsolutePoint)
    400400{
    401401    auto* renderer = innerTextElement()->renderer();
     
    403403        return false;
    404404    auto* scrollableArea = renderer->layer() ? renderer->layer()->scrollableArea() : nullptr;
    405     if (scrollableArea && scrollableArea->scroll(direction, granularity, multiplier))
     405    if (scrollableArea && scrollableArea->scroll(direction, granularity, stepCount))
    406406        return true;
    407     return RenderBlockFlow::scroll(direction, granularity, multiplier, stopElement, startBox, wheelEventAbsolutePoint);
    408 }
    409 
    410 bool RenderTextControlSingleLine::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, float multiplier, Element** stopElement)
     407    return RenderBlockFlow::scroll(direction, granularity, stepCount, stopElement, startBox, wheelEventAbsolutePoint);
     408}
     409
     410bool RenderTextControlSingleLine::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, unsigned stepCount, Element** stopElement)
    411411{
    412412    auto* layer = innerTextElement()->renderer()->layer();
    413413    auto* scrollableArea = layer ? layer->scrollableArea() : nullptr;
    414     if (scrollableArea && scrollableArea->scroll(logicalToPhysical(direction, style().isHorizontalWritingMode(), style().isFlippedBlocksWritingMode()), granularity, multiplier))
     414    if (scrollableArea && scrollableArea->scroll(logicalToPhysical(direction, style().isHorizontalWritingMode(), style().isFlippedBlocksWritingMode()), granularity, stepCount))
    415415        return true;
    416     return RenderBlockFlow::logicalScroll(direction, granularity, multiplier, stopElement);
     416    return RenderBlockFlow::logicalScroll(direction, granularity, stepCount, stopElement);
    417417}
    418418
  • trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h

    r271439 r286115  
    6060    void setScrollLeft(int, const ScrollPositionChangeOptions&) override;
    6161    void setScrollTop(int, const ScrollPositionChangeOptions&) override;
    62     bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = nullptr, RenderBox* startBox = nullptr, const IntPoint& wheelEventAbsolutePoint = IntPoint()) final;
    63     bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = 0) final;
     62    bool scroll(ScrollDirection, ScrollGranularity, unsigned stepCount = 1, Element** stopElement = nullptr, RenderBox* startBox = nullptr, const IntPoint& wheelEventAbsolutePoint = IntPoint()) final;
     63    bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, unsigned stepCount = 1, Element** stopElement = nullptr) final;
    6464
    6565    int textBlockWidth() const;
Note: See TracChangeset for help on using the changeset viewer.