Changeset 243919 in webkit


Ignore:
Timestamp:
Apr 4, 2019, 5:11:08 PM (6 years ago)
Author:
Simon Fraser
Message:

Have ScrollableArea store a ScrollType for the current scroll
https://bugs.webkit.org/show_bug.cgi?id=196627

Reviewed by Zalan Bujtas.

Source/WebCore:

RenderLayer had isInUserScroll() which is the opposite of ScrollableArea::inProgrammaticScroll(),
so just have ScrollableArea store a ScrollType.

RenderLayer's scrolling bottleneck, scrollToOffset(), now takes a ScrollType, and pushes
it onto the base class.

AsyncScrollingCoordinator::requestScrollPositionUpdate() can use the incoming scrollType (currently
incorrect for iOS WK2 overflow) rather than deducing a user scroll from ScrollingLayerPositionAction.

No behavior change.

  • page/FrameView.cpp:

(WebCore::FrameView::setFrameRect):
(WebCore::FrameView::topContentInsetDidChange):
(WebCore::FrameView::updateLayoutViewport):
(WebCore::FrameView::setScrollPosition):
(WebCore::FrameView::shouldUpdateCompositingLayersAfterScrolling const):
(WebCore::FrameView::setWasScrolledByUser):

  • page/FrameViewLayoutContext.cpp:

(WebCore::LayoutScope::LayoutScope):
(WebCore::LayoutScope::~LayoutScope):

  • page/ios/FrameIOS.mm:

(WebCore::Frame::overflowScrollPositionChangedForNode):

  • page/scrolling/AsyncScrollingCoordinator.cpp:

(WebCore::AsyncScrollingCoordinator::requestScrollPositionUpdate):
(WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll):
(WebCore::AsyncScrollingCoordinator::reconcileScrollingState):

  • platform/ScrollView.cpp:

(WebCore::ScrollView::setScrollPosition):

  • platform/ScrollableArea.cpp:

(WebCore::ScrollableArea::ScrollableArea):

  • platform/ScrollableArea.h:

(WebCore::ScrollableArea::currentScrollType const):
(WebCore::ScrollableArea::setCurrentScrollType):
(WebCore::ScrollableArea::setIsUserScroll): Deleted.
(WebCore::ScrollableArea::inProgrammaticScroll const): Deleted.
(WebCore::ScrollableArea::setInProgrammaticScroll): Deleted.

  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::RenderLayer):
(WebCore::RenderLayer::scrollToXPosition):
(WebCore::RenderLayer::scrollToYPosition):
(WebCore::RenderLayer::scrollToOffset):
(WebCore::RenderLayer::scrollTo):

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

(WebCore::RenderLayerBacking::updateScrollOffset):

  • rendering/RenderMarquee.cpp:

(WebCore::RenderMarquee::start):

Source/WebKitLegacy/mac:

Send the programmatic scroll type.

  • DOM/DOMHTML.mm:

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

Location:
trunk/Source
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r243917 r243919  
     12019-04-04  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Have ScrollableArea store a ScrollType for the current scroll
     4        https://bugs.webkit.org/show_bug.cgi?id=196627
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        RenderLayer had isInUserScroll() which is the opposite of ScrollableArea::inProgrammaticScroll(),
     9        so just have ScrollableArea store a ScrollType.
     10
     11        RenderLayer's scrolling bottleneck, scrollToOffset(), now takes a ScrollType, and pushes
     12        it onto the base class.
     13
     14        AsyncScrollingCoordinator::requestScrollPositionUpdate() can use the incoming scrollType (currently
     15        incorrect for iOS WK2 overflow) rather than deducing a user scroll from ScrollingLayerPositionAction.
     16
     17        No behavior change.
     18
     19        * page/FrameView.cpp:
     20        (WebCore::FrameView::setFrameRect):
     21        (WebCore::FrameView::topContentInsetDidChange):
     22        (WebCore::FrameView::updateLayoutViewport):
     23        (WebCore::FrameView::setScrollPosition):
     24        (WebCore::FrameView::shouldUpdateCompositingLayersAfterScrolling const):
     25        (WebCore::FrameView::setWasScrolledByUser):
     26        * page/FrameViewLayoutContext.cpp:
     27        (WebCore::LayoutScope::LayoutScope):
     28        (WebCore::LayoutScope::~LayoutScope):
     29        * page/ios/FrameIOS.mm:
     30        (WebCore::Frame::overflowScrollPositionChangedForNode):
     31        * page/scrolling/AsyncScrollingCoordinator.cpp:
     32        (WebCore::AsyncScrollingCoordinator::requestScrollPositionUpdate):
     33        (WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll):
     34        (WebCore::AsyncScrollingCoordinator::reconcileScrollingState):
     35        * platform/ScrollView.cpp:
     36        (WebCore::ScrollView::setScrollPosition):
     37        * platform/ScrollableArea.cpp:
     38        (WebCore::ScrollableArea::ScrollableArea):
     39        * platform/ScrollableArea.h:
     40        (WebCore::ScrollableArea::currentScrollType const):
     41        (WebCore::ScrollableArea::setCurrentScrollType):
     42        (WebCore::ScrollableArea::setIsUserScroll): Deleted.
     43        (WebCore::ScrollableArea::inProgrammaticScroll const): Deleted.
     44        (WebCore::ScrollableArea::setInProgrammaticScroll): Deleted.
     45        * rendering/RenderLayer.cpp:
     46        (WebCore::RenderLayer::RenderLayer):
     47        (WebCore::RenderLayer::scrollToXPosition):
     48        (WebCore::RenderLayer::scrollToYPosition):
     49        (WebCore::RenderLayer::scrollToOffset):
     50        (WebCore::RenderLayer::scrollTo):
     51        * rendering/RenderLayer.h:
     52        * rendering/RenderLayerBacking.cpp:
     53        (WebCore::RenderLayerBacking::updateScrollOffset):
     54        * rendering/RenderMarquee.cpp:
     55        (WebCore::RenderMarquee::start):
     56
    1572019-04-04  Shawn Roberts  <sroberts@apple.com>
    258
  • trunk/Source/WebCore/page/FrameView.cpp

    r243905 r243919  
    460460    if (newRect == oldRect)
    461461        return;
     462
    462463    // Every scroll that happens as the result of frame size change is programmatic.
    463     bool wasInProgrammaticScroll = inProgrammaticScroll();
    464     setInProgrammaticScroll(true);
     464    auto oldScrollType = currentScrollType();
     465    setCurrentScrollType(ScrollType::Programmatic);
     466
    465467    ScrollView::setFrameRect(newRect);
    466468
     
    476478
    477479    viewportContentsChanged();
    478     setInProgrammaticScroll(wasInProgrammaticScroll);
     480    setCurrentScrollType(oldScrollType);
    479481}
    480482
     
    10931095    layoutContext().layout();
    10941096    // Every scroll that happens as the result of content inset change is programmatic.
    1095     bool wasInProgrammaticScroll = inProgrammaticScroll();
    1096     setInProgrammaticScroll(true);
     1097    auto oldScrollType = currentScrollType();
     1098    setCurrentScrollType(ScrollType::Programmatic);
     1099
    10971100    updateScrollbars(scrollPosition());
    10981101    if (renderView->usesCompositing())
     
    11021105        tiledBacking->setTopContentInset(newTopContentInset);
    11031106
    1104     setInProgrammaticScroll(wasInProgrammaticScroll);
     1107    setCurrentScrollType(oldScrollType);
    11051108}
    11061109
     
    16761679   
    16771680    if (m_layoutViewportOverrideRect) {
    1678         if (inProgrammaticScroll()) {
     1681        if (currentScrollType() == ScrollType::Programmatic) {
    16791682            LOG_WITH_STREAM(Scrolling, stream << "computing new override layout viewport because of programmatic scrolling");
    16801683            LayoutPoint newOrigin = computeLayoutViewportOrigin(visualViewportRect(), minStableLayoutViewportOrigin(), maxStableLayoutViewportOrigin(), layoutViewport, StickToDocumentBounds);
     
    22802283    LOG_WITH_STREAM(Scrolling, stream << "FrameView::setScrollPosition " << scrollPosition << " , clearing anchor");
    22812284
    2282     bool wasInProgrammaticScroll = inProgrammaticScroll();
    2283     setInProgrammaticScroll(true);
     2285    auto oldScrollType = currentScrollType();
     2286    setCurrentScrollType(ScrollType::Programmatic);
    22842287
    22852288    m_maintainScrollPositionAnchor = nullptr;
     
    22912294    ScrollView::setScrollPosition(scrollPosition);
    22922295
    2293     setInProgrammaticScroll(wasInProgrammaticScroll);
     2296    setCurrentScrollType(oldScrollType);
    22942297}
    22952298
     
    25652568        return true;
    25662569
    2567     if (inProgrammaticScroll())
     2570    if (currentScrollType() == ScrollType::Programmatic)
    25682571        return true;
    25692572
     
    41104113    m_shouldScrollToFocusedElement = false;
    41114114    m_delayedScrollToFocusedElementTimer.stop();
    4112     if (inProgrammaticScroll())
     4115    if (currentScrollType() == ScrollType::Programmatic)
    41134116        return;
    41144117    m_maintainScrollPositionAnchor = nullptr;
  • trunk/Source/WebCore/page/FrameViewLayoutContext.cpp

    r243643 r243919  
    117117        , m_nestedState(layoutContext.m_layoutNestedState, layoutContext.m_layoutNestedState == FrameViewLayoutContext::LayoutNestedState::NotInLayout ? FrameViewLayoutContext::LayoutNestedState::NotNested : FrameViewLayoutContext::LayoutNestedState::Nested)
    118118        , m_schedulingIsEnabled(layoutContext.m_layoutSchedulingIsEnabled, false)
    119         , m_inProgrammaticScroll(layoutContext.view().inProgrammaticScroll())
    120     {
    121         m_view.setInProgrammaticScroll(true);
     119        , m_previousScrollType(layoutContext.view().currentScrollType())
     120    {
     121        m_view.setCurrentScrollType(ScrollType::Programmatic);
    122122    }
    123123       
    124124    ~LayoutScope()
    125125    {
    126         m_view.setInProgrammaticScroll(m_inProgrammaticScroll);
     126        m_view.setCurrentScrollType(m_previousScrollType);
    127127    }
    128128       
     
    131131    SetForScope<FrameViewLayoutContext::LayoutNestedState> m_nestedState;
    132132    SetForScope<bool> m_schedulingIsEnabled;
    133     bool m_inProgrammaticScroll { false };
     133    ScrollType m_previousScrollType;
    134134};
    135135
  • trunk/Source/WebCore/page/ios/FrameIOS.mm

    r240237 r243919  
    706706    RenderLayer& layer = *downcast<RenderBoxModelObject>(*renderer).layer();
    707707
    708     layer.setIsUserScroll(isUserScroll);
     708    auto oldScrollType = layer.currentScrollType();
     709    layer.setCurrentScrollType(isUserScroll ? ScrollType::User : ScrollType::Programmatic);
    709710    layer.scrollToOffsetWithoutAnimation(position);
    710     layer.setIsUserScroll(false);
     711    layer.setCurrentScrollType(oldScrollType);
     712
    711713    layer.didEndScroll(); // FIXME: Should we always call this?
    712714}
  • trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp

    r243855 r243919  
    214214
    215215    bool inPageCache = frameView.frame().document()->pageCacheState() != Document::NotInPageCache;
    216     bool inProgrammaticScroll = frameView.inProgrammaticScroll();
     216    bool inProgrammaticScroll = frameView.currentScrollType() == ScrollType::Programmatic;
    217217    if (inProgrammaticScroll || inPageCache)
    218218        updateScrollPositionAfterAsyncScroll(frameView.scrollingNodeID(), scrollPosition, { }, ScrollType::Programmatic, ScrollingLayerPositionAction::Set);
     
    326326    // Overflow-scroll area.
    327327    if (auto* scrollableArea = frameView.scrollableAreaForScrollLayerID(scrollingNodeID)) {
    328         scrollableArea->setIsUserScroll(scrollingLayerPositionAction == ScrollingLayerPositionAction::Sync);
     328        auto previousScrollType = scrollableArea->currentScrollType();
     329        scrollableArea->setCurrentScrollType(scrollType);
    329330        scrollableArea->scrollToOffsetWithoutAnimation(scrollPosition);
    330         scrollableArea->setIsUserScroll(false);
     331        scrollableArea->setCurrentScrollType(previousScrollType);
     332
    331333        if (scrollingLayerPositionAction == ScrollingLayerPositionAction::Set)
    332334            m_page->editorClient().overflowScrollPositionChanged();
     
    344346void AsyncScrollingCoordinator::reconcileScrollingState(FrameView& frameView, const FloatPoint& scrollPosition, const LayoutViewportOriginOrOverrideRect& layoutViewportOriginOrOverrideRect, ScrollType scrollType, ViewportRectStability viewportRectStability, ScrollingLayerPositionAction scrollingLayerPositionAction)
    345347{
    346     bool oldProgrammaticScroll = frameView.inProgrammaticScroll();
    347     frameView.setInProgrammaticScroll(scrollType == ScrollType::Programmatic);
     348    auto previousScrollType = frameView.currentScrollType();
     349    frameView.setCurrentScrollType(scrollType);
    348350
    349351    LOG_WITH_STREAM(Scrolling, stream << getCurrentProcessID() << " AsyncScrollingCoordinator " << this << " reconcileScrollingState scrollPosition " << scrollPosition << " type " << scrollType << " stability " << viewportRectStability << " " << scrollingLayerPositionAction);
     
    368370    frameView.notifyScrollPositionChanged(roundedIntPoint(scrollPosition));
    369371    frameView.setConstrainsScrollingToContentEdge(true);
    370     frameView.setInProgrammaticScroll(oldProgrammaticScroll);
     372
     373    frameView.setCurrentScrollType(previousScrollType);
    371374
    372375    if (scrollType == ScrollType::User && scrollingLayerPositionAction != ScrollingLayerPositionAction::Set) {
  • trunk/Source/WebCore/platform/ScrollView.cpp

    r240249 r243919  
    502502    ScrollPosition newScrollPosition = !delegatesScrolling() ? adjustScrollPositionWithinRange(scrollPosition) : scrollPosition;
    503503
    504     if ((!delegatesScrolling() || !inProgrammaticScroll()) && newScrollPosition == this->scrollPosition())
     504    if ((!delegatesScrolling() || currentScrollType() == ScrollType::User) && newScrollPosition == this->scrollPosition())
    505505        return;
    506506
  • trunk/Source/WebCore/platform/ScrollableArea.cpp

    r243905 r243919  
    6767    , m_scrollbarOverlayStyle(ScrollbarOverlayStyleDefault)
    6868    , m_scrollOriginChanged(false)
    69     , m_inProgrammaticScroll(false)
     69    , m_currentScrollType(static_cast<unsigned>(ScrollType::User))
    7070    , m_scrollShouldClearLatchedState(false)
    7171{
  • trunk/Source/WebCore/platform/ScrollableArea.h

    r243905 r243919  
    9696    virtual void didUpdateScroll() { }
    9797#endif
    98     virtual void setIsUserScroll(bool) { }
    9998
    10099    // Functions for controlling if you can scroll past the end of the document.
     
    229228    WEBCORE_EXPORT virtual bool scrolledToRight() const;
    230229
    231     bool inProgrammaticScroll() const { return m_inProgrammaticScroll; }
    232     void setInProgrammaticScroll(bool inProgrammaticScroll) { m_inProgrammaticScroll = inProgrammaticScroll; }
     230    ScrollType currentScrollType() const { return static_cast<ScrollType>(m_currentScrollType); }
     231    void setCurrentScrollType(ScrollType scrollType) { m_currentScrollType = static_cast<unsigned>(scrollType); }
    233232
    234233    bool scrollShouldClearLatchedState() const { return m_scrollShouldClearLatchedState; }
     
    395394
    396395    unsigned m_scrollOriginChanged : 1;
    397     unsigned m_inProgrammaticScroll : 1;
     396    unsigned m_currentScrollType : 1; // ScrollType
    398397    unsigned m_scrollShouldClearLatchedState : 1;
    399398};
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r243893 r243919  
    302302    , m_adjustForIOSCaretWhenScrolling(false)
    303303#endif
    304     , m_inUserScroll(false)
    305304    , m_requiresScrollPositionReconciliation(false)
    306305    , m_containsDirtyOverlayScrollbars(false)
     
    23222321}
    23232322
    2324 void RenderLayer::scrollToXPosition(int x, ScrollType, ScrollClamping clamping)
     2323void RenderLayer::scrollToXPosition(int x, ScrollType scrollType, ScrollClamping clamping)
    23252324{
    23262325    ScrollPosition position(x, m_scrollPosition.y());
    2327     scrollToOffset(scrollOffsetFromPosition(position), clamping);
    2328 }
    2329 
    2330 void RenderLayer::scrollToYPosition(int y, ScrollType, ScrollClamping clamping)
     2326    scrollToOffset(scrollOffsetFromPosition(position), scrollType, clamping);
     2327}
     2328
     2329void RenderLayer::scrollToYPosition(int y, ScrollType scrollType, ScrollClamping clamping)
    23312330{
    23322331    ScrollPosition position(m_scrollPosition.x(), y);
    2333     scrollToOffset(scrollOffsetFromPosition(position), clamping);
     2332    scrollToOffset(scrollOffsetFromPosition(position), scrollType, clamping);
    23342333}
    23352334
     
    23392338}
    23402339
    2341 void RenderLayer::scrollToOffset(const ScrollOffset& scrollOffset, ScrollClamping clamping)
     2340void RenderLayer::scrollToOffset(const ScrollOffset& scrollOffset, ScrollType scrollType, ScrollClamping clamping)
    23422341{
    23432342    ScrollOffset newScrollOffset = clamping == ScrollClamping::Clamped ? clampScrollOffset(scrollOffset) : scrollOffset;
    2344     if (newScrollOffset != this->scrollOffset())
    2345         scrollToOffsetWithoutAnimation(newScrollOffset, clamping);
     2343    if (newScrollOffset == this->scrollOffset())
     2344        return;
     2345
     2346    auto previousScrollType = currentScrollType();
     2347    setCurrentScrollType(scrollType);
     2348
     2349    scrollToOffsetWithoutAnimation(newScrollOffset, clamping);
     2350
     2351    setCurrentScrollType(previousScrollType);
    23462352}
    23472353
     
    23522358        return;
    23532359
    2354     LOG_WITH_STREAM(Scrolling, stream << "RenderLayer::scrollTo " << position << " from " << m_scrollPosition << " (in user scroll " << isInUserScroll() << ")");
     2360    LOG_WITH_STREAM(Scrolling, stream << "RenderLayer::scrollTo " << position << " from " << m_scrollPosition << " (is user scroll " << (currentScrollType() == ScrollType::User) << ")");
    23552361
    23562362    ScrollPosition newPosition = position;
  • trunk/Source/WebCore/rendering/RenderLayer.h

    r243893 r243919  
    415415    void scrollByRecursively(const IntSize& delta, ScrollableArea** scrolledArea = nullptr);
    416416
    417     WEBCORE_EXPORT void scrollToOffset(const ScrollOffset&, ScrollClamping = ScrollClamping::Clamped);
    418     void scrollToXOffset(int x, ScrollClamping clamping = ScrollClamping::Clamped) { scrollToOffset(ScrollOffset(x, scrollOffset().y()), clamping); }
    419     void scrollToYOffset(int y, ScrollClamping clamping = ScrollClamping::Clamped) { scrollToOffset(ScrollOffset(scrollOffset().x(), y), clamping); }
     417    WEBCORE_EXPORT void scrollToOffset(const ScrollOffset&, ScrollType = ScrollType::Programmatic, ScrollClamping = ScrollClamping::Clamped);
    420418
    421419    void scrollToXPosition(int x, ScrollType, ScrollClamping = ScrollClamping::Clamped);
    422420    void scrollToYPosition(int y, ScrollType, ScrollClamping = ScrollClamping::Clamped);
     421
     422    // These are only used by marquee.
     423    void scrollToXOffset(int x, ScrollClamping clamping = ScrollClamping::Clamped) { scrollToOffset(ScrollOffset(x, scrollOffset().y()), ScrollType::Programmatic, clamping); }
     424    void scrollToYOffset(int y, ScrollClamping clamping = ScrollClamping::Clamped) { scrollToOffset(ScrollOffset(scrollOffset().x(), y), ScrollType::Programmatic, clamping); }
    423425
    424426    void setPostLayoutScrollPosition(Optional<ScrollPosition>);
     
    459461    void updateSnapOffsets() override;
    460462#endif
    461 
    462     void setIsUserScroll(bool isUserScroll) override { m_inUserScroll = isUserScroll; }
    463     bool isInUserScroll() const { return m_inUserScroll; }
    464463
    465464    bool requiresScrollPositionReconciliation() const { return m_requiresScrollPositionReconciliation; }
     
    12211220#endif
    12221221
    1223     bool m_inUserScroll : 1;
    12241222    bool m_requiresScrollPositionReconciliation : 1;
    12251223    bool m_containsDirtyOverlayScrollbars : 1;
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r243893 r243919  
    12631263void RenderLayerBacking::updateScrollOffset(ScrollOffset scrollOffset)
    12641264{
    1265     if (m_owningLayer.isInUserScroll()) {
     1265    if (m_owningLayer.currentScrollType() == ScrollType::User) {
    12661266        // If scrolling is happening externally, we don't want to touch the layer bounds origin here because that will cause jitter.
    12671267        setLocationOfScrolledContents(scrollOffset, ScrollingLayerPositionAction::Sync);
  • trunk/Source/WebCore/rendering/RenderMarquee.cpp

    r234808 r243919  
    174174    if (!m_suspended && !m_stopped) {
    175175        if (isHorizontal())
    176             m_layer->scrollToOffset(ScrollOffset(m_start, 0), ScrollClamping::Unclamped);
     176            m_layer->scrollToOffset(ScrollOffset(m_start, 0), ScrollType::Programmatic, ScrollClamping::Unclamped);
    177177        else
    178             m_layer->scrollToOffset(ScrollOffset(0, m_start), ScrollClamping::Unclamped);
     178            m_layer->scrollToOffset(ScrollOffset(0, m_start), ScrollType::Programmatic, ScrollClamping::Unclamped);
    179179    } else {
    180180        m_suspended = false;
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r243841 r243919  
     12019-04-04  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Have ScrollableArea store a ScrollType for the current scroll
     4        https://bugs.webkit.org/show_bug.cgi?id=196627
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        Send the programmatic scroll type.
     9
     10        * DOM/DOMHTML.mm:
     11        (-[DOMHTMLElement setScrollXOffset:scrollYOffset:adjustForIOSCaret:]):
     12
    1132019-04-03  Myles C. Maxfield  <mmaxfield@apple.com>
    214
  • trunk/Source/WebKitLegacy/mac/DOM/DOMHTML.mm

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