mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 18:17:45 +00:00
LibWeb: Parse CSS <general-enclosed>
This commit is contained in:
parent
42176d37fc
commit
e760263728
2 changed files with 21 additions and 7 deletions
|
@ -1111,10 +1111,26 @@ Optional<Supports::Feature> Parser::parse_supports_feature(TokenStream<StyleComp
|
|||
return {};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Optional<Parser::GeneralEnclosed> Parser::parse_general_enclosed(TokenStream<T>&)
|
||||
// https://www.w3.org/TR/mediaqueries-4/#typedef-general-enclosed
|
||||
Optional<GeneralEnclosed> Parser::parse_general_enclosed(TokenStream<StyleComponentValueRule>& tokens)
|
||||
{
|
||||
// FIXME: Actually parse this! https://www.w3.org/TR/mediaqueries-5/#typedef-general-enclosed
|
||||
tokens.skip_whitespace();
|
||||
auto start_position = tokens.position();
|
||||
|
||||
auto& first_token = tokens.next_token();
|
||||
|
||||
// `[ <function-token> <any-value> ) ]`
|
||||
if (first_token.is_function())
|
||||
return GeneralEnclosed { first_token.to_string() };
|
||||
|
||||
// `( <ident> <any-value> )`
|
||||
if (first_token.is_block() && first_token.block().is_paren()) {
|
||||
auto& block = first_token.block();
|
||||
if (!block.values().is_empty() && block.values().first().is(Token::Type::Ident))
|
||||
return GeneralEnclosed { first_token.to_string() };
|
||||
}
|
||||
|
||||
tokens.rewind_to_position(start_position);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <AK/Result.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibWeb/CSS/CSSStyleDeclaration.h>
|
||||
#include <LibWeb/CSS/GeneralEnclosed.h>
|
||||
#include <LibWeb/CSS/MediaQuery.h>
|
||||
#include <LibWeb/CSS/Parser/DeclarationOrAtRule.h>
|
||||
#include <LibWeb/CSS/Parser/StyleBlockRule.h>
|
||||
|
@ -170,10 +171,7 @@ private:
|
|||
template<typename T>
|
||||
[[nodiscard]] NonnullRefPtr<StyleFunctionRule> consume_a_function(TokenStream<T>&);
|
||||
|
||||
struct GeneralEnclosed {
|
||||
};
|
||||
template<typename T>
|
||||
[[nodiscard]] Optional<GeneralEnclosed> parse_general_enclosed(TokenStream<T>&);
|
||||
[[nodiscard]] Optional<GeneralEnclosed> parse_general_enclosed(TokenStream<StyleComponentValueRule>&);
|
||||
|
||||
[[nodiscard]] RefPtr<CSSRule> convert_to_rule(NonnullRefPtr<StyleRule>);
|
||||
[[nodiscard]] RefPtr<PropertyOwningCSSStyleDeclaration> convert_to_declaration(NonnullRefPtr<StyleBlockRule>);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue