Commit graph

1405 commits

Author SHA1 Message Date
Sam Atkins
84f0f37a29 LibWeb/CSS: Implement StylePropertyMap::set()
With this commit, only direct CSSStyleValues created from internal
StyleValues can be converted back to a StyleValue. More subtests will
pass as create_an_internal_representation() is implemented for the
various CSSStyleValue subclasses. :^)

Gets us... a LOT of WPT passes, because there's a ton of coverage for
each property.
2025-10-04 22:57:00 +02:00
Sam Atkins
927ce89864 LibWeb/CSS: Make CSSStyleValue::parse_a_css_style_value() public
Needed by StylePropertyMap.
2025-10-04 22:57:00 +02:00
Sam Atkins
2f3053bc64 LibWeb/CSS: Use FlyString for StylePropertyMap property arguments
The bindings are able to give us FlyString, and that's the type we use
for property names, so let's use that instead of String.
2025-10-04 22:57:00 +02:00
Sam Atkins
7778f3b279 LibWeb/CSS: Allow setting StyleValues on CSSStyleProperties directly
This is used by StylePropertyMap - we already have verified that the
value is acceptable for the property before this point.
2025-10-04 22:57:00 +02:00
Sam Atkins
2de4fe8104 LibWeb/CSS: Store StyleValue pointer instead of string on CSSStyleValue
When setting style to a CSSStyleValue we need to convert it to a
StyleValue. If we already have one, we might as well use it avoid the
work of serialization and re-parsing.

I realised I misunderstood what "constructed from a USVString" means, so
I've adjusted based on that. It does raise a question on what the source
USVString is if that string resulted in multiple CSSStyleValues being
created - see the linked issue.
2025-10-04 22:57:00 +02:00
Sam Atkins
1e1752b33b LibWeb/CSS: Mark list-valued properties
Typed-OM requires us to have a generic way of asking "does property X
accept a list or a single value?" so this exists mainly for that.
Coordinating lists are annotated too - I'm not clear on exactly what
will be needed for those, but giving them a unique value now at the
worst will make them easier to find later.
2025-10-04 22:57:00 +02:00
Sam Atkins
b3ad4be90c LibWeb/CSS: Ensure properties can be computed from "basic" StyleValues
This commit modifies the `compute_foo()` code for `font-style` and
`math-depth`. They previously assumed that their StyleValue was always
a special kind: FontStyleStyleValue or MathDepthStyleValue. This was
always true, because that's how we parse them, but it stops being true
once StylePropertyMap is involved: An author can set font-style to a
CSSKeywordValue of "italic", and this should work.

There are multiple ways that we could solve this, but the simplest and
easiest to maintain seems to be to handle those more basic StyleValues
in this computation code. Going forward, we'll have to be aware that
similar properties could have a basic StyleValue from the typed-OM
instead of the property-specific one we'd expect.
2025-10-04 22:57:00 +02:00
Sam Atkins
ccd9bb0286 LibWeb/CSS: Remove outdated use of PropertyID::Invalid
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 doesn't exist any more, but did when I submitted the
PropertyNameAndID PR. Oops!
2025-10-02 14:25:48 +01:00
Sam Atkins
561fdc0228 LibWeb/CSS: Use PropertyNameAndID in Parser::convert_to_style_property() 2025-10-02 13:46:04 +01:00
Sam Atkins
d014c6818a LibWeb/CSS: Use PropertyNameAndID in CSSSV::parse_a_css_style_value() 2025-10-02 13:46:04 +01:00
Sam Atkins
2906176500 LibWeb/CSS: Update CSS::supports() to match current spec
Also introduce usage of PropertyNameAndID.
2025-10-02 13:46:04 +01:00
Sam Atkins
ce7a8418ed LibWeb: Add and use CSSStyleProperties helpers in Algorithms code 2025-10-02 13:46:04 +01:00
Sam Atkins
2f02ccc5c1 LibWeb/CSS: Take PropertyNameAndID in in style-only CSSSD methods
StylePropertyMap only ever works with style properties - never
descriptors. Switching `has_property()` and `get_property_style_value()`
to taking PropertyNameAndID skips some duplicate work.
2025-10-02 13:46:04 +01:00
Sam Atkins
47062424fb LibWeb/CSS: Pull out and expand CSSStyleProperties::get_property()
This awkwardly sat as the internal final API for getting a StyleProperty
directly for a given PropertyID, and also the external API for getting
the StyleProperty for a PropertyID. For the latter, it lacked support
for shorthands, and for both it lacked support for custom properties.

This commit:
- Moves the code from get_property() into get_direct_property()
- Makes get_property() call get_property_internal() to support
  shorthands
- Adds custom property support for get_direct_property()

This also wins us some WPT points for StylePropertyMap.
2025-10-02 13:46:04 +01:00
Sam Atkins
8f456d781c LibWeb/CSS: Take PropertyNameAndID in get_property_internal() 2025-10-02 13:46:04 +01:00
Sam Atkins
d60c8d80e5 LibWeb: Rename CSSStyleProperties::property() -> get_property()
Verbs are nice, and `property` is too useful as a variable name.
2025-10-02 13:46:04 +01:00
Sam Atkins
38664cb79f LibWeb/CSS: Use PropertyNameAndID in CSSSP::set/remove_property()
This saves the PropertyID overloads from converting the ID to a string,
and then back to an ID again.
2025-10-02 13:46:04 +01:00
Sam Atkins
a30afafcc9 LibWeb/CSS: Use FlyString for CSSStyleValue property name 2025-10-02 13:46:04 +01:00
Sam Atkins
a8312bf571 LibWeb/CSS: Use FlyString const& for property name IDL parameters 2025-10-02 13:46:04 +01:00
Sam Atkins
c0ef7f09e4 LibWeb/CSS: Use PropertyNameAndID instead of old Variant 2025-10-02 13:46:04 +01:00
Sam Atkins
3af8e705c1 LibWeb/CSS: Introduce a PropertyNameAndID type
We often want to call a function with either a built-in or custom
property, and that means either passing it as a string (and converting
back and forth between strings and PropertyIDs) or using the
PropertyIDOrCustomPropertyName variant, which complicates user code.
PropertyNameAndID is intended to make that easier: Create it with a
string or PropertyID, and it can tell you either one.
2025-10-02 13:46:04 +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
bbfc3a0f5e LibWeb/CSS: Use a bitfield for Containment flags
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
Shrinks the struct down from 5 bytes to 1.
2025-09-30 22:05:45 +01: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
b0bb775c05 LibWeb/CSS: Remove unnecessary CSS:: namespaces from ComputedValues.h
These are just visual noise.
2025-09-30 22:05:45 +01:00
Sam Atkins
a098b5fcc4 LibWeb/CSS: Remove PropertyID::Invalid 2025-09-30 15:21:09 +02:00
Sam Atkins
56c7d838f0 LibWeb/CSS: Stop using PropertyID::Invalid in border parsing 2025-09-30 15:21:09 +02:00
Sam Atkins
7d4b2d10e4 LibWeb/CSS: Remove default value for parse_css_value() PropertyID
Every user provides this, and it's not clear what passing
PropertyID::Invalid here actually means.
2025-09-30 15:21:09 +02:00
Tim Ledbetter
3299ea97c6 LibWeb: Treat word-wrap as an alias for overflow-wrap
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-30 13:50:53 +01:00
luizgfc
13748a8c19 LibWeb: Make Custom Properties cascading consider !important
Make so that !important properties are always applied last, prioritizing
them over normal properties
2025-09-30 09:54:10 +01:00
Pascal Pomper
5b1eba7ac8 LibWeb: Position absolute block-level boxes below previous siblings
Some checks are pending
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / macOS, arm64, Sanitizer, 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
Whether an absbox is positioned below or to the right of its previous
sibling in an `InlineFormattingContext` is determined by the
display-outside value before blockification, so we store the
pre-blockification `display` value in `ComputedValues` to access it in
`InlineFormattingContext` and position the box accordingly.
2025-09-29 18:37:53 +02:00
Tim Ledbetter
fda5ea8277 LibWeb: Correctly resolve position-area computed value 2025-09-29 12:48:13 +02:00
Tim Ledbetter
eb571a1a46 LibWeb: Parse the position-area property 2025-09-29 09:53:27 +02:00
Tim Ledbetter
bf1564388d LibWeb: Serialize grid-template shorthand correctly 2025-09-28 17:34:58 +02:00
Sam Atkins
1ccf37a6ac LibWeb/CSS: Expose StyleProperty outside of LibWeb 2025-09-26 22:31:07 +02:00
Sam Atkins
aa8bf6372f LibWeb/CSS: Inline EasingStyleValue::CubicBezier::operator==()
For whatever reason, this method in particular ends up failing to link
into WebContent with a subsequent change. It's small and simple, so
just inline it.
2025-09-26 22:31:07 +02:00
Sam Atkins
9ebdb58604 LibWeb/CSS: Add operator== to StyleSheetIdentifier
Only the rule count isn't part of identifying the style sheet.
2025-09-26 22:30:20 +02:00
Callum Law
c4d6deb5c7 LibWeb: Parse widows CSS property 2025-09-26 16:32:54 +01:00
Callum Law
3d85532752 LibWeb: Parse orphans CSS property 2025-09-26 16:32:54 +01:00
Tim Ledbetter
b64cb89b9d LibWeb: Implement compositing of font-variation-settings 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-26 11:20:54 +01:00
Tim Ledbetter
f9452b77b7 LibWeb: Implement interpolation of font-variation-settings values 2025-09-26 11:20:54 +01: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
Tim Ledbetter
6cb0f0fbcd LibWeb: Ensure large animation progress values don't overflow 2025-09-26 11:20:54 +01:00
Tim Ledbetter
d18d40f7b9 LibWeb: Handle interpolation of grid track size lists
This allows the `grid-template-rows` and `grid-template-columns`
properties to be correctly interpolated.
2025-09-26 11:15:08 +01:00
Tim Ledbetter
436e9c317a LibWeb: Extract commonly used interpolation lambdas into methods 2025-09-26 11:15:08 +01:00
Tim Ledbetter
f438c1721c LibWeb: Add GridTrackSize constructor that initializes values explicitly 2025-09-26 11:15:08 +01:00
Tim Ledbetter
56d5177eda LibWeb: Add length percentage getter to CSS::Size 2025-09-26 11:15:08 +01:00
Tim Ledbetter
d9b66b22a6 LibWeb: Add type getter to CSS::Size 2025-09-26 11:15:08 +01:00
Callum Law
9ee9be720c LibWeb: Collapse & trim whitespace when serializing UnresolvedStyleValue 2025-09-26 07:30:10 +01:00
Andreas Kling
321809320b LibWeb+LibGfx: Remove Path::close_all_subpaths()
As it turns out, SkPath already behaves the way we need for SVG and HTML
canvas elements. Less work for us, yay! This removes a 5% item from the
profile when scrolling on https://imdb.com/

Note that there's a tiny screenshot test expectation change due to
minor antialiasing differences when we no longer do our redundant
subpath modifications.
2025-09-25 21:42:52 +02:00