From 7b4c76788b6b536cb9a30b8361d15845e081b5b3 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 6 Apr 2023 18:01:01 +0200 Subject: [PATCH] LibWeb: Don't put abspos grid/flex items in anonymous wrapper Grid and flex containers have their own rules for abspos items, so we shouldn't try to be clever and put them in the "current" anonymous wrapper block. That behavior is primarily for the benefit of block & inline layout. --- ...lex-abspos-item-with-preceding-whitespace.txt | 7 +++++++ ...ex-abspos-item-with-preceding-whitespace.html | 16 ++++++++++++++++ Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp | 2 ++ 3 files changed, 25 insertions(+) create mode 100644 Tests/LibWeb/Layout/expected/flex-abspos-item-with-preceding-whitespace.txt create mode 100644 Tests/LibWeb/Layout/input/flex-abspos-item-with-preceding-whitespace.html diff --git a/Tests/LibWeb/Layout/expected/flex-abspos-item-with-preceding-whitespace.txt b/Tests/LibWeb/Layout/expected/flex-abspos-item-with-preceding-whitespace.txt new file mode 100644 index 00000000000..7fa013d846c --- /dev/null +++ b/Tests/LibWeb/Layout/expected/flex-abspos-item-with-preceding-whitespace.txt @@ -0,0 +1,7 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (1,1) content-size 798x20 children: not-inline + BlockContainer at (10,10) content-size 780x2 children: not-inline + Box at (11,11) content-size 778x0 flex-container(row) children: not-inline + BlockContainer <(anonymous)> at (11,11) content-size 0x0 children: inline + TextNode <#text> + BlockContainer at (11,-39) content-size 100x100 positioned children: not-inline diff --git a/Tests/LibWeb/Layout/input/flex-abspos-item-with-preceding-whitespace.html b/Tests/LibWeb/Layout/input/flex-abspos-item-with-preceding-whitespace.html new file mode 100644 index 00000000000..a92bd052a19 --- /dev/null +++ b/Tests/LibWeb/Layout/input/flex-abspos-item-with-preceding-whitespace.html @@ -0,0 +1,16 @@ +
\ No newline at end of file diff --git a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp index 4022652be4a..e041c361bb7 100644 --- a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp +++ b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp @@ -92,6 +92,8 @@ static Layout::Node& insertion_parent_for_block_node(Layout::NodeWithStyle& layo bool is_out_of_flow = layout_node.is_absolutely_positioned() || layout_node.is_floating(); if (is_out_of_flow + && !layout_parent.display().is_flex_inside() + && !layout_parent.display().is_grid_inside() && layout_parent.last_child()->is_anonymous() && layout_parent.last_child()->children_are_inline()) { // Block is out-of-flow & previous sibling was wrapped in an anonymous block.