LibWeb: Don't allocate NamedNodeMap in Element constructor
Allocations should happen in the initialize() virtual, so move it there.
This commit is contained in:
parent
ffad902c07
commit
b30e95eb27
Notes:
sideshowbarker
2024-07-17 07:26:00 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/b30e95eb27 Pull-request: https://github.com/SerenityOS/serenity/pull/14816 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/linusg ✅
2 changed files with 10 additions and 3 deletions
|
@ -45,7 +45,6 @@ namespace Web::DOM {
|
|||
Element::Element(Document& document, DOM::QualifiedName qualified_name)
|
||||
: ParentNode(document, NodeType::ELEMENT_NODE)
|
||||
, m_qualified_name(move(qualified_name))
|
||||
, m_attributes(NamedNodeMap::create(*this))
|
||||
{
|
||||
set_prototype(&window().cached_web_prototype("Element"));
|
||||
make_html_uppercased_qualified_name();
|
||||
|
@ -53,6 +52,12 @@ Element::Element(Document& document, DOM::QualifiedName qualified_name)
|
|||
|
||||
Element::~Element() = default;
|
||||
|
||||
void Element::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
m_attributes = NamedNodeMap::create(*this);
|
||||
}
|
||||
|
||||
void Element::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
|
|
|
@ -32,7 +32,6 @@ class Element
|
|||
WEB_PLATFORM_OBJECT(Element, ParentNode);
|
||||
|
||||
public:
|
||||
Element(Document&, DOM::QualifiedName);
|
||||
virtual ~Element() override;
|
||||
|
||||
String const& qualified_name() const { return m_qualified_name.as_string(); }
|
||||
|
@ -142,6 +141,9 @@ public:
|
|||
void serialize_pseudo_elements_as_json(JsonArraySerializer<StringBuilder>& children_array) const;
|
||||
|
||||
protected:
|
||||
Element(Document&, DOM::QualifiedName);
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
virtual void children_changed() override;
|
||||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
@ -152,7 +154,7 @@ private:
|
|||
QualifiedName m_qualified_name;
|
||||
String m_html_uppercased_qualified_name;
|
||||
|
||||
JS::NonnullGCPtr<NamedNodeMap> m_attributes;
|
||||
JS::GCPtr<NamedNodeMap> m_attributes;
|
||||
JS::GCPtr<CSS::ElementInlineCSSStyleDeclaration> m_inline_style;
|
||||
JS::GCPtr<DOMTokenList> m_class_list;
|
||||
JS::GCPtr<ShadowRoot> m_shadow_root;
|
||||
|
|
Loading…
Add table
Reference in a new issue