Changeset 210117 in webkit


Ignore:
Timestamp:
Dec 22, 2016 2:55:31 PM (7 years ago)
Author:
Wenson Hsieh
Message:

CSS Scroll Snap does not work if scrollbar is hidden
https://bugs.webkit.org/show_bug.cgi?id=160442
<rdar://problem/23317034>

Reviewed by Simon Fraser.

Source/WebCore:

Currently, the only reason scroll snapping works in overflow scrolling containers without forcing layout is
because we would initialize the scrolling container's ScrollAnimator in the process of updating scrollbars. If
there are no scrollbars to render, we won't bother creating a ScrollAnimator. Without an existing
ScrollAnimator, ScrollableArea::updateScrollSnapState will simply bail instead of setting up the scroll snap
state. Instead, we should take setting a non-empty vector of scroll offsets on the ScrollableArea as a cue that
the ScrollableArea also needs a ScrollAnimator, and initialize it there if necessary.

Test: tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-hidden-scrollbars.html

  • platform/ScrollableArea.cpp:

(WebCore::ScrollableArea::setHorizontalSnapOffsets):
(WebCore::ScrollableArea::setVerticalSnapOffsets):

LayoutTests:

Adds a new layout test verifying that scroll snapping still works when scrollbars are hidden via CSS.

  • tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-hidden-scrollbars-expected.txt: Added.
  • tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-hidden-scrollbars.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r210113 r210117  
     12016-12-22  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        CSS Scroll Snap does not work if scrollbar is hidden
     4        https://bugs.webkit.org/show_bug.cgi?id=160442
     5        <rdar://problem/23317034>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Adds a new layout test verifying that scroll snapping still works when scrollbars are hidden via CSS.
     10
     11        * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-hidden-scrollbars-expected.txt: Added.
     12        * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-hidden-scrollbars.html: Added.
     13
    1142016-12-22  Daniel Bates  <dabates@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r210112 r210117  
     12016-12-22  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        CSS Scroll Snap does not work if scrollbar is hidden
     4        https://bugs.webkit.org/show_bug.cgi?id=160442
     5        <rdar://problem/23317034>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Currently, the only reason scroll snapping works in overflow scrolling containers without forcing layout is
     10        because we would initialize the scrolling container's ScrollAnimator in the process of updating scrollbars. If
     11        there are no scrollbars to render, we won't bother creating a ScrollAnimator. Without an existing
     12        ScrollAnimator, ScrollableArea::updateScrollSnapState will simply bail instead of setting up the scroll snap
     13        state. Instead, we should take setting a non-empty vector of scroll offsets on the ScrollableArea as a cue that
     14        the ScrollableArea also needs a ScrollAnimator, and initialize it there if necessary.
     15
     16        Test: tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-hidden-scrollbars.html
     17
     18        * platform/ScrollableArea.cpp:
     19        (WebCore::ScrollableArea::setHorizontalSnapOffsets):
     20        (WebCore::ScrollableArea::setVerticalSnapOffsets):
     21
    1222016-12-22  Daniel Bates  <dabates@apple.com>
    223
  • trunk/Source/WebCore/platform/ScrollableArea.cpp

    r200282 r210117  
    428428void ScrollableArea::setHorizontalSnapOffsets(std::unique_ptr<Vector<LayoutUnit>> horizontalSnapOffsets)
    429429{
     430    ASSERT(horizontalSnapOffsets);
     431    // Consider having a non-empty set of snap offsets as a cue to initialize the ScrollAnimator.
     432    if (horizontalSnapOffsets->size())
     433        scrollAnimator();
     434
    430435    m_horizontalSnapOffsets = WTFMove(horizontalSnapOffsets);
    431436}
     
    433438void ScrollableArea::setVerticalSnapOffsets(std::unique_ptr<Vector<LayoutUnit>> verticalSnapOffsets)
    434439{
     440    ASSERT(verticalSnapOffsets);
     441    // Consider having a non-empty set of snap offsets as a cue to initialize the ScrollAnimator.
     442    if (verticalSnapOffsets->size())
     443        scrollAnimator();
     444
    435445    m_verticalSnapOffsets = WTFMove(verticalSnapOffsets);
    436446}
Note: See TracChangeset for help on using the changeset viewer.