Commit Graph

2027 Commits

Author SHA1 Message Date
Callum Law
3f97f1579f LibGfx: Remove default parameters for some font related functions
We always pass these values so there is no need for default parameters
2026-01-21 23:49:25 +01:00
Callum Law
44415fcbe7 LibWeb: Rename FontLoader::m_vector_font to m_typeface
The `VectorFont` type was renamed to `Typeface` in d5926a3 but this
member variable was never updated.

The getter for this was also unused so has been removed
2026-01-21 23:49:25 +01:00
Callum Law
89a360e643 LibGfx+LibWeb: Remove unused FontWeight.h 2026-01-21 23:49:25 +01:00
Aliaksandr Kalenik
96a39aeaa6 LibWeb: Move effects application into AccumulatedVisualContext
Effects (opacity, blend mode, filters) must be applied in the parent's
coordinate space, before the element's transform. Previously this was
handled by manually switching to the parent's visual context when
applying effects at paint time.

By adding EffectsData to AccumulatedVisualContext and positioning it
before TransformData in the chain, effects are now naturally applied in
the correct order during display list replay, eliminating the special
case in StackingContext::paint().

For SVG filters that can generate content from empty elements (feFlood,
feImage, feTurbulence), a transparent FillRect command is emitted to
trigger the filter through the same AVC pipeline.
2026-01-21 16:19:18 +01:00
Tim Ledbetter
3e704e0fd6 LibGfx+LibWeb: Fall back to system fonts for missing glyphs
When rendering text, if none of the fonts in the cascade list contain a
glyph for a given code point, we now query Skia's font manager to find
a system font that can render it.
2026-01-21 14:01:35 +01:00
Aliaksandr Kalenik
c9a8ca3b8c LibWeb: Rebuild AccumulatedVisualContext on clip property changes
AccumulatedVisualContext nodes capture a snapshot of the current clip
rect when the tree is built, so we must invalidate whenever the clip
property changes.
2026-01-19 04:01:37 +01:00
Aliaksandr Kalenik
eb860e2f10 LibWeb: Rebuild AccumulatedVisualContext on clip-path changes
AccumulatedVisualContext nodes capture a snapshot of the current
clip-path when the tree is built, so we must invalidate whenever the
clip-path changes.

Fixes regression introduced in 98afd82
2026-01-19 04:01:37 +01:00
Andreas Kling
59e0e331e3 LibWeb: Make ComputedValues::will_change() return a const reference
We were incurring a whole lot of Vector copies with this one.
2026-01-18 10:10:04 +01:00
Adam Colvin
3a6d82245b LibWeb: Implement Screen.isExtended attribute
- Add WindowManagement to PolicyControlledFeature enum
- Add screen_count() virtual method to PageClient
- Store all screen rects in WebContent::PageClient, derive both
  screen_rect() and screen_count() from stored data
- Implement screen_count() overrides in SVGPageClient and PageHost
- Replace FIXME stub in Screen.cpp with spec-compliant implementation
2026-01-16 20:34:58 +01:00
Tim Ledbetter
115a794291 LibWeb: Implement composition of filter function lists 2026-01-16 11:29:30 +00:00
Tim Ledbetter
09290ae05f LibWeb: Ensure filter values are absolutized before interpolation 2026-01-16 11:29:30 +00:00
Aliaksandr Kalenik
04c3ad669b LibWeb: Rebuild AccumulatedVisualContext on transform changes
Ensure AccumulatedVisualContext stays synchronized when CSS transform
properties change.

AccumulatedVisualContext copies transform and perspective matrices from
the paintable tree at assignment time. When CSS properties that affect
these matrices change (transform, rotate, scale, translate, perspective,
transform-origin, perspective-origin), we must rebuild the
AccumulatedVisualContext tree to reflect the new values.

This adds a rebuild_accumulated_visual_contexts flag to style
invalidation that triggers a full rebuild during the next paint.

Note: The current invalidation strategy is inefficient - it rebuilds
the entire tree even for single-element transform changes. This could
be improved by patching the AccumulatedVisualContext node in-place with
updated matrices, but only when the transform doesn't transition
from/to none (which would change the tree structure). This optimization
is left for future work.
2026-01-15 19:50:53 +01: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
27dd77a538 LibWeb: Don't store resolved math depth directly
There's no need to store this twice

We also now use `set_property_without_modifying_flags` to avoid
overwriting inherited/important flags
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
Andreas Kling
5049599594 LibWeb: Use FixedBitmap in StyleComputer to avoid malloc
Replace two uses of heap-allocated Bitmap with stack-allocated
FixedBitmap. The sizes are known at compile time, so there's no need
to hit malloc for these.
2026-01-14 11:46:23 +01:00
Sam Atkins
692760b109 LibWeb/CSS: Update links to css-scoping and css-shadow-parts specs
These have been merged together into a new "CSS Shadow Module" spec. No
behaviour changes.

Corresponds to:
80d140567a
2026-01-13 16:18:11 +01:00
Tim Ledbetter
03f262f03d LibWeb: Normalize rotate3d() axis vector when computing transform matrix 2026-01-13 12:40:55 +01:00
Callum Law
668d3afde0 LibWeb: Properly parse attributes for CSS-connected FontFace
Previously we would just set the attributes to the serialized
descriptors, even if they were the empty string.

We now apply defaults when we have empty descriptors and apply parsing
logic from the various `set_*` methods (only applicable to `font-family`
so far where we now extract the value from either a string or a
custom-ident)

Fixes an issue in some css/css-shapes WPT tests where we weren't
properly matching fonts.
2026-01-13 10:40:00 +00:00
Callum Law
bbfe7c64fe LibWeb: Disconnect font face if descriptor change makes it invalid 2026-01-13 10:40:00 +00:00
Callum Law
9af90f81bf LibWeb: Use correct base-url for CSS-connected FontFace
Previously we would always try to load the font URL relative to the
document's base URL. This commit means that for CSS-connected
`FontFace`s we now try to load relative to the URL of the stylesheet
that contains the associated `CSSFontFaceRule`
2026-01-13 10:40:00 +00:00
Callum Law
3996d9ec82 LibWeb: Support setting FontFace::family with StringStyleValue 2026-01-13 10:40:00 +00:00
Callum Law
06313acac0 LibWeb: Store updated attributes directly within FontFace
The spec states that updates to descriptors in a `@font-face` rule
should be reflected in the connected `FontFace`'s attributes.

Previously this was achieved by directly accessing those descriptors
when calling the attribute getters, but this has a couple of issues:
 a) The changes are only reflected if we use the accessors (i.e.
    `FontFace::family()` rather than `FontFace::m_family`) which isn't
     the case everywhere
 b) The changes aren't persisted after the `FontFace` is disconnected
    from it's `CSSFontFaceRule`

To fix these issues we now reparse and store the `FontFace`'s attributes
whenever the `CSSFontFaceRule`'s descriptors change.
2026-01-13 10:40:00 +00:00
Callum Law
df03c31e13 LibWeb: Don't crash when serializing @font-face without font-family 2026-01-13 10:40:00 +00:00
Callum Law
e114c7341e LibWeb: Support <custom-ident> in FontFaceSet::load()
This exposed a false positive in our test suite which has been fixed and
made more robust
2026-01-13 10:40:00 +00: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
1c1476f728 LibWeb: Don't compute font-feature-settings until compute-time
Previously we applied the computation logic (i.e. deduplication and
sorting of tags) at parse time
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
49f8fafc2e LibWeb: Treat content-visibility auto as non-hidden in interpolation
This matches the interpolation behavior of the `visibility` property
and of other engines.
2026-01-13 10:49:31 +01:00
Jelle Raaijmakers
aed9f6a395 LibWeb: Move onanimation* IDL attributes to AnimationEvent.idl
Use the newly added `partial interface mixin` support to move the
CSS animation event handler attributes to their proper location as
specified in CSS Animations Level 1.
2026-01-13 10:09:22 +01:00
Tim Ledbetter
ba4a58fc0a LibWeb: Use correct angle calculation in quaternion_to_axis_angle()
For small rotations we were returning the quaternion's `w` component
directly. The angle returned should be `2*acos(w)` in all cases.
2026-01-13 09:36:47 +01:00
Shannon Booth
5ffc70a2e2 LibWeb/CSS: Implement CSSNumericValue numeric IDL functions 2026-01-12 11:51:15 +00:00
Shannon Booth
09f2db7aa9 LibWeb/CSS: Add various CSSMathXXX constructor helpers
The exact same two steps are repeated for all of these in
CSSNumericValue. These steps are complicated enough that it makes
sense to factor them out into some helpers.
2026-01-12 11:51:15 +00:00
Shannon Booth
3cb428e76d LibWeb/CSS: Remove uneeded ExceptionOr use in CSSMath{Invert,Negate} 2026-01-12 11:51:15 +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
Jonathan Gamble
4579bb5bed LibWeb: Add resize property plumbing 2026-01-12 11:00:14 +00:00
Callum Law
7c544175e5 LibWeb: Cache compute_font_for_style_values
We already cached the result of `font_matching_algorithm` but we can
instead cache the entire function.
2026-01-11 14:10:37 +01:00
Callum Law
99c06675cf LibWeb: Combine cascaded property lookups during computation
Previously we would do two cascaded property lookups per property during
style computation - the first to get the value of the property and the
second to check whether it was marked as important. We now do this as a
single lookup to save some unnecessary work.
2026-01-11 14:10:37 +01:00
Callum Law
df39394a7e LibWeb: Remove font face from document font source when disconnecting
When a CSS-connected FontFace is disconnected from it's associated
`CSSFontFaceRule` it should be removed from the Document's font source
2026-01-10 03:33:03 +00:00
Callum Law
d8f9caf853 LibWeb: Only run handle_src_descriptor_change once
Previously we would run it once within `set_src()` and then again within
`set_property()` which would lead to us creating two new `FontFace`s
instead of just one
2026-01-10 03:33:03 +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
Tim Ledbetter
89a391198e LibWeb: Avoid intermediate string allocations in typed om serialization 2026-01-09 17:14:20 +00:00
Tim Ledbetter
cac2ad5ec4 LibWeb: Avoid intermediate string allocation in CSSPropertyRule::dump() 2026-01-09 15:20:06 +00:00
Tim Ledbetter
7335b90c40 LibWeb: Prefer serialize() to to_string() when serializing at-rules 2026-01-09 15:20:06 +00:00
Sam Atkins
960558f30a LibWeb: Register and unregister @property rules when added or removed
Previously, we registered `@property` rules during parsing, and treated
them the same as `CSS.registerProperty()` calls. This is not correct
for a couple of reasons: One, the spec wants us to distinguish between
those two sources of registered custom properties, with
`CSS.registerProperty()` calls taking precedence. Two, we never removed
the registered property when its `@property` was removed from the
document.

This commit deals with this by iterating active CSSPropertyRules to find
which ones currently apply, and storing those in a cache. This cache is
invalidated whenever the Document's style is invalidated, which happens
whenever a CSSRule is added or removed from the Document.

The attached test demonstrates this now working as it should.
2026-01-09 10:54:37 +00:00
Sam Atkins
7c773e73e0 LibWeb/CSS: Read @property initial values in computed style
If a custom property is registered, then it may have an initial value
which we should fall back to here.

This is a temporary hack until we cascade our custom properties (see
https://github.com/LadybirdBrowser/ladybird/pull/6608).
2026-01-09 10:54:37 +00:00