mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 07:07:23 +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:
@@ -255,11 +255,8 @@ void Element::parse_attribute(const FlyString& name, const String& value)
|
||||
if (m_class_list)
|
||||
m_class_list->associated_attribute_changed(value);
|
||||
} else if (name == HTML::AttributeNames::style) {
|
||||
auto parsed_style = parse_css_style_attribute(CSS::ParsingContext(document()), value);
|
||||
if (!parsed_style.is_null()) {
|
||||
m_inline_style = CSS::ElementInlineCSSStyleDeclaration::create_and_take_properties_from(*this, parsed_style.release_nonnull());
|
||||
set_needs_style_update(true);
|
||||
}
|
||||
m_inline_style = parse_css_style_attribute(CSS::ParsingContext(document()), value, *this);
|
||||
set_needs_style_update(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -452,7 +449,7 @@ void Element::set_shadow_root(RefPtr<ShadowRoot> shadow_root)
|
||||
NonnullRefPtr<CSS::CSSStyleDeclaration> Element::style_for_bindings()
|
||||
{
|
||||
if (!m_inline_style)
|
||||
m_inline_style = CSS::ElementInlineCSSStyleDeclaration::create(*this);
|
||||
m_inline_style = CSS::ElementInlineCSSStyleDeclaration::create(*this, {}, {});
|
||||
return *m_inline_style;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user