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

Changeset 243905 in webkit


Ignore:
Timestamp:
Apr 4, 2019, 2:10:29 PM (7 years ago)
Author:
Simon Fraser
Message:

Move "inProgrammaticScroll" down to ScrollableArea
https://bugs.webkit.org/show_bug.cgi?id=196614

Reviewed by Zalan Bujtas.

A future patch will need to update "inProgrammaticScroll" on RenderLayers, so push
inProgrammaticScroll() down to ScrollableArea.

ScrollableArea already has "isScrolledProgrammatically", which I rename to "scrollShouldClearLatchedState"
to reduce confusion. It might be possible to remove this in future with some refactoring.

Sadly we can no longer use SetForScope<> in FrameView after this change so add some manual save/restore code.

  • dom/Element.cpp:

(WebCore::Element::setScrollLeft):
(WebCore::Element::setScrollTop):

  • page/EventHandler.cpp:

(WebCore::EventHandler::completeWidgetWheelEvent):
(WebCore::EventHandler::handleWheelEvent):

  • page/FrameView.cpp:

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

  • page/FrameView.h:
  • platform/ScrollView.h:

(WebCore::ScrollView::inProgrammaticScroll const): Deleted.

  • platform/ScrollableArea.cpp:

(WebCore::ScrollableArea::ScrollableArea):

  • platform/ScrollableArea.h:

