summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/DOM/HTMLCollection.h
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibWeb/DOM/HTMLCollection.h')
-rw-r--r--Userland/Libraries/LibWeb/DOM/HTMLCollection.h37
1 files changed, 14 insertions, 23 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/HTMLCollection.h b/Userland/Libraries/LibWeb/DOM/HTMLCollection.h
index eae346bf07..b9f5a7eca2 100644
--- a/Userland/Libraries/LibWeb/DOM/HTMLCollection.h
+++ b/Userland/Libraries/LibWeb/DOM/HTMLCollection.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2021-2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -8,9 +8,8 @@
#include <AK/FlyString.h>
#include <AK/Function.h>
-#include <AK/Noncopyable.h>
#include <LibJS/Heap/GCPtr.h>
-#include <LibWeb/Bindings/Wrappable.h>
+#include <LibWeb/Bindings/LegacyPlatformObject.h>
#include <LibWeb/Forward.h>
namespace Web::DOM {
@@ -26,21 +25,13 @@ namespace Web::DOM {
// We should teach it how to cache results. The main challenge is invalidating
// these caches, since this needs to happen on various kinds of DOM mutation.
-class HTMLCollection
- : public RefCounted<HTMLCollection>
- , public Bindings::Wrappable {
- AK_MAKE_NONCOPYABLE(HTMLCollection);
- AK_MAKE_NONMOVABLE(HTMLCollection);
+class HTMLCollection : public Bindings::LegacyPlatformObject {
+ WEB_PLATFORM_OBJECT(HTMLCollection, Bindings::LegacyPlatformObject);
public:
- using WrapperType = Bindings::HTMLCollectionWrapper;
+ static JS::NonnullGCPtr<HTMLCollection> create(ParentNode& root, Function<bool(Element const&)> filter);
- static NonnullRefPtr<HTMLCollection> create(ParentNode& root, Function<bool(Element const&)> filter)
- {
- return adopt_ref(*new HTMLCollection(root, move(filter)));
- }
-
- ~HTMLCollection();
+ virtual ~HTMLCollection() override;
size_t length();
Element* item(size_t index) const;
@@ -48,8 +39,10 @@ public:
JS::MarkedVector<Element*> collect_matching_elements() const;
- Vector<String> supported_property_names() const;
- bool is_supported_property_index(u32) const;
+ virtual JS::Value item_value(size_t index) const override;
+ virtual JS::Value named_item_value(FlyString const& name) const override;
+ virtual Vector<String> supported_property_names() const override;
+ virtual bool is_supported_property_index(u32) const override;
protected:
HTMLCollection(ParentNode& root, Function<bool(Element const&)> filter);
@@ -57,14 +50,12 @@ protected:
JS::NonnullGCPtr<ParentNode> root() { return *m_root; }
private:
- JS::Handle<ParentNode> m_root;
+ virtual void visit_edges(Cell::Visitor&) override;
+
+ JS::NonnullGCPtr<ParentNode> m_root;
Function<bool(Element const&)> m_filter;
};
}
-namespace Web::Bindings {
-
-HTMLCollectionWrapper* wrap(JS::Realm&, DOM::HTMLCollection&);
-
-}
+WRAPPER_HACK(HTMLCollection, Web::DOM)