Commit graph

319 commits

Author SHA1 Message Date
Callum Law
f49cf75d44 LibWeb: Don't pass unnecessary PropertyComputationDependencies struct
Since we now have access to the `AbstractElement` through the
`ComputationContext` we can just set the flag that this element relies
on tree counting functions directly, no need to pass this struct around.
2025-10-22 00:01:30 +02:00
Callum Law
5b9a36b172 LibWeb: Pass AbstractElement in ComputationContext
Passing the `AbstractElement` rather than the
`TreeCountingFunctionResolutionContext` allows us to only compute the
resolution context when necessary (i.e. when we actually need to resolve
a tree counting function)
2025-10-22 00:01:30 +02:00
Callum Law
2404f95e03 LibWeb: Invalidate style for tree counting functions when required
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 mark any element that relies on tree counting functions as needing a
style update when a sibling is inserted/removed.
2025-10-20 16:12:08 +01:00
Callum Law
e9036c7c75 LibWeb: Support tree counting functions within calc() 2025-10-20 16:12:08 +01:00
Callum Law
55bcdcf824 LibWeb: Set up initial infrastructure for non-math functions in calc
There are some non-math functions (such as tree counting functions)
which we should allow within `calc()`s . This commit implements the
initial infrastructure for this.

We don't yet parse any of these non-math functions in
`parse_a_calculation` so there is no functional change.
2025-10-20 16:12:08 +01:00
Callum Law
831e471444 LibWeb: Support top-level tree counting functions
Adds support for `sibling-index()` and `sibling-count()` when parsing
`<number>` and `<integer>`. This is achieved by a new
`TreeCountingFunctionStyleValue` class which is converted within
`absolutized` to `NumberStyleValue` and `IntegerStyleValue` respectively

There are still a few kinks to work out in order to support these
everywhere, namely:
 - There are some `StyleValue`s which aren't absolutized (i.e. those
   which are stored within another `StyleValue` without an
   `absolutize()` method.
 - We don't have a way to represent this new `StyleValue` within
   `{Number,Integer}OrCalculated`. This would be fixed if we were to
   instead just use the `StyleValue` classes until style computation at
   which time they would be absolutized into their respective
   primitives (double, i64, etc) bypassing the need for *OrCalculated
   entirely.
2025-10-20 16:12:08 +01:00
Callum Law
9cd23e3ae5 LibWeb: Compute and propagate tree-counting function resolution context
Tree counting functions should be resolved at style computation time -
to do this we will need to know the element's sibling count and index.

This commit computes that information and propagates it to the various
`StyleValue::to_computed_value` methods.
2025-10-20 16:12:08 +01:00
Callum Law
8284a99f0a LibWeb: Add absolutized method for FontStyleStyleValue 2025-10-20 16:12:08 +01:00
Callum Law
28451b16c9 LibWeb: Absolutize StyleValues before computing font properties
We also avoid prematurely constructing CSSPixels when computing
font-size which gains us a couple of test passes
2025-10-20 16:12:08 +01:00
Callum Law
ca9d107a1a LibWeb: Remove unused variable in white-space property serialization 2025-10-20 16:12:08 +01:00
Callum Law
03be70087d LibWeb: Maintain easing keywords as KeywordStyleValue until use-time
This excludes `step-end` and `step-start` which are expected to be
converted to the equivalent function at parse time.

We are expected to serialize these as the explicit keywords - previously
we would parse as `EasingStyleValue` and serialize equivalent functions
as the keywords. This caused issues as we would incorrectly serialize
even explicit functions as the keyword.

This also allows us to move the magic easing functions to
`EasingFunction` rather than `EasingStyleValue` which is a bit tidier
2025-10-20 11:27:44 +01:00
Callum Law
755a576013 LibWeb: Support relative lengths within easing function calc()s 2025-10-20 11:27:44 +01:00
Callum Law
ad41f053b8 LibWeb: Clamp calculated steps() interval count using normal system
Previously we were doing this ad-hoc later in the process but we now
have the `calc` clamping system which can simplify things.

This reveals some false-positives in that we don't handle relative
lengths within these `calc`s but these are fixed in the next commit
2025-10-20 11:27:44 +01:00
Callum Law
06a57a280d LibWeb: Clamp calculated cubic-bezier() X coords using normal system
Previously we were doing this ad-hoc later in the process but we now
have the `calc` clamping system which can simplify things
2025-10-20 11:27:44 +01:00
Callum Law
2f83356c0f LibWeb: Support calc within linear() easing function 2025-10-20 11:27:44 +01:00
Callum Law
91925db9ca LibWeb: Don't canonicalize linear easing function points until use time
Canonicalization can require information that is only known after
compute time (i.e. resolved relative lengths within calcs).

This also allows us to get rid of the `had_explicit_input` flag and just
rely on whether Optional has a value
2025-10-20 11:27:44 +01:00
Callum Law
95e26819d9 LibWeb: Separate use time easing functions from EasingStyleValue
In the future there will be different methods of creating these use-time
easing functions (e.g. from `KeywordStyleValue`s)
2025-10-20 11:27:44 +01:00
Callum Law
0e30de82cc LibWeb: Implement <step-position> as an enum
This simplifies parsing and serialization by using the generated
functions
2025-10-20 11:27:44 +01:00
Luke Wilde
eeb5446c1b LibWeb: Avoid including Navigable.h in headers
This greatly reduces how much is recompiled when changing Navigable.h,
from >1000 to 82.
2025-10-20 10:16:55 +01:00
Andreas Kling
dfa796a4e4 LibJS+LibWeb: Use GC::Weak instead of AK::WeakPtr for GC-allocated types
This makes some common types like JS::Object smaller (by 8 bytes) and
yields a minor speed improvement on many benchmarks.
2025-10-17 17:22:16 +02:00
Tim Ledbetter
e55060ef6e LibWeb: Support the display-p3-linear color space in color functions 2025-10-15 18:40:48 +02:00
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