<!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>[279364] 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/279364">279364</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2021-06-29 00:14:08 -0700 (Tue, 29 Jun 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>CSS scroll snap should allow scrolling to the middle of snap areas that overflow the snapport
https://bugs.webkit.org/show_bug.cgi?id=223021
<rdar://problem/75518606>

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

LayoutTests/imported/w3c:

* web-platform-tests/css/css-scroll-snap/overflowing-snap-areas-expected.txt: Update test
expectations to reflect newly passing tests.

Source/WebCore:

No new tests. This is covered by existing tests and, in particular, a WPT test:
    - web-platform-tests/css/css-scroll-snap/overflowing-snap-areas.html

* page/scrolling/ScrollSnapOffsetsInfo.cpp:
(WebCore::searchForPotentialSnapPoints): Record when the target snap offset happens to
fall in the interior of a snap area that overflows the snap port.
(WebCore::closestSnapOffsetWithInfoAndAxis): When this happens and we are in a spec-compliant
sitaution, just snap to the original target offset.

LayoutTests:

Update some existing tests that were relying on non-spec compliant behavior. These tests
used snap areas that were larger than the snapport and didn't expect that the parent
scroller could scroll into them.

* css3/scroll-snap/scroll-snap-click-scrollbar-gutter.html: This test used snap areas that
overflow the snapport, thus meant that it relied on non-spec compliant behavior. Rework it so
that the snap areas do not overflow, maintaining the existing behavior.
* tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html: Ditto.
* tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-overflow.html: Ditto.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestscss3scrollsnapscrollsnapclickscrollbargutterhtml">trunk/LayoutTests/css3/scroll-snap/scroll-snap-click-scrollbar-gutter.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestscsscssscrollsnapoverflowingsnapareasexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/overflowing-snap-areas-expected.txt</a></li>
<li><a href="#trunkLayoutTeststileddrawingscrollingscrollsnapscrollsnapmandatorymainframeverticalthenhorizontalhtml">trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html</a></li>
<li><a href="#trunkLayoutTeststileddrawingscrollingscrollsnapscrollsnapproximityoverflowhtml">trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-overflow.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorepagescrollingScrollSnapOffsetsInfocpp">trunk/Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (279363 => 279364)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2021-06-29 06:11:52 UTC (rev 279363)
+++ trunk/LayoutTests/ChangeLog 2021-06-29 07:14:08 UTC (rev 279364)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2021-06-29  Martin Robinson  <mrobinson@igalia.com>
+
+        CSS scroll snap should allow scrolling to the middle of snap areas that overflow the snapport
+        https://bugs.webkit.org/show_bug.cgi?id=223021
+        <rdar://problem/75518606>
+
+        Reviewed by Simon Fraser.
+
+        Update some existing tests that were relying on non-spec compliant behavior. These tests
+        used snap areas that were larger than the snapport and didn't expect that the parent
+        scroller could scroll into them.
+
+        * css3/scroll-snap/scroll-snap-click-scrollbar-gutter.html: This test used snap areas that
+        overflow the snapport, thus meant that it relied on non-spec compliant behavior. Rework it so
+        that the snap areas do not overflow, maintaining the existing behavior.
+        * tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html: Ditto.
+        * tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-overflow.html: Ditto.
+
</ins><span class="cx"> 2021-06-28  Wenson Hsieh  <wenson_hsieh@apple.com>
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (r279310): Occasional crash when focusing login fields on iPad with a software keyboard
</span></span></pre></div>
<a id="trunkLayoutTestscss3scrollsnapscrollsnapclickscrollbargutterhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/css3/scroll-snap/scroll-snap-click-scrollbar-gutter.html (279363 => 279364)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/css3/scroll-snap/scroll-snap-click-scrollbar-gutter.html       2021-06-29 06:11:52 UTC (rev 279363)
+++ trunk/LayoutTests/css3/scroll-snap/scroll-snap-click-scrollbar-gutter.html  2021-06-29 07:14:08 UTC (rev 279364)
</span><span class="lines">@@ -34,21 +34,32 @@
</span><span class="cx">                 scroll-snap-type: both mandatory;
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            .block {
-                height: 1000px;
-                width: 250px;
-                scroll-snap-align: start;
-            }
-
</del><span class="cx">             .horizontal-drawer {
</span><span class="cx">                 height: 100%;
</span><span class="cx">                 width: 2000px;
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            .horizontal-drawer .block {
-                width: 1000px;
-                height: 250px;
</del><ins>+            .horizontal-drawer > div {
+                float: left;
+                width: 990px;
+                height: 100%;
</ins><span class="cx">             }
</span><ins>+
+            .horizontal-drawer > div.snap-point {
+                scroll-snap-align: start;
+                width: 10px;
+             }
+
+            #vertical-container > div {
+                width: 100%;
+                height: 990px;
+            }
+
+            #vertical-container > div.snap-point {
+                scroll-snap-align: start;
+                height: 10px;
+            }
+
</ins><span class="cx">         </style>
</span><span class="cx">         <script src="../../resources/js-test.js"></script>
</span><span class="cx">         <script src="../../resources/ui-helper.js"></script>
</span><span class="lines">@@ -87,13 +98,17 @@
</span><span class="cx">     <body onload="onLoad();">
</span><span class="cx">         <div id="horizontal-container" class="container">
</span><span class="cx">             <div class="horizontal-drawer">
</span><del>-                <div class="block" style="float: left; background: #80475E"></div>
-                <div class="block" style="width: 450px; float: left; background: #CC5A71"></div>
</del><ins>+                <div class="snap-point" style="background: #80475E"></div>
+                <div></div>
+                <div class="snap-point" style="background: #CC5A71"></div>
+                <div></div>
</ins><span class="cx">             </div>
</span><span class="cx">         </div>
</span><span class="cx">         <div id="vertical-container" class="container">
</span><del>-            <div class="block" style="background: #80475E"></div>
-            <div class="block" style="height: 450px; background: #CC5A71"></div>
</del><ins>+            <div class="snap-point" style="background: #80475E"></div>
+            <div></div>
+            <div class="snap-point" style="background: #CC5A71"></div>
+            <div></div>
</ins><span class="cx">         </div>
</span><span class="cx">         <p id="console"></p>
</span><span class="cx">         <script>
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (279363 => 279364)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-06-29 06:11:52 UTC (rev 279363)
+++ trunk/LayoutTests/imported/w3c/ChangeLog    2021-06-29 07:14:08 UTC (rev 279364)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2021-06-29  Martin Robinson  <mrobinson@igalia.com>
+
+        CSS scroll snap should allow scrolling to the middle of snap areas that overflow the snapport
+        https://bugs.webkit.org/show_bug.cgi?id=223021
+        <rdar://problem/75518606>
+
+        Reviewed by Simon Fraser.
+
+        * web-platform-tests/css/css-scroll-snap/overflowing-snap-areas-expected.txt: Update test
+        expectations to reflect newly passing tests.
+
</ins><span class="cx"> 2021-06-28  Darin Adler  <darin@apple.com>
</span><span class="cx"> 
</span><span class="cx">         CSS parser "consume declaration" algorithm does not handle whitespace correctly
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestscsscssscrollsnapoverflowingsnapareasexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/overflowing-snap-areas-expected.txt (279363 => 279364)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/overflowing-snap-areas-expected.txt        2021-06-29 06:11:52 UTC (rev 279363)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/overflowing-snap-areas-expected.txt   2021-06-29 07:14:08 UTC (rev 279364)
</span><span class="lines">@@ -1,13 +1,13 @@
</span><span class="cx"> 
</span><span class="cx"> PASS Snaps to the snap position if the snap area doesn't cover the snapport on x.
</span><del>-FAIL Snaps to the snap position if the snap area covers the snapport on x on the right border. assert_equals: expected 2715 but got 200
-FAIL Snaps to the snap position if the snap area covers the snapport on x on the left border. assert_equals: expected 200 but got 2715
</del><ins>+PASS Snaps to the snap position if the snap area covers the snapport on x on the right border.
+PASS Snaps to the snap position if the snap area covers the snapport on x on the left border.
</ins><span class="cx"> PASS Snaps if the distance between the previous(400) and next(800) snap positions is smaller than snapport(500) on x.
</span><span class="cx"> PASS Snaps if the distance between the previous(400) and next(800) snap positions is smaller than snapport(500) on y.
</span><del>-FAIL Snap to current scroll position which is a valid snap position, as the snap area covers snapport on x and the distance between the previous(800) and next(1400) is larger than snapport(500). assert_equals: expected 900 but got 800
-FAIL Snap to current scroll position which is a valid snap position, as the snap area covers snapport on y and the distance between the previous(800) and next(1400) is larger than snapport(500). assert_equals: expected 900 but got 800
-FAIL Snap to current scroll position which is a valid snap position, as the snap area covers snapport on x and there is no subsequent snap positions. assert_equals: expected 1500 but got 1400
-FAIL Snap to current scroll position which is a valid snap position, as the snap area covers snapport on y and there is no subsequent snap positions. assert_equals: expected 1500 but got 1400
-FAIL Don't snap back even if scrollTo tries to scroll to positions which are outside of the scroll range and if a snap target element covers the snaport assert_equals: expected 3715 but got 2200
-FAIL Snap to current scroll position on x as the area is covering x axis.However, we snap to the specified snap position on y as the area is not covering y axis. assert_equals: expected 10 but got 0
</del><ins>+PASS Snap to current scroll position which is a valid snap position, as the snap area covers snapport on x and the distance between the previous(800) and next(1400) is larger than snapport(500).
+PASS Snap to current scroll position which is a valid snap position, as the snap area covers snapport on y and the distance between the previous(800) and next(1400) is larger than snapport(500).
+PASS Snap to current scroll position which is a valid snap position, as the snap area covers snapport on x and there is no subsequent snap positions.
+PASS Snap to current scroll position which is a valid snap position, as the snap area covers snapport on y and there is no subsequent snap positions.
+PASS Don't snap back even if scrollTo tries to scroll to positions which are outside of the scroll range and if a snap target element covers the snaport
+PASS Snap to current scroll position on x as the area is covering x axis.However, we snap to the specified snap position on y as the area is not covering y axis.
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTeststileddrawingscrollingscrollsnapscrollsnapmandatorymainframeverticalthenhorizontalhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html (279363 => 279364)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html      2021-06-29 06:11:52 UTC (rev 279363)
+++ trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-vertical-then-horizontal.html 2021-06-29 07:14:08 UTC (rev 279364)
</span><span class="lines">@@ -4,6 +4,7 @@
</span><span class="cx">         <style>
</span><span class="cx">             html {
</span><span class="cx">                 scroll-snap-type: y mandatory;
</span><ins>+                margin: 0;
</ins><span class="cx">             }
</span><span class="cx">             .verticalGallery {
</span><span class="cx">                 width: 100vw;
</span><span class="lines">@@ -12,7 +13,7 @@
</span><span class="cx">                 padding: 0;
</span><span class="cx">             }
</span><span class="cx">             .colorBox {
</span><del>-                height: 100vh;
</del><ins>+                height: 90vh;
</ins><span class="cx">                 width: 100vw;
</span><span class="cx">                 float: left;
</span><span class="cx">                 scroll-snap-align: start;
</span></span></pre></div>
<a id="trunkLayoutTeststileddrawingscrollingscrollsnapscrollsnapproximityoverflowhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-overflow.html (279363 => 279364)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-overflow.html        2021-06-29 06:11:52 UTC (rev 279363)
+++ trunk/LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-proximity-overflow.html   2021-06-29 07:14:08 UTC (rev 279364)
</span><span class="lines">@@ -13,21 +13,16 @@
</span><span class="cx">                 position: absolute;
</span><span class="cx">                 top: 0;
</span><span class="cx">                 left: 0;
</span><del>-                overflow-x: none;
</del><span class="cx">                 overflow-y: scroll;
</span><span class="cx">                 scroll-snap-type: y proximity;
</span><del>-                -webkit-scroll-snap-type: proximity;
-                scroll-snap-type: proximity;
</del><span class="cx">                 opacity: 0.5;
</span><span class="cx">             }
</span><span class="cx"> 
</span><span class="cx">             .area {
</span><del>-                height: 600px;
-                width: 600px;
</del><ins>+                height: 100%;
+                width: 100%;
</ins><span class="cx">                 float: left;
</span><span class="cx">                 scroll-snap-align: start;
</span><del>-                -webkit-scroll-snap-coordinate: 0 0;
-                scroll-snap-coordinate: 0 0;
</del><span class="cx">             }
</span><span class="cx">         </style>
</span><span class="cx">         <script>
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (279363 => 279364)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-06-29 06:11:52 UTC (rev 279363)
+++ trunk/Source/WebCore/ChangeLog      2021-06-29 07:14:08 UTC (rev 279364)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2021-06-29  Martin Robinson  <mrobinson@igalia.com>
+
+        CSS scroll snap should allow scrolling to the middle of snap areas that overflow the snapport
+        https://bugs.webkit.org/show_bug.cgi?id=223021
+        <rdar://problem/75518606>
+
+        Reviewed by Simon Fraser.
+
+        No new tests. This is covered by existing tests and, in particular, a WPT test:
+            - web-platform-tests/css/css-scroll-snap/overflowing-snap-areas.html
+
+        * page/scrolling/ScrollSnapOffsetsInfo.cpp:
+        (WebCore::searchForPotentialSnapPoints): Record when the target snap offset happens to
+        fall in the interior of a snap area that overflows the snap port.
+        (WebCore::closestSnapOffsetWithInfoAndAxis): When this happens and we are in a spec-compliant
+        sitaution, just snap to the original target offset.
+
</ins><span class="cx"> 2021-06-28  Xabier Rodriguez Calvar  <calvaris@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         [GStreamer][EME] Fix resources release when a MediaKeySession is closed
</span></span></pre></div>
<a id="trunkSourceWebCorepagescrollingScrollSnapOffsetsInfocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.cpp (279363 => 279364)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.cpp    2021-06-29 06:11:52 UTC (rev 279363)
+++ trunk/Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.cpp       2021-06-29 07:14:08 UTC (rev 279364)
</span><span class="lines">@@ -45,13 +45,15 @@
</span><span class="cx">     std::optional<std::pair<UnitType, unsigned>> previous;
</span><span class="cx">     std::optional<std::pair<UnitType, unsigned>> next;
</span><span class="cx">     std::optional<std::pair<UnitType, unsigned>> snapStop;
</span><ins>+    bool landedInsideSnapAreaThatConsumesViewport;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> template <typename InfoType, typename UnitType>
</span><del>-static PotentialSnapPointSearchResult<UnitType> searchForPotentialSnapPoints(const InfoType& info, ScrollEventAxis axis, UnitType destinationOffset, std::optional<UnitType> originalOffset)
</del><ins>+static PotentialSnapPointSearchResult<UnitType> searchForPotentialSnapPoints(const InfoType& info, ScrollEventAxis axis, UnitType viewportLength, UnitType destinationOffset, std::optional<UnitType> originalOffset)
</ins><span class="cx"> {
</span><span class="cx">     const auto& snapOffsets = info.offsetsForAxis(axis);
</span><span class="cx">     std::optional<std::pair<UnitType, unsigned>> previous, next, exact, snapStop;
</span><ins>+    bool landedInsideSnapAreaThatConsumesViewport = false;
</ins><span class="cx"> 
</span><span class="cx">     // A particular snap stop is better if it's between the original offset and destination offset and closer original
</span><span class="cx">     // offset than the previously selected snap stop. We always want to stop at the snap stop closest to the original offset.
</span><span class="lines">@@ -66,6 +68,12 @@
</span><span class="cx"> 
</span><span class="cx">     for (unsigned i = 0; i < snapOffsets.size(); i++) {
</span><span class="cx">         UnitType potentialSnapOffset = snapOffsets[i].offset;
</span><ins>+
+        const auto& snapArea = info.snapAreas[snapOffsets[i].snapAreaIndex];
+        auto snapAreaMin = axis == ScrollEventAxis::Horizontal ? snapArea.x() : snapArea.y();
+        auto snapAreaMax = axis == ScrollEventAxis::Horizontal ? snapArea.maxX() : snapArea.maxY();
+        landedInsideSnapAreaThatConsumesViewport |= snapAreaMin <= destinationOffset && snapAreaMax >= (destinationOffset + viewportLength);
+
</ins><span class="cx">         if (potentialSnapOffset == destinationOffset)
</span><span class="cx">             exact = std::make_pair(potentialSnapOffset, i);
</span><span class="cx">         else if (potentialSnapOffset < destinationOffset)
</span><span class="lines">@@ -78,8 +86,8 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (exact)
</span><del>-        return { exact, exact, snapStop };
-    return { previous, next, snapStop };
</del><ins>+        return { exact, exact, snapStop, landedInsideSnapAreaThatConsumesViewport };
+    return { previous, next, snapStop, landedInsideSnapAreaThatConsumesViewport };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template <typename InfoType, typename SizeType, typename LayoutType>
</span><span class="lines">@@ -90,11 +98,20 @@
</span><span class="cx">     if (snapOffsets.isEmpty())
</span><span class="cx">         return pairForNoSnapping;
</span><span class="cx"> 
</span><del>-    auto [previous, next, snapStop] = searchForPotentialSnapPoints(info, axis, scrollDestinationOffset, originalOffsetForDirectionalSnapping);
</del><ins>+    auto viewportLength = axis == ScrollEventAxis::Horizontal ? viewportSize.width() : viewportSize.height();
+    auto [previous, next, snapStop, landedInsideSnapAreaThatConsumesViewport] = searchForPotentialSnapPoints(info, axis, viewportLength, scrollDestinationOffset, originalOffsetForDirectionalSnapping);
</ins><span class="cx">     if (snapStop)
</span><span class="cx">         return *snapStop;
</span><span class="cx"> 
</span><del>-    auto viewportLength = axis == ScrollEventAxis::Horizontal ? viewportSize.width() : viewportSize.height();
</del><ins>+    // From https://www.w3.org/TR/css-scroll-snap-1/#snap-overflow
+    // "If the snap area is larger than the snapport in a particular axis, then any scroll position
+    // in which the snap area covers the snapport, and the distance between the geometrically
+    // previous and subsequent snap positions in that axis is larger than size of the snapport in
+    // that axis, is a valid snap position in that axis. The UA may use the specified alignment as a
+    // more precise target for certain scroll operations (e.g. explicit paging)."
+    if (landedInsideSnapAreaThatConsumesViewport && (!previous || !next || ((*next).first - (*previous).first) >= viewportLength))
+        return pairForNoSnapping;
+
</ins><span class="cx">     auto isNearEnoughToOffsetForProximity = [&](LayoutType candidateSnapOffset) {
</span><span class="cx">         if (info.strictness != ScrollSnapStrictness::Proximity)
</span><span class="cx">             return true;
</span></span></pre>
</div>
</div>

</body>
</html>