mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:17:35 +00:00
LibWeb: Make NodeList GC-allocated
This commit is contained in:
parent
8f4ea4e308
commit
48e0066371
16 changed files with 128 additions and 57 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -7,19 +8,18 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Function.h>
|
||||
#include <AK/NonnullRefPtrVector.h>
|
||||
#include <LibWeb/DOM/NodeList.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
// FIXME: Just like HTMLCollection, LiveNodeList currently does no caching.
|
||||
|
||||
class LiveNodeList : public NodeList {
|
||||
class LiveNodeList final : public NodeList {
|
||||
WEB_PLATFORM_OBJECT(LiveNodeList, NodeList);
|
||||
|
||||
public:
|
||||
static NonnullRefPtr<NodeList> create(Node& root, Function<bool(Node const&)> filter)
|
||||
{
|
||||
return adopt_ref(*new LiveNodeList(root, move(filter)));
|
||||
}
|
||||
static JS::NonnullGCPtr<NodeList> create(HTML::Window&, Node& root, Function<bool(Node const&)> filter);
|
||||
virtual ~LiveNodeList() override;
|
||||
|
||||
virtual u32 length() const override;
|
||||
virtual Node const* item(u32 index) const override;
|
||||
|
@ -27,11 +27,13 @@ public:
|
|||
virtual bool is_supported_property_index(u32) const override;
|
||||
|
||||
private:
|
||||
LiveNodeList(Node& root, Function<bool(Node const&)> filter);
|
||||
LiveNodeList(HTML::Window&, Node& root, Function<bool(Node const&)> filter);
|
||||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
JS::MarkedVector<Node*> collection() const;
|
||||
|
||||
JS::Handle<Node> m_root;
|
||||
JS::NonnullGCPtr<Node> m_root;
|
||||
Function<bool(Node const&)> m_filter;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue