Skip to content

Truly independent web browser

LibWeb: Hand line clamp flags to the fragment builder

Aliaksandr Kalenika48df62e23cf
diff --git a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
index be10e233667..4c1ff4de806 100644
--- a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
@@ -3910,11 +3910,13 @@ impl<'pass> BlockFormattingContext<'pass> {
pub(crate) fn run(&self, run: &FormattingContextRun<'pass>, input: LayoutInput) {
self.lay_out_root_contents(run, input);
- let root_used = self.used(self.run.box_);
- root_used.has_line_clamp_point.set(self.line_clamp_point_found.get());
- root_used
- .clamped_content_is_scrollable_overflow
- .set(self.clamped_content_is_scrollable_overflow);
+ let has_line_clamp_point = self.line_clamp_point_found.get();
+ if has_line_clamp_point || self.clamped_content_is_scrollable_overflow {
+ run.update_fragment_payloads_of(self.run.box_, |payloads| {
+ payloads.has_line_clamp_point = has_line_clamp_point;
+ payloads.clamped_content_is_scrollable_overflow = self.clamped_content_is_scrollable_overflow;
+ });
+ }
}
fn lay_out_root_contents(&self, run: &FormattingContextRun<'pass>, input: LayoutInput) {
diff --git a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs
index b480b46cfd0..53a67e8f472 100644
--- a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs
+++ b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs
@@ -1349,8 +1349,6 @@ mod tests {
record.has_first_baseline.set(true);
record.first_baseline.set(px(12));
- record.has_line_clamp_point.set(true);
- record.clamped_content_is_scrollable_overflow.set(true);
let mut adopting_input = item_input;
adopting_input.sizing.adopt_automatic_content_block_size = true;
adopting_input.sizing.content_block_size_after_inside_layout = Some(px(40));
diff --git a/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs b/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs
index d301f447fcf..e59d0628d7b 100644
--- a/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs
+++ b/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs
@@ -435,6 +435,10 @@ pub(crate) struct FragmentPayloads {
pub(crate) svg: CommittedSvgFacts,
pub(crate) computed_svg_path: Option<std::sync::Arc<libgfx_rust::path::Path>>,
pub(crate) svg_text_character_cells: Option<std::sync::Arc<Vec<svg_formatting_context::FfiSvgTextCharacterCell>>>,
+ /// For a line-clamp container: whether its contents hold the clamp point, and whether what follows the clamp
+ /// point still counts as scrollable overflow.
+ pub(crate) has_line_clamp_point: bool,
+ pub(crate) clamped_content_is_scrollable_overflow: bool,
}
impl FragmentPayloads {
@@ -449,6 +453,8 @@ impl FragmentPayloads {
svg: fragment.svg.as_deref().copied().unwrap_or_default(),
computed_svg_path: fragment.computed_svg_path.clone(),
svg_text_character_cells: fragment.svg_text_character_cells.clone(),
+ has_line_clamp_point: fragment.has_line_clamp_point,
+ clamped_content_is_scrollable_overflow: fragment.clamped_content_is_scrollable_overflow,
}
}
}
@@ -495,6 +501,8 @@ fn snapshot_fragment(
svg,
computed_svg_path,
svg_text_character_cells,
+ has_line_clamp_point,
+ clamped_content_is_scrollable_overflow,
} = payloads.map(|payloads| *payloads).unwrap_or_default();
let mut fragment = Fragment {
identity: 0,
@@ -528,9 +536,9 @@ fn snapshot_fragment(
svg: (svg != CommittedSvgFacts::default()).then(|| Box::new(svg)),
computed_svg_path,
svg_text_character_cells,
- has_line_clamp_point: used.has_line_clamp_point.get(),
+ has_line_clamp_point,
is_invisible_for_line_clamp: fragment_facts.is_invisible_for_line_clamp,
- clamped_content_is_scrollable_overflow: used.clamped_content_is_scrollable_overflow.get(),
+ clamped_content_is_scrollable_overflow,
continues_from_previous_fragment: fragment_facts.continues_from_previous_fragment,
continues_in_next_fragment: fragment_facts.continues_in_next_fragment,
children,
diff --git a/Libraries/LibWeb/Rust/src/layout/used_values.rs b/Libraries/LibWeb/Rust/src/layout/used_values.rs
index 07c5b0c75f8..43fef5d3138 100644
--- a/Libraries/LibWeb/Rust/src/layout/used_values.rs
+++ b/Libraries/LibWeb/Rust/src/layout/used_values.rs
@@ -213,8 +213,6 @@ pub(crate) struct UsedValues {
/// and friends): the table's border area lies outside the grid, so it owns the part of an outer border on the far
/// side of the first or last grid line, while a cell owns the part on the inner side of its grid lines.
pub is_collapsed_borders_table_box: Cell<bool>,
- pub has_line_clamp_point: Cell<bool>,
- pub clamped_content_is_scrollable_overflow: Cell<bool>,
// Keep baseline payloads separate so resetting the presence bits does not
// perturb the payloads observed by the existing derivation flow.
@@ -255,8 +253,6 @@ impl Default for UsedValues {
has_definite_block_size_only_for_button_content_alignment: Cell::new(false),
uses_collapsing_borders_model: Cell::new(false),
is_collapsed_borders_table_box: Cell::new(false),
- has_line_clamp_point: Cell::new(false),
- clamped_content_is_scrollable_overflow: Cell::new(false),
has_first_baseline: Cell::new(false),
first_baseline: Cell::new(zero),
has_last_baseline: Cell::new(false),
@@ -455,8 +451,6 @@ used_values_cells! {
used_values_cells! {
RootOutputCells {
- has_line_clamp_point: bool,
- clamped_content_is_scrollable_overflow: bool,
has_first_baseline: bool,
first_baseline: CssPixels,
has_last_baseline: bool,