Skip to content

Commit b87d0b3

Browse files
Steinar H. Gundersonchromium-wpt-export-bot
authored andcommitted
Add a fast path for comparing fields in “transition: all”.
If the author writes “transition: all”, we essentially treat that as a shorthand with 100+ longhands. However, most of the time, almost all of those longhands will end up early-aborting due to the old and new properties being the same. Do that comparison up-front instead; this allows us to skip entire groups if they are shared, and also allows straight-line comparison code instead of going through a large switch every time. Speedometer3 (M1 Pinpoint, LTO but no PGO, significant results at 99% CI only): TodoMVC-Preact-Complex-DOM [ -1.3%, -0.0%] TodoMVC-JavaScript-ES6-Webpack-Complex-DOM [ -1.0%, -0.2%] NewsSite-Next [ -1.6%, -1.1%] NewsSite-Nuxt [ -1.6%, -1.3%] Score [ +0.1%, +0.4%] Bug: 475091954 Change-Id: Iea61d1455265443c131729ae63c20bcbc39deaea Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7493822 Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org> Commit-Queue: Steinar H Gunderson <sesse@chromium.org> Cr-Commit-Position: refs/heads/main@{#1579359}
1 parent dbaf5ee commit b87d0b3

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>transition:all interpolates the same as transition:the-actual-property</title>
5+
<link rel="help" href="https://drafts.csswg.org/css-transitions/#transition-property-property">
6+
7+
<script src="/resources/testharness.js" type="text/javascript"></script>
8+
<script src="/resources/testharnessreport.js" type="text/javascript"></script>
9+
<script src="./support/helper.js" type="text/javascript"></script>
10+
11+
</head>
12+
<body>
13+
<div id="log"></div>
14+
15+
<script>
16+
const cases = [
17+
// Property name, from-value, to-value, transition at 50%
18+
["width", "100px", "200px", "150px"],
19+
["height", "100px", "200px", "150px"],
20+
["z-index", "100", "200", "150"],
21+
["display", "none", "block", "block"],
22+
["margin-left", "100px", "200px", "150px"],
23+
["font-kerning", "normal", "none", "none"],
24+
["font-optical-sizing", "none", "auto", "auto"],
25+
["font-size", "10px", "12px", "11px"],
26+
["font-stretch", "100%", "150%", "125%"],
27+
["font-style", "normal", "oblique 10deg", "oblique 5deg"],
28+
["font-variant-ligatures", "common-ligatures", "none", "none"],
29+
["font-variant-caps", "normal", "small-caps", "small-caps"],
30+
["font-variant-east-asian", "normal", "ruby", "ruby"],
31+
["font-variant-numeric", "normal", "slashed-zero", "slashed-zero"],
32+
["font-weight", "400", "600", "500"],
33+
["text-rendering", "none", "optimizespeed", "optimizespeed"],
34+
["background-attachment", "scroll", "local", "local"],
35+
["background-clip", "border-box", "text", "text"],
36+
["background-image", "auto", "none", "none"],
37+
["background-origin", "border-box", "padding-box", "padding-box"],
38+
["background-position-x", "100px", "200px", "150px"],
39+
["background-position-y", "100px", "200px", "150px"],
40+
["background-repeat", "repeat-x", "repeat-y", "repeat-y"],
41+
["background-size", "auto", "cover", "cover"],
42+
["border-image-outset", "10px", "20px", "15px"],
43+
["border-image-repeat", "stretch", "repeat", "repeat"],
44+
["border-image-slice", "100", "200", "150"],
45+
["border-image-width", "100px", "200px", "150px"],
46+
["border-left-color", "black", "white", "rgb(128, 128, 128)"],
47+
["counter-increment", "example-counter 10", "example-counter 20", "example-counter 20"],
48+
["vertical-align", "10px", "20px", "15px"],
49+
["vertical-align", "baseline", "super", "super"],
50+
];
51+
52+
for (const c of cases) {
53+
let propertyName = c[0];
54+
let fromValue = c[1];
55+
let toValue = c[2];
56+
let midValue = c[3];
57+
promise_test(async t => {
58+
// Start a 100s transition 50% of the way through.
59+
const div = addDiv(t, {
60+
style: `transition: ${propertyName} 100s -50s linear allow-discrete; ${propertyName}: ${fromValue}`,
61+
});
62+
getComputedStyle(div)[propertyName];
63+
div.style[propertyName] = toValue;
64+
assert_equals(getComputedStyle(div)[propertyName],
65+
midValue,
66+
'Transition should be initially 50% complete');
67+
68+
// Now do the same with transition:all.
69+
const div2 = addDiv(t, {
70+
style: `transition: all 100s -50s linear allow-discrete; ${propertyName}: ${fromValue}`,
71+
});
72+
getComputedStyle(div2)[propertyName];
73+
div2.style[propertyName] = toValue;
74+
assert_equals(getComputedStyle(div2)[propertyName],
75+
midValue,
76+
'Transition should be initially 50% complete, with transition:all');
77+
});
78+
}
79+
</script>
80+
81+
</body>
82+
</html>

0 commit comments

Comments
 (0)