Commit graph

747 commits

Author SHA1 Message Date
Sam Atkins
6a6995cb12 LibWeb: Make text-decoration-line parsing match other properties 2023-12-26 15:32:32 +00:00
Sam Atkins
ed77dee405 LibWeb: Parse text-decoration property using TokenStream 2023-12-26 15:32:32 +00:00
Sam Atkins
513dee04d4 LibWeb: Parse place-self property using TokenStream 2023-12-26 15:32:32 +00:00
Sam Atkins
5a8f57f7b3 LibWeb: Parse place-items property using TokenStream 2023-12-26 15:32:32 +00:00
Sam Atkins
61d6f611cb LibWeb: Parse place-content property using TokenStream 2023-12-26 15:32:32 +00:00
Sam Atkins
4f773a7dae LibWeb: Parse overflow property using TokenStream
Also simplify it a bit. We don't need to handle 1 / 2 values separately,
but past Sam didn't realise that.
2023-12-26 15:32:32 +00:00
Sam Atkins
0578bec655 LibWeb: Parse math-depth property using TokenStream
We don't need to skip whitespace at the top level because that's already
done before we're called. But we do still have to skip it inside the
`add()` function
2023-12-26 15:32:32 +00:00
Sam Atkins
6e0a550a03 LibWeb: Parse list-style property using TokenStream 2023-12-26 15:32:32 +00:00
Sam Atkins
14e2e2bac4 LibWeb: Parse grid track placements using TokenStream
I'm not entirely happy with this, but I barely understand grid, and this
does still work.
2023-12-26 15:32:32 +00:00
Shannon Booth
83758d4cdd LibWeb: Wrap PseudoElements stored in SimpleSelector in a class
No functional impact intended. This is just a more complicated way of
writing what we have now.

The goal of this commit is so that we are able to store the 'name' of a
pseudo element for use in serializing 'unknown -webkit-
pseudo-elements', see:

https://www.w3.org/TR/selectors-4/#compat

This is quite awkward, as in pretty much all cases just the selector
type enum is enough, but we will need to cache the name for serializing
these unknown selectors. I can't figure out any reason why we would need
this name anywhere else in the engine, so pretty much everywhere is
still just passing around this raw enum. But this change will allow us
to easily store the name inside of this new struct for when it is needed
for serialization, once those webkit unknown elements are supported by
our engine.
2023-12-11 16:54:59 +01:00
Aliaksandr Kalenik
f50bf00814 LibWeb+LibGfx: Move UnicodeRange from LibWeb to LibGfx
In upcoming changes UnicodeRange is going to be used in LibGfx in
a class that represents font cascade list.
2023-12-10 17:32:04 +01:00
Shannon Booth
74b6e7b1f0 LibWeb: Avoid calling FlyString::from_utf8 on FlyString's 2023-12-10 09:45:03 +01:00
Shannon Booth
6ce0d588ee Everywhere: Avoid calling from_utf8 on FlyString or String
We already have a String :^)
2023-12-10 09:45:03 +01:00
Sam Atkins
29ecb2eda6 LibWeb: Parse grid-template-areas property using TokenStream 2023-12-08 10:47:23 +00:00
Sam Atkins
c3583317ee LibWeb: Parse grid-auto-flow property using TokenStream
RefPtr is already `[[nodiscard]]` so we can remove that extra noise from
the declaration.
2023-12-08 10:47:23 +00:00
Sam Atkins
bbbd9c14ac LibWeb: Parse grid-area property using TokenStream 2023-12-08 10:47:23 +00:00
Sam Atkins
a16b35a755 LibWeb: Parse grid-column and grid-row properties using TokenStream 2023-12-08 10:47:23 +00:00
Sam Atkins
b18c334a4f LibWeb: Ensure there are no trailing tokens when parsing font-family 2023-12-08 10:47:23 +00:00
Sam Atkins
f84ccb8627 LibWeb: Part font property using TokenStream 2023-12-08 10:47:23 +00:00
Sam Atkins
333b705f25 LibWeb: Parse flex-flow property using TokenStream 2023-12-08 10:47:23 +00:00
Sam Atkins
bf3576667a LibWeb: Parse flex property using TokenStream 2023-12-08 10:47:23 +00:00
Sam Atkins
4f3136c230 LibWeb: Parse shadow values using TokenStream 2023-12-08 10:47:23 +00:00
Sam Atkins
3a36b2eea9 LibWeb: Parse border properties using TokenStream 2023-12-08 10:47:23 +00:00
Sam Atkins
0e00d9a67d LibWeb: Parse background property using TokenStream 2023-12-08 10:47:23 +00:00
Sam Atkins
64a44b719e LibWeb: Parse FilterValueListStyleValue using TokenStream 2023-12-08 10:47:23 +00:00
Sam Atkins
2efaadd63c LibWeb: Parse aspect-ratio property using TokenStream 2023-12-08 10:47:23 +00:00
Sam Atkins
647d52ff9a LibWeb: Parse quotes property using TokenStream 2023-12-08 10:47:23 +00:00
Sam Atkins
ebad94658a LibWeb: Parse display property using TokenStream 2023-12-08 10:47:23 +00:00
Sam Atkins
3d6eb36664 LibWeb: Parse content property using TokenStream 2023-12-08 10:47:23 +00:00
Sam Atkins
4d6e8d8f37 LibWeb: Parse border-radius properties using TokenStream 2023-12-08 10:47:23 +00:00
Sam Atkins
28c719fff5 LibWeb: Extract contains_single_none_ident() helper function
Several CSS properties can be `none` instead of their usual value.
2023-12-08 10:47:23 +00:00
Sam Atkins
1cc88dc4bc LibWeb: Make parse_comma_separated_value_list() take a TokenStream
This lets us use it from inside places that use TokenStreams.
2023-12-08 10:47:23 +00:00
Sam Atkins
cd9344d4c1 LibWeb: Clarify naming of TokenStreams in parse_css_value()
Originally, the input was named `tokens`, and we later created a
`tokens_without_whitespace` from the filtered contents of `tokens`.
Since `tokens_without_whitespace` is what we actually want to use while
parsing, let's rename `tokens` -> `unprocessed_tokens` and use the
`tokens` name for the processed ones.
2023-12-08 10:47:23 +00:00
Sam Atkins
ef48d967d4 LibWeb: Correct parsing of background-position 3-value syntax
There were two bugs here, one of which hid the other:
- Only one offset would have a value, but we dereferenced both.
- We consumed a token whether it was a valid offset or not.
2023-12-05 09:55:16 +01:00
Shannon Booth
89bbf53745 LibWeb: Port CSS Parser from DeprecatedString
These are the last instances of DeprecatedString in the CSS folder.
2023-12-02 22:54:53 +01:00
Shannon Booth
6813dcaff8 LibWeb: Return FlyString const& from CSS::Parser::Token
This allows us to not need to convert back to a FlyString when we need
one.
2023-12-02 22:54:53 +01:00
Andreas Kling
189d1e8291 LibWeb: Port CSSNamespaceRule to FlyString
This removes a performance problem where we'd convert the style sheet's
default namespace from DeprecatedFlyString to FlyString once per rule
during selector matching.

The conversion now happens once, during CSS parse. It should eventually
be removed from there as well, but one step at a time. :^)
2023-12-01 16:03:58 +01:00
Sam Atkins
f69d38a346 LibWeb: Use ComponentValue::is_ident("..."sv) helper 2023-11-22 09:45:51 +01:00
Sam Atkins
6cd6186399 LibWeb: Don't assume grid size is always Function or Token
This stops `grid-template-columns: minmax({},{})` from crashing.
2023-11-22 09:45:51 +01:00
Sam Atkins
1a17b8a304 LibWeb: Don't assume grid-area parts are Tokens
This stops `grid-area: {}` from crashing.
2023-11-22 09:45:51 +01:00
Sam Atkins
ab9d39bf4a LibWeb: Don't assume grid-row/grid-column parts are Tokens
This stops `grid-column: {}` from crashing.
2023-11-22 09:45:51 +01:00
Sam Atkins
314a30b12e LibWeb: Don't assume grid-line parts are Tokens
This stops `grid-row-start: {}` from crashing.

Also tidy up the parsing code a little.
2023-11-22 09:45:51 +01:00
Sam Atkins
1f6e13d8fe LibWeb: Don't assume repeat() contents are Tokens
This stops `grid-template-rows: repeat({})` from crashing.
2023-11-22 09:45:51 +01:00
Sam Atkins
5e54ff1858 LibWeb: Don't assume rect() contents are Tokens
This stops `clip: rect({});` from crashing.
2023-11-22 09:45:51 +01:00
Sam Atkins
aba2946b1e LibWeb: Use ComponentValue::is_function("..."sv) helper 2023-11-22 09:45:51 +01:00
Sam Atkins
148f873321 LibWeb: Merge background-position parsing into position code
Implemented by adding the extra 3-value syntax as its own case and only
running it when parsing background-position. I'm sure it could be
implemented in a smarter way but this is still a bunch less code than
before. :^)
2023-11-21 01:29:26 +01:00
Sam Atkins
26d6ba6f58 LibWeb: Parse the CSS position type automatically
This means `object-position` will no longer incorrectly accept the
3-value background-position syntax.

Remove the now-ambiguous and unused `position` enum while we're at it.
(This enum only existed as a hack.)
2023-11-21 01:29:26 +01:00
Sam Atkins
19da17f07e LibWeb: Allow calc() in CSS position values 2023-11-21 01:29:26 +01:00
Sam Atkins
763b08c23f LibWeb: Remove now-unused CSS::PositionValue type and associated parsing
All the users now use PositionStyleValue instead.
2023-11-07 22:00:24 +00:00
Sam Atkins
8917378aa7 LibWeb: Adapt parse_position() into parse_position_value()
Having two ways that `<position>` is represented is awkward and
unnecessary. So, let's combine the two paths together. This first step
copies and modifies the `parse_position()` code to produce a
`PositionStyleValue`.

Apart from returning a StyleValue, this also makes use of automatic enum
parsing instead of manually comparing identifier strings.
2023-11-07 22:00:24 +00:00