Commit graph

1308 commits

Author SHA1 Message Date
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
Tim Ledbetter
f5fd6338d5 LibWeb: Handle interpolation of mixed-type LengthPercentages 2025-09-15 10:41:01 +01:00
Tim Ledbetter
7409c564d7 LibWeb: Extract mixed-type interpolation to a separate method 2025-09-15 10:41:01 +01:00
Tim Ledbetter
b19fee9962 LibWeb: Interpolate ellipse() function by computed value 2025-09-15 10:34:43 +01:00
Tim Ledbetter
f146207a04 LibWeb: Interpolate circle() function by computed value 2025-09-15 10:34:43 +01:00
Tim Ledbetter
4a0fe65923 LibWeb: Interpolate polygon() function by computed value 2025-09-15 10:34:43 +01:00
Tim Ledbetter
853bedeb31 LibWeb: Interpolate rect() function by computed value 2025-09-15 10:34:43 +01:00
Tim Ledbetter
0c89e86ff7 LibWeb: Interpolate xywh() function by computed value 2025-09-15 10:34:43 +01:00
Tim Ledbetter
be94c8d456 LibWeb: Interpolate inset() function by computed value 2025-09-15 10:34:43 +01:00
Sam Atkins
5904694844 LibWeb/CSS: Implement CSSImageValue and reify images as it
This is specced to be opaque, so there's not much to it.
2025-09-15 08:47:10 +01:00
Callum Law
50239b58aa LibWeb: Reset border-image to initial value when using border
Also includes associated handling for serialization of the `border`
shorthand.
2025-09-15 08:42:22 +01:00
Callum Law
588c611e7e LibWeb: Use correct initial value for border-image
Omitting the `/`s meant that `1` and `0` were parsed as part of
border-slice instead of their intended values.

No functional changes but this will be relied on in a later commit.
2025-09-15 08:42:22 +01:00
MFMF-EGY
fff09ed330 LibWeb: Handle interpolation of BorderRadius style value type
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-14 16:49:20 +01:00
Marcos Del Sol Vives
40792aa85d LibWeb/CSS: Fix compilation with CSS_TRANSITIONS_DEBUG
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, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (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
A new parameter was added to Web::CSS::StyleValue::to_string() in
PR #2820 but this debug message was never updated. If
CSS_TRANSITIONS_DEBUG was enabled, compilation would fail.
2025-09-13 23:33:57 +02:00
Tim Ledbetter
19577b966e LibWeb: Implement interpolation of border-image-slice style values 2025-09-13 12:05:19 +02:00
Callum Law
a805635e40 LibWeb: Compute dimension percentage mix as percentage where applicable
When we have a `calc` which is a mix of a dimension and a percentage, we
should use the percentage alone for the computed value if the dimension
component is 0 e.g. `calc(50% + 0px)` should use `50%` as it's computed
value.
2025-09-12 15:04:30 +01:00
Nico Weber
9272df7a86 Everywhere: Fix a few unreachable-return / unreachable-break warnings
I was playing with clang's -Wunreachable-code-aggressive a bit.
This fixes a handful uncontroversial things it flags.

No behavior change.
2025-09-12 14:33:14 +01:00
Sam Atkins
a139ad1c44 LibWeb/CSS: Implement CSSNumericValue.to()
Some checks are pending
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
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
Tries to convert the CSSNumericValue to a CSSUnitValue with the given
unit.

This gets us the remaining 11 WPT subtests for this method.
2025-09-12 13:45:41 +02:00
Sam Atkins
80abffd2e8 LibWeb/CSS: Implement "Create a sum value" 2025-09-12 13:45:41 +02:00
Sam Atkins
1c952b01ac LibWeb/CSS: Implement "Convert a CSSUnitValue" 2025-09-12 13:45:41 +02:00