mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:17: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:
parent
10679b6df2
commit
0bcab60463
9 changed files with 106 additions and 69 deletions
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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&);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue