1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 14:45:07 +00:00

LibWeb: Streamline how inline CSS style declarations are constructed

When parsing the "style" attribute on elements, we'd previously ask the
CSS parser for a PropertyOwningCSSStyleDeclaration. Then we'd create a
new ElementCSSInlineStyleDeclaration and transfer the properties from
the first object to the second object.

This patch teaches the parser to make ElementCSSInlineStyleDeclaration
objects directly.
This commit is contained in:
Andreas Kling 2022-03-29 16:01:38 +02:00
parent 3efa6cedec
commit 427beb97b5
5 changed files with 34 additions and 36 deletions

View file

@ -23,14 +23,8 @@ String PropertyOwningCSSStyleDeclaration::item(size_t index) const
return CSS::string_from_property_id(m_properties[index].property_id);
}
ElementInlineCSSStyleDeclaration::ElementInlineCSSStyleDeclaration(DOM::Element& element)
: PropertyOwningCSSStyleDeclaration({}, {})
, m_element(element.make_weak_ptr<DOM::Element>())
{
}
ElementInlineCSSStyleDeclaration::ElementInlineCSSStyleDeclaration(DOM::Element& element, PropertyOwningCSSStyleDeclaration& declaration)
: PropertyOwningCSSStyleDeclaration(move(declaration.m_properties), move(declaration.m_custom_properties))
ElementInlineCSSStyleDeclaration::ElementInlineCSSStyleDeclaration(DOM::Element& element, Vector<StyleProperty> properties, HashMap<String, StyleProperty> custom_properties)
: PropertyOwningCSSStyleDeclaration(move(properties), move(custom_properties))
, m_element(element.make_weak_ptr<DOM::Element>())
{
}