Skip to content

Commit

Permalink
Nested view transitions: support view-transition-group: nearest/normal
Browse files Browse the repository at this point in the history
Parse nearest/normal as keywords, and use a StyleViewTransitionGroup
struct to store the result.

Rely on a stack while capturing elements hierarchically, to
correctly resolve "view-transition-group: nearest".

Also use that stack instead of element ancestry for
computing explicit names.

Bug: 347947051
Change-Id: If06d2a6ff266013f4a46a492191c31e4a66111c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5752182
Reviewed-by: Khushal Sagar <[email protected]>
Commit-Queue: Noam Rosenthal <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1338320}
  • Loading branch information
noamr authored and pull[bot] committed Jan 27, 2025
1 parent 74c0aa3 commit 1079031
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 0 deletions.
16 changes: 16 additions & 0 deletions css/css-view-transitions/nested/nearest-direct.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html class=reftest-wait>
<title>Nearest should match direct parent</title>
<meta name=fuzzy content="maxDifference=0-255; totalPixels=0-515">
<link rel="help" href="https://drafts.csswg.org/css-view-transitions-2/">
<link rel="match" href="nested-ref.html">
<link rel=stylesheet href="resources/compute-common.css"></link>
<script src="/common/reftest-wait.js"></script>
<script src="resources/compute-test.js"></script>
<body>
<div class="green">
<div>
<div class="test nearest-ref"></article>
</div>
</div>
</body>
18 changes: 18 additions & 0 deletions css/css-view-transitions/nested/nearest-ignores-nearest-name.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html class=reftest-wait>
<title>Nearest should not match a group called "nearest"</title>
<meta name=fuzzy content="maxDifference=0-255; totalPixels=0-515">
<link rel="help" href="https://drafts.csswg.org/css-view-transitions-2/">
<link rel="match" href="nested-ref.html">
<link rel=stylesheet href="resources/compute-common.css"></link>
<script src="/common/reftest-wait.js"></script>
<script src="resources/compute-test.js"></script>
<body>
<div style="view-transition-name: nearest">
<div class="green">
<div>
<div class="test nearest-ref"></article>
</div>
</div>
</div>
</body>
18 changes: 18 additions & 0 deletions css/css-view-transitions/nested/nearest-nested.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html class=reftest-wait>
<title>Nearest should match non-direct ancestor</title>
<meta name=fuzzy content="maxDifference=0-255; totalPixels=0-515">
<link rel="help" href="https://drafts.csswg.org/css-view-transitions-2/">
<link rel="match" href="nested-ref.html">
<link rel=stylesheet href="resources/compute-common.css"></link>
<script src="/common/reftest-wait.js"></script>
<script src="resources/compute-test.js"></script>
<body>
<div class="red">
<div class="green">
<div>
<div class="test nearest-ref"></article>
</div>
</div>
</div>
</body>
16 changes: 16 additions & 0 deletions css/css-view-transitions/nested/normal-goes-up.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html class="reftest-wait no-match">
<title>view-transition: normal should behave like having no group</title>
<meta name=fuzzy content="maxDifference=0-255; totalPixels=0-515">
<link rel="help" href="https://drafts.csswg.org/css-view-transitions-2/">
<link rel="match" href="nested-ref.html">
<link rel=stylesheet href="resources/compute-common.css"></link>
<script src="/common/reftest-wait.js"></script>
<script src="resources/compute-test.js"></script>
<body>
<div class="normal">
<div>
<div class="test normal-ref"></article>
</div>
</div>
</body>
11 changes: 11 additions & 0 deletions css/css-view-transitions/nested/resources/compute-common.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ html.no-match::view-transition {
view-transition-group: red;
}

.nearest-ref {
view-transition-group: nearest;
}

.normal {
view-transition-name: normal;
}

.normal-ref {
view-transition-group: normal;
}
::view-transition-group(green) {
background: green;
}
Expand Down

0 comments on commit 1079031

Please sign in to comment.