From 7d863174b34750ba1e676adf601d2a7c77141e07 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 1 Jan 2023 15:32:48 +0100 Subject: [PATCH] LibWeb: Use a JS::NonnullGCPtr for DOMTokenList::m_associated_element Both Element and DOMTokenList are GC-allocated objects so they can just mark each other instead of using the old strong/weak pattern we use in ref-counting ownership models. --- Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp | 6 ++++++ Userland/Libraries/LibWeb/DOM/DOMTokenList.h | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp b/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp index 883e39e48e..8806e05fa3 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp +++ b/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp @@ -68,6 +68,12 @@ DOMTokenList::DOMTokenList(Element const& associated_element, FlyString associat associated_attribute_changed(value); } +void DOMTokenList::visit_edges(Cell::Visitor& visitor) +{ + Base::visit_edges(visitor); + visitor.visit(m_associated_element); +} + // https://dom.spec.whatwg.org/#ref-for-domtokenlist%E2%91%A0%E2%91%A1 void DOMTokenList::associated_attribute_changed(StringView value) { diff --git a/Userland/Libraries/LibWeb/DOM/DOMTokenList.h b/Userland/Libraries/LibWeb/DOM/DOMTokenList.h index 3e56117537..40b3704d35 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMTokenList.h +++ b/Userland/Libraries/LibWeb/DOM/DOMTokenList.h @@ -45,10 +45,12 @@ public: private: DOMTokenList(Element const& associated_element, FlyString associated_attribute); + virtual void visit_edges(Cell::Visitor&) override; + WebIDL::ExceptionOr validate_token(StringView token) const; void run_update_steps(); - WeakPtr m_associated_element; + JS::NonnullGCPtr m_associated_element; FlyString m_associated_attribute; Vector m_token_set; };