Skip to content

Commit

Permalink
Add view-transition-capture-mode CSS property
Browse files Browse the repository at this point in the history
This property has the values of flat | layered, layered by
default.

- Flat is the current way we capture view transition content
- Layered is the new way, which captures box decorations and
  effects as style instead of baking them into the image.

Bug: 347947051
Change-Id: If70c8436ef34d194002452447dbd2d5ebedfa387
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5935195
Commit-Queue: Noam Rosenthal <[email protected]>
Reviewed-by: Khushal Sagar <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1369285}
  • Loading branch information
noamr authored and chromium-wpt-export-bot committed Oct 16, 2024
1 parent 32d9a66 commit c35d4f9
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 0 deletions.
45 changes: 45 additions & 0 deletions css/css-view-transitions/layered-capture/capture-mode-flat.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!DOCTYPE html>
<html class=reftest-wait>
<title>Capture mode: flat</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-opacity-ref.html">
<script src="/common/reftest-wait.js"></script>
<script src="../nested/resources/compute-test.js"></script>
<style>
body {
margin: 0;
}
div {
position: absolute;
width: 100px;
height: 100px;
background: green;
}

.parent {
opacity: 0.4;
view-transition-name: parent;
view-transition-capture-mode: flat;
will-change: opacity;
}

.child {
top: 50px;
left: 50px;
}

::view-transition-group(parent) {
animation-name: none;
opacity: 1;
}
::view-transition-old(*),
::view-transition-new(*) {
animation-play-state: paused;
}
</style>
<body>
<div class="parent">
<div class="child"></div>
</div>
</body>
45 changes: 45 additions & 0 deletions css/css-view-transitions/layered-capture/capture-mode-layered.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!DOCTYPE html>
<html class=reftest-wait>
<title>Captured mode: layered</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-opacity-ref.html">
<script src="/common/reftest-wait.js"></script>
<script src="../nested/resources/compute-test.js"></script>
<style>
body {
margin: 0;
}
div {
position: absolute;
width: 100px;
height: 100px;
background: green;
}

.parent {
opacity: 0.7;
view-transition-name: parent;
will-change: opacity;
view-transition-capture-mode: layered;
}

.child {
top: 50px;
left: 50px;
}

::view-transition-group(parent) {
opacity: 0.4;
animation-name: none;
}
::view-transition-old(*),
::view-transition-new(*) {
animation-play-state: paused;
}
</style>
<body>
<div class="parent">
<div class="child"></div>
</div>
</body>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS View Transitions Test: view-transition-capture-mode with invalid values</title>
<link rel="help" href="https://drafts.csswg.org/css-view-transitions-2/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/parsing-testcommon.js"></script>
</head>
<body>
<script>
test_invalid_value("view-transition-capture-mode", "none");
test_invalid_value("view-transition-capture-mode", "auto");
test_invalid_value("view-transition-capture-mode", "stuff");
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS View Transitions Test: view-transition-capture-mode with valid values</title>
<link rel="help" href="https://drafts.csswg.org/css-view-transitions-2/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/parsing-testcommon.js"></script>
</head>
<body>
<script>
test_valid_value("view-transition-capture-mode", "flat");
test_valid_value("view-transition-capture-mode", "layered");

</script>
</body>
</html>

0 comments on commit c35d4f9

Please sign in to comment.