Commit graph

436 commits

Author SHA1 Message Date
Tim Ledbetter
4a57fc72cf LibWeb: Omit "row" when serializing grid-auto-flow as "dense" 2026-02-09 17:36:12 +01:00
Tim Ledbetter
f6ad878ea3 LibWeb: Allow interleaving of grid-template line names and track values 2026-02-09 17:36:12 +01:00
Tim Ledbetter
400a1332a6 LibWeb: Correctly parse the grid shorthand property 2026-02-09 17:36:12 +01:00
Aliaksandr Kalenik
e76cf3e225 LibWeb: Remove Document.h include from Layout/Node.h
This reduces the recompilation cascade when Document.h is modified.
Add explicit includes to files that relied on the transitive dependency.
2026-02-08 18:51:13 +01:00
Sam Atkins
3aeaecaf28 LibWeb/CSS: Absolutize ColorMixStyleValue
A lot of this is temporary, as a proper implementation will require our
color-interpolation code working with different color spaces and
producing a ColorStyleValue instead of an RGBA32 Gfx::Color. But it
gets us some test improvement.
2026-02-05 13:48:10 +00:00
Sam Atkins
54f54a63b2 LibWeb/CSS: Absolutize LightDarkStyleValues 2026-02-05 13:48:10 +00:00
Sam Atkins
92897a1dec LibWeb/CSS: Absolutize color KeywordStyleValues
These get computed to an equivalent RGBColorStyleValue.

To support this, we now store the computed color-scheme on the
ComputationContext when computing properties that might contain a color.

This has a nice bonus of correcting the css-accent-color test's result.
2026-02-05 13:48:10 +00:00
Sam Atkins
7ba7377e19 LibWeb/CSS: Absolutize basic color StyleValues
These generally work as you'd expect. The exceptions are that hsl() and
hwb() are expected to compute to rgb(), so absolutization produces an
RGBColorStyleValue where possible.
2026-02-05 13:48:10 +00:00
Callum Law
11d524bda4 LibWeb: Support CSS font-optical-sizing property 2026-02-03 11:44:25 +00:00
Callum Law
85d64a1215 LibWeb: Parse @counter-style additive-symbols descriptor 2026-02-03 09:58:47 +00:00
Callum Law
ecfdf252b8 LibWeb: Parse @counter-style symbols descriptor 2026-02-03 09:58:47 +00:00
Callum Law
f60bfd9e9e LibWeb: Parse @counter-style system descriptor 2026-02-03 09:58:47 +00:00
Callum Law
c7f288bf97 LibWeb: Allow marking StyleValueList as non-collapsible
We already disallow collapsing for comma separated lists but this allows
us to disallow it for space separated lists as well
2026-02-03 09:58:47 +00:00
Jonathan Gamble
b8ee6ec476 LibWeb: Use SizeWithAspectRatio struct 2026-02-02 14:36:49 +00:00
Vahan Arakelyan
d04b74555b LibWeb/CSS: Make accentColor and accentColorText take accent-color value 2026-02-02 14:19:08 +00:00
Andreas Kling
bcc7be1751 LibWeb: Optimize EdgeStyleValue::absolutize() in same-value case 2026-01-26 12:40:36 +01:00
Sam Atkins
0796418c18 LibWeb/CSS: Use serialize_a_number() for color components 2026-01-23 14:26:11 +01:00
Sam Atkins
d2a76933d5 LibWeb/CSS: Use serialize_a_number() directly in NumberStyleValue 2026-01-23 14:26:11 +01:00
Sam Atkins
a6b7da9b7c LibWeb/CSS: Serialize resolved alpha components with serialize_a_number
This rounds the numbers in the expected way.
2026-01-23 14:26:11 +01:00
Sam Atkins
0f04c6dd3e LibWeb/CSS: Extract ValueComparingRefPtr types into their own header
I originally wanted to move this to prevent a circular dependency, in a
commit that I'm probably not submitting any more. But also, there's
nothing about this type that is CSS or LibWeb-specific, so let's put
this in AK.
2026-01-23 14:26:11 +01:00
Callum Law
89a360e643 LibGfx+LibWeb: Remove unused FontWeight.h 2026-01-21 23:49:25 +01:00
Tim Ledbetter
09290ae05f LibWeb: Ensure filter values are absolutized before interpolation 2026-01-16 11:29:30 +00:00
Callum Law
2c3ddc294f LibWeb: Compute math-depth in line with other font properties
The main change here is that we now properly absolutize values which
means we now support `random()` and `sibling-{count,index}()`

We are also more consistent with how we handle computation for the other
font properties
2026-01-15 12:03:16 +00:00
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