Commit graph

298 commits

Author SHA1 Message Date
Sam Atkins
0afa93e639 LibWeb/CSS: Add a Property -> CalculationContext factory method
We have this code duplicated in multiple places, and we'll want to
handle registered custom properties too at some point, so wrap it in a
reusable `CalculationContext::for_property()` method.

Noticed while doing this that ValueParsingContext will eventually need
to take a PropertyNameAndID, not a PropertyID, so I've added a FIXME.
2025-10-13 09:59:38 +01:00
Callum Law
102edf638d LibWeb: Support interpolation of SuperellipseStyleValue
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-10-09 10:23:20 +01:00
Callum Law
20a2e8ab12 LibWeb: Store corner-*-shape properties in computed form 2025-10-09 10:23:20 +01:00
Callum Law
814efa9809 LibWeb: Parse corner-*-shape physical longhands 2025-10-09 10:23:20 +01:00
Callum Law
e772a992be LibWeb: Store CursorStyleValue sub-values directly
Storing these within NumberOrCalculated is unnecessary
2025-10-07 10:50:01 +01:00
Callum Law
25192d3c20 LibWeb: Store BorderRadiusStyleValue sub-values directly
Storing these within LengthPercentage is unnecessary
2025-10-07 10:50:01 +01:00
Callum Law
2ebf446cbf LibWeb: Store BackgroundSizeStyleValue sub-values directly
Storing these within LengthPercentage is unnecessary
2025-10-07 10:50:01 +01:00
Callum Law
4a998879d5 LibWeb: Add absolutized method for TransformStyleValue 2025-10-07 10:50:01 +01:00
Callum Law
e675b95f51 LibWeb: Add absolutized method to OpenTypeTaggedStyleValue 2025-10-07 10:50:01 +01:00
Callum Law
2c7b56511b LibWeb: Add absolutized method to CounterDefinitionsStyleValue
This avoids a crash when a counter value relies on relative units
2025-10-07 10:50:01 +01:00
Callum Law
52192a308b LibWeb: Update absolutize to take a ComputationContext struct
This struct will in the future hold information other than a length
resolution context (e.g. context for tree counting functions) and a
single struct is easier to work with than multiple parameters.
2025-10-07 10:50:01 +01:00
Callum Law
28c12324c2 LibWeb: Remove unused NumericCalculationNode::to_style_value 2025-10-07 10:50:01 +01:00
Sam Atkins
2de4fe8104 LibWeb/CSS: Store StyleValue pointer instead of string on CSSStyleValue
When setting style to a CSSStyleValue we need to convert it to a
StyleValue. If we already have one, we might as well use it avoid the
work of serialization and re-parsing.

I realised I misunderstood what "constructed from a USVString" means, so
I've adjusted based on that. It does raise a question on what the source
USVString is if that string resulted in multiple CSSStyleValues being
created - see the linked issue.
2025-10-04 22:57:00 +02:00
Sam Atkins
a30afafcc9 LibWeb/CSS: Use FlyString for CSSStyleValue property name 2025-10-02 13:46:04 +01:00
Tim Ledbetter
bf1564388d LibWeb: Serialize grid-template shorthand correctly 2025-09-28 17:34:58 +02:00
Sam Atkins
aa8bf6372f LibWeb/CSS: Inline EasingStyleValue::CubicBezier::operator==()
For whatever reason, this method in particular ends up failing to link
into WebContent with a subsequent change. It's small and simple, so
just inline it.
2025-09-26 22:31:07 +02:00
Andreas Kling
321809320b LibWeb+LibGfx: Remove Path::close_all_subpaths()
As it turns out, SkPath already behaves the way we need for SVG and HTML
canvas elements. Less work for us, yay! This removes a 5% item from the
profile when scrolling on https://imdb.com/

Note that there's a tiny screenshot test expectation change due to
minor antialiasing differences when we no longer do our redundant
subpath modifications.
2025-09-25 21:42:52 +02:00
Tim Ledbetter
d42235a642 LibWeb: Use move() for grid track placement values where possible 2025-09-25 10:34:45 +01:00
Sam Atkins
4acde45d5e LibWeb/CSS: Remove now-unused non-spec calc() resolution code
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
We're now fully using the simplification algorithm to produce calc
results.
2025-09-24 16:33:53 +01:00
Sam Atkins
0314606c73 LibWeb/CSS: Replace resolve_length_deprecated() with resolve_length() 2025-09-24 16:33:53 +01:00
Sam Atkins
995b7eb7b4 LibWeb/CSS: Replace resolve_percentage_deprecated() with undeprecated 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
Sam Atkins
0ff012d3f3 LibWeb/CSS: Replace resolve_time_deprecated() with resolve_time() 2025-09-24 16:33:53 +01:00
Sam Atkins
7428a8eb40 LibWeb/CSS: Replace resolve_resolution_deprecated() with undeprecated 2025-09-24 16:33:53 +01:00
Sam Atkins
7f237b3e62 LibWeb/CSS: Replace resolve_frequency_deprecated() with undeprecated 2025-09-24 16:33:53 +01:00
Sam Atkins
cd29111b36 LibWeb/CSS: Replace resolve_flex_deprecated() with resolve_flex() 2025-09-24 16:33:53 +01:00
Sam Atkins
375e32c523 LibWeb/CSS: Replace resolve_angle_deprecated() with resolve_angle()
Gets us some WPT passes. 🎉
2025-09-24 16:33:53 +01:00
Sam Atkins
b24b00fb7d LibWeb/CSS: Reify CSSTransformValues
We have a slightly odd setup here. TransformationStyleValue reifies as a
single CSSTransformComponent. It's StyleValueList that actually reifies
as a CSSTransformValue - but only if it only contains
TransformationStyleValues.

+79 WPT subtests.
2025-09-24 12:27:05 +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
2ff1ae6155 LibWeb: Escape serialized custom idents 2025-09-24 11:58:20 +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
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
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
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
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
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
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
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
Sam Atkins
995c19da56 LibWeb/CSS: Return unit names as FlyStrings
From the CSS token side, we already have these in FlyString form. From
the generated code side, we can easily return FlyStrings instead of
StringViews. So, let's do that, and save some work converting back and
forth.
2025-09-12 13:45:41 +02:00
Sam Atkins
583d74e3a9 LibWeb/DOM: Reduce AbstractElement.h's includes
This doesn't need all of Selector.h and its various includes, it just
needs the PseudoElement enum.

StringStyleValue.h was transitively including ComponentValue.h through
this, so it now includes it directly.
2025-09-11 18:45:35 +02: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
Callum Law
1c2c77b441 LibWeb: Remove unnecessary handling of StyleValueList border longhands
This is no longer needed as we parse border longhands directly to
ShorthandStyleValues
2025-09-09 11:45:47 +02:00
Callum Law
5ed3b2ed16 LibWeb: Support interpolation of CalculatedStyleValue
We also support interpolating from a CalculatedStyleValue to a
compatible dimension or percentage style value.

This also brings with it a couple of improvements in how we handle
interpolation between mixed dimension and percentage types in terms of:
 - Proper simplification of the resulting calc()
 - Improved handling of interpolation outside the 0-1 range
2025-09-08 11:58:44 +01:00