1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:38:11 +00:00

LibWeb+LibJS: Make the EventTarget hierarchy (incl. DOM) GC-allocated

This is a monster patch that turns all EventTargets into GC-allocated
PlatformObjects. Their C++ wrapper classes are removed, and the LibJS
garbage collector is now responsible for their lifetimes.

There's a fair amount of hacks and band-aids in this patch, and we'll
have a lot of cleanup to do after this.
This commit is contained in:
Andreas Kling 2022-08-28 13:42:07 +02:00
parent bb547ce1c4
commit 6f433c8656
445 changed files with 4797 additions and 4268 deletions

View file

@ -12,24 +12,26 @@
namespace Web::HTML {
class HTMLTemplateElement final : public HTMLElement {
public:
using WrapperType = Bindings::HTMLTemplateElementWrapper;
WEB_PLATFORM_OBJECT(HTMLTemplateElement, HTMLElement);
HTMLTemplateElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLTemplateElement() override;
NonnullRefPtr<DOM::DocumentFragment> content() { return *m_content; }
NonnullRefPtr<DOM::DocumentFragment> const content() const { return *m_content; }
JS::NonnullGCPtr<DOM::DocumentFragment> content() { return *m_content; }
JS::NonnullGCPtr<DOM::DocumentFragment> const content() const { return *m_content; }
virtual void adopted_from(DOM::Document&) override;
virtual void cloned(Node& copy, bool clone_children) override;
private:
HTMLTemplateElement(DOM::Document&, DOM::QualifiedName);
virtual bool is_html_template_element() const final { return true; }
virtual void visit_edges(Cell::Visitor&) override;
DOM::Document& appropriate_template_contents_owner_document(DOM::Document&);
RefPtr<DOM::DocumentFragment> m_content;
JS::GCPtr<DOM::DocumentFragment> m_content;
};
}
@ -38,3 +40,5 @@ namespace Web::DOM {
template<>
inline bool Node::fast_is<HTML::HTMLTemplateElement>() const { return is_html_template_element(); }
}
WRAPPER_HACK(HTMLTemplateElement, Web::HTML)