1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:27:45 +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

@ -99,6 +99,7 @@ void TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder::Context&
if (is<DOM::Element>(dom_node)) {
auto& element = static_cast<DOM::Element&>(dom_node);
element.clear_pseudo_element_nodes({});
auto style = style_computer.compute_style(element);
if (style->display().is_none())
return;
@ -193,20 +194,26 @@ void TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder::Context&
};
push_parent(verify_cast<NodeWithStyle>(*layout_node));
if (auto before_node = create_pseudo_element_if_needed(CSS::Selector::PseudoElement::Before))
if (auto before_node = create_pseudo_element_if_needed(CSS::Selector::PseudoElement::Before)) {
element.set_pseudo_element_node({}, CSS::Selector::PseudoElement::Before, before_node);
insert_node_into_inline_or_block_ancestor(before_node, true);
if (auto after_node = create_pseudo_element_if_needed(CSS::Selector::PseudoElement::After))
}
if (auto after_node = create_pseudo_element_if_needed(CSS::Selector::PseudoElement::After)) {
element.set_pseudo_element_node({}, CSS::Selector::PseudoElement::After, after_node);
insert_node_into_inline_or_block_ancestor(after_node);
}
pop_parent();
}
if (is<ListItemBox>(*layout_node)) {
auto& element = static_cast<DOM::Element&>(dom_node);
int child_index = layout_node->parent()->index_of_child<ListItemBox>(*layout_node).value();
auto marker_style = style_computer.compute_style(static_cast<DOM::Element&>(dom_node), CSS::Selector::PseudoElement::Marker);
auto marker_style = style_computer.compute_style(element, CSS::Selector::PseudoElement::Marker);
auto list_item_marker = adopt_ref(*new ListItemMarkerBox(document, layout_node->computed_values().list_style_type(), child_index + 1, *marker_style));
if (layout_node->first_child())
list_item_marker->set_inline(layout_node->first_child()->is_inline());
static_cast<ListItemBox&>(*layout_node).set_marker(list_item_marker);
element.set_pseudo_element_node({}, CSS::Selector::PseudoElement::Marker, list_item_marker);
layout_node->append_child(move(list_item_marker));
}
}