1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 19:37:36 +00:00

LibWeb: Display pseudo-elements in the DOM inspector

This patch only makes them appear in the tree - they are not yet
inspectable themselves.
This commit is contained in:
Sam Atkins 2022-03-03 17:50:12 +00:00 committed by Andreas Kling
parent 1c18bb13a2
commit 6de2b62906
5 changed files with 57 additions and 3 deletions

View file

@ -501,4 +501,34 @@ void Element::children_changed()
set_needs_style_update(true);
}
void Element::set_pseudo_element_node(Badge<Layout::TreeBuilder>, CSS::Selector::PseudoElement pseudo_element, RefPtr<Layout::Node> pseudo_element_node)
{
m_pseudo_element_nodes[to_underlying(pseudo_element)] = move(pseudo_element_node);
}
RefPtr<Layout::Node> Element::get_pseudo_element_node(CSS::Selector::PseudoElement pseudo_element) const
{
return m_pseudo_element_nodes[to_underlying(pseudo_element)];
}
void Element::clear_pseudo_element_nodes(Badge<Layout::TreeBuilder>)
{
m_pseudo_element_nodes.fill(nullptr);
}
void Element::serialize_pseudo_elements_as_json(JsonArraySerializer<StringBuilder>& children_array) const
{
for (size_t i = 0; i < m_pseudo_element_nodes.size(); ++i) {
auto& pseudo_element_node = m_pseudo_element_nodes[i];
if (!pseudo_element_node)
continue;
auto object = MUST(children_array.add_object());
MUST(object.add("name", String::formatted("::{}", CSS::pseudo_element_name(static_cast<CSS::Selector::PseudoElement>(i)))));
MUST(object.add("type", "pseudo-element"));
MUST(object.add("parent-id", id()));
MUST(object.add("pseudo-element", i));
MUST(object.finish());
}
}
}