<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[278350] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/278350">278350</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2021-06-02 05:37:00 -0700 (Wed, 02 Jun 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>[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 <mrobinson@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:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsTestExpectations">trunk/LayoutTests/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestscsscssscrollsnapscrollsnaptypeonrootelementexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-snap-type-on-root-element-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestscsscssscrollsnapsnapinlineblockexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/snap-inline-block-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformiosimportedw3cwebplatformtestscsscssscrollsnapsnapinlineblockexpectedtxt">trunk/LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-scroll-snap/snap-inline-block-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssCSSComputedStyleDeclarationcpp">trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp</a></li>
<li><a href="#trunkSourceWebCorepageFrameViewcpp">trunk/Source/WebCore/page/FrameView.cpp</a></li>
<li><a href="#trunkSourceWebCorepagescrollingScrollSnapOffsetsInfocpp">trunk/Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.cpp</a></li>
<li><a href="#trunkSourceWebCorepagescrollingScrollSnapOffsetsInfoh">trunk/Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerScrollableAreacpp">trunk/Source/WebCore/rendering/RenderLayerScrollableArea.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleRenderStylecpp">trunk/Source/WebCore/rendering/style/RenderStyle.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleStyleScrollSnapPointsh">trunk/Source/WebCore/rendering/style/StyleScrollSnapPoints.h</a></li>
<li><a href="#trunkSourceWebCorestyleStyleBuilderConverterh">trunk/Source/WebCore/style/StyleBuilderConverter.h</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li>trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/css/css-scroll-snap/</li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (278349 => 278350)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2021-06-02 12:17:18 UTC (rev 278349)
+++ trunk/LayoutTests/ChangeLog 2021-06-02 12:37:00 UTC (rev 278350)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2021-06-02  Martin Robinson  <mrobinson@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:
+
</ins><span class="cx"> 2021-06-02  Antti Koivisto  <antti@apple.com>
</span><span class="cx"> 
</span><span class="cx">         REGRESSION(r276882): Style not invalidated correctly for media queries in shadow trees that share style
</span></span></pre></div>
<a id="trunkLayoutTestsTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/TestExpectations (278349 => 278350)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/TestExpectations       2021-06-02 12:17:18 UTC (rev 278349)
+++ trunk/LayoutTests/TestExpectations  2021-06-02 12:37:00 UTC (rev 278350)
</span><span class="lines">@@ -4543,7 +4543,6 @@
</span><span class="cx"> imported/w3c/web-platform-tests/css/css-scroll-snap/snap-after-initial-layout/direction-rtl.html [ ImageOnlyFailure ]
</span><span class="cx"> imported/w3c/web-platform-tests/css/css-scroll-snap/snap-after-initial-layout/scroll-snap-initial-layout-000.html [ ImageOnlyFailure ]
</span><span class="cx"> imported/w3c/web-platform-tests/css/css-scroll-snap/snap-after-initial-layout/scroll-snap-writing-mode-000.html [ ImageOnlyFailure ]
</span><del>-imported/w3c/web-platform-tests/css/css-scroll-snap/snap-after-initial-layout/writing-mode-vertical-lr.html [ ImageOnlyFailure ]
</del><span class="cx"> webkit.org/b/218325 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-margin-001.html [ Pass ImageOnlyFailure ]
</span><span class="cx"> webkit.org/b/218325 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-margin-003.html [ Pass ImageOnlyFailure ]
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (278349 => 278350)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2021-06-02  Martin Robinson  <mrobinson@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.
+
</ins><span class="cx"> 2021-06-01  Jean-Yves Avenard  <jya@apple.com>
</span><span class="cx"> 
</span><span class="cx">         MediaSession.coordinator should not be optional, relying on coordinator state change instead
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestscsscssscrollsnapscrollsnaptypeonrootelementexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-snap-type-on-root-element-expected.txt (278349 => 278350)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> 
</span><span class="cx"> PASS The scroll-snap-type on the root element is applied
</span><del>-FAIL The writing-mode (vertical-lr) on the body is used assert_equals: inline should snap expected 515 but got 800
</del><ins>+PASS The writing-mode (vertical-lr) on the body is used
</ins><span class="cx"> PASS The writing-mode (horizontal-tb) on the body is used
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestscsscssscrollsnapsnapinlineblockexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/snap-inline-block-expected.txt (278349 => 278350)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,10 +1,10 @@
</span><span class="cx"> 
</span><span class="cx"> PASS Snaps correctly for horizontal-tb writing mode with 'scroll-snap-align: end start' alignment
</span><del>-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
</del><ins>+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
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsplatformiosimportedw3cwebplatformtestscsscssscrollsnapsnapinlineblockexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-scroll-snap/snap-inline-block-expected.txt (278349 => 278350)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,10 +1,10 @@
</span><span class="cx"> 
</span><span class="cx"> PASS Snaps correctly for horizontal-tb writing mode with 'scroll-snap-align: end start' alignment
</span><del>-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
</del><ins>+PASS Snaps correctly for vertical-lr writing mode with 'scroll-snap-align: end start' alignment
</ins><span class="cx"> 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
</span><span class="cx"> 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
</span><span class="cx"> 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
</span><span class="cx"> 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
</span><del>-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
</del><ins>+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
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (278349 => 278350)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,42 @@
</span><ins>+2021-06-02  Martin Robinson  <mrobinson@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.
+
</ins><span class="cx"> 2021-06-02  Antti Koivisto  <antti@apple.com>
</span><span class="cx"> 
</span><span class="cx">         REGRESSION(r276882): Style not invalidated correctly for media queries in shadow trees that share style
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSComputedStyleDeclarationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (278349 => 278350)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1100,9 +1100,9 @@
</span><span class="cx"> static Ref<CSSValueList> valueForScrollSnapAlignment(const ScrollSnapAlign& alignment)
</span><span class="cx"> {
</span><span class="cx">     auto value = CSSValueList::createSpaceSeparated();
</span><del>-    value->append(CSSPrimitiveValue::create(alignment.y));
-    if (alignment.x != alignment.y)
-        value->append(CSSPrimitiveValue::create(alignment.x));
</del><ins>+    value->append(CSSPrimitiveValue::create(alignment.blockAlign));
+    if (alignment.inlineAlign != alignment.blockAlign)
+        value->append(CSSPrimitiveValue::create(alignment.inlineAlign));
</ins><span class="cx">     return value;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorepageFrameViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/FrameView.cpp (278349 => 278350)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -949,7 +949,7 @@
</span><span class="cx">     LayoutRect viewport = LayoutRect(IntPoint(), baseLayoutViewportSize());
</span><span class="cx">     viewport.move(-rootRenderer->marginLeft(), -rootRenderer->marginTop());
</span><span class="cx"> 
</span><del>-    updateSnapOffsetsForScrollableArea(*this, *rootRenderer, *styleToUse, viewport);
</del><ins>+    updateSnapOffsetsForScrollableArea(*this, *rootRenderer, *styleToUse, viewport, rootRenderer->style().writingMode(), rootRenderer->style().direction());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool FrameView::isScrollSnapInProgress() const
</span></span></pre></div>
<a id="trunkSourceWebCorepagescrollingScrollSnapOffsetsInfocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.cpp (278349 => 278350)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -197,7 +197,7 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void updateSnapOffsetsForScrollableArea(ScrollableArea& scrollableArea, const RenderBox& scrollingElementBox, const RenderStyle& scrollingElementStyle, LayoutRect viewportRectInBorderBoxCoordinates)
</del><ins>+void updateSnapOffsetsForScrollableArea(ScrollableArea& scrollableArea, const RenderBox& scrollingElementBox, const RenderStyle& scrollingElementStyle, LayoutRect viewportRectInBorderBoxCoordinates, WritingMode writingMode, TextDirection textDirection)
</ins><span class="cx"> {
</span><span class="cx">     auto scrollSnapType = scrollingElementStyle.scrollSnapType();
</span><span class="cx">     const auto& boxesWithScrollSnapPositions = scrollingElementBox.view().boxesWithScrollSnapPositions();
</span><span class="lines">@@ -217,13 +217,29 @@
</span><span class="cx">     HashMap<float, SnapOffset<LayoutUnit>> verticalSnapOffsetsMap;
</span><span class="cx">     HashMap<float, SnapOffset<LayoutUnit>> horizontalSnapOffsetsMap;
</span><span class="cx">     Vector<LayoutRect> snapAreas;
</span><del>-    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;
</del><span class="cx"> 
</span><span class="cx">     auto maxScrollOffset = scrollableArea.maximumScrollOffset();
</span><span class="cx">     auto scrollPosition = LayoutPoint { scrollableArea.scrollPosition() };
</span><del>-    bool scrollerIsRTL = !scrollingElementBox.style().isLeftToRightDirection();
</del><span class="cx"> 
</span><ins>+    // 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;
+    }
+
</ins><span class="cx">     // The bounds of the scrolling container's snap port, where the top left of the scrolling container's border box is the origin.
</span><span class="cx">     auto scrollSnapPort = computeScrollSnapPortOrAreaRect(viewportRectInBorderBoxCoordinates, scrollingElementStyle.scrollPadding(), InsetOrOutset::Inset);
</span><span class="cx">     LOG_WITH_STREAM(ScrollSnap, stream << "Computing scroll snap offsets for " << scrollableArea << " in snap port " << scrollSnapPort);
</span><span class="lines">@@ -233,7 +249,6 @@
</span><span class="cx"> 
</span><span class="cx">         // The bounds of the child element's snap area, where the top left of the scrolling container's border box is the origin.
</span><span class="cx">         // The snap area is the bounding box of the child element's border box, after applying transformations.
</span><del>-        // 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.
</del><span class="cx">         auto scrollSnapArea = LayoutRect(child->localToContainerQuad(FloatQuad(child->borderBoundingBox()), &scrollingElementBox).boundingBox());
</span><span class="cx"> 
</span><span class="cx">         // localToContainerQuad will transform the scroll snap area by the scroll position, except in the case that this position is
</span><span class="lines">@@ -246,8 +261,11 @@
</span><span class="cx">         auto alignment = child->style().scrollSnapAlign();
</span><span class="cx">         auto stop = child->style().scrollSnapStop();
</span><span class="cx"> 
</span><del>-        bool snapsHorizontally = hasHorizontalSnapOffsets && alignment.x != ScrollSnapAxisAlignType::None;
-        bool snapsVertically = hasVerticalSnapOffsets && alignment.y != ScrollSnapAxisAlignType::None;
</del><ins>+        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;
+
</ins><span class="cx">         if (!snapsHorizontally && !snapsVertically)
</span><span class="cx">             continue;
</span><span class="cx"> 
</span><span class="lines">@@ -257,12 +275,12 @@
</span><span class="cx">         snapAreas.append(scrollSnapAreaAsOffsets);
</span><span class="cx"> 
</span><span class="cx">         if (snapsHorizontally) {
</span><del>-            auto absoluteScrollXPosition = computeScrollSnapAlignOffset(scrollSnapArea.x(), scrollSnapArea.maxX(), alignment.x, scrollerIsRTL) - computeScrollSnapAlignOffset(scrollSnapPort.x(), scrollSnapPort.maxX(), alignment.x, scrollerIsRTL);
</del><ins>+            auto absoluteScrollXPosition = computeScrollSnapAlignOffset(scrollSnapArea.x(), scrollSnapArea.maxX(), xAlign, xAxisFlipped) - computeScrollSnapAlignOffset(scrollSnapPort.x(), scrollSnapPort.maxX(), xAlign, xAxisFlipped);
</ins><span class="cx">             auto absoluteScrollOffset = clampTo<int>(scrollableArea.scrollOffsetFromPosition({ roundToInt(absoluteScrollXPosition), 0 }).x(), 0, maxScrollOffset.x());
</span><span class="cx">             addOrUpdateStopForSnapOffset(horizontalSnapOffsetsMap, { absoluteScrollOffset, stop, snapAreas.size() - 1 });
</span><span class="cx">         }
</span><span class="cx">         if (snapsVertically) {
</span><del>-            auto absoluteScrollYPosition = computeScrollSnapAlignOffset(scrollSnapArea.y(), scrollSnapArea.maxY(), alignment.y, false) - computeScrollSnapAlignOffset(scrollSnapPort.y(), scrollSnapPort.maxY(), alignment.y, false);
</del><ins>+            auto absoluteScrollYPosition = computeScrollSnapAlignOffset(scrollSnapArea.y(), scrollSnapArea.maxY(), yAlign, yAxisFlipped) - computeScrollSnapAlignOffset(scrollSnapPort.y(), scrollSnapPort.maxY(), yAlign, yAxisFlipped);
</ins><span class="cx">             auto absoluteScrollOffset = clampTo<int>(scrollableArea.scrollOffsetFromPosition({ 0, roundToInt(absoluteScrollYPosition) }).y(), 0, maxScrollOffset.y());
</span><span class="cx">             addOrUpdateStopForSnapOffset(verticalSnapOffsetsMap, { absoluteScrollOffset, stop, snapAreas.size() - 1 });
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkSourceWebCorepagescrollingScrollSnapOffsetsInfoh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.h (278349 => 278350)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -96,7 +96,7 @@
</span><span class="cx"> // Update the snap offsets for this scrollable area, given the RenderBox of the scroll container, the RenderStyle
</span><span class="cx"> // which defines the scroll-snap properties, and the viewport rectangle with the origin at the top left of
</span><span class="cx"> // the scrolling container's border box.
</span><del>-void updateSnapOffsetsForScrollableArea(ScrollableArea&, const RenderBox& scrollingElementBox, const RenderStyle& scrollingElementStyle, LayoutRect viewportRectInBorderBoxCoordinates);
</del><ins>+void updateSnapOffsetsForScrollableArea(ScrollableArea&, const RenderBox& scrollingElementBox, const RenderStyle& scrollingElementStyle, LayoutRect viewportRectInBorderBoxCoordinates, WritingMode, TextDirection);
</ins><span class="cx"> 
</span><span class="cx"> template <typename T> WTF::TextStream& operator<<(WTF::TextStream& ts, SnapOffset<T> offset)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerScrollableAreacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayerScrollableArea.cpp (278349 => 278350)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1469,7 +1469,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     RenderBox* box = m_layer.enclosingElement()->renderBox();
</span><del>-    updateSnapOffsetsForScrollableArea(*this, *box, box->style(), box->paddingBoxRect());
</del><ins>+    updateSnapOffsetsForScrollableArea(*this, *box, box->style(), box->paddingBoxRect(), box->style().writingMode(), box->style().direction());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool RenderLayerScrollableArea::isScrollSnapInProgress() const
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleRenderStylecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (278349 => 278350)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -2578,7 +2578,7 @@
</span><span class="cx"> bool RenderStyle::hasSnapPosition() const
</span><span class="cx"> {
</span><span class="cx">     const ScrollSnapAlign& alignment = this->scrollSnapAlign();
</span><del>-    return alignment.x != ScrollSnapAxisAlignType::None || alignment.y != ScrollSnapAxisAlignType::None;
</del><ins>+    return alignment.blockAlign != ScrollSnapAxisAlignType::None || alignment.inlineAlign != ScrollSnapAxisAlignType::None;
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleStyleScrollSnapPointsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/StyleScrollSnapPoints.h (278349 => 278350)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -48,13 +48,13 @@
</span><span class="cx"> inline bool operator!=(const ScrollSnapType& a, const ScrollSnapType& b) { return !(a == b); }
</span><span class="cx"> 
</span><span class="cx"> struct ScrollSnapAlign {
</span><del>-    ScrollSnapAxisAlignType x { ScrollSnapAxisAlignType::None };
-    ScrollSnapAxisAlignType y { ScrollSnapAxisAlignType::None };
</del><ins>+    ScrollSnapAxisAlignType blockAlign { ScrollSnapAxisAlignType::None };
+    ScrollSnapAxisAlignType inlineAlign { ScrollSnapAxisAlignType::None };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> inline bool operator==(const ScrollSnapAlign& a, const ScrollSnapAlign& b)
</span><span class="cx"> {
</span><del>-    return a.x == b.x && a.y == b.y;
</del><ins>+    return a.blockAlign == b.blockAlign && a.inlineAlign == b.inlineAlign;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> inline bool operator!=(const ScrollSnapAlign& a, const ScrollSnapAlign& b) { return !(a == b); }
</span></span></pre></div>
<a id="trunkSourceWebCorestyleStyleBuilderConverterh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/StyleBuilderConverter.h (278349 => 278350)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -921,11 +921,11 @@
</span><span class="cx"> {
</span><span class="cx">     auto& values = downcast<CSSValueList>(value);
</span><span class="cx">     ScrollSnapAlign alignment;
</span><del>-    alignment.y = downcast<CSSPrimitiveValue>(*values.item(0));
</del><ins>+    alignment.blockAlign = downcast<CSSPrimitiveValue>(*values.item(0));
</ins><span class="cx">     if (values.length() == 1)
</span><del>-        alignment.x = alignment.y;
</del><ins>+        alignment.inlineAlign = alignment.blockAlign;
</ins><span class="cx">     else
</span><del>-        alignment.x = downcast<CSSPrimitiveValue>(*values.item(1));
</del><ins>+        alignment.inlineAlign = downcast<CSSPrimitiveValue>(*values.item(1));
</ins><span class="cx">     return alignment;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>