-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[css-scroll-snap-2] Resolve scroll-start-targets with reverse DOM order
Per CSSWG resolution[1], user agents should handle competing scroll-start-targets by scrolling to each target in reverse-DOM-order. This patch implements this and re-enables scroll-start-target tests. Note that, for now, we only need to store the scroll-start-target which is first-in-tree/DOM order and not the whole list. This is because when we scroll to the scroll-start-targets (in reverse DOM order) we're effectively only scrolling to the first-in-tree/DOM order scroll-start-target. Scrolling to each target will only have an effect when a "nearest" value is accepted by scroll-snap-align which will have the same effect as "nearest" in scrollIntoView. So for now we can keep track of just one element, the first in tree/DOM order. [1] w3c/csswg-drafts#10774 (comment) Bug: 40909052, 368038561 Change-Id: I029920bdb053ae258932e3e7579f28d8256baf70 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5881923 Commit-Queue: David Awogbemila <awogbemila@chromium.org> Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org> Cr-Commit-Position: refs/heads/main@{#1363980}
- Loading branch information
1 parent
a18606c
commit e87b420
Showing
14 changed files
with
140 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
css/css-scroll-snap-2/scroll-start-target/scroll-start-target-span.tentative.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title> CSS Scroll Snap 2 Test: scroll-start-target with a <span> element</title> | ||
<link rel="help" href="https://drafts.csswg.org/css-scroll-snap-2/#scroll-start-target"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/css/css-animations/support/testcommon.js"></script> | ||
</head> | ||
<body> | ||
<style> | ||
* { | ||
margin: 0px; | ||
} | ||
.space { | ||
width: 150%; | ||
height: 150%; | ||
} | ||
.box { | ||
height: 50px; | ||
width: 50px; | ||
border: solid 1px black; | ||
background-color: turquoise; | ||
} | ||
.target { | ||
scroll-start-target: auto; | ||
} | ||
.scroller { | ||
overflow: scroll; | ||
height: 100px; | ||
width: 100px; | ||
} | ||
</style> | ||
<div id="scroller" class="scroller"> | ||
<div class="space"></div> | ||
<span id="target" class="target"> | ||
<div class="box"></div> | ||
</span> | ||
<div class="space"></div> | ||
</div> | ||
<script> | ||
promise_test(async (t) => { | ||
await waitForAnimationFrames(2); | ||
const scroller = document.getElementById("scroller"); | ||
const target = document.getElementById("target"); | ||
|
||
assert_equals(scroller.scrollTop, target.offsetTop, | ||
"scroller is initially scrolled to it <span> scroll-start-target"); | ||
}, "<span> scroll-start-target is honored"); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.