Commit graph

1364 commits

Author SHA1 Message Date
Tim Ledbetter
83ad5ce8a2 LibWeb: Don't deduplicate font-variation-settings values at parse time
We now only deduplicate and sort the computed value of the
`font-variation-settings` property.
2025-09-26 11:20:54 +01:00
Tim Ledbetter
6cb0f0fbcd LibWeb: Ensure large animation progress values don't overflow 2025-09-26 11:20:54 +01:00
Tim Ledbetter
d18d40f7b9 LibWeb: Handle interpolation of grid track size lists
This allows the `grid-template-rows` and `grid-template-columns`
properties to be correctly interpolated.
2025-09-26 11:15:08 +01:00
Tim Ledbetter
436e9c317a LibWeb: Extract commonly used interpolation lambdas into methods 2025-09-26 11:15:08 +01:00
Tim Ledbetter
f438c1721c LibWeb: Add GridTrackSize constructor that initializes values explicitly 2025-09-26 11:15:08 +01:00
Tim Ledbetter
56d5177eda LibWeb: Add length percentage getter to CSS::Size 2025-09-26 11:15:08 +01:00
Tim Ledbetter
d9b66b22a6 LibWeb: Add type getter to CSS::Size 2025-09-26 11:15:08 +01:00
Callum Law
9ee9be720c LibWeb: Collapse & trim whitespace when serializing UnresolvedStyleValue 2025-09-26 07:30:10 +01: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
585e96d61d LibWeb: Escape custom-ident when serializing grid track placement values 2025-09-25 10:34:45 +01:00
Tim Ledbetter
d42235a642 LibWeb: Use move() for grid track placement values where possible 2025-09-25 10:34:45 +01:00
Andreas Kling
eff9989aeb LibWeb: Only update paint-only properties in affected subtrees
Before this change, we always updated paint-only properties for every
single paintable after layout or style changes.

This could get very expensive in large documents, so this patch makes
it something we can do partially based on "repaint" invalidations.

This cuts down time spent in paint-only property update when scrolling
https://imdb.com/ from 19% to 5%.
2025-09-24 23:59:41 +02:00
Andreas Kling
4b281fa880 LibWeb: Make Length ctor/dtor/factory inline
These functions are trivial, and we were actually bleeding a lot of time
in profiles to just function entry/exit.

By marking Length::make_px() as [[nodiscard]], we also exposed some
places that were creating a Length and not using it for anything.
2025-09-24 23:59:41 +02:00
Andreas Kling
fab96ff805 LibWeb: Don't flag ComputedValues for non-initial border radii too soon
Before this change, we were basically always setting the non-initial
border radii flag on ComputedValues, which made the work-avoiding
optimization based on this flag ineffective.
2025-09-24 23:59:41 +02:00
Andreas Kling
2e0dff420e LibWeb: Use move() in ComputedValue setters where applicable
This avoids copy-constructing various expensive temporaries.
2025-09-24 23:59:41 +02: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
Sam Atkins
d5977b9f74 LibWeb/CSS: Implement CSSTransformValue
This is the final CSSStyleValue class used by the per-property test
harness, so those now actually run instead of throwing an exception on
load. 🎉

+39 WPT subtests. (Plus however many from the per-property tests finally
running.)

The two failing serialization tests are also failed by Safari in exactly
the same way, so that seems more like a spec issue. (The spec is
incomplete in quite a few places.) The failing subtest for toMatrix() is
also a spec issue: is2D is handled oddly by CSSMatrixComponent and this
subtest fails because of the `matrix` getter, which is unspecified. See
https://github.com/w3c/css-houdini-drafts/issues/1155 for details.
2025-09-24 12:27:05 +01:00
Sam Atkins
d3d695e9d2 LibWeb/CSS: Make CSSStyleValue.to_string() return ExceptionOr
DOMMatrix.to_string() throws exceptions if any of its values are
non-finite. This ends up affecting CSSStyleValue because its subclass
CSSTransformValue (which is about to be added) serializes
CSSTransformComponents, and one of those is CSSMatrixComponent, which
calls DOMMatrix.to_string().

This is all quite unfortunate, and because at the time the spec for
DOMMatrix was written, CSS couldn't represent NaN or infinity. That's
no longer true, so I'm hoping the spec can be updated and this can be
reverted. https://github.com/w3c/fxtf-drafts/issues/611
2025-09-24 12:27:05 +01:00
Sam Atkins
a1db5e7789 LibWeb/CSS: Implement CSSMatrixComponent
Equivalent to the matrix() and matrix3d() transform functions.

+19 WPT subtests.
2025-09-24 12:27:05 +01:00
Sam Atkins
2ffbb284f2 LibWeb/CSS: Implement CSSPerspective
Equivalent to the perspective() transform function.

+34 WPT subtests, and the transformvalue-normalization test now runs to
completion instead of throwing an error - though its cases still fail
until CSSTransformValue is implemented.
2025-09-24 12:27:05 +01:00
Sam Atkins
68ceacb0c5 LibWeb/CSS: Implement CSSKeywordish type 2025-09-24 12:27:05 +01:00
Sam Atkins
da883877f5 LibWeb/CSS: Implement CSSSkewY
Equivalent to the skewY() transform function.

+27 WPT subtests.
2025-09-24 12:27:05 +01:00
Sam Atkins
b0cc1c6406 LibWeb/CSS: Implement CSSSkewX
Equivalent to the skewX() transform function.

+27 WPT subtests.
2025-09-24 12:27:05 +01:00
Sam Atkins
161e384521 LibWeb/CSS: Implement CSSSkew
Equivalent to the skew() transform function.

+39 WPT subtests.
2025-09-24 12:27:05 +01:00
Sam Atkins
456946368e LibWeb/CSS: Implement CSSScale
Equivalent to the scale() transform functions.

+33 WPT subtests.
2025-09-24 12:27:05 +01:00
Sam Atkins
d348d8d9b8 LibWeb/CSS: Implement CSSRotate
Equivalent to the rotate() transform functions.

+39 WPT subtests.
2025-09-24 12:27:05 +01:00
Sam Atkins
c7d22d8cfd LibWeb/CSS: Implement CSSTranslate
Equivalent to the translate() transform functions.

+34 WPT subtests.
2025-09-24 12:27:05 +01:00
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