mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
LibWeb: Cache parsed inline style of DOM elements
Instead of invoking the CSS parser every time we compute the style for an element that has a "style" attribute, we now cache the result of parsing the inline style whenever the "style" attribute is set. This is a nice boost to relayout performance since we no longer hit the CSS parser at all.
This commit is contained in:
@@ -567,12 +567,9 @@ NonnullRefPtr<StyleProperties> StyleResolver::resolve_style(const DOM::Element&
|
||||
}
|
||||
}
|
||||
|
||||
auto style_attribute = element.attribute(HTML::AttributeNames::style);
|
||||
if (!style_attribute.is_null()) {
|
||||
if (auto declaration = parse_css_declaration(CSS::ParsingContext(document()), style_attribute)) {
|
||||
for (auto& property : declaration->properties()) {
|
||||
set_property_expanding_shorthands(style, property.property_id, property.value, m_document);
|
||||
}
|
||||
if (auto* inline_style = element.inline_style()) {
|
||||
for (auto& property : inline_style->properties()) {
|
||||
set_property_expanding_shorthands(style, property.property_id, property.value, m_document);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user