diff options
author | Andreas Kling <kling@serenityos.org> | 2023-05-15 10:08:13 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-05-15 14:08:20 +0200 |
commit | 20e2c9a7dd207bfb3575933b41edc1a905baebb0 (patch) | |
tree | c9f581a069235bc92d6580b40abd08cb5f937e9a /Userland/Libraries/LibWeb/HTML/HTMLElement.h | |
parent | 990e7219d655d39b76105ddd2678966c89be1ad3 (diff) | |
download | serenity-20e2c9a7dd207bfb3575933b41edc1a905baebb0.zip |
LibWeb: Cache state of the contenteditable attribute on HTMLElement
Instead of recomputing the state whenever someone asks for it, we now
cache it when the attribute is added/changed/removed.
Before this change, HTMLElement::is_editable() was 6.5% of CPU time
when furiously resizing Hacker News. After, it's less than 0.5%. :^)
Diffstat (limited to 'Userland/Libraries/LibWeb/HTML/HTMLElement.h')
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/HTMLElement.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLElement.h b/Userland/Libraries/LibWeb/HTML/HTMLElement.h index 4bfc1c6a96..86bda36d39 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLElement.h @@ -67,6 +67,7 @@ protected: virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) override; + virtual void did_remove_attribute(DeprecatedFlyString const& name) override; virtual void visit_edges(Cell::Visitor&) override; @@ -81,7 +82,7 @@ private: False, Inherit, }; - ContentEditableState content_editable_state() const; + ContentEditableState m_content_editable_state { ContentEditableState::Inherit }; JS::GCPtr<DOMStringMap> m_dataset; |