Commit graph

17 commits

Author SHA1 Message Date
Sam Atkins
846c719e49 LibWeb: Make serializing Supports rules infallible 2023-08-22 17:51:48 +01:00
Luke Wilde
f7ff1fd985 LibWeb: Remove CSS::Parser::ParsingContext's default constructor
This relied on pulling the current realm from the main thread VM, which
requires an execution context to be on the VM's stack. This heavily
relied on the dummy execution context that is always on the stack, for
example, when parsing the UA style sheets where no JavaScript is
running.
2023-03-07 11:51:12 +00:00
Sam Atkins
235018046e LibWeb: Use free functions for parsing in @Supports 2023-03-07 00:43:36 +01:00
Sam Atkins
33e9c4e1b2 LibWeb: Port GeneralEnclosed to new Strings 2023-02-19 00:51:16 +01:00
Sam Atkins
a381ce9519 LibWeb: Port CSS::Supports to new Strings 2023-02-15 12:48:26 -05:00
Linus Groh
57dc179b1f Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
2022-12-06 08:54:33 +01:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
sin-ack
3f3f45580a Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
2022-07-12 23:11:35 +02:00
Sam Atkins
dfba0cb2d9 LibWeb: Implement @supports serialization 2022-05-11 20:16:10 +02:00
Sam Atkins
c449cabae3 LibWeb: Move CSS Parser into new Web::CSS::Parser namespace
The goal here is to move the parser-internal classes into this namespace
so they can have more convenient names without causing collisions. The
Parser itself won't collide, and would be more convenient to just
remain `CSS::Parser`, but having a namespace and a class with the same
name makes C++ unhappy.
2022-04-12 23:03:46 +02:00
Sam Atkins
2aac9f9258 LibWeb: Bring parse_a_declaration() to spec and add comments
User code now calls `parse_as_supports_condition()` which actually does
the conversion to a StyleProperty.
2022-03-30 18:43:07 +02:00
Sam Atkins
7880718fa8 LibWeb: Implement @supports selector(.foo)
This is defined in
https://www.w3.org/TR/css-conditional-4/#at-supports-ext which just
became a CR. :^)
2022-02-19 19:33:54 +01:00
Sam Atkins
7bea0d501e LibWeb: Remove unknown value in @supports query logic
This is in line with this recent change to Conditional-3:

> Removed the “unknown” value in CSS feature queries’ boolean logic,
> defining unrecognized syntaxes as “false” instead.
> https://github.com/w3c/csswg-drafts/issues/6175
2022-01-19 21:44:45 +00:00
Ali Mohammad Pur
9de33629da AK+Everywhere: Make Variant::visit() respect the Variant's constness
...and fix all the instances of visit() taking non-const arguments.
2022-01-14 11:35:40 +03:30
Sam Atkins
dea4f83037 LibWeb: Use a string instead of an internal Parser class in Supports
Now that we can serialize CSS tokens, we can just hold a string and then
re-parse it when the Supports is evaluated. This feels a little weird,
but it only happens once so it's not going to slow it down much, and it
keep the API cleaner.
2021-11-24 22:57:46 +01:00
Sam Atkins
99e18f40fb LibWeb: Use new GeneralEnclosed class in Supports 2021-11-24 22:57:46 +01:00
Sam Atkins
87a30418bf LibWeb: Add CSS 'Supports' class
The name is a little awkward, but this corresponds to the condition of a
`@supports` rule or the `CSS.supports("")` function.

A supports query only gets evaluated once, since its condition cannot
change during runtime. (We either support something or we don't, and the
spec specifically mentions that user preferences that disable features
do not affect the result here.) We keep a representation of it around
though, so that it can be serialized if needed. This is a little awkward
since we hold onto a `StyleDeclarationRule` which should be an internal
Parser class. This means making some Parser functions more public.

Potentially we could evaluate the Supports inside the Parser, and have
it only store a String representation of itself. But this works for now.
:^)
2021-10-08 23:02:57 +02:00