summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp
diff options
context:
space:
mode:
authorAliaksandr Kalenik <kalenik.aliaksandr@gmail.com>2022-11-23 00:55:12 +0300
committerAndreas Kling <kling@serenityos.org>2022-11-23 15:05:57 +0100
commit0ca1af00e792b0f5a2649e4e449ddcfa658c22cb (patch)
treedee3b5430cf171473c75add76149259934b631ae /Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp
parente277185eb1da950f6bb2982dc4f1495cce6988d0 (diff)
downloadserenity-0ca1af00e792b0f5a2649e4e449ddcfa658c22cb.zip
LibWeb: Try to place out-of-flow blocks only in anonymous blocks
This change makes out-of-flow blocks to be considered for joining only to anonymous blocks that have inline children. It finally solved the problem that out-of-flow break anonymous blocks into chunks causing wrong layout without regressing Acid2.
Diffstat (limited to 'Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp')
-rw-r--r--Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp
index 6227f381df..a95f5a0bf1 100644
--- a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp
+++ b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp
@@ -84,9 +84,7 @@ static Layout::Node& insertion_parent_for_block_node(Layout::NodeWithStyle& layo
return layout_parent;
}
- // TODO: Floats should probably also be able to have inline siblings
- if (layout_node.is_absolutely_positioned() && layout_parent.last_child()->children_are_inline()) {
- // Block is out-of-flow, it can have inline siblings if necessary.
+ if ((layout_node.is_absolutely_positioned() || layout_node.is_floating()) && layout_parent.last_child()->children_are_inline() && layout_parent.last_child()->is_anonymous()) {
return *layout_parent.last_child();
}
@@ -95,6 +93,11 @@ static Layout::Node& insertion_parent_for_block_node(Layout::NodeWithStyle& layo
return layout_parent;
}
+ if (layout_node.is_absolutely_positioned() || layout_node.is_floating()) {
+ // Block is out-of-flow, it can have inline siblings if necessary.
+ return layout_parent;
+ }
+
// Parent block has inline-level children (our siblings).
// First move these siblings into an anonymous wrapper block.
Vector<JS::Handle<Layout::Node>> children;