Skip to content

Commit

Permalink
VT: Pixel snapping ink overflow rect
Browse files Browse the repository at this point in the history
This patch adds pixel snapping to the overflow rect sometimes.
The ideal solution would know whether pixel snapping happens in all
cases, but it's really complicated to know that, since we need to
figure out which element caused the overflow edge and whether that
element was pixel snapped and at what offset.

For now, handle common cases.

R=khushalsagar@chromium.org

Bug: 1432868
Change-Id: I4d5d52bba22bf7b5a5412152accd524fedbfce11
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4481094
Reviewed-by: Khushal Sagar <khushalsagar@chromium.org>
Commit-Queue: Vladimir Levin <vmpstr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1137954}
  • Loading branch information
vmpstr authored and chromium-wpt-export-bot committed May 1, 2023
1 parent 6508033 commit e088e34
Show file tree
Hide file tree
Showing 9 changed files with 318 additions and 0 deletions.
35 changes: 35 additions & 0 deletions css/css-view-transitions/fractional-box-new.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html class=reftest-wait>
<title>View transitions: fractional box -- new content</title>
<link rel="help" href="https://drafts.csswg.org/css-view-transitions-1/">
<link rel="author" href="mailto:vmpstr@chromium.org">
<link rel="match" href="fractional-box-ref.html">
<script src="/common/reftest-wait.js"></script>
<style>
.box {
margin: 15px;
background: green;
width: 100.125px;
height: 50.875px;
}
.shift {
position: relative;
left: 0.4px;
}
html::view-transition-group(*) { animation-duration: 300s; }
html::view-transition-new(*) { animation: unset; opacity: 1; }
html::view-transition-old(*) { animation: unset; opacity: 0; }
html::view-transition-group(root) { animation: unset; opacity: 0; }
html::view-transition { background: lightpink; }
</style>
<div class="box" style="view-transition-name: one"></div>
<div class="box shift" style="view-transition-name: two"></div>
<script>
failIfNot(document.startViewTransition, "Missing document.startViewTransition");

async function runTest() {
document.startViewTransition().ready.then(takeScreenshot);
}
onload = () => requestAnimationFrame(() => requestAnimationFrame(runTest));
</script>

35 changes: 35 additions & 0 deletions css/css-view-transitions/fractional-box-old.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html class=reftest-wait>
<title>View transitions: fractional box -- old content</title>
<link rel="help" href="https://drafts.csswg.org/css-view-transitions-1/">
<link rel="author" href="mailto:vmpstr@chromium.org">
<link rel="match" href="fractional-box-ref.html">
<script src="/common/reftest-wait.js"></script>
<style>
.box {
margin: 15px;
background: green;
width: 100.125px;
height: 50.875px;
}
.shift {
position: relative;
left: 0.4px;
}
html::view-transition-group(*) { animation-duration: 300s; }
html::view-transition-new(*) { animation: unset; opacity: 0; }
html::view-transition-old(*) { animation: unset; opacity: 1; }
html::view-transition-group(root) { animation: unset; opacity: 0; }
html::view-transition { background: lightpink; }
</style>
<div class="box" style="view-transition-name: one"></div>
<div class="box shift" style="view-transition-name: two"></div>
<script>
failIfNot(document.startViewTransition, "Missing document.startViewTransition");

async function runTest() {
document.startViewTransition().ready.then(takeScreenshot);
}
onload = () => requestAnimationFrame(() => requestAnimationFrame(runTest));
</script>

