Truly independent web browser
LibWeb: Rebuild from a ::first-letter owner what holds its letter
Andreas Klingd529e32f4aeb
diff --git a/Libraries/LibWeb/DOM/Node.cpp b/Libraries/LibWeb/DOM/Node.cppindex da6649db462..bdd0debeb44 100644--- a/Libraries/LibWeb/DOM/Node.cpp+++ b/Libraries/LibWeb/DOM/Node.cpp@@ -2641,7 +2641,7 @@ void Node::set_needs_layout_tree_update(bool value, SetNeedsLayoutTreeUpdateReasif (identity == 0)return;- if (value && reason == SetNeedsLayoutTreeUpdateReason::NodeInsertBefore) {+ if (value) {Layout::ForcedReadScope read { document() };if (auto* first_letter_owner = first_letter_owner_for_layout_subtree_from(read, *this); first_letter_owner && first_letter_owner != this)first_letter_owner->set_needs_layout_tree_update(true, reason);diff --git a/Libraries/LibWeb/Rust/src/layout/tree_update_marks.rs b/Libraries/LibWeb/Rust/src/layout/tree_update_marks.rsindex 99e63c23518..b8a138369cb 100644--- a/Libraries/LibWeb/Rust/src/layout/tree_update_marks.rs+++ b/Libraries/LibWeb/Rust/src/layout/tree_update_marks.rs@@ -318,8 +318,7 @@ impl LayoutNodeArena {let Some(style_node) = node.or(document) else {return;};- if mark.is_child_list_insertion- && let Some(element) = node+ if let Some(element) = node&& let Some(owner) = self.first_letter_owner_covering(element)&& owner != element{@@ -385,7 +384,7 @@ impl LayoutNodeArena {}/// The `::first-letter` owner on or above the element `element` whose first letter its box holds, or that has no- /// first-letter box, whose rebuild an insertion under `element` reaches. See+ /// first-letter box, whose rebuild a rebuild of `element` reaches: it alone finds the letter again. See/// `DOM::Node::first_letter_owner_for_layout_subtree_from`.fn first_letter_owner_covering(&self, element: StyleNodeID) -> Option<StyleNodeID> {let layout_node = self.bound_row(element);diff --git a/Tests/LibWeb/Text/expected/Layout/first-letter-below-a-rebuilt-box.txt b/Tests/LibWeb/Text/expected/Layout/first-letter-below-a-rebuilt-box.txtnew file mode 100644index 00000000000..2d2cd978d05--- /dev/null+++ b/Tests/LibWeb/Text/expected/Layout/first-letter-below-a-rebuilt-box.txt@@ -0,0 +1,8 @@+sibling out of flow to in flow: matches a full rebuild+sibling block to inline: matches a full rebuild+sibling inline to block: matches a full rebuild+sibling hidden: matches a full rebuild+sibling shown: matches a full rebuild+own box: matches a full rebuild+inside an inline: matches a full rebuild+list marker: matches a full rebuilddiff --git a/Tests/LibWeb/Text/input/Layout/first-letter-below-a-rebuilt-box.html b/Tests/LibWeb/Text/input/Layout/first-letter-below-a-rebuilt-box.htmlnew file mode 100644index 00000000000..4fc660a8ec1--- /dev/null+++ b/Tests/LibWeb/Text/input/Layout/first-letter-below-a-rebuilt-box.html@@ -0,0 +1,31 @@+<!DOCTYPE html>+<script src="../include.js"></script>+<style>+ .owner::first-letter { color: red; }+</style>+<body>+<script>+ function check(label, html, change) {+ const owner = document.createElement("div");+ owner.className = "owner";+ owner.innerHTML = html;+ document.body.append(owner);+ document.body.offsetWidth;+ change(owner.querySelector("#t"));+ document.body.offsetWidth;+ const comparison = internals.compareLayoutTreeWithFullRebuild();+ println(`${label}: ${comparison.matches ? "matches a full rebuild" : "differs from a full rebuild"}`);+ owner.remove();+ }++ test(() => {+ check("sibling out of flow to in flow", "<div>a<div id=t style='position: absolute'>x</div>b</div>", t => { t.style.position = "relative"; });+ check("sibling block to inline", "<div>a<div id=t>x</div>b</div>", t => { t.style.display = "inline"; });+ check("sibling inline to block", "<div>a<span id=t>x</span>b</div>", t => { t.style.display = "block"; });+ check("sibling hidden", "<div>a<div id=t>x</div>b</div>", t => { t.style.display = "none"; });+ check("sibling shown", "<div>a<div id=t style='display: none'>x</div>b</div>", t => { t.style.display = "block"; });+ check("own box", "<div id=t>abc</div>", t => { t.style.display = "inline-block"; });+ check("inside an inline", "<div><span id=t>abc</span></div>", t => { t.style.display = "inline-block"; });+ check("list marker", "<ul><li id=t>a</li></ul>", t => { t.style.listStylePosition = "inside"; });+ });+</script>