You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c4f1e17
Browse filesBrowse the repository at this point in the historyBrowse files
fix(css): keep a color whose channels are read back as written (#21923)
* fix(css): keep a color whose channels are read back as written
A relative color reads its origin's channels off as the `r` / `l` / `h`
keywords, and `color-mix()` interpolates its arguments the way a gradient
does, so converting one through an 8-bit hex moves the color the engine
computes rather than only its spelling — `lch(from lch(50% 20 30) l c h)`
computes `lch(50.0415 19.8356 30.1479)` once the origin is a hex.
The gradient guard becomes one flag over every such context, keyed on the
`from` the arguments open with so an unknown function guards its origin
too, and an `rgb()` whose channels are not already bytes is declined there
as well.
* chore(deps): bump the test262 and wpt submodules
Same bumps as #21917 — the wpt corpus they bring is what the printer fix
in the previous commit is held to.
* fix(css): read an escaped name before deciding a color is an operand
`\66 rom` names the relative-color keyword, and an escaped `color-mix` or
gradient name names those, so the guard compared a spelling the source need
not use. The escaped gradient name was already folding before this branch.
Copy file name to clipboardExpand all lines: test/configCases/css/minimize-colors/__snapshots__/ConfigCacheTest.snap
+12Lines changed: 12 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -61,5 +61,17 @@ Array [
61
61
"/*! declined without a space too: a stop outside sRGB is handed back as written
62
62
rather than computed, so converting one moves what the CSSOM reports */.g03{background-image:linear-gradient(90deg,red,lch(502030))}",
63
63
"/*! the legacy sRGB forms all compute to \`rgb(…)\` however they are spelled */.g04{background-image:linear-gradient(90deg,red,#010203)}",
64
+
"/*! declined: a relative color reads its origin's channels off as the \`r\` / \`l\` /
65
+
\`h\` keywords, so a hex — 8 bits a channel — is a different origin */.r01{color:lch(fromlch(50%2030) lch)}.r02{color:rgb(fromlch(50%2030) rgb)}.r03{color:hsl(fromhsl(12050%50%) hsl)}.r04{color:rgb(fromrgb(50%50%50%) rgb)}",
66
+
"/*! declined whatever the function is named: \`from\` says the argument after it is
67
+
read the same way, which is the only thing an unknown function states */.r05{color:alpha(fromlch(50%2030) /.5)}",
68
+
"/*! ...and the keyword is the first argument however the call is spaced */.r06{color:lch(fromlch(50%2030) lch)}",
69
+
"/*! an origin already written as bytes converts exactly, so it still folds — one
70
+
out of range with it, since the engine clamps that to the same byte */.r07{color:rgb(from #781e28rgb)}.r08{color:rgb(fromredrgb)}",
71
+
"/*! ...and \`from\` heading a function's name is not the keyword */.r09{color:from(#976c67)}",
72
+
"/*! declined: \`color-mix()\` interpolates its arguments the way a gradient does */.m01{color:color-mix(inoklab,lch(50%2030),red)}.m02{color:color-mix(insrgb,hsl(12050%50%),red)}",
73
+
"/*! the legacy sRGB forms fold there too, where their channels are already bytes */.m03{color:color-mix(insrgb,#010203,red)}",
74
+
"/*! declined however the keyword is spelled: \`\\\\66 rom\` names it too, as an
75
+
escaped \`color-mix\` or gradient name names those */.r10{color:rgb(fromrgb(50%50%50%) rgb)}.m04{color:color-\\\\6dix(inoklab,lch(50%2030),red)}.g05{background-image:linear-\\\\67radient(lch(502030),red)}",
Copy file name to clipboardExpand all lines: test/configCases/css/minimize-colors/__snapshots__/ConfigTest.snap
+12Lines changed: 12 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -61,5 +61,17 @@ Array [
61
61
"/*! declined without a space too: a stop outside sRGB is handed back as written
62
62
rather than computed, so converting one moves what the CSSOM reports */.g03{background-image:linear-gradient(90deg,red,lch(502030))}",
63
63
"/*! the legacy sRGB forms all compute to \`rgb(…)\` however they are spelled */.g04{background-image:linear-gradient(90deg,red,#010203)}",
64
+
"/*! declined: a relative color reads its origin's channels off as the \`r\` / \`l\` /
65
+
\`h\` keywords, so a hex — 8 bits a channel — is a different origin */.r01{color:lch(fromlch(50%2030) lch)}.r02{color:rgb(fromlch(50%2030) rgb)}.r03{color:hsl(fromhsl(12050%50%) hsl)}.r04{color:rgb(fromrgb(50%50%50%) rgb)}",
66
+
"/*! declined whatever the function is named: \`from\` says the argument after it is
67
+
read the same way, which is the only thing an unknown function states */.r05{color:alpha(fromlch(50%2030) /.5)}",
68
+
"/*! ...and the keyword is the first argument however the call is spaced */.r06{color:lch(fromlch(50%2030) lch)}",
69
+
"/*! an origin already written as bytes converts exactly, so it still folds — one
70
+
out of range with it, since the engine clamps that to the same byte */.r07{color:rgb(from #781e28rgb)}.r08{color:rgb(fromredrgb)}",
71
+
"/*! ...and \`from\` heading a function's name is not the keyword */.r09{color:from(#976c67)}",
72
+
"/*! declined: \`color-mix()\` interpolates its arguments the way a gradient does */.m01{color:color-mix(inoklab,lch(50%2030),red)}.m02{color:color-mix(insrgb,hsl(12050%50%),red)}",
73
+
"/*! the legacy sRGB forms fold there too, where their channels are already bytes */.m03{color:color-mix(insrgb,#010203,red)}",
74
+
"/*! declined however the keyword is spelled: \`\\\\66 rom\` names it too, as an
75
+
escaped \`color-mix\` or gradient name names those */.r10{color:rgb(fromrgb(50%50%50%) rgb)}.m04{color:color-\\\\6dix(inoklab,lch(50%2030),red)}.g05{background-image:linear-\\\\67radient(lch(502030),red)}",
0 commit comments