Commit graph

141 commits

Author SHA1 Message Date
Tim Ledbetter
27cdf3a2c8 LibWeb: Parse the position-anchor property 2025-10-07 11:30:23 +01:00
Tim Ledbetter
7374a07fbc LibWeb: Parse the anchor-name property 2025-10-07 11:30:23 +01:00
Callum Law
e772a992be LibWeb: Store CursorStyleValue sub-values directly
Storing these within NumberOrCalculated is unnecessary
2025-10-07 10:50:01 +01:00
Callum Law
25192d3c20 LibWeb: Store BorderRadiusStyleValue sub-values directly
Storing these within LengthPercentage is unnecessary
2025-10-07 10:50:01 +01:00
Callum Law
2ebf446cbf LibWeb: Store BackgroundSizeStyleValue sub-values directly
Storing these within LengthPercentage is unnecessary
2025-10-07 10:50:01 +01:00
Tim Ledbetter
51ea4a7e2a LibWeb: Align position-area values with the specification
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
This change renames the following `position-area` values:

x-self-start -> self-x-start
x-self-end -> self-x-end
y-self-start -> self-y-start
y-self-end -> self-y-end
span-x-self-start -> span-self-x-start
span-x-self-end -> span-self-x-end
span-y-self-start -> span-self-y-start
span-y-self-end -> span-self-y-end
2025-10-05 15:48:21 +01:00
Sam Atkins
89c89470ef LibWeb/CSS: Stop rejecting declarations with vendor-prefixed keywords
property_accepts_type() only looks at the property itself, not any
longhands it might have, so we thought that `font` didn't accept
`<custom-ident>`s, and seeing "-apple-..." makes us throw out the
declaration even though it's valid as a font name.

We'll reject these like any other unrecognized value if it's somewhere
that's not supported, so this was really just an optimization for a
rare edge case, and removing the check doesn't have any observable
effect except fixing this bug and any similar cases.

Changing property_accepts_type() to look at longhands is not
straightforward, as not all longhand values are valid in the shorthand.
2025-10-02 13:26:26 +02:00
Sam Atkins
3916e33276 LibWeb/CSS: Parse the container-type property
This applies size, inline-size, and style containment in some cases.
There are other WPT tests for that, but we seem to not implement enough
of containment for this to have an effect so I've not imported those.

Gets us 35 WPT subtests.
2025-09-30 22:05:45 +01:00
Sam Atkins
56c7d838f0 LibWeb/CSS: Stop using PropertyID::Invalid in border parsing 2025-09-30 15:21:09 +02:00
Tim Ledbetter
eb571a1a46 LibWeb: Parse the position-area property 2025-09-29 09:53:27 +02:00
Tim Ledbetter
83ad5ce8a2 LibWeb: Don't deduplicate font-variation-settings values at parse time
We now only deduplicate and sort the computed value of the
`font-variation-settings` property.
2025-09-26 11:20:54 +01:00
Callum Law
869442c206 LibWeb: Parse animation shorthand as comma separated list
We now parse (but don't yet trigger animations for) multiple definitions
within a single animation property.
2025-09-24 11:58:20 +01:00
Callum Law
030e6d7c9b LibWeb: Parse animation-* properties as comma separated lists
We are yet to actually support having more than one value but this gets
us closer and gains us some WPT tests in the process.
2025-09-24 11:58:20 +01:00
Tim Ledbetter
0aec8912c9 LibWeb: Remove special casing for font oblique angle from CSS parser 2025-09-24 11:40:38 +01:00
Tim Ledbetter
27de4fdcea LibWeb: Clamp interpolated font-style angle
This change adds the allowed angle range to the `font-style` property
definition. This allows these angles to be clamped after interpolation.

Ideally, the generator should be updated so that we can specify the
angle is in degrees. This would allow us to make use of this
information during parsing, which we can't do currently because we
don't know what the unit is. Using this value for interpolation
purposes is fine because the angle has been converted to its canonical
unit by this point.
2025-09-24 11:40:38 +01:00
Callum Law
e17d91780d LibWeb: Clamp computed value for font-style oblique angle
Values outside [-90deg,90deg] are invalid and should be clamped
2025-09-19 10:06:33 +01:00
Callum Law
004bd3dc8f LibWeb: Clamp calc()'d shadow blur radius to positive values
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
2025-09-18 15:21:22 +01:00
Callum Law
19e3ddc0c6 LibWeb: Simplify parse_single_shadow_value
The `possibly_dynamic_length` function was unnecessary and can be
replaced with the standard `parse_length_value`
2025-09-18 15:21:22 +01:00
Callum Law
c3a78d2884 LibWeb: Don't include spread distance when serializing text-shadow
We shouldn't include spread distance when serializing `text-shadow` as
it is not supported unlike `box-shadow` - to achieve this we store
whether this is a text or box shadow within the ShadowStyleValue and
serialize appropriately.
2025-09-18 15:21:22 +01:00
Callum Law
1ac7b47764 LibWeb: Disallow spread distance value when parsing text-shadow
`text-shadow` does not support setting a value for spread distance
unlike `box-shadow`.
2025-09-18 15:21:22 +01:00
Callum Law
b0e3af7d10 LibWeb: Parse text-underline-position property
This introduces the `TextUnderlinePositionStyleValue` class, it is
possible to represent `text-underline-position` as a `StyleValueList`
but would have required ugly workarounds for either serialization or in
`ComputedProperties::text_underline_position`
2025-09-15 15:24:20 +01:00
Callum Law
a6812e1005 LibWeb: Store parsed shorthands in canonical order 2025-09-15 15:24:20 +01:00
Callum Law
50239b58aa LibWeb: Reset border-image to initial value when using border
Also includes associated handling for serialization of the `border`
shorthand.
2025-09-15 08:42:22 +01:00
Callum Law
a7e5ded188 LibWeb: Add generic logic for parsing "positional-value-list-shorthands"
Continues the work started in #5386 to simplify handling of positional
value list shorthand properties.

Previously we would parse these as `StyleValueList`s and then rely on
`StyleComputer::for_each_property_expanding_shorthands` to expand them
into longhands.

This required a bit of work to handle `ShorthandStyleValue`s for the
`@page` `margin` descriptor.
2025-09-09 11:45:47 +02:00
Callum Law
b1e77b3522 LibWeb: Parse longhands of border as ShorthandStyleValues
Previously we would instead parse these as single values and rely on
ad-hoc functionality in `for_each_property_expanding_shorthands` to
expand them to longhands.

This gets us a step closer to removing that ad-hoc functionality.
2025-09-09 11:45:47 +02:00
Callum Law
246a1c41ff LibWeb: Don't resolve calc'd opacity percentages at parse time
This behaviour should only apply to literal percentages as clarified
here: 4ee8429

We were also doing this wrong by converting the numeric type of the calc
to Length which was causing values to be defaulted to 1 instead (hence
the new passing tests for computed values as well)
2025-09-08 11:03:32 +01:00
Psychpsyo
9ea8b5a0a3 LibWeb: Add CSS column-height property
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
2025-09-07 15:59:39 +01:00
Sam Atkins
04622f3940 LibWeb/CSS: Use LengthPercentageOrAuto for background sizes
...instead of `auto` Lengths.

This also fixes interpolating between two `auto` `<bg-size>`s, which
fixes a lot of animation tests for both `background-size` and `mask`.
2025-09-04 13:31:24 +01:00
Tim Ledbetter
a87a9156d5 LibWeb/CSS: Parse the paint-order property 2025-08-28 10:31:09 +01:00
Sam Atkins
5bdc2981e3 LibWeb/CSS: Rename CSSNumericType to NumericType
The CSSNumericType defined in the spec is a simple dictionary which is
only used for OM purposes. This NumericType class is used internally
and matches the more abstract definition of a "type".
2025-08-22 09:48:30 +01:00
Tim Ledbetter
4f663ca6e7 LibWeb: Parse the will-change property
This property provides a hint to the rendering engine about properties
that are likely to change in the near future, allowing for early
optimizations to be applied.
2025-08-18 12:36:37 +01:00
Callum Law
2af7016a77 LibWeb: Rename ValueType::OpenTypeTag to ValueType::OpentypeTag
This is the correct capitalization in line with what it is called in the
spec "opentype-tag".
2025-08-11 17:10:04 +01:00
Sam Atkins
6cad3f1921 LibWeb/CSS: Rename CSSColorValue -> ColorStyleValue
The typed-om class will be a separate thing.
2025-08-08 15:19:03 +01:00
Sam Atkins
99bce9a94d LibWeb/CSS: Replace CSSUnitValue with DimensionStyleValue
CSSUnitValue is a typed-om type which we will implement separately in
the future. However, it still seems useful to give our dimension values
a base class. (Maybe they could be templated in the future?) So instead
of deleting it entirely, rename it to DimensionStyleValue and make its
API match our style better.
2025-08-08 15:19:03 +01:00
Sam Atkins
7157d19f56 LibWeb/CSS: Separate IntegerSV and NumberSV from CSSUnitValue
This inheritance exists for typed-om classes, but StyleValues aren't
typed-om.

Somehow this makes our z-index interpolation slightly more correct. 🎉
2025-08-08 15:19:03 +01:00
Sam Atkins
4e92ab52e3 LibWeb/CSS: Rename CSSKeywordValue -> KeywordStyleValue
The typed-om CSSKeywordValue will need to be a separate class.
2025-08-08 15:19:03 +01:00
Sam Atkins
c57975c9fd LibWeb: Move and rename CSSStyleValue to StyleValues/StyleValue.{h,cpp}
This reverts 0e3487b9ab.

Back when I made that change, I thought we could make our StyleValue
classes match the typed-om definitions directly. However, they have
different requirements. Typed-om types need to be mutable and GCed,
whereas StyleValues are immutable and ideally wouldn't require a JS VM.

While I was already making such a cataclysmic change, I've moved it into
the StyleValues directory, because it *not* being there has bothered me
for a long time. 😅
2025-08-08 15:19:03 +01:00
Callum Law
39fdcbc526 LibWeb: Improve support for CalculatedStyleValue in translate
- Omit calcs that are resolved to `0px` from the serialized value
- Allow CSV to be the 'Z' component in interpolated value.
- Allow calcs with mixed percentages in the first two arguments.

To achieve the third item above the concept of a "special" value parsing
context has been added - this will also be useful for instance for
different arguments of color functions having different contexts.

Gains us 23 WPT tests
2025-08-08 09:45:00 +01:00
InvalidUsernameException
39b64c9b5c LibWeb/CSS: Parse mask shorthand-property into longhands
This commit regresses a couple tests related to the mask shorthand
property. This is because we now parse the longhands but there are
errors related to serialization. Some of the failures are fixed again in
the next commit. However, for some animation tests this is not the case.
Those failures were simply masked by the fact that we did not parse the
property correctly.
2025-08-06 23:09:07 +01:00
InvalidUsernameException
5fca78e0f9 LibWeb/CSS: Parse mask-image property with multiple values 2025-08-06 23:09:07 +01:00
InvalidUsernameException
f953196cb4 LibWeb/CSS: Parse mask-clip property 2025-08-06 23:09:07 +01:00
InvalidUsernameException
eea6792cf7 LibWeb/CSS: Parse mask-origin property 2025-08-06 23:09:07 +01:00
InvalidUsernameException
866e12f688 LibWeb/CSS: Parse mask-size property 2025-08-06 23:09:07 +01:00
InvalidUsernameException
7c5f1a93ed LibWeb/CSS: Parse mask-repeat property 2025-08-06 23:09:07 +01:00
InvalidUsernameException
add3a095d8 LibWeb/CSS: Rename background-repeat related symbols to align with spec
These will be used for the mask-repeat property as well in an upcoming
commit, hence the more generic names. Also, this more closely matches
the names used in the spec.
2025-08-06 23:09:07 +01:00
InvalidUsernameException
667f195d1e LibWeb/CSS: Parse mask-position property 2025-08-06 23:09:07 +01:00
InvalidUsernameException
d022eea9fc LibWeb/CSS: Parse mask-mode property 2025-08-06 23:09:07 +01:00
InvalidUsernameException
22d7a58998 LibWeb/CSS: Parse mask-composite property 2025-08-06 23:09:07 +01:00
Callum Law
46153910ec LibWeb: Update to_color to take ColorResolutionContext
Using a generic context argument will allow us to resolve colors in
places where we have all the required information but not in the form of
a layout node as was expected previously.
2025-08-04 11:29:05 +01:00
Sam Atkins
dc91688f18 LibWeb/CSS: Use ErrorReporter for property/descriptor parsing errors 2025-08-04 10:50:09 +01:00