LibWeb: Store whether sheet being parsed is a UA stylesheet
UA stylesheets allow some things that regular stylesheets don't, for instance allowing use of "non-overridable" `@counter-style` names.
This commit is contained in:
parent
73b07d25ac
commit
3e9cdb2cf4
3 changed files with 19 additions and 4 deletions
|
|
@ -50,6 +50,12 @@ ParsingParams::ParsingParams(JS::Realm& realm, ParsingMode mode)
|
|||
{
|
||||
}
|
||||
|
||||
ParsingParams::ParsingParams(JS::Realm& realm, IsUAStyleSheet is_ua_style_sheet)
|
||||
: realm(realm)
|
||||
, is_ua_style_sheet(is_ua_style_sheet)
|
||||
{
|
||||
}
|
||||
|
||||
ParsingParams::ParsingParams(DOM::Document const& document, ParsingMode mode)
|
||||
: realm(const_cast<JS::Realm&>(document.realm()))
|
||||
, document(&document)
|
||||
|
|
@ -67,6 +73,7 @@ Parser::Parser(ParsingParams const& context, Vector<Token> tokens)
|
|||
: m_document(context.document)
|
||||
, m_realm(context.realm)
|
||||
, m_parsing_mode(context.mode)
|
||||
, m_is_ua_style_sheet(context.is_ua_style_sheet)
|
||||
, m_tokens(move(tokens))
|
||||
, m_token_stream(m_tokens)
|
||||
, m_value_context(move(context.value_context))
|
||||
|
|
|
|||
|
|
@ -92,14 +92,21 @@ enum class ParsingMode {
|
|||
SVGPresentationAttribute, // See https://svgwg.org/svg2-draft/types.html#presentation-attribute-css-value
|
||||
};
|
||||
|
||||
enum class IsUAStyleSheet {
|
||||
Yes,
|
||||
No,
|
||||
};
|
||||
|
||||
struct ParsingParams {
|
||||
explicit ParsingParams(ParsingMode = ParsingMode::Normal);
|
||||
explicit ParsingParams(JS::Realm&, ParsingMode = ParsingMode::Normal);
|
||||
explicit ParsingParams(JS::Realm&, IsUAStyleSheet);
|
||||
explicit ParsingParams(DOM::Document const&, ParsingMode = ParsingMode::Normal);
|
||||
|
||||
GC::Ptr<JS::Realm> realm;
|
||||
GC::Ptr<DOM::Document const> document;
|
||||
ParsingMode mode { ParsingMode::Normal };
|
||||
IsUAStyleSheet is_ua_style_sheet { IsUAStyleSheet::No };
|
||||
|
||||
Vector<ValueParsingContext> value_context;
|
||||
Vector<RuleContext> rule_context;
|
||||
|
|
@ -599,6 +606,7 @@ private:
|
|||
GC::Ptr<DOM::Document const> m_document;
|
||||
GC::Ptr<JS::Realm> m_realm;
|
||||
ParsingMode m_parsing_mode { ParsingMode::Normal };
|
||||
IsUAStyleSheet m_is_ua_style_sheet { IsUAStyleSheet::No };
|
||||
|
||||
Vector<Token> m_tokens;
|
||||
TokenStream<Token> m_token_stream;
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ static CSSStyleSheet& default_stylesheet()
|
|||
static GC::Root<CSSStyleSheet> sheet;
|
||||
if (!sheet.cell()) {
|
||||
extern String default_stylesheet_source;
|
||||
sheet = GC::make_root(parse_css_stylesheet(CSS::Parser::ParsingParams(internal_css_realm()), default_stylesheet_source));
|
||||
sheet = GC::make_root(parse_css_stylesheet(CSS::Parser::ParsingParams(internal_css_realm(), Parser::IsUAStyleSheet::Yes), default_stylesheet_source));
|
||||
}
|
||||
return *sheet;
|
||||
}
|
||||
|
|
@ -152,7 +152,7 @@ static CSSStyleSheet& quirks_mode_stylesheet()
|
|||
static GC::Root<CSSStyleSheet> sheet;
|
||||
if (!sheet.cell()) {
|
||||
extern String quirks_mode_stylesheet_source;
|
||||
sheet = GC::make_root(parse_css_stylesheet(CSS::Parser::ParsingParams(internal_css_realm()), quirks_mode_stylesheet_source));
|
||||
sheet = GC::make_root(parse_css_stylesheet(CSS::Parser::ParsingParams(internal_css_realm(), Parser::IsUAStyleSheet::Yes), quirks_mode_stylesheet_source));
|
||||
}
|
||||
return *sheet;
|
||||
}
|
||||
|
|
@ -162,7 +162,7 @@ static CSSStyleSheet& mathml_stylesheet()
|
|||
static GC::Root<CSSStyleSheet> sheet;
|
||||
if (!sheet.cell()) {
|
||||
extern String mathml_stylesheet_source;
|
||||
sheet = GC::make_root(parse_css_stylesheet(CSS::Parser::ParsingParams(internal_css_realm()), mathml_stylesheet_source));
|
||||
sheet = GC::make_root(parse_css_stylesheet(CSS::Parser::ParsingParams(internal_css_realm(), Parser::IsUAStyleSheet::Yes), mathml_stylesheet_source));
|
||||
}
|
||||
return *sheet;
|
||||
}
|
||||
|
|
@ -172,7 +172,7 @@ static CSSStyleSheet& svg_stylesheet()
|
|||
static GC::Root<CSSStyleSheet> sheet;
|
||||
if (!sheet.cell()) {
|
||||
extern String svg_stylesheet_source;
|
||||
sheet = GC::make_root(parse_css_stylesheet(CSS::Parser::ParsingParams(internal_css_realm()), svg_stylesheet_source));
|
||||
sheet = GC::make_root(parse_css_stylesheet(CSS::Parser::ParsingParams(internal_css_realm(), Parser::IsUAStyleSheet::Yes), svg_stylesheet_source));
|
||||
}
|
||||
return *sheet;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue