Title: [278350] trunk
Revision
278350
Author
commit-qu...@webkit.org
Date
2021-06-02 05:37:00 -0700 (Wed, 02 Jun 2021)

Log Message

[css-scroll-snap] Scroll snap is broken with non-horizontal writing modes
https://bugs.webkit.org/show_bug.cgi?id=226010

Patch by Martin Robinson <mrobin...@igalia.com> on 2021-06-02
Reviewed by Frédéric Wang.

LayoutTests/imported/w3c:

* web-platform-tests/css/css-scroll-snap/scroll-snap-type-on-root-element-expected.txt: Update expectations to mark tests as passing.
* web-platform-tests/css/css-scroll-snap/snap-inline-block-expected.txt: Ditto.

Source/WebCore:

Fix issues related to vertical writing modes and scroll snap.

This change fixes three existing WPT tests.
    imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-snap-type-on-root-element.html
    imported/w3c/web-platform-tests/css/css-scroll-snap/snap-after-initial-layout/writing-mode-vertical-lr.html
    imported/w3c/web-platform-tests/css/css-scroll-snap/snap-inline-block.html

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::valueForScrollSnapAlignment): Update to reflect new member names of ScrollSnapAlign.
* page/FrameView.cpp:
(WebCore::FrameView::updateSnapOffsets): Pass in the text direction and writing mode of the
container, allowing the values specified on the body to override those specified on the root
element.
* page/scrolling/ScrollSnapOffsetsInfo.cpp:
(WebCore::updateSnapOffsetsForScrollableArea): Properly handle the writing mode and the
text direction of the container.
* page/scrolling/ScrollSnapOffsetsInfo.h: Update function signature.
* rendering/RenderLayerModelObject.cpp:
(WebCore::scrollSnapContainerRequiresUpdateForStyleUpdate): Pass in the writing mode and
text direction of the scrolling container.
* rendering/RenderLayerScrollableArea.cpp:
(WebCore::RenderLayerScrollableArea::updateSnapOffsets): Update to reflect new member names
of ScrollSnapAlign.
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::hasSnapPosition const): Ditto.
* rendering/style/StyleScrollSnapPoints.h: Change the name of the members of ScrollSnapAlign
to match what is described in the specification. The values provided are for block and
inline directions, but depending on the scroll container.
(WebCore::operator==): Ditto.
* style/StyleBuilderConverter.h:
(WebCore::Style::BuilderConverter::convertScrollSnapAlign): Ditto.

LayoutTests:

* TestExpectations: Mark one test as passing.
* platform/ios-wk2/imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-snap-type-on-root-element-expected.txt: Removed.
* platform/ios/imported/w3c/web-platform-tests/css/css-scroll-snap/snap-inline-block-expected.txt:

Modified Paths

Removed Paths

  • trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/css/css-scroll-snap/

Diff

Modified: trunk/LayoutTests/ChangeLog (278349 => 278350)


--- trunk/LayoutTests/ChangeLog	2021-06-02 12:17:18 UTC (rev 278349)
+++ trunk/LayoutTests/ChangeLog	2021-06-02 12:37:00 UTC (rev 278350)
@@ -1,3 +1,14 @@
+2021-06-02  Martin Robinson  <mrobin...@igalia.com>
+
+        [css-scroll-snap] Scroll snap is broken with non-horizontal writing modes
+        https://bugs.webkit.org/show_bug.cgi?id=226010
+
+        Reviewed by Frédéric Wang.
+
+        * TestExpectations: Mark one test as passing.
+        * platform/ios-wk2/imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-snap-type-on-root-element-expected.txt: Removed.
+        * platform/ios/imported/w3c/web-platform-tests/css/css-scroll-snap/snap-inline-block-expected.txt:
+
 2021-06-02  Antti Koivisto  <an...@apple.com>
 
         REGRESSION(r276882): Style not invalidated correctly for media queries in shadow trees that share style

Modified: trunk/LayoutTests/TestExpectations (278349 => 278350)


