Bug 1877740 [wpt PR 44322] - Implement view-transition-class selector matching, a=testonly

Automatic update from web-platform-tests
Implement view-transition-class selector matching

Selector checker now matches classes from selector to classes
from pseudo-element.

The classes aren't saved on the pseudo-element, but rather in the
ViewTransitionStyleTracker, in the element map.

Bug: 1519997
Change-Id: Iee74bb5d8e6f1ced0edfbcdc1ac9eec32497e97f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5253451
Reviewed-by: Vladimir Levin <vmpstr@chromium.org>
Reviewed-by: Nate Chapin <japhet@chromium.org>
Reviewed-by: Camille Lamy <clamy@chromium.org>
Reviewed-by: Khushal Sagar <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1257975}

--

wpt-commits: 50cdae7b23a8ab23a1ebeacc71d254105c710b15
wpt-pr: 44322
This commit is contained in:
Noam Rosenthal 2024-02-12 08:40:50 +00:00 коммит произвёл moz-wptsync-bot
Родитель 642403bb43
Коммит 463ae403e2
15 изменённых файлов: 636 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,54 @@
<!DOCTYPE html>
<html class=reftest-wait>
<title>View transition classes: entry animation should consider view-transition-class from new state</title>
<link rel="help" href="https://drafts.csswg.org/css-transitions-2/">
<link rel="author" href="mailto:nrosenthal@chromium.org">
<link rel="match" href="pseudo-with-classes-ref.html">
<script src="/common/rendering-utils.js"></script>
<script src="/common/reftest-wait.js"></script>
<style>
div {
width: 100px;
height: 100px;
position: absolute;
}
#target {
background: green;
}
#target.new-state {
view-transition-class: cls;
view-transition-name: target;
}
@keyframes jump {
from { opacity: 1;}
to { opacity: 1;}
}
::view-transition-group(*),
::view-transition-image-pair(*),
::view-transition-new(*) {
animation-name: jump;
animation-timing-function: step-start;
animation-duration: 1s;
}
::view-transition-new(*.cls) {
left: 100px;
}
</style>
<div id=target></div>
<script>
failIfNot(document.startViewTransition, "Missing document.startViewTransition");
window.addEventListener("load", () => {
document.startViewTransition(() => {
document.getElementById("target").classList.add("new-state");
}).ready.then(takeScreenshot);
});
</script>

Просмотреть файл

@ -0,0 +1,54 @@
<!DOCTYPE html>
<html class=reftest-wait>
<title>View transition classes: exit animation should consider view-transition-class from old state</title>
<link rel="help" href="https://drafts.csswg.org/css-transitions-2/">
<link rel="author" href="mailto:nrosenthal@chromium.org">
<link rel="match" href="pseudo-with-classes-ref.html">
<script src="/common/rendering-utils.js"></script>
<script src="/common/reftest-wait.js"></script>
<style>
div {
width: 100px;
height: 100px;
position: absolute;
}
#target {
background: green;
}
#target:not(.new-state) {
view-transition-class: cls;
view-transition-name: target;
}
@keyframes jump {
from { opacity: 1;}
to { opacity: 1;}
}
::view-transition-group(*),
::view-transition-image-pair(*),
::view-transition-old(*) {
animation-name: jump;
animation-timing-function: step-start;
animation-duration: 1s;
}
::view-transition-old(*.cls) {
left: 100px;
}
</style>
<div id=target></div>
<script>
failIfNot(document.startViewTransition, "Missing document.startViewTransition");
window.addEventListener("load", () => {
document.startViewTransition(() => {
document.getElementById("target").classList.add("new-state");
}).ready.then(takeScreenshot);
});
</script>

Просмотреть файл

@ -0,0 +1,41 @@
<!DOCTYPE html>
<html class=reftest-wait>
<title>View transition classes: selector should match ident.class</title>
<link rel="help" href="https://drafts.csswg.org/css-transitions-2/">
<link rel="author" href="mailto:nrosenthal@chromium.org">
<link rel="match" href="pseudo-with-classes-ref.html">
<script src="/common/rendering-utils.js"></script>
<script src="/common/reftest-wait.js"></script>
<style>
div {
width: 100px;
height: 100px;
position: absolute;
}
#target {
background: green;
view-transition-name: target;
view-transition-class: cls;
}
::view-transition-group(*) {
animation-duration: 1s;
}
::view-transition-new(target.cls),
::view-transition-old(target.cls) {
left: 100px;
}
</style>
<div id=target></div>
<script>
failIfNot(document.startViewTransition, "Missing document.startViewTransition");
window.addEventListener("load", () => {
document.startViewTransition().ready.then(takeScreenshot);
});
</script>

Просмотреть файл

@ -0,0 +1,41 @@
<!DOCTYPE html>
<html class=reftest-wait>
<title>View transition classes: selector should match with wildcard and multiple classes</title>
<link rel="help" href="https://drafts.csswg.org/css-transitions-2/">
<link rel="author" href="mailto:nrosenthal@chromium.org">
<link rel="match" href="pseudo-with-classes-ref.html">
<script src="/common/rendering-utils.js"></script>
<script src="/common/reftest-wait.js"></script>
<style>
div {
width: 100px;
height: 100px;
position: absolute;
}
#target {
background: green;
view-transition-name: target;
view-transition-class: cls some-div;
}
::view-transition-group(*) {
animation-duration: 1s;
}
::view-transition-new(*.cls.some-div),
::view-transition-old(*.cls.some-div) {
left: 100px;
}
</style>
<div id=target></div>
<script>
failIfNot(document.startViewTransition, "Missing document.startViewTransition");
window.addEventListener("load", () => {
document.startViewTransition().ready.then(takeScreenshot);
});
</script>

Просмотреть файл

@ -0,0 +1,41 @@
<!DOCTYPE html>
<html class=reftest-wait>
<title>View transition classes: selector should match with multiple classes</title>
<link rel="help" href="https://drafts.csswg.org/css-transitions-2/">
<link rel="author" href="mailto:nrosenthal@chromium.org">
<link rel="match" href="pseudo-with-classes-ref.html">
<script src="/common/rendering-utils.js"></script>
<script src="/common/reftest-wait.js"></script>
<style>
div {
width: 100px;
height: 100px;
position: absolute;
view-transition-class: cls some-div;
}
#target {
background: green;
view-transition-name: target;
}
::view-transition-group(*) {
animation-duration: 1s;
}
::view-transition-new(target.cls.some-div),
::view-transition-old(target.cls.some-div) {
left: 100px;
}
</style>
<div id=target></div>
<script>
failIfNot(document.startViewTransition, "Missing document.startViewTransition");
window.addEventListener("load", () => {
document.startViewTransition().ready.then(takeScreenshot);
});
</script>

Просмотреть файл

@ -0,0 +1,41 @@
<!DOCTYPE html>
<html class=reftest-wait>
<title>View transition classes: selector should match with wildcard</title>
<link rel="help" href="https://drafts.csswg.org/css-transitions-2/">
<link rel="author" href="mailto:nrosenthal@chromium.org">
<link rel="match" href="pseudo-with-classes-ref.html">
<script src="/common/rendering-utils.js"></script>
<script src="/common/reftest-wait.js"></script>
<style>
div {
width: 100px;
height: 100px;
position: absolute;
}
#target {
background: green;
view-transition-name: target;
view-transition-class: cls;
}
::view-transition-group(*) {
animation-duration: 1s;
}
::view-transition-new(*.cls),
::view-transition-old(*.cls) {
left: 100px;
}
</style>
<div id=target></div>
<script>
failIfNot(document.startViewTransition, "Missing document.startViewTransition");
window.addEventListener("load", () => {
document.startViewTransition().ready.then(takeScreenshot);
});
</script>

Просмотреть файл

@ -0,0 +1,46 @@
<!DOCTYPE html>
<html class=reftest-wait>
<title>View transition classes: selector should not match different ident</title>
<link rel="help" href="https://drafts.csswg.org/css-transitions-2/">
<link rel="author" href="mailto:nrosenthal@chromium.org">
<link rel="match" href="pseudo-with-classes-ref.html">
<script src="/common/rendering-utils.js"></script>
<script src="/common/reftest-wait.js"></script>
<style>
div {
width: 100px;
height: 100px;
position: absolute;
}
#target {
background: green;
view-transition-name: target;
view-transition-class: cls;
}
::view-transition-group(*) {
animation-duration: 1s;
}
::view-transition-new(*),
::view-transition-old(*) {
left: 100px;
}
::view-transition-new(target.other),
::view-transition-old(target.other) {
left: 0;
}
</style>
<div id=target></div>
<script>
failIfNot(document.startViewTransition, "Missing document.startViewTransition");
window.addEventListener("load", () => {
document.startViewTransition().ready.then(takeScreenshot);
});
</script>

