-
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.
View transition layered capture: determine geometry based on box model
Instead of capturing the border offset, we capture the following layout sizes to determine sizing, in addition to the border box: - padding box - content box - The box-sizing property - In layered capture mode, we use the content box size as the reference box for positioning the snapshot, so that padding take effect. - The ::view-transition-image-pair pseudo-element now has position:relative so that it gets affected by padding. It has the content box size. - The width/height of the group is determined by the box-sizing property, and it receives the computed padding. Bug: 375395117 Change-Id: I18fe5126fbfac58b0619043cc5521ea1f280e457 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5953705 Reviewed-by: Khushal Sagar <[email protected]> Reviewed-by: Philip Rogers <[email protected]> Reviewed-by: Arthur Sonzogni <[email protected]> Commit-Queue: Noam Rosenthal <[email protected]> Cr-Commit-Position: refs/heads/main@{#1379706}
- Loading branch information
1 parent
23f125f
commit 07dfce3
Showing
8 changed files
with
210 additions
and
7 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
34 changes: 34 additions & 0 deletions
34
css/css-view-transitions/layered-capture/border-offset-with-padding-inline-ref.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,34 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<title>Borders should not affect snapshot position</title> | ||
<link rel="help" href="https://drafts.csswg.org/css-view-transitions-2/"> | ||
<style> | ||
* { | ||
box-sizing: content-box; | ||
} | ||
html { | ||
view-transition-name: none; | ||
} | ||
body { | ||
margin: 0; | ||
} | ||
|
||
div { | ||
position: absolute; | ||
} | ||
|
||
.inline { | ||
view-transition-name: parent; | ||
border: 10px solid black; | ||
background: green; | ||
padding: 12px; | ||
position: relative; | ||
left: 100px; | ||
top: 40px; | ||
} | ||
</style> | ||
<body> | ||
<span class="inline"> | ||
ABC | ||
</span> | ||
</body> |
49 changes: 49 additions & 0 deletions
49
css/css-view-transitions/layered-capture/border-offset-with-padding-inline.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,49 @@ | ||
<!DOCTYPE html> | ||
<html class=reftest-wait> | ||
<title>Borders should not affect snapshot position</title> | ||
<link rel="help" href="https://drafts.csswg.org/css-view-transitions-2/"> | ||
<link rel="match" href="border-offset-with-padding-inline-ref.html"> | ||
<script src="/common/reftest-wait.js"></script> | ||
<script src="resources/compute-test.js"></script> | ||
<style> | ||
* { | ||
box-sizing: content-box; | ||
} | ||
html { | ||
view-transition-name: none; | ||
} | ||
body { | ||
margin: 0; | ||
} | ||
|
||
div { | ||
position: absolute; | ||
} | ||
|
||
.inline { | ||
view-transition-name: parent; | ||
border: 10px solid black; | ||
background: green; | ||
padding: 12px; | ||
position: relative; | ||
left: 100px; | ||
top: 40px; | ||
} | ||
|
||
::view-transition-old(*), | ||
::view-transition-new(*), | ||
::view-transition-group(*) { | ||
animation-play-state: paused; | ||
} | ||
</style> | ||
<body> | ||
<span class="inline"> | ||
ABC | ||
</span> | ||
<script> | ||
const transition = document.startViewTransition(() => { | ||
document.documentElement.classList.add("vt-new"); | ||
}); | ||
transition.ready.then(() => takeScreenshot()); | ||
</script> | ||
</body> |
59 changes: 59 additions & 0 deletions
59
css/css-view-transitions/layered-capture/border-offset-with-padding-nested.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,59 @@ | ||
<!DOCTYPE html> | ||
<html class=reftest-wait> | ||
<title>Borders should not affect snapshot position</title> | ||
<link rel="help" href="https://drafts.csswg.org/css-view-transitions-2/"> | ||
<link rel="match" href="border-offset-ref.tentative.html"> | ||
<script src="/common/reftest-wait.js"></script> | ||
<script src="resources/compute-test.js"></script> | ||
<style> | ||
html { | ||
view-transition-name: none; | ||
} | ||
body { | ||
margin: 0; | ||
} | ||
|
||
div { | ||
position: absolute; | ||
} | ||
|
||
.parent { | ||
view-transition-name: parent; | ||
border: 10px solid black; | ||
background: green; | ||
padding: 20px; | ||
width: 40px; | ||
height: 40px; | ||
box-sizing: content-box; | ||
} | ||
|
||
.child { | ||
width: 30px; | ||
padding-left: 6px; | ||
height: 36px; | ||
background: yellow; | ||
border: 2px dashed blue; | ||
view-transition-group: parent; | ||
} | ||
|
||
::view-transition-old(*), | ||
::view-transition-new(*), | ||
::view-transition-group(*) { | ||
animation-play-state: paused; | ||
} | ||
|
||
::view-transition-group(parent) { | ||
overflow: clip; | ||
} | ||
</style> | ||
<body> | ||
<div class="parent"> | ||
<div class="child"></div> | ||
</div> | ||
<script> | ||
const transition = document.startViewTransition(() => { | ||
document.documentElement.classList.add("vt-new"); | ||
}); | ||
transition.ready.then(() => takeScreenshot()); | ||
</script> | ||
</body> |
59 changes: 59 additions & 0 deletions
59
css/css-view-transitions/layered-capture/border-offset-with-padding.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,59 @@ | ||
<!DOCTYPE html> | ||
<html class=reftest-wait> | ||
<title>Borders should not affect snapshot position</title> | ||
<link rel="help" href="https://drafts.csswg.org/css-view-transitions-2/"> | ||
<link rel="match" href="border-offset-ref.tentative.html"> | ||
<script src="/common/reftest-wait.js"></script> | ||
<script src="resources/compute-test.js"></script> | ||
<style> | ||
* { | ||
box-sizing: content-box; | ||
} | ||
html { | ||
view-transition-name: none; | ||
} | ||
body { | ||
margin: 0; | ||
} | ||
|
||
div { | ||
position: absolute; | ||
} | ||
|
||
.parent { | ||
view-transition-name: parent; | ||
border: 10px solid black; | ||
background: green; | ||
padding: 20px; | ||
width: 40px; | ||
height: 40px; | ||
} | ||
|
||
.child { | ||
width: 36px; | ||
height: 36px; | ||
background: yellow; | ||
border: 2px dashed blue; | ||
} | ||
|
||
::view-transition-old(*), | ||
::view-transition-new(*), | ||
::view-transition-group(*) { | ||
animation-play-state: paused; | ||
} | ||
|
||
::view-transition-group(parent) { | ||
overflow: clip; | ||
} | ||
</style> | ||
<body> | ||
<div class="parent"> | ||
<div class="child"></div> | ||
</div> | ||
<script> | ||
const transition = document.startViewTransition(() => { | ||
document.documentElement.classList.add("vt-new"); | ||
}); | ||
transition.ready.then(() => takeScreenshot()); | ||
</script> | ||
</body> |
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