Commit graph

1327 commits

Author SHA1 Message Date
Sam Atkins
8e86bf2dd0 LibWeb/CSS: Implement CSSTransformComponent
This is a base type for the various transform functions.

CSSMatrixComponent's to_string() can throw exceptions, so to_string() is
implemented that way. https://github.com/w3c/fxtf-drafts/issues/611

+9 WPT subtests.
2025-09-24 12:27:05 +01:00
Callum Law
43dd0f2dda LibWeb: Properly clamp interpolated opacity values
Opacity values are unique in that the range which calculated and
interpolated values should be clamped to [0,1] is different from the
range of allowed values [-∞,∞].

This fixes 28 WPT tests that were regressed in #6112
2025-09-24 12:01:52 +01:00
Callum Law
517e3f5f1d LibWeb: Serialize animation according to spec
We now:
 - Serialize longhands in the correct order
 - Support serializing multiple values
 - Include default longhands where required (to distinguish
   animation-name from that longhand).
2025-09-24 11:58:20 +01:00
Callum Law
869442c206 LibWeb: Parse animation shorthand as comma separated list
We now parse (but don't yet trigger animations for) multiple definitions
within a single animation property.
2025-09-24 11:58:20 +01:00
Callum Law
2ff1ae6155 LibWeb: Escape serialized custom idents 2025-09-24 11:58:20 +01:00
Callum Law
c5e6e4fd95 LibWeb: Use custom_ident method for getting @font-face font-family
`CustomIdentStyleValue::to_string` will be updated to return the escaped
value in a future commit but we want to use the unescaped value here.
2025-09-24 11:58:20 +01:00
Callum Law
ce4a24eec5 LibWeb: Store animation-name in ComputedProperties in computed form 2025-09-24 11:58:20 +01:00
Callum Law
030e6d7c9b LibWeb: Parse animation-* properties as comma separated lists
We are yet to actually support having more than one value but this gets
us closer and gains us some WPT tests in the process.
2025-09-24 11:58:20 +01:00
Callum Law
4fd57f90b3 LibWeb: Apply animations after computing property values
We were unnecessarily computing property values within
`collect_animation_into` which we can avoid by ensuring that all calls
to `collect_animation_into` happen after property values are computed.
2025-09-24 11:58:20 +01:00
Tim Ledbetter
0aec8912c9 LibWeb: Remove special casing for font oblique angle from CSS parser 2025-09-24 11:40:38 +01:00
Tim Ledbetter
27de4fdcea LibWeb: Clamp interpolated font-style angle
This change adds the allowed angle range to the `font-style` property
definition. This allows these angles to be clamped after interpolation.

Ideally, the generator should be updated so that we can specify the
angle is in degrees. This would allow us to make use of this
information during parsing, which we can't do currently because we
don't know what the unit is. Using this value for interpolation
purposes is fine because the angle has been converted to its canonical
unit by this point.
2025-09-24 11:40:38 +01:00
Tim Ledbetter
23380a563a LibWeb: Include custom-ident type in specification of grid properties
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Previously, serialization of `grid-column-*` and `grid-row-*`
properties containing a custom-ident would fail.
2025-09-24 02:25:26 +02:00
Tim Ledbetter
4def0b9dc4 LibWeb: Serialize grid-area according to specification 2025-09-24 02:25:26 +02:00
Callum Law
af32413dec LibWeb: Store line-height in ComputedProperties in computed form
We now fail a few more tests in properties-value-inherit-001.txt as we
no longer overwrite the non-animated value of `line-height` with the
animated value, this is in line with other major browsers.
2025-09-23 15:57:32 +01:00
Callum Law
3b15c303f6 LibWeb: Use computed line-height for FontMetrics
We were already doing this within `compute_property_values` where
we resolved most relative lengths but the remainder was instead
incorrectly using the font's line-spacing
2025-09-23 15:57:32 +01:00
Callum Law
e8ad657589 LibWeb: Don't override value of font-style when computing keyframes
We don't actually rely on this being in computed form yet so this is a
non-functional change for now.
2025-09-23 15:57:32 +01:00
Sam Atkins
3272b8c0f3 LibWeb/CSS: Delete EasingFunctions.json
The generator that used this was removed back in
667e313731 but this small JSON file was
overlooked.
2025-09-22 15:35:43 +01:00
Tim Ledbetter
637724f8d9 LibWeb: Add the overflow-inline property 2025-09-19 13:41:27 +01:00
Tim Ledbetter
2e00ff80e5 LibWeb: Add the overflow-block property 2025-09-19 13:41:27 +01:00
Tim Ledbetter
e502f19fa7 LibWeb: Implement the animation-composition property 2025-09-19 10:10:05 +01:00
Callum Law
968a8e618c LibWeb: Use computed font style when parsing font-style descriptor
This means we now properly support relative units and clamping for calcs
in font-style descriptors
2025-09-19 10:06:33 +01:00
Callum Law
e17d91780d LibWeb: Clamp computed value for font-style oblique angle
Values outside [-90deg,90deg] are invalid and should be clamped
2025-09-19 10:06:33 +01:00
Callum Law
dc41d045d8 LibWeb: Store font-style in ComputedProperties in computed form 2025-09-19 10:06:33 +01:00
Callum Law
10793aef56 LibWeb: Move to_font_slope from StyleValue to FontStyleStyleValue
This method only operated on `FontStyleStyleValue`s anyway so this is a
better place to have it
2025-09-19 10:06:33 +01:00
Callum Law
425b7de44a LibWeb: Use compute_font_width for font-width descriptor
This allows us to remove `StyleValue::to_font_width`
2025-09-19 10:06:33 +01:00
Callum Law
335c8c7ffb LibWeb: Store font-width in ComputedProperties in computed form 2025-09-19 10:06:33 +01:00
Callum Law
073d10c6d1 LibWeb: Clamp dimension percentage values to the specified percentage
Previously we would clamp the percentage value to the allowed range for
canonical dimension values rather than the percentage value.

Also fixes an issue where we would clamp pure percentages (i.e.
percentages that don't have a hint) against the allowed values for the
first dimension we checked (i.e. angle)
2025-09-19 10:06:33 +01:00
Callum Law
b52525b454 LibWeb: Convert font-width percentages to keywords when serializing font 2025-09-19 10:06:33 +01:00
Callum Law
45a4e9cd0f LibWeb: Use compute_font_weight for font-weight descriptor
This allows us to remove `StyleValue::to_font_weight`
2025-09-19 10:06:33 +01:00
Callum Law
44eaa7ad98 LibWeb: Avoid overwriting non-animated font-weight when computing font
Previously if we would overwrite the non-animated font-size with the
animated font-size if it was set.

Loses us 2 WPT tests but this is in line with other browsers
2025-09-19 10:06:33 +01:00
Callum Law
39484e2027 LibWeb: Store font-weight in ComputedProperties in computed form
We now also more closely follow the spec when computing values for
font-weight and we now:
 - Support relative lengths in `calc()`s
 - Properly clamp `calc()`s
 - Support relative keywords (e.g. lighter, bolder)
 - Respect that font-weight can be a non-integer number.

This does expose a few false positives in the font-weight-computed.html
WPT test. This is because we don't recompute non-inherited font-weight
within `recompute_inherited_style` which means that relative keyword
values can fall out of sync with their parent's value. These previously
passed as we treated `bolder` and `lighter` as aliases for `bold` and
`normal` respectively.
2025-09-19 10:06:33 +01:00
Callum Law
cfbe0244d4 LibWeb: Use computed value of font-size in keyframes
Remaining test failures in font-size-interpolation-00* are either:
 - Rounding of font-size to CSSPixels when setting the expected value
 - Not clamping negative values from the point of view of
   getComputedStyle (used values are still clamped)
2025-09-19 10:06:33 +01:00
Callum Law
64d2f0d55a LibWeb: Avoid overwriting non-animated font-size when computing font
Previously if we would overwrite the non-animated font-size with the
animated font-size if it was set.

Gains us 8 WPT tests and means we now fail 9 others in line with other
browsers.
2025-09-19 10:06:33 +01:00
Callum Law
c6049e6853 LibWeb: Remove StyleComputer::root_element_font_metrics_for_element
This method is now unused so can be removed
2025-09-19 10:06:33 +01:00
Callum Law
e9faf056f1 LibWeb: Decouple font-size computation from compute_font_for_syle_values
There are other places we want to convert font-size into it's computed
form than just when we are loading the font (e.g. computing keyframes).

Gains us 36 WPT passes as we now correctly clamp negative calc values.
2025-09-19 10:06:33 +01:00
Callum Law
d6754307f9 LibWeb: Separate relative sizes from absolute_size_mapping
Having relative sizes handled in this function was misleading
2025-09-19 10:06:33 +01:00
Callum Law
1ca511b627 LibWeb: Correctly resolve percentages against relative lengths in calcs
Previously we would always assume the percentage was 100%
2025-09-19 10:06:33 +01:00
Callum Law
b80e6a4d30 LibWeb: Rename get_inherit_value to get_non_animated_inherit_value
This more acurately represents what it does.
2025-09-19 10:06:33 +01:00
Tim Ledbetter
9b15517052 LibWeb: Apply composite operator to keyframe effects 2025-09-18 16:46:06 +01:00
Callum Law
004bd3dc8f LibWeb: Clamp calc()'d shadow blur radius to positive values
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
2025-09-18 15:21:22 +01:00
Callum Law
19e3ddc0c6 LibWeb: Simplify parse_single_shadow_value
The `possibly_dynamic_length` function was unnecessary and can be
replaced with the standard `parse_length_value`
2025-09-18 15:21:22 +01:00
Callum Law
c3a78d2884 LibWeb: Don't include spread distance when serializing text-shadow
We shouldn't include spread distance when serializing `text-shadow` as
it is not supported unlike `box-shadow` - to achieve this we store
whether this is a text or box shadow within the ShadowStyleValue and
serialize appropriately.
2025-09-18 15:21:22 +01:00
Callum Law
1ac7b47764 LibWeb: Disallow spread distance value when parsing text-shadow
`text-shadow` does not support setting a value for spread distance
unlike `box-shadow`.
2025-09-18 15:21:22 +01:00
Sam Atkins
95aceb6ec9 LibWeb: Store custom properties in an OrderedHashMap
We are expected to preserve their order within a style declaration, so
let's do that. Passes 1 tracked WPT subtest.
2025-09-18 14:59:14 +02:00
luizgfc
bcbbecff9f LibWeb: Correctly handle properties on CSS declaration serialization 2025-09-18 09:25:23 +01:00
luizgfc
3b5df12b38 LibWeb: Handle custom properties on CSSStyleProperties list 2025-09-18 09:25:23 +01:00
Jelle Raaijmakers
c31eff6a47 Everywhere: Use Optional<T>::ensure() where useful
No functional changes.
2025-09-17 12:01:18 -04:00
Callum Law
34b8947ca0 LibWeb: Support text-underline-position: under 2025-09-15 15:24:20 +01:00
Callum Law
b0e3af7d10 LibWeb: Parse text-underline-position property
This introduces the `TextUnderlinePositionStyleValue` class, it is
possible to represent `text-underline-position` as a `StyleValueList`
but would have required ugly workarounds for either serialization or in
`ComputedProperties::text_underline_position`
2025-09-15 15:24:20 +01:00
Callum Law
a6812e1005 LibWeb: Store parsed shorthands in canonical order 2025-09-15 15:24:20 +01:00