(WebCore::ScrollableArea::inProgrammaticScroll const):
(WebCore::ScrollableArea::setInProgrammaticScroll):
(WebCore::ScrollableArea::scrollShouldClearLatchedState const):
(WebCore::ScrollableArea::setScrollShouldClearLatchedState):
(WebCore::ScrollableArea::isScrolledProgrammatically const): Deleted.
(WebCore::ScrollableArea::setScrolledProgrammatically): Deleted.

Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r243903 r243905  
     12019-04-04  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Move "inProgrammaticScroll" down to ScrollableArea
     4        https://bugs.webkit.org/show_bug.cgi?id=196614
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        A future patch will need to update "inProgrammaticScroll" on RenderLayers, so push
     9        inProgrammaticScroll() down to ScrollableArea.
     10
     11        ScrollableArea already has "isScrolledProgrammatically", which I rename to "scrollShouldClearLatchedState"
     12        to reduce confusion. It might be possible to remove this in future with some refactoring.
     13
     14        Sadly we can no longer use SetForScope<> in FrameView after this change so add some manual save/restore code.
     15
     16        * dom/Element.cpp:
     17        (WebCore::Element::setScrollLeft):
     18        (WebCore::Element::setScrollTop):
     19        * page/EventHandler.cpp:
     20        (WebCore::EventHandler::completeWidgetWheelEvent):
     21        (WebCore::EventHandler::handleWheelEvent):
     22        * page/FrameView.cpp:
     23        (WebCore::FrameView::setFrameRect):
     24        (WebCore::FrameView::topContentInsetDidChange):
     25        (WebCore::FrameView::updateLayoutViewport):
     26        (WebCore::FrameView::setScrollPosition):
     27        (WebCore::FrameView::setWasScrolledByUser):
     28        * page/FrameView.h:
     29        * platform/ScrollView.h:
     30        (WebCore::ScrollView::inProgrammaticScroll const): Deleted.
     31        * platform/ScrollableArea.cpp:
     32        (WebCore::ScrollableArea::ScrollableArea):
     33        * platform/ScrollableArea.h:
     34        (WebCore::ScrollableArea::inProgrammaticScroll const):
     35        (WebCore::ScrollableArea::setInProgrammaticScroll):
     36        (WebCore::ScrollableArea::scrollShouldClearLatchedState const):
     37        (WebCore::ScrollableArea::setScrollShouldClearLatchedState):
     38        (WebCore::ScrollableArea::isScrolledProgrammatically const): Deleted.
     39        (WebCore::ScrollableArea::setScrolledProgrammatically): Deleted.
     40
    1412019-04-04  Sihui Liu  <sihui_liu@apple.com>
    242
  • trunk/Source/WebCore/dom/Element.cpp

    r243893 r243905  
    11411141        renderer->setScrollLeft(static_cast<int>(newLeft * renderer->style().effectiveZoom()), ScrollType::Programmatic);
    11421142        if (auto* scrollableArea = renderer->layer())
    1143             scrollableArea->setScrolledProgrammatically(true);
     1143            scrollableArea->setScrollShouldClearLatchedState(true);
    11441144    }
    11451145}
     
    11581158        renderer->setScrollTop(static_cast<int>(newTop * renderer->style().effectiveZoom()), ScrollType::Programmatic);
    11591159        if (auto* scrollableArea = renderer->layer())
    1160             scrollableArea->setScrolledProgrammatically(true);
     1160            scrollableArea->setScrollShouldClearLatchedState(true);
    11611161    }
    11621162}
  • trunk/Source/WebCore/page/EventHandler.cpp

    r242798 r243905  
    27502750   
    27512751    if (scrollableArea)
    2752         scrollableArea->setScrolledProgrammatically(false);
     2752        scrollableArea->setScrollShouldClearLatchedState(false);
    27532753
    27542754    platformNotifyIfEndGesture(event, scrollableArea);
     
    28132813        if (!element->dispatchWheelEvent(adjustedEvent)) {
    28142814            m_isHandlingWheelEvent = false;
    2815             if (scrollableArea && scrollableArea->isScrolledProgrammatically()) {
     2815            if (scrollableArea && scrollableArea->scrollShouldClearLatchedState()) {
    28162816                // Web developer is controlling scrolling, so don't attempt to latch.
    28172817                clearLatchedState();
    2818                 scrollableArea->setScrolledProgrammatically(false);
     2818                scrollableArea->setScrollShouldClearLatchedState(false);
    28192819            }
    28202820
     
    28252825
    28262826    if (scrollableArea)
    2827         scrollableArea->setScrolledProgrammatically(false);
     2827        scrollableArea->setScrollShouldClearLatchedState(false);
    28282828
    28292829    bool handledEvent = platformCompleteWheelEvent(adjustedEvent, scrollableContainer.get(), scrollableArea);
  • trunk/Source/WebCore/page/FrameView.cpp

    r243643 r243905  
    461461        return;
    462462    // Every scroll that happens as the result of frame size change is programmatic.
    463     SetForScope<bool> changeInProgrammaticScroll(m_inProgrammaticScroll, true);
     463    bool wasInProgrammaticScroll = inProgrammaticScroll();
     464    setInProgrammaticScroll(true);
    464465    ScrollView::setFrameRect(newRect);
    465466
     
    475476
    476477    viewportContentsChanged();
     478    setInProgrammaticScroll(wasInProgrammaticScroll);
    477479}
    478480
     
    10911093    layoutContext().layout();
    10921094    // Every scroll that happens as the result of content inset change is programmatic.
    1093     SetForScope<bool> changeInProgrammaticScroll(m_inProgrammaticScroll, true);
     1095    bool wasInProgrammaticScroll = inProgrammaticScroll();
     1096    setInProgrammaticScroll(true);
    10941097    updateScrollbars(scrollPosition());
    10951098    if (renderView->usesCompositing())
     
    10981101    if (TiledBacking* tiledBacking = this->tiledBacking())
    10991102        tiledBacking->setTopContentInset(newTopContentInset);
     1103
     1104    setInProgrammaticScroll(wasInProgrammaticScroll);
    11001105}
    11011106
     
    16711676   
    16721677    if (m_layoutViewportOverrideRect) {
    1673         if (m_inProgrammaticScroll) {
     1678        if (inProgrammaticScroll()) {
    16741679            LOG_WITH_STREAM(Scrolling, stream << "computing new override layout viewport because of programmatic scrolling");
    16751680            LayoutPoint newOrigin = computeLayoutViewportOrigin(visualViewportRect(), minStableLayoutViewportOrigin(), maxStableLayoutViewportOrigin(), layoutViewport, StickToDocumentBounds);
     
    22752280    LOG_WITH_STREAM(Scrolling, stream << "FrameView::setScrollPosition " << scrollPosition << " , clearing anchor");
    22762281
    2277     SetForScope<bool> changeInProgrammaticScroll(m_inProgrammaticScroll, true);
     2282    bool wasInProgrammaticScroll = inProgrammaticScroll();
     2283    setInProgrammaticScroll(true);
     2284
    22782285    m_maintainScrollPositionAnchor = nullptr;
    22792286    m_shouldScrollToFocusedElement = false;
     
    22832290        scrollAnimator().setWheelEventTestTrigger(page->testTrigger());
    22842291    ScrollView::setScrollPosition(scrollPosition);
     2292
     2293    setInProgrammaticScroll(wasInProgrammaticScroll);
    22852294}
    22862295
     
    41014110    m_shouldScrollToFocusedElement = false;
    41024111    m_delayedScrollToFocusedElementTimer.stop();
    4103     if (m_inProgrammaticScroll)
     4112    if (inProgrammaticScroll())
    41044113        return;
    41054114    m_maintainScrollPositionAnchor = nullptr;
  • trunk/Source/WebCore/page/FrameView.h

    r242082 r243905  
    556556    void setPagination(const Pagination&);
    557557   
    558     bool inProgrammaticScroll() const final { return m_inProgrammaticScroll; }
    559     void setInProgrammaticScroll(bool programmaticScroll) { m_inProgrammaticScroll = programmaticScroll; }
    560 
    561558#if ENABLE(CSS_DEVICE_ADAPTATION)
    562559    IntSize initialViewportSize() const { return m_initialViewportSize; }
     
    924921    bool m_isTrackingRepaints { false }; // Used for testing.
    925922    bool m_wasScrolledByUser { false };
    926     bool m_inProgrammaticScroll { false };
    927923    bool m_shouldScrollToFocusedElement { false };
    928924
  • trunk/Source/WebCore/platform/ScrollView.h

    r242333 r243905  
    197197#endif
    198198
    199     virtual bool inProgrammaticScroll() const { return false; }
    200 
    201199    // Size available for view contents, including content inset areas. Not affected by zooming.
    202200    IntSize sizeForVisibleContent(VisibleContentRectIncludesScrollbars = ExcludeScrollbars) const;
  • trunk/Source/WebCore/platform/ScrollableArea.cpp

    r242333 r243905  
    6767    , m_scrollbarOverlayStyle(ScrollbarOverlayStyleDefault)
    6868    , m_scrollOriginChanged(false)
    69     , m_scrolledProgrammatically(false)
     69    , m_inProgrammaticScroll(false)
     70    , m_scrollShouldClearLatchedState(false)
    7071{
    7172}
  • trunk/Source/WebCore/platform/ScrollableArea.h

    r243416 r243905  
    229229    WEBCORE_EXPORT virtual bool scrolledToRight() const;
    230230
    231     bool isScrolledProgrammatically() const { return m_scrolledProgrammatically; }
    232     void setScrolledProgrammatically(bool state) { m_scrolledProgrammatically = state; }
     231    bool inProgrammaticScroll() const { return m_inProgrammaticScroll; }
     232    void setInProgrammaticScroll(bool inProgrammaticScroll) { m_inProgrammaticScroll = inProgrammaticScroll; }
     233
     234    bool scrollShouldClearLatchedState() const { return m_scrollShouldClearLatchedState; }
     235    void setScrollShouldClearLatchedState(bool shouldClear) { m_scrollShouldClearLatchedState = shouldClear; }
    233236
    234237    enum VisibleContentRectIncludesScrollbars { ExcludeScrollbars, IncludeScrollbars };
     
    392395
    393396    unsigned m_scrollOriginChanged : 1;
    394     unsigned m_scrolledProgrammatically : 1;
     397    unsigned m_inProgrammaticScroll : 1;
     398    unsigned m_scrollShouldClearLatchedState : 1;
    395399};
    396400
Note: See TracChangeset for help on using the changeset viewer.