Truly independent web browser
LibWeb: Size vertical boxes without layout runs
Aliaksandr Kalenikfabbeddf983c
diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rsindex 0c56fb73866..f2e346ec353 100644--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs@@ -2036,11 +2036,10 @@ pub(crate) fn explicit_intrinsic_inner_inline_size(facts: &NodeFacts<'_>) -> Css}}-/// Whether the content inline sizes of `box_` are measured by laying it out: those of a box in a vertical writing mode,-/// of a box that establishes an orthogonal flow, whose block size they are, and of a MathML box.+/// Whether the content inline sizes of `box_` are measured by laying it out: those of a box that establishes an+/// orthogonal flow, whose block size they are, and of a MathML box.pub(crate) fn content_inline_sizes_are_measured_by_layout(callbacks: &LayoutPass<'_>, box_: Node) -> bool {- StyleValues::for_node(callbacks, box_).writing_mode() != writing_mode::HORIZONTAL_TB- || frame_established_by(callbacks, box_).is_orthogonal_to(callbacks.frame)+ frame_established_by(callbacks, box_).is_orthogonal_to(callbacks.frame)|| independent_formatting_context_type(box_, callbacks) == FormattingContextType::Math}diff --git a/Libraries/LibWeb/Rust/src/layout/intrinsic_sizing.rs b/Libraries/LibWeb/Rust/src/layout/intrinsic_sizing.rsindex e982a517cbb..c3d35f8053d 100644--- a/Libraries/LibWeb/Rust/src/layout/intrinsic_sizing.rs+++ b/Libraries/LibWeb/Rust/src/layout/intrinsic_sizing.rs@@ -84,7 +84,6 @@ pub(super) fn content_sizes_of_inline_content(|| formatting_context::independent_formatting_context_type(node, &callbacks)!= formatting_context::FormattingContextType::Block|| facts.is_table_wrapper()- || style.writing_mode() != writing_mode::HORIZONTAL_TB|| establishes_orthogonal_flow(&callbacks, node){return None;@@ -336,8 +335,6 @@ pub(super) fn content_sizes_of_block_container(|| formatting_context::independent_formatting_context_type(node, &callbacks)!= formatting_context::FormattingContextType::Block|| facts.is_table_wrapper()- || (style.writing_mode() != writing_mode::HORIZONTAL_TB- && block_formatting_context::is_line_clamp_container(&callbacks, node))|| establishes_orthogonal_flow(&callbacks, node)|| callbacks.children(node)@@ -448,10 +445,7 @@ pub(super) fn content_sizes_of_table(let facts = NodeFacts::new(&callbacks, node);let is_table_box = formatting_context::independent_formatting_context_type(node, &callbacks)== formatting_context::FormattingContextType::Table;- if !(facts.is_table_wrapper() || is_table_box)- || StyleValues::for_node(&callbacks, node).writing_mode() != writing_mode::HORIZONTAL_TB- || establishes_orthogonal_flow(&callbacks, node)- {+ if !(facts.is_table_wrapper() || is_table_box) || establishes_orthogonal_flow(&callbacks, node) {return None;}Some(scope.enter(callbacks, |run| {@@ -532,7 +526,6 @@ fn container_content_is_sized_without_layout(formatting_context_type: formatting_context::FormattingContextType,) -> bool {formatting_context::independent_formatting_context_type(node, callbacks) == formatting_context_type- && StyleValues::for_node(callbacks, node).writing_mode() == writing_mode::HORIZONTAL_TB&& !establishes_orthogonal_flow(callbacks, node)}diff --git a/Libraries/LibWeb/Rust/src/layout/sizing_context.rs b/Libraries/LibWeb/Rust/src/layout/sizing_context.rsindex f83844be32e..f0d93930483 100644--- a/Libraries/LibWeb/Rust/src/layout/sizing_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/sizing_context.rs@@ -2992,7 +2992,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {) -> ContentInlineSizes {debug_assert!(formatting_context::content_inline_sizes_are_measured_by_layout(&self.callbacks, node),- "the content inline sizes of a horizontal box are computed without layout"+ "only boxes that establish an orthogonal flow and MathML boxes are measured by layout");let content_size_named_by_grid_maximum_inline_size =if formatting_context::independent_formatting_context_type(node, &self.callbacks)diff --git a/Tests/LibWeb/Text/expected/width-queries-of-vertical-boxes-skip-layout.txt b/Tests/LibWeb/Text/expected/width-queries-of-vertical-boxes-skip-layout.txtnew file mode 100644index 00000000000..ff37f5f7cc8--- /dev/null+++ b/Tests/LibWeb/Text/expected/width-queries-of-vertical-boxes-skip-layout.txt@@ -0,0 +1,7 @@+inline-content: 1 inline misses answered from items, 0 runs under them, inline size 160+block-children: 1 inline misses answered from children, 0 runs under them, inline size 100+float: 1 inline misses answered from items, 0 runs under them, inline size 100+table-in-inline-block: 1 inline misses answered from children, 0 runs under them, inline size 100+flex: 1 inline misses answered from flex items, 0 runs under them, inline size 150+grid: 1 inline misses answered from grid tracks, 0 runs under them, inline size 150+line-clamp: 1 inline misses answered from children, 0 runs under them, inline size 160diff --git a/Tests/LibWeb/Text/input/width-queries-of-vertical-boxes-skip-layout.html b/Tests/LibWeb/Text/input/width-queries-of-vertical-boxes-skip-layout.htmlnew file mode 100644index 00000000000..210c0ca4b7e--- /dev/null+++ b/Tests/LibWeb/Text/input/width-queries-of-vertical-boxes-skip-layout.html@@ -0,0 +1,59 @@+<!doctype html>+<script src="include.js"></script>+<script src="layout-test.js"></script>+<style>+ @font-face {+ font-family: Ahem;+ src: url("../../Ref/data/fonts/Ahem.ttf");+ }++ .vertical {+ writing-mode: vertical-rl;+ font: 10px/20px Ahem;+ }++ #line-clamp {+ display: -webkit-box;+ -webkit-box-orient: vertical;+ -webkit-line-clamp: 1;+ overflow: hidden;+ }+</style>+<template id="fixture">+ <div class="vertical"><div id="inline-content" style="display: inline-block">alpha beta gamma</div></div>+ <div class="vertical"><div id="block-children" style="display: inline-block"><div>alpha</div><div>beta gamma</div></div></div>+ <div class="vertical"><div id="float" style="float: left">alpha beta</div></div>+ <div class="vertical"><div id="table-in-inline-block" style="display: inline-block"><div style="display: table"><div style="display: table-cell">alpha beta</div></div></div></div>+ <div class="vertical"><div id="flex" style="display: inline-flex"><div>alpha</div><div>beta gamma</div></div></div>+ <div class="vertical"><div id="grid" style="display: inline-grid; grid-template-columns: auto auto"><div>alpha</div><div>beta gamma</div></div></div>+ <div class="vertical"><div style="display: inline-block"><div id="line-clamp"><div>alpha</div><div>beta gamma delta</div></div></div></div>+</template>+<script>+ asyncTest(async done => {+ await document.fonts.load("10px Ahem");+ const work = layoutWork(() => {+ document.body.appendChild(document.getElementById("fixture").content.cloneNode(true));+ });+ for (const id of ["inline-content", "block-children", "float", "table-in-inline-block", "flex", "grid", "line-clamp"]) {+ const isTarget = box => box.endsWith(`#${id}`);+ const answers = new Set();+ let misses = 0;+ let nestedRuns = 0;+ work.events.forEach((measure, start) => {+ if (measure.event !== "measure" || !isTarget(measure.box) || !measure.size.endsWith("inline")) return;+ if (measure.cache !== "miss") return;+ ++misses;+ answers.add(measure.from);+ for (const event of work.events.slice(start + 1)) {+ if (event.depth <= measure.depth) break;+ if (event.event === "run") ++nestedRuns;+ }+ });+ const inlineSize = document.getElementById(id).getBoundingClientRect().height;+ println(+ `${id}: ${misses} inline misses answered from ${[...answers].join(", ") || "nothing"}, ${nestedRuns} runs under them, inline size ${inlineSize}`+ );+ }+ done();+ });+</script>