Skip to content

Truly independent web browser

LibWeb: Hold found slottables conservatively

Shannon Booth2ed530cb4add
diff --git a/Libraries/LibWeb/DOM/Slottable.cpp b/Libraries/LibWeb/DOM/Slottable.cpp
index 8ddf2ce646f..ca0d470f4a6 100644
--- a/Libraries/LibWeb/DOM/Slottable.cpp
+++ b/Libraries/LibWeb/DOM/Slottable.cpp
@@ -154,10 +154,10 @@ GC::Ptr<HTML::HTMLSlotElement> find_a_slot(Slottable const& slottable, OpenFlag
}
// https://dom.spec.whatwg.org/#find-slotables
-Vector<Slottable> find_slottables(GC::Ref<HTML::HTMLSlotElement> slot)
+GC::ConservativeVector<Slottable> find_slottables(GC::Ref<HTML::HTMLSlotElement> slot)
{
// 1. Let result be an empty list.
- Vector<Slottable> result;
+ GC::ConservativeVector<Slottable> result;
// 2. Let root be slot’s root.
auto& root = slot->root();
@@ -205,10 +205,10 @@ Vector<Slottable> find_slottables(GC::Ref<HTML::HTMLSlotElement> slot)
}
// https://dom.spec.whatwg.org/#find-flattened-slotables
-Vector<Slottable> find_flattened_slottables(GC::Ref<HTML::HTMLSlotElement> slot)
+GC::ConservativeVector<Slottable> find_flattened_slottables(GC::Ref<HTML::HTMLSlotElement> slot)
{
// 1. Let result be « ».
- Vector<Slottable> result;
+ GC::ConservativeVector<Slottable> result;
// 2. If slot’s root is not a shadow root, then return result.
if (!slot->root().is_shadow_root())
@@ -300,7 +300,7 @@ void assign_slottables(GC::Ref<HTML::HTMLSlotElement> slot, SignalSlotChange sig
// old slottables to another slot, which the old slot must not overwrite when it is
// processed afterward.
if (assignment_changed && !slot->assigned_nodes_internal().is_empty()) {
- HashTable<Node const*> slottable_nodes;
+ GC::RootHashTable<Node const*> slottable_nodes;
slottable_nodes.ensure_capacity(slottables.size());
for (auto const& slottable : slottables)
slottable_nodes.set(slottable_as_node(slottable));
diff --git a/Libraries/LibWeb/DOM/Slottable.h b/Libraries/LibWeb/DOM/Slottable.h
index f78e3946a0f..461577404c6 100644
--- a/Libraries/LibWeb/DOM/Slottable.h
+++ b/Libraries/LibWeb/DOM/Slottable.h
@@ -8,6 +8,7 @@
#include <AK/Utf16FlyString.h>
#include <AK/Variant.h>
+#include <LibGC/ConservativeVector.h>
#include <LibGC/Ptr.h>
#include <LibJS/Heap/Cell.h>
#include <LibWeb/Export.h>
@@ -69,8 +70,8 @@ GC::Ptr<HTML::HTMLSlotElement> assigned_slot_for_node(GC::Ref<Node>);
bool is_an_assigned_slottable(GC::Ref<Node>);
GC::Ptr<HTML::HTMLSlotElement> find_a_slot(Slottable const&, OpenFlag = OpenFlag::Unset);
-Vector<Slottable> find_slottables(GC::Ref<HTML::HTMLSlotElement>);
-Vector<Slottable> find_flattened_slottables(GC::Ref<HTML::HTMLSlotElement>);
+GC::ConservativeVector<Slottable> find_slottables(GC::Ref<HTML::HTMLSlotElement>);
+GC::ConservativeVector<Slottable> find_flattened_slottables(GC::Ref<HTML::HTMLSlotElement>);
void assign_slottables(GC::Ref<HTML::HTMLSlotElement>, SignalSlotChange = SignalSlotChange::Yes);
void assign_slottables_for_a_tree(GC::Ref<Node>);
void assign_a_slot(Slottable const&);