1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:07:46 +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:
Andreas Kling 2020-12-07 19:56:53 +01:00
parent 867faa5d44
commit d65bebd8cf
4 changed files with 12 additions and 7 deletions

View file

@ -90,6 +90,8 @@ public:
const CSS::StyleProperties* resolved_style() const { return m_resolved_style.ptr(); }
NonnullRefPtr<CSS::StyleProperties> computed_style();
const CSS::StyleDeclaration* inline_style() const { return m_inline_style; }
// FIXME: innerHTML also appears on shadow roots. https://w3c.github.io/DOM-Parsing/#dom-innerhtml
String inner_html() const;
void set_inner_html(StringView);
@ -107,6 +109,8 @@ private:
QualifiedName m_qualified_name;
Vector<Attribute> m_attributes;
RefPtr<CSS::StyleDeclaration> m_inline_style;
RefPtr<CSS::StyleProperties> m_resolved_style;
Vector<FlyString> m_classes;