Truly independent web browser
LibWeb: Splice in-flow positioned blocks after pending whitespace
Aliaksandr Kalenik174edf9843b6
diff --git a/Libraries/LibWeb/Rust/src/layout/tree_builder.rs b/Libraries/LibWeb/Rust/src/layout/tree_builder.rsindex 126661b0024..6fecc38b6d6 100644--- a/Libraries/LibWeb/Rust/src/layout/tree_builder.rs+++ b/Libraries/LibWeb/Rust/src/layout/tree_builder.rs@@ -1094,9 +1094,7 @@ impl ChildListInsertionReuse<'_, '_> {&& child_facts.position != positioning::FIXED&& child_facts.float_ == float::NONE;if parent_lays_out_flex_or_grid_children {- if has_pending_collapsing_whitespace- && (child_facts.position != positioning::STATIC || child_facts.float_ != float::NONE)- {+ if has_pending_collapsing_whitespace && !child_is_in_flow {return false;}has_pending_collapsing_whitespace = false;@@ -1107,9 +1105,7 @@ impl ChildListInsertionReuse<'_, '_> {continue;}if parent_lays_out_block_children && child_display.is_block_outside() {- if has_pending_collapsing_whitespace- && (child_facts.position != positioning::STATIC || child_facts.float_ != float::NONE)- {+ if has_pending_collapsing_whitespace && !child_is_in_flow {return false;}has_pending_collapsing_whitespace = false;diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/direct-child-list-preservation.txt b/Tests/LibWeb/Text/expected/layout-tree-update/direct-child-list-preservation.txtindex ba6e9e04eba..0f339a368ca 100644--- a/Tests/LibWeb/Text/expected/layout-tree-update/direct-child-list-preservation.txt+++ b/Tests/LibWeb/Text/expected/layout-tree-update/direct-child-list-preservation.txt@@ -131,6 +131,23 @@ PASS: append positioned in-flow block child after anonymous inline run | preservPASS: append positioned in-flow block child after anonymous inline run | preserve beforePASS: append positioned in-flow block child after anonymous inline run | layout tree builds=1PASS: append positioned in-flow block child after anonymous inline run | incremental tree matches full rebuild+PASS: append relative block child after whitespace | preserve parent+PASS: append relative block child after whitespace | preserve before+PASS: append relative block child after whitespace | layout tree builds=1+PASS: append relative block child after whitespace | incremental tree matches full rebuild+PASS: append sticky block child after whitespace | preserve parent+PASS: append sticky block child after whitespace | preserve before+PASS: append sticky block child after whitespace | layout tree builds=1+PASS: append sticky block child after whitespace | incremental tree matches full rebuild+PASS: insert relative block child after whitespace | preserve parent+PASS: insert relative block child after whitespace | preserve before+PASS: insert relative block child after whitespace | preserve after+PASS: insert relative block child after whitespace | layout tree builds=1+PASS: insert relative block child after whitespace | incremental tree matches full rebuild+PASS: append relative item after whitespace in flex | preserve parent+PASS: append relative item after whitespace in flex | preserve before+PASS: append relative item after whitespace in flex | layout tree builds=1+PASS: append relative item after whitespace in flex | incremental tree matches full rebuildPASS: fall back for block child before anonymous inline run | rebuild parentPASS: fall back for block child before anonymous inline run | layout tree builds=1PASS: fall back for block child before anonymous inline run | incremental tree matches full rebuilddiff --git a/Tests/LibWeb/Text/input/layout-tree-update/direct-child-list-preservation.html b/Tests/LibWeb/Text/input/layout-tree-update/direct-child-list-preservation.htmlindex d051b4f2bd3..32165d76182 100644--- a/Tests/LibWeb/Text/input/layout-tree-update/direct-child-list-preservation.html+++ b/Tests/LibWeb/Text/input/layout-tree-update/direct-child-list-preservation.html@@ -245,6 +245,30 @@mutate: parent => parent.insertAdjacentHTML("beforeend", '<section class="target child" style="position: relative"><b></b></section>'),tracked: ["parent", "before"],},+ {+ name: "append relative block child after whitespace",+ markup: '<div class="parent"><i class="before child"></i></div>',+ mutate: parent => parent.insertAdjacentHTML("beforeend", '\n<section class="target child" style="position: relative"><b></b></section>'),+ tracked: ["parent", "before"],+ },+ {+ name: "append sticky block child after whitespace",+ markup: '<div class="parent"><i class="before child"></i></div>',+ mutate: parent => parent.insertAdjacentHTML("beforeend", '\n<section class="target child" style="position: sticky"><b></b></section>'),+ tracked: ["parent", "before"],+ },+ {+ name: "insert relative block child after whitespace",+ markup: '<div class="parent"><i class="before child"></i><i class="after child"></i></div>',+ mutate: parent => parent.querySelector(".after").insertAdjacentHTML("beforebegin", '\n<section class="target child" style="position: relative"><b></b></section>'),+ tracked: ["parent", "before", "after"],+ },+ {+ name: "append relative item after whitespace in flex",+ markup: '<div class="parent flex"><i class="before child"></i></div>',+ mutate: parent => parent.insertAdjacentHTML("beforeend", '\n<section class="target child" style="position: relative"><b></b></section>'),+ tracked: ["parent", "before"],+ },{name: "fall back for block child before anonymous inline run",markup: '<div class="parent"><i class="before child"></i><span class="inline">inline</span></div>',