Просмотреть файл

@ -0,0 +1,45 @@
<!DOCTYPE html>
<html class=reftest-wait>
<title>View transition classes: selector should not match if only some classes match</title>
<link rel="help" href="https://drafts.csswg.org/css-transitions-2/">
<link rel="author" href="mailto:nrosenthal@chromium.org">
<link rel="match" href="pseudo-with-classes-ref.html">
<script src="/common/rendering-utils.js"></script>
<script src="/common/reftest-wait.js"></script>
<style>
div {
width: 100px;
height: 100px;
position: absolute;
}
#target {
background: green;
view-transition-name: target;
view-transition-class: cls;
}
::view-transition-group(*) {
animation-duration: 1s;
}
::view-transition-new(*),
::view-transition-old(*) {
left: 100px;
}
::view-transition-new(target.cls.other),
::view-transition-old(target.cls.other) {
left: 0;
}
</style>
<div id=target></div>
<script>
failIfNot(document.startViewTransition, "Missing document.startViewTransition");
window.addEventListener("load", () => {
document.startViewTransition().ready.then(takeScreenshot);
});
</script>

Просмотреть файл

@ -0,0 +1,46 @@
<!DOCTYPE html>
<html class=reftest-wait>
<title>View transition classes: selector should not match if only some classes match (with *)</title>
<link rel="help" href="https://drafts.csswg.org/css-transitions-2/">
<link rel="author" href="mailto:nrosenthal@chromium.org">
<link rel="match" href="pseudo-with-classes-ref.html">
<script src="/common/rendering-utils.js"></script>
<script src="/common/reftest-wait.js"></script>
<style>
div {
width: 100px;
height: 100px;
position: absolute;
}
#target {
background: green;
view-transition-name: target;
view-transition-class: cls;
}
::view-transition-group(*) {
animation-duration: 1s;
}
::view-transition-new(*),
::view-transition-old(*) {
left: 100px;
}
::view-transition-new(*.other),
::view-transition-old(*.other) {
left: 0;
}
</style>
<div id=target></div>
<script>
failIfNot(document.startViewTransition, "Missing document.startViewTransition");
window.addEventListener("load", () => {
document.startViewTransition().ready.then(takeScreenshot);
});
</script>

Просмотреть файл

@ -0,0 +1,41 @@
<!DOCTYPE html>
<html class=reftest-wait>
<title>View transition classes: selector should match when view-transition-class has multiple idents</title>
<link rel="help" href="https://drafts.csswg.org/css-transitions-2/">
<link rel="author" href="mailto:nrosenthal@chromium.org">
<link rel="match" href="pseudo-with-classes-ref.html">
<script src="/common/rendering-utils.js"></script>
<script src="/common/reftest-wait.js"></script>
<style>
div {
width: 100px;
height: 100px;
position: absolute;
view-transition-class: cls some-div;
}
#target {
background: green;
view-transition-name: target;
}
::view-transition-group(*) {
animation-duration: 1s;
}
::view-transition-new(target.cls),
::view-transition-old(target.cls) {
left: 100px;
}
</style>
<div id=target></div>
<script>
failIfNot(document.startViewTransition, "Missing document.startViewTransition");
window.addEventListener("load", () => {
document.startViewTransition().ready.then(takeScreenshot);
});
</script>

Просмотреть файл

