Commit graph

102 commits

Author SHA1 Message Date
Callum Law
309ff33278 LibWeb: Add convenience from_style_value for LengthPercentage{OrAuto} 2025-10-07 10:50:01 +01:00
Sam Atkins
3916e33276 LibWeb/CSS: Parse the container-type property
This applies size, inline-size, and style containment in some cases.
There are other WPT tests for that, but we seem to not implement enough
of containment for this to have an effect so I've not imported those.

Gets us 35 WPT subtests.
2025-09-30 22:05:45 +01:00
Pascal Pomper
5b1eba7ac8 LibWeb: Position absolute block-level boxes below previous siblings
Some checks are pending
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / macOS, arm64, Sanitizer, 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
Whether an absbox is positioned below or to the right of its previous
sibling in an `InlineFormattingContext` is determined by the
display-outside value before blockification, so we store the
pre-blockification `display` value in `ComputedValues` to access it in
`InlineFormattingContext` and position the box accordingly.
2025-09-29 18:37:53 +02:00
Sam Atkins
0314606c73 LibWeb/CSS: Replace resolve_length_deprecated() with resolve_length() 2025-09-24 16:33:53 +01:00
Sam Atkins
0dba531772 LibWeb/CSS: Replace resolve_number_deprecated() with resolve_number() 2025-09-24 16:33:53 +01:00
Sam Atkins
d9a386fa81 LibWeb/CSS: Replace resolve_integer_deprecated() with resolve_integer() 2025-09-24 16:33:53 +01: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
dc41d045d8 LibWeb: Store font-style in ComputedProperties in computed form 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
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
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
34b8947ca0 LibWeb: Support text-underline-position: under 2025-09-15 15:24:20 +01:00
Callum Law
815e77c04d LibWeb: Respect text-underline-offset when rendering underlines 2025-09-12 07:07:15 +01:00
Sam Atkins
b3e32445d3 LibWeb/CSS: Use generated FooUnit types instead of Foo::Type
I've also renamed the `m_type` and `type()` members to be `m_unit` and
`unit()` instead, to match what they actually are.
2025-09-11 17:06:44 +01:00
Tim Ledbetter
831088939a LibWeb: Return word-spacing computed value as CSSPixels 2025-09-10 16:12:29 +01:00
Tim Ledbetter
099247d502 LibWeb: Return letter-spacing computed value as CSSPixels 2025-09-10 16:12:29 +01:00
Callum Law
f061f565b9 LibWeb: Remove unused ComputedProperties::resolve_opacity_value 2025-09-08 11:03:32 +01:00
Callum Law
5a7eaf6f73 LibWeb: Store flood-opacity in computed form in ComputedProperties 2025-09-08 11:03:32 +01:00
Callum Law
91e88ad6e8 LibWeb: Store stroke-opacity in computed form in ComputedProperties 2025-09-08 11:03:32 +01:00
Callum Law
c045969234 LibWeb: Store stop-opacity in computed form in ComputedProperties 2025-09-08 11:03:32 +01:00
Callum Law
9434b08bed LibWeb: Store fill-opacity in computed form in ComputedProperties 2025-09-08 11:03:32 +01:00
Callum Law
1ba84de4f6 LibWeb: Store opacity in computed form in ComputedProperties 2025-09-08 11:03:32 +01:00
Sam Atkins
930ee495e7 LibWeb/CSS: Remove the "Auto" type from Length
This has always been a bit of a hack. Initially it made sense as a lot
of properties that accept a length also accept `auto`, but while
convenient, that leads to problems: It's easy to forget to check if a
length is `auto`, and places that don't accept it end up with an
invalid state lurking in the type system, which makes things unclear.
2025-09-04 13:31:24 +01:00
Sam Atkins
dd122e2f74 LibWeb: Make LengthBox hold LengthPercentageOrAuto
Not every user of this requires an `auto` state, but most do.

This has quite a big diff but most of that is mechanical:
LengthPercentageOrAuto has `resolved_or_auto()` instead of `resolved()`,
and `to_px_or_zero()` instead of `to_px()`, to make their output
clearer.
2025-09-04 13:31:24 +01:00
Sam Atkins
d10eaa996e LibWeb/CSS: Use empty optional for stretch in FitContentSV
...instead of using an `auto` Length.
2025-09-04 13:31:24 +01:00
Sam Atkins
1a3246b560 LibWeb/CSS: Stop allowing auto in ComputedProperties::length_percentage
We only had one user of this which allows `auto`, which is length_box().
So, inline the code there, remove the `auto` branch from
length_percentage(), and then remove length_percentage_or_fallback()
entirely as nobody uses it any more.
2025-09-04 13:31:24 +01:00
Sam Atkins
381d3bf4e0 LibWeb: Stop pretending text-decoration-thickness is a LengthPercentage
It has two keywords: auto and from-font. from-font isn't handled
properly yet, but at least we have a FIXME for it now. :^)
2025-09-04 13:31:24 +01:00
Callum Law
39dc604642 LibWeb: Return unanimated font-size in ComputedProperties::font_size()
1a3da3d introduced a crash as we assumed that font-size values were
always stored in their computed forms, this isn't correct for animated
font-size values.

As a temporary workaround until we store animated font-sizes in their
computed form we will return the non-animated value - this restores the
functionality prior to 1a3da3d
2025-09-01 12:28:53 +01:00
Callum Law
6fcaceedd9 LibWeb: Clamp negative computed values for padding-* properties
Interpolation can leave `padding-*` values as negative - this should be
handled by interpolation clamping it to the allowed range of values
but we don't yet do that. As a stop gap we can clamp this before setting
it in ComputedValues.

This fixes 3 crashes and gains us 11 passes in the imported WPT tests
2025-09-01 12:28:53 +01:00
Tim Ledbetter
a87a9156d5 LibWeb/CSS: Parse the paint-order property 2025-08-28 10:31:09 +01:00
Callum Law
6eae92511f LibWeb: Store border-*-width in computed form in ComputedProperties
Gains us 112 new passes since we now interpolate keywords (thick, thin,
etc) correctly.

Also loses us 4 WPT tests as we longer clamp negative values produced by
interpolation from the point of view of getComputedStyle (although the
'used' value is still clamped).
2025-08-28 09:29:46 +01:00
Callum Law
912ffc3f84 LibWeb: Remove unnecessary ComputedProperties::maybe_null_property
We know that all (longhand) properties have a value so this is
unnecessary.
2025-08-26 12:17:55 +02:00
Callum Law
6bccc7c242 LibWeb: Don't allocate space for shorthands in ComputedProperties
Only longhands have computed values so allocating space for shorthands
is just wasted memory
2025-08-26 12:17:55 +02:00
Callum Law
1a3da3d825 LibWeb: Don't store separate computed value for font_size
The StyleValue stored in m_property_values is already in it's computed
form and it's trivial to pull the underlying value out so there is no
need to store this separately.

Also removes unnecessary handling of percentage values in
`absolutize_values` - this is already handled within `compute_font`.
2025-08-26 12:17:55 +02:00
Callum Law
5431f1534a LibWeb: Remove unnecessary check on ComputedProperties array size
This is a constant length array - this check will always be false
2025-08-26 12:17:55 +02:00
Callum Law
9330bf4b72 LibWeb: Propagate animated values in recompute_inherited_style
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
As `recompute_inherited_style` works in-place rather than building
ComputedProperties from scratch we need to keep track of which animated
properties are inherited to know whether we should remove them when we
have no more inherited value.
2025-08-21 10:46:55 +01:00
Tim Ledbetter
1d745884be LibWeb: Parse the shape-rendering property 2025-08-19 09:47:28 +01:00
Tim Ledbetter
4f663ca6e7 LibWeb: Parse the will-change property
This property provides a hint to the rendering engine about properties
that are likely to change in the near future, allowing for early
optimizations to be applied.
2025-08-18 12:36:37 +01:00
Tim Ledbetter
ad06ac0d58 LibWeb: Implement the color-interpolation property for SVG gradients
This changes the operating color space for gradient `<linearGradient>`
and `<radialGradient>` elements.
2025-08-17 10:51:05 +02:00
Callum Law
719ab5735e LibWeb: Avoid addition to infinity when rounding calc'd z-index 2025-08-11 17:10:04 +01:00
Sam Atkins
7157d19f56 LibWeb/CSS: Separate IntegerSV and NumberSV from CSSUnitValue
This inheritance exists for typed-om classes, but StyleValues aren't
typed-om.

Somehow this makes our z-index interpolation slightly more correct. 🎉
2025-08-08 15:19:03 +01:00
Sam Atkins
4e92ab52e3 LibWeb/CSS: Rename CSSKeywordValue -> KeywordStyleValue
The typed-om CSSKeywordValue will need to be a separate class.
2025-08-08 15:19:03 +01:00
Sam Atkins
c57975c9fd LibWeb: Move and rename CSSStyleValue to StyleValues/StyleValue.{h,cpp}
This reverts 0e3487b9ab.

Back when I made that change, I thought we could make our StyleValue
classes match the typed-om definitions directly. However, they have
different requirements. Typed-om types need to be mutable and GCed,
whereas StyleValues are immutable and ideally wouldn't require a JS VM.

While I was already making such a cataclysmic change, I've moved it into
the StyleValues directory, because it *not* being there has bothered me
for a long time. 😅
2025-08-08 15:19:03 +01:00
Callum Law
a70a397501 LibWeb: Support percentages in word-spacing
Fixes crash in the created test as well as https://wpt.live/css/css-text
/word-spacing/reference/word-spacing-percent-001-ref.html. The WPT test
hasn't been imported as it passing is currently a false-positive due to
the fact that we don't yet respect `word-spacing` in most cases.
2025-08-05 11:43:55 +01:00
Callum Law
15cee5cc15 LibWeb: Correctly round non-integer z-indexes
Previously we would just cast to an int.

Gains us 3 WPT tests.
2025-08-05 06:37:40 +01:00
Callum Law
344d6199da LibWeb: Use correct colors for SVGFEFloodElement::flood_color
Previously we would always render floods as black, we now use the
computed color.

We also now support relative lengths within any `calc`s present.
2025-08-04 11:29:05 +01:00
Callum Law
3b52b1139a LibWeb: Support relative lengths in stop-color calcs 2025-08-04 11:29:05 +01:00
Callum Law
a19a6deaa4 LibWeb: Take a ColorResolutionContext in color_or_fallback
Taking a ColorResolutionContext directly instead of creating one from a
layout node allows us to call this from places where we don't have a
layout node.
2025-08-04 11:29:05 +01:00
Callum Law
46153910ec LibWeb: Update to_color to take ColorResolutionContext
Using a generic context argument will allow us to resolve colors in
places where we have all the required information but not in the form of
a layout node as was expected previously.
2025-08-04 11:29:05 +01:00