LibWeb/CSS: Parse @font-face descriptors as style values

CSSFontFaceRule now stores its values as a CSSFontFaceDescriptors, with
a ParsedFontFace produced on request. This is exposed via the `style`
attribute, so we pass a lot of tests that try to read values from
that.

We have one test regression, which we passed by mistake before: The test
wanted to ensure we don't allow `@font-face` nested inside other rules.
We passed it just because we discarded any `@font-face` without a
`font-family`. What we're supposed to do is 1) keep at-rules with
missing required descriptors and just not use them, and 2) reject
certain ones when nested.

We may want to cache the ParsedFontFace in the future, but I didn't here
because 1) it's called rarely, and 2) that would mean knowing to
invalidate it when the CSSFontFaceDescriptors changes, which isn't
obvious to me right now.
This commit is contained in:
Sam Atkins 2025-04-03 12:05:49 +01:00
commit f87b454fa9
Notes: github-actions[bot] 2025-04-04 09:41:41 +00:00
12 changed files with 118 additions and 378 deletions

View file

@ -2,10 +2,11 @@ Harness status: OK
Found 6 tests
6 Fail
2 Pass
4 Fail
Fail Check that size-adjust: 100% is valid
Fail Check that size-adjust: 0% is valid
Fail Check that size-adjust: 110% is valid
Fail Check that size-adjust: 100000000000% is valid
Fail Check that size-adjust: -100% is invalid
Fail Check that size-adjust: -1% is invalid
Pass Check that size-adjust: -100% is invalid
Pass Check that size-adjust: -1% is invalid

View file

@ -2,33 +2,34 @@ Harness status: OK
Found 35 tests
35 Fail
Fail Check that src: url("foo.ttf") is valid
Fail Check that src: url("foo.ttf"), url("bar.ttf") is valid
Fail Check that src: url("foo.ttf") format() is invalid
Fail Check that src: url("foo.ttf") dummy() is invalid
Fail Check that src: url("foo.ttf") format("woff") dummy() is invalid
Fail Check that src: url("foo.ttf") dummy() format("woff") is invalid
21 Pass
14 Fail
Pass Check that src: url("foo.ttf") is valid
Pass Check that src: url("foo.ttf"), url("bar.ttf") is valid
Pass Check that src: url("foo.ttf") format() is invalid
Pass Check that src: url("foo.ttf") dummy() is invalid
Pass Check that src: url("foo.ttf") format("woff") dummy() is invalid
Pass Check that src: url("foo.ttf") dummy() format("woff") is invalid
Fail Check that src: url("foo.ttf") format("collection") is valid
Fail Check that src: url("foo.ttf") format("opentype") is valid
Fail Check that src: url("foo.ttf") format("truetype") is valid
Fail Check that src: url("foo.ttf") format("woff") is valid
Fail Check that src: url("foo.ttf") format("woff2") is valid
Pass Check that src: url("foo.ttf") format("opentype") is valid
Pass Check that src: url("foo.ttf") format("truetype") is valid
Pass Check that src: url("foo.ttf") format("woff") is valid
Pass Check that src: url("foo.ttf") format("woff2") is valid
Fail Check that src: url("foo.ttf") format("opentype", "truetype") is invalid
Fail Check that src: url("foo.ttf") format(collection) is valid
Fail Check that src: url("foo.ttf") format(opentype) is valid
Fail Check that src: url("foo.ttf") format(truetype) is valid
Fail Check that src: url("foo.ttf") format(woff) is valid
Fail Check that src: url("foo.ttf") format(woff2) is valid
Pass Check that src: url("foo.ttf") format(opentype) is valid
Pass Check that src: url("foo.ttf") format(truetype) is valid
Pass Check that src: url("foo.ttf") format(woff) is valid
Pass Check that src: url("foo.ttf") format(woff2) is valid
Fail Check that src: url("foo.ttf") format(opentype, truetype) is invalid
Fail Check that src: url("foo.ttf") format(opentype truetype) is invalid
Fail Check that src: url("foo.ttf") format(auto) is invalid
Fail Check that src: url("foo.ttf") format(default) is invalid
Fail Check that src: url("foo.ttf") format(inherit) is invalid
Fail Check that src: url("foo.ttf") format(initial) is invalid
Fail Check that src: url("foo.ttf") format(none) is invalid
Fail Check that src: url("foo.ttf") format(normal) is invalid
Fail Check that src: url("foo.ttf") format(xyzzy) is invalid
Pass Check that src: url("foo.ttf") format(auto) is invalid
Pass Check that src: url("foo.ttf") format(default) is invalid
Pass Check that src: url("foo.ttf") format(inherit) is invalid
Pass Check that src: url("foo.ttf") format(initial) is invalid
Pass Check that src: url("foo.ttf") format(none) is invalid
Pass Check that src: url("foo.ttf") format(normal) is invalid
Pass Check that src: url("foo.ttf") format(xyzzy) is invalid
Fail Check that src: url("foo.ttf") format("embedded-opentype"), url("bar.html") is valid
Fail Check that src: url("foo.ttf") format(embedded-opentype), url("bar.html") is valid
Fail Check that src: url("foo.ttf") format("svg"), url("bar.html") is valid