@ -0,0 +1,46 @@
<!DOCTYPE html>
<html class=reftest-wait>
<title>View transition classes: view-transition-class should apply if applied only in new state</title>
<link rel="help" href="https://drafts.csswg.org/css-transitions-2/">
<link rel="author" href="mailto:nrosenthal@chromium.org">
<link rel="match" href="pseudo-with-classes-ref.html">
<script src="/common/rendering-utils.js"></script>
<script src="/common/reftest-wait.js"></script>
<style>
div {
width: 100px;
height: 100px;
position: absolute;
}
#target {
background: green;
view-transition-name: target;
}
#target.new-state {
view-transition-class: cls;
}
::view-transition-group(*) {
animation-duration: 1s;
}
::view-transition-new(*.cls),
::view-transition-old(*.cls) {
left: 100px;
}
</style>
<div id=target></div>
<script>
failIfNot(document.startViewTransition, "Missing document.startViewTransition");
window.addEventListener("load", () => {
document.startViewTransition(() => {
document.getElementById("target").classList.add("new-state");
}).ready.then(takeScreenshot);
});
</script>

Просмотреть файл

@ -0,0 +1,51 @@
<!DOCTYPE html>
<html class=reftest-wait>
<title>View transition classes: view-transition-class should not apply if applied only in old state</title>
<link rel="help" href="https://drafts.csswg.org/css-transitions-2/">
<link rel="author" href="mailto:nrosenthal@chromium.org">
<link rel="match" href="pseudo-with-classes-ref.html">
<script src="/common/rendering-utils.js"></script>
<script src="/common/reftest-wait.js"></script>
<style>
div {
width: 100px;
height: 100px;
position: absolute;
}
#target {
background: green;
view-transition-name: target;
}
#target:not(.new-state) {
view-transition-class: cls;
}
::view-transition-group(*) {
animation-duration: 1s;
}
::view-transition-new(*),
::view-transition-old(*) {
left: 100px;
}
::view-transition-new(*.cls),
::view-transition-old(*.cls) {
left: 0;
}
</style>
<div id=target></div>
<script>
failIfNot(document.startViewTransition, "Missing document.startViewTransition");
window.addEventListener("load", () => {
document.startViewTransition(() => {
document.querySelector("#target").classList.add("new-state");
}).ready.then(takeScreenshot);
});
</script>

Просмотреть файл

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<title>View transitions: reference expectation</title>
<style>
div {
position: relative;
left: 100px;
width: 100px;
height: 100px;
background: green;
}
</style>
<body>
<div></div>
</script>

Просмотреть файл

@ -0,0 +1,37 @@
<!DOCTYPE html>
<html class=reftest-wait>
<title>View transition classes: group selectors should respect classes</title>
<link rel="help" href="https://drafts.csswg.org/css-transitions-2/">
<link rel="author" href="mailto:nrosenthal@chromium.org">
<link rel="match" href="pseudo-with-classes-ref.html">
<script src="/common/rendering-utils.js"></script>
<script src="/common/reftest-wait.js"></script>
<style>
#target {
width: 100px;
height: 100px;
position: absolute;
background: green;
view-transition-name: target;
view-transition-class: cls;
}
:root::view-transition-group(*) {
animation-duration: 1s;
}
:root::view-transition-group(target.cls) {
left: 100px;
}
</style>
<div id=target></div>
<script>
failIfNot(document.startViewTransition, "Missing document.startViewTransition");
window.addEventListener("load", () => {
document.startViewTransition().ready.then(requestAnimationFrame(() => takeScreenshot()));
});
</script>

Просмотреть файл

@ -0,0 +1,37 @@
<!DOCTYPE html>
<html class=reftest-wait>
<title>View transition classes: group selectors should respect classes</title>
<link rel="help" href="https://drafts.csswg.org/css-transitions-2/">
<link rel="author" href="mailto:nrosenthal@chromium.org">
<link rel="match" href="pseudo-with-classes-ref.html">
<script src="/common/rendering-utils.js"></script>
<script src="/common/reftest-wait.js"></script>
<style>
#target {
width: 100px;
height: 100px;
position: absolute;
background: green;
view-transition-name: target;
view-transition-class: cls;
}
::view-transition-group(*) {
animation-duration: 1s;
}
::view-transition-image-pair(target.cls) {
transform: translateX(100px);
}
</style>
<div id=target></div>
<script>
failIfNot(document.startViewTransition, "Missing document.startViewTransition");
window.addEventListener("load", () => {
document.startViewTransition().ready.then(requestAnimationFrame(() => takeScreenshot()));
});
</script>