Commit graph

486 commits

Author SHA1 Message Date
Callum Law
13ce2d1857 LibWeb: Parse the scroll-timeline shorthand CSS property
The remaining failing tests in scroll-timeline-shorthand.html are due to
either:
 a) incorrect tests, see web-platform-tests/wpt#56181 or;
 b) a wider issue where we collapse coordinating value list longhand
properties to a single value when we shouldn't.
2025-11-28 13:24:11 +00:00
Callum Law
992b0a4dc6 LibWeb: Parse the scroll-timeline-axis CSS property 2025-11-28 13:24:11 +00:00
Callum Law
e95f326f3d LibWeb: Parse the scroll-timeline-name CSS property 2025-11-28 13:24:11 +00:00
Sam Atkins
9a1352fc17 LibWeb/CSS: Support calculated angles in conic-gradient() 2025-11-21 11:36:28 +01:00
Hendiadyoin1
bcd01da91d AK: Use Deducing this for OptionalBase
This is taken from and akin to
https://github.com/SerenityOS/serenity/pull/25894
2025-11-20 16:27:07 +01:00
Sam Atkins
c4b9e7eadf LibWeb: Parse and propagate extended text-indent property values
CSS Text 3 gives `text-indent` a couple of optional keywords to control
which lines are affected. This commit parses them, but doesn't yet do
anything with them.
2025-11-20 16:02:40 +01:00
Sam Atkins
7d2f631d4c LibWeb/CSS: Handle whitespace better in font-language-override strings
The rules for strings here are:
- 4 ASCII characters long
- Shorter ones are right-padded with spaces before use
- Trailing whitespace is always removed when serializing

We previously always padded them during parsing, which was incorrect.
This commit flips it around so we trim trailing whitespace when parsing.

We don't yet actually use this property's value for anything. Once we do
so, maybe we'll care more about them being stored as 4 characters
always, but for now this avoids us needing a special step during
computation.
2025-11-18 17:22:03 +01:00
Sam Atkins
1ae4429f3b LibWeb/CSS: Stop inserting whitespace in TokenStream::dump_string()
Another one I missed before!
2025-11-17 19:11:48 +01:00
Sam Atkins
eaece1d12c LibWeb/CSS: Stop inserting whitespace when serializing SimpleBlocks
I missed this in #6646. It mostly affects debug logging, but it's nice
when logs reflect reality.
2025-11-17 19:11:48 +01:00
Sam Atkins
48854a8e74 LibWeb/CSS: Resolve calc percentages as lengths in basic-shape functions
Fixes a crash on https://www.lego.com/en-gb/product/game-boy-72046 :^)

The apparent regressions in clip-path-interpolation-xywh-rect.html are
because of false positives. Something about the test was causing it to
compare two wrong values that happened to be the same. Now one of the
values is correct, they don't match.
2025-11-14 09:55:09 +00:00
Sam Atkins
7aef3245ea LibWeb/CSS: Expose method for parsing a type of StyleValue
In a few places, user code wants to parse a `<color>` or `<length>` etc,
but we didn't have a way to do so, so they would do something
similar-ish instead, like parse the value of the `color` property.
Let's make that available instead.
2025-11-14 09:55:02 +00:00
Psychpsyo
100f37995f Everywhere: Clean up AD-HOC and FIXME comments without colons 2025-11-13 15:56:04 +01:00
Callum Law
d6bb247bf7 LibWeb: Reject non-exclusive none in text-decoration-line
This updates the `parse_text_decoration_line_value` to reject values
which non-exclusively include `none` e.g. `underline none`.

