Commit graph

465 commits

Author SHA1 Message Date
Jelle Raaijmakers
90a211bf47 LibWeb: Use device-pixel coordinates in display list and AVC
Stop converting between CSS and device pixels as part of rendering - the
display list should be as simple as possible, so convert to DevicePixels
once when constructing the display list.
2026-02-26 07:43:00 +01:00
Sam Atkins
c9350374a1 LibWeb/CSS: Update a couple of font-related comments 2026-02-24 10:05:09 +00:00
Tim Ledbetter
b3e6df5eef LibWeb: Defer vector allocation in StyleValueList::absolutized()
We now only allocate a StyleValueVector if we know absolutization has
caused a value to change.

This change also avoids a double StyleValue::absolutized() computation.
2026-02-23 17:30:25 +01:00
Callum Law
ca54cc6c79 LibWeb: Resolve <counter> functions using registered counter styles
Previously we only supported a subset of the predefined counter styles,
we now respect counter styles defined by `@counter-style` rules when
resolving the value of `counter()` and `counters()` functions
2026-02-23 11:21:09 +00:00
Callum Law
bb5c8bb5be LibWeb: Add CounterStyleDefinition
This serves as an intermediate step between `CSSCounterStyleRule` and a
fully built counter style which will be helpful for:
 - Determining whether a rule defines a counter style
 - Resolving extends cycles
 - Determining registration order
2026-02-23 11:21:09 +00:00
Callum Law
32b9ff21df LibWeb: Add generic int_from_style_value method
Reduces duplication in line with `number_from_style_value`,
`string_from_style_value` etc
2026-02-23 11:21:09 +00:00
Aliaksandr Kalenik
795222fab3 LibWeb: Validate grid-template-areas rectangles at parse time
Move grid area rectangle computation and validation from layout to the
CSS parser. Named grid areas that don't form filled-in rectangles now
correctly invalidate the declaration per spec.
2026-02-21 21:46:34 +01:00
Callum Law
e6669482e6 LibWeb: Parse font-variant-alternates functions 2026-02-20 22:01:44 +00:00
Callum Law
849e55b7ae LibWeb: Simplify parsing of font-variant-numeric 2026-02-20 22:01:44 +00:00
Callum Law
f511b95b81 LibWeb: Simplify parsing of font-variant-ligatures 2026-02-20 22:01:44 +00:00
Callum Law
d6b94951cf LibWeb: Simplify parsing of font-variant-east-asian 2026-02-20 22:01:44 +00:00
Callum Law
893eac18dd LibWeb: Add TupleStyleValue
Many CSS grammars call for us to parse `Foo || Bar` but we don't have a
good way to represent this unless we have a custom style value. Usually
we store the values in a `StyleValueList` but since that can only store
non-null elements we have to manually recheck which elements we have at
which index whenever we use it.

This style value holds a Vector of `RefPtr<StyleValue const>` so that we
can represent null values and know what values are at what index without
manually rechecking.
2026-02-20 22:01:44 +00:00
Aliaksandr Kalenik
c7dc2ba0d3 LibWeb: Remove DrawPaintingSurface
No callers of draw_painting_surface remain after the previous commits
migrated canvas, video, and SVG to use ExternalContentSource or
ImmutableBitmap snapshots.
2026-02-20 18:41:33 +01:00
Callum Law
f0434655f9 LibWeb: Reduce recompilation from editing Enums.json
Reduces the recompilation caused by editing `Enums.json` from ~1528 to
~327
2026-02-19 11:27:06 +00:00
Timothy Flynn
ea32502947 Everywhere: Run clang-format
The following command was used to clang-format these files:

    clang-format-21 -i $(find . \
        -not \( -path "./\.*" -prune \) \
        -not \( -path "./Build/*" -prune \) \
        -not \( -path "./Toolchain/*" -prune \) \
        -type f -name "*.cpp" -o -name "*.mm" -o -name "*.h")
