1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:27:35 +00:00

LibWeb: Add context to new CSS parser, and deprecate the old one

The new one is the same as the old one, just in the new Parser's
source files. This isn't the most elegant solution but it seemed
like the best option. And it's all temporary, after all.
This commit is contained in:
Sam Atkins 2021-07-02 20:25:13 +01:00 committed by Andreas Kling
parent 390cc30a97
commit 004ae453d1
10 changed files with 83 additions and 41 deletions

View file

@ -26,9 +26,23 @@ class CSSRule;
class CSSStyleRule;
struct StyleProperty;
class ParsingContext {
public:
ParsingContext();
explicit ParsingContext(DOM::Document const&);
explicit ParsingContext(DOM::ParentNode const&);
bool in_quirks_mode() const;
URL complete_url(String const&) const;
private:
const DOM::Document* m_document { nullptr };
};
class Parser {
public:
Parser(const StringView& input, const String& encoding = "utf-8");
Parser(ParsingContext const&, StringView const& input, String const& encoding = "utf-8");
~Parser();
// The normal parser entry point, for parsing stylesheets.
@ -87,6 +101,8 @@ private:
RefPtr<CSSRule> convert_rule(NonnullRefPtr<QualifiedStyleRule>);
ParsingContext m_context;
Tokenizer m_tokenizer;
Vector<Token> m_tokens;
int m_iterator_offset { -1 };