Truly independent web browser
LibWeb: Rebuild a fieldset's boxes when a rendered legend is inserted
Aliaksandr Kalenik15ae234002d8
diff --git a/Libraries/LibWeb/Rust/src/layout/tree_builder.rs b/Libraries/LibWeb/Rust/src/layout/tree_builder.rsindex 753caaf2e3a..670a748c02b 100644--- a/Libraries/LibWeb/Rust/src/layout/tree_builder.rs+++ b/Libraries/LibWeb/Rust/src/layout/tree_builder.rs@@ -1076,6 +1076,11 @@ impl ChildListInsertionReuse<'_, '_> {if self.engine.subtree_affects_generated_content_state(child) {return false;}+ if self.layout.data(self.layout_node).kind.get() == NodeKind::FieldSetBox+ && self.engine.element_box_kind(child) == ElementBoxKind::Legend+ {+ return false;+ }let child_type_facts = self.engine.element_adjustment_facts(child);let child_is_svg_root = child_type_facts & element_adjustment_fact::IS_SVG_CONTAINER != 0;// NB: An SVG root owns its subtree and can be inserted like another replaced box. Graphics whichdiff --git a/Tests/LibWeb/Text/expected/fieldset-legend-insertion.txt b/Tests/LibWeb/Text/expected/fieldset-legend-insertion.txtnew file mode 100644index 00000000000..728f1ee4756--- /dev/null+++ b/Tests/LibWeb/Text/expected/fieldset-legend-insertion.txt@@ -0,0 +1,6 @@+prepend: legend at 20,0, hit: true+prepend: matches full rebuild: true+append: legend at 20,0, hit: true+append: matches full rebuild: true+before-legend: legend at 20,0, hit: true+before-legend: matches full rebuild: truediff --git a/Tests/LibWeb/Text/input/fieldset-legend-insertion.html b/Tests/LibWeb/Text/input/fieldset-legend-insertion.htmlnew file mode 100644index 00000000000..80934d9dab2--- /dev/null+++ b/Tests/LibWeb/Text/input/fieldset-legend-insertion.html@@ -0,0 +1,29 @@+<!DOCTYPE html>+<script src="include.js"></script>+<style>+ body { margin: 0; }+ fieldset { width: 200px; margin: 0 0 10px; padding: 0; border: 20px solid black; overflow: hidden; }+ legend { height: 20px; padding: 0; }+ .content { height: 50px; }+</style>+<fieldset id="prepend"><div class="content"></div></fieldset>+<fieldset id="append"><div class="content"></div></fieldset>+<fieldset id="before-legend"><legend>First</legend><div class="content"></div></fieldset>+<script>+ test(() => {+ document.body.offsetHeight;+ for (const fieldset of document.querySelectorAll("fieldset")) {+ const legend = document.createElement("legend");+ legend.textContent = "Inserted";+ if (fieldset.id === "append")+ fieldset.append(legend);+ else+ fieldset.prepend(legend);+ document.body.offsetHeight;+ const origin = fieldset.getBoundingClientRect();+ const rect = legend.getBoundingClientRect();+ println(`${fieldset.id}: legend at ${rect.x - origin.x},${rect.y - origin.y}, hit: ${document.elementFromPoint(rect.x + 2, rect.y + 2) === legend}`);+ println(`${fieldset.id}: matches full rebuild: ${internals.compareLayoutTreeWithFullRebuild().matches}`);+ }+ });+</script>