Skip to main content

sk_css/
catalog.rs

1//! What CSS Skathi supports, property by property: the one list `CSS.supports`, `@supports` and the
2//! docs answer from. Each entry's sample values run through the mapper in the tests below, so an entry
3//! that disagrees with what the mapper does fails the build.
4
5use crate::mapper::{accepts_declaration, verdict, Verdict};
6
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum Status {
9    /// Applied, every sample value.
10    Supported,
11    /// Applied, with the limitation in the note; `refused` lists values that are not.
12    Partial,
13    /// Accepted without an advisory and without effect, which is right for this engine.
14    Ignored,
15    /// Not applied; a declaration prints an advisory.
16    Unsupported,
17    /// A vendor-prefixed spelling dropped without an advisory, as Chromium drops one it does not know.
18    Dropped,
19}
20
21impl Status {
22    pub fn as_str(self) -> &'static str {
23        match self {
24            Status::Supported => "supported",
25            Status::Partial => "partial",
26            Status::Ignored => "ignored",
27            Status::Unsupported => "unsupported",
28            Status::Dropped => "dropped",
29        }
30    }
31}
32
33#[derive(Clone, Copy, Debug, PartialEq, Eq)]
34pub enum Platform {
35    Windows,
36    MacOs,
37    Linux,
38}
39
40#[derive(Debug)]
41pub struct Entry {
42    pub name: &'static str,
43    pub status: Status,
44    /// Values the engine applies.
45    pub applied: &'static [&'static str],
46    /// Values it parses and does not honour; `CSS.supports` answers false for each.
47    pub refused: &'static [&'static str],
48    pub note: &'static str,
49    /// Where it works, when not on every platform.
50    pub platforms: &'static [Platform],
51}
52
53const fn e(
54    name: &'static str,
55    status: Status,
56    applied: &'static [&'static str],
57    refused: &'static [&'static str],
58    note: &'static str,
59) -> Entry {
60    Entry {
61        name,
62        status,
63        applied,
64        refused,
65        note,
66        platforms: &[],
67    }
68}
69
70use Status::*;
71
72const SIZING_KEYWORDS: &[&str] = &["min-content", "max-content", "fit-content", "stretch"];
73const SIZING_NOTE: &str = "Intrinsic sizing keywords are ignored; use flex or grid sizing";
74
75#[rustfmt::skip]
76pub const CATALOG: &[Entry] = &[
77    e("accent-color", Supported, &["auto", "red"], &[], ""),
78    e("align-content", Partial, &["center", "space-between"], &["normal", "baseline"], "`normal` and baseline alignment are not mapped"),
79    e("align-items", Partial, &["center", "baseline"], &["normal"], "`normal` is not mapped; `stretch` is the default"),
80    e("align-self", Partial, &["center", "stretch"], &["auto", "normal"], "`auto` and `normal` cannot undo an earlier value"),
81    e("anchor-name", Unsupported, &[], &["--a"], ""),
82    e("animation", Supported, &["spin 1s linear infinite", "none"], &[], ""),
83    e("animation-composition", Unsupported, &[], &["add"], ""),
84    e("animation-delay", Supported, &["1s", "-1s"], &[], ""),
85    e("animation-direction", Supported, &["normal", "alternate"], &[], ""),
86    e("animation-duration", Supported, &["1s"], &[], ""),
87    e("animation-fill-mode", Supported, &["none", "both"], &[], ""),
88    e("animation-iteration-count", Supported, &["1", "infinite"], &[], ""),
89    e("animation-name", Supported, &["none", "spin"], &[], ""),
90    e("animation-play-state", Supported, &["running", "paused"], &[], ""),
91    e("animation-range", Unsupported, &[], &["normal"], ""),
92    e("animation-range-end", Unsupported, &[], &["normal"], ""),
93    e("animation-range-start", Unsupported, &[], &["normal"], ""),
94    e("animation-timeline", Unsupported, &[], &["none"], ""),
95    e("animation-timing-function", Partial, &["ease", "cubic-bezier(0.34, 1.56, 0.64, 1)"], &[], "`linear()` easing is not parsed"),
96    e("app-region", Supported, &["drag", "no-drag"], &[], "A window drag region, as in Electron"),
97    e("appearance", Supported, &["none", "auto"], &[], ""),
98    e("aspect-ratio", Supported, &["1 / 1", "1.5", "auto", "auto 16 / 9"], &[], ""),
99    e("backdrop-filter", Partial, &["none", "blur(2px)"], &["grayscale(1)", "saturate(180%)", "brightness(2)", "contrast(2)", "sepia(1)", "hue-rotate(10deg)", "invert(1)", "opacity(0.5)", "drop-shadow(0 0 1px red)"], "Only `blur()`"),
100    e("backface-visibility", Unsupported, &[], &["hidden"], ""),
101    e("background", Supported, &["red", "linear-gradient(red, blue)"], &[], ""),
102    e("background-attachment", Ignored, &["scroll", "fixed"], &[], "A background scrolls with its element"),
103    e("background-blend-mode", Unsupported, &[], &["multiply"], ""),
104    e("background-clip", Partial, &["text"], &["border-box", "content-box"], "Only `text`; the background fills the padding box"),
105    e("background-color", Supported, &["red", "transparent"], &[], ""),
106    e("background-image", Supported, &["none", "url(a.png)"], &[], ""),
107    e("background-origin", Ignored, &["border-box", "content-box"], &[], ""),
108    e("background-position", Supported, &["center", "10px 20%"], &[], ""),
109    e("background-position-x", Supported, &["center", "10px"], &[], ""),
110    e("background-position-y", Supported, &["center", "10px"], &[], ""),
111    e("background-repeat", Supported, &["repeat", "no-repeat"], &[], ""),
112    e("background-size", Supported, &["cover", "10px 20px"], &[], ""),
113    e("block-size", Partial, &["auto", "10px", "calc-size(auto, size)"], SIZING_KEYWORDS, SIZING_NOTE),
114    e("border", Supported, &["1px solid red", "none"], &[], ""),
115    e("border-block", Unsupported, &[], &["1px solid red"], ""),
116    e("border-block-color", Unsupported, &[], &["red"], ""),
117    e("border-block-end", Unsupported, &[], &["1px solid red"], ""),
118    e("border-block-end-color", Unsupported, &[], &["red"], ""),
119    e("border-block-end-style", Unsupported, &[], &["solid"], ""),
120    e("border-block-end-width", Unsupported, &[], &["1px"], ""),
121    e("border-block-start", Unsupported, &[], &["1px solid red"], ""),
122    e("border-block-start-color", Unsupported, &[], &["red"], ""),
123    e("border-block-start-style", Unsupported, &[], &["solid"], ""),
124    e("border-block-start-width", Unsupported, &[], &["1px"], ""),
125    e("border-block-style", Unsupported, &[], &["solid"], ""),
126    e("border-block-width", Unsupported, &[], &["1px"], ""),
127    e("border-bottom", Supported, &["1px solid red", "none"], &[], ""),
128    e("border-bottom-color", Supported, &["red", "transparent"], &[], ""),
129    e("border-bottom-left-radius", Supported, &["4px", "50%"], &[], ""),
130    e("border-bottom-right-radius", Supported, &["4px", "50%"], &[], ""),
131    e("border-bottom-style", Supported, &["none", "solid"], &[], ""),
132    e("border-bottom-width", Supported, &["0", "2px"], &[], ""),
133    e("border-collapse", Unsupported, &[], &["collapse"], "Tables lay out as blocks"),
134    e("border-color", Supported, &["red", "transparent"], &[], ""),
135    e("border-end-end-radius", Unsupported, &[], &["4px"], ""),
136    e("border-end-start-radius", Unsupported, &[], &["4px"], ""),
137    e("border-image", Unsupported, &[], &["url(a.png) 10"], ""),
138    e("border-image-outset", Unsupported, &[], &["1px"], ""),
139    e("border-image-repeat", Unsupported, &[], &["stretch"], ""),
140    e("border-image-slice", Unsupported, &[], &["10"], ""),
141    e("border-image-source", Unsupported, &[], &["url(a.png)"], ""),
142    e("border-image-width", Unsupported, &[], &["1px"], ""),
143    e("border-inline", Unsupported, &[], &["1px solid red"], ""),
144    e("border-inline-color", Unsupported, &[], &["red"], ""),
145    e("border-inline-end", Unsupported, &[], &["1px solid red"], ""),
146    e("border-inline-end-color", Unsupported, &[], &["red"], ""),
147    e("border-inline-end-style", Unsupported, &[], &["solid"], ""),
148    e("border-inline-end-width", Unsupported, &[], &["1px"], ""),
149    e("border-inline-start", Unsupported, &[], &["1px solid red"], ""),
150    e("border-inline-start-color", Unsupported, &[], &["red"], ""),
151    e("border-inline-start-style", Unsupported, &[], &["solid"], ""),
152    e("border-inline-start-width", Unsupported, &[], &["1px"], ""),
153    e("border-inline-style", Unsupported, &[], &["solid"], ""),
154    e("border-inline-width", Unsupported, &[], &["1px"], ""),
155    e("border-left", Supported, &["1px solid red", "none"], &[], ""),
156    e("border-left-color", Supported, &["red", "transparent"], &[], ""),
157    e("border-left-style", Supported, &["none", "solid"], &[], ""),
158    e("border-left-width", Supported, &["0", "2px"], &[], ""),
159    e("border-radius", Supported, &["4px", "50%"], &[], ""),
160    e("border-right", Supported, &["1px solid red", "none"], &[], ""),
161    e("border-right-color", Supported, &["red", "transparent"], &[], ""),
162    e("border-right-style", Supported, &["none", "solid"], &[], ""),
163    e("border-right-width", Supported, &["0", "2px"], &[], ""),
164    e("border-spacing", Unsupported, &[], &["2px"], "Tables lay out as blocks"),
165    e("border-start-end-radius", Unsupported, &[], &["4px"], ""),
166    e("border-start-start-radius", Unsupported, &[], &["4px"], ""),
167    e("border-style", Supported, &["none", "solid"], &[], ""),
168    e("border-top", Supported, &["1px solid red", "none"], &[], ""),
169    e("border-top-color", Supported, &["red", "transparent"], &[], ""),
170    e("border-top-left-radius", Supported, &["4px", "50%"], &[], ""),
171    e("border-top-right-radius", Supported, &["4px", "50%"], &[], ""),
172    e("border-top-style", Supported, &["none", "solid"], &[], ""),
173    e("border-top-width", Supported, &["0", "2px"], &[], ""),
174    e("border-width", Supported, &["0", "2px"], &[], ""),
175    e("bottom", Supported, &["auto", "10px"], &[], ""),
176    e("box-align", Unsupported, &[], &["center"], ""),
177    e("box-decoration-break", Unsupported, &[], &["clone"], ""),
178    e("box-direction", Unsupported, &[], &["normal"], ""),
179    e("box-flex", Unsupported, &[], &["1"], ""),
180    e("box-flex-group", Unsupported, &[], &["1"], ""),
181    e("box-lines", Unsupported, &[], &["single"], ""),
182    e("box-ordinal-group", Unsupported, &[], &["1"], ""),
183    e("box-orient", Unsupported, &[], &["vertical"], ""),
184    e("box-pack", Unsupported, &[], &["center"], ""),
185    e("box-shadow", Partial, &["none", "0 2px 4px red"], &["1px 2px"], "A shadow coloured `currentColor` or a system colour is dropped"),
186    e("box-sizing", Partial, &["border-box"], &["content-box"], "Every box is `border-box`"),
187    e("caption-side", Unsupported, &[], &["bottom"], "Tables lay out as blocks"),
188    e("caret", Unsupported, &[], &["auto"], ""),
189    e("caret-color", Unsupported, &[], &["red"], ""),
190    e("caret-shape", Unsupported, &[], &["block"], ""),
191    e("clear", Unsupported, &[], &["both"], "Use flex or grid"),
192    e("clip", Partial, &["rect(0, 0, 0, 0)"], &["rect(0, 10px, 10px, 0)"], "Only the empty rect of the visually-hidden idiom"),
193    e("clip-path", Partial, &["circle(50%)", "path(\"M0 0L10 10\")"], &["url(#c)"], "Basic shapes and `path()`; `url()` is not applied"),
194    e("clip-rule", Unsupported, &[], &["nonzero"], ""),
195    e("color", Supported, &["red", "oklch(70% 0.1 200)", "light-dark(black, white)"], &[], ""),
196    e("color-interpolation", Unsupported, &[], &["auto"], ""),
197    e("color-interpolation-filters", Unsupported, &[], &["auto"], ""),
198    e("color-rendering", Unsupported, &[], &["auto"], ""),
199    e("color-scheme", Supported, &["normal", "light dark", "only dark"], &[], ""),
200    e("column-count", Unsupported, &[], &["2"], ""),
201    e("column-gap", Supported, &["0", "10px"], &[], ""),
202    e("column-rule", Unsupported, &[], &["1px solid red"], ""),
203    e("column-width", Unsupported, &[], &["100px"], ""),
204    e("column-span", Unsupported, &[], &["all"], ""),
205    e("columns", Unsupported, &[], &["2"], ""),
206    e("contain", Supported, &["none", "paint", "size", "inline-size", "strict"], &[], ""),
207    e("contain-intrinsic-size", Unsupported, &[], &["100px"], ""),
208    e("container", Supported, &["card / inline-size", "none"], &[], ""),
209    e("container-name", Supported, &["card", "card sidebar", "none"], &[], ""),
210    e("container-type", Partial, &["normal", "inline-size", "size"], &["scroll-state"], "Scroll-state container queries are not supported"),
211    e("content", Partial, &["none", "\"a\""], &["counter(n)", "attr(data-x)"], "A literal string; counters and `attr()` generate nothing"),
212    e("content-visibility", Unsupported, &[], &["auto"], ""),
213    e("corner", Unsupported, &[], &["8px bevel"], "Use `border-radius` and `corner-shape`"),
214    e("corner-block-end-shape", Supported, &["bevel", "round scoop"], &[], ""),
215    e("corner-block-start-shape", Supported, &["bevel", "round scoop"], &[], ""),
216    e("corner-bottom-left", Unsupported, &[], &["8px bevel"], "Use `border-bottom-left-radius` and `corner-bottom-left-shape`"),
217    e("corner-bottom-left-shape", Supported, &["bevel", "superellipse(-2)"], &[], ""),
218    e("corner-bottom-right", Unsupported, &[], &["8px bevel"], "Use `border-bottom-right-radius` and `corner-bottom-right-shape`"),
219    e("corner-bottom-right-shape", Supported, &["bevel", "superellipse(-2)"], &[], ""),
220    e("corner-bottom-shape", Supported, &["bevel", "round scoop"], &[], ""),
221    e("corner-end-end-shape", Supported, &["bevel", "squircle"], &[], ""),
222    e("corner-end-start-shape", Supported, &["bevel", "squircle"], &[], ""),
223    e("corner-inline-end-shape", Supported, &["bevel", "round scoop"], &[], ""),
224    e("corner-inline-start-shape", Supported, &["bevel", "round scoop"], &[], ""),
225    e("corner-left-shape", Supported, &["bevel", "round scoop"], &[], ""),
226    e("corner-right-shape", Supported, &["bevel", "round scoop"], &[], ""),
227    e("corner-shape", Supported, &["round", "squircle", "bevel scoop", "notch square round superellipse(0.5)", "superellipse(infinity)"], &[], ""),
228    e("corner-start-end-shape", Supported, &["bevel", "squircle"], &[], ""),
229    e("corner-start-start-shape", Supported, &["bevel", "squircle"], &[], ""),
230    e("corner-top-left", Unsupported, &[], &["8px bevel"], "Use `border-top-left-radius` and `corner-top-left-shape`"),
231    e("corner-top-left-shape", Supported, &["bevel", "superellipse(-2)"], &[], ""),
232    e("corner-top-right", Unsupported, &[], &["8px bevel"], "Use `border-top-right-radius` and `corner-top-right-shape`"),
233    e("corner-top-right-shape", Supported, &["bevel", "superellipse(-2)"], &[], ""),
234    e("corner-top-shape", Supported, &["bevel", "round scoop"], &[], ""),
235    e("counter-increment", Unsupported, &[], &["n"], ""),
236    e("counter-reset", Unsupported, &[], &["n"], ""),
237    e("counter-set", Unsupported, &[], &["n 1"], ""),
238    e("cursor", Partial, &["pointer", "text", "wait", "none", "url(hand.png) 4 4, pointer"], &[], "A `url()` image is not loaded: the fallback keyword shows. A keyword the OS has no cursor for shows the arrow"),
239    e("cx", Unsupported, &[], &["10px"], ""),
240    e("cy", Unsupported, &[], &["10px"], ""),
241    e("d", Unsupported, &[], &["path(\"M0 0L10 10\")"], ""),
242    e("direction", Unsupported, &[], &["rtl"], "Left-to-right text only"),
243    e("display", Partial, &["flex", "grid"], &[], "No line boxes; `contents` and the table values lay out as `block`"),
244    e("dominant-baseline", Unsupported, &[], &["middle"], ""),
245    e("dynamic-range-limit", Partial, &["standard", "no-limit", "dynamic-range-limit-mix(standard 30%, no-limit 70%)"], &[], "Computed and inherited, and reported to `<sk-surface>` producers; windows draw SDR, so nothing on screen is limited yet"),
246    e("empty-cells", Unsupported, &[], &["hide"], "Tables lay out as blocks"),
247    e("field-sizing", Unsupported, &[], &["content"], ""),
248    e("fill", Supported, &["none", "red"], &[], ""),
249    e("fill-opacity", Supported, &["0.5"], &[], ""),
250    e("fill-rule", Supported, &["nonzero", "evenodd"], &[], ""),
251    e("filter", Partial, &["blur(2px)", "url(#f)"], &["grayscale(1)", "url(a.svg#f)", "sepia(1)", "brightness(2)", "contrast(2)", "saturate(2)", "hue-rotate(10deg)", "invert(1)", "opacity(0.5)"], "One `blur()`, one `drop-shadow()` and one same-document SVG `url(#id)`; the colour functions are not applied"),
252    e("flex", Supported, &["1", "none"], &[], ""),
253    e("flex-align", Unsupported, &[], &["center"], ""),
254    e("flex-basis", Supported, &["auto", "10px", "calc-size(content, size * 2)"], &[], ""),
255    e("flex-direction", Supported, &["row", "column"], &[], ""),
256    e("flex-flow", Supported, &["row wrap", "column", "wrap-reverse"], &[], ""),
257    e("flex-grow", Supported, &["0", "1"], &[], ""),
258    e("flex-item-align", Unsupported, &[], &["center"], ""),
259    e("flex-line-pack", Unsupported, &[], &["center"], ""),
260    e("flex-negative", Unsupported, &[], &["1"], ""),
261    e("flex-order", Unsupported, &[], &["1"], ""),
262    e("flex-pack", Unsupported, &[], &["center"], ""),
263    e("flex-positive", Unsupported, &[], &["1"], ""),
264    e("flex-preferred-size", Unsupported, &[], &["auto"], ""),
265    e("flex-shrink", Supported, &["0", "1"], &[], ""),
266    e("flex-wrap", Supported, &["wrap", "nowrap"], &[], ""),
267    e("float", Unsupported, &[], &["left"], "Use flex or grid"),
268    e("flood-color", Unsupported, &[], &["red"], ""),
269    e("font", Unsupported, &[], &["12px serif"], "Use the longhands"),
270    e("font-family", Supported, &["serif", "\"Segoe UI\", sans-serif"], &[], ""),
271    e("font-feature-settings", Supported, &["\"tnum\"", "normal"], &[], ""),
272    e("font-kerning", Supported, &["none", "auto"], &[], ""),
273    e("font-optical-sizing", Partial, &["auto"], &["none"], "Always `auto`"),
274    e("font-palette", Unsupported, &[], &["--p"], ""),
275    e("font-size", Supported, &["12px", "larger"], &[], ""),
276    e("font-size-adjust", Unsupported, &[], &["0.5"], ""),
277    e("font-stretch", Unsupported, &[], &["condensed"], ""),
278    e("font-style", Supported, &["normal", "italic"], &[], ""),
279    e("font-synthesis", Unsupported, &[], &["none"], ""),
280    e("font-variant", Unsupported, &[], &["small-caps"], "`font-feature-settings: \"smcp\"` where the font has it"),
281    e("font-variant-caps", Unsupported, &[], &["small-caps"], "`font-feature-settings: \"smcp\"` where the font has it"),
282    e("font-variant-east-asian", Unsupported, &[], &["ruby"], ""),
283    e("font-variant-ligatures", Supported, &["none", "normal"], &[], ""),
284    e("font-variant-numeric", Supported, &["tabular-nums", "normal"], &[], ""),
285    e("font-variation-settings", Partial, &["normal"], &["\"wght\" 400"], "`font-weight` and `font-style` reach the matching axes"),
286    e("font-weight", Supported, &["bold", "450"], &[], ""),
287    e("font-width", Unsupported, &[], &["condensed"], ""),
288    e("forced-color-adjust", Unsupported, &[], &["none"], ""),
289    e("gap", Supported, &["0", "10px 20px"], &[], ""),
290    e("grid", Unsupported, &[], &["auto / 1fr 1fr"], "Use the longhands"),
291    e("grid-area", Partial, &["auto", "1 / 2"], &["a"], "Named areas are not mapped"),
292    e("grid-auto-columns", Supported, &["auto", "1fr"], &[], ""),
293    e("grid-auto-flow", Supported, &["row", "column"], &[], ""),
294    e("grid-auto-rows", Supported, &["auto", "1fr"], &[], ""),
295    e("grid-column", Partial, &["auto", "1 / 3"], &["a"], "Named lines are not mapped"),
296    e("grid-column-end", Partial, &["auto", "span 2"], &["a"], "Named lines are not mapped"),
297    e("grid-column-start", Partial, &["auto", "2"], &["a"], "Named lines are not mapped"),
298    e("grid-row", Partial, &["auto", "1 / 3"], &["a"], "Named lines are not mapped"),
299    e("grid-row-end", Partial, &["auto", "span 2"], &["a"], "Named lines are not mapped"),
300    e("grid-row-start", Partial, &["auto", "2"], &["a"], "Named lines are not mapped"),
301    e("grid-template", Unsupported, &[], &["none"], "Use `grid-template-columns` / `-rows`"),
302    e("grid-template-areas", Unsupported, &[], &["\"a b\""], "Place items by line number"),
303    e("grid-template-columns", Partial, &["1fr 1fr", "repeat(3, 10px)"], &["none"], "`none` cannot undo an earlier track list"),
304    e("grid-template-rows", Partial, &["1fr 1fr", "repeat(3, 10px)"], &["none"], "`none` cannot undo an earlier track list"),
305    e("height", Partial, &["auto", "10px", "calc-size(auto, size + 10px)"], SIZING_KEYWORDS, SIZING_NOTE),
306    e("hyphenate-character", Unsupported, &[], &["\"-\""], ""),
307    e("hyphens", Partial, &["none", "manual"], &["auto"], "`auto` breaks only at soft hyphens"),
308    e("image-orientation", Unsupported, &[], &["from-image"], ""),
309    e("image-rendering", Unsupported, &[], &["auto"], ""),
310    e("initial-letter", Unsupported, &[], &["2"], ""),
311    e("inline-size", Partial, &["auto", "10px", "calc-size(fit-content, size)"], SIZING_KEYWORDS, SIZING_NOTE),
312    e("inset", Supported, &["auto", "0"], &[], ""),
313    e("inset-block", Supported, &["auto", "0"], &[], ""),
314    e("inset-block-end", Supported, &["auto", "0"], &[], ""),
315    e("inset-block-start", Supported, &["auto", "0"], &[], ""),
316    e("inset-inline", Supported, &["auto", "0"], &[], ""),
317    e("inset-inline-end", Supported, &["auto", "0"], &[], ""),
318    e("inset-inline-start", Supported, &["auto", "0"], &[], ""),
319    e("interactivity", Unsupported, &[], &["inert"], ""),
320    e("interpolate-size", Supported, &["numeric-only", "allow-keywords"], &[], ""),
321    e("isolation", Supported, &["auto", "isolate"], &[], ""),
322    e("justify-content", Partial, &["center", "space-between"], &["normal", "left"], "`normal`, `left` and `right` are not mapped"),
323    e("justify-items", Supported, &["normal", "center"], &[], ""),
324    e("justify-self", Supported, &["auto", "center"], &[], ""),
325    e("left", Supported, &["auto", "10px"], &[], ""),
326    e("letter-spacing", Supported, &["normal", "1px"], &[], ""),
327    e("lighting-color", Unsupported, &[], &["red"], ""),
328    e("line-break", Unsupported, &[], &["strict"], ""),
329    e("line-clamp", Partial, &["2"], &["none"], "`none` cannot undo an earlier clamp"),
330    e("line-height", Supported, &["normal", "1.5"], &[], ""),
331    e("list-style", Supported, &["none", "disc inside"], &[], ""),
332    e("list-style-image", Partial, &["none"], &["url(a.png)"], "Marker images are not drawn"),
333    e("list-style-position", Supported, &["inside", "outside"], &[], ""),
334    e("list-style-type", Partial, &["disc", "decimal"], &["hebrew"], "disc, circle, square, decimal, decimal-leading-zero, the alpha and roman styles"),
335    e("margin", Supported, &["auto", "10px 20px"], &[], ""),
336    e("margin-block", Supported, &["auto", "10px"], &[], ""),
337    e("margin-block-end", Supported, &["auto", "10px"], &[], ""),
338    e("margin-block-start", Supported, &["auto", "10px"], &[], ""),
339    e("margin-bottom", Supported, &["auto", "10px"], &[], ""),
340    e("margin-inline", Supported, &["auto", "10px"], &[], ""),
341    e("margin-inline-end", Supported, &["auto", "10px"], &[], ""),
342    e("margin-inline-start", Supported, &["auto", "10px"], &[], ""),
343    e("margin-left", Supported, &["auto", "10px"], &[], ""),
344    e("margin-right", Supported, &["auto", "10px"], &[], ""),
345    e("margin-top", Supported, &["auto", "10px"], &[], ""),
346    e("marker", Unsupported, &[], &["none"], ""),
347    e("marker-end", Unsupported, &[], &["none"], ""),
348    e("marker-mid", Unsupported, &[], &["none"], ""),
349    e("marker-side", Unsupported, &[], &["match-self"], ""),
350    e("marker-start", Unsupported, &[], &["none"], ""),
351    e("mask", Partial, &["none", "url(a.png) center / contain no-repeat"], &[], "`url(#id)` references to an SVG `<mask>` are not applied; fixed-position descendants escape the mask"),
352    e("mask-border", Unsupported, &[], &["none"], ""),
353    e("mask-border-mode", Unsupported, &[], &["luminance"], ""),
354    e("mask-border-outset", Unsupported, &[], &["0"], ""),
355    e("mask-border-repeat", Unsupported, &[], &["stretch"], ""),
356    e("mask-border-slice", Unsupported, &[], &["0"], ""),
357    e("mask-border-source", Unsupported, &[], &["none"], ""),
358    e("mask-border-width", Unsupported, &[], &["auto"], ""),
359    e("mask-box-image", Unsupported, &[], &["none"], ""),
360    e("mask-box-image-outset", Unsupported, &[], &["none"], ""),
361    e("mask-box-image-repeat", Unsupported, &[], &["none"], ""),
362    e("mask-box-image-slice", Unsupported, &[], &["none"], ""),
363    e("mask-box-image-source", Unsupported, &[], &["none"], ""),
364    e("mask-box-image-width", Unsupported, &[], &["none"], ""),
365    e("mask-clip", Partial, &["border-box"], &["content-box"], "Only `border-box`"),
366    e("mask-composite", Supported, &["add"], &[], ""),
367    e("mask-image", Partial, &["none", "url(a.png)", "linear-gradient(#000, transparent)"], &[], "`url(#id)` references to an SVG `<mask>` are not applied"),
368    e("mask-mode", Partial, &["alpha", "luminance"], &[], "`match-source` is treated as `alpha`; one mode for all layers"),
369    e("mask-origin", Partial, &["border-box"], &["content-box"], "Only `border-box`"),
370    e("mask-position", Supported, &["center", "10px 20%"], &[], ""),
371    e("mask-position-x", Supported, &["center", "10px"], &[], ""),
372    e("mask-position-y", Supported, &["center", "20%"], &[], ""),
373    e("mask-repeat", Supported, &["repeat", "no-repeat"], &[], ""),
374    e("mask-size", Supported, &["auto", "contain", "16px 16px"], &[], ""),
375    e("mask-source-type", Unsupported, &[], &["none"], ""),
376    e("mask-type", Unsupported, &[], &["luminance"], ""),
377    e("max-block-size", Partial, &["none", "10px", "calc-size(fit-content, size)"], SIZING_KEYWORDS, SIZING_NOTE),
378    e("max-height", Partial, &["none", "10px", "calc-size(fit-content, size * .5)"], SIZING_KEYWORDS, SIZING_NOTE),
379    e("max-inline-size", Partial, &["none", "10px", "calc-size(max-content, size)"], SIZING_KEYWORDS, SIZING_NOTE),
380    e("max-width", Partial, &["none", "10px", "calc-size(max-content, size)"], SIZING_KEYWORDS, SIZING_NOTE),
381    e("min-block-size", Partial, &["auto", "10px", "calc-size(min-content, size)"], SIZING_KEYWORDS, SIZING_NOTE),
382    e("min-height", Partial, &["auto", "10px", "calc-size(min-content, size)"], SIZING_KEYWORDS, SIZING_NOTE),
383    e("min-inline-size", Partial, &["auto", "10px", "calc-size(min-content, size)"], SIZING_KEYWORDS, SIZING_NOTE),
384    e("min-width", Partial, &["auto", "10px", "calc-size(min-content, size)"], SIZING_KEYWORDS, SIZING_NOTE),
385    e("mix-blend-mode", Unsupported, &[], &["multiply"], ""),
386    e("-moz-osx-font-smoothing", Dropped, &[], &["grayscale"], ""),
387    e("object-fit", Supported, &["cover", "contain"], &[], ""),
388    e("object-position", Supported, &["center", "10px 20%"], &[], ""),
389    e("offset-path", Unsupported, &[], &["none"], ""),
390    e("opacity", Supported, &["0.5", "50%"], &[], ""),
391    e("order", Supported, &["0", "-1"], &[], ""),
392    e("outline", Supported, &["none", "2px solid red"], &[], ""),
393    e("outline-color", Supported, &["red", "transparent"], &[], ""),
394    e("outline-offset", Supported, &["0", "2px"], &[], ""),
395    e("outline-style", Supported, &["none", "solid"], &[], ""),
396    e("outline-width", Supported, &["0", "2px"], &[], ""),
397    e("overflow", Supported, &["auto", "hidden"], &[], ""),
398    e("overflow-clip-margin", Unsupported, &[], &["10px"], ""),
399    e("overflow-wrap", Supported, &["normal", "break-word"], &[], ""),
400    e("overflow-x", Supported, &["auto", "hidden"], &[], ""),
401    e("overflow-y", Supported, &["auto", "hidden"], &[], ""),
402    e("overscroll-behavior", Supported, &["none", "contain"], &[], ""),
403    e("overscroll-behavior-block", Supported, &["none", "auto"], &[], ""),
404    e("overscroll-behavior-inline", Supported, &["none", "auto"], &[], ""),
405    e("overscroll-behavior-x", Supported, &["none", "auto"], &[], ""),
406    e("overscroll-behavior-y", Supported, &["none", "auto"], &[], ""),
407    e("padding", Supported, &["0", "10px 20px"], &[], ""),
408    e("padding-block", Supported, &["0", "10px"], &[], ""),
409    e("padding-block-end", Supported, &["0", "10px"], &[], ""),
410    e("padding-block-start", Supported, &["0", "10px"], &[], ""),
411    e("padding-bottom", Supported, &["0", "10px"], &[], ""),
412    e("padding-inline", Supported, &["0", "10px"], &[], ""),
413    e("padding-inline-end", Supported, &["0", "10px"], &[], ""),
414    e("padding-inline-start", Supported, &["0", "10px"], &[], ""),
415    e("padding-left", Supported, &["0", "10px"], &[], ""),
416    e("padding-right", Supported, &["0", "10px"], &[], ""),
417    e("padding-top", Supported, &["0", "10px"], &[], ""),
418    e("paint-order", Unsupported, &[], &["stroke"], ""),
419    e("perspective", Unsupported, &[], &["100px"], ""),
420    e("perspective-origin", Unsupported, &[], &["center"], ""),
421    e("place-content", Unsupported, &[], &["center"], "Use the `align-*` / `justify-*` longhands"),
422    e("place-items", Supported, &["center", "start end"], &[], ""),
423    e("place-self", Unsupported, &[], &["center"], "Use the `align-*` / `justify-*` longhands"),
424    e("pointer-events", Partial, &["none", "auto"], &["visiblePainted"], "Only `none` and `auto`"),
425    e("position", Supported, &["absolute", "sticky"], &[], ""),
426    e("position-anchor", Unsupported, &[], &["--a"], ""),
427    e("print-color-adjust", Unsupported, &[], &["exact"], ""),
428    e("quotes", Unsupported, &[], &["none"], ""),
429    e("r", Unsupported, &[], &["5px"], ""),
430    e("resize", Partial, &["none"], &["both"], "There is no user-resize affordance"),
431    e("right", Supported, &["auto", "10px"], &[], ""),
432    e("rotate", Unsupported, &[], &["45deg"], "Use `transform`"),
433    e("row-gap", Supported, &["0", "10px"], &[], ""),
434    e("rx", Unsupported, &[], &["5px"], ""),
435    e("ry", Unsupported, &[], &["5px"], ""),
436    e("scale", Unsupported, &[], &["2"], "Use `transform`"),
437    e("scroll-behavior", Supported, &["auto", "smooth"], &[], ""),
438    e("scroll-margin", Supported, &["0", "10px"], &[], ""),
439    e("scroll-margin-block", Supported, &["0", "10px"], &[], ""),
440    e("scroll-margin-block-end", Supported, &["0", "10px"], &[], ""),
441    e("scroll-margin-block-start", Supported, &["0", "10px"], &[], ""),
442    e("scroll-margin-bottom", Supported, &["0", "10px"], &[], ""),
443    e("scroll-margin-inline", Supported, &["0", "10px"], &[], ""),
444    e("scroll-margin-inline-end", Supported, &["0", "10px"], &[], ""),
445    e("scroll-margin-inline-start", Supported, &["0", "10px"], &[], ""),
446    e("scroll-margin-left", Supported, &["0", "10px"], &[], ""),
447    e("scroll-margin-right", Supported, &["0", "10px"], &[], ""),
448    e("scroll-margin-top", Supported, &["0", "10px"], &[], ""),
449    e("scroll-padding", Supported, &["auto", "10px", "10%"], &[], ""),
450    e("scroll-padding-block", Supported, &["auto", "10px", "10%"], &[], ""),
451    e("scroll-padding-block-end", Supported, &["auto", "10px", "10%"], &[], ""),
452    e("scroll-padding-block-start", Supported, &["auto", "10px", "10%"], &[], ""),
453    e("scroll-padding-bottom", Supported, &["auto", "10px", "10%"], &[], ""),
454    e("scroll-padding-inline", Supported, &["auto", "10px", "10%"], &[], ""),
455    e("scroll-padding-inline-end", Supported, &["auto", "10px", "10%"], &[], ""),
456    e("scroll-padding-inline-start", Supported, &["auto", "10px", "10%"], &[], ""),
457    e("scroll-padding-left", Supported, &["auto", "10px", "10%"], &[], ""),
458    e("scroll-padding-right", Supported, &["auto", "10px", "10%"], &[], ""),
459    e("scroll-padding-top", Supported, &["auto", "10px", "10%"], &[], ""),
460    e("scroll-snap-align", Supported, &["start", "none", "start end"], &[], ""),
461    e("scroll-snap-stop", Supported, &["normal", "always"], &[], ""),
462    e("scroll-snap-type", Supported, &["none", "x mandatory", "both proximity"], &[], ""),
463    e("scrollbar-color", Supported, &["auto", "red blue"], &[], ""),
464    e("scrollbar-gutter", Unsupported, &[], &["stable"], ""),
465    e("scrollbar-width", Supported, &["none", "thin"], &[], ""),
466    e("shape-rendering", Supported, &["auto", "crispEdges"], &[], ""),
467    e("stop-color", Unsupported, &[], &["red"], ""),
468    e("stop-opacity", Unsupported, &[], &["0.5"], ""),
469    e("stroke", Supported, &["none", "red"], &[], ""),
470    e("stroke-dasharray", Supported, &["none", "4 2"], &[], ""),
471    e("stroke-dashoffset", Supported, &["0", "2"], &[], ""),
472    e("stroke-linecap", Supported, &["round", "butt"], &[], ""),
473    e("stroke-linejoin", Supported, &["round", "bevel"], &[], ""),
474    e("stroke-miterlimit", Supported, &["4"], &[], ""),
475    e("stroke-opacity", Supported, &["0.5"], &[], ""),
476    e("stroke-width", Supported, &["0", "2"], &[], ""),
477    e("tab-size", Ignored, &["4"], &[], "Whitespace is collapsed, so a tab is one space"),
478    e("table-layout", Unsupported, &[], &["fixed"], "Tables lay out as blocks"),
479    e("text-align", Supported, &["center", "start"], &[], ""),
480    e("text-align-last", Unsupported, &[], &["center"], ""),
481    e("text-anchor", Unsupported, &[], &["middle"], ""),
482    e("text-decoration", Partial, &["underline", "line-through red"], &["none"], "`none` cannot undo an earlier line; use `text-decoration-line: none`"),
483    e("text-decoration-color", Supported, &["red", "transparent"], &[], ""),
484    e("text-decoration-line", Supported, &["none", "underline"], &[], ""),
485    e("text-decoration-skip-ink", Partial, &["none"], &["auto"], "The underline is one unbroken line"),
486    e("text-decoration-style", Supported, &["solid", "wavy"], &[], ""),
487    e("text-decoration-thickness", Supported, &["1px", "2px"], &[], ""),
488    e("text-emphasis", Unsupported, &[], &["dot"], ""),
489    e("text-emphasis-color", Unsupported, &[], &["red"], ""),
490    e("text-emphasis-position", Unsupported, &[], &["under"], ""),
491    e("text-emphasis-style", Unsupported, &[], &["dot"], ""),
492    e("text-indent", Partial, &["0"], &["10px"], "There is no first line to indent; use `padding-left`"),
493    e("text-justify", Unsupported, &[], &["inter-word"], ""),
494    e("text-orientation", Unsupported, &[], &["upright"], ""),
495    e("text-overflow", Partial, &["ellipsis"], &["clip"], "`clip` cannot undo an earlier ellipsis"),
496    e("text-rendering", Unsupported, &[], &["optimizeLegibility"], ""),
497    e("text-shadow", Supported, &["none", "1px 1px 2px red"], &[], ""),
498    e("text-size-adjust", Ignored, &["none", "100%"], &[], ""),
499    e("text-transform", Supported, &["none", "uppercase"], &[], ""),
500    e("text-underline-offset", Supported, &["auto", "2px"], &[], ""),
501    e("text-underline-position", Unsupported, &[], &["under"], "The underline is one unbroken line"),
502    e("text-wrap", Unsupported, &[], &["balance"], ""),
503    e("text-wrap-mode", Unsupported, &[], &["nowrap"], ""),
504    e("text-wrap-style", Unsupported, &[], &["balance"], ""),
505    e("top", Supported, &["auto", "10px"], &[], ""),
506    e("touch-action", Ignored, &["none", "manipulation"], &[], ""),
507    e("transform", Partial, &["none", "translate(1px) rotate(10deg)"], &["rotateX(10deg)", "rotateY(10deg)", "translateZ(1px)", "perspective(100px)", "rotate3d(1, 1, 0, 45deg)", "matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)"], "2D only: rotation about the X or Y axis, depth and `perspective()` are not applied"),
508    e("transform-box", Unsupported, &[], &["border-box"], ""),
509    e("transform-origin", Supported, &["center", "0 0"], &[], ""),
510    e("transition", Partial, &["opacity 1s ease", "none"], &[], "`linear()` easing is not parsed"),
511    e("transition-behavior", Unsupported, &[], &["allow-discrete"], ""),
512    e("transition-delay", Supported, &["1s", "-1s"], &[], ""),
513    e("transition-duration", Supported, &["1s"], &[], ""),
514    e("transition-property", Supported, &["none", "opacity"], &[], ""),
515    e("transition-timing-function", Partial, &["ease", "linear"], &[], "`linear()` easing is not parsed"),
516    e("translate", Unsupported, &[], &["10px"], "Use `transform`"),
517    e("unicode-bidi", Unsupported, &[], &["isolate"], "Left-to-right text only"),
518    e("user-select", Partial, &["none", "text"], &["contain"], "`contain` selects like `text`"),
519    e("vector-effect", Unsupported, &[], &["non-scaling-stroke"], ""),
520    e("vertical-align", Partial, &["baseline"], &["middle"], "Use `align-items` / `align-self` on a flex parent"),
521    e("view-transition-class", Supported, &["card", "a b"], &[], ""),
522    e("view-transition-group", Unsupported, &[], &["normal"], ""),
523    e("view-transition-name", Supported, &["card", "none"], &[], ""),
524    e("visibility", Supported, &["hidden", "visible"], &[], ""),
525    e("-webkit-app-region", Supported, &["drag", "no-drag"], &[], ""),
526    e("-webkit-box-reflect", Unsupported, &[], &["below"], ""),
527    e("-webkit-font-smoothing", Dropped, &[], &["antialiased"], ""),
528    e("-webkit-line-clamp", Partial, &["2"], &["none"], "`none` cannot undo an earlier clamp"),
529    e("-webkit-mask-composite", Supported, &["source-over"], &[], ""),
530    e("-webkit-tap-highlight-color", Dropped, &[], &["transparent"], ""),
531    e("-webkit-text-fill-color", Supported, &["red", "transparent"], &[], ""),
532    e("-webkit-text-stroke", Unsupported, &[], &["1px red"], ""),
533    e("-webkit-text-stroke-color", Unsupported, &[], &["red"], ""),
534    e("-webkit-text-stroke-width", Unsupported, &[], &["1px"], ""),
535    e("-webkit-touch-callout", Dropped, &[], &["none"], ""),
536    e("white-space", Supported, &["normal", "nowrap"], &[], ""),
537    e("white-space-collapse", Unsupported, &[], &["preserve"], ""),
538    e("width", Partial, &["auto", "10px", "calc-size(fit-content, size + 2em)"], SIZING_KEYWORDS, SIZING_NOTE),
539    e("will-change", Ignored, &["transform", "auto"], &[], ""),
540    e("window-drag", Supported, &["drag", "no-drag"], &[], ""),
541    e("word-break", Supported, &["normal", "break-all"], &[], ""),
542    e("word-spacing", Supported, &["normal", "2px"], &[], ""),
543    e("word-wrap", Supported, &["normal", "break-word"], &[], ""),
544    e("writing-mode", Unsupported, &[], &["vertical-rl"], "Horizontal text only"),
545    e("x", Unsupported, &[], &["10px"], ""),
546    e("y", Unsupported, &[], &["10px"], ""),
547    e("z-index", Supported, &["auto", "10"], &[], ""),
548    e("zoom", Unsupported, &[], &["1.5"], ""),
549];
550
551pub fn entry(name: &str) -> Option<&'static Entry> {
552    let name = name.trim();
553    CATALOG.iter().find(|e| e.name.eq_ignore_ascii_case(name))
554}
555
556/// `CSS.supports(property, value)`: the mapper applies the declaration, and the catalog does not list
557/// the value as one it ignores (`width: fit-content` is accepted and changes nothing).
558pub fn supports(name: &str, value: &str) -> bool {
559    if !accepts_declaration(name, value) {
560        return false;
561    }
562    let name = name.trim();
563    let name = name
564        .strip_prefix("-webkit-")
565        .filter(|base| {
566            crate::prefix::WEBKIT_APPLIED
567                .iter()
568                .any(|n| n.eq_ignore_ascii_case(base))
569        })
570        .unwrap_or(name);
571    let value = value.split_whitespace().collect::<Vec<_>>().join(" ");
572    entry(name).is_none_or(|e| !e.refused.iter().any(|r| r.eq_ignore_ascii_case(&value)))
573}
574
575/// Is the `-webkit-` spelling read as this property?
576pub fn webkit_applied(name: &str) -> bool {
577    crate::prefix::WEBKIT_APPLIED
578        .iter()
579        .any(|n| n.eq_ignore_ascii_case(name))
580}
581
582fn json_string(out: &mut String, s: &str) {
583    out.push('"');
584    for c in s.chars() {
585        match c {
586            '"' => out.push_str("\\\""),
587            '\\' => out.push_str("\\\\"),
588            '\n' => out.push_str("\\n"),
589            c if (c as u32) < 0x20 => out.push_str(&format!("\\u{:04x}", c as u32)),
590            c => out.push(c),
591        }
592    }
593    out.push('"');
594}
595
596fn json_list(out: &mut String, items: impl IntoIterator<Item = impl AsRef<str>>) {
597    out.push('[');
598    for (i, s) in items.into_iter().enumerate() {
599        if i > 0 {
600            out.push_str(", ");
601        }
602        json_string(out, s.as_ref());
603    }
604    out.push(']');
605}
606
607/// The catalog as JSON, one object per property, with the advisory the engine prints for the first
608/// refused value.
609pub fn to_json() -> String {
610    let mut out = String::from("[\n");
611    for (i, e) in CATALOG.iter().enumerate() {
612        out.push_str("  {\"name\": ");
613        json_string(&mut out, e.name);
614        out.push_str(", \"status\": ");
615        json_string(&mut out, e.status.as_str());
616        out.push_str(", \"note\": ");
617        json_string(&mut out, e.note);
618        out.push_str(", \"applied\": ");
619        json_list(&mut out, e.applied);
620        out.push_str(", \"refused\": ");
621        json_list(&mut out, e.refused);
622        out.push_str(", \"webkit\": ");
623        out.push_str(if webkit_applied(e.name) {
624            "true"
625        } else {
626            "false"
627        });
628        out.push_str(", \"platforms\": ");
629        json_list(
630            &mut out,
631            e.platforms.iter().map(|p| match p {
632                Platform::Windows => "windows",
633                Platform::MacOs => "macos",
634                Platform::Linux => "linux",
635            }),
636        );
637        out.push_str(", \"advisory\": ");
638        match e.refused.first().map(|v| verdict(e.name, v)) {
639            Some(Verdict::Rejected(msg)) => json_string(&mut out, &msg),
640            _ => out.push_str("null"),
641        }
642        out.push('}');
643        if i + 1 < CATALOG.len() {
644            out.push(',');
645        }
646        out.push('\n');
647    }
648    out.push(']');
649    out
650}
651
652#[cfg(test)]
653mod tests {
654    use super::*;
655
656    /// The anti-drift guard: every entry's samples get the verdict its status promises.
657    #[test]
658    fn the_catalog_agrees_with_the_mapper() {
659        let mut wrong = Vec::new();
660        for e in CATALOG {
661            let mut check = |value: &str, ok: bool, want: &str| {
662                if !ok {
663                    wrong.push(format!(
664                        "{}: {value} is {:?}, the catalog says {want} ({:?})",
665                        e.name,
666                        verdict(e.name, value),
667                        e.status
668                    ));
669                }
670            };
671            for v in e.applied {
672                let got = verdict(e.name, v);
673                match e.status {
674                    Supported | Partial => check(
675                        v,
676                        matches!(got, Verdict::Applied | Verdict::Inert) && supports(e.name, v),
677                        "applied",
678                    ),
679                    Ignored => check(v, got == Verdict::Inert && supports(e.name, v), "inert"),
680                    Unsupported | Dropped => check(v, false, "nothing applied"),
681                }
682            }
683            for v in e.refused {
684                let got = verdict(e.name, v);
685                match e.status {
686                    Partial => check(
687                        v,
688                        matches!(got, Verdict::Rejected(_) | Verdict::Inert)
689                            && !supports(e.name, v),
690                        "refused",
691                    ),
692                    Unsupported => check(v, matches!(got, Verdict::Rejected(_)), "rejected"),
693                    Dropped => check(v, got == Verdict::Dropped, "dropped"),
694                    Supported | Ignored => check(v, false, "no refused values"),
695                }
696            }
697            let shape = match e.status {
698                Supported => {
699                    !e.applied.is_empty()
700                        && e.applied
701                            .iter()
702                            .any(|v| verdict(e.name, v) == Verdict::Applied)
703                }
704                Partial => !e.applied.is_empty() && !e.note.is_empty(),
705                Ignored => !e.applied.is_empty(),
706                Unsupported | Dropped => e.applied.is_empty() && !e.refused.is_empty(),
707            };
708            if !shape {
709                wrong.push(format!("{}: samples do not fit {:?}", e.name, e.status));
710            }
711        }
712        assert!(wrong.is_empty(), "\n{}", wrong.join("\n"));
713    }
714
715    #[test]
716    fn every_property_the_mapper_names_is_catalogued() {
717        let src = include_str!("mapper.rs");
718        let mut missing = Vec::new();
719        for (at, _) in src.match_indices("CustomPropertyName::Unknown(name)") {
720            let guard = &src[at..];
721            let guard = &guard[..guard.find("=>").unwrap_or(0)];
722            for literal in guard.split('"').skip(1).step_by(2) {
723                if entry(literal).is_none() {
724                    missing.push(literal.to_string());
725                }
726            }
727        }
728        for name in crate::prefix::WEBKIT_APPLIED {
729            let known = lightningcss::properties::PropertyId::from(*name);
730            let unknown = matches!(known, lightningcss::properties::PropertyId::Custom(_));
731            if entry(name).is_none() && entry(&format!("-webkit-{name}")).is_none() && unknown {
732                missing.push(format!("-webkit-{name}"));
733            }
734        }
735        let mut names: Vec<_> = CATALOG.iter().map(|e| e.name).collect();
736        names.sort_unstable();
737        names.dedup();
738        assert_eq!(names.len(), CATALOG.len(), "a property is listed twice");
739        assert!(missing.is_empty(), "not in the catalog: {missing:?}");
740    }
741
742    #[test]
743    fn supports_answers_what_the_engine_applies() {
744        assert!(supports("order", "2"));
745        assert!(supports("object-position", "center top"));
746        assert!(supports("contain", "paint"));
747        assert!(supports("scroll-behavior", "smooth"));
748        assert!(supports("filter", "blur(4px)"));
749        assert!(supports("box-shadow", "none"));
750        assert!(supports("clip-path", "path(\"M0 0L10 10Z\")"));
751        assert!(supports("width", "var(--w)"));
752        assert!(supports("--anything", "at all"));
753        assert!(supports("-webkit-user-select", "none"));
754        assert!(!supports("width", "fit-content"));
755        assert!(!supports("WIDTH", " Fit-Content "));
756        assert!(!supports("animation-timing-function", "linear(0, 1)"));
757        assert!(!supports("transition", "opacity 1s linear(0, 1)"));
758        assert!(!supports("float", "left"));
759        assert!(!supports("width", "red"));
760        assert!(!supports("-moz-appearance", "none"));
761        assert!(!supports("display", "flex; color: red"));
762    }
763
764    #[test]
765    fn condition_text_is_evaluated_as_at_supports_is() {
766        use crate::supports_condition_text as cond;
767        assert!(cond("order: 2"));
768        assert!(cond("(display: flex) and (not (float: left))"));
769        assert!(cond(
770            "(-webkit-backdrop-filter: blur(2px)) or (backdrop-filter: blur(2px))"
771        ));
772        assert!(!cond("(width: fit-content)"));
773        assert!(!cond("(-moz-appearance: none)"));
774        assert!(!cond("display: flex; color: red"));
775        assert!(!cond(""));
776    }
777
778    /// `sk check` reads this copy; regenerate it with
779    /// `cargo run -p sk-css --example css-catalog > packages/cli/check/css-catalog.json`.
780    #[test]
781    fn the_cli_copy_of_the_catalog_is_current() {
782        let path = concat!(
783            env!("CARGO_MANIFEST_DIR"),
784            "/../../packages/cli/check/css-catalog.json"
785        );
786        let Ok(copy) = std::fs::read_to_string(path) else {
787            return;
788        };
789        assert!(
790            copy.replace("\r\n", "\n").trim_end() == to_json(),
791            "packages/cli/check/css-catalog.json is stale: cargo run -p sk-css --example css-catalog > packages/cli/check/css-catalog.json"
792        );
793    }
794
795    #[test]
796    fn the_json_dump_is_one_object_per_property() {
797        let parsed: serde_json::Value = serde_json::from_str(&to_json()).expect("valid JSON");
798        let list = parsed.as_array().unwrap();
799        assert_eq!(list.len(), CATALOG.len());
800        let width = list.iter().find(|p| p["name"] == "width").unwrap();
801        assert_eq!(width["status"], "partial");
802        assert_eq!(width["refused"][0], "min-content");
803        let float = list.iter().find(|p| p["name"] == "float").unwrap();
804        assert!(float["advisory"].as_str().is_some_and(|a| !a.is_empty()));
805    }
806}