Commit graph

1704 commits

Author SHA1 Message Date
Callum Law
e935dfbf5b LibWeb: Simplify compute_style_value_list 2025-12-02 12:47:10 +00:00
Callum Law
38efc39e17 LibWeb: Simplify assemble_coordinated_value_list
We know that all coordinated value list longhands are parsed as
`StyleValueList`s
2025-12-02 12:47:10 +00:00
Callum Law
74e6c5074f LibWeb: Store list-valued properties as lists in StylePropertyMap::set()
This matches the behavior of parsed values
2025-12-02 12:47:10 +00:00
Callum Law
953f9775a4 LibWeb: Mark animation-* properties as list-valued 2025-12-02 12:47:10 +00:00
Callum Law
758432c1cd LibWeb: Don't mark mask-type as list-valued
This is distinct from the other `mask-*` properties and is not a
longhand of `mask`, and is thus not a coordinating value list longhand
2025-12-02 12:14:27 +00:00
Callum Law
4034ce995a LibWeb: Account for transition-{delay,duration} always being a list
This fixes the optimization implemented in 46acdbd that was no longer
working after e937f5d
2025-12-02 11:45:46 +00:00
Callum Law
d7d4f90a2c LibWeb: Update style attribute when calling attributeStyleMap.set()
We also now invalidate the element
2025-12-02 11:37:11 +00:00
Sam Atkins
b376ab4e81 LibWeb/CSS: Serialize Supports::Declaration as original representation
Fixes some WPT tests that expected `supports(foo:bar)` to serialize as
`supports(foo:bar)`, instead of `supports(foo: bar)` with a space
between.

Reading the original_full_text directly also lets us delete
Declaration::to_string(), which was only used here.
2025-12-02 09:49:23 +00:00
Sam Atkins
db910c68a3 LibWeb/CSS: Add option to retain a Declaration's full source text
This will be needed by Supports, which expects declarations to serialize
verbatim.
2025-12-02 09:49:23 +00:00
Sam Atkins
a8d0be4382 LibWeb/CSS: Expose consumed tokens from TokenStream
In some situations we want to examine a sequence of tokens that have
been already consumed from a TokenStream. These methods let us do so:
- current_index() provides the current internal token index
- tokens_since() provides a span from the given index to the current one
2025-12-02 09:49:23 +00:00
Sam Atkins
8d5eac28a4 LibWeb/CSS: Rename Declaration.original_text -> original_value_text
Otherwise this will conflict with a different original text that I'm
about to add.
2025-12-02 09:49:23 +00:00
Sam Atkins
faba11f33c LibWeb/CSS: Pull out Supports::Declaration parsing
Avoid repeating this in two places.
2025-12-02 09:49:23 +00:00
Sam Atkins
4ed1c56267 LibWeb/CSS: Parse all supports features in @import supports()
The previous implementation assumed that the contents of `supports()`
was either a raw declaration, or a block containing some number of them.
This meant we wouldn't parse things like `supports(not (a:b))` or
`supports(selector(*))`.

`parse_a_supports()` actually does what we want in every case except for
raw declarations (`supports(a: b)`), so let's always call it first, and
then fall back to parsing a single declaration.
2025-12-02 09:49:23 +00:00
Sam Atkins
d9abfdf2ab LibWeb/CSS: Allow non-StyleValueLists in animation properties
Reverts 51f694c6af and
b52beb5105.

The animation-* properties are in an awkward place currently, where
they *should* be lists, and a lot of our code acts as if they are, but
actually we parse them as single values. The above commits caused a few
WPT tests to crash - see link below. I've imported one of them to
prevent future regressions.
https://wpt.fyi/results/css/css-typed-om/the-stylepropertymap/properties?diff&filter=ADC&run_id=6293362870321152&run_id=5123272984494080
2025-12-02 09:48:32 +00:00
Sam Atkins
cdc81e8921 LibWeb/CSS: Add -moz-appearance property alias 2025-12-01 11:10:13 +00:00
Sam Atkins
d5d1b5351e LibWeb: Hide stepper buttons on appearance: textfield number inputs
The spec says:

> For the purpose of this specification, they all have the same effect
  as auto. However, the host language may also take these values into
  account when defining the native appearance of the element.

https://drafts.csswg.org/css-ui/#typedef-appearance-compat-special

Firefox at least hides the stepper buttons when this is set.
2025-12-01 11:10:13 +00:00
Sam Atkins
f81bb1bd8c LibWeb/CSS: Absolutize GradientStyleValues
This lets us not care about non-absolute Length units when resolving
gradient data, as they'll already have been converted to px.

We can also use Angle::from_style_value() safely on absolutized angles,
which reduces some boilerplate code.
2025-12-01 11:01:06 +00:00
Sam Atkins
fbe0567f90 LibWeb/CSS: Store RadialGradientStyleValue sizes as StyleValues
No significant consequences of this, but it'll make it easier to
absolutize these values.
2025-12-01 11:01:06 +00:00
Sam Atkins
d327f677c5 LibWeb/CSS: Store linear-gradient() angle as a StyleValue
This means we now support calc() there too.
2025-12-01 11:01:06 +00:00
Sam Atkins
73fbaaba77 LibWeb: Store GradientStyleValue color-stop positions as StyleValues
A few things fall out of this:
- We no longer need to templatize our color-stop list types.
- A bit more code is required to resolve gradient data.

This results in a slightly different rendering for a couple of the test
gradients, with a larger difference between macOS and Linux. I've
expanded the fuzziness factor to cover for it.
2025-12-01 11:01:06 +00:00
Callum Law
12e8f503aa LibWeb: Support non-fixed <random-value-sharing>
This works by generating random values using XorShift128PlusRNG at
compute time and then caching them on the document using the relevant
random-caching-key
2025-12-01 11:00:33 +00:00
Callum Law
86e6aa0291 LibWeb: Keep track of random function index within property value
Caching keys for 'auto' <random-value-sharing> rely on this value to
distinguish between two random functions in a single property
2025-12-01 11:00:33 +00:00
Callum Law
bad9efac22 LibWeb: Support CSS random() function step argument 2025-12-01 11:00:33 +00:00
Callum Law
2a5e389f63 LibWeb: Implement basic CSS random() function
At the moment this is limited to only fixed value sharing and does not
support step values
2025-12-01 11:00:33 +00:00
Callum Law
8944130fde LibWeb: Serialize CSS::Number to spec
We were previously serializing with 5 instead of 6 digits of precision
2025-12-01 11:00:33 +00:00
Callum Law
76108b1979 LibWeb: Update math function argument parsing to use TokenStream
This brings us in line with the rest of the parsing methods
2025-12-01 11:00:33 +00:00
Callum Law
cd0976395a LibWeb: Remove unused class in CSS parser 2025-12-01 11:00:33 +00:00
Callum Law
2477a8eb0d LibWeb: Use property_initial_value rather than hardcoded default value 2025-12-01 10:16:41 +00:00
Callum Law
d6371fe896 LibWeb: Simplify parse_coordinating_value_list_shorthand 2025-12-01 10:16:41 +00:00
Callum Law
51f694c6af LibWeb: Simplify compute_style_value_list 2025-12-01 10:16:41 +00:00
Callum Law
3ab0bdf4fd LibWeb: Simplify handling of unicode-range descriptor
We know that this is always a `StyleValueList`
2025-12-01 10:16:41 +00:00
Callum Law
47bed173b4 LibWeb: Simplify ComputedProperties::will_change()
We know that `will-change` parses as either `Keyword::Auto` or
`StyleValueList`
2025-12-01 10:16:41 +00:00
Callum Law
b52beb5105 LibWeb: Simplify assemble_coordinated_value_list
We know that all coordinated value list longhands are parsed as
`StyleValueList`s
2025-12-01 10:16:41 +00:00
Callum Law
e8ba1b4fdf LibWeb: Simplify serialization of coordinating value list shorthands
We know that longhand values are always `StyleValueList`s

