summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/CSS/Parser
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-09-12 19:24:01 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-12 20:44:50 +0200
commit0bcab6046366892bbcef88e26077b2097af98948 (patch)
tree873e9391048453ce61479c69b97c3c33f1b88626 /Userland/Libraries/LibWeb/CSS/Parser
parent10679b6df2f8e9689588f44331544886c54b32fb (diff)
downloadserenity-0bcab6046366892bbcef88e26077b2097af98948.zip
LibWeb: Make CSSStyleDeclaration an abstract class
This patch moves the CSS property+value storage down to a new subclass of CSSStyleDeclaration called PropertyOwningCSSStyleDeclaration. The JavaScript wrapper for CSSStyleDeclaration now calls virtual functions on the C++ object. This is preparation for supporting computed style CSSStyleDeclaration objects which won't have internal property storage, but rather an internal element pointer. :^)
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS/Parser')
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp12
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Parser.h8
2 files changed, 10 insertions, 10 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
index 2f907ac40d..0fe7343138 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
@@ -1085,13 +1085,13 @@ Optional<StyleProperty> Parser::parse_a_declaration(TokenStream<T>& tokens)
return {};
}
-RefPtr<CSSStyleDeclaration> Parser::parse_as_list_of_declarations()
+RefPtr<PropertyOwningCSSStyleDeclaration> Parser::parse_as_list_of_declarations()
{
return parse_a_list_of_declarations(m_token_stream);
}
template<typename T>
-RefPtr<CSSStyleDeclaration> Parser::parse_a_list_of_declarations(TokenStream<T>& tokens)
+RefPtr<PropertyOwningCSSStyleDeclaration> Parser::parse_a_list_of_declarations(TokenStream<T>& tokens)
{
dbgln_if(CSS_PARSER_DEBUG, "Parser::parse_as_list_of_declarations");
@@ -1119,7 +1119,7 @@ RefPtr<CSSStyleDeclaration> Parser::parse_a_list_of_declarations(TokenStream<T>&
}
}
- return CSSStyleDeclaration::create(move(properties), move(custom_properties));
+ return PropertyOwningCSSStyleDeclaration::create(move(properties), move(custom_properties));
}
Optional<StyleComponentValueRule> Parser::parse_as_component_value()
@@ -1295,7 +1295,7 @@ RefPtr<CSSRule> Parser::convert_to_rule(NonnullRefPtr<StyleRule> rule)
return {};
}
-RefPtr<CSSStyleDeclaration> Parser::convert_to_declaration(NonnullRefPtr<StyleBlockRule> block)
+RefPtr<PropertyOwningCSSStyleDeclaration> Parser::convert_to_declaration(NonnullRefPtr<StyleBlockRule> block)
{
dbgln_if(CSS_PARSER_DEBUG, "Parser::convert_to_declaration");
@@ -3487,10 +3487,10 @@ RefPtr<CSS::CSSStyleSheet> parse_css(CSS::ParsingContext const& context, StringV
return parser.parse_as_stylesheet();
}
-RefPtr<CSS::CSSStyleDeclaration> parse_css_declaration(CSS::ParsingContext const& context, StringView const& css)
+RefPtr<CSS::PropertyOwningCSSStyleDeclaration> parse_css_declaration(CSS::ParsingContext const& context, StringView const& css)
{
if (css.is_empty())
- return CSS::CSSStyleDeclaration::create({}, {});
+ return CSS::PropertyOwningCSSStyleDeclaration::create({}, {});
CSS::Parser parser(context, css);
return parser.parse_as_list_of_declarations();
}
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h
index 062830520e..7b9c566fbc 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h
@@ -86,7 +86,7 @@ public:
// Used in @supports conditions. [CSS3-CONDITIONAL]
Optional<StyleProperty> parse_as_declaration();
// For the contents of a style attribute, which parses text into the contents of a single style rule.
- RefPtr<CSSStyleDeclaration> parse_as_list_of_declarations();
+ RefPtr<PropertyOwningCSSStyleDeclaration> parse_as_list_of_declarations();
// For things that need to consume a single value, like the parsing rules for attr().
Optional<StyleComponentValueRule> parse_as_component_value();
// For the contents of presentational attributes, which parse text into a single declaration’s value, or for parsing a stand-alone selector [SELECT] or list of Media Queries [MEDIAQ], as in Selectors API or the media HTML attribute.
@@ -109,7 +109,7 @@ private:
template<typename T>
Optional<StyleProperty> parse_a_declaration(TokenStream<T>&);
template<typename T>
- RefPtr<CSSStyleDeclaration> parse_a_list_of_declarations(TokenStream<T>&);
+ RefPtr<PropertyOwningCSSStyleDeclaration> parse_a_list_of_declarations(TokenStream<T>&);
template<typename T>
Optional<StyleComponentValueRule> parse_a_component_value(TokenStream<T>&);
template<typename T>
@@ -160,7 +160,7 @@ private:
[[nodiscard]] NonnullRefPtr<StyleFunctionRule> consume_a_function(TokenStream<T>&);
[[nodiscard]] RefPtr<CSSRule> convert_to_rule(NonnullRefPtr<StyleRule>);
- [[nodiscard]] RefPtr<CSSStyleDeclaration> convert_to_declaration(NonnullRefPtr<StyleBlockRule>);
+ [[nodiscard]] RefPtr<PropertyOwningCSSStyleDeclaration> convert_to_declaration(NonnullRefPtr<StyleBlockRule>);
[[nodiscard]] Optional<StyleProperty> convert_to_style_property(StyleDeclarationRule&);
static Optional<float> try_parse_float(StringView string);
@@ -228,7 +228,7 @@ private:
namespace Web {
RefPtr<CSS::CSSStyleSheet> parse_css(CSS::ParsingContext const&, StringView const&);
-RefPtr<CSS::CSSStyleDeclaration> parse_css_declaration(CSS::ParsingContext const&, StringView const&);
+RefPtr<CSS::PropertyOwningCSSStyleDeclaration> parse_css_declaration(CSS::ParsingContext const&, StringView const&);
RefPtr<CSS::StyleValue> parse_css_value(CSS::ParsingContext const&, StringView const&, CSS::PropertyID property_id = CSS::PropertyID::Invalid);
Optional<CSS::SelectorList> parse_selector(CSS::ParsingContext const&, StringView const&);