summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-04-12 12:00:07 +0100
committerAndreas Kling <kling@serenityos.org>2022-04-12 23:03:46 +0200
commitc449cabae3e861d19ec665ec1b55ac2882a9925c (patch)
tree0f7d402955e83f87fdbbfc68bdf06a2e22a8c05e
parent1304bf5a219d042c5ccd2560bf99cedd76a85b45 (diff)
downloadserenity-c449cabae3e861d19ec665ec1b55ac2882a9925c.zip
LibWeb: Move CSS Parser into new Web::CSS::Parser namespace
The goal here is to move the parser-internal classes into this namespace so they can have more convenient names without causing collisions. The Parser itself won't collide, and would be more convenient to just remain `CSS::Parser`, but having a namespace and a class with the same name makes C++ unhappy.
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp4
-rw-r--r--Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp2
-rw-r--r--Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp2
-rw-r--r--Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp2
-rw-r--r--Userland/Libraries/LibWeb/CSS/MediaQuery.h2
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Declaration.h2
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/DeclarationOrAtRule.h2
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp38
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Parser.h18
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/StyleBlockRule.h3
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/StyleFunctionRule.h5
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/StyleRule.h2
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleComputer.cpp6
-rw-r--r--Userland/Libraries/LibWeb/CSS/Supports.cpp4
-rw-r--r--Userland/Libraries/LibWeb/CSS/Supports.h2
-rw-r--r--Userland/Libraries/LibWeb/DOM/Element.cpp6
-rw-r--r--Userland/Libraries/LibWeb/DOM/ParentNode.cpp4
-rw-r--r--Userland/Libraries/LibWeb/Forward.h4
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLStyleElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp3
-rw-r--r--Userland/Libraries/LibWeb/HTML/Window.cpp2
-rw-r--r--Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp2
23 files changed, 61 insertions, 58 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp
index 0fccaec451..8381c5b4b1 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp
@@ -312,7 +312,7 @@ NonnullRefPtr<StyleValue> property_initial_value(PropertyID property_id)
static bool initialized = false;
if (!initialized) {
initialized = true;
- ParsingContext parsing_context;
+ Parser::ParsingContext parsing_context;
)~~~");
// NOTE: Parsing a shorthand property requires that its longhands are already available here.
@@ -334,7 +334,7 @@ NonnullRefPtr<StyleValue> property_initial_value(PropertyID property_id)
member_generator.set("initial_value_string", initial_value_string);
member_generator.append(R"~~~(
{
- auto parsed_value = Parser(parsing_context, "@initial_value_string@").parse_as_css_value(PropertyID::@name:titlecase@);
+ auto parsed_value = parse_css_value(parsing_context, "@initial_value_string@", PropertyID::@name:titlecase@);
VERIFY(!parsed_value.is_null());
initial_values[to_underlying(PropertyID::@name:titlecase@)] = parsed_value.release_nonnull();
}
diff --git a/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp
index 19e3a0a14b..932d8120c7 100644
--- a/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp
+++ b/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp
@@ -73,7 +73,7 @@ void CSSImportRule::resource_did_load()
dbgln_if(CSS_LOADER_DEBUG, "CSSImportRule: Resource did load, has encoded data. URL: {}", resource()->url());
}
- auto sheet = parse_css_stylesheet(CSS::ParsingContext(*m_document, resource()->url()), resource()->encoded_data());
+ auto sheet = parse_css_stylesheet(CSS::Parser::ParsingContext(*m_document, resource()->url()), resource()->encoded_data());
if (!sheet) {
dbgln_if(CSS_LOADER_DEBUG, "CSSImportRule: Failed to parse stylesheet: {}", resource()->url());
return;
diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp
index e8f094d52d..853c471fa8 100644
--- a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp
+++ b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp
@@ -65,7 +65,7 @@ DOM::ExceptionOr<void> PropertyOwningCSSStyleDeclaration::set_property(PropertyI
return {};
// 5. Let component value list be the result of parsing value for property property.
- auto component_value_list = parse_css_value(CSS::ParsingContext {}, value, property_id);
+ auto component_value_list = parse_css_value(CSS::Parser::ParsingContext {}, value, property_id);
// 6. If component value list is null, then return.
if (!component_value_list)
diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp
index 594c5240cb..f3ce3b9135 100644
--- a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp
+++ b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp
@@ -27,7 +27,7 @@ DOM::ExceptionOr<unsigned> CSSStyleSheet::insert_rule(StringView rule, unsigned
// FIXME: 2. If the disallow modification flag is set, throw a NotAllowedError DOMException.
// 3. Let parsed rule be the return value of invoking parse a rule with rule.
- auto parsed_rule = parse_css_rule(CSS::ParsingContext {}, rule);
+ auto parsed_rule = parse_css_rule(CSS::Parser::ParsingContext {}, rule);
// 4. If parsed rule is a syntax error, return parsed rule.
if (!parsed_rule)
diff --git a/Userland/Libraries/LibWeb/CSS/MediaQuery.h b/Userland/Libraries/LibWeb/CSS/MediaQuery.h
index 5a6b304c67..a50d30508a 100644
--- a/Userland/Libraries/LibWeb/CSS/MediaQuery.h
+++ b/Userland/Libraries/LibWeb/CSS/MediaQuery.h
@@ -213,7 +213,7 @@ private:
};
class MediaQuery : public RefCounted<MediaQuery> {
- friend class Parser;
+ friend class Parser::Parser;
public:
~MediaQuery() = default;
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Declaration.h b/Userland/Libraries/LibWeb/CSS/Parser/Declaration.h
index c8e06037cd..35d8ef7441 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Declaration.h
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Declaration.h
@@ -14,7 +14,7 @@
namespace Web::CSS {
class Declaration {
- friend class Parser;
+ friend class Parser::Parser;
public:
Declaration();
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/DeclarationOrAtRule.h b/Userland/Libraries/LibWeb/CSS/Parser/DeclarationOrAtRule.h
index 1c3b5502a1..ed271a9e26 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/DeclarationOrAtRule.h
+++ b/Userland/Libraries/LibWeb/CSS/Parser/DeclarationOrAtRule.h
@@ -12,7 +12,7 @@
namespace Web::CSS {
class DeclarationOrAtRule {
- friend class Parser;
+ friend class Parser::Parser;
public:
explicit DeclarationOrAtRule(RefPtr<StyleRule> at);
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
index 9abbc4d421..f68c1e5478 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
@@ -34,7 +34,7 @@ static void log_parse_error(SourceLocation const& location = SourceLocation::cur
dbgln_if(CSS_PARSER_DEBUG, "Parse error (CSS) {}", location);
}
-namespace Web::CSS {
+namespace Web::CSS::Parser {
ParsingContext::ParsingContext(DOM::Document const& document, Optional<AK::URL> const url)
: m_document(&document)
@@ -5741,8 +5741,8 @@ RefPtr<StyleValue> Parser::parse_css_value(Badge<StyleComputer>, ParsingContext
if (tokens.is_empty() || property_id == CSS::PropertyID::Invalid || property_id == CSS::PropertyID::Custom)
return {};
- CSS::Parser parser(context, "");
- CSS::TokenStream<CSS::ComponentValue> token_stream { tokens };
+ Parser parser(context, "");
+ TokenStream<ComponentValue> token_stream { tokens };
auto result = parser.parse_css_value(property_id, token_stream);
if (result.is_error())
return {};
@@ -5868,59 +5868,59 @@ TimePercentage Parser::Dimension::time_percentage() const
namespace Web {
-RefPtr<CSS::CSSStyleSheet> parse_css_stylesheet(CSS::ParsingContext const& context, StringView css, Optional<AK::URL> location)
+RefPtr<CSS::CSSStyleSheet> parse_css_stylesheet(CSS::Parser::ParsingContext const& context, StringView css, Optional<AK::URL> location)
{
if (css.is_empty())
return CSS::CSSStyleSheet::create({}, location);
- CSS::Parser parser(context, css);
+ CSS::Parser::Parser parser(context, css);
return parser.parse_as_css_stylesheet(location);
}
-RefPtr<CSS::ElementInlineCSSStyleDeclaration> parse_css_style_attribute(CSS::ParsingContext const& context, StringView css, DOM::Element& element)
+RefPtr<CSS::ElementInlineCSSStyleDeclaration> parse_css_style_attribute(CSS::Parser::ParsingContext const& context, StringView css, DOM::Element& element)
{
if (css.is_empty())
return CSS::ElementInlineCSSStyleDeclaration::create(element, {}, {});
- CSS::Parser parser(context, css);
+ CSS::Parser::Parser parser(context, css);
return parser.parse_as_style_attribute(element);
}
-RefPtr<CSS::StyleValue> parse_css_value(CSS::ParsingContext const& context, StringView string, CSS::PropertyID property_id)
+RefPtr<CSS::StyleValue> parse_css_value(CSS::Parser::ParsingContext const& context, StringView string, CSS::PropertyID property_id)
{
if (string.is_empty())
return {};
- CSS::Parser parser(context, string);
+ CSS::Parser::Parser parser(context, string);
return parser.parse_as_css_value(property_id);
}
-RefPtr<CSS::CSSRule> parse_css_rule(CSS::ParsingContext const& context, StringView css_text)
+RefPtr<CSS::CSSRule> parse_css_rule(CSS::Parser::ParsingContext const& context, StringView css_text)
{
- CSS::Parser parser(context, css_text);
+ CSS::Parser::Parser parser(context, css_text);
return parser.parse_as_css_rule();
}
-Optional<CSS::SelectorList> parse_selector(CSS::ParsingContext const& context, StringView selector_text)
+Optional<CSS::SelectorList> parse_selector(CSS::Parser::ParsingContext const& context, StringView selector_text)
{
- CSS::Parser parser(context, selector_text);
+ CSS::Parser::Parser parser(context, selector_text);
return parser.parse_as_selector();
}
-RefPtr<CSS::MediaQuery> parse_media_query(CSS::ParsingContext const& context, StringView string)
+RefPtr<CSS::MediaQuery> parse_media_query(CSS::Parser::ParsingContext const& context, StringView string)
{
- CSS::Parser parser(context, string);
+ CSS::Parser::Parser parser(context, string);
return parser.parse_as_media_query();
}
-NonnullRefPtrVector<CSS::MediaQuery> parse_media_query_list(CSS::ParsingContext const& context, StringView string)
+NonnullRefPtrVector<CSS::MediaQuery> parse_media_query_list(CSS::Parser::ParsingContext const& context, StringView string)
{
- CSS::Parser parser(context, string);
+ CSS::Parser::Parser parser(context, string);
return parser.parse_as_media_query_list();
}
-RefPtr<CSS::Supports> parse_css_supports(CSS::ParsingContext const& context, StringView string)
+RefPtr<CSS::Supports> parse_css_supports(CSS::Parser::ParsingContext const& context, StringView string)
{
if (string.is_empty())
return {};
- CSS::Parser parser(context, string);
+ CSS::Parser::Parser parser(context, string);
return parser.parse_as_supports();
}
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h
index 1b14d08541..10d2b1b6bc 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h
@@ -30,7 +30,7 @@
#include <LibWeb/CSS/UnicodeRange.h>
#include <LibWeb/Forward.h>
-namespace Web::CSS {
+namespace Web::CSS::Parser {
class ParsingContext {
public:
@@ -375,13 +375,13 @@ private:
namespace Web {
-RefPtr<CSS::CSSStyleSheet> parse_css_stylesheet(CSS::ParsingContext const&, StringView, Optional<AK::URL> location = {});
-RefPtr<CSS::ElementInlineCSSStyleDeclaration> parse_css_style_attribute(CSS::ParsingContext const&, StringView, DOM::Element&);
-RefPtr<CSS::StyleValue> parse_css_value(CSS::ParsingContext const&, StringView, CSS::PropertyID property_id = CSS::PropertyID::Invalid);
-Optional<CSS::SelectorList> parse_selector(CSS::ParsingContext const&, StringView);
-RefPtr<CSS::CSSRule> parse_css_rule(CSS::ParsingContext const&, StringView);
-RefPtr<CSS::MediaQuery> parse_media_query(CSS::ParsingContext const&, StringView);
-NonnullRefPtrVector<CSS::MediaQuery> parse_media_query_list(CSS::ParsingContext const&, StringView);
-RefPtr<CSS::Supports> parse_css_supports(CSS::ParsingContext const&, StringView);
+RefPtr<CSS::CSSStyleSheet> parse_css_stylesheet(CSS::Parser::ParsingContext const&, StringView, Optional<AK::URL> location = {});
+RefPtr<CSS::ElementInlineCSSStyleDeclaration> parse_css_style_attribute(CSS::Parser::ParsingContext const&, StringView, DOM::Element&);
+RefPtr<CSS::StyleValue> parse_css_value(CSS::Parser::ParsingContext const&, StringView, CSS::PropertyID property_id = CSS::PropertyID::Invalid);
+Optional<CSS::SelectorList> parse_selector(CSS::Parser::ParsingContext const&, StringView);
+RefPtr<CSS::CSSRule> parse_css_rule(CSS::Parser::ParsingContext const&, StringView);
+RefPtr<CSS::MediaQuery> parse_media_query(CSS::Parser::ParsingContext const&, StringView);
+NonnullRefPtrVector<CSS::MediaQuery> parse_media_query_list(CSS::Parser::ParsingContext const&, StringView);
+RefPtr<CSS::Supports> parse_css_supports(CSS::Parser::ParsingContext const&, StringView);
}
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/StyleBlockRule.h b/Userland/Libraries/LibWeb/CSS/Parser/StyleBlockRule.h
index e137320575..d0573bb342 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/StyleBlockRule.h
+++ b/Userland/Libraries/LibWeb/CSS/Parser/StyleBlockRule.h
@@ -11,11 +11,12 @@
#include <AK/Vector.h>
#include <LibWeb/CSS/Parser/ComponentValue.h>
#include <LibWeb/CSS/Parser/Token.h>
+#include <LibWeb/Forward.h>
namespace Web::CSS {
class StyleBlockRule : public RefCounted<StyleBlockRule> {
- friend class Parser;
+ friend class Parser::Parser;
public:
StyleBlockRule();
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/StyleFunctionRule.h b/Userland/Libraries/LibWeb/CSS/Parser/StyleFunctionRule.h
index 3b74bc1ecd..356fef1d7f 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/StyleFunctionRule.h
+++ b/Userland/Libraries/LibWeb/CSS/Parser/StyleFunctionRule.h
@@ -11,13 +11,12 @@
#include <AK/String.h>
#include <AK/Vector.h>
#include <LibWeb/CSS/Parser/ComponentValue.h>
+#include <LibWeb/Forward.h>
namespace Web::CSS {
-class ComponentValue;
-
class StyleFunctionRule : public RefCounted<StyleFunctionRule> {
- friend class Parser;
+ friend class Parser::Parser;
public:
explicit StyleFunctionRule(String name);
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/StyleRule.h b/Userland/Libraries/LibWeb/CSS/Parser/StyleRule.h
index 3d6cc961bd..b999883abe 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/StyleRule.h
+++ b/Userland/Libraries/LibWeb/CSS/Parser/StyleRule.h
@@ -15,7 +15,7 @@
namespace Web::CSS {
class StyleRule : public RefCounted<StyleRule> {
- friend class Parser;
+ friend class Parser::Parser;
public:
enum class Type {
diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
index ac474a653f..601818e2d3 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
+++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
@@ -114,7 +114,7 @@ static StyleSheet& default_stylesheet()
if (!sheet) {
extern char const default_stylesheet_source[];
String css = default_stylesheet_source;
- sheet = parse_css_stylesheet(CSS::ParsingContext(), css).leak_ref();
+ sheet = parse_css_stylesheet(CSS::Parser::ParsingContext(), css).leak_ref();
}
return *sheet;
}
@@ -125,7 +125,7 @@ static StyleSheet& quirks_mode_stylesheet()
if (!sheet) {
extern char const quirks_mode_stylesheet_source[];
String css = quirks_mode_stylesheet_source;
- sheet = parse_css_stylesheet(CSS::ParsingContext(), css).leak_ref();
+ sheet = parse_css_stylesheet(CSS::Parser::ParsingContext(), css).leak_ref();
}
return *sheet;
}
@@ -652,7 +652,7 @@ RefPtr<StyleValue> StyleComputer::resolve_unresolved_style_value(DOM::Element& e
if (!expand_unresolved_values(element, string_from_property_id(property_id), dependencies, unresolved.values(), expanded_values, 0))
return {};
- if (auto parsed_value = Parser::parse_css_value({}, ParsingContext { document() }, property_id, expanded_values))
+ if (auto parsed_value = Parser::Parser::parse_css_value({}, Parser::ParsingContext { document() }, property_id, expanded_values))
return parsed_value.release_nonnull();
return {};
diff --git a/Userland/Libraries/LibWeb/CSS/Supports.cpp b/Userland/Libraries/LibWeb/CSS/Supports.cpp
index 3a65ef8c1d..0cb947ec19 100644
--- a/Userland/Libraries/LibWeb/CSS/Supports.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Supports.cpp
@@ -52,13 +52,13 @@ bool Supports::InParens::evaluate() const
bool Supports::Declaration::evaluate() const
{
- auto style_property = Parser({}, declaration).parse_as_supports_condition();
+ auto style_property = Parser::Parser({}, declaration).parse_as_supports_condition();
return style_property.has_value();
}
bool Supports::Selector::evaluate() const
{
- auto style_property = Parser({}, selector).parse_as_selector();
+ auto style_property = Parser::Parser({}, selector).parse_as_selector();
return style_property.has_value();
}
diff --git a/Userland/Libraries/LibWeb/CSS/Supports.h b/Userland/Libraries/LibWeb/CSS/Supports.h
index 160b8287da..51a7a72d96 100644
--- a/Userland/Libraries/LibWeb/CSS/Supports.h
+++ b/Userland/Libraries/LibWeb/CSS/Supports.h
@@ -18,7 +18,7 @@ namespace Web::CSS {
// https://www.w3.org/TR/css-conditional-4/#at-supports
class Supports final : public RefCounted<Supports> {
- friend class Parser;
+ friend class Parser::Parser;
public:
struct Declaration {
diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp
index 54cc4962ca..b8a9a89425 100644
--- a/Userland/Libraries/LibWeb/DOM/Element.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Element.cpp
@@ -313,7 +313,7 @@ void Element::parse_attribute(FlyString const& name, String const& value)
// https://drafts.csswg.org/cssom/#ref-for-cssstyledeclaration-updating-flag
if (m_inline_style && m_inline_style->is_updating())
return;
- m_inline_style = parse_css_style_attribute(CSS::ParsingContext(document()), value, *this);
+ m_inline_style = parse_css_style_attribute(CSS::Parser::ParsingContext(document()), value, *this);
set_needs_style_update(true);
}
}
@@ -422,7 +422,7 @@ RefPtr<DOMTokenList> const& Element::class_list()
// https://dom.spec.whatwg.org/#dom-element-matches
DOM::ExceptionOr<bool> Element::matches(StringView selectors) const
{
- auto maybe_selectors = parse_selector(CSS::ParsingContext(static_cast<ParentNode&>(const_cast<Element&>(*this))), selectors);
+ auto maybe_selectors = parse_selector(CSS::Parser::ParsingContext(static_cast<ParentNode&>(const_cast<Element&>(*this))), selectors);
if (!maybe_selectors.has_value())
return DOM::SyntaxError::create("Failed to parse selector");
@@ -437,7 +437,7 @@ DOM::ExceptionOr<bool> Element::matches(StringView selectors) const
// https://dom.spec.whatwg.org/#dom-element-closest
DOM::ExceptionOr<DOM::Element const*> Element::closest(StringView selectors) const
{
- auto maybe_selectors = parse_selector(CSS::ParsingContext(static_cast<ParentNode&>(const_cast<Element&>(*this))), selectors);
+ auto maybe_selectors = parse_selector(CSS::Parser::ParsingContext(static_cast<ParentNode&>(const_cast<Element&>(*this))), selectors);
if (!maybe_selectors.has_value())
return DOM::SyntaxError::create("Failed to parse selector");
diff --git a/Userland/Libraries/LibWeb/DOM/ParentNode.cpp b/Userland/Libraries/LibWeb/DOM/ParentNode.cpp
index 2734295f91..16f65efa41 100644
--- a/Userland/Libraries/LibWeb/DOM/ParentNode.cpp
+++ b/Userland/Libraries/LibWeb/DOM/ParentNode.cpp
@@ -17,7 +17,7 @@ namespace Web::DOM {
ExceptionOr<RefPtr<Element>> ParentNode::query_selector(StringView selector_text)
{
- auto maybe_selectors = parse_selector(CSS::ParsingContext(*this), selector_text);
+ auto maybe_selectors = parse_selector(CSS::Parser::ParsingContext(*this), selector_text);
if (!maybe_selectors.has_value())
return DOM::SyntaxError::create("Failed to parse selector");
@@ -40,7 +40,7 @@ ExceptionOr<RefPtr<Element>> ParentNode::query_selector(StringView selector_text
ExceptionOr<NonnullRefPtr<NodeList>> ParentNode::query_selector_all(StringView selector_text)
{
- auto maybe_selectors = parse_selector(CSS::ParsingContext(*this), selector_text);
+ auto maybe_selectors = parse_selector(CSS::Parser::ParsingContext(*this), selector_text);
if (!maybe_selectors.has_value())
return DOM::SyntaxError::create("Failed to parse selector");
diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h
index 5940d2a4bf..933133b5eb 100644
--- a/Userland/Libraries/LibWeb/Forward.h
+++ b/Userland/Libraries/LibWeb/Forward.h
@@ -98,6 +98,10 @@ enum class PropertyID;
enum class ValueID;
}
+namespace Web::CSS::Parser {
+class Parser;
+}
+
namespace Web::DOM {
class AbstractRange;
class AbortController;
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp
index f6b601f9c3..03680401c8 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp
@@ -126,7 +126,7 @@ void HTMLLinkElement::resource_did_load_stylesheet()
}
}
- auto sheet = parse_css_stylesheet(CSS::ParsingContext(document(), resource()->url()), resource()->encoded_data());
+ auto sheet = parse_css_stylesheet(CSS::Parser::ParsingContext(document(), resource()->url()), resource()->encoded_data());
if (!sheet) {
dbgln_if(CSS_LOADER_DEBUG, "HTMLLinkElement: Failed to parse stylesheet: {}", resource()->url());
return;
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLStyleElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLStyleElement.cpp
index 7be65c8cfc..293e703873 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLStyleElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLStyleElement.cpp
@@ -126,7 +126,7 @@ void HTMLStyleElement::update_a_style_block()
// FIXME: This is a bit awkward, as the spec doesn't actually tell us when to parse the CSS text,
// so we just do it here and pass the parsed sheet to create_a_css_style_sheet().
- auto sheet = parse_css_stylesheet(CSS::ParsingContext(document()), text_content());
+ auto sheet = parse_css_stylesheet(CSS::Parser::ParsingContext(document()), text_content());
if (!sheet)
return;
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp
index c3d42b399e..936512dc97 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp
@@ -30,8 +30,7 @@ void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& styl
if (value.equals_ignoring_case("center"sv) || value.equals_ignoring_case("middle"sv)) {
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::LibwebCenter));
} else {
- CSS::Parser parser(CSS::ParsingContext(document()), value.view());
- if (auto parsed_value = parser.parse_as_css_value(CSS::PropertyID::TextAlign))
+ if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value.view(), CSS::PropertyID::TextAlign))
style.set_property(CSS::PropertyID::TextAlign, parsed_value.release_nonnull());
}
return;
diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp
index 4429d17c3c..b5529497f0 100644
--- a/Userland/Libraries/LibWeb/HTML/Window.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Window.cpp
@@ -390,7 +390,7 @@ NonnullRefPtr<CSS::CSSStyleDeclaration> Window::get_computed_style(DOM::Element&
NonnullRefPtr<CSS::MediaQueryList> Window::match_media(String media)
{
- auto media_query_list = CSS::MediaQueryList::create(associated_document(), parse_media_query_list(CSS::ParsingContext(associated_document()), media));
+ auto media_query_list = CSS::MediaQueryList::create(associated_document(), parse_media_query_list(CSS::Parser::ParsingContext(associated_document()), media));
associated_document().add_media_query_list(media_query_list);
return media_query_list;
}
diff --git a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp
index 1de18fc444..a8fbbba311 100644
--- a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp
+++ b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp
@@ -19,7 +19,7 @@ SVGGraphicsElement::SVGGraphicsElement(DOM::Document& document, DOM::QualifiedNa
void SVGGraphicsElement::apply_presentational_hints(CSS::StyleProperties& style) const
{
- CSS::ParsingContext parsing_context { document() };
+ CSS::Parser::ParsingContext parsing_context { document() };
for_each_attribute([&](auto& name, auto& value) {
if (name.equals_ignoring_case("fill")) {
// FIXME: The `fill` attribute and CSS `fill` property are not the same! But our support is limited enough that they are equivalent for now.