Truly independent web browser
LibWeb: Test relayout of changed content inside multicol columns
Aliaksandr Kalenik38e8b3eef36c
diff --git a/Tests/LibWeb/Text/expected/multicol-incremental-relayout.txt b/Tests/LibWeb/Text/expected/multicol-incremental-relayout.txtnew file mode 100644index 00000000000..59a5839ed78--- /dev/null+++ b/Tests/LibWeb/Text/expected/multicol-incremental-relayout.txt@@ -0,0 +1,47 @@+balanced: partial-layouts=0 full-layouts=1 PASS+ div 0,0,100,40+ div 0,40,100,54.671875+ div 120,0,100,25.328125+ div 120,25.328125,100,69.34375+ div 240,0,100,54.65625+ div 122,27.328125,96,30+ div 122,57.328125,96,30+ div 122,87.328125,96,7.34375+ div 242,0,96,22.65625+ div 242,22.65625,96,30+ div 240,54.65625,100,40+abspos: partial-layouts=1 full-layouts=0 PASS+ div 0,0,100,100+ div 120,0,100,60+ div 130,5,50,45+ div 130,5,50,45+svg: partial-layouts=1 full-layouts=0 PASS+ div 0,0,100,100+ div 120,0,100,40+ svg 120,40,60,40+ rect 120,40,50,10+split containing block: partial-layouts=1 full-layouts=0 PASS+ div 0,0,100,60+ div 0,60,100,40+ div 120,0,100,40+ div 10,65,50,45+ div 10,65,50,45+static position: partial-layouts=1 full-layouts=0 PASS+ div 0,0,100,100+ div 120,0,100,40+ div 120,40,30,45+ div 120,40,30,45+svg in a later fragment: partial-layouts=1 full-layouts=0 PASS+ div 0,0,100,100+ div 120,0,100,60+ div 0,0,100,100+ div 120,0,100,20+ svg 120,20,60,40+ rect 120,20,50,10+moved to a later column: partial-layouts=0 full-layouts=1 PASS+ div 0,0,100,100+ div 120,0,100,100+ div 240,0,100,40+ div 0,0,100,100+ div 120,0,100,50+ div 240,0,100,40diff --git a/Tests/LibWeb/Text/input/multicol-incremental-relayout.html b/Tests/LibWeb/Text/input/multicol-incremental-relayout.htmlnew file mode 100644index 00000000000..0212aa81f83--- /dev/null+++ b/Tests/LibWeb/Text/input/multicol-incremental-relayout.html@@ -0,0 +1,155 @@+<!DOCTYPE html>+<script src="include.js"></script>+<style>+ body { margin: 0; }+ .pair { display: flex; gap: 40px; margin-bottom: 20px; }+ .multicol { columns: 3; column-gap: 20px; width: 340px; }+ .fixed { column-fill: auto; height: 100px; }+ .block { height: 40px; }+ .breakable { border: 2px solid black; }+ .breakable > div { height: 30px; }+ .cb { position: relative; height: 60px; }+ .abspos { position: absolute; left: 10px; top: 5px; width: 50px; overflow: hidden; }+ .abspos > div { height: 20px; }+ svg { display: block; }+ .split-cb { position: relative; height: 80px; }+ .static-cb { position: relative; }+ .static { position: absolute; width: 30px; overflow: hidden; }+ .static > div { height: 15px; }+</style>+<div class="pair">+ <div id="balanced-live" class="multicol">+ <div class="block"></div>+ <div id="balanced-live-grow" class="block"></div>+ <div class="breakable"><div></div><div></div><div></div><div></div></div>+ <div class="block"></div>+ </div>+ <div id="balanced-reference" class="multicol">+ <div class="block"></div>+ <div class="block" style="height: 80px"></div>+ <div class="breakable"><div></div><div></div><div></div><div></div></div>+ <div class="block"></div>+ </div>+</div>+<div class="pair">+ <div id="abspos-live" class="multicol fixed">+ <div class="block" style="height: 100px"></div>+ <div class="cb"><div class="abspos"><div id="abspos-live-grow"></div></div></div>+ </div>+ <div id="abspos-reference" class="multicol fixed">+ <div class="block" style="height: 100px"></div>+ <div class="cb"><div class="abspos"><div style="height: 45px"></div></div></div>+ </div>+</div>+<div class="pair">+ <div id="svg-live" class="multicol fixed">+ <div class="block" style="height: 100px"></div>+ <div class="block"></div>+ <svg width="60" height="40"><rect id="svg-live-rect" width="20" height="10"/></svg>+ </div>+ <div id="svg-reference" class="multicol fixed">+ <div class="block" style="height: 100px"></div>+ <div class="block"></div>+ <svg width="60" height="40"><rect width="50" height="10"/></svg>+ </div>+</div>+<div class="pair">+ <div id="split-live" class="multicol fixed">+ <div class="block" style="height: 60px"></div>+ <div class="split-cb"><div class="abspos"><div id="split-live-grow"></div></div></div>+ </div>+ <div id="split-reference" class="multicol fixed">+ <div class="block" style="height: 60px"></div>+ <div class="split-cb"><div class="abspos"><div style="height: 45px"></div></div></div>+ </div>+</div>+<div class="pair static-cb">+ <div id="static-live" class="multicol fixed">+ <div class="block" style="height: 100px"></div>+ <div class="block"></div>+ <div class="static"><div id="static-live-grow"></div></div>+ </div>+ <div id="static-reference" class="multicol fixed">+ <div class="block" style="height: 100px"></div>+ <div class="block"></div>+ <div class="static"><div style="height: 45px"></div></div>+ </div>+</div>+<div class="pair">+ <div id="svg-fragment-live" class="multicol fixed">+ <div><div class="block" style="height: 120px"></div><svg width="60" height="40"><rect id="svg-fragment-live-rect" width="20" height="10"/></svg></div>+ </div>+ <div id="svg-fragment-reference" class="multicol fixed">+ <div><div class="block" style="height: 120px"></div><svg width="60" height="40"><rect width="50" height="10"/></svg></div>+ </div>+</div>+<div class="pair">+ <div id="moved-live" class="multicol fixed">+ <div>+ <div id="moved-live-grow" class="block"></div>+ <div class="block" style="break-before: column"></div>+ </div>+ </div>+ <div id="moved-reference" class="multicol fixed">+ <div>+ <div class="block" style="height: 150px"></div>+ <div class="block" style="break-before: column"></div>+ </div>+ </div>+</div>+<script>+ function geometryOf(container) {+ const origin = container.getBoundingClientRect();+ const lines = [];+ for (const element of container.querySelectorAll("*")) {+ for (const rect of element.getClientRects())+ lines.push(`${element.localName} ${rect.left - origin.left},${rect.top - origin.top},${rect.width},${rect.height}`);+ }+ return lines;+ }++ function check(name, live, reference, mutate) {+ document.body.offsetHeight;+ const partialBefore = internals.partialLayoutCount();+ const fullBefore = internals.fullLayoutCount();+ mutate();+ document.body.offsetHeight;+ const partialLayouts = internals.partialLayoutCount() - partialBefore;+ const fullLayouts = internals.fullLayoutCount() - fullBefore;+ const liveGeometry = geometryOf(document.getElementById(live));+ const referenceGeometry = geometryOf(document.getElementById(reference));+ const matches = liveGeometry.join("|") === referenceGeometry.join("|");+ println(`${name}: partial-layouts=${partialLayouts} full-layouts=${fullLayouts} ${matches ? "PASS" : "FAIL"}`);+ for (const line of liveGeometry)+ println(` ${line}`);+ if (!matches) {+ println(" reference:");+ for (const line of referenceGeometry)+ println(` ${line}`);+ }+ }++ test(() => {+ check("balanced", "balanced-live", "balanced-reference", () => {+ document.getElementById("balanced-live-grow").style.height = "80px";+ });+ check("abspos", "abspos-live", "abspos-reference", () => {+ document.getElementById("abspos-live-grow").style.height = "45px";+ });+ check("svg", "svg-live", "svg-reference", () => {+ document.getElementById("svg-live-rect").setAttribute("width", "50");+ });+ check("split containing block", "split-live", "split-reference", () => {+ document.getElementById("split-live-grow").style.height = "45px";+ });+ check("static position", "static-live", "static-reference", () => {+ document.getElementById("static-live-grow").style.height = "45px";+ });+ check("svg in a later fragment", "svg-fragment-live", "svg-fragment-reference", () => {+ document.getElementById("svg-fragment-live-rect").setAttribute("width", "50");+ });+ check("moved to a later column", "moved-live", "moved-reference", () => {+ document.getElementById("moved-live-grow").style.height = "150px";+ });+ });+</script>