1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 21:18:14 +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

@ -16,10 +16,9 @@ namespace Web::HTML {
class HTMLElement
: public DOM::Element
, public HTML::GlobalEventHandlers {
public:
using WrapperType = Bindings::HTMLElementWrapper;
WEB_PLATFORM_OBJECT(HTMLElement, DOM::Element);
HTMLElement(DOM::Document&, DOM::QualifiedName);
public:
virtual ~HTMLElement() override;
String title() const { return attribute(HTML::AttributeNames::title); }
@ -38,8 +37,8 @@ public:
bool cannot_navigate() const;
DOMStringMap* dataset() { return m_dataset.cell(); }
DOMStringMap const* dataset() const { return m_dataset.cell(); }
DOMStringMap* dataset() { return m_dataset.ptr(); }
DOMStringMap const* dataset() const { return m_dataset.ptr(); }
void focus();
@ -51,8 +50,12 @@ public:
virtual bool is_labelable() const { return false; }
protected:
HTMLElement(DOM::Document&, DOM::QualifiedName);
virtual void parse_attribute(FlyString const& name, String const& value) override;
virtual void visit_edges(Cell::Visitor&) override;
private:
virtual bool is_html_element() const final { return true; }
@ -66,7 +69,7 @@ private:
};
ContentEditableState content_editable_state() const;
JS::Handle<DOMStringMap> m_dataset;
JS::NonnullGCPtr<DOMStringMap> m_dataset;
// https://html.spec.whatwg.org/multipage/interaction.html#locked-for-focus
bool m_locked_for_focus { false };
@ -81,3 +84,5 @@ namespace Web::DOM {
template<>
inline bool Node::fast_is<HTML::HTMLElement>() const { return is_html_element(); }
}
WRAPPER_HACK(HTMLElement, Web::HTML)