2026-02-18 08:02:45 -05:00
Callum Law
d998a0aeeb LibWeb: Add generic string_from_style_value method
Reduces duplication in line with `Time::from_style_value()`,
`Angle::from_style_value()` etc
2026-02-17 12:25:27 +00:00
Callum Law
9f7f623455 LibWeb: Store FilterOperation::DropShadow sub-values as StyleValues
This simplifies handling and brings it into line with other `StyleValue`
types
2026-02-16 12:09:23 +00:00
Callum Law
98e62cf86a LibWeb: Store FilterOperation::Blur::radius as StyleValue
This simplifies handling and brings it into line with other `StyleValue`
types
2026-02-16 12:09:23 +00:00
Callum Law
c529614e67 LibWeb: Store FilterOperation::HueRotate::angle as StyleValue
This simplifies handling and brings it into line with other `StyleValue`
types
2026-02-16 12:09:23 +00:00
Callum Law
68c596942c LibWeb: Store FilterOperation::Color::amount as StyleValue
This simplifies handling and means we now support tree counting
functions.
2026-02-16 12:09:23 +00:00
Callum Law
2c4db0da7e LibWeb: Clamp calculated filter color() amounts by context
This brings us in line with other properties/values and simplifies
handling of non-calculated values
2026-02-16 12:09:23 +00:00
Callum Law
79dbca29ee LibWeb: Correctly serialize filter url() value
Previously we would have two closing parentheses when serializing a
`url()` within a `FilterValueListStyleValue`
2026-02-16 12:09:23 +00:00
Callum Law
cd799aa7e7 LibWeb: Forward declare CSS::FilterOperation structs
This means we don't need to include `FilterValueListStyleValue.h` in as
many places - reducing the rebuild from editing that file from 717 files
to 19.
2026-02-16 12:09:23 +00:00
Callum Law
846493831d LibWeb: Add generic number_from_style_value method 2026-02-16 12:09:23 +00:00
Psychpsyo
a7267f711b LibWeb: Add overflow-clip-margin-* properties
The corner radius isn't quite right yet, but this gives us
another couple WPT passes for these.
2026-02-14 22:58:21 +01:00
Callum Law
f1e7743989 LibWeb: Add generic method to get computation context for property
The computation context used is the main thing distinguishing the
computation of font/non-font properties so having a generic method to
handle this will allow us to consolidate logic between the two.
2026-02-13 21:54:06 +01:00
Andreas Kling
97986f9739 LibWeb: Stream animated image frames on demand
Add AnimatedDecodedImageData which implements DecodedImageData with
an 8-slot buffer pool instead of storing all frames in memory.
Frames are requested on demand from the ImageDecoder service as
the animation progresses.

For a 344-frame animated image at 1920x1080, this reduces
WebContent memory from ~1.3 GB to ~66 MB.

The streaming class owns frame progression and synchronizes
multiple callers (HTMLImageElement and ImageStyleValue) through
notify_frame_advanced() returning the authoritative frame index.
When a frame isn't in the pool, the last displayed frame is shown
as a fallback (brief freeze rather than blank).

Rename the old AnimatedBitmapDecodedImageData (which now only
handles static/single-frame images) to BitmapDecodedImageData.
2026-02-13 18:34:24 +01:00
Callum Law
8a82d116d6 LibWeb: Always parse <counter-style> as such
Previously we parsed it as `<custom-ident>` in `<counter>` and as a
keyword in `list-style-type`.

The practical effect of this is:
 - Spec defined counter style names in `<counter>` are ASCII lowercased
   on parse.
 - Non spec defined counter style names are allowed in `list-style-type.

We are still to parse the `symbols()` function but this gives us a
better base for that.
2026-02-12 10:33:09 +00:00
Aliaksandr Kalenik
901cc28272 LibWeb: Reduce recompilation impact of DOM/Document.h
Remove 11 heavy includes from Document.h that were only needed for
pointer/reference types (already forward-declared in Forward.h), and
extract the nested ViewportClient interface to a standalone header.

This reduces Document.h's recompilation cascade from ~1228 files to
~717 files (42% reduction). Headers like BrowsingContext.h that were
previously transitively included see even larger improvements (from
~1228 down to ~73 dependents).
2026-02-11 20:02:28 +01:00
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