--- trunk/LayoutTests/TestExpectations	2021-06-02 12:17:18 UTC (rev 278349)
+++ trunk/LayoutTests/TestExpectations	2021-06-02 12:37:00 UTC (rev 278350)
@@ -4543,7 +4543,6 @@
 imported/w3c/web-platform-tests/css/css-scroll-snap/snap-after-initial-layout/direction-rtl.html [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-scroll-snap/snap-after-initial-layout/scroll-snap-initial-layout-000.html [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-scroll-snap/snap-after-initial-layout/scroll-snap-writing-mode-000.html [ ImageOnlyFailure ]
-imported/w3c/web-platform-tests/css/css-scroll-snap/snap-after-initial-layout/writing-mode-vertical-lr.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 ]
 

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (278349 => 278350)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-06-02 12:17:18 UTC (rev 278349)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-06-02 12:37:00 UTC (rev 278350)
@@ -1,3 +1,13 @@
+2021-06-02  Martin Robinson  <mrobin...@igalia.com>
+
+        [css-scroll-snap] Scroll snap is broken with non-horizontal writing modes
+        https://bugs.webkit.org/show_bug.cgi?id=226010
+
+        Reviewed by Frédéric Wang.
+
+        * web-platform-tests/css/css-scroll-snap/scroll-snap-type-on-root-element-expected.txt: Update expectations to mark tests as passing.
+        * web-platform-tests/css/css-scroll-snap/snap-inline-block-expected.txt: Ditto.
+
 2021-06-01  Jean-Yves Avenard  <j...@apple.com>
 
         MediaSession.coordinator should not be optional, relying on coordinator state change instead

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-snap-type-on-root-element-expected.txt (278349 => 278350)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-snap-type-on-root-element-expected.txt	2021-06-02 12:17:18 UTC (rev 278349)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-snap-type-on-root-element-expected.txt	2021-06-02 12:37:00 UTC (rev 278350)
@@ -1,5 +1,5 @@
 
 PASS The scroll-snap-type on the root element is applied
-FAIL The writing-mode (vertical-lr) on the body is used assert_equals: inline should snap expected 515 but got 800
+PASS The writing-mode (vertical-lr) on the body is used
 PASS The writing-mode (horizontal-tb) on the body is used
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/snap-inline-block-expected.txt (278349 => 278350)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/snap-inline-block-expected.txt	2021-06-02 12:17:18 UTC (rev 278349)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/snap-inline-block-expected.txt	2021-06-02 12:37:00 UTC (rev 278350)
@@ -1,10 +1,10 @@
 
 PASS Snaps correctly for horizontal-tb writing mode with 'scroll-snap-align: end start' alignment
-FAIL Snaps correctly for vertical-lr writing mode with 'scroll-snap-align: end start' alignment assert_equals: aligns correctly on x expected 115 but got 300
-FAIL Snaps correctly for vertical-rl writing mode with 'scroll-snap-align: end start' alignment assert_equals: aligns correctly on y expected 300 but got 165
-FAIL Snaps correctly for horizontal-tb writing mode with 'scroll-snap-align: start end' alignment assert_equals: aligns correctly on x expected 115 but got 0
-FAIL Snaps correctly for vertical-lr writing mode with 'scroll-snap-align: start end' alignment assert_equals: aligns correctly on x expected 300 but got 0
-FAIL Snaps correctly for vertical-rl writing mode with 'scroll-snap-align: start end' alignment assert_equals: aligns correctly on y expected 165 but got 300
-FAIL Snaps correctly for 'direction: rtl' with 'scroll-snap-align: end start' alignment assert_equals: aligns correctly on y expected 165 but got 0
-FAIL Snaps correctly for 'direction: rtl' with 'scroll-snap-align: start end' alignment assert_equals: aligns correctly on y expected 300 but got 0
+PASS Snaps correctly for vertical-lr writing mode with 'scroll-snap-align: end start' alignment
+PASS Snaps correctly for vertical-rl writing mode with 'scroll-snap-align: end start' alignment
+PASS Snaps correctly for horizontal-tb writing mode with 'scroll-snap-align: start end' alignment
+PASS Snaps correctly for vertical-lr writing mode with 'scroll-snap-align: start end' alignment
+PASS Snaps correctly for vertical-rl writing mode with 'scroll-snap-align: start end' alignment
+PASS Snaps correctly for 'direction: rtl' with 'scroll-snap-align: end start' alignment
+PASS Snaps correctly for 'direction: rtl' with 'scroll-snap-align: start end' alignment
 

Modified: trunk/LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-scroll-snap/snap-inline-block-expected.txt (278349 => 278350)


--- trunk/LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-scroll-snap/snap-inline-block-expected.txt	2021-06-02 12:17:18 UTC (rev 278349)
+++ trunk/LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-scroll-snap/snap-inline-block-expected.txt	2021-06-02 12:37:00 UTC (rev 278350)
@@ -1,10 +1,10 @@
 
 PASS Snaps correctly for horizontal-tb writing mode with 'scroll-snap-align: end start' alignment
-FAIL Snaps correctly for vertical-lr writing mode with 'scroll-snap-align: end start' alignment assert_equals: aligns correctly on x expected 115 but got 300
+PASS Snaps correctly for vertical-lr writing mode with 'scroll-snap-align: end start' alignment
 FAIL Snaps correctly for vertical-rl writing mode with 'scroll-snap-align: end start' alignment assert_equals: aligns correctly on x expected -315 but got -300
 FAIL Snaps correctly for horizontal-tb writing mode with 'scroll-snap-align: start end' alignment assert_equals: aligns correctly on x expected 115 but got 0
 FAIL Snaps correctly for vertical-lr writing mode with 'scroll-snap-align: start end' alignment assert_equals: aligns correctly on x expected 300 but got 0
 FAIL Snaps correctly for vertical-rl writing mode with 'scroll-snap-align: start end' alignment assert_equals: aligns correctly on x expected -500 but got -485
-FAIL Snaps correctly for 'direction: rtl' with 'scroll-snap-align: end start' alignment assert_equals: aligns correctly on x expected -500 but got -485
-FAIL Snaps correctly for 'direction: rtl' with 'scroll-snap-align: start end' alignment assert_equals: aligns correctly on x expected -315 but got -300
+FAIL Snaps correctly for 'direction: rtl' with 'scroll-snap-align: end start' alignment assert_equals: aligns correctly on x expected -500 but got -300
+FAIL Snaps correctly for 'direction: rtl' with 'scroll-snap-align: start end' alignment assert_equals: aligns correctly on x expected -315 but got -485
 

Modified: trunk/Source/WebCore/ChangeLog (278349 => 278350)


--- trunk/Source/WebCore/ChangeLog	2021-06-02 12:17:18 UTC (rev 278349)
+++ trunk/Source/WebCore/ChangeLog	2021-06-02 12:37:00 UTC (rev 278350)
@@ -1,3 +1,42 @@
+2021-06-02  Martin Robinson  <mrobin...@igalia.com>
+
+        [css-scroll-snap] Scroll snap is broken with non-horizontal writing modes
+        https://bugs.webkit.org/show_bug.cgi?id=226010
+
+        Reviewed by Frédéric Wang.
+
+        Fix issues related to vertical writing modes and scroll snap.
+
+        This change fixes three existing WPT tests.
+            imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-snap-type-on-root-element.html
+            imported/w3c/web-platform-tests/css/css-scroll-snap/snap-after-initial-layout/writing-mode-vertical-lr.html
+            imported/w3c/web-platform-tests/css/css-scroll-snap/snap-inline-block.html
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::valueForScrollSnapAlignment): Update to reflect new member names of ScrollSnapAlign.
+        * page/FrameView.cpp:
+        (WebCore::FrameView::updateSnapOffsets): Pass in the text direction and writing mode of the
+        container, allowing the values specified on the body to override those specified on the root
+        element.
+        * page/scrolling/ScrollSnapOffsetsInfo.cpp:
+        (WebCore::updateSnapOffsetsForScrollableArea): Properly handle the writing mode and the
+        text direction of the container.
+        * page/scrolling/ScrollSnapOffsetsInfo.h: Update function signature.
+        * rendering/RenderLayerModelObject.cpp:
+        (WebCore::scrollSnapContainerRequiresUpdateForStyleUpdate): Pass in the writing mode and
+        text direction of the scrolling container.
+        * rendering/RenderLayerScrollableArea.cpp:
+        (WebCore::RenderLayerScrollableArea::updateSnapOffsets): Update to reflect new member names
+        of ScrollSnapAlign.
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::hasSnapPosition const): Ditto.
+        * rendering/style/StyleScrollSnapPoints.h: Change the name of the members of ScrollSnapAlign
+        to match what is described in the specification. The values provided are for block and
+        inline directions, but depending on the scroll container.
+        (WebCore::operator==): Ditto.
+        * style/StyleBuilderConverter.h:
+        (WebCore::Style::BuilderConverter::convertScrollSnapAlign): Ditto.
+
 2021-06-02  Antti Koivisto  <an...@apple.com>
 
         REGRESSION(r276882): Style not invalidated correctly for media queries in shadow trees that share style

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (278349 => 278350)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2021-06-02 12:17:18 UTC (rev 278349)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2021-06-02 12:37:00 UTC (rev 278350)
@@ -1100,9 +1100,9 @@
 static Ref<CSSValueList> valueForScrollSnapAlignment(const ScrollSnapAlign& alignment)
 {
     auto value = CSSValueList::createSpaceSeparated();
-    value->append(CSSPrimitiveValue::create(alignment.y));
-    if (alignment.x != alignment.y)
-        value->append(CSSPrimitiveValue::create(alignment.x));
+    value->append(CSSPrimitiveValue::create(alignment.blockAlign));
+    if (alignment.inlineAlign != alignment.blockAlign)
+        value->append(CSSPrimitiveValue::create(alignment.inlineAlign));
     return value;
 }
 

