Changeset 286119 in webkit


Ignore:
Timestamp:
Nov 22, 2021, 1:30:08 PM (4 years ago)
Author:
Simon Fraser
Message:

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

Unreviewed.

Address patch feedback from Chris Lord.

  • dom/Element.cpp:

(WebCore::Element::scrollByUnits):

  • page/FrameView.cpp:

(WebCore::FrameView::adjustVerticalPageScrollStepForFixedContent):
(WebCore::FrameView::adjustScrollStepForFixedContent): Deleted.

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

(WebCore::ScrollAnimator::singleAxisScroll):

  • platform/ScrollTypes.h:

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

  • platform/ScrollableArea.cpp:

(WebCore::ScrollableArea::adjustVerticalPageScrollStepForFixedContent):
(WebCore::ScrollableArea::scroll):
(WebCore::ScrollableArea::adjustScrollStepForFixedContent): Deleted.

  • platform/ScrollableArea.h:
Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r286118 r286119  
     12021-11-22  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        Unreviewed.
     7
     8        Address patch feedback from Chris Lord.
     9
     10        * dom/Element.cpp:
     11        (WebCore::Element::scrollByUnits):
     12        * page/FrameView.cpp:
     13        (WebCore::FrameView::adjustVerticalPageScrollStepForFixedContent):
     14        (WebCore::FrameView::adjustScrollStepForFixedContent): Deleted.
     15        * page/FrameView.h:
     16        * platform/ScrollAnimator.cpp:
     17        (WebCore::ScrollAnimator::singleAxisScroll):
     18        * platform/ScrollTypes.h:
     19        (WebCore::axisFromDirection):
     20        (WebCore::valueForAxis):
     21        (WebCore::setValueForAxis):
     22        * platform/ScrollableArea.cpp:
     23        (WebCore::ScrollableArea::adjustVerticalPageScrollStepForFixedContent):
     24        (WebCore::ScrollableArea::scroll):
     25        (WebCore::ScrollableArea::adjustScrollStepForFixedContent): Deleted.
     26        * platform/ScrollableArea.h:
     27
    1282021-11-22  Fujii Hironori  <Hironori.Fujii@sony.com>
    229
  • trunk/Source/WebCore/dom/Element.cpp

    r286115 r286119  
    11191119        return;
    11201120
    1121     ScrollDirection direction = ScrollDown;
    1122     if (units < 0)
    1123         direction = ScrollUp;
    1124 
     1121    auto direction = units < 0 ? ScrollUp : ScrollDown;
    11251122    auto* stopElement = this;
    11261123    downcast<RenderBox>(*renderer).scroll(direction, granularity, std::abs(units), &stopElement);
  • trunk/Source/WebCore/page/FrameView.cpp

    r286115 r286119  
    38353835}
    38363836
    3837 float FrameView::adjustScrollStepForFixedContent(float step, ScrollEventAxis axis, ScrollGranularity granularity)
    3838 {
    3839     if (granularity != ScrollGranularity::Page || axis == ScrollEventAxis::Horizontal)
    3840         return step;
    3841 
     3837float FrameView::adjustVerticalPageScrollStepForFixedContent(float step)
     3838{
    38423839    TrackedRendererListHashSet* positionedObjects = nullptr;
    38433840    if (RenderView* root = frame().contentRenderer()) {
  • trunk/Source/WebCore/page/FrameView.h

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

    r286115 r286119  
    7070    auto delta = setValueForAxis(FloatSize { }, axis, scrollDelta);
    7171
    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         }
     72    if (behavior.contains(ScrollBehavior::RespectScrollSnap) && m_scrollController.usesScrollSnap()) {
     73        auto currentOffset = offsetFromPosition(currentPosition());
     74        auto newOffset = currentOffset + delta;
     75        auto velocity = copysignf(1.0f, scrollDelta);
     76        auto newOffsetOnAxis = m_scrollController.adjustedScrollDestination(axis, newOffset, velocity, valueForAxis(currentOffset, axis));
     77        newOffset = setValueForAxis(newOffset, axis, newOffsetOnAxis);
     78        delta = newOffset - currentOffset;
    8279    }
    8380
  • trunk/Source/WebCore/platform/ScrollTypes.h

    r286115 r286119  
    180180    case ScrollRight: return ScrollEventAxis::Horizontal;
    181181    }
     182    ASSERT_NOT_REACHED();
    182183    return ScrollEventAxis::Vertical;
    183184}
     
    189190    case ScrollEventAxis::Vertical: return size.height();
    190191    }
     192    ASSERT_NOT_REACHED();
    191193    return 0;
    192194}
     
    202204        return size;
    203205    }
     206    ASSERT_NOT_REACHED();
    204207    return size;
    205208}
     
    211214    case ScrollEventAxis::Vertical: return point.y();
    212215    }
     216    ASSERT_NOT_REACHED();
    213217    return 0;
    214218}
     
    223227        return point;
    224228    }
     229    ASSERT_NOT_REACHED();
    225230    return point;
    226231}
  • trunk/Source/WebCore/platform/ScrollableArea.cpp

    r286115 r286119  
    9292}
    9393
    94 float ScrollableArea::adjustScrollStepForFixedContent(float step, ScrollEventAxis, ScrollGranularity)
     94float ScrollableArea::adjustVerticalPageScrollStepForFixedContent(float step)
    9595{
    9696    return step;
     
    120120
    121121    auto axis = axisFromDirection(direction);
    122     step = adjustScrollStepForFixedContent(step, axis, granularity);
     122
     123    if (granularity == ScrollGranularity::Page && axis == ScrollEventAxis::Vertical)
     124        step = adjustVerticalPageScrollStepForFixedContent(step);
     125
    123126    auto scrollDelta = step * stepCount;
    124127   
  • trunk/Source/WebCore/platform/ScrollableArea.h

    r286115 r286119  
    379379    void resetScrollOriginChanged() { m_scrollOriginChanged = false; }
    380380
    381     WEBCORE_EXPORT virtual float adjustScrollStepForFixedContent(float step, ScrollEventAxis, ScrollGranularity);
     381    WEBCORE_EXPORT virtual float adjustVerticalPageScrollStepForFixedContent(float step);
    382382    virtual void invalidateScrollbarRect(Scrollbar&, const IntRect&) = 0;
    383383    virtual void invalidateScrollCornerRect(const IntRect&) = 0;
Note: See TracChangeset for help on using the changeset viewer.