19 changes: 19 additions & 0 deletions css/css-view-transitions/fractional-box-ref.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<title>View transitions: fractional box -- reference</title>
<link rel="help" href="https://drafts.csswg.org/css-view-transitions-1/">
<link rel="author" href="mailto:vmpstr@chromium.org">
<style>
.box {
margin: 15px;
background: green;
width: 100.125px;
height: 50.875px;
}
.shift {
position: relative;
left: 0.4px;
}
body { background: lightpink }
</style>
<div class="box"></div>
<div class="box shift"></div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!DOCTYPE html>
<html class=reftest-wait>
<title>View transitions: fractional box with overflow children -- new content</title>
<link rel="help" href="https://drafts.csswg.org/css-view-transitions-1/">
<link rel="author" href="mailto:vmpstr@chromium.org">
<link rel="match" href="fractional-box-with-overflow-children-ref.html">
<!-- subpixel differences are ok in this test (in highdpi), but channel difference
should not be perceptible -->
<meta name=fuzzy content="fractional-box-with-overflow-children-ref.html:0-3;0-100">
<script src="/common/reftest-wait.js"></script>
<style>
.box {
position: relative;
margin: 15px;
background: green;
width: 100.125px;
height: 50.875px;
}
.shift {
left: 0.4px;
}
.child1 {
position: absolute;
left: -2px;
width: 110px;
height: 25px;
background: darkgreen;
}
.child2 {
position: absolute;
top: -3px;
width: 50px;
height: 55px;
background: darkgreen;
}
html::view-transition-group(*) { animation-duration: 300s; }
html::view-transition-new(*) { animation: unset; opacity: 1; }
html::view-transition-old(*) { animation: unset; opacity: 0; }
html::view-transition-group(root) { animation: unset; opacity: 0; }
html::view-transition { background: lightpink; }
</style>
<div class="box" style="view-transition-name: one"><div class="child1"></div><div class="child2"></div></div>
<div class="box shift" style="view-transition-name: two"><div class="child1"></div><div class="child2"></div></div>
<script>
failIfNot(document.startViewTransition, "Missing document.startViewTransition");

async function runTest() {
document.startViewTransition().ready.then(takeScreenshot);
}
onload = () => requestAnimationFrame(() => requestAnimationFrame(runTest));
</script>

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!DOCTYPE html>
<html class=reftest-wait>
<title>View transitions: fractional box with overflow children -- old content</title>
<link rel="help" href="https://drafts.csswg.org/css-view-transitions-1/">
<link rel="author" href="mailto:vmpstr@chromium.org">
<link rel="match" href="fractional-box-with-overflow-children-ref.html">
<!-- subpixel differences are ok in this test (in highdpi), but channel difference
should not be perceptible -->
<meta name=fuzzy content="fractional-box-with-overflow-children-ref.html:0-3;0-100">
<script src="/common/reftest-wait.js"></script>
<style>
.box {
position: relative;
margin: 15px;
background: green;
width: 100.125px;
height: 50.875px;
}
.shift {
left: 0.4px;
}
.child1 {
position: absolute;
left: -2px;
width: 110px;
height: 25px;
background: darkgreen;
}
.child2 {
position: absolute;
top: -3px;
width: 50px;
height: 55px;
background: darkgreen;
}
html::view-transition-group(*) { animation-duration: 300s; }
html::view-transition-new(*) { animation: unset; opacity: 0; }
html::view-transition-old(*) { animation: unset; opacity: 1; }
html::view-transition-group(root) { animation: unset; opacity: 0; }
html::view-transition { background: lightpink; }
</style>
<div class="box" style="view-transition-name: one"><div class="child1"></div><div class="child2"></div></div>
<div class="box shift" style="view-transition-name: two"><div class="child1"></div><div class="child2"></div></div>
<script>
failIfNot(document.startViewTransition, "Missing document.startViewTransition");

async function runTest() {
document.startViewTransition().ready.then(takeScreenshot);
}
onload = () => requestAnimationFrame(() => requestAnimationFrame(runTest));
</script>

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE html>
<title>View transitions: fractional box with overflow children-- reference</title>
<link rel="help" href="https://drafts.csswg.org/css-view-transitions-1/">
<link rel="author" href="mailto:vmpstr@chromium.org">
<style>
.box {
position: relative;
margin: 15px;
background: green;
width: 100.125px;
height: 50.875px;
}
.shift {
left: 0.4px;
}
.child1 {
position: absolute;
left: -2px;
width: 110px;
height: 25px;
background: darkgreen;
}
.child2 {
position: absolute;
top: -3px;
width: 50px;
height: 55px;
background: darkgreen;
}
body { background: lightpink }
</style>
<div class="box"><div class="child1"></div><div class="child2"></div></div>
<div class="box shift"><div class="child1"></div><div class="child2"></div></div>
36 changes: 36 additions & 0 deletions css/css-view-transitions/fractional-box-with-shadow-new.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<html class=reftest-wait>
<title>View transitions: fractional box with shadow -- new content</title>
<link rel="help" href="https://drafts.csswg.org/css-view-transitions-1/">
<link rel="author" href="mailto:vmpstr@chromium.org">
<link rel="match" href="fractional-box-with-shadow-ref.html">
<script src="/common/reftest-wait.js"></script>
<style>
.box {
box-shadow: -2px -3px 0 7px darkgreen;
margin: 15px;
background: green;
width: 100.125px;
height: 50.875px;
}
.shift {
position: relative;
left: 0.4px;
}
html::view-transition-group(*) { animation-duration: 300s; }
html::view-transition-new(*) { animation: unset; opacity: 1; }
html::view-transition-old(*) { animation: unset; opacity: 0; }
html::view-transition-group(root) { animation: unset; opacity: 0; }
html::view-transition { background: lightpink; }
</style>
<div class="box" style="view-transition-name: one"></div>
<div class="box shift" style="view-transition-name: two"></div>
<script>
failIfNot(document.startViewTransition, "Missing document.startViewTransition");

async function runTest() {
document.startViewTransition().ready.then(takeScreenshot);
}
onload = () => requestAnimationFrame(() => requestAnimationFrame(runTest));
</script>

36 changes: 36 additions & 0 deletions css/css-view-transitions/fractional-box-with-shadow-old.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<html class=reftest-wait>
<title>View transitions: fractional box with shadow -- old content</title>
<link rel="help" href="https://drafts.csswg.org/css-view-transitions-1/">
<link rel="author" href="mailto:vmpstr@chromium.org">
<link rel="match" href="fractional-box-with-shadow-ref.html">
<script src="/common/reftest-wait.js"></script>
<style>
.box {
box-shadow: -2px -3px 0 7px darkgreen;
margin: 15px;
background: green;
width: 100.125px;
height: 50.875px;
}
.shift {
position: relative;
left: 0.4px;
}
html::view-transition-group(*) { animation-duration: 300s; }
html::view-transition-new(*) { animation: unset; opacity: 0; }
html::view-transition-old(*) { animation: unset; opacity: 1; }
html::view-transition-group(root) { animation: unset; opacity: 0; }
html::view-transition { background: lightpink; }
</style>
<div class="box" style="view-transition-name: one"></div>
<div class="box shift" style="view-transition-name: two"></div>
<script>
failIfNot(document.startViewTransition, "Missing document.startViewTransition");

async function runTest() {
document.startViewTransition().ready.then(takeScreenshot);
}
onload = () => requestAnimationFrame(() => requestAnimationFrame(runTest));
</script>

20 changes: 20 additions & 0 deletions css/css-view-transitions/fractional-box-with-shadow-ref.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<title>View transitions: fractional box with shadow -- reference</title>
<link rel="help" href="https://drafts.csswg.org/css-view-transitions-1/">
<link rel="author" href="mailto:vmpstr@chromium.org">
<style>
.box {
box-shadow: -2px -3px 0 7px darkgreen;
margin: 15px;
background: green;
width: 100.125px;
height: 50.875px;
}
.shift {
position: relative;
left: 0.4px;
}
body { background: lightpink }
</style>
<div class="box"></div>
<div class="box shift"></div>

0 comments on commit e088e34

Please sign in to comment.