View file

@ -2,7 +2,8 @@ Harness status: OK
Found 17 tests
17 Fail
5 Pass
12 Fail
Fail Check that src: local(inherit), url(foo.ttf) is valid
Fail Check that src: local("myfont"), local(unset) is valid
Fail Check that src: local(), url(foo.ttf) is valid
@ -15,8 +16,8 @@ Fail Check that src: url(foo.ttf) tech(color-COLRv0) otherfunc(othervalue), url(
Fail Check that src: url(foo.ttf), url(something.ttf) format(broken) is valid
Fail Check that src: /* an empty component */, url(foo.ttf) is valid
Fail Check that src: local(""), url(foo.ttf), unparseable-garbage, local("another font name") is valid
Fail Check that src: local(), local(initial) is invalid
Fail Check that src: local("textfont") format(opentype), local("emoji") tech(color-COLRv0) is invalid
Fail Check that src: local(), /*empty*/, url(should be quoted.ttf), junk is invalid
Fail Check that src: url(foo.ttf) format(unknown), url(bar.ttf) tech(broken) is invalid
Fail Check that src: url(foo.ttf) tech(color-COLRv0) otherfunc(othervalue), junk is invalid
Pass Check that src: local(), local(initial) is invalid
Pass Check that src: local("textfont") format(opentype), local("emoji") tech(color-COLRv0) is invalid
Pass Check that src: local(), /*empty*/, url(should be quoted.ttf), junk is invalid
Pass Check that src: url(foo.ttf) format(unknown), url(bar.ttf) tech(broken) is invalid
Pass Check that src: url(foo.ttf) tech(color-COLRv0) otherfunc(othervalue), junk is invalid

View file

@ -2,13 +2,14 @@ Harness status: OK
Found 18 tests
18 Fail
Fail Check that src: local(A) dummy() is invalid
Fail Check that src: dummy() local(A) is invalid
Fail Check that src: local( A ) is valid
Fail Check that src: local(A B) is valid
Fail Check that src: local(A B) is valid
Fail Check that src: local( A B ) is valid
6 Pass
12 Fail
Pass Check that src: local(A) dummy() is invalid
Pass Check that src: dummy() local(A) is invalid
Pass Check that src: local( A ) is valid
Pass Check that src: local(A B) is valid
Pass Check that src: local(A B) is valid
Pass Check that src: local( A B ) is valid
Fail Check that src: local(default) is invalid
Fail Check that src: local(inherit) is invalid
Fail Check that src: local(revert) is invalid

View file

@ -2,9 +2,10 @@ Harness status: OK
Found 39 tests
39 Fail
Fail Check that src: url("foo.ttf") is valid
Fail Check that src: url("foo.ttf") tech() is invalid
22 Pass
17 Fail
Pass Check that src: url("foo.ttf") is valid
Pass Check that src: url("foo.ttf") tech() is invalid
Fail Check that src: url("foo.ttf") tech(features-opentype) is valid
Fail Check that src: url("foo.ttf") tech(features-aat) is valid
Fail Check that src: url("foo.ttf") tech(color-COLRv0) is valid
@ -13,32 +14,32 @@ Fail Check that src: url("foo.ttf") tech(color-sbix) is valid
Fail Check that src: url("foo.ttf") tech(color-CBDT) is valid
Fail Check that src: url("foo.ttf") tech(variations) is valid
Fail Check that src: url("foo.ttf") tech(palettes) is valid
Fail Check that src: url("foo.ttf") tech("features-opentype") is invalid
Fail Check that src: url("foo.ttf") tech("color-COLRv0") is invalid
Fail Check that src: url("foo.ttf") tech("variations") is invalid
Pass Check that src: url("foo.ttf") tech("features-opentype") is invalid
Pass Check that src: url("foo.ttf") tech("color-COLRv0") is invalid
Pass Check that src: url("foo.ttf") tech("variations") is invalid
Fail Check that src: url("foo.ttf") tech(features-opentype, color-COLRv0, variations, palettes) is valid
Fail Check that src: url("foo.ttf") tech(features-opentype color-COLRv0 variations palettes) is invalid
Fail Check that src: url("foo.ttf") tech(feature-opentype) is invalid
Fail Check that src: url("foo.ttf") tech(feature-aat) is invalid
Fail Check that src: url("foo.ttf") tech(feature-graphite) is invalid
Fail Check that src: url("foo.ttf") tech(auto) is invalid
Fail Check that src: url("foo.ttf") tech(default) is invalid
Fail Check that src: url("foo.ttf") tech(inherit) is invalid
Fail Check that src: url("foo.ttf") tech(initial) is invalid
Fail Check that src: url("foo.ttf") tech(none) is invalid
Fail Check that src: url("foo.ttf") tech(normal) is invalid
Fail Check that src: url("foo.ttf") tech(xyzzy) is invalid
Fail Check that src: url("foo.ttf") tech(xyzzy, features-opentype) is invalid
Fail Check that src: url("foo.ttf") tech(features-opentype, xyzzy) is invalid
Pass Check that src: url("foo.ttf") tech(features-opentype color-COLRv0 variations palettes) is invalid
Pass Check that src: url("foo.ttf") tech(feature-opentype) is invalid
Pass Check that src: url("foo.ttf") tech(feature-aat) is invalid
Pass Check that src: url("foo.ttf") tech(feature-graphite) is invalid
Pass Check that src: url("foo.ttf") tech(auto) is invalid
Pass Check that src: url("foo.ttf") tech(default) is invalid
Pass Check that src: url("foo.ttf") tech(inherit) is invalid
Pass Check that src: url("foo.ttf") tech(initial) is invalid
Pass Check that src: url("foo.ttf") tech(none) is invalid
Pass Check that src: url("foo.ttf") tech(normal) is invalid
Pass Check that src: url("foo.ttf") tech(xyzzy) is invalid
Pass Check that src: url("foo.ttf") tech(xyzzy, features-opentype) is invalid
Pass Check that src: url("foo.ttf") tech(features-opentype, xyzzy) is invalid
Fail Check that src: url("foo.ttf") format(opentype) tech(features-opentype) is valid
Fail Check that src: url("foo.ttf") tech(features-opentype) format(opentype) is invalid
Pass Check that src: url("foo.ttf") tech(features-opentype) format(opentype) is invalid
Fail Check that src: url("foo.ttf") tech(incremental), url("bar.html") is valid
Fail Check that src: url("foo.ttf") tech(incremental, color-SVG, features-graphite, features-aat), url("bar.html") is valid
Fail Check that src: url("foo.ttf") tech(color-SVG, features-graphite), url("bar.html") is valid
Fail Check that src: url("foo.ttf") tech(color-SVG), url("bar.html") is valid
Fail Check that src: url("foo.ttf") tech(features-graphite), url("bar.html") is valid
Fail Check that src: url("foo.ttf") dummy("opentype") tech(variations) is invalid
Fail Check that src: url("foo.ttf") dummy("opentype") dummy(variations) is invalid
Fail Check that src: url("foo.ttf") format(opentype) tech(features-opentype) dummy(something) is invalid
Pass Check that src: url("foo.ttf") dummy("opentype") tech(variations) is invalid
Pass Check that src: url("foo.ttf") dummy("opentype") dummy(variations) is invalid
Pass Check that src: url("foo.ttf") format(opentype) tech(features-opentype) dummy(something) is invalid
Fail Check that src: url("foo.ttf") format(dummy), url("foo.ttf") tech(variations) is valid
Fail Check that src: url("foo.ttf") tech(color), url("bar.html") is valid