LibWeb: Don't allocate DOMStringMap in HTMLElement constructor

Allocations go in initialize().
This commit is contained in:
Andreas Kling 2022-09-03 18:49:56 +02:00
parent b30e95eb27
commit 05dcf3b2f8
Notes: sideshowbarker 2024-07-18 05:37:06 +09:00
2 changed files with 9 additions and 2 deletions

View File

@ -30,13 +30,18 @@ namespace Web::HTML {
HTMLElement::HTMLElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: Element(document, move(qualified_name))
, m_dataset(DOMStringMap::create(*this))
{
set_prototype(&window().cached_web_prototype("HTMLElement"));
}
HTMLElement::~HTMLElement() = default;
void HTMLElement::initialize(JS::Realm& realm)
{
Base::initialize(realm);
m_dataset = DOMStringMap::create(*this);
}
void HTMLElement::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);

View File

@ -52,6 +52,8 @@ public:
protected:
HTMLElement(DOM::Document&, DOM::QualifiedName);
virtual void initialize(JS::Realm&) override;
virtual void parse_attribute(FlyString const& name, String const& value) override;
virtual void visit_edges(Cell::Visitor&) override;
@ -69,7 +71,7 @@ private:
};
ContentEditableState content_editable_state() const;
JS::NonnullGCPtr<DOMStringMap> m_dataset;
JS::GCPtr<DOMStringMap> m_dataset;
// https://html.spec.whatwg.org/multipage/interaction.html#locked-for-focus
bool m_locked_for_focus { false };