mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 17:38:12 +00:00
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.
This commit is contained in:
parent
1304bf5a21
commit
c449cabae3
23 changed files with 61 additions and 58 deletions
|
@ -14,7 +14,7 @@
|
|||
namespace Web::CSS {
|
||||
|
||||
class Declaration {
|
||||
friend class Parser;
|
||||
friend class Parser::Parser;
|
||||
|
||||
public:
|
||||
Declaration();
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
namespace Web::CSS {
|
||||
|
||||
class DeclarationOrAtRule {
|
||||
friend class Parser;
|
||||
friend class Parser::Parser;
|
||||
|
||||
public:
|
||||
explicit DeclarationOrAtRule(RefPtr<StyleRule> at);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
namespace Web::CSS {
|
||||
|
||||
class StyleRule : public RefCounted<StyleRule> {
|
||||
friend class Parser;
|
||||
friend class Parser::Parser;
|
||||
|
||||
public:
|
||||
enum class Type {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue