mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:57:35 +00:00
LibWeb: Convert CSS::Parser methods to return desired types
This is very much stubbed out for now. Most notably is Parser::convert_rule() where most of the conversion will happen from the parser's internal rule classes to CSSRule and its children.
This commit is contained in:
parent
f9ffa34622
commit
caff7fff94
2 changed files with 59 additions and 25 deletions
|
@ -21,21 +21,26 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
class CSSStyleSheet;
|
||||
class CSSRule;
|
||||
class CSSStyleRule;
|
||||
struct StyleProperty;
|
||||
|
||||
class Parser {
|
||||
public:
|
||||
Parser(const StringView& input, const String& encoding = "utf-8");
|
||||
~Parser();
|
||||
|
||||
// The normal parser entry point, for parsing stylesheets.
|
||||
NonnullRefPtrVector<QualifiedStyleRule> parse_as_stylesheet();
|
||||
NonnullRefPtr<CSSStyleSheet> parse_as_stylesheet();
|
||||
// For the content of at-rules such as @media. It differs from "Parse a stylesheet" in the handling of <CDO-token> and <CDC-token>.
|
||||
NonnullRefPtrVector<QualifiedStyleRule> parse_as_list_of_rules();
|
||||
NonnullRefPtrVector<CSSRule> parse_as_list_of_rules();
|
||||
// For use by the CSSStyleSheet#insertRule method, and similar functions which might exist, which parse text into a single rule.
|
||||
RefPtr<QualifiedStyleRule> parse_as_rule();
|
||||
RefPtr<CSSRule> parse_as_rule();
|
||||
// Used in @supports conditions. [CSS3-CONDITIONAL]
|
||||
Optional<StyleDeclarationRule> parse_as_declaration();
|
||||
Optional<StyleProperty> parse_as_declaration();
|
||||
// For the contents of a style attribute, which parses text into the contents of a single style rule.
|
||||
Vector<DeclarationOrAtRule> parse_as_list_of_declarations();
|
||||
Vector<StyleProperty> parse_as_list_of_declarations();
|
||||
// For things that need to consume a single value, like the parsing rules for attr().
|
||||
Optional<StyleComponentValueRule> parse_as_component_value();
|
||||
// For the contents of presentational attributes, which parse text into a single declaration’s value, or for parsing a stand-alone selector [SELECT] or list of Media Queries [MEDIAQ], as in Selectors API or the media HTML attribute.
|
||||
|
@ -80,6 +85,8 @@ private:
|
|||
NonnullRefPtr<StyleBlockRule> consume_a_simple_block();
|
||||
NonnullRefPtr<StyleFunctionRule> consume_a_function();
|
||||
|
||||
RefPtr<CSSRule> convert_rule(NonnullRefPtr<QualifiedStyleRule>);
|
||||
|
||||
Tokenizer m_tokenizer;
|
||||
Vector<Token> m_tokens;
|
||||
int m_iterator_offset { -1 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue