diff --git a/Tests/LibWeb/Layout/expected/block-and-inline/button-with-abspos-pseudo-element.txt b/Tests/LibWeb/Layout/expected/block-and-inline/button-with-abspos-pseudo-element.txt index 151afd1937..81ccd3d56b 100644 --- a/Tests/LibWeb/Layout/expected/block-and-inline/button-with-abspos-pseudo-element.txt +++ b/Tests/LibWeb/Layout/expected/block-and-inline/button-with-abspos-pseudo-element.txt @@ -5,15 +5,15 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline frag 0 from BlockContainer start: 0, length: 0, rect: [29,29 0x0] BlockContainer \ No newline at end of file diff --git a/Tests/LibWeb/Layout/input/block-and-inline/button-with-before-pseudo.html b/Tests/LibWeb/Layout/input/block-and-inline/button-with-before-pseudo.html new file mode 100644 index 0000000000..6e54f8c7f6 --- /dev/null +++ b/Tests/LibWeb/Layout/input/block-and-inline/button-with-before-pseudo.html @@ -0,0 +1,18 @@ + \ No newline at end of file diff --git a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp index d0034bdf08..1a2dccbe40 100644 --- a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp +++ b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp @@ -332,15 +332,6 @@ ErrorOr TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder:: pop_parent(); } - // Add nodes for the ::before and ::after pseudo-elements. - if (is(dom_node)) { - auto& element = static_cast(dom_node); - push_parent(verify_cast(*layout_node)); - TRY(create_pseudo_element_if_needed(element, CSS::Selector::PseudoElement::Before, AppendOrPrepend::Prepend)); - TRY(create_pseudo_element_if_needed(element, CSS::Selector::PseudoElement::After, AppendOrPrepend::Append)); - pop_parent(); - } - if (is(*layout_node)) { auto& element = static_cast(dom_node); int child_index = layout_node->parent()->index_of_child(*layout_node).value(); @@ -414,6 +405,15 @@ ErrorOr TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder:: parent.set_children_are_inline(false); } + // Add nodes for the ::before and ::after pseudo-elements. + if (is(dom_node)) { + auto& element = static_cast(dom_node); + push_parent(verify_cast(*layout_node)); + TRY(create_pseudo_element_if_needed(element, CSS::Selector::PseudoElement::Before, AppendOrPrepend::Prepend)); + TRY(create_pseudo_element_if_needed(element, CSS::Selector::PseudoElement::After, AppendOrPrepend::Append)); + pop_parent(); + } + return {}; }