Commit graph

604 commits

Author SHA1 Message Date
Sam Atkins
f657a4b71b LibWeb/CSS: Parse @font-face { font-weight } with two values
WPT has coverage for matching but not parsing, so the test is homemade.
2026-02-24 10:05:09 +00:00
Callum Law
2008c6be5a LibWeb: Add predefined @counter-styles to UA stylesheet
There are some predefined counter styles (such as the longhand east
asian ones) which are too complex to be defined here and will need to be
implemented ad-hoc, this remains as a FIXME for now.
2026-02-23 11:21:09 +00:00
Callum Law
3e9cdb2cf4 LibWeb: Store whether sheet being parsed is a UA stylesheet
UA stylesheets allow some things that regular stylesheets don't, for
instance allowing use of "non-overridable" `@counter-style` names.
2026-02-23 11:21:09 +00:00
Adam Colvin
d2f10c76fd LibWeb: Reject invalid alt text values in CSS content property parsing
The CSS content property's alt text (after `/`) was incorrectly
accepting any content value. Per the CSS Content Module Level 3 spec,
alt text only accepts <string>, <counter>, and <attr()> values. This
change adds type validation in the alt text parsing branch to reject
URLs, quote keywords, images, and other non-alt-text value types.

This fixes 64 subtests in the content-invalid WPT test.
2026-02-22 13:55:22 -05:00
Aliaksandr Kalenik
795222fab3 LibWeb: Validate grid-template-areas rectangles at parse time
Move grid area rectangle computation and validation from layout to the
CSS parser. Named grid areas that don't form filled-in rectangles now
correctly invalidate the declaration per spec.
2026-02-21 21:46:34 +01:00
Callum Law
e6669482e6 LibWeb: Parse font-variant-alternates functions 2026-02-20 22:01:44 +00:00
Callum Law
630117e111 LibWeb: Reuse logic for parsing font-variant-alternates
This means that we only need to add support for parsing of alternates
functions in one place
2026-02-20 22:01:44 +00:00
Callum Law
849e55b7ae LibWeb: Simplify parsing of font-variant-numeric 2026-02-20 22:01:44 +00:00
Callum Law
04fd7e00e9 LibWeb: Disallow disjointed numeric component of font-variant
The grammar groups this component together meaning that all
sub-components must occur together i.e.
`ordinal slashed-zero small-caps` is valid but
`ordinal small-caps slashed-zero` is not.

We also reuse the logic for parsing from the longhand
`font-variant-numeric` property for simplicity.
2026-02-20 22:01:44 +00:00
Callum Law
f511b95b81 LibWeb: Simplify parsing of font-variant-ligatures 2026-02-20 22:01:44 +00:00
Callum Law
d97098ec80 LibWeb: Disallow disjointed ligatures component of font-variant
The grammar groups this component together meaning that all
sub-components must occur together i.e.
`common-ligatures no-contextual small-caps` is valid but
`common-ligatures small-caps no-contextual` is not.

We also reuse the logic for parsing from the longhand
`font-variant-ligatures` property for simplicity.
2026-02-20 22:01:44 +00:00
Callum Law
d6b94951cf LibWeb: Simplify parsing of font-variant-east-asian 2026-02-20 22:01:44 +00:00
Callum Law
75dd7b767f LibWeb: Disallow disjointed east asian component of font-variant
The grammar groups this component together meaning that all
sub-components must occur together i.e. `jis78 full-width small-caps` is
valid but `jis78 small-caps full-width` is not.

We also reuse the logic for parsing from the longhand
`font-variant-east-asian` property for simplicity.
2026-02-20 22:01:44 +00:00
Callum Law
a287df4620 LibWeb: Improve formatting of font-variant grammar comment
Fix indentation and wrapping to clearly show grouped components
2026-02-20 22:01:44 +00:00
Callum Law
f0434655f9 LibWeb: Reduce recompilation from editing Enums.json
Reduces the recompilation caused by editing `Enums.json` from ~1528 to
~327
2026-02-19 11:27:06 +00:00
Callum Law
6d73a3e85f LibWeb: Parse @font-feature-values at-rule
We don't yet support the `font-display` descriptor as part of this
2026-02-17 12:25:27 +00:00
Callum Law
784911fb6d LibWeb: Implement CSSFontFeatureValuesRule 2026-02-17 12:25:27 +00:00
Callum Law
9f7f623455 LibWeb: Store FilterOperation::DropShadow sub-values as StyleValues
This simplifies handling and brings it into line with other `StyleValue`
types
2026-02-16 12:09:23 +00:00
Callum Law
98e62cf86a LibWeb: Store FilterOperation::Blur::radius as StyleValue
This simplifies handling and brings it into line with other `StyleValue`
types
2026-02-16 12:09:23 +00:00
Callum Law
caa5705edf LibWeb: Clamp blur() calculated values 2026-02-16 12:09:23 +00:00
Callum Law
c529614e67 LibWeb: Store FilterOperation::HueRotate::angle as StyleValue
This simplifies handling and brings it into line with other `StyleValue`
types
2026-02-16 12:09:23 +00:00
Callum Law
68c596942c LibWeb: Store FilterOperation::Color::amount as StyleValue
This simplifies handling and means we now support tree counting
functions.
2026-02-16 12:09:23 +00:00
Callum Law
2c4db0da7e LibWeb: Clamp calculated filter color() amounts by context
This brings us in line with other properties/values and simplifies
handling of non-calculated values
2026-02-16 12:09:23 +00:00
Psychpsyo
a7267f711b LibWeb: Add overflow-clip-margin-* properties
The corner radius isn't quite right yet, but this gives us
another couple WPT passes for these.
2026-02-14 22:58:21 +01:00
Luke Wilde
5e1493d4c0 LibWeb/CSS: Don't assume that we consumed a color space token
Fixes https://cockpit-project.org/ crashing on load.
2026-02-14 19:54:51 +00:00
Callum Law
8a82d116d6 LibWeb: Always parse <counter-style> as such
Previously we parsed it as `<custom-ident>` in `<counter>` and as a
keyword in `list-style-type`.

