Changeset 269144 in webkit


Ignore:
Timestamp:
Oct 29, 2020 4:37:18 AM (3 years ago)
Author:
commit-queue@webkit.org
Message:

Make scroll-margin independent of scroll snapping and have it apply when scrolling to anchors
https://bugs.webkit.org/show_bug.cgi?id=218076

Patch by Martin Robinson <mrobinson@igalia.com> on 2020-10-29
Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

  • web-platform-tests/css/cssom-view/scrollIntoView-scrollMargin-expected.txt: Updated expectation to note new pass.

Source/WebCore:

  • dom/Element.cpp:

(WebCore::Element::scrollIntoView): Use absoluteAnchorRectWithScrollMargin, taking into
account scroll-margin.
(WebCore::Element::scrollIntoViewIfNeeded): Ditto.
(WebCore::Element::scrollIntoViewIfNotVisible): Ditto.

  • page/FrameView.cpp:

(WebCore::FrameView::scrollToAnchor): Ditto.

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::absoluteAnchorRectWithScrollMargin const): Added this override
which properly converts the scroll-margin to LayoutUnits and applies it to absoluteAnchorRect.

  • rendering/RenderBox.h: Added method declaration.
  • rendering/RenderElement.cpp:

(WebCore::RenderElement::absoluteAnchorRectWithScrollMargin const): Added implementation
that simply calls absoluteAnchorRect.

  • rendering/RenderElement.h: Added declaration of new virtual

absoluteAnchorRectWithScrollMargin.

  • rendering/RenderLayerModelObject.cpp:

(WebCore::RenderLayerModelObject::styleDidChange): Get the scroll-margin directly from the
style instead of the now-removed ScrollSnapArea.

  • rendering/style/RenderStyle.cpp:

(WebCore::RenderStyle::scrollMargin const): Move scroll-margin and scroll-snap-align to
m_rareNonInheritedData and get rid of intermediate ScrollSnapArea. These two properties
are no independent.
(WebCore::RenderStyle::scrollMarginTop const): Ditto.
(WebCore::RenderStyle::scrollMarginBottom const): Ditto.
(WebCore::RenderStyle::scrollMarginLeft const): Ditto.
(WebCore::RenderStyle::scrollMarginRight const): Ditto.
(WebCore::RenderStyle::setScrollMarginTop): Ditto.
(WebCore::RenderStyle::setScrollMarginBottom): Ditto.
(WebCore::RenderStyle::setScrollMarginLeft): Ditto.
(WebCore::RenderStyle::setScrollMarginRight): Ditto.
(WebCore::RenderStyle::scrollSnapAlign const): Ditto.
(WebCore::RenderStyle::setScrollSnapAlign): Ditto.
(WebCore::RenderStyle::hasSnapPosition const): Ditto.
(WebCore::RenderStyle::scrollSnapArea const): Deleted.

  • rendering/style/RenderStyle.h: Add accessors for scroll-margin and moved hasSnapPosition

from ScrollSnapArea.

  • rendering/style/StyleRareNonInheritedData.cpp: Removed intermediate ScrollSnapArea data

structure and moved members here.
(WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): Ditto.
(WebCore::StyleRareNonInheritedData::operator== const): Ditto.

  • rendering/style/StyleRareNonInheritedData.h: Ditto.
  • rendering/style/StyleScrollSnapPoints.cpp: Ditto.

(WebCore::StyleScrollSnapArea::copy const): Deleted.
(WebCore::StyleScrollSnapArea::StyleScrollSnapArea): Deleted.

  • rendering/style/StyleScrollSnapPoints.h: Removed ScrollSnapArea.

(WebCore::StyleScrollSnapArea::create): Deleted.
(WebCore::StyleScrollSnapArea::hasSnapPosition const): Deleted.

LayoutTests:

  • TestExpectations: Updated expectations for newly passing tests and marked some tests

as flaky.