It also simplifies handling by always producing a Vector (except for
`none`) and adding VERIFY_NOT_REACHED in more places which shouldn't be
reachable.
2025-11-13 10:15:02 +01:00
Tim Ledbetter
df23b42b37 LibWeb: Don't store custom name on StyleProperty
This reduces time spent in `~StyleProperty()` from 2.18% to 0.67% on
https://cloudflare.com.
2025-11-12 11:19:37 +01:00
Sam Atkins
427d7fabd7 LibWeb/CSS: Stop copying the input in parse_css_value()
Now that we don't strip out whitespace, this method was copying the
input TokenStream into a Vector, and then creating new TokenStreams
from that. So, stop doing that and use the input TokenStream instead.
2025-11-03 11:23:21 +00:00
Sam Atkins
2bbf578737 LibWeb/CSS: Commit transaction when parsing valid anchor()
I'm honestly not sure how this worked before.
2025-11-03 11:23:21 +00:00
Sam Atkins
1b1bb3b897 LibWeb/CSS: Remove "strip-whitespace" flag from Properties.json
Now that it's not on any properties, remove support for it entirely.
2025-11-03 11:23:21 +00:00
Sam Atkins
4286a2c154 LibWeb/CSS: Handle whitespace properly in quotes property 2025-11-03 11:23:21 +00:00
Sam Atkins
b12851427b LibWeb/CSS: Handle whitespace properly in transformation properties
We can no longer rely on the remaining token count, so these required
significant rearranging.
2025-11-03 11:23:21 +00:00
Sam Atkins
12588b6f9d LibWeb/CSS: Handle whitespace properly in content property 2025-11-03 11:23:21 +00:00
Sam Atkins
971c0d0126 LibWeb/CSS: Handle whitespace properly for scrollbar properties
Imported a WPT test that regressed without these changes.
2025-11-03 11:23:21 +00:00
Sam Atkins
4f5126e52f LibWeb/CSS: Handle whitespace properly in list-style properties 2025-11-03 11:23:21 +00:00
Sam Atkins
8c8168c65c LibWeb/CSS: Handle whitespace properly in grid properties 2025-11-03 11:23:21 +00:00
Sam Atkins
123a3dbbc5 LibWeb/CSS: Handle whitespace properly in mask properties 2025-11-03 11:23:21 +00:00
Sam Atkins
941ad24abd LibWeb/CSS: Handle whitespace properly in column properties 2025-11-03 11:23:21 +00:00
Sam Atkins
cb3773755a LibWeb/CSS: Handle whitespace properly in font properties 2025-11-03 11:23:21 +00:00
Sam Atkins
372ae7c697 LibWeb/CSS: Reformat anchor-size() allowed properties, one per line
Having them grouped as they were is nice, but clang-format 21 really
hates these having multiple values per line.
2025-11-03 11:23:21 +00:00
Sam Atkins
39e0d06987 LibWeb/CSS: Discard whitespace at the start of simple parsing functions 2025-11-03 11:23:21 +00:00
Sam Atkins
a348f919be LibWeb/CSS: Handle whitespace properly for shadow properties 2025-11-03 11:23:21 +00:00
Sam Atkins
c5fa5fb80e LibWeb/CSS: Handle whitespace properly for border-image properties 2025-11-03 11:23:21 +00:00
Sam Atkins
a2cd5d5ec8 LibWeb/CSS: Handle whitespace properly for border-radius properties 2025-11-03 11:23:21 +00:00
Sam Atkins
e3332dc5c6 LibWeb/CSS: Handle whitespace properly for background properties 2025-11-03 11:23:21 +00:00
Sam Atkins
821bf4a289 LibWeb/CSS: Discard whitespace when parsing comma-separated lists 2025-11-03 11:23:21 +00:00
Sam Atkins
9dc9e98d14 LibWeb/CSS: Skip whitespace before and after property values
To make this a bit easier, we now wrap the per-property parsing
functions in a parse_all_as() lambda, which skips whitespace, and
returns an error if parsing failed or there are trailing tokens.
2025-11-03 11:23:21 +00:00
Sam Atkins
6d38ad32cb LibWeb/CSS: Let Properties.json specify whether to strip whitespace
Removing all whitespace before parsing StyleValues seemed like a good
idea back when I did it, but causes issues. Serialization cares about
whether there was whitespace or not, and we also weren't removing
whitespace from inside blocks and functions so it was inconsistent
whether we needed to deal with whitespace or not.

So currently, some parsing code is conscious of whitespace, some isn't,
and some tries to be but is incorrect. Rather than try to fix all of
this in a single large, messy change, this commit introduces
a "strip-whitespace" flag to Properties.json. We can then disable
whitespace-stripping a few properties at a time and debug any issues
more easily. Eventually (hopefully soon), this will go away entirely.
2025-11-03 11:23:21 +00:00
Callum Law
ed0b741a26 LibWeb: Remove special handling of all property for animations
There were a couple places that we had special handling for the `all`
property but since d31a58a was merged we can treat it the same as any
other shorthand
2025-11-02 23:54:00 +01:00
Sam Atkins
9c06d58b2e LibWeb/CSS: Implement and use ValueType::DashedIdent
Reduces the repeated code for parsing these, and makes them available to
the generic value parser.
2025-10-30 11:33:45 +00:00
InvalidUsernameException
35254d17d1 LibWeb/CSS: Do not crash when parsing some multi-layer mask shorthands
This fixes a silly bug where we would crash when parsing a multi-layer
mask shorthand property that contained the no-clip keyword but no value
for mask-origin.

Fixes a crash when parsing the CSS of https://www.browserbase.com/. The
site still has other, unrelated problems though.
2025-10-28 23:50:46 -07:00
Lorenz A
14dba82202 LibWeb: Allow whitespace in not after a boolean-expr-group 2025-10-28 21:54:48 -07:00
Callum Law
5381146e85 LibWeb: Include PropertyID.h in fewer header files
This reduces the size of the recompile when PropertyID.h is modified
from ~1500 to ~125
2025-10-27 14:50:54 +00:00
Callum Law
8417d74328 LibWeb: Parse transition property as a coordinating list shorthand
We don't need all this specific logic for parsing the `transition`
property - we also now maintain `none` as such until use time which
gains us a couple extra tests
2025-10-23 10:09:11 +01:00
Callum Law
94c788f2e0 LibWeb: Make animation parsing logic reusable
This is useful for parsing of other coordinating list shorthands
2025-10-23 10:09:11 +01:00
Callum Law
f49cf75d44 LibWeb: Don't pass unnecessary PropertyComputationDependencies struct
Since we now have access to the `AbstractElement` through the
`ComputationContext` we can just set the flag that this element relies
on tree counting functions directly, no need to pass this struct around.
2025-10-22 00:01:30 +02:00
Callum Law
2404f95e03 LibWeb: Invalidate style for tree counting functions when required
We mark any element that relies on tree counting functions as needing a
style update when a sibling is inserted/removed.
2025-10-20 16:12:08 +01:00
Callum Law
e9036c7c75 LibWeb: Support tree counting functions within calc() 2025-10-20 16:12:08 +01:00
Callum Law
55bcdcf824 LibWeb: Set up initial infrastructure for non-math functions in calc
There are some non-math functions (such as tree counting functions)
which we should allow within `calc()`s . This commit implements the
initial infrastructure for this.

We don't yet parse any of these non-math functions in
`parse_a_calculation` so there is no functional change.
2025-10-20 16:12:08 +01:00
Callum Law
831e471444 LibWeb: Support top-level tree counting functions
Adds support for `sibling-index()` and `sibling-count()` when parsing
`<number>` and `<integer>`. This is achieved by a new
`TreeCountingFunctionStyleValue` class which is converted within
`absolutized` to `NumberStyleValue` and `IntegerStyleValue` respectively

There are still a few kinks to work out in order to support these
everywhere, namely:
 - There are some `StyleValue`s which aren't absolutized (i.e. those
   which are stored within another `StyleValue` without an
   `absolutize()` method.
 - We don't have a way to represent this new `StyleValue` within
   `{Number,Integer}OrCalculated`. This would be fixed if we were to
   instead just use the `StyleValue` classes until style computation at
   which time they would be absolutized into their respective
   primitives (double, i64, etc) bypassing the need for *OrCalculated
   entirely.
2025-10-20 16:12:08 +01:00
Callum Law
fd31fbd84b LibWeb: Add method for whether tree-counting function is allowed
Some contexts (e.g. descriptors, media conditions) don't allow tree
counting functions, this commit adds an easy way to check if the current
value context is one of those.
2025-10-20 16:12:08 +01:00
Callum Law
fbc6a4c96f LibWeb: Allow setting initial value context when creating CSS parser 2025-10-20 16:12:08 +01:00
Sam Atkins
7ba496b798 LibWeb/CSS: Add ValueTypes for <foo-percentage> 2025-10-20 13:55:23 +01:00