Changeset 240921 in webkit


Ignore:
Timestamp:
Feb 4, 2019 7:39:48 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

[css-scroll-snap] scroll-snap-align not honored on child with non-visible overflow
https://bugs.webkit.org/show_bug.cgi?id=191816

Patch by Frederic Wang <fwang@igalia.com> on 2019-02-04
Reviewed by Wenson Hsieh.

Source/WebCore:

This patch fixes a bug that prevents children of a scroll container to create snap positions
when they have non-visible overflow. This happens because for such a child, the function
RenderBox::findEnclosingScrollableContainer() will return the child itself rather than the
scroll container. To address that issue, we introduce a new
RenderObject::enclosingScrollableContainerForSnapping() helper function that ensures that
a real RenderBox ancestor is returned.

Test: css3/scroll-snap/scroll-snap-children-with-overflow.html

  • page/scrolling/AxisScrollSnapOffsets.cpp:

(WebCore::updateSnapOffsetsForScrollableArea): Use enclosingScrollableContainerForSnapping()
so that we don't skip children with non-visible overflow.

  • rendering/RenderLayerModelObject.cpp:

(WebCore::RenderLayerModelObject::styleDidChange): Ditto. The new function calls
enclosingBox().

  • rendering/RenderObject.cpp:

(WebCore::RenderObject::enclosingScrollableContainerForSnapping const): Return
the scrollable container of the enclosing box. If it is actually the render object itself
then start the search from the parent box instead.

  • rendering/RenderObject.h: Declare enclosingScrollableContainerForSnapping().

LayoutTests:

Add a test to verify that children with non-visible overflow create snap offsets.

  • css3/scroll-snap/scroll-snap-children-with-overflow-expected.txt: Added.
  • css3/scroll-snap/scroll-snap-children-with-overflow.html: Added.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r240916 r240921  
     12019-02-04  Frederic Wang  <fwang@igalia.com>
     2
     3        [css-scroll-snap] scroll-snap-align not honored on child with non-visible overflow
     4        https://bugs.webkit.org/show_bug.cgi?id=191816
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        Add a test to verify that children with non-visible overflow create snap offsets.
     9
     10        * css3/scroll-snap/scroll-snap-children-with-overflow-expected.txt: Added.
     11        * css3/scroll-snap/scroll-snap-children-with-overflow.html: Added.
     12
    1132019-02-03  Antti Koivisto  <antti@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r240918 r240921  
     12019-02-04  Frederic Wang  <fwang@igalia.com>
     2
     3        [css-scroll-snap] scroll-snap-align not honored on child with non-visible overflow
     4        https://bugs.webkit.org/show_bug.cgi?id=191816
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        This patch fixes a bug that prevents children of a scroll container to create snap positions
     9        when they have non-visible overflow. This happens because for such a child, the function
     10        RenderBox::findEnclosingScrollableContainer() will return the child itself rather than the
     11        scroll container. To address that issue, we introduce a new
     12        RenderObject::enclosingScrollableContainerForSnapping() helper function that ensures that
     13        a real RenderBox ancestor is returned.
     14
     15        Test: css3/scroll-snap/scroll-snap-children-with-overflow.html
     16
     17        * page/scrolling/AxisScrollSnapOffsets.cpp:
     18        (WebCore::updateSnapOffsetsForScrollableArea): Use enclosingScrollableContainerForSnapping()
     19        so that we don't skip children with non-visible overflow.
     20        * rendering/RenderLayerModelObject.cpp:
     21        (WebCore::RenderLayerModelObject::styleDidChange): Ditto. The new function calls
     22        enclosingBox().
     23        * rendering/RenderObject.cpp:
     24        (WebCore::RenderObject::enclosingScrollableContainerForSnapping const): Return
     25        the scrollable container of the enclosing box. If it is actually the render object itself
     26        then start the search from the parent box instead.
     27        * rendering/RenderObject.h: Declare enclosingScrollableContainerForSnapping().
     28
    1292019-02-04  Antti Koivisto  <antti@apple.com>
    230
  • trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp

    r240892 r240921  
    235235#endif
    236236    for (auto* child : scrollContainer->view().boxesWithScrollSnapPositions()) {
    237         if (child->findEnclosingScrollableContainer() != scrollContainer)
     237        if (child->enclosingScrollableContainerForSnapping() != scrollContainer)
    238238            continue;
    239239
  • trunk/Source/WebCore/rendering/RenderLayerModelObject.cpp

    r238837 r240921  
    220220    }
    221221    if (oldStyle && oldStyle->scrollSnapArea() != newStyle.scrollSnapArea()) {
    222         const RenderBox* scrollSnapBox = enclosingBox().findEnclosingScrollableContainer();
     222        auto* scrollSnapBox = enclosingScrollableContainerForSnapping();
    223223        if (scrollSnapBox && scrollSnapBox->layer()) {
    224224            const RenderStyle& style = scrollSnapBox->style();
  • trunk/Source/WebCore/rendering/RenderObject.cpp

    r239685 r240921  
    439439}
    440440
     441const RenderBox* RenderObject::enclosingScrollableContainerForSnapping() const
     442{
     443    auto& renderBox = enclosingBox();
     444    if (auto* scrollableContainer = renderBox.findEnclosingScrollableContainer()) {
     445        // The scrollable container for snapping cannot be the node itself.
     446        if (scrollableContainer != this)
     447            return scrollableContainer;
     448        if (renderBox.parentBox())
     449            return renderBox.parentBox()->findEnclosingScrollableContainer();
     450    }
     451    return nullptr;
     452}
     453
    441454RenderBlock* RenderObject::firstLineBlock() const
    442455{
  • trunk/Source/WebCore/rendering/RenderObject.h

    r239685 r240921  
    166166    WEBCORE_EXPORT RenderBox& enclosingBox() const;
    167167    RenderBoxModelObject& enclosingBoxModelObject() const;
     168    const RenderBox* enclosingScrollableContainerForSnapping() const;
    168169
    169170    // Function to return our enclosing flow thread if we are contained inside one. This
Note: See TracChangeset for help on using the changeset viewer.