Modified: trunk/Source/WebCore/page/FrameView.cpp (278349 => 278350)


--- trunk/Source/WebCore/page/FrameView.cpp	2021-06-02 12:17:18 UTC (rev 278349)
+++ trunk/Source/WebCore/page/FrameView.cpp	2021-06-02 12:37:00 UTC (rev 278350)
@@ -949,7 +949,7 @@
     LayoutRect viewport = LayoutRect(IntPoint(), baseLayoutViewportSize());
     viewport.move(-rootRenderer->marginLeft(), -rootRenderer->marginTop());
 
-    updateSnapOffsetsForScrollableArea(*this, *rootRenderer, *styleToUse, viewport);
+    updateSnapOffsetsForScrollableArea(*this, *rootRenderer, *styleToUse, viewport, rootRenderer->style().writingMode(), rootRenderer->style().direction());
 }
 
 bool FrameView::isScrollSnapInProgress() const

Modified: trunk/Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.cpp (278349 => 278350)


--- trunk/Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.cpp	2021-06-02 12:17:18 UTC (rev 278349)
+++ trunk/Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.cpp	2021-06-02 12:37:00 UTC (rev 278350)
@@ -197,7 +197,7 @@
     }
 }
 
-void updateSnapOffsetsForScrollableArea(ScrollableArea& scrollableArea, const RenderBox& scrollingElementBox, const RenderStyle& scrollingElementStyle, LayoutRect viewportRectInBorderBoxCoordinates)
+void updateSnapOffsetsForScrollableArea(ScrollableArea& scrollableArea, const RenderBox& scrollingElementBox, const RenderStyle& scrollingElementStyle, LayoutRect viewportRectInBorderBoxCoordinates, WritingMode writingMode, TextDirection textDirection)
 {
     auto scrollSnapType = scrollingElementStyle.scrollSnapType();
     const auto& boxesWithScrollSnapPositions = scrollingElementBox.view().boxesWithScrollSnapPositions();
@@ -217,13 +217,29 @@
     HashMap<float, SnapOffset<LayoutUnit>> verticalSnapOffsetsMap;
     HashMap<float, SnapOffset<LayoutUnit>> horizontalSnapOffsetsMap;
     Vector<LayoutRect> snapAreas;
-    bool hasHorizontalSnapOffsets = scrollSnapType.axis == ScrollSnapAxis::Both || scrollSnapType.axis == ScrollSnapAxis::XAxis || scrollSnapType.axis == ScrollSnapAxis::Inline;
-    bool hasVerticalSnapOffsets = scrollSnapType.axis == ScrollSnapAxis::Both || scrollSnapType.axis == ScrollSnapAxis::YAxis || scrollSnapType.axis == ScrollSnapAxis::Block;
 
     auto maxScrollOffset = scrollableArea.maximumScrollOffset();
     auto scrollPosition = LayoutPoint { scrollableArea.scrollPosition() };
-    bool scrollerIsRTL = !scrollingElementBox.style().isLeftToRightDirection();
 
+    // text-direction flips the inline axis and writing-mode can flip the block axis. Whether or
+    // not the writing-mode is vertical determines the physical orientation of the block and inline axes.
+    bool scrollerHasVerticalWritingMode = isVerticalWritingMode(writingMode);
+    bool blockAxisFlipped = isFlippedWritingMode(writingMode);
+    bool inlineAxisFlipped = textDirection == TextDirection::RTL;
+    bool xAxisFlipped = scrollerHasVerticalWritingMode ? blockAxisFlipped : inlineAxisFlipped;
+    bool yAxisFlipped = scrollerHasVerticalWritingMode ? inlineAxisFlipped : blockAxisFlipped;
+
+    bool hasHorizontalSnapOffsets = scrollSnapType.axis == ScrollSnapAxis::Both || scrollSnapType.axis == ScrollSnapAxis::XAxis;
+    bool hasVerticalSnapOffsets = scrollSnapType.axis == ScrollSnapAxis::Both || scrollSnapType.axis == ScrollSnapAxis::YAxis;
+    if (scrollSnapType.axis == ScrollSnapAxis::Block) {
+        hasHorizontalSnapOffsets = scrollerHasVerticalWritingMode;
+        hasVerticalSnapOffsets = !scrollerHasVerticalWritingMode;
+    }
+    if (scrollSnapType.axis == ScrollSnapAxis::Inline) {
+        hasHorizontalSnapOffsets = !scrollerHasVerticalWritingMode;
+        hasVerticalSnapOffsets = scrollerHasVerticalWritingMode;
+    }
+
     // The bounds of the scrolling container's snap port, where the top left of the scrolling container's border box is the origin.
     auto scrollSnapPort = computeScrollSnapPortOrAreaRect(viewportRectInBorderBoxCoordinates, scrollingElementStyle.scrollPadding(), InsetOrOutset::Inset);
     LOG_WITH_STREAM(ScrollSnap, stream << "Computing scroll snap offsets for " << scrollableArea << " in snap port " << scrollSnapPort);
@@ -233,7 +249,6 @@
 
         // The bounds of the child element's snap area, where the top left of the scrolling container's border box is the origin.
         // The snap area is the bounding box of the child element's border box, after applying transformations.
-        // FIXME: For now, just consider whether the scroller is RTL. The behavior of LTR boxes inside a RTL scroller is poorly defined: https://github.com/w3c/csswg-drafts/issues/5361.
         auto scrollSnapArea = LayoutRect(child->localToContainerQuad(FloatQuad(child->borderBoundingBox()), &scrollingElementBox).boundingBox());
 
         // localToContainerQuad will transform the scroll snap area by the scroll position, except in the case that this position is
@@ -246,8 +261,11 @@
         auto alignment = child->style().scrollSnapAlign();
         auto stop = child->style().scrollSnapStop();
 
-        bool snapsHorizontally = hasHorizontalSnapOffsets && alignment.x != ScrollSnapAxisAlignType::None;
-        bool snapsVertically = hasVerticalSnapOffsets && alignment.y != ScrollSnapAxisAlignType::None;
+        ScrollSnapAxisAlignType xAlign = scrollerHasVerticalWritingMode ? alignment.blockAlign : alignment.inlineAlign;
+        ScrollSnapAxisAlignType yAlign = scrollerHasVerticalWritingMode ? alignment.inlineAlign : alignment.blockAlign;
+        bool snapsHorizontally = hasHorizontalSnapOffsets && xAlign != ScrollSnapAxisAlignType::None;
+        bool snapsVertically = hasVerticalSnapOffsets && yAlign != ScrollSnapAxisAlignType::None;
+
         if (!snapsHorizontally && !snapsVertically)
             continue;
 
@@ -257,12 +275,12 @@
         snapAreas.append(scrollSnapAreaAsOffsets);
 
         if (snapsHorizontally) {
-            auto absoluteScrollXPosition = computeScrollSnapAlignOffset(scrollSnapArea.x(), scrollSnapArea.maxX(), alignment.x, scrollerIsRTL) - computeScrollSnapAlignOffset(scrollSnapPort.x(), scrollSnapPort.maxX(), alignment.x, scrollerIsRTL);
+            auto absoluteScrollXPosition = computeScrollSnapAlignOffset(scrollSnapArea.x(), scrollSnapArea.maxX(), xAlign, xAxisFlipped) - computeScrollSnapAlignOffset(scrollSnapPort.x(), scrollSnapPort.maxX(), xAlign, xAxisFlipped);
             auto absoluteScrollOffset = clampTo<int>(scrollableArea.scrollOffsetFromPosition({ roundToInt(absoluteScrollXPosition), 0 }).x(), 0, maxScrollOffset.x());
             addOrUpdateStopForSnapOffset(horizontalSnapOffsetsMap, { absoluteScrollOffset, stop, snapAreas.size() - 1 });
         }
         if (snapsVertically) {
-            auto absoluteScrollYPosition = computeScrollSnapAlignOffset(scrollSnapArea.y(), scrollSnapArea.maxY(), alignment.y, false) - computeScrollSnapAlignOffset(scrollSnapPort.y(), scrollSnapPort.maxY(), alignment.y, false);
+            auto absoluteScrollYPosition = computeScrollSnapAlignOffset(scrollSnapArea.y(), scrollSnapArea.maxY(), yAlign, yAxisFlipped) - computeScrollSnapAlignOffset(scrollSnapPort.y(), scrollSnapPort.maxY(), yAlign, yAxisFlipped);
             auto absoluteScrollOffset = clampTo<int>(scrollableArea.scrollOffsetFromPosition({ 0, roundToInt(absoluteScrollYPosition) }).y(), 0, maxScrollOffset.y());
             addOrUpdateStopForSnapOffset(verticalSnapOffsetsMap, { absoluteScrollOffset, stop, snapAreas.size() - 1 });
         }

Modified: trunk/Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.h (278349 => 278350)


--- trunk/Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.h	2021-06-02 12:17:18 UTC (rev 278349)
+++ trunk/Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.h	2021-06-02 12:37:00 UTC (rev 278350)
@@ -96,7 +96,7 @@
 // Update the snap offsets for this scrollable area, given the RenderBox of the scroll container, the RenderStyle
 // which defines the scroll-snap properties, and the viewport rectangle with the origin at the top left of
 // the scrolling container's border box.
-void updateSnapOffsetsForScrollableArea(ScrollableArea&, const RenderBox& scrollingElementBox, const RenderStyle& scrollingElementStyle, LayoutRect viewportRectInBorderBoxCoordinates);
+void updateSnapOffsetsForScrollableArea(ScrollableArea&, const RenderBox& scrollingElementBox, const RenderStyle& scrollingElementStyle, LayoutRect viewportRectInBorderBoxCoordinates, WritingMode, TextDirection);
 
 template <typename T> WTF::TextStream& operator<<(WTF::TextStream& ts, SnapOffset<T> offset)
 {

Modified: trunk/Source/WebCore/rendering/RenderLayerScrollableArea.cpp (278349 => 278350)


--- trunk/Source/WebCore/rendering/RenderLayerScrollableArea.cpp	2021-06-02 12:17:18 UTC (rev 278349)
+++ trunk/Source/WebCore/rendering/RenderLayerScrollableArea.cpp	2021-06-02 12:37:00 UTC (rev 278350)
@@ -1469,7 +1469,7 @@
         return;
 
     RenderBox* box = m_layer.enclosingElement()->renderBox();
-    updateSnapOffsetsForScrollableArea(*this, *box, box->style(), box->paddingBoxRect());
+    updateSnapOffsetsForScrollableArea(*this, *box, box->style(), box->paddingBoxRect(), box->style().writingMode(), box->style().direction());
 }
 
 bool RenderLayerScrollableArea::isScrollSnapInProgress() const

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (278349 => 278350)


--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2021-06-02 12:17:18 UTC (rev 278349)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2021-06-02 12:37:00 UTC (rev 278350)
@@ -2578,7 +2578,7 @@
 bool RenderStyle::hasSnapPosition() const
 {
     const ScrollSnapAlign& alignment = this->scrollSnapAlign();
-    return alignment.x != ScrollSnapAxisAlignType::None || alignment.y != ScrollSnapAxisAlignType::None;
+    return alignment.blockAlign != ScrollSnapAxisAlignType::None || alignment.inlineAlign != ScrollSnapAxisAlignType::None;
 }
 #endif
 

Modified: trunk/Source/WebCore/rendering/style/StyleScrollSnapPoints.h (278349 => 278350)


--- trunk/Source/WebCore/rendering/style/StyleScrollSnapPoints.h	2021-06-02 12:17:18 UTC (rev 278349)
+++ trunk/Source/WebCore/rendering/style/StyleScrollSnapPoints.h	2021-06-02 12:37:00 UTC (rev 278350)
@@ -48,13 +48,13 @@
 inline bool operator!=(const ScrollSnapType& a, const ScrollSnapType& b) { return !(a == b); }
 
 struct ScrollSnapAlign {
-    ScrollSnapAxisAlignType x { ScrollSnapAxisAlignType::None };
-    ScrollSnapAxisAlignType y { ScrollSnapAxisAlignType::None };
+    ScrollSnapAxisAlignType blockAlign { ScrollSnapAxisAlignType::None };
+    ScrollSnapAxisAlignType inlineAlign { ScrollSnapAxisAlignType::None };
 };
 
 inline bool operator==(const ScrollSnapAlign& a, const ScrollSnapAlign& b)
 {
-    return a.x == b.x && a.y == b.y;
+    return a.blockAlign == b.blockAlign && a.inlineAlign == b.inlineAlign;
 }
 
 inline bool operator!=(const ScrollSnapAlign& a, const ScrollSnapAlign& b) { return !(a == b); }

Modified: trunk/Source/WebCore/style/StyleBuilderConverter.h (278349 => 278350)


--- trunk/Source/WebCore/style/StyleBuilderConverter.h	2021-06-02 12:17:18 UTC (rev 278349)
+++ trunk/Source/WebCore/style/StyleBuilderConverter.h	2021-06-02 12:37:00 UTC (rev 278350)
@@ -921,11 +921,11 @@
 {
     auto& values = downcast<CSSValueList>(value);
     ScrollSnapAlign alignment;
-    alignment.y = downcast<CSSPrimitiveValue>(*values.item(0));
+    alignment.blockAlign = downcast<CSSPrimitiveValue>(*values.item(0));
     if (values.length() == 1)
-        alignment.x = alignment.y;
+        alignment.inlineAlign = alignment.blockAlign;
     else
-        alignment.x = downcast<CSSPrimitiveValue>(*values.item(1));
+        alignment.inlineAlign = downcast<CSSPrimitiveValue>(*values.item(1));
     return alignment;
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to