Title: [269144] trunk
Revision
269144
Author
[email protected]
Date
2020-10-29 04:37:18 -0700 (Thu, 29 Oct 2020)

Log 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 <[email protected]> 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.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (269143 => 269144)


--- trunk/LayoutTests/ChangeLog	2020-10-29 11:23:45 UTC (rev 269143)
+++ trunk/LayoutTests/ChangeLog	2020-10-29 11:37:18 UTC (rev 269144)
@@ -1,3 +1,13 @@
+2020-10-29  Martin Robinson  <[email protected]>
+
+        Make scroll-margin independent of scroll snapping and have it apply when scrolling to anchors
+        https://bugs.webkit.org/show_bug.cgi?id=218076
+
+        Reviewed by Simon Fraser.
+
+        * TestExpectations: Updated expectations for newly passing tests and marked some tests
+        as flaky.
+
 2020-10-29  Cathie Chen  <[email protected]>
 
         IntersectionObserverCallback leak

Modified: trunk/LayoutTests/TestExpectations (269143 => 269144)


--- trunk/LayoutTests/TestExpectations	2020-10-29 11:23:45 UTC (rev 269143)
+++ trunk/LayoutTests/TestExpectations	2020-10-29 11:37:18 UTC (rev 269144)
@@ -4502,10 +4502,8 @@
 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-align-001.html [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-align-002.html [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-align-003.html [ ImageOnlyFailure ]
-imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-margin-001.html [ ImageOnlyFailure ]
-imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-margin-002.html [ ImageOnlyFailure ]
-imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-margin-003.html [ ImageOnlyFailure ]
-imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-margin-004.html [ ImageOnlyFailure ]
+webkit.org/b/218325 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-margin-001.html [ Pass ImageOnlyFailure ]
+webkit.org/b/218325 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-margin-003.html [ Pass ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-padding-001.html [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-padding-002.html [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-padding-003.html [ ImageOnlyFailure ]

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (269143 => 269144)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-10-29 11:23:45 UTC (rev 269143)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-10-29 11:37:18 UTC (rev 269144)
@@ -1,3 +1,12 @@
+2020-10-29  Martin Robinson  <[email protected]>
+
+        Make scroll-margin independent of scroll snapping and have it apply when scrolling to anchors
+        https://bugs.webkit.org/show_bug.cgi?id=218076
+
+        Reviewed by Simon Fraser.
+
+        * web-platform-tests/css/cssom-view/scrollIntoView-scrollMargin-expected.txt: Updated expectation to note new pass.
+
 2020-10-28  Chris Dumez  <[email protected]>
 
         Resync web-platform-tests/webaudio tests from upstream

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scrollIntoView-scrollMargin-expected.txt (269143 => 269144)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scrollIntoView-scrollMargin-expected.txt	2020-10-29 11:23:45 UTC (rev 269143)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scrollIntoView-scrollMargin-expected.txt	2020-10-29 11:37:18 UTC (rev 269144)
@@ -1,5 +1,5 @@
 
-FAIL scrollIntoView({block: "center", inline: "center"}) assert_approx_equals: scrollX expected 153.5 +/- 0.5 but got 158
-FAIL scrollIntoView({block: "start", inline: "start"}) assert_approx_equals: scrollX expected 184 +/- 0.5 but got 200
-FAIL scrollIntoView({block: "end", inline: "end"}) assert_approx_equals: scrollX expected 123 +/- 0.5 but got 115
+PASS scrollIntoView({block: "center", inline: "center"})
+PASS scrollIntoView({block: "start", inline: "start"})
+PASS scrollIntoView({block: "end", inline: "end"})
 

Modified: trunk/Source/WebCore/ChangeLog (269143 => 269144)


--- trunk/Source/WebCore/ChangeLog	2020-10-29 11:23:45 UTC (rev 269143)
+++ trunk/Source/WebCore/ChangeLog	2020-10-29 11:37:18 UTC (rev 269144)
@@ -1,3 +1,59 @@
+2020-10-29  Martin Robinson  <[email protected]>
+
+        Make scroll-margin independent of scroll snapping and have it apply when scrolling to anchors
+        https://bugs.webkit.org/show_bug.cgi?id=218076
+
+        Reviewed by Simon Fraser.
+
+        * 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.
+
 2020-10-29  Chris Lord  <[email protected]>
 
         [GTK] Smooth scrolling should not apply to continuous scrolling with sync scrolling

Modified: trunk/Source/WebCore/dom/Element.cpp (269143 => 269144)


--- trunk/Source/WebCore/dom/Element.cpp	2020-10-29 11:23:45 UTC (rev 269143)
+++ trunk/Source/WebCore/dom/Element.cpp	2020-10-29 11:37:18 UTC (rev 269144)
@@ -861,7 +861,7 @@
         return;
 
     bool insideFixed;
-    LayoutRect absoluteBounds = renderer()->absoluteAnchorRect(&insideFixed);
+    LayoutRect absoluteBounds = renderer()->absoluteAnchorRectWithScrollMargin(&insideFixed);
 
     ScrollIntoViewOptions options;
     if (arg) {
@@ -895,7 +895,7 @@
         return;
 
     bool insideFixed;
-    LayoutRect absoluteBounds = renderer()->absoluteAnchorRect(&insideFixed);
+    LayoutRect absoluteBounds = renderer()->absoluteAnchorRectWithScrollMargin(&insideFixed);
     // Align to the top / bottom and to the closest edge.
     if (alignToTop)
         renderer()->scrollRectToVisible(absoluteBounds, insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways, ShouldAllowCrossOriginScrolling::No });
@@ -911,7 +911,7 @@
         return;
 
     bool insideFixed;
-    LayoutRect absoluteBounds = renderer()->absoluteAnchorRect(&insideFixed);
+    LayoutRect absoluteBounds = renderer()->absoluteAnchorRectWithScrollMargin(&insideFixed);
     if (centerIfNeeded)
         renderer()->scrollRectToVisible(absoluteBounds, insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded, ShouldAllowCrossOriginScrolling::No });
     else
@@ -926,7 +926,7 @@
         return;
     
     bool insideFixed;
-    LayoutRect absoluteBounds = renderer()->absoluteAnchorRect(&insideFixed);
+    LayoutRect absoluteBounds = renderer()->absoluteAnchorRectWithScrollMargin(&insideFixed);
     if (centerIfNotVisible)
         renderer()->scrollRectToVisible(absoluteBounds, insideFixed, { SelectionRevealMode::Reveal, ScrollAlignment::alignCenterIfNotVisible, ScrollAlignment::alignCenterIfNotVisible, ShouldAllowCrossOriginScrolling::No });
     else

Modified: trunk/Source/WebCore/page/FrameView.cpp (269143 => 269144)


--- trunk/Source/WebCore/page/FrameView.cpp	2020-10-29 11:23:45 UTC (rev 269143)
+++ trunk/Source/WebCore/page/FrameView.cpp	2020-10-29 11:37:18 UTC (rev 269144)
@@ -3176,7 +3176,7 @@
     LayoutRect rect;
     bool insideFixed = false;
     if (anchorNode != frame().document() && anchorNode->renderer())
-        rect = anchorNode->renderer()->absoluteAnchorRect(&insideFixed);
+        rect = anchorNode->renderer()->absoluteAnchorRectWithScrollMargin(&insideFixed);
 
     LOG_WITH_STREAM(Scrolling, stream << " anchor node rect " << rect);
 

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (269143 => 269144)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2020-10-29 11:23:45 UTC (rev 269143)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2020-10-29 11:37:18 UTC (rev 269144)
@@ -161,7 +161,7 @@
     removeControlStatesForRenderer(*this);
 
 #if ENABLE(CSS_SCROLL_SNAP)
-    if (hasInitializedStyle() && style().scrollSnapArea().hasSnapPosition())
+    if (hasInitializedStyle() && style().hasSnapPosition())
         view().unregisterBoxWithScrollSnapPositions(*this);
 #endif
 
@@ -277,8 +277,8 @@
         view().repaintRootContents();
 
 #if ENABLE(CSS_SCROLL_SNAP)
-    bool boxContributesSnapPositions = newStyle.scrollSnapArea().hasSnapPosition();
-    if (boxContributesSnapPositions || (oldStyle && oldStyle->scrollSnapArea().hasSnapPosition())) {
+    bool boxContributesSnapPositions = newStyle.hasSnapPosition();
+    if (boxContributesSnapPositions || (oldStyle && oldStyle->hasSnapPosition())) {
         if (boxContributesSnapPositions)
             view().registerBoxWithScrollSnapPositions(*this);
         else
@@ -5054,4 +5054,26 @@
     return nullptr;
 }
 
+LayoutRect RenderBox::absoluteAnchorRectWithScrollMargin(bool* insideFixed) const
+{
+    LayoutRect anchorRect = absoluteAnchorRect(insideFixed);
+    const LengthBox& scrollMargin = style().scrollMargin();
+    if (scrollMargin.isZero())
+        return anchorRect;
+
+    // The scroll snap specification says that the scroll-margin should be applied in the
+    // coordinate system of the scroll container and applied to the rectangular bounding
+    // box of the transformed border box of the target element.
+    // See https://www.w3.org/TR/css-scroll-snap-1/#scroll-margin.
+    const LayoutSize boxSize = size();
+    const LayoutBoxExtent margin(
+        valueForLength(scrollMargin.top(), boxSize.height()),
+        valueForLength(scrollMargin.right(), boxSize.width()),
+        valueForLength(scrollMargin.bottom(), boxSize.height()),
+        valueForLength(scrollMargin.left(), boxSize.width()));
+    anchorRect.expand(margin);
+
+    return anchorRect;
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/RenderBox.h (269143 => 269144)


--- trunk/Source/WebCore/rendering/RenderBox.h	2020-10-29 11:23:45 UTC (rev 269143)
+++ trunk/Source/WebCore/rendering/RenderBox.h	2020-10-29 11:37:18 UTC (rev 269144)
@@ -644,6 +644,8 @@
 
     virtual void adjustBorderBoxRectForPainting(LayoutRect&) { };
 
+    LayoutRect absoluteAnchorRectWithScrollMargin(bool* insideFixed = nullptr) const override;
+
 protected:
     RenderBox(Element&, RenderStyle&&, BaseTypeFlags);
     RenderBox(Document&, RenderStyle&&, BaseTypeFlags);

Modified: trunk/Source/WebCore/rendering/RenderElement.cpp (269143 => 269144)


--- trunk/Source/WebCore/rendering/RenderElement.cpp	2020-10-29 11:23:45 UTC (rev 269143)
+++ trunk/Source/WebCore/rendering/RenderElement.cpp	2020-10-29 11:37:18 UTC (rev 269144)
@@ -1657,6 +1657,11 @@
     return enclosingLayoutRect(FloatRect(upperLeft, lowerRight.expandedTo(upperLeft) - upperLeft));
 }
 
+LayoutRect RenderElement::absoluteAnchorRectWithScrollMargin(bool* insideFixed) const
+{
+    return absoluteAnchorRect(insideFixed);
+}
+
 const RenderElement* RenderElement::enclosingRendererWithTextDecoration(OptionSet<TextDecoration> textDecoration, bool firstLine) const
 {
     const RenderElement* current = this;

Modified: trunk/Source/WebCore/rendering/RenderElement.h (269143 => 269144)


--- trunk/Source/WebCore/rendering/RenderElement.h	2020-10-29 11:23:45 UTC (rev 269143)
+++ trunk/Source/WebCore/rendering/RenderElement.h	2020-10-29 11:37:18 UTC (rev 269144)
@@ -155,11 +155,15 @@
 
     bool checkForRepaintDuringLayout() const;
 
-    // anchorRect() is conceptually similar to absoluteBoundingBoxRect(), but is intended for scrolling to an anchor.
-    // For inline renderers, this gets the logical top left of the first leaf child and the logical bottom right of the
-    // last leaf child, converts them to absolute coordinates, and makes a box out of them.
+    // absoluteAnchorRect() is conceptually similar to absoluteBoundingBoxRect(), but is intended for scrolling to an
+    // anchor. For inline renderers, this gets the logical top left of the first leaf child and the logical bottom
+    // right of the last leaf child, converts them to absolute coordinates, and makes a box out of them.
     LayoutRect absoluteAnchorRect(bool* insideFixed = nullptr) const;
 
+    // absoluteAnchorRectWithScrollMargin() is similar to absoluteAnchorRect, but it also takes into account any
+    // CSS scroll-margin that is set in the style of this RenderElement.
+    virtual LayoutRect absoluteAnchorRectWithScrollMargin(bool* insideFixed = nullptr) const;
+
     bool hasFilter() const { return style().hasFilter(); }
     bool hasBackdropFilter() const
     {

Modified: trunk/Source/WebCore/rendering/RenderLayerModelObject.cpp (269143 => 269144)


--- trunk/Source/WebCore/rendering/RenderLayerModelObject.cpp	2020-10-29 11:23:45 UTC (rev 269143)
+++ trunk/Source/WebCore/rendering/RenderLayerModelObject.cpp	2020-10-29 11:37:18 UTC (rev 269144)
@@ -185,7 +185,12 @@
             frameView.updateScrollingCoordinatorScrollSnapProperties();
         }
     }
-    if (oldStyle && oldStyle->scrollSnapArea() != newStyle.scrollSnapArea()) {
+
+    bool scrollMarginChanged =
+        oldStyle && oldStyle->scrollMargin() != newStyle.scrollMargin();
+    bool scrollAlignChanged =
+        oldStyle && oldStyle->scrollSnapAlign() != newStyle.scrollSnapAlign();
+    if (scrollMarginChanged || scrollAlignChanged) {
         auto* scrollSnapBox = enclosingScrollableContainerForSnapping();
         if (scrollSnapBox && scrollSnapBox->layer()) {
             const RenderStyle& style = scrollSnapBox->style();

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (269143 => 269144)


--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2020-10-29 11:23:45 UTC (rev 269143)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2020-10-29 11:37:18 UTC (rev 269144)
@@ -2392,6 +2392,51 @@
     m_rareNonInheritedData.access().customProperties.access().setCustomPropertyValue(name, WTFMove(value));
 }
 
+const LengthBox& RenderStyle::scrollMargin() const
+{
+    return m_rareNonInheritedData->scrollMargin;
+}
+
+const Length& RenderStyle::scrollMarginTop() const
+{
+    return scrollMargin().top();
+}
+
+const Length& RenderStyle::scrollMarginBottom() const
+{
+    return scrollMargin().bottom();
+}
+
+const Length& RenderStyle::scrollMarginLeft() const
+{
+    return scrollMargin().left();
+}
+
+const Length& RenderStyle::scrollMarginRight() const
+{
+    return scrollMargin().right();
+}
+
+void RenderStyle::setScrollMarginTop(Length&& length)
+{
+    SET_VAR(m_rareNonInheritedData, scrollMargin.top(), WTFMove(length));
+}
+
+void RenderStyle::setScrollMarginBottom(Length&& length)
+{
+    SET_VAR(m_rareNonInheritedData, scrollMargin.bottom(), WTFMove(length));
+}
+
+void RenderStyle::setScrollMarginLeft(Length&& length)
+{
+    SET_VAR(m_rareNonInheritedData, scrollMargin.left(), WTFMove(length));
+}
+
+void RenderStyle::setScrollMarginRight(Length&& length)
+{
+    SET_VAR(m_rareNonInheritedData, scrollMargin.right(), WTFMove(length));
+}
+
 #if ENABLE(CSS_SCROLL_SNAP)
 
 ScrollSnapType RenderStyle::initialScrollSnapType()
@@ -2404,11 +2449,6 @@
     return { };
 }
 
-const StyleScrollSnapArea& RenderStyle::scrollSnapArea() const
-{
-    return *m_rareNonInheritedData->scrollSnapArea;
-}
-
 const StyleScrollSnapPort& RenderStyle::scrollSnapPort() const
 {
     return *m_rareNonInheritedData->scrollSnapPort;
@@ -2446,34 +2486,9 @@
 
 const ScrollSnapAlign& RenderStyle::scrollSnapAlign() const
 {
-    return m_rareNonInheritedData->scrollSnapArea->alignment;
+    return m_rareNonInheritedData->scrollSnapAlign;
 }
 
-const LengthBox& RenderStyle::scrollMargin() const
-{
-    return m_rareNonInheritedData->scrollSnapArea->scrollMargin;
-}
-
-const Length& RenderStyle::scrollMarginTop() const
-{
-    return scrollMargin().top();
-}
-
-const Length& RenderStyle::scrollMarginBottom() const
-{
-    return scrollMargin().bottom();
-}
-
-const Length& RenderStyle::scrollMarginLeft() const
-{
-    return scrollMargin().left();
-}
-
-const Length& RenderStyle::scrollMarginRight() const
-{
-    return scrollMargin().right();
-}
-
 void RenderStyle::setScrollSnapType(const ScrollSnapType& type)
 {
     SET_NESTED_VAR(m_rareNonInheritedData, scrollSnapPort, type, type);
@@ -2501,29 +2516,14 @@
 
 void RenderStyle::setScrollSnapAlign(const ScrollSnapAlign& alignment)
 {
-    SET_NESTED_VAR(m_rareNonInheritedData, scrollSnapArea, alignment, alignment);
+    SET_VAR(m_rareNonInheritedData, scrollSnapAlign, alignment);
 }
 
-void RenderStyle::setScrollMarginTop(Length&& length)
+bool RenderStyle::hasSnapPosition() const
 {
-    SET_NESTED_VAR(m_rareNonInheritedData, scrollSnapArea, scrollMargin.top(), WTFMove(length));
+    const ScrollSnapAlign& alignment = this->scrollSnapAlign();
+    return alignment.x != ScrollSnapAxisAlignType::None || alignment.y != ScrollSnapAxisAlignType::None;
 }
-
-void RenderStyle::setScrollMarginBottom(Length&& length)
-{
-    SET_NESTED_VAR(m_rareNonInheritedData, scrollSnapArea, scrollMargin.bottom(), WTFMove(length));
-}
-
-void RenderStyle::setScrollMarginLeft(Length&& length)
-{
-    SET_NESTED_VAR(m_rareNonInheritedData, scrollSnapArea, scrollMargin.left(), WTFMove(length));
-}
-
-void RenderStyle::setScrollMarginRight(Length&& length)
-{
-    SET_NESTED_VAR(m_rareNonInheritedData, scrollSnapArea, scrollMargin.right(), WTFMove(length));
-}
-
 #endif
 
 bool RenderStyle::hasReferenceFilterOnly() const

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (269143 => 269144)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2020-10-29 11:23:45 UTC (rev 269143)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2020-10-29 11:37:18 UTC (rev 269144)
@@ -719,7 +719,15 @@
     OptionSet<TouchAction> effectiveTouchActions() const { return m_rareInheritedData->effectiveTouchActions; }
     OptionSet<EventListenerRegionType> eventListenerRegionTypes() const { return m_rareInheritedData->eventListenerRegionTypes; }
 
+    const LengthBox& scrollMargin() const;
+    const Length& scrollMarginTop() const;
+    const Length& scrollMarginBottom() const;
+    const Length& scrollMarginLeft() const;
+    const Length& scrollMarginRight() const;
+
 #if ENABLE(CSS_SCROLL_SNAP)
+    bool hasSnapPosition() const;
+
     // Scroll snap port style.
     const StyleScrollSnapPort& scrollSnapPort() const;
     const ScrollSnapType& scrollSnapType() const;
@@ -729,14 +737,7 @@
     const Length& scrollPaddingLeft() const;
     const Length& scrollPaddingRight() const;
 
-    // Scroll snap area style.
-    const StyleScrollSnapArea& scrollSnapArea() const;
     const ScrollSnapAlign& scrollSnapAlign() const;
-    const LengthBox& scrollMargin() const;
-    const Length& scrollMarginTop() const;
-    const Length& scrollMarginBottom() const;
-    const Length& scrollMarginLeft() const;
-    const Length& scrollMarginRight() const;
 #endif
 
 #if ENABLE(TOUCH_EVENTS)
@@ -1265,6 +1266,11 @@
     void setEffectiveTouchActions(OptionSet<TouchAction> touchActions) { SET_VAR(m_rareInheritedData, effectiveTouchActions, touchActions); }
     void setEventListenerRegionTypes(OptionSet<EventListenerRegionType> eventListenerTypes) { SET_VAR(m_rareInheritedData, eventListenerRegionTypes, eventListenerTypes); }
 
+    void setScrollMarginTop(Length&&);
+    void setScrollMarginBottom(Length&&);
+    void setScrollMarginLeft(Length&&);
+    void setScrollMarginRight(Length&&);
+
 #if ENABLE(CSS_SCROLL_SNAP)
     void setScrollSnapType(const ScrollSnapType&);
     void setScrollPaddingTop(Length&&);
@@ -1273,10 +1279,6 @@
     void setScrollPaddingRight(Length&&);
 
     void setScrollSnapAlign(const ScrollSnapAlign&);
-    void setScrollMarginTop(Length&&);
-    void setScrollMarginBottom(Length&&);
-    void setScrollMarginLeft(Length&&);
-    void setScrollMarginRight(Length&&);
 #endif
 
 #if ENABLE(TOUCH_EVENTS)
@@ -1674,10 +1676,11 @@
 
     static TouchAction initialTouchActions() { return TouchAction::Auto; }
 
+    static Length initialScrollMargin() { return Length(Fixed); }
+
 #if ENABLE(CSS_SCROLL_SNAP)
     static ScrollSnapType initialScrollSnapType();
     static ScrollSnapAlign initialScrollSnapAlign();
-    static Length initialScrollMargin() { return Length(Fixed); }
     static Length initialScrollPadding() { return Length(Fixed); }
 #endif
 

Modified: trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp (269143 => 269144)


--- trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp	2020-10-29 11:23:45 UTC (rev 269143)
+++ trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp	2020-10-29 11:37:18 UTC (rev 269144)
@@ -31,7 +31,6 @@
 #include "StyleTransformData.h"
 #include "StyleImage.h"
 #include "StyleResolver.h"
-#include "StyleScrollSnapPoints.h"
 #include <wtf/PointerComparison.h>
 #include <wtf/RefPtr.h>
 #include <wtf/text/TextStream.h>
@@ -62,7 +61,6 @@
     , gridItem(StyleGridItemData::create())
 #if ENABLE(CSS_SCROLL_SNAP)
     , scrollSnapPort(StyleScrollSnapPort::create())
-    , scrollSnapArea(StyleScrollSnapArea::create())
 #endif
     , willChange(RenderStyle::initialWillChange())
     , mask(FillLayer::create(FillLayerType::Mask))
@@ -139,9 +137,10 @@
 #endif
     , grid(o.grid)
     , gridItem(o.gridItem)
+    , scrollMargin(o.scrollMargin)
 #if ENABLE(CSS_SCROLL_SNAP)
     , scrollSnapPort(o.scrollSnapPort)
-    , scrollSnapArea(o.scrollSnapArea)
+    , scrollSnapAlign(o.scrollSnapAlign)
 #endif
     , content(o.content ? o.content->clone() : nullptr)
     , counterDirectives(o.counterDirectives ? makeUnique<CounterDirectiveMap>(*o.counterDirectives) : nullptr)
@@ -241,9 +240,10 @@
 #endif
         && grid == o.grid
         && gridItem == o.gridItem
+        && scrollMargin == o.scrollMargin
 #if ENABLE(CSS_SCROLL_SNAP)
         && scrollSnapPort == o.scrollSnapPort
-        && scrollSnapArea == o.scrollSnapArea
+        && scrollSnapAlign == o.scrollSnapAlign
 #endif
         && contentDataEquivalent(o)
         && arePointingToEqualData(counterDirectives, o.counterDirectives)

Modified: trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h (269143 => 269144)


--- trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h	2020-10-29 11:23:45 UTC (rev 269143)
+++ trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h	2020-10-29 11:37:18 UTC (rev 269144)
@@ -45,6 +45,10 @@
 #include <wtf/OptionSet.h>
 #include <wtf/Vector.h>
 
+#if ENABLE(CSS_SCROLL_SNAP)
+#include "StyleScrollSnapPoints.h"
+#endif
+
 namespace WebCore {
 
 class AnimationList;
@@ -60,8 +64,6 @@
 class StyleMultiColData;
 class StyleReflection;
 class StyleResolver;
-class StyleScrollSnapArea;
-class StyleScrollSnapPort;
 class StyleTransformData;
 
 struct LengthSize;
@@ -129,9 +131,10 @@
     DataRef<StyleGridData> grid;
     DataRef<StyleGridItemData> gridItem;
 
+    LengthBox scrollMargin { 0, 0, 0, 0 };
 #if ENABLE(CSS_SCROLL_SNAP)
     DataRef<StyleScrollSnapPort> scrollSnapPort;
-    DataRef<StyleScrollSnapArea> scrollSnapArea;
+    ScrollSnapAlign scrollSnapAlign;
 #endif
 
     std::unique_ptr<ContentData> content;

Modified: trunk/Source/WebCore/rendering/style/StyleScrollSnapPoints.cpp (269143 => 269144)


--- trunk/Source/WebCore/rendering/style/StyleScrollSnapPoints.cpp	2020-10-29 11:23:45 UTC (rev 269143)
+++ trunk/Source/WebCore/rendering/style/StyleScrollSnapPoints.cpp	2020-10-29 11:37:18 UTC (rev 269144)
@@ -46,23 +46,6 @@
 {
 }
 
-Ref<StyleScrollSnapArea> StyleScrollSnapArea::copy() const
-{
-    return adoptRef(*new StyleScrollSnapArea(*this));
-}
-
-StyleScrollSnapArea::StyleScrollSnapArea()
-    : scrollMargin(0, 0, 0, 0)
-{
-}
-
-inline StyleScrollSnapArea::StyleScrollSnapArea(const StyleScrollSnapArea& other)
-    : RefCounted()
-    , alignment(other.alignment)
-    , scrollMargin(other.scrollMargin)
-{
-}
-
 } // namespace WebCore
 
 #endif /* ENABLE(CSS_SCROLL_SNAP) */

Modified: trunk/Source/WebCore/rendering/style/StyleScrollSnapPoints.h (269143 => 269144)


--- trunk/Source/WebCore/rendering/style/StyleScrollSnapPoints.h	2020-10-29 11:23:45 UTC (rev 269143)
+++ trunk/Source/WebCore/rendering/style/StyleScrollSnapPoints.h	2020-10-29 11:37:18 UTC (rev 269144)
@@ -79,27 +79,6 @@
 
 inline bool operator!=(const ScrollSnapAlign& a, const ScrollSnapAlign& b) { return !(a == b); }
 
-class StyleScrollSnapArea : public RefCounted<StyleScrollSnapArea> {
-public:
-    static Ref<StyleScrollSnapArea> create() { return adoptRef(*new StyleScrollSnapArea); }
-    Ref<StyleScrollSnapArea> copy() const;
-    bool hasSnapPosition() const { return alignment.x != ScrollSnapAxisAlignType::None || alignment.y != ScrollSnapAxisAlignType::None; }
-
-    ScrollSnapAlign alignment;
-    LengthBox scrollMargin { 0, 0, 0, 0 };
-
-private:
-    StyleScrollSnapArea();
-    StyleScrollSnapArea(const StyleScrollSnapArea&);
-};
-
-inline bool operator==(const StyleScrollSnapArea& a, const StyleScrollSnapArea& b)
-{
-    return a.alignment == b.alignment && a.scrollMargin == b.scrollMargin;
-}
-
-inline bool operator!=(const StyleScrollSnapArea& a, const StyleScrollSnapArea& b) { return !(a == b); }
-
 } // namespace WebCore
 
 #endif // ENABLE(CSS_SCROLL_SNAP)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to