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

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. :^)
This commit is contained in:
Andreas Kling 2021-09-12 19:24:01 +02:00
parent 10679b6df2
commit 0bcab60463
9 changed files with 106 additions and 69 deletions

View file

@ -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();
}