diff options
author | Andreas Kling <kling@serenityos.org> | 2022-02-05 15:19:16 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-02-05 22:50:39 +0100 |
commit | 04bec7a4f53ecd13673d6ea1acdb172abadc4b2c (patch) | |
tree | 28b9500b57e3c56c7be37d5187c798b78f5cda76 /Userland/Libraries/LibWeb/DOM/Element.cpp | |
parent | e6f279dadaebbdb032a8f45a34dbafeb48a593c4 (diff) | |
download | serenity-04bec7a4f53ecd13673d6ea1acdb172abadc4b2c.zip |
LibWeb: Remove CSS::StyleInvalidator in favor of dirtying + lazy update
Style updates are lazy since late last year, so the StyleInvalidator is
actually hurting us more than it's helping by running the entire CSS
selector machine on the whole DOM for every attribute change.
Instead, simply mark the entire DOM dirty and let the lazy style update
mechanism run *once* on next event loop iteration.
Diffstat (limited to 'Userland/Libraries/LibWeb/DOM/Element.cpp')
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Element.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 85cb637806..0df7eb3fd0 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -10,7 +10,6 @@ #include <LibWeb/CSS/PropertyID.h> #include <LibWeb/CSS/ResolvedCSSStyleDeclaration.h> #include <LibWeb/CSS/SelectorEngine.h> -#include <LibWeb/CSS/StyleInvalidator.h> #include <LibWeb/DOM/DOMException.h> #include <LibWeb/DOM/DOMTokenList.h> #include <LibWeb/DOM/Document.h> @@ -70,8 +69,6 @@ ExceptionOr<void> Element::set_attribute(const FlyString& name, const String& va if (name.is_empty()) return InvalidCharacterError::create("Attribute name must not be empty"); - CSS::StyleInvalidator style_invalidator(document()); - // 2. If this is in the HTML namespace and its node document is an HTML document, then set qualifiedName to qualifiedName in ASCII lowercase. // FIXME: Handle the second condition, assume it is an HTML document for now. bool insert_as_lowercase = namespace_uri() == Namespace::HTML; @@ -93,14 +90,20 @@ ExceptionOr<void> Element::set_attribute(const FlyString& name, const String& va } parse_attribute(attribute->local_name(), value); + + // FIXME: Invalidate less. + document().invalidate_style(); + return {}; } // https://dom.spec.whatwg.org/#dom-element-removeattribute void Element::remove_attribute(const FlyString& name) { - CSS::StyleInvalidator style_invalidator(document()); m_attributes->remove_attribute(name); + + // FIXME: Invalidate less. + document().invalidate_style(); } // https://dom.spec.whatwg.org/#dom-element-hasattribute |