Commit graph

413 commits

Author SHA1 Message Date
Callum Law
eb5b73d3b5 LibWeb: Use existing StyleValues for math-depth
Previously we implemented an all encompassing `MathDepthStyleValue`
specifically for the `math-depth` property, this was unnecessary since
we can represent `auto-add` and `<integer>` using existing `StyleValue`
classes.

This brings the values created from parsing in line with those set via
`StylePropertyMap` which allows us to simplify computation
2026-01-15 12:03:16 +00:00
Tim Ledbetter
40d217bde2 LibWeb/CSS: Serialize shorthands with var() to original value 2026-01-15 11:50:45 +00:00
Tim Ledbetter
03f262f03d LibWeb: Normalize rotate3d() axis vector when computing transform matrix 2026-01-13 12:40:55 +01:00
Callum Law
9b20fe6902 LibWeb: Promote font-style to ValueType
This means we now allow oblique angles when parsing the `font`
shorthand.

This also required us to rename the existing `FontStyle` enum to
`FontStyleKeyword`
2026-01-13 10:21:26 +00:00
Callum Law
3a515fd3ee LibWeb: Ignore initial keyword when serializing font shorthand
We know that none of the longhands contain CSS-wide keywords since that
is handled as the first step of `ShorthandStyleValue::serialize()`
2026-01-13 10:21:26 +00:00
Callum Law
252e1d86bd LibWeb: Dont serialize font with non-initial reset-only sub-properties 2026-01-13 10:21:26 +00:00
Tim Ledbetter
1df792ddbd LibWeb: Avoid intermediate string allocations in calc() serialization 2026-01-12 11:35:01 +00:00
Jonathan Gamble
8f1cb4cbb0 LibWeb: Implement resizing for eligible elements and update scrollbars
Add ElementResizeAction to Page (maybe there's a better place). It's
just a mousemove delegate that updates styles on the target element.

Add ChromeMetrics for zoom-invariant chrome like scrollbar thumb
thickness, resize gripper size, paddings, etc. It's not user-stylable
but separates basic concerns in a way that a visually gifted
designer unlike myself can adjust to taste.

These values are pre-divided by zoom factor so that PaintableBox can
continue using device_pixels_per_css_pixel calls as normal.

The adjusted metrics are computed on demand from Page multiple times
per paint cycle, which is not ideal but avoids lifetime management and
atomics. Maybe someone with more surety about the painting flow control
can improve this, but it won't be a huge win. If profiling shows
this slowing paints, then Ladybird is in good shape.

Update PaintableBox to draw the resize gripper and deconflict
the scrollbars. Set apropriate cursors for scrollbars and gripper in
mousemove. We override EventHandler's cursor handling because nothing
should ever come between a man and his resize gripper.

Chrome metrics use the CSSPixels class. This is good because it's
broadly compatible but bad because they're actually different units
when zoom is not 1.0. If that's a problem, we could make a new type
or just use double.
2026-01-12 11:00:14 +00:00
Sam Atkins
35bb1e20ee LibWeb/CSS: Don't serialize "in oklab" in color-mix()
This is the default interpolation method, so should be skipped according
to the rule of the shortest serialization.
2026-01-09 19:11:59 +00:00
Sam Atkins
ade44c7ddb LibWeb/CSS: Make color-interpolation-method optional in color-mix() 2026-01-09 19:11:59 +00:00
Shannon Booth
d901e937b6 LibWeb/CSS: Do not give internal stylesheets a location URL
This fixes Acid3 numbered test 72.
2026-01-09 10:54:11 +00:00
Tim Ledbetter
65f6da8d92 LibWeb: Reduce String allocations in serialize_layer lambdas 2026-01-09 10:00:58 +01:00
Tim Ledbetter
1d2e4e4273 LibWeb: Use StringBuilder when serializing basic grid types 2026-01-09 10:00:58 +01:00
Tim Ledbetter
17ee0e3a19 LibWeb: Use StringBuilder when serializing more CSS types 2026-01-09 10:00:58 +01:00
Tim Ledbetter
d28d04f78e LibWeb: Make InterpolationMethod serialization take a StringBuilder 2026-01-09 10:00:58 +01:00
Tim Ledbetter
b4cf7e8060 LibWeb: Avoid String allocations in easing values serialization methods 2026-01-09 10:00:58 +01:00
Tim Ledbetter
0d7f2b8cba LibWeb: Avoid String allocations in BasicShape serialization methods 2026-01-09 10:00:58 +01:00
Tim Ledbetter
a27d269721 LibWeb: Pass StringBuilder around during StyleValue serialization
Previously, some StyleValues created a large number of intermediate
strings during serialization. Passing a StringBUilder into the
serialization function allows us to avoid a large number of these
unnecessary allocations.
2026-01-09 10:00:58 +01:00
Callum Law
09799e794e LibWeb: Update Length::absolutize() to take a ResolutionContext
All callers are passing individual values from a `ResolutionContext`
anyway so we may as well do it in a single place.
2026-01-08 10:51:35 +01:00
Aliaksandr Kalenik
d7fb5ba35f LibWeb: Use value-comparing RefPtr in ColorStopListElement
The color stop members were RefPtr which compares by pointer identity.
This caused false positives in style invalidation when the same gradient
color values were recomputed as different objects.
2026-01-06 13:23:00 +00:00
Aliaksandr Kalenik
b6da3aaa3f LibWeb: Use value-comparing RefPtr in CursorStyleValue
The x and y members were RefPtr which compares by pointer identity.
This caused false positives in style invalidation when the same values
were recomputed as different objects.
2026-01-06 13:23:00 +00:00
Aliaksandr Kalenik
9cd583ff6e LibWeb: Use value-comparing RefPtr in TextIndentStyleValue
The member type was NonnullRefPtr which compares by pointer identity.
This caused false positives in style invalidation when the same values
were recomputed as different objects.
2026-01-06 13:23:00 +00:00
Aliaksandr Kalenik
fee49c3837 LibWeb: Use value-comparing RefPtr in ScrollbarColorStyleValue
The member types were NonnullRefPtr which compares by pointer identity.
This caused false positives in style invalidation when the same color
values were recomputed as different objects.
2026-01-06 13:23:00 +00:00
Tim Ledbetter
584e0996c9 LibWeb: Store color as a StyleValue in FilterOperation::DropShadow 2026-01-06 12:13:13 +01:00
Callum Law
72a00a17cc LibWeb: Omit nonzero fill rule when serializing polygon()
Gains us ~160 WPT passes
2026-01-06 10:49:51 +00:00
Callum Law
4f5bab7e5d LibWeb: Support border radius in xywh() function 2026-01-06 10:50:06 +01:00
Callum Law
02a8d22a4e LibWeb: Support border radius in rect() function 2026-01-06 10:50:06 +01:00
Callum Law
1b7567cc86 LibWeb: Support parsing of border radius in inset() function
Respecting this value during basic shape path resolution is yet to be
implemented
2026-01-06 10:50:06 +01:00
Callum Law
84c6fd5730 LibWeb: Make parsing of border-radius value reusable
This is also useful for `<basic-shape-rect>`
2026-01-06 10:50:06 +01:00
Callum Law
cb1425877a LibWeb: Serialize inset() arguments as positional value list 2026-01-06 10:50:06 +01:00
Callum Law
00af50d49e LibWeb: Make serialization of positional value list reusable
This is useful for more than just shorthands (e.g. it is also useful for
the arguments of the `inset()` function)
2026-01-06 10:50:06 +01:00
Callum Law
96a4e33eaf LibWeb: Resolve circle()/ellipse() position keywords at parse time 2026-01-05 11:42:19 +00:00
Callum Law
64010c78ab LibWeb: Store ColorStopListElement::transition_hint as a RefPtr
There's no need for us to wrap this in an optional struct.
2026-01-03 02:30:59 +01:00
matjojo
9314cc3a30 LibWeb: Absolutize transition hint in ColorStopListElement 2026-01-02 21:48:31 +01:00
Callum Law
acc8b90549 LibWeb: Improve gradient position serialization
`EdgeStyleValues` which consist of an offset of a `calc()`s which
resolves to 50% should be considered "centered" for
`SerializationMode::ResolvedValue` for the purpose of omitting the
position value from gradient serialization.
2026-01-02 11:43:10 +01:00
Callum Law
6964593377 LibWeb: Add absolutized method to EdgeStyleValue
Fixes #7192.

We absolutize `EdgeStyleValue` to always be relative to the top/left
edge which allows for some simplification.
2026-01-02 11:43:10 +01:00
Callum Law
727058dfcd LibWeb: Add absolutized method to PositionStyleValue
This is a non-functional change for now since it's descendent
`EdgeStyleValue`s don't yet have their corresponding `absolutized`
method
2026-01-02 11:43:10 +01:00
Callum Law
e6ddb7db9e LibWeb: Store EdgeStyleValue sub-values directly
As well as being required to implement absolutization this also means we
now bypass a limitation with `LengthPercentage` where we would always
use `SerializationMode::Normal` for the constituent lengths which gains
us some WPT passes
2026-01-02 11:43:10 +01:00
Gingeh
5c0e707f01 LibWeb: Don't crash when rounded background image is too large 2025-12-30 12:26:55 +01:00
Andreas Kling
95a9ea68a0 LibWeb: Add fast_is<T>() for CalculationNode and all its subclasses 2025-12-20 09:13:19 -06:00
Sam Atkins
c446281844 LibWeb/CSS: Remove Transformation in favor of TransformationStyleValue
The Transformation class wasn't really accomplishing anything. It still
had to store StyleValues, so it was basically the same as
TransformationStyleValue, with extra steps to convert from one to the
other. So... let's just use TransformationStyleValue instead!

Apart from moving code around, the behavior has changed a bit. We now
actually acknowledge unresolvable parameters and return an error when
we try to produce a matrix from them. Previously we just skipped over
them, which was pretty wrong. This gets us an extra pass in the
typed-om test.

We also get some slightly different results with our transform
serialization, because we're not converting to CSSPixels and back.
2025-12-19 14:51:53 +01:00
Sam Atkins
ab176b5dde LibWeb/CSS: Allow unreifiable transform-lists to reify as CSSStyleValues
Some transform-functions are not reifiable as a CSSTransformComponent,
for example a matrix() with sibling-index() in it. In that case, rather
than crashing, fall back to the basic CSSStyleValue reification.

The crash doesn't happen yet, but would with the following commit's
changes. Currently, Transformation::to_matrix() completely ignores
unsupported argument types, but in the next commit that's replaced with
TransformationStyleValue::to_matrix(), which attempts to handle them
properly.
2025-12-19 14:51:53 +01:00
Callum Law
883b190e64 LibWeb: Omit default radius from ellipse() serialization 2025-12-12 12:20:16 +00:00
Callum Law
f17f4f233d LibWeb: Don't serialize omitted ellipse() position argument 2025-12-12 12:20:16 +00:00
Callum Law
daf464844b LibWeb: Support all <radial-extent> values in ellipse()
To do this we use the generic `RadialSizeStyleValue` which allows us to
remove the remaining logic around `<shape-radius>`
2025-12-12 12:20:16 +00:00
Callum Law
375df05ab9 LibWeb: Omit default radius from serialization of CSS circle() 2025-12-12 12:20:16 +00:00
Callum Law
ad1083f14e LibWeb: Don't serialize omitted circle() position argument
This should only be defaulted to `center` at use time
2025-12-12 12:20:16 +00:00
Callum Law
7b76b7f6f6 LibWeb: Add PositionStyleValue::create_computed_center
This is equivalent to the existing `PositionStyleValue::create_center`
but returns the value expected after computation has been completed
(i.e. `50% 50%` rather than `center center`)
2025-12-12 12:20:16 +00:00
Callum Law
8501d6995d LibWeb: Support all <radial-extent> values in circle() 2025-12-12 12:20:16 +00:00
Callum Law
4909e19aca LibWeb: Make <radal-size> parsing generic
Previously this was implemented inline within the parsing of
`{repeating}-radial-gradient()` functions but it will also be useful for
`circle()` and `ellipse()`.

We now support the CSS Images Module Level 4 additions to the
`<radial-size>` syntax, namely:
 - `<length-percentage>` rather than just `<length>` for circles.
 - Distinct `<radial-extent>` values for horizontal and vertical for
   ellipses.
 - Mixing of `<radial-extent>` and `<length-percentage>` values for
   ellipses.

The regressions are due to WPT not being updated to expect the first of
these additions.
2025-12-12 12:20:16 +00:00