The practical effect of this is:
 - Spec defined counter style names in `<counter>` are ASCII lowercased
   on parse.
 - Non spec defined counter style names are allowed in `list-style-type.

We are still to parse the `symbols()` function but this gives us a
better base for that.
2026-02-12 10:33:09 +00:00
Callum Law
b0274268f8 LibWeb: Support calculated values in @counter-style range descriptor
Calculated values are resolved and confirmed to be valid (in line with
non-calculated values) at parse time
2026-02-12 01:26:52 +01:00
Callum Law
a541c09d61 LibWeb: Support calculated value in additive-symbols descriptor
Calculated weight values are resolved and verified to be in strictly
decreasing order (as with non-calculated values) at parse time.
2026-02-12 01:26:52 +01:00
Callum Law
3783dd96a3 LibWeb: Support calculated value in @counter-style pad descriptor 2026-02-12 01:26:52 +01:00
Callum Law
046dfdd192 LibWeb: Parse CSS timeline-scope property 2026-02-11 11:27:16 +01:00
Tim Ledbetter
400a1332a6 LibWeb: Correctly parse the grid shorthand property 2026-02-09 17:36:12 +01:00
Tim Ledbetter
e863a04b12 LibWeb: Include grid-auto-* longhands in grid shorthand parsing 2026-02-09 17:36:12 +01:00
Sam Atkins
8975fd7d06 LibWeb/CSS: Stop parsing media-features without parentheses
Our parsing code was treating `foo` and `foo: bar` as `<media-feature>`s
when really they need to be `(foo)` and `(foo: bar)` respectively. This
previously worked for the valid case because boolean expressions can
also have arbitrary `()` blocks. However, it meant we'd also allow them
without the parentheses which isn't valid.

So instead, parse and serialize the parentheses as part of the
`<media-feature>`. This gets us some WPT passes and fixes an Acid3
failure.
2026-02-05 12:22:58 +01:00
Callum Law
11d524bda4 LibWeb: Support CSS font-optical-sizing property 2026-02-03 11:44:25 +00:00
Callum Law
2f90529438 LibWeb: Parse @counter-style speak-as descriptor 2026-02-03 09:58:47 +00:00
Callum Law
85d64a1215 LibWeb: Parse @counter-style additive-symbols descriptor 2026-02-03 09:58:47 +00:00
Callum Law
ecfdf252b8 LibWeb: Parse @counter-style symbols descriptor 2026-02-03 09:58:47 +00:00
Callum Law
1f8c9cf662 LibWeb: Parse @counter-style fallback descriptor 2026-02-03 09:58:47 +00:00
Callum Law
9b376240f9 LibWeb: Parse @counter-style pad descriptor 2026-02-03 09:58:47 +00:00
Callum Law
afca221d47 LibWeb: Parse @counter-style range descriptor 2026-02-03 09:58:47 +00:00
Callum Law
f1e8d54717 LibWeb: Parse @counter-style prefix and suffix descriptors 2026-02-03 09:58:47 +00:00
Callum Law
70c8d8746f LibWeb: Parse @counter-style negative descriptor 2026-02-03 09:58:47 +00:00
Callum Law
f60bfd9e9e LibWeb: Parse @counter-style system descriptor 2026-02-03 09:58:47 +00:00
Callum Law
703259a24c LibWeb: Parse and serialize @counter-style rule
We don't yet parse or serialize any of the descriptors in the rule, just
the rule itself and the name
2026-02-03 09:58:47 +00:00
Jonathan Gamble
b8ee6ec476 LibWeb: Use SizeWithAspectRatio struct 2026-02-02 14:36:49 +00:00
Callum Law
afdde488c3 LibWeb: Correctly parse logical border-*-*-radius shorthands
Builds on #7609 by parsing these properties correctly in the first place
2026-01-25 10:22:10 +01:00
Tim Ledbetter
191e0e8c18 LibWeb: Support @-webkit-keyframes as an alias for @keyframes
This is listed as mandatory in the compat spec.
2026-01-25 09:33:24 +01:00
Callum Law
eb5b73d3b5 LibWeb: Use existing StyleValues for math-depth
Previously we implemented an all encompassing `MathDepthStyleValue`
specifically for the `math-depth` property, this was unnecessary since
we can represent `auto-add` and `<integer>` using existing `StyleValue`
classes.

This brings the values created from parsing in line with those set via
`StylePropertyMap` which allows us to simplify computation
2026-01-15 12:03:16 +00:00
Callum Law
9b20fe6902 LibWeb: Promote font-style to ValueType
This means we now allow oblique angles when parsing the `font`
shorthand.

This also required us to rename the existing `FontStyle` enum to
`FontStyleKeyword`
2026-01-13 10:21:26 +00:00
Callum Law
1c1476f728 LibWeb: Don't compute font-feature-settings until compute-time
Previously we applied the computation logic (i.e. deduplication and
sorting of tags) at parse time
2026-01-13 10:21:26 +00:00