Location:
trunk
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r269141 r269144  
     12020-10-29  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Make scroll-margin independent of scroll snapping and have it apply when scrolling to anchors
     4        https://bugs.webkit.org/show_bug.cgi?id=218076
     5
     6        Reviewed by Simon Fraser.
     7
     8        * TestExpectations: Updated expectations for newly passing tests and marked some tests
     9        as flaky.
     10
    1112020-10-29  Cathie Chen  <cathiechen@igalia.com>
    212
  • trunk/LayoutTests/TestExpectations

    r269133 r269144  
    45034503imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-align-002.html [ ImageOnlyFailure ]
    45044504imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-align-003.html [ ImageOnlyFailure ]
    4505 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-margin-001.html [ ImageOnlyFailure ]
    4506 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-margin-002.html [ ImageOnlyFailure ]
    4507 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-margin-003.html [ ImageOnlyFailure ]
    4508 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-margin-004.html [ ImageOnlyFailure ]
     4505webkit.org/b/218325 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-margin-001.html [ Pass ImageOnlyFailure ]
     4506webkit.org/b/218325 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-margin-003.html [ Pass ImageOnlyFailure ]
    45094507imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-padding-001.html [ ImageOnlyFailure ]
    45104508imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-padding-002.html [ ImageOnlyFailure ]
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r269133 r269144  
     12020-10-29  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Make scroll-margin independent of scroll snapping and have it apply when scrolling to anchors
     4        https://bugs.webkit.org/show_bug.cgi?id=218076
     5
     6        Reviewed by Simon Fraser.
     7
     8        * web-platform-tests/css/cssom-view/scrollIntoView-scrollMargin-expected.txt: Updated expectation to note new pass.
     9
    1102020-10-28  Chris Dumez  <cdumez@apple.com>
    211
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scrollIntoView-scrollMargin-expected.txt

    r235659 r269144  
    11
    2 FAIL scrollIntoView({block: "center", inline: "center"}) assert_approx_equals: scrollX expected 153.5 +/- 0.5 but got 158
    3 FAIL scrollIntoView({block: "start", inline: "start"}) assert_approx_equals: scrollX expected 184 +/- 0.5 but got 200
    4 FAIL scrollIntoView({block: "end", inline: "end"}) assert_approx_equals: scrollX expected 123 +/- 0.5 but got 115
     2PASS scrollIntoView({block: "center", inline: "center"})
     3PASS scrollIntoView({block: "start", inline: "start"})
     4PASS scrollIntoView({block: "end", inline: "end"})
    55
  • trunk/Source/WebCore/ChangeLog

    r269143 r269144  
     12020-10-29  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Make scroll-margin independent of scroll snapping and have it apply when scrolling to anchors
     4        https://bugs.webkit.org/show_bug.cgi?id=218076
     5
     6        Reviewed by Simon Fraser.
     7
     8        * dom/Element.cpp:
     9        (WebCore::Element::scrollIntoView): Use absoluteAnchorRectWithScrollMargin, taking into
     10        account scroll-margin.
     11        (WebCore::Element::scrollIntoViewIfNeeded): Ditto.
     12        (WebCore::Element::scrollIntoViewIfNotVisible): Ditto.
     13        * page/FrameView.cpp:
     14        (WebCore::FrameView::scrollToAnchor): Ditto.
     15        * rendering/RenderBox.cpp:
     16        (WebCore::RenderBox::absoluteAnchorRectWithScrollMargin const): Added this override
     17        which properly converts the scroll-margin to LayoutUnits and applies it to absoluteAnchorRect.
     18        * rendering/RenderBox.h: Added method declaration.
     19        * rendering/RenderElement.cpp:
     20        (WebCore::RenderElement::absoluteAnchorRectWithScrollMargin const): Added implementation
     21        that simply calls absoluteAnchorRect.
     22        * rendering/RenderElement.h: Added declaration of new virtual
     23        absoluteAnchorRectWithScrollMargin.
     24        * rendering/RenderLayerModelObject.cpp:
     25        (WebCore::RenderLayerModelObject::styleDidChange): Get the scroll-margin directly from the
     26        style instead of the now-removed ScrollSnapArea.
     27        * rendering/style/RenderStyle.cpp:
     28        (WebCore::RenderStyle::scrollMargin const): Move scroll-margin and scroll-snap-align to
     29        m_rareNonInheritedData and get rid of intermediate ScrollSnapArea. These two properties
     30        are no independent.
     31        (WebCore::RenderStyle::scrollMarginTop const): Ditto.
     32        (WebCore::RenderStyle::scrollMarginBottom const): Ditto.
     33        (WebCore::RenderStyle::scrollMarginLeft const): Ditto.
     34        (WebCore::RenderStyle::scrollMarginRight const): Ditto.
     35        (WebCore::RenderStyle::setScrollMarginTop): Ditto.
     36        (WebCore::RenderStyle::setScrollMarginBottom): Ditto.
     37        (WebCore::RenderStyle::setScrollMarginLeft): Ditto.
     38        (WebCore::RenderStyle::setScrollMarginRight): Ditto.
     39        (WebCore::RenderStyle::scrollSnapAlign const): Ditto.
     40        (WebCore::RenderStyle::setScrollSnapAlign): Ditto.
     41        (WebCore::RenderStyle::hasSnapPosition const): Ditto.
     42        (WebCore::RenderStyle::scrollSnapArea const): Deleted.
     43        * rendering/style/RenderStyle.h: Add accessors for scroll-margin and moved hasSnapPosition
     44        from ScrollSnapArea.
     45        * rendering/style/StyleRareNonInheritedData.cpp: Removed intermediate ScrollSnapArea data
     46        structure and moved members here.
     47        (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): Ditto.
     48        (WebCore::StyleRareNonInheritedData::operator== const): Ditto.
     49        * rendering/style/StyleRareNonInheritedData.h: Ditto.
     50        * rendering/style/StyleScrollSnapPoints.cpp: Ditto.
     51        (WebCore::StyleScrollSnapArea::copy const): Deleted.
     52        (WebCore::StyleScrollSnapArea::StyleScrollSnapArea): Deleted.
     53        * rendering/style/StyleScrollSnapPoints.h: Removed ScrollSnapArea.
     54        (WebCore::StyleScrollSnapArea::create): Deleted.
     55        (WebCore::StyleScrollSnapArea::hasSnapPosition const): Deleted.
     56
    1572020-10-29  Chris Lord  <clord@igalia.com>
    258
  • trunk/Source/WebCore/dom/Element.cpp

    r268932 r269144  
    862862
    863863    bool insideFixed;
    864     LayoutRect absoluteBounds = renderer()->absoluteAnchorRect(&insideFixed);
     864    LayoutRect absoluteBounds = renderer()->absoluteAnchorRectWithScrollMargin(&insideFixed);
    865865
    866866    ScrollIntoViewOptions options;
     
    896896
    897897    bool insideFixed;
    898     LayoutRect absoluteBounds = renderer()->absoluteAnchorRect(&insideFixed);
     898    LayoutRect absoluteBounds = renderer()->absoluteAnchorRectWithScrollMargin(&insideFixed);
    899899    // Align to the top / bottom and to the closest edge.
    900900    if (alignToTop)
     
    912912
    913913    bool insideFixed;
    914     LayoutRect absoluteBounds = renderer()->absoluteAnchorRect(&insideFixed);
     914    LayoutRect absoluteBounds = renderer()->absoluteAnchorRectWithScrollMargin(&insideFixed);
    915915    if (centerIfNeeded)
    916916        renderer()->scrollRectToVisible(absoluteBounds, insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded, ShouldAllowCrossOriginScrolling::No });
     
    927927   
    928928    bool insideFixed;
    929     LayoutRect absoluteBounds = renderer()->absoluteAnchorRect(&insideFixed);
     929    LayoutRect absoluteBounds = renderer()->absoluteAnchorRectWithScrollMargin(&insideFixed);
    930930    if (centerIfNotVisible)
    931931        renderer()->scrollRectToVisible(absoluteBounds, insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignCenterIfNotVisible, ScrollAlignment::alignCenterIfNotVisible, ShouldAllowCrossOriginScrolling::No });
  • trunk/Source/WebCore/page/FrameView.cpp

    r268902 r269144  
    31773177    bool insideFixed = false;
    31783178    if (anchorNode != frame().document() && anchorNode->renderer())
    3179         rect = anchorNode->renderer()->absoluteAnchorRect(&insideFixed);
     3179        rect = anchorNode->renderer()->absoluteAnchorRectWithScrollMargin(&insideFixed);
    31803180
    31813181    LOG_WITH_STREAM(Scrolling, stream << " anchor node rect " << rect);
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r268919 r269144  
    162162
    163163#if ENABLE(CSS_SCROLL_SNAP)
    164     if (hasInitializedStyle() && style().scrollSnapArea().hasSnapPosition())
     164    if (hasInitializedStyle() && style().hasSnapPosition())
    165165        view().unregisterBoxWithScrollSnapPositions(*this);
    166166#endif
     
    278278
    279279#if ENABLE(CSS_SCROLL_SNAP)
    280     bool boxContributesSnapPositions = newStyle.scrollSnapArea().hasSnapPosition();
    281     if (boxContributesSnapPositions || (oldStyle && oldStyle->scrollSnapArea().hasSnapPosition())) {
     280    bool boxContributesSnapPositions = newStyle.hasSnapPosition();
     281    if (boxContributesSnapPositions || (oldStyle && oldStyle->hasSnapPosition())) {
    282282        if (boxContributesSnapPositions)
    283283            view().registerBoxWithScrollSnapPositions(*this);
     
    50555055}
    50565056
     5057LayoutRect RenderBox::absoluteAnchorRectWithScrollMargin(bool* insideFixed) const
     5058{
     5059    LayoutRect anchorRect = absoluteAnchorRect(insideFixed);
     5060    const LengthBox& scrollMargin = style().scrollMargin();
     5061    if (scrollMargin.isZero())
     5062        return anchorRect;
     5063
     5064    // The scroll snap specification says that the scroll-margin should be applied in the
     5065    // coordinate system of the scroll container and applied to the rectangular bounding
     5066    // box of the transformed border box of the target element.
     5067    // See https://www.w3.org/TR/css-scroll-snap-1/#scroll-margin.
     5068    const LayoutSize boxSize = size();
     5069    const LayoutBoxExtent margin(
     5070        valueForLength(scrollMargin.top(), boxSize.height()),
     5071        valueForLength(scrollMargin.right(), boxSize.width()),
     5072        valueForLength(scrollMargin.bottom(), boxSize.height()),
     5073        valueForLength(scrollMargin.left(), boxSize.width()));
     5074    anchorRect.expand(margin);
     5075
     5076    return anchorRect;
     5077}
     5078
    50575079} // namespace WebCore
  • trunk/Source/WebCore/rendering/RenderBox.h

    r268919 r269144  
    645645    virtual void adjustBorderBoxRectForPainting(LayoutRect&) { };
    646646
     647    LayoutRect absoluteAnchorRectWithScrollMargin(bool* insideFixed = nullptr) const override;
     648
    647649protected:
    648650    RenderBox(Element&, RenderStyle&&, BaseTypeFlags);
  • trunk/Source/WebCore/rendering/RenderElement.cpp

    r268249 r269144  
    16581658}
    16591659
     1660LayoutRect RenderElement::absoluteAnchorRectWithScrollMargin(bool* insideFixed) const
     1661{
     1662    return absoluteAnchorRect(insideFixed);
     1663}
     1664
    16601665const RenderElement* RenderElement::enclosingRendererWithTextDecoration(OptionSet<TextDecoration> textDecoration, bool firstLine) const
    16611666{
  • trunk/Source/WebCore/rendering/RenderElement.h

    r268932 r269144  
    156156    bool checkForRepaintDuringLayout() const;
    157157
    158     // anchorRect() is conceptually similar to absoluteBoundingBoxRect(), but is intended for scrolling to an anchor.
    159     // For inline renderers, this gets the logical top left of the first leaf child and the logical bottom right of the
    160     // last leaf child, converts them to absolute coordinates, and makes a box out of them.
     158    // absoluteAnchorRect() is conceptually similar to absoluteBoundingBoxRect(), but is intended for scrolling to an
     159    // anchor. For inline renderers, this gets the logical top left of the first leaf child and the logical bottom
     160    // right of the last leaf child, converts them to absolute coordinates, and makes a box out of them.
    161161    LayoutRect absoluteAnchorRect(bool* insideFixed = nullptr) const;
     162
     163    // absoluteAnchorRectWithScrollMargin() is similar to absoluteAnchorRect, but it also takes into account any
     164    // CSS scroll-margin that is set in the style of this RenderElement.
     165    virtual LayoutRect absoluteAnchorRectWithScrollMargin(bool* insideFixed = nullptr) const;
    162166
    163167    bool hasFilter() const { return style().hasFilter(); }
  • trunk/Source/WebCore/rendering/RenderLayerModelObject.cpp

    r268932 r269144  
    186186        }
    187187    }
    188     if (oldStyle && oldStyle->scrollSnapArea() != newStyle.scrollSnapArea()) {
     188
     189    bool scrollMarginChanged =
     190        oldStyle && oldStyle->scrollMargin() != newStyle.scrollMargin();
     191    bool scrollAlignChanged =
     192        oldStyle && oldStyle->scrollSnapAlign() != newStyle.scrollSnapAlign();
     193    if (scrollMarginChanged || scrollAlignChanged) {
    189194        auto* scrollSnapBox = enclosingScrollableContainerForSnapping();
    190195        if (scrollSnapBox && scrollSnapBox->layer()) {
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r268889 r269144  
    23932393}
    23942394
     2395const LengthBox& RenderStyle::scrollMargin() const
     2396{
     2397    return m_rareNonInheritedData->scrollMargin;
     2398}
     2399
     2400const Length& RenderStyle::scrollMarginTop() const
     2401{
     2402    return scrollMargin().top();
     2403}
     2404
     2405const Length& RenderStyle::scrollMarginBottom() const
     2406{
     2407    return scrollMargin().bottom();
     2408}
     2409
     2410const Length& RenderStyle::scrollMarginLeft() const
     2411{
     2412    return scrollMargin().left();
     2413}
     2414
     2415const Length& RenderStyle::scrollMarginRight() const
     2416{
     2417    return scrollMargin().right();
     2418}
     2419
     2420void RenderStyle::setScrollMarginTop(Length&& length)
     2421{
     2422    SET_VAR(m_rareNonInheritedData, scrollMargin.top(), WTFMove(length));
     2423}
     2424
     2425void RenderStyle::setScrollMarginBottom(Length&& length)
     2426{
     2427    SET_VAR(m_rareNonInheritedData, scrollMargin.bottom(), WTFMove(length));
     2428}
     2429
     2430void RenderStyle::setScrollMarginLeft(Length&& length)
     2431{
     2432    SET_VAR(m_rareNonInheritedData, scrollMargin.left(), WTFMove(length));
     2433}
     2434
     2435void RenderStyle::setScrollMarginRight(Length&& length)
     2436{
     2437    SET_VAR(m_rareNonInheritedData, scrollMargin.right(), WTFMove(length));
     2438}
     2439
    23952440#if ENABLE(CSS_SCROLL_SNAP)
    23962441
     
    24052450}
    24062451
    2407 const StyleScrollSnapArea& RenderStyle::scrollSnapArea() const
    2408 {
    2409     return *m_rareNonInheritedData->scrollSnapArea;
    2410 }
    2411 
    24122452const StyleScrollSnapPort& RenderStyle::scrollSnapPort() const
    24132453{
     
    24472487const ScrollSnapAlign& RenderStyle::scrollSnapAlign() const
    24482488{
    2449     return m_rareNonInheritedData->scrollSnapArea->alignment;
    2450 }
    2451 
    2452 const LengthBox& RenderStyle::scrollMargin() const
    2453 {
    2454     return m_rareNonInheritedData->scrollSnapArea->scrollMargin;
    2455 }
    2456 
    2457 const Length& RenderStyle::scrollMarginTop() const
    2458 {
    2459     return scrollMargin().top();
    2460 }
    2461 
    2462 const Length& RenderStyle::scrollMarginBottom() const
    2463 {
    2464     return scrollMargin().bottom();
    2465 }
    2466 
    2467 const Length& RenderStyle::scrollMarginLeft() const
    2468 {
    2469     return scrollMargin().left();
    2470 }
    2471 
    2472 const Length& RenderStyle::scrollMarginRight() const
    2473 {
    2474     return scrollMargin().right();
     2489    return m_rareNonInheritedData->scrollSnapAlign;
    24752490}
    24762491
     
    25022517void RenderStyle::setScrollSnapAlign(const ScrollSnapAlign& alignment)
    25032518{
    2504     SET_NESTED_VAR(m_rareNonInheritedData, scrollSnapArea, alignment, alignment);
    2505 }
    2506 
    2507 void RenderStyle::setScrollMarginTop(Length&& length)
    2508 {
    2509     SET_NESTED_VAR(m_rareNonInheritedData, scrollSnapArea, scrollMargin.top(), WTFMove(length));
    2510 }
    2511 
    2512 void RenderStyle::setScrollMarginBottom(Length&& length)
    2513 {
    2514     SET_NESTED_VAR(m_rareNonInheritedData, scrollSnapArea, scrollMargin.bottom(), WTFMove(length));
    2515 }
    2516 
    2517 void RenderStyle::setScrollMarginLeft(Length&& length)
    2518 {
    2519     SET_NESTED_VAR(m_rareNonInheritedData, scrollSnapArea, scrollMargin.left(), WTFMove(length));
    2520 }
    2521 
    2522 void RenderStyle::setScrollMarginRight(Length&& length)
    2523 {
    2524     SET_NESTED_VAR(m_rareNonInheritedData, scrollSnapArea, scrollMargin.right(), WTFMove(length));
    2525 }
    2526 
     2519    SET_VAR(m_rareNonInheritedData, scrollSnapAlign, alignment);
     2520}
     2521
     2522bool RenderStyle::hasSnapPosition() const
     2523{
     2524    const ScrollSnapAlign& alignment = this->scrollSnapAlign();
     2525    return alignment.x != ScrollSnapAxisAlignType::None || alignment.y != ScrollSnapAxisAlignType::None;
     2526}
    25272527#endif
    25282528
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r269037 r269144  
    720720    OptionSet<EventListenerRegionType> eventListenerRegionTypes() const { return m_rareInheritedData->eventListenerRegionTypes; }
    721721
     722    const LengthBox& scrollMargin() const;
     723    const Length& scrollMarginTop() const;
     724    const Length& scrollMarginBottom() const;
     725    const Length& scrollMarginLeft() const;
     726    const Length& scrollMarginRight() const;
     727
    722728#if ENABLE(CSS_SCROLL_SNAP)
     729    bool hasSnapPosition() const;
     730
    723731    // Scroll snap port style.
    724732    const StyleScrollSnapPort& scrollSnapPort() const;
     
    730738    const Length& scrollPaddingRight() const;
    731739
    732     // Scroll snap area style.
    733     const StyleScrollSnapArea& scrollSnapArea() const;
    734740    const ScrollSnapAlign& scrollSnapAlign() const;
    735     const LengthBox& scrollMargin() const;
    736     const Length& scrollMarginTop() const;
    737     const Length& scrollMarginBottom() const;
    738     const Length& scrollMarginLeft() const;
    739     const Length& scrollMarginRight() const;
    740741#endif
    741742
     
    12661267    void setEventListenerRegionTypes(OptionSet<EventListenerRegionType> eventListenerTypes) { SET_VAR(m_rareInheritedData, eventListenerRegionTypes, eventListenerTypes); }
    12671268
     1269    void setScrollMarginTop(Length&&);
     1270    void setScrollMarginBottom(Length&&);
     1271    void setScrollMarginLeft(Length&&);
     1272    void setScrollMarginRight(Length&&);
     1273
    12681274#if ENABLE(CSS_SCROLL_SNAP)
    12691275    void setScrollSnapType(const ScrollSnapType&);
     
    12741280
    12751281    void setScrollSnapAlign(const ScrollSnapAlign&);
    1276     void setScrollMarginTop(Length&&);
    1277     void setScrollMarginBottom(Length&&);
    1278     void setScrollMarginLeft(Length&&);
    1279     void setScrollMarginRight(Length&&);
    12801282#endif
    12811283
     
    16751677    static TouchAction initialTouchActions() { return TouchAction::Auto; }
    16761678
     1679    static Length initialScrollMargin() { return Length(Fixed); }
     1680
    16771681#if ENABLE(CSS_SCROLL_SNAP)
    16781682    static ScrollSnapType initialScrollSnapType();
    16791683    static ScrollSnapAlign initialScrollSnapAlign();
    1680     static Length initialScrollMargin() { return Length(Fixed); }
    16811684    static Length initialScrollPadding() { return Length(Fixed); }
    16821685#endif
  • trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp

    r268173 r269144  
    3232#include "StyleImage.h"
    3333#include "StyleResolver.h"
    34 #include "StyleScrollSnapPoints.h"
    3534#include <wtf/PointerComparison.h>
    3635#include <wtf/RefPtr.h>
     
    6362#if ENABLE(CSS_SCROLL_SNAP)
    6463    , scrollSnapPort(StyleScrollSnapPort::create())
    65     , scrollSnapArea(StyleScrollSnapArea::create())
    6664#endif
    6765    , willChange(RenderStyle::initialWillChange())
     
    140138    , grid(o.grid)
    141139    , gridItem(o.gridItem)
     140    , scrollMargin(o.scrollMargin)
    142141#if ENABLE(CSS_SCROLL_SNAP)
    143142    , scrollSnapPort(o.scrollSnapPort)
    144     , scrollSnapArea(o.scrollSnapArea)
     143    , scrollSnapAlign(o.scrollSnapAlign)
    145144#endif
    146145    , content(o.content ? o.content->clone() : nullptr)
     
    242241        && grid == o.grid
    243242        && gridItem == o.gridItem
     243        && scrollMargin == o.scrollMargin
    244244#if ENABLE(CSS_SCROLL_SNAP)
    245245        && scrollSnapPort == o.scrollSnapPort
    246         && scrollSnapArea == o.scrollSnapArea
     246        && scrollSnapAlign == o.scrollSnapAlign
    247247#endif
    248248        && contentDataEquivalent(o)
  • trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h

    r267985 r269144  
    4646#include <wtf/Vector.h>
    4747
     48#if ENABLE(CSS_SCROLL_SNAP)
     49#include "StyleScrollSnapPoints.h"
     50#endif
     51
    4852namespace WebCore {
    4953
     
    6165class StyleReflection;
    6266class StyleResolver;
    63 class StyleScrollSnapArea;
    64 class StyleScrollSnapPort;
    6567class StyleTransformData;
    6668
     
    130132    DataRef<StyleGridItemData> gridItem;
    131133
     134    LengthBox scrollMargin { 0, 0, 0, 0 };
    132135#if ENABLE(CSS_SCROLL_SNAP)
    133136    DataRef<StyleScrollSnapPort> scrollSnapPort;
    134     DataRef<StyleScrollSnapArea> scrollSnapArea;
     137    ScrollSnapAlign scrollSnapAlign;
    135138#endif
    136139
  • trunk/Source/WebCore/rendering/style/StyleScrollSnapPoints.cpp

    r268889 r269144  
    4747}
    4848
    49 Ref<StyleScrollSnapArea> StyleScrollSnapArea::copy() const
    50 {
    51     return adoptRef(*new StyleScrollSnapArea(*this));
    52 }
    53 
    54 StyleScrollSnapArea::StyleScrollSnapArea()
    55     : scrollMargin(0, 0, 0, 0)
    56 {
    57 }
    58 
    59 inline StyleScrollSnapArea::StyleScrollSnapArea(const StyleScrollSnapArea& other)
    60     : RefCounted()
    61     , alignment(other.alignment)
    62     , scrollMargin(other.scrollMargin)
    63 {
    64 }
    65 
    6649} // namespace WebCore
    6750
  • trunk/Source/WebCore/rendering/style/StyleScrollSnapPoints.h

    r268889 r269144  
    8080inline bool operator!=(const ScrollSnapAlign& a, const ScrollSnapAlign& b) { return !(a == b); }
    8181
    82 class StyleScrollSnapArea : public RefCounted<StyleScrollSnapArea> {
    83 public:
    84     static Ref<StyleScrollSnapArea> create() { return adoptRef(*new StyleScrollSnapArea); }
    85     Ref<StyleScrollSnapArea> copy() const;
    86     bool hasSnapPosition() const { return alignment.x != ScrollSnapAxisAlignType::None || alignment.y != ScrollSnapAxisAlignType::None; }
    87 
    88     ScrollSnapAlign alignment;
    89     LengthBox scrollMargin { 0, 0, 0, 0 };
    90 
    91 private:
    92     StyleScrollSnapArea();
    93     StyleScrollSnapArea(const StyleScrollSnapArea&);
    94 };
    95 
    96 inline bool operator==(const StyleScrollSnapArea& a, const StyleScrollSnapArea& b)
    97 {
    98     return a.alignment == b.alignment && a.scrollMargin == b.scrollMargin;
    99 }
    100 
    101 inline bool operator!=(const StyleScrollSnapArea& a, const StyleScrollSnapArea& b) { return !(a == b); }
    102 
    10382} // namespace WebCore
    10483
Note: See TracChangeset for help on using the changeset viewer.