Introduces a new fail in the `view-timeline-shorthand.html` WPT test
but this is because the test is incorrect and we now correctly don't
contract when `view-timeline-inset` has dissimilar cardinality. See
web-platform-tests/wpt#56181
2025-12-01 10:16:41 +00:00
Callum Law
11a9b5a67b LibWeb: Simplify handling of font-family
We know `parse_comma_separated_value_list` always returns a
`StyleValueList`
2025-12-01 10:16:41 +00:00
Callum Law
0595d52be2 LibWeb: Simplify handling of {text,box}-shadow
We know that shadow values are always parsed as a `KeywordStyleValue`
with `Keyword::None` or a `StyleValueList`
2025-12-01 10:16:41 +00:00
Callum Law
4c4fa5c9cd LibWeb: Simplify expansion of background-position shorthand
We know that this is always a `StyleValueList`
2025-12-01 10:16:41 +00:00
Callum Law
40596d5b99 LibWeb: Simplify getting resolved value for animation-duration
We now know that `animation_duration_computed_value` is always a
StyleValueList
2025-12-01 10:16:41 +00:00
Callum Law
e937f5db57 LibWeb: Always parse comma separated value lists as StyleValueList
Previously we would either parse these as `StyleValueList<T>` or `T`
depending on whether or not there was more than one value, this meant we
always had to handle both cases anywhere we used these values.
2025-12-01 10:16:41 +00:00
Callum Law
1af0364cfc LibWeb: Store last_css_animation_play_state on anim instead of effect
Since it is the animation rather than the effect which has a play state
it makes more sense to store it here
2025-12-01 10:16:41 +00:00
InvalidUsernameException
ce2c4a3417 LibGfx+LibWeb: Fix compile errors in clang-cl from recent header cleanup
The recent commits 28ba610f32 and
70c4ed261f adjusted some include
directives to avoid excessive recompilation when changing some header
files. This has broken compilation with clang-cl on Windows without
getting noticed before the PRs were merged.
2025-11-30 08:45:29 -05:00
InvalidUsernameException
28ba610f32 Everywhere: Avoid large rebuilds when editing (Immutable)Bitmap headers
This reduces the number of recompiled files as follow:
- Bitmap.h: 1309 -> 101
- ImmutableBitmap.h: 1218 -> 75
2025-11-28 18:32:48 +01:00
Callum Law
63538c8a75 LibWeb: Prefer transitioned property values over important
CSS transitions have a higher precedence in the cascade than important
properties
2025-11-28 16:15:49 +00:00
Callum Law
9afb523be3 LibWeb: Remove unnecessary parse_list_of_time_values function
We can achieve the same thing by using
`parse_simple_comma_separated_value_list`
2025-11-28 16:15:49 +00:00
Callum Law
b0ab94c00c LibWeb: Allow multiple values for transition-behavior 2025-11-28 16:15:49 +00:00
Callum Law
70c4ed261f LibWeb: Reduce the number of headers CSS Parser.h is included in
Reduces the rebuild required when editing this file
2025-11-28 16:15:49 +00:00
Callum Law
8a197b7ee5 LibWeb: Produce correct resolved value for animation-duration 2025-11-28 13:24:11 +00:00
Callum Law
c8d91c127e LibWeb: Parse view() for the animation-timeline CSS property 2025-11-28 13:24:11 +00:00
Callum Law
7d70714eac LibWeb: Parse scroll() for the animation-timeline CSS property 2025-11-28 13:24:11 +00:00
Callum Law
5bbcd0a48f LibWeb: Parse the animation-timeline CSS property 2025-11-28 13:24:11 +00:00