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

LibWeb: Split CSS::StyleSheet into StyleSheet and CSSStyleSheet

This is a little convoluted but matches the CSSOM specification.
This commit is contained in:
Andreas Kling 2021-03-07 16:14:04 +01:00
parent 0af4762662
commit fefb05f6f3
17 changed files with 162 additions and 82 deletions

View file

@ -934,7 +934,7 @@ public:
consume_whitespace_or_comments();
}
RefPtr<CSS::StyleSheet> parse_sheet()
RefPtr<CSS::CSSStyleSheet> parse_sheet()
{
if (peek(0) == (char)0xef && peek(1) == (char)0xbb && peek(2) == (char)0xbf) {
// HACK: Skip UTF-8 BOM.
@ -945,7 +945,7 @@ public:
parse_rule();
}
return CSS::StyleSheet::create(move(rules));
return CSS::CSSStyleSheet::create(move(rules));
}
RefPtr<CSS::StyleDeclaration> parse_standalone_declaration()
@ -986,10 +986,10 @@ Optional<CSS::Selector> parse_selector(const CSS::ParsingContext& context, const
return parser.parse_individual_selector();
}
RefPtr<CSS::StyleSheet> parse_css(const CSS::ParsingContext& context, const StringView& css)
RefPtr<CSS::CSSStyleSheet> parse_css(const CSS::ParsingContext& context, const StringView& css)
{
if (css.is_empty())
return CSS::StyleSheet::create({});
return CSS::CSSStyleSheet::create({});
CSSParser parser(context, css);
return parser.parse_sheet();
}

View file

@ -28,7 +28,7 @@
#include <AK/NonnullRefPtr.h>
#include <AK/String.h>
#include <LibWeb/CSS/StyleSheet.h>
#include <LibWeb/CSS/CSSStyleSheet.h>
namespace Web::CSS {
class ParsingContext {
@ -48,7 +48,7 @@ private:
namespace Web {
RefPtr<CSS::StyleSheet> parse_css(const CSS::ParsingContext&, const StringView&);
RefPtr<CSS::CSSStyleSheet> parse_css(const CSS::ParsingContext&, const StringView&);
RefPtr<CSS::StyleDeclaration> parse_css_declaration(const CSS::ParsingContext&, const StringView&);
RefPtr<CSS::StyleValue> parse_css_value(const CSS::ParsingContext&, const StringView&, CSS::PropertyID property_id = CSS::PropertyID::Invalid);
Optional<CSS::Selector> parse_selector(const CSS::ParsingContext&, const StringView&);