Commit Graph

2204 Commits

Author SHA1 Message Date
Callum Law
cbc2bb7aa7 LibWeb: Don't pass layout node when resolving EdgeRect
We know that these lengths have already been absolutized at computed
value time
2026-03-30 14:05:10 +01:00
Callum Law
3aa71034de LibWeb: Support calc() within clip: rect() 2026-03-30 14:05:10 +01:00
Callum Law
ab6f5b36d2 LibWeb: Add LengthOrAuto::from_style_value 2026-03-30 14:05:10 +01:00
Callum Law
3b3f06bfa3 LibWeb: Support non-literal integers in repeat()
We now support non-literal integers (i.e. `calc()` and tree counting
functions) within `<track-repeat>` and `<fixed-repeat>`
2026-03-30 14:05:10 +01:00
Callum Law
f2a8099d13 LibWeb: Parse sizes attribute as StyleValue
Gets us a step closer to removing the `FooOrCalculated` classes
2026-03-30 14:05:10 +01:00
Callum Law
3e58e15217 LibWeb: Support relative lengths within color-mix percentage calc()s 2026-03-30 14:05:10 +01:00
Callum Law
3c00a13237 LibWeb: Remove redundant normalization of percentages in ColorMixSV
We normalize percentages at computed value time so there's no need to
normalize them again when converting to used value
2026-03-30 14:05:10 +01:00
Callum Law
9b2dd73359 LibWeb: Store ColorMixComponent::percentage as StyleValue
This simplifies handling and gets us closer to removing the
`OrCalculated` classes
2026-03-30 14:05:10 +01:00
Callum Law
149acdd7c5 LibWeb: Add Percentage::from_style_value 2026-03-30 14:05:10 +01:00
Callum Law
fe5d6471f0 LibWeb: Store GridTrackPlacement sub-values as StyleValues
Gets us one step closer to removing the `FooOrCalculated` classes
2026-03-30 14:05:10 +01:00
Dylan Hart
1354eb1ac2 LibWeb: Resolve var() in shorthands before pseudo-element filtering
When a shorthand like `background` containing `var()` is used in
a `::selection` rule, the shorthand was filtered out by the pseudo-
element property whitelist before variable resolution could occur.
This left PendingSubstitutionStyleValue longhands unresolved,
causing either a crash or incorrect computed values.

Allow unresolved shorthands to bypass the pseudo-element filter so
variable resolution can proceed. After resolution and expansion
into longhands, filter out any that the pseudo-element does not
support.

Fixes #8625.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 12:46:20 +01:00
Tim Ledbetter
4c48827ed2 LibWeb: Merge duplicate @keyframe rule selector values
Previously, a keyframe with duplicate selector would cause a crash.
2026-03-30 12:42:57 +01:00
Sam Atkins
fd46ade2a2 LibWeb/CSS: Add the env() function to @supports conditions
This was just added to the spec and doesn't yet have WPT coverage, but
it's also pretty trivial.
2026-03-29 21:27:20 +01:00
Tim Ledbetter
657060ccc2 LibWeb: Implement FontFaceSet.check()
This returns true if the given text can be rendered with the fonts in
the set that are fully loaded.
2026-03-27 15:28:59 +00:00
Callum Law
c7b402eff5 LibWeb: Parse @function rules 2026-03-27 11:19:28 +00:00
Callum Law
01394322ac LibWeb: Propagate media query evaluation into @function rules
`CSSFunctionRule`s can contain `CSSMediaRule`s so we need to propagate
evaluation through `CSSFunctionRule`
2026-03-27 11:19:28 +00:00
Callum Law
7d158c47d1 LibWeb: Implement CSSFunctionDeclarations
We also define it as a valid `NestedDeclarationsRule` for the relevant
functions
2026-03-27 11:19:28 +00:00
Callum Law
7f72b01ed3 LibWeb: Implement CSSFunctionDescriptors 2026-03-27 11:19:28 +00:00
Callum Law
19c8eb4146 LibWeb: Implement CSSFunctionRule
Parsing/using this rule will come in later commits
2026-03-27 11:19:28 +00:00
Callum Law
401b0fb734 LibWeb: Expose parse_syntax_component
This will be used when parsing `@function` rules
2026-03-27 11:19:28 +00:00
Callum Law
cd05e1d039 LibWeb: Allow specifying type of nested declarations rule
When parsing declarations within a nested grouping rule, we don't store
these directly, but within a "nested declarations rule", in most cases
this is `CSSNestedDeclarations`, but this isn't always the case e.g.
`@function` rules and others (e.g. @media) within them should instead
use `CSSFunctionDeclarations`
2026-03-27 11:19:28 +00:00
Callum Law
e7243f0090 LibWeb: Support custom descriptors
Some at-rules (i.e. `@function`) require us to support custom
descriptors (e.g. `--foo`).

We do this by adding `DescriptorID::Custom` and using a new
`DescriptorNameAndID` class in a bunch of places where we previously
just used `DescriptorID`
2026-03-27 11:19:28 +00:00
Jelle Raaijmakers
3d2571b46e LibWeb: Implement text-decoration-skip-ink painting
Use Skia's SkTextBlob::getIntercepts() to find where glyph outlines
cross the underline/overline band, then split the decoration line into
segments with gaps around those intersections.
2026-03-26 12:15:36 +00:00
Jelle Raaijmakers
18f01b2c4b LibWeb: Support parsing text-decoration-skip-ink property 2026-03-26 12:15:36 +00:00
Callum Law
761ccdb5e3 LibWeb: Remove special handling of z-index resolved value
Previously we waited until used-value time to apply handling for the
z-index value that we should have applied at declared or computed-value
time, which was papered over by returning the used rather than computed
value as the resolved value. This is no longer required.

This allows us to unmark z-index as requiring a layout node to get
resolved value.
2026-03-26 12:30:01 +01:00
Callum Law
124b142ae4 LibWeb: Simplify z-index handling in ComputedProperites
We now implement clamping and up-on-half rounding for all <integer>
values generically so this is no longer needed
2026-03-26 12:30:01 +01:00
Callum Law
b86377b9dc LibWeb: Clamp CSS <integer> value to i32 at parse time
This matches the behavior of other browsers. Previously we implemented
this at used-value time for z-index specifically.
2026-03-26 12:30:01 +01:00
Callum Law
0ab06e119e LibWeb: Use i32 max for clamping 'infinite' calculated integers
This required us to change our range values from `float`s to `double`s
since `float` can't exactly represent i32 max
2026-03-26 12:30:01 +01:00
Callum Law
0e8956ee30 LibWeb: Round up on half when rounding to nearest integer in CSS 2026-03-26 12:30:01 +01:00
Callum Law
cdc264a62e LibWeb: Validate nested contents when parsing declaration value
Previously we automatically assumed that contents inside functions and
blocks were valid, now we actually check them.
2026-03-26 01:11:39 +00:00
Callum Law
93bd066639 LibWeb: Ensure <declaration-value>? descriptors are valid
Currently this only applies to the `@property` `syntax` descriptor.

As with custom properties in the previous commit we assumed that any
consumed values were valid but that's not the case.
2026-03-26 01:11:39 +00:00
Callum Law
46bebf44c5 LibWeb: Ensure custom property definition is valid <declaration-value>?
Previously we assumed that consumed declarations were always valid but
that isn't the case
2026-03-26 01:11:39 +00:00
Callum Law
6afe2ff27b LibWeb: Limit <ident> to <custom-ident> in @property/syntax
The definition of syntax in the "css-properties-values-api" spec (which
is used for the `@property/syntax` descriptor) is slightly different
from the definition of `<syntax>` in the "css-values" spec (which we
implement) in that it limits literal idents to exclusively
`<custom-ident>`s (i.e. not CSS-wide keywords or "default").

`<custom-ident>`s are also case-sensitive so that behavior is
implemented for syntax matching here as well
2026-03-26 01:11:39 +00:00
Callum Law
cfc2e64b4b LibWeb: Add is_valid_custom_ident function
We repeat this pattern in a couple of places so let's add a single
helper method
2026-03-26 01:11:39 +00:00
Callum Law
283f8e46a4 LibWeb: Only match alternative syntax if entire stream consumed
Previously we would consider an alternative syntax child to be a match
as long as parsing produced a value, even if there were trailing tokens
(which would later invalidate it within `parse_with_a_syntax`). This
meant that we wouldn't consider later alternatives which may actually
produce a valid match.
2026-03-26 01:11:39 +00:00
Callum Law
614a5cf33e LibWeb: Set context for parsing against <foo-percentage> syntax
This means that we correctly parse dimension percentage mixes (i.e.
`calc(10px + 10%)` is a valid `<length-percentage>`)
2026-03-26 01:11:39 +00:00
Callum Law
ed2909674f LibWeb: Add computationally independent check for custom properties
Registered custom properties only accept "computationally independent"
values for their initial value
2026-03-26 01:11:39 +00:00
Callum Law
3b3caa96d9 LibWeb: Don't pass around unnecessary element when parsing with syntax
This wasn't actually used anywhere and was just being recursively passed
around
2026-03-26 01:11:39 +00:00
Psychpsyo
bd91567863 Meta: Ensure that idl files link to draft specs 2026-03-25 16:02:04 +00:00
Luke Wilde
df32da5e86 LibWeb: Make every HTMLElement potentially form-associated
This can be the case for form-associated custom elements, where any
HTML element can be form-associated.
2026-03-25 13:18:15 +00:00
Callum Law
500ca417ce LibWeb: Map logical aliases at compute rather than cascade time
This requires us to front load computation of writing-mode and direction
before we encounter any logical aliases or their physical counterparts
so that we can create a mapping context.

Doing this at compute rather than cascade time achieves a few things:
 1) Brings us into line with the spec
 2) Avoids the double cascade that was previously required to compute
    mapping contexts
 3) We now compute values of logical aliases, while
    `style_value_for_computed_property` maps logical aliases to their
    physical counterparts, this didn't account for all cases (i.e. if
    there was no layout node, Typed OM, etc).
 4) Removes a hurdle to moving other upstream processes (i.e. arbitrary
    substitution function resolution, custom property computation) to
    compute time as the spec requires.
2026-03-25 12:53:22 +00:00
Callum Law
127d10c048 LibWeb: Record cascaded properties relative order
This will be required to perform logical alias mapping at compute time
since we need to know the relative order of logical and physical
property pairs
2026-03-25 12:53:22 +00:00
Callum Law
d0a868dcfb LibWeb: Add method to map from physical to logical property
This will be required in later commit.

The implementation could do with some optimization
2026-03-25 12:53:22 +00:00
Callum Law
d284ff96fe LibWeb: Nest logical property group physical properties
In a later commit we will also add logical properties in here
2026-03-25 12:53:22 +00:00
Callum Law
9bd4dff1aa LibWeb: Remove outdated AD-HOC comment in parse_media_feature
The spec has been updated so this is no longer ad-hoc
2026-03-25 08:18:35 +00:00
Tim Ledbetter
77b9fcf7f9 LibWeb+LibWebView: Select generic font families based on requested style
Pass the requested font weight and slope to generic_font_name() and use
them to select the most suitable font family. Families that have the
exact requested weight are strongly preferred, followed by families with
more style variety.

This ensures that when CSS requests bold text with a generic font family
like `serif`, we select a family that actually supports bold weights
rather than one that only has regular weight.

Co-authored-by: Jelle Raaijmakers <jelle@ladybird.org>
2026-03-24 15:08:24 +01:00
Callum Law
02db1b942b LibWeb: Improve handling of calculated values in <ratio>
We no longer try to resolve calculated values at parse time which means
we support relative lengths.

We now clamp negative values rather than rejecting them at parse time.

Parsing has been inlined into `parse_ratio_value` and `parse_ratio` has
been removed since `parse_ratio_value` was the only caller
2026-03-24 14:00:01 +00:00
Callum Law
f347be8206 LibWeb: Store underlying RatioStyleValue values as StyleValues
Previously we stored a fully formed `Ratio` - this restricted us from
supporting calculated values which will be implemented in a later commit
2026-03-24 14:00:01 +00:00
Callum Law
9f8ffc3ad0 LibWeb: Move RatioStyleValue methods into implementation file
We will be expanding this class in a later commit so it makes sense to
have an implementation file
2026-03-24 14:00:01 +00:00
Callum Law
201b609450 LibWeb: Store MediaFeatureValue underlying value as StyleValue
This simplifies handling in some cases and gets us a step closer to
removing the `OrCalculated` classes
2026-03-24 14:00:01 +00:00