Changeset 243701 in webkit


Ignore:
Timestamp:
Apr 1, 2019, 11:33:04 AM (7 years ago)
Author:
Simon Fraser
Message:

Plumb through a ScrollType value that indicates whether a scroll was a user or programmatic scroll
https://bugs.webkit.org/show_bug.cgi?id=196424

Reviewed by Zalan Bujtas.

In preparation for fixing webkit.org/b/195584, we need to know if an overflow scroll
is programmatic, so plumb through an enum value. The functions touched by this patch are
only ever called for programmatic scrolls.

  • dom/Element.cpp:

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

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

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

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

(WebCore::RenderLayer::scrollToXPosition):
(WebCore::RenderLayer::scrollToYPosition):

  • 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:
Location:
trunk/Source/WebCore
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r243695 r243701  
     12019-04-01  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Plumb through a ScrollType value that indicates whether a scroll was a user or programmatic scroll
     4        https://bugs.webkit.org/show_bug.cgi?id=196424
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        In preparation for fixing webkit.org/b/195584, we need to know if an overflow scroll
     9        is programmatic, so plumb through an enum value. The functions touched by this patch are
     10        only ever called for programmatic scrolls.
     11
     12        * dom/Element.cpp:
     13        (WebCore::Element::scrollTo):
     14        (WebCore::Element::setScrollLeft):
     15        (WebCore::Element::setScrollTop):
     16        * platform/ScrollTypes.h:
     17        * rendering/RenderBox.cpp:
     18        (WebCore::RenderBox::setScrollLeft):
     19        (WebCore::RenderBox::setScrollTop):
     20        * rendering/RenderBox.h:
     21        * rendering/RenderLayer.cpp:
     22        (WebCore::RenderLayer::scrollToXPosition):
     23        (WebCore::RenderLayer::scrollToYPosition):
     24        * rendering/RenderLayer.h:
     25        * rendering/RenderListBox.cpp:
     26        (WebCore::RenderListBox::setScrollLeft):
     27        (WebCore::RenderListBox::setScrollTop):
     28        * rendering/RenderListBox.h:
     29        * rendering/RenderTextControlSingleLine.cpp:
     30        (WebCore::RenderTextControlSingleLine::setScrollLeft):
     31        (WebCore::RenderTextControlSingleLine::setScrollTop):
     32        * rendering/RenderTextControlSingleLine.h:
     33
    1342019-04-01  Wenson Hsieh  <wenson_hsieh@apple.com>
    235
  • trunk/Source/WebCore/dom/Element.cpp

    r243643 r243701  
    823823        adjustForAbsoluteZoom(renderer->scrollTop(), *renderer)
    824824    );
    825     renderer->setScrollLeft(clampToInteger(scrollToOptions.left.value() * renderer->style().effectiveZoom()), clamping);
    826     renderer->setScrollTop(clampToInteger(scrollToOptions.top.value() * renderer->style().effectiveZoom()), clamping);
     825    renderer->setScrollLeft(clampToInteger(scrollToOptions.left.value() * renderer->style().effectiveZoom()), ScrollType::Programmatic, clamping);
     826    renderer->setScrollTop(clampToInteger(scrollToOptions.top.value() * renderer->style().effectiveZoom()), ScrollType::Programmatic, clamping);
    827827}
    828828
     
    11451145
    11461146    if (auto* renderer = renderBox()) {
    1147         renderer->setScrollLeft(static_cast<int>(newLeft * renderer->style().effectiveZoom()));
     1147        renderer->setScrollLeft(static_cast<int>(newLeft * renderer->style().effectiveZoom()), ScrollType::Programmatic);
    11481148        if (auto* scrollableArea = renderer->layer())
    11491149            scrollableArea->setScrolledProgrammatically(true);
     
    11621162
    11631163    if (auto* renderer = renderBox()) {
    1164         renderer->setScrollTop(static_cast<int>(newTop * renderer->style().effectiveZoom()));
     1164        renderer->setScrollTop(static_cast<int>(newTop * renderer->style().effectiveZoom()), ScrollType::Programmatic);
    11651165        if (auto* scrollableArea = renderer->layer())
    11661166            scrollableArea->setScrolledProgrammatically(true);
  • trunk/Source/WebCore/platform/ScrollTypes.h

    r242913 r243701  
    3131namespace WebCore {
    3232
     33enum class ScrollType : uint8_t {
     34    User,
     35    Programmatic
     36};
     37
    3338enum ScrollDirection : uint8_t {
    3439    ScrollUp,
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r241747 r243701  
    576576}
    577577
    578 void RenderBox::setScrollLeft(int newLeft, ScrollClamping clamping)
     578void RenderBox::setScrollLeft(int newLeft, ScrollType scrollType, ScrollClamping clamping)
    579579{
    580580    if (!hasOverflowClip() || !layer())
    581581        return;
    582582    setupWheelEventTestTrigger(*layer());
    583     layer()->scrollToXPosition(newLeft, clamping);
    584 }
    585 
    586 void RenderBox::setScrollTop(int newTop, ScrollClamping clamping)
     583    layer()->scrollToXPosition(newLeft, scrollType, clamping);
     584}
     585
     586void RenderBox::setScrollTop(int newTop, ScrollType scrollType, ScrollClamping clamping)
    587587{
    588588    if (!hasOverflowClip() || !layer())
    589589        return;
    590590    setupWheelEventTestTrigger(*layer());
    591     layer()->scrollToYPosition(newTop, clamping);
     591    layer()->scrollToYPosition(newTop, scrollType, clamping);
    592592}
    593593
  • trunk/Source/WebCore/rendering/RenderBox.h

    r240218 r243701  
    248248    virtual int scrollWidth() const;
    249249    virtual int scrollHeight() const;
    250     virtual void setScrollLeft(int, ScrollClamping = ScrollClamping::Clamped);
    251     virtual void setScrollTop(int, ScrollClamping = ScrollClamping::Clamped);
     250    virtual void setScrollLeft(int, ScrollType, ScrollClamping = ScrollClamping::Clamped);
     251    virtual void setScrollTop(int, ScrollType, ScrollClamping = ScrollClamping::Clamped);
    252252
    253253    LayoutUnit marginTop() const override { return m_marginBox.top(); }
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r243694 r243701  
    23222322}
    23232323
    2324 void RenderLayer::scrollToXPosition(int x, ScrollClamping clamping)
     2324void RenderLayer::scrollToXPosition(int x, ScrollType, ScrollClamping clamping)
    23252325{
    23262326    ScrollPosition position(x, m_scrollPosition.y());
     
    23282328}
    23292329
    2330 void RenderLayer::scrollToYPosition(int y, ScrollClamping clamping)
     2330void RenderLayer::scrollToYPosition(int y, ScrollType, ScrollClamping clamping)
    23312331{
    23322332    ScrollPosition position(m_scrollPosition.x(), y);
  • trunk/Source/WebCore/rendering/RenderLayer.h

    r243416 r243701  
    415415    void scrollToYOffset(int y, ScrollClamping clamping = ScrollClamping::Clamped) { scrollToOffset(ScrollOffset(scrollOffset().x(), y), clamping); }
    416416
    417     void scrollToXPosition(int x, ScrollClamping = ScrollClamping::Clamped);
    418     void scrollToYPosition(int y, ScrollClamping = ScrollClamping::Clamped);
     417    void scrollToXPosition(int x, ScrollType, ScrollClamping = ScrollClamping::Clamped);
     418    void scrollToYPosition(int y, ScrollType, ScrollClamping = ScrollClamping::Clamped);
    419419
    420420    void setPostLayoutScrollPosition(Optional<ScrollPosition>);
  • trunk/Source/WebCore/rendering/RenderListBox.cpp

    r240011 r243701  
    750750}
    751751
    752 void RenderListBox::setScrollLeft(int, ScrollClamping)
     752void RenderListBox::setScrollLeft(int, ScrollType, ScrollClamping)
    753753{
    754754}
     
    767767}
    768768
    769 void RenderListBox::setScrollTop(int newTop, ScrollClamping)
     769void RenderListBox::setScrollTop(int newTop, ScrollType, ScrollClamping)
    770770{
    771771    // Determine an index and scroll to it.   
  • trunk/Source/WebCore/rendering/RenderListBox.h

    r239427 r243701  
    107107    int scrollWidth() const override;
    108108    int scrollHeight() const override;
    109     void setScrollLeft(int, ScrollClamping) override;
    110     void setScrollTop(int, ScrollClamping) override;
     109    void setScrollLeft(int, ScrollType, ScrollClamping) override;
     110    void setScrollTop(int, ScrollType, ScrollClamping) override;
    111111
    112112    bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) override;
  • trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp

    r239652 r243701  
    377377}
    378378
    379 void RenderTextControlSingleLine::setScrollLeft(int newLeft, ScrollClamping)
     379void RenderTextControlSingleLine::setScrollLeft(int newLeft, ScrollType, ScrollClamping)
    380380{
    381381    if (innerTextElement())
     
    383383}
    384384
    385 void RenderTextControlSingleLine::setScrollTop(int newTop, ScrollClamping)
     385void RenderTextControlSingleLine::setScrollTop(int newTop, ScrollType, ScrollClamping)
    386386{
    387387    if (innerTextElement())
  • trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h

    r225879 r243701  
    5858    int scrollWidth() const override;
    5959    int scrollHeight() const override;
    60     void setScrollLeft(int, ScrollClamping) override;
    61     void setScrollTop(int, ScrollClamping) override;
     60    void setScrollLeft(int, ScrollType, ScrollClamping) override;
     61    void setScrollTop(int, ScrollType, ScrollClamping) override;
    6262    bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = nullptr, RenderBox* startBox = nullptr, const IntPoint& wheelEventAbsolutePoint = IntPoint()) final;
    6363    bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = 0) final;
Note: See TracChangeset for help on using the changeset viewer.