1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 20:25:07 +00:00

LibWeb: Make the layout tree GC-allocated

This removes a set of complex reference cycles between DOM, layout tree
and browsing context.

It also makes lifetimes much easier to reason about, as the DOM and
layout trees are now free to keep each other alive.
This commit is contained in:
Andreas Kling 2022-10-17 14:41:50 +02:00
parent 83c5ff57d8
commit 268b9c5d90
72 changed files with 258 additions and 207 deletions

View file

@ -51,21 +51,21 @@ void HTMLInputElement::visit_edges(Cell::Visitor& visitor)
visitor.visit(m_selected_files);
}
RefPtr<Layout::Node> HTMLInputElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)
JS::GCPtr<Layout::Node> HTMLInputElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)
{
if (type_state() == TypeAttributeState::Hidden)
return nullptr;
if (type_state() == TypeAttributeState::SubmitButton || type_state() == TypeAttributeState::Button || type_state() == TypeAttributeState::ResetButton || type_state() == TypeAttributeState::FileUpload)
return adopt_ref(*new Layout::ButtonBox(document(), *this, move(style)));
return heap().allocate_without_realm<Layout::ButtonBox>(document(), *this, move(style));
if (type_state() == TypeAttributeState::Checkbox)
return adopt_ref(*new Layout::CheckBox(document(), *this, move(style)));
return heap().allocate_without_realm<Layout::CheckBox>(document(), *this, move(style));
if (type_state() == TypeAttributeState::RadioButton)
return adopt_ref(*new Layout::RadioButton(document(), *this, move(style)));
return heap().allocate_without_realm<Layout::RadioButton>(document(), *this, move(style));
return adopt_ref(*new Layout::BlockContainer(document(), this, move(style)));
return heap().allocate_without_realm<Layout::BlockContainer>(document(), this, move(style));
}
void HTMLInputElement::set_checked(bool checked, ChangeSource change_source)