summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/HTML/HTMLElement.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-08-28 13:42:07 +0200
committerAndreas Kling <kling@serenityos.org>2022-09-06 00:27:09 +0200
commit6f433c86564c24d47d520cb5bdcc2209d724ac96 (patch)
tree886a2f727782e466e99c61c628637872c1b7403f /Userland/Libraries/LibWeb/HTML/HTMLElement.h
parentbb547ce1c4251e3689287eac845593398a379ca5 (diff)
downloadserenity-6f433c86564c24d47d520cb5bdcc2209d724ac96.zip
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.
Diffstat (limited to 'Userland/Libraries/LibWeb/HTML/HTMLElement.h')
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLElement.h17
1 files changed, 11 insertions, 6 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLElement.h b/Userland/Libraries/LibWeb/HTML/HTMLElement.h
index 1c0376668e..a40cd1cfd1 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLElement.h
+++ b/Userland/Libraries/LibWeb/HTML/HTMLElement.h
@@ -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)