mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:58:12 +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:
parent
3efa6cedec
commit
427beb97b5
5 changed files with 34 additions and 36 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue