From 0f4b82bdea83bd4da64b51faec0e2abc5f8ffc35 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 21 May 2023 13:25:03 +0200 Subject: LibWeb: Move SVGElement's dataset construction to initialize() It's not safe to allocate new cells while in a cell constructor. --- Userland/Libraries/LibWeb/SVG/SVGElement.cpp | 8 ++++++-- Userland/Libraries/LibWeb/SVG/SVGElement.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'Userland/Libraries') diff --git a/Userland/Libraries/LibWeb/SVG/SVGElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGElement.cpp index 189a6c7a54..09da38721d 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGElement.cpp @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include #include #include @@ -12,7 +13,6 @@ namespace Web::SVG { SVGElement::SVGElement(DOM::Document& document, DOM::QualifiedName qualified_name) : Element(document, move(qualified_name)) - , m_dataset(HTML::DOMStringMap::create(*this).release_value_but_fixme_should_propagate_errors()) { } @@ -21,13 +21,17 @@ JS::ThrowCompletionOr SVGElement::initialize(JS::Realm& realm) MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype(realm, "SVGElement")); + m_dataset = TRY(Bindings::throw_dom_exception_if_needed(realm.vm(), [&]() { + return HTML::DOMStringMap::create(*this); + })); + return {}; } void SVGElement::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); - visitor.visit(m_dataset.ptr()); + visitor.visit(m_dataset); } } diff --git a/Userland/Libraries/LibWeb/SVG/SVGElement.h b/Userland/Libraries/LibWeb/SVG/SVGElement.h index 7ffff6f812..e3ce0535c2 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGElement.h @@ -25,7 +25,7 @@ protected: virtual JS::ThrowCompletionOr initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; - JS::NonnullGCPtr m_dataset; + JS::GCPtr m_dataset; }; } -- cgit v1.2.3