mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:27:42 +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:
parent
867faa5d44
commit
d65bebd8cf
4 changed files with 12 additions and 7 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue