mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 07:38:10 +00:00
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. :^)
This commit is contained in:
parent
2a2efdedf7
commit
87a30418bf
6 changed files with 169 additions and 2 deletions
|
@ -106,6 +106,9 @@ public:
|
|||
|
||||
RefPtr<StyleValue> parse_as_css_value(PropertyID);
|
||||
|
||||
// FIXME: This is a hack, while CSS::Supports is using a StyleDeclarationRule
|
||||
[[nodiscard]] Optional<StyleProperty> convert_to_style_property(StyleDeclarationRule const&);
|
||||
|
||||
private:
|
||||
enum class ParsingResult {
|
||||
Done,
|
||||
|
@ -176,7 +179,6 @@ private:
|
|||
|
||||
[[nodiscard]] RefPtr<CSSRule> convert_to_rule(NonnullRefPtr<StyleRule>);
|
||||
[[nodiscard]] RefPtr<PropertyOwningCSSStyleDeclaration> convert_to_declaration(NonnullRefPtr<StyleBlockRule>);
|
||||
[[nodiscard]] Optional<StyleProperty> convert_to_style_property(StyleDeclarationRule&);
|
||||
|
||||
static Optional<float> try_parse_float(StringView string);
|
||||
static Optional<Color> parse_color(ParsingContext const&, StyleComponentValueRule const&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue