1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:47:44 +00:00

LibWeb: Don't generate ::before/::after for BR elements

We shouldn't be putting generated pseudo elements inside elements that
can't have children in the first place.

This patch fixes two issues:
- We stop generating pseudo elements for layout nodes that can't have
  children anyway.
- We mark Layout::BreakNode as not being able to have children.
This commit is contained in:
Andreas Kling 2023-09-14 14:30:39 +02:00
parent a7c1af08ca
commit 80a78c4deb
4 changed files with 34 additions and 1 deletions

View file

@ -427,7 +427,7 @@ ErrorOr<void> TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder::
}
// Add nodes for the ::before and ::after pseudo-elements.
if (is<DOM::Element>(dom_node)) {
if (is<DOM::Element>(dom_node) && layout_node->can_have_children()) {
auto& element = static_cast<DOM::Element&>(dom_node);
push_parent(verify_cast<NodeWithStyle>(*layout_node));
TRY(create_pseudo_element_if_needed(element, CSS::Selector::PseudoElement::Before, AppendOrPrepend::Prepend));