Changeset 288947 in webkit


Ignore:
Timestamp:
Feb 2, 2022 1:12:57 AM (6 months ago)
Author:
Martin Robinson
Message:

scroll-margin-top doesn't work on inline elements
https://bugs.webkit.org/show_bug.cgi?id=235933
<rdar://87983307>

Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

  • web-platform-tests/css/css-scroll-snap/scroll-target-margin-006-expected.txt: Added.
  • web-platform-tests/css/css-scroll-snap/scroll-target-margin-006.html: Added.

Source/WebCore:

Test: imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-margin-005.html

Move the implementation of absoluteAnchorRectWithScrollMargin which actually processes
the CSS scroll-margin property to RenderElement. This allows it to be used for inline
as well as block elements. The specification says it should apply to both. The box
sizes passed in here do not matter too much, because the Length should never be a
percentage.

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::absoluteAnchorRectWithScrollMargin const): Deleted.

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

(WebCore::RenderElement::absoluteAnchorRectWithScrollMargin const):

  • rendering/RenderElement.h:
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r288906 r288947  
     12022-02-02  Martin Robinson  <mrobinson@webkit.org>
     2
     3        scroll-margin-top doesn't work on inline elements
     4        https://bugs.webkit.org/show_bug.cgi?id=235933
     5        <rdar://87983307>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * web-platform-tests/css/css-scroll-snap/scroll-target-margin-006-expected.txt: Added.
     10        * web-platform-tests/css/css-scroll-snap/scroll-target-margin-006.html: Added.
     11
    1122022-02-01  Antti Koivisto  <antti@apple.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r288944 r288947  
     12022-02-02  Martin Robinson  <mrobinson@webkit.org>
     2
     3        scroll-margin-top doesn't work on inline elements
     4        https://bugs.webkit.org/show_bug.cgi?id=235933
     5        <rdar://87983307>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Test: imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-margin-005.html
     10
     11        Move the implementation of absoluteAnchorRectWithScrollMargin which actually processes
     12        the CSS scroll-margin property to RenderElement. This allows it to be used for inline
     13        as well as block elements. The specification says it should apply to both. The box
     14        sizes passed in here do not matter too much, because the Length should never be a
     15        percentage.
     16
     17        * rendering/RenderBox.cpp:
     18        (WebCore::RenderBox::absoluteAnchorRectWithScrollMargin const): Deleted.
     19        * rendering/RenderBox.h:
     20        * rendering/RenderElement.cpp:
     21        (WebCore::RenderElement::absoluteAnchorRectWithScrollMargin const):
     22        * rendering/RenderElement.h:
     23
    1242022-02-01  Alan Bujtas  <zalan@apple.com>
    225
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r288069 r288947  
    54735473}
    54745474
    5475 LayoutRect RenderBox::absoluteAnchorRectWithScrollMargin(bool* insideFixed) const
    5476 {
    5477     LayoutRect anchorRect = absoluteAnchorRect(insideFixed);
    5478     const LengthBox& scrollMargin = style().scrollMargin();
    5479     if (scrollMargin.isZero())
    5480         return anchorRect;
    5481 
    5482     // The scroll snap specification says that the scroll-margin should be applied in the
    5483     // coordinate system of the scroll container and applied to the rectangular bounding
    5484     // box of the transformed border box of the target element.
    5485     // See https://www.w3.org/TR/css-scroll-snap-1/#scroll-margin.
    5486     const LayoutSize boxSize = size();
    5487     const LayoutBoxExtent margin(
    5488         valueForLength(scrollMargin.top(), boxSize.height()),
    5489         valueForLength(scrollMargin.right(), boxSize.width()),
    5490         valueForLength(scrollMargin.bottom(), boxSize.height()),
    5491         valueForLength(scrollMargin.left(), boxSize.width()));
    5492     anchorRect.expand(margin);
    5493 
    5494     return anchorRect;
    5495 }
    5496 
    54975475LayoutBoxExtent RenderBox::scrollPaddingForViewportRect(const LayoutRect& viewportRect)
    54985476{
  • trunk/Source/WebCore/rendering/RenderBox.h

    r288067 r288947  
    670670    virtual void adjustBorderBoxRectForPainting(LayoutRect&) { };
    671671
    672     LayoutRect absoluteAnchorRectWithScrollMargin(bool* insideFixed = nullptr) const override;
    673 
    674672    bool shouldComputeLogicalHeightFromAspectRatio() const;
    675673
  • trunk/Source/WebCore/rendering/RenderElement.cpp

    r288267 r288947  
    17351735LayoutRect RenderElement::absoluteAnchorRectWithScrollMargin(bool* insideFixed) const
    17361736{
    1737     return absoluteAnchorRect(insideFixed);
     1737    LayoutRect anchorRect = absoluteAnchorRect(insideFixed);
     1738    const LengthBox& scrollMargin = style().scrollMargin();
     1739    if (scrollMargin.isZero())
     1740        return anchorRect;
     1741
     1742    // The scroll snap specification says that the scroll-margin should be applied in the
     1743    // coordinate system of the scroll container and applied to the rectangular bounding
     1744    // box of the transformed border box of the target element.
     1745    // See https://www.w3.org/TR/css-scroll-snap-1/#scroll-margin.
     1746    const LayoutBoxExtent margin(
     1747        valueForLength(scrollMargin.top(), anchorRect.height()),
     1748        valueForLength(scrollMargin.right(), anchorRect.width()),
     1749        valueForLength(scrollMargin.bottom(), anchorRect.height()),
     1750        valueForLength(scrollMargin.left(), anchorRect.width()));
     1751    anchorRect.expand(margin);
     1752    return anchorRect;
    17381753}
    17391754
  • trunk/Source/WebCore/rendering/RenderElement.h

    r288267 r288947  
    191191    // absoluteAnchorRectWithScrollMargin() is similar to absoluteAnchorRect, but it also takes into account any
    192192    // CSS scroll-margin that is set in the style of this RenderElement.
    193     virtual LayoutRect absoluteAnchorRectWithScrollMargin(bool* insideFixed = nullptr) const;
     193    LayoutRect absoluteAnchorRectWithScrollMargin(bool* insideFixed = nullptr) const;
    194194
    195195    bool hasFilter() const { return style().hasFilter(); }
Note: See TracChangeset for help on using the changeset viewer.