Truly independent web browser
LibWeb: Lay out the contents of multi-column containers in columns
Aliaksandr Kalenik0cd2b259fa1f
diff --git a/Libraries/LibWeb/Layout/Node.cpp b/Libraries/LibWeb/Layout/Node.cppindex 9bb9d0e1b7e..5ce4318c5a5 100644--- a/Libraries/LibWeb/Layout/Node.cpp+++ b/Libraries/LibWeb/Layout/Node.cpp@@ -496,6 +496,14 @@ void NodeWithStyle::set_computed_values(Layout::BegunRead const& read, NonnullRem_has_layout_derived_style = true;}+static bool uses_button_layout(Node const& node)+{+ if (node.is_generated_for_pseudo_element())+ return false;+ auto const* html_element = as_if<HTML::HTMLElement>(node.dom_node());+ return html_element && html_element->uses_button_layout();+}+void NodeWithStyle::set_style_record_identity(CSS::InstalledStyle const& installed, CSS::InstalledStyle const& held_before){auto style_record_identity = installed.record();@@ -544,6 +552,8 @@ void NodeWithStyle::set_style_record_identity(CSS::InstalledStyle const& installif (changes_layout_affecting_style)reset_cached_intrinsic_sizes_of_self_and_ancestors();+ if (changes_layout_affecting_style && (kind() == RustFFI::NodeKind::FieldSetBox || uses_button_layout(*this)))+ RustFFI::render_state_reinherit_anonymous_descendants(document_host(), slot_id(this), false);}void NodeWithStyle::pin_style_record_for_cxx_consumers()diff --git a/Libraries/LibWeb/Rust/src/css/computed_value_views.rs b/Libraries/LibWeb/Rust/src/css/computed_value_views.rsindex 8555261895d..c86048c5657 100644--- a/Libraries/LibWeb/Rust/src/css/computed_value_views.rs+++ b/Libraries/LibWeb/Rust/src/css/computed_value_views.rs@@ -419,9 +419,13 @@ scalar_accessors! {is_size_container: bool => is_size_container,is_inline_size_container: bool => is_inline_size_container,aspect_ratio_uses_natural_when_available: bool => aspect_ratio.use_natural_aspect_ratio_if_available,+ has_column_count: bool => column_count_has_value,+ column_count: i32 => column_count,}misc_reset: {appearance: u8 => appearance,+ break_before: u8 => break_before,+ break_after: u8 => break_after,}border_facts: {border_top_width: CssPixels => border_top.width,@@ -508,6 +512,9 @@ reference_accessors! {max_width: ComputedSize => max_width,max_height: ComputedSize => max_height,}+ box_values: {+ column_width: ComputedSize => column_width,+ }surround: {margin_top: ComputedLengthPercentageOrAuto => margin.top,margin_right: ComputedLengthPercentageOrAuto => margin.right,diff --git a/Libraries/LibWeb/Rust/src/css/style/layout_style.rs b/Libraries/LibWeb/Rust/src/css/style/layout_style.rsindex 1a0b1e288bc..4944e740436 100644--- a/Libraries/LibWeb/Rust/src/css/style/layout_style.rs+++ b/Libraries/LibWeb/Rust/src/css/style/layout_style.rs@@ -40,6 +40,7 @@ pub(crate) struct AnonymousStyleOverrides {pub inline_block_wrapper: bool,pub overflow_x: u8,pub overflow_y: u8,+ pub columns_from_parent: bool,}#[derive(Clone, Copy)]@@ -248,6 +249,24 @@ impl LayoutStyle {self.copy_table_properties(source);}+ pub(crate) fn copy_column_properties(&mut self, source: &Self) {+ let box_values = source.group::<BoxValues>();+ self.edit::<BoxValues>(|target| {+ target.column_count = box_values.column_count;+ target.column_count_has_value = box_values.column_count_has_value;+ target.column_width = box_values.column_width.clone();+ });+ let misc_reset = source.group::<MiscResetValues>();+ self.edit::<MiscResetValues>(|target| {+ target.column_fill = misc_reset.column_fill;+ target.column_rule_style = misc_reset.column_rule_style;+ target.column_rule_width = misc_reset.column_rule_width;+ target.column_rule_color = misc_reset.column_rule_color;+ });+ let alignment = source.group::<AlignmentValues>();+ self.edit::<AlignmentValues>(|target| target.column_gap = alignment.column_gap.clone());+ }+fn copy_table_properties(&mut self, source: &Self) {let surround = source.group::<SurroundValues>();self.edit::<SurroundValues>(|target| {@@ -392,6 +411,9 @@ impl LayoutStyle {}});}+ if overrides.columns_from_parent {+ style.copy_column_properties(&Self::from_record(engine, parent));+ }if kind == AnonymousStyleKind::ButtonContentBox {style.edit::<SizingValues>(|values| {values.min_height = ComputedSize {diff --git a/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs b/Libraries/LibWeb/Rust/src/layout/abspos_engine.rsindex b86ebd2ddea..e5fb19d6289 100644--- a/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs+++ b/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs@@ -2900,6 +2900,7 @@ pub(crate) fn drain_abspos_with_placed_containing_blocks(treat_block_axis_percentage_insets_as_auto_beyond_root: false,fragments: Some(entry_fragments.clone()),previous_line_data: None,+ fragmentainer: None,};loop {let batch = entry_fragments.take_drainable_abspos(accumulator_root, records, &callbacks);diff --git a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rsindex 27a3dcccbb3..f8796845243 100644--- a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs@@ -8,6 +8,42 @@use super::*;use smallvec::{SmallVec, smallvec};+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+enum FragmentationStep {+ LayOut,+ Skip,+ Stop,+}++struct FragmentationState {+ resume_child: Option<Node>,+ has_in_flow_content: bool,+ truncate_next_block_start_margin: bool,+ previous_in_flow_child_forces_break_after: bool,+}++impl FragmentationState {+ fn new(fragmentainer: &fragmentation::FragmentainerContext) -> Self {+ let (resume_child, after_forced_break) = match fragmentainer.incoming.as_deref() {+ Some(fragmentation::BlockBreakToken {+ resume:+ fragmentation::BlockResume::BeforeChild {+ child,+ after_forced_break,+ },+ ..+ }) => (Some(*child), *after_forced_break),+ None => (None, false),+ };+ Self {+ resume_child,+ has_in_flow_content: false,+ truncate_next_block_start_margin: resume_child.is_some() && !after_forced_break,+ previous_in_flow_child_forces_break_after: false,+ }+ }+}+struct FloatAvoidanceProbe {opportunity: Option<CssPixels>,content_inline_size: Option<CssPixels>,@@ -189,6 +225,8 @@ pub(crate) struct BlockFormattingContext<'pass> {automatic_line_clamp_max_lines: Cell<Option<usize>>,automatic_line_clamp_block_size_exceeded: Cell<bool>,laying_out_invisible_line_clamp_content: Cell<bool>,+ multicol_automatic_content_block_size: Cell<Option<CssPixels>>,+ discard_block_start_margin_of_next_child: Cell<bool>,}impl<'pass> BlockFormattingContext<'pass> {@@ -241,6 +279,8 @@ impl<'pass> BlockFormattingContext<'pass> {automatic_line_clamp_max_lines: Cell::new(None),automatic_line_clamp_block_size_exceeded: Cell::new(false),laying_out_invisible_line_clamp_content: Cell::new(false),+ multicol_automatic_content_block_size: Cell::new(None),+ discard_block_start_margin_of_next_child: Cell::new(false),}}@@ -1810,9 +1850,11 @@ impl<'pass> BlockFormattingContext<'pass> {attempt => attempt,};- self.margin_state- .borrow_mut()- .add_margin(self.used(node).margin_top.get());+ if !self.discard_block_start_margin_of_next_child.replace(false) {+ self.margin_state+ .borrow_mut()+ .add_margin(self.used(node).margin_top.get());+ }let introduced_clearance = self.clear_floating_boxes(node, None, containing_block_position_in_root);if introduced_clearance {self.margin_state.borrow_mut().reset();@@ -2225,6 +2267,7 @@ impl<'pass> BlockFormattingContext<'pass> {self.run.purpose == formatting_context::LayoutPurpose::Commit&& self.run.layout_mode == LayoutMode::Normal&& self.run.fragments.is_some()+ && self.run.fragmentainer.is_none()&& !self.run.should_collect_devtools_layout_data&& containing_line_box_fragment.is_none()&& self.floats.borrow().is_empty()@@ -2447,7 +2490,20 @@ impl<'pass> BlockFormattingContext<'pass> {let saved = self.block_offset_of_current_block_container.replace(Some(CssPixels::default()));+ let fragmentainer = self+ .run+ .fragmentainer+ .clone()+ .filter(|_| block_container == self.run.box_);+ let mut fragmentation_state = fragmentainer.as_deref().map(FragmentationState::new);for child in self.children(block_container) {+ if let (Some(fragmentainer), Some(state)) = (fragmentainer.as_deref(), fragmentation_state.as_mut()) {+ match self.fragmentation_step_before_child(fragmentainer, state, block_container, child) {+ FragmentationStep::Skip => continue,+ FragmentationStep::Stop => break,+ FragmentationStep::LayOut => {}+ }+ }let invisible = self.line_clamp_reached() && !self.facts(child).is_absolutely_positioned();let previous_bottom = bottom_of_lowest_margin_box;if invisible {@@ -2465,11 +2521,203 @@ impl<'pass> BlockFormattingContext<'pass> {self.laying_out_invisible_line_clamp_content.set(false);bottom_of_lowest_margin_box = previous_bottom;}+ if let (Some(fragmentainer), Some(state)) = (fragmentainer.as_deref(), fragmentation_state.as_mut())+ && self.fragmentation_step_after_child(fragmentainer, state, block_container, child)+ == FragmentationStep::Stop+ {+ break;+ }}self.block_offset_of_current_block_container.set(saved);self.finish_block_level_children_layout(block_container, input, available_space, bottom_of_lowest_margin_box);}+ fn fragmentation_step_before_child(+ &self,+ fragmentainer: &fragmentation::FragmentainerContext,+ state: &mut FragmentationState,+ block_container: Node,+ child: Node,+ ) -> FragmentationStep {+ if let Some(resume_child) = state.resume_child {+ if resume_child != child {+ return FragmentationStep::Skip;+ }+ state.resume_child = None;+ }+ let facts = self.facts(child);+ if !facts.is_flow_layout_participant() || facts.is_floating() {+ return FragmentationStep::LayOut;+ }+ if fragmentainer.early_break_before == Some(child) {+ self.break_before_child(fragmentainer, block_container, child, false);+ return FragmentationStep::Stop;+ }+ let forced = state.previous_in_flow_child_forces_break_after+ || fragmentation::is_forced_column_break(self.style(child).break_before());+ if forced && state.has_in_flow_content {+ self.break_before_child(fragmentainer, block_container, child, true);+ return FragmentationStep::Stop;+ }+ if state.truncate_next_block_start_margin {+ self.margin_state.borrow_mut().reset();+ self.discard_block_start_margin_of_next_child.set(true);+ }+ FragmentationStep::LayOut+ }++ fn fragmentation_step_after_child(+ &self,+ fragmentainer: &fragmentation::FragmentainerContext,+ state: &mut FragmentationState,+ _block_container: Node,+ child: Node,+ ) -> FragmentationStep {+ self.discard_block_start_margin_of_next_child.set(false);+ let facts = self.facts(child);+ if !facts.is_flow_layout_participant() || facts.is_floating() {+ return FragmentationStep::LayOut;+ }+ state.truncate_next_block_start_margin = false;+ let used = self.used(child);+ let collapsed = used.uses_collapsing_borders_model.get();+ let border_box_block_end =+ used.content_offset.get().y + used.content_block_size.get() + used.border_box_bottom(collapsed);+ fragmentainer.note_unbreakable_block_size(used.border_box_block_size(collapsed));+ if fragmentainer.exceeds(border_box_block_end) {+ fragmentainer.note_space_shortage(border_box_block_end);+ if state.has_in_flow_content {+ fragmentainer.outcome_mut().needs_early_break_before = Some(child);+ return FragmentationStep::Stop;+ }+ }+ state.has_in_flow_content = true;+ state.previous_in_flow_child_forces_break_after =+ fragmentation::is_forced_column_break(self.style(child).break_after());+ FragmentationStep::LayOut+ }++ fn break_before_child(+ &self,+ fragmentainer: &fragmentation::FragmentainerContext,+ block_container: Node,+ child: Node,+ after_forced_break: bool,+ ) {+ fragmentainer.outcome_mut().outgoing = Some(std::rc::Rc::new(fragmentation::BlockBreakToken {+ node: block_container,+ resume: fragmentation::BlockResume::BeforeChild {+ child,+ after_forced_break,+ },+ }));+ }++ fn is_multicol_container(&self) -> bool {+ self.facts(self.run.box_).lays_out_in_columns()+ }++ fn lays_out_multicol_container(&self) -> bool {+ self.run.fragmentainer.is_none() && self.run.layout_mode == LayoutMode::Normal && self.is_multicol_container()+ }++ fn layout_multicol_container(&self, input: LayoutInput) {+ let root = self.run.box_;+ let root_used = self.used(root);+ let style = self.style(root);+ let content_inline_size = root_used.content_inline_size.get();+ let geometry = fragmentation::resolve_column_geometry(style, content_inline_size);+ let definite_block_size = root_used+ .has_definite_block_size()+ .then(|| root_used.content_block_size.get());+ let column_input = LayoutInput {+ available_space: AvailableSpace {+ inline_size: AvailableSize::definite(geometry.inline_size),+ block_size: definite_block_size.map_or(AvailableSize::Indefinite, AvailableSize::definite),+ },+ containing_block_constraints: input.containing_block_constraints,+ content_box_position_in_bfc_root: None,+ sizing: RootSizingDirectives {+ forced_content_inline_size: Some(geometry.inline_size),+ forced_content_block_size: definite_block_size,+ ..RootSizingDirectives::default()+ },+ participation: ParticipationInParentFormattingContext::Root,+ };+ let is_right_to_left = style.direction() == direction::RTL;+ let column_origin = |index: usize| {+ let offset = geometry.pitch() * index;+ FfiCssPixelPoint {+ x: if is_right_to_left {+ content_inline_size - geometry.inline_size - offset+ } else {+ offset+ },+ y: CssPixels::default(),+ }+ };++ let column_block_size = definite_block_size;+ let mut incoming = None;+ let mut content_block_size = CssPixels::default();+ let mut column_index = 0;+ loop {+ let (outcome, consumed_block_size) =+ self.layout_column(column_input, column_block_size, incoming, column_origin(column_index));+ content_block_size = content_block_size.max(consumed_block_size);+ let Some(outgoing) = outcome.outgoing else {+ break;+ };+ if column_index + 1 >= fragmentation::MAXIMUM_COLUMN_COUNT {+ break;+ }+ incoming = Some(outgoing);+ column_index += 1;+ }+ self.multicol_automatic_content_block_size+ .set(Some(column_block_size.unwrap_or(content_block_size)));+ }++ fn layout_column(+ &self,+ input: LayoutInput,+ block_size: Option<CssPixels>,+ incoming: Option<std::rc::Rc<fragmentation::BlockBreakToken>>,+ origin: FfiCssPixelPoint,+ ) -> (fragmentation::FragmentainerOutcome, CssPixels) {+ let mut early_break_before = None;+ loop {+ let fragmentainer = std::rc::Rc::new(fragmentation::FragmentainerContext::new(+ block_size,+ incoming.clone(),+ early_break_before,+ ));+ let journals_stored_entries = self.run.fragments.is_some();+ let fc_run_cache_store = self.run.callbacks.arena().fc_run_cache_store();+ if journals_stored_entries {+ fc_run_cache_store.begin_store_journal();+ }+ let outputs = formatting_context::run_fragmentainer(&self.run, input, fragmentainer.clone());+ let outcome = fragmentainer.take_outcome();+ let retries = outcome+ .needs_early_break_before+ .is_some_and(|node| early_break_before != Some(node));+ if journals_stored_entries {+ fc_run_cache_store.end_store_journal(!retries);+ }+ if let Some(node) = outcome.needs_early_break_before+ && early_break_before != Some(node)+ {+ early_break_before = Some(node);+ continue;+ }+ if let (Some(fragments), Some(root)) = (self.run.fragments.as_deref(), outputs.root) {+ fragments.adopt_fragmentainer_root(root, origin);+ }+ return (outcome, outputs.result.automatic_content_block_size);+ }+ }+// Per https://www.w3.org/TR/CSS22/tables.html#model, caption boxes are block-level boxes laid// out inside the table wrapper box together with the table box itself. Captions remain tree// children of the table box, but they participate in the wrapper's block formatting context:@@ -2734,7 +2982,18 @@ impl<'pass> BlockFormattingContext<'pass> {}}}- // FIXME: Do multi-column layout.+ if self.lays_out_multicol_container() {+ self.layout_multicol_container(input);+ if self.facts(self.run.box_).is_list_item_box() {+ self.layout_list_item_marker(+ run,+ self.run.box_,+ input.sizing.outer_float_intrusion_before_list_item_children,+ self.derived_baselines_of_root_box().first,+ );+ }+ return;+ }let root_input = LayoutInput {content_box_position_in_bfc_root: Some(FfiCssPixelPoint::default()),@@ -2774,6 +3033,9 @@ impl<'pass> BlockFormattingContext<'pass> {if facts.is_absolutely_positioned() || facts.is_floating() {continue;}+ if self.run.records.used_values_if_owned(child).is_none() {+ continue;+ }if self.margins_collapse_through(child) {continue;}@@ -2782,7 +3044,7 @@ impl<'pass> BlockFormattingContext<'pass> {}}- if root_facts.is_list_item_box() {+ if root_facts.is_list_item_box() && self.run.fragmentainer.is_none() {self.layout_list_item_marker(run,self.run.box_,@@ -3525,8 +3787,11 @@ impl<'pass> BlockFormattingContext<'pass> {}pub(crate) fn automatic_content_block_size(&self) -> CssPixels {+ if let Some(block_size) = self.multicol_automatic_content_block_size.get() {+ return block_size;+ }let line_clamp_reached = self.line_clamp_reached();- automatic_block_size_for_bfc_root(+ let block_size = automatic_block_size_for_bfc_root(self.run.records,self.run.callbacks,self.run.box_,@@ -3536,7 +3801,11 @@ impl<'pass> BlockFormattingContext<'pass> {(!line_clamp_reached).then_some(self.trailing_collapsed_margin.get()).flatten(),- )+ );+ if self.run.fragmentainer.is_some() {+ return block_size;+ }+ floor_list_item_automatic_block_size_by_marker_line_height(self.run.callbacks, self.run.box_, block_size)}fn line_clamp_subtree_contains_line(&self, node: Node) -> bool {@@ -3695,11 +3964,7 @@ pub(crate) fn automatic_block_size_for_bfc_root(if let Some(lowest) = lowest_floating_descendant_bottom_margin_edge {bottom = Some(bottom.map_or(lowest, |value| value.max(lowest)));}- floor_list_item_automatic_block_size_by_marker_line_height(- callbacks,- root,- bottom.unwrap_or_default().max(CssPixels::default()),- )+ bottom.unwrap_or_default().max(CssPixels::default())}pub(crate) fn floor_list_item_automatic_block_size_by_marker_line_height(diff --git a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rsindex 195a1f50997..be138aca632 100644--- a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs+++ b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs@@ -307,9 +307,27 @@ pub(crate) struct FcRunCacheArenaStore {inline_layout_damage: RefCell<Vec<InlineLayoutDamage>>,pending_sweep_slots: RefCell<Vec<u32>>,enrolled_for_sweep: RefCell<Vec<bool>>,+ store_journals: RefCell<Vec<Vec<u32>>>,}impl FcRunCacheArenaStore {+ pub(crate) fn begin_store_journal(&self) {+ self.store_journals.borrow_mut().push(Vec::new());+ }++ pub(crate) fn end_store_journal(&self, keeps_stored_entries: bool) {+ let slots = self.store_journals.borrow_mut().pop().expect("a store journal is open");+ if keeps_stored_entries {+ if let Some(enclosing) = self.store_journals.borrow_mut().last_mut() {+ enclosing.extend(slots);+ }+ return;+ }+ for slot in slots {+ self.remove_entry(slot);+ }+ }+fn enqueue_for_sweep(&self, slot: u32) {let mut enrolled = self.enrolled_for_sweep.borrow_mut();if enrolled.len() <= slot as usize {@@ -453,6 +471,9 @@ impl FcRunCacheArenaStore {None => entries[slot as usize] = Some(std::sync::Arc::new(entry)),}drop(entries);+ if let Some(journal) = self.store_journals.borrow_mut().last_mut() {+ journal.push(slot);+ }// NB: Invalidation can occur between probing a run and storing its result.self.enqueue_for_sweep(slot);}diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rsindex b0f612a0e60..39a878e7578 100644--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs@@ -186,6 +186,34 @@ impl<'pass> MeasurementState<'pass> {}}+pub(crate) fn run_fragmentainer(+ outer: &FormattingContextRun,+ input: LayoutInput,+ fragmentainer: std::rc::Rc<fragmentation::FragmentainerContext>,+) -> RunOutputs {+ debug_assert_eq!(input.participation, ParticipationInParentFormattingContext::Root);+ let box_ = outer.box_;+ let root_containing_block = outer+ .callbacks+ .containing_block_for_child_run(box_, &input.participation);+ execute_formatting_context_run(+ outer.purpose,+ used_values::UsedValuesCellState::capture(outer.records.used_values(box_)),+ box_,+ root_containing_block,+ None,+ FormattingContextType::Block,+ LayoutMode::Normal,+ outer.should_collect_devtools_layout_data,+ outer.callbacks,+ input,+ None,+ None,+ None,+ Some(fragmentainer),+ )+}+pub(super) fn cache_key(measured_at_inline_size: Option<CssPixels>,measured_at_block_size: Option<CssPixels>,@@ -1074,6 +1102,7 @@ pub(crate) struct FormattingContextRun<'pass> {pub(crate) treat_block_axis_percentage_insets_as_auto_beyond_root: bool,pub(crate) fragments: Option<std::rc::Rc<fragment_tree::RunFragmentBuilder>>,pub(crate) previous_line_data: Option<std::sync::Arc<inline_content::InlineContent>>,+ pub(crate) fragmentainer: Option<std::rc::Rc<fragmentation::FragmentainerContext>>,}impl<'pass> FormattingContextRun<'pass> {@@ -1727,6 +1756,7 @@ pub(super) fn run_formatting_context(parent_block,previous_line_data,table_inline_layout,+ None,);cache_attempt.conclude(&callbacks, box_, cache_key, &outputs);absorb_run_outputs(parent_fragments, parent_used, box_, outputs, false)@@ -1789,6 +1819,7 @@ fn execute_formatting_context_run(parent_block: Option<&block_formatting_context::BlockFormattingContext>,previous_line_data: Option<std::sync::Arc<inline_content::InlineContent>>,table_inline_layout: Option<table_formatting_context::TableInlineLayout>,+ fragmentainer: Option<std::rc::Rc<fragmentation::FragmentainerContext>>,) -> RunOutputs {assert!(!box_.is_invalid());let root_used = root_cells.materialize_record();@@ -1816,6 +1847,7 @@ fn execute_formatting_context_run())}),previous_line_data,+ fragmentainer,};let run = &run;if let Some(table_inline_layout) = table_inline_layout {@@ -2380,6 +2412,7 @@ pub(crate) fn run_table_cell_ahead_of_its_intrinsic_block_padding(None,previous_line_data,None,+ None,);cache_attempt.conclude_uncommitted(&run.callbacks, cell, cache_key, &outputs);Some(outputs.result)@@ -2653,6 +2686,7 @@ fn compute_root_layout(input: LayoutStageInput<'_>, should_collect_devtools_layotreat_block_axis_percentage_insets_as_auto_beyond_root: false,fragments: Some(entry_fragments.clone()),previous_line_data: None,+ fragmentainer: None,};let mut root_for_layout = root;@@ -2774,6 +2808,7 @@ fn compute_subtree_layout_fragments(input: LayoutStageInput<'_>, containing_bloctreat_block_axis_percentage_insets_as_auto_beyond_root: false,fragments: Some(entry_fragments.clone()),previous_line_data: None,+ fragmentainer: None,};if root_is_absolutely_positioned {abspos_engine::AbsposEngine::for_run(&entry_run).replay(&entry_run, root);diff --git a/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs b/Libraries/LibWeb/Rust/src/layout/fragment_tree.rsindex 9f5e066cc32..946a3ea876f 100644--- a/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs+++ b/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs@@ -745,6 +745,13 @@ struct RunFragmentBuilderInner {reused_subtree_roots_holding_fragments: Vec<crate::layout::node_data::NodeSlotId>,}+impl RunFragmentBuilderInner {+ fn receive_abspos_containing_block_info(&mut self, contributions: Vec<AbsposContainingBlockInfoContribution>) {+ self.abspos_containing_block_info_contributions_received += contributions.len() as u64;+ self.abspos_containing_block_info_contributions.extend(contributions);+ }+}+/// The committed fragment a run holds in the record of a box it sized from it, for the box's placement to attach as it/// is, and whether the box roots a reused subtree.pub(crate) struct HeldCommittedFragment {@@ -1044,6 +1051,32 @@ impl RunFragmentBuilder {);}+ pub(crate) fn adopt_fragmentainer_root(&self, root: UnplacedRootFragment, offset: FfiCssPixelPoint) {+ debug_assert!(+ root.node == self.root_node,+ "a fragmentainer run's root is the box of the run that adopts it"+ );+ let mut inner = self.inner.borrow_mut();+ inner.reused_subtree_roots.extend(root.reused_subtree_roots);+ for mut link in root.scoped_descendants {+ link.committed_offset = formatting_context::point_add(link.committed_offset, offset);+ inner.top_scope_links.push(link);+ }+ for mut entry in root.propagated_pending_abspos {+ entry.translate_by(offset);+ inner.pending_abspos_at_root.push(entry);+ }+ for mut candidate in root.propagated_anchor_candidates {+ candidate.translate_by(offset);+ inner.anchor_candidates_at_root.push(candidate);+ }+ for mut payload in root.propagated_inline_containing_block_rects {+ payload.translate_by(offset);+ inner.inline_containing_block_rects_at_root.push(payload);+ }+ inner.receive_abspos_containing_block_info(root.propagated_abspos_containing_block_info);+ }+pub(crate) fn note_reused_subtree_root(&self, node: crate::layout::node_data::NodeSlotId) {self.inner.borrow_mut().reused_subtree_roots.insert(node.slot_index());}@@ -1144,11 +1177,7 @@ impl RunFragmentBuilder {pending_fragment.inline_containing_block_rects.extend(root.propagated_inline_containing_block_rects);- inner.abspos_containing_block_info_contributions_received +=- root.propagated_abspos_containing_block_info.len() as u64;- inner- .abspos_containing_block_info_contributions- .extend(root.propagated_abspos_containing_block_info);+ inner.receive_abspos_containing_block_info(root.propagated_abspos_containing_block_info);}#[allow(clippy::too_many_arguments)]diff --git a/Libraries/LibWeb/Rust/src/layout/fragmentation.rs b/Libraries/LibWeb/Rust/src/layout/fragmentation.rsnew file mode 100644index 00000000000..8e7b17b158b--- /dev/null+++ b/Libraries/LibWeb/Rust/src/layout/fragmentation.rs@@ -0,0 +1,152 @@+/*+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++use super::*;+use std::cell::{RefCell, RefMut};+use std::rc::Rc;++#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub(crate) struct ColumnGeometry {+ pub(crate) count: usize,+ pub(crate) inline_size: CssPixels,+ pub(crate) gap: CssPixels,+}++impl ColumnGeometry {+ pub(crate) fn pitch(&self) -> CssPixels {+ self.inline_size + self.gap+ }+}++pub(crate) fn used_column_gap(style: StyleValues<'_>, percentage_basis: CssPixels) -> CssPixels {+ let gap = style.column_gap();+ if gap.is_normal() {+ return style.font_size();+ }+ gap.to_px(percentage_basis).max(CssPixels::default())+}++pub(crate) const MAXIMUM_COLUMN_COUNT: usize = 1000;++pub(crate) fn resolved_column_count(style: StyleValues<'_>) -> usize {+ (style.column_count().max(1) as usize).min(MAXIMUM_COLUMN_COUNT)+}++pub(crate) fn resolved_column_width(style: StyleValues<'_>, percentage_basis: CssPixels) -> Option<CssPixels> {+ let column_width = style.column_width();+ (!column_width.is_auto()).then(|| column_width.to_px(percentage_basis).max(CssPixels::from_integer(1)))+}++// https://drafts.csswg.org/css-multicol-1/#pseudo-algorithm+pub(crate) fn resolve_column_geometry(style: StyleValues<'_>, available_inline_size: CssPixels) -> ColumnGeometry {+ let available_inline_size = available_inline_size.max(CssPixels::default());+ let gap = used_column_gap(style, available_inline_size);+ let count = match resolved_column_width(style, available_inline_size) {+ // (04) N := column-count+ None => resolved_column_count(style),+ Some(column_width) => {+ // (06) N := max(1, floor((U + column-gap)/(column-width + column-gap)))+ let fitting_count = ((i64::from(available_inline_size.raw_value()) + i64::from(gap.raw_value()))+ / (i64::from(column_width.raw_value()) + i64::from(gap.raw_value())))+ .clamp(1, MAXIMUM_COLUMN_COUNT as i64) as usize;+ if style.has_column_count() {+ // (08) N := min(column-count, max(1, floor((U + column-gap)/(column-width + column-gap))))+ fitting_count.min(resolved_column_count(style))+ } else {+ fitting_count+ }+ }+ };+ // (09) W := max(0, ((U + column-gap)/N - column-gap))+ let inline_size = CssPixels::from_raw(+ ((i64::from(available_inline_size.raw_value()) + i64::from(gap.raw_value())) / count as i64+ - i64::from(gap.raw_value()))+ .max(0) as i32,+ );+ ColumnGeometry {+ count,+ inline_size,+ gap,+ }+}++pub(crate) fn is_forced_column_break(value: u8) -> bool {+ value == break_between::COLUMN+}++#[derive(Clone, Debug, PartialEq, Eq)]+pub(crate) enum BlockResume {+ BeforeChild { child: Node, after_forced_break: bool },+}++#[derive(Clone, Debug, PartialEq, Eq)]+pub(crate) struct BlockBreakToken {+ pub(crate) node: Node,+ pub(crate) resume: BlockResume,+}++#[derive(Clone, Debug, Default)]+pub(crate) struct FragmentainerOutcome {+ pub(crate) outgoing: Option<Rc<BlockBreakToken>>,+ pub(crate) needs_early_break_before: Option<Node>,+ pub(crate) minimal_space_shortage: Option<CssPixels>,+ pub(crate) tallest_unbreakable_block_size: CssPixels,+}++pub(crate) struct FragmentainerContext {+ pub(crate) block_size: Option<CssPixels>,+ pub(crate) incoming: Option<Rc<BlockBreakToken>>,+ pub(crate) early_break_before: Option<Node>,+ outcome: RefCell<FragmentainerOutcome>,+}++impl FragmentainerContext {+ pub(crate) fn new(+ block_size: Option<CssPixels>,+ incoming: Option<Rc<BlockBreakToken>>,+ early_break_before: Option<Node>,+ ) -> Self {+ Self {+ block_size,+ incoming,+ early_break_before,+ outcome: RefCell::new(FragmentainerOutcome::default()),+ }+ }++ pub(crate) fn outcome_mut(&self) -> RefMut<'_, FragmentainerOutcome> {+ self.outcome.borrow_mut()+ }++ pub(crate) fn take_outcome(&self) -> FragmentainerOutcome {+ self.outcome.take()+ }++ pub(crate) fn exceeds(&self, block_end: CssPixels) -> bool {+ self.block_size.is_some_and(|block_size| block_end > block_size)+ }++ pub(crate) fn note_space_shortage(&self, block_end: CssPixels) {+ let Some(block_size) = self.block_size else {+ return;+ };+ let shortage = block_end - block_size;+ if shortage <= CssPixels::default() {+ return;+ }+ let mut outcome = self.outcome.borrow_mut();+ outcome.minimal_space_shortage = Some(+ outcome+ .minimal_space_shortage+ .map_or(shortage, |minimal| minimal.min(shortage)),+ );+ }++ pub(crate) fn note_unbreakable_block_size(&self, block_size: CssPixels) {+ let mut outcome = self.outcome.borrow_mut();+ outcome.tallest_unbreakable_block_size = outcome.tallest_unbreakable_block_size.max(block_size);+ }+}diff --git a/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rsindex 72faa3bdc9b..81ef1d4e88e 100644--- a/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs@@ -2729,6 +2729,7 @@ impl<'pass> GridFormattingContext<'pass> {treat_block_axis_percentage_insets_as_auto_beyond_root: false,fragments: None,previous_line_data: None,+ fragmentainer: None,};let mut context = GridFormattingContext::new(&scratch_run, Some(self));measure(&mut context, &scratch_run)diff --git a/Libraries/LibWeb/Rust/src/layout/intrinsic_sizing.rs b/Libraries/LibWeb/Rust/src/layout/intrinsic_sizing.rsindex 8be22806b25..68ac0fb412f 100644--- a/Libraries/LibWeb/Rust/src/layout/intrinsic_sizing.rs+++ b/Libraries/LibWeb/Rust/src/layout/intrinsic_sizing.rs@@ -50,6 +50,7 @@ pub(super) fn compute_inline_sizes(treat_block_axis_percentage_insets_as_auto_beyond_root: false,fragments: None,previous_line_data: None,+ fragmentainer: None,};let sizing = run.sizing();let input = LayoutInput::new(diff --git a/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs b/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rsindex 8ec530e8397..05a6c673205 100644--- a/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs+++ b/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs@@ -2655,7 +2655,12 @@ impl LayoutNodeArena {});return None;}- let derived = self.reinherit_anonymous_style_record(host_record(child), parent_record);+ let column_source = self+ .anonymous_box_column_source(child)+ .filter(|source| *source == row)+ .map(|_| sample.record);+ let derived =+ self.reinherit_anonymous_style_record(host_record(child), parent_record, column_source);parents.push((child, derived.record));samples.push((child, derived));}@@ -3545,14 +3550,41 @@ impl LayoutNodeArena {})}- pub(crate) fn reinherit_anonymous_style_record(&self, record: u64, parent: u64) -> DerivedStyleRecord {+ pub(crate) fn reinherit_anonymous_style_record(+ &self,+ record: u64,+ parent: u64,+ column_source: Option<u64>,+ ) -> DerivedStyleRecord {self.with_style_engine(|engine| {let mut style = LayoutStyle::from_record(engine, record);style.inherit_from(engine, parent);+ if let Some(column_source) = column_source {+ style.copy_column_properties(&LayoutStyle::from_record(engine, column_source));+ }style.intern(engine)})}+ fn anonymous_box_column_source(&self, node: NodeSlotId) -> Option<NodeSlotId> {+ let parent = self.data(node).parent.get();+ if parent.is_invalid() {+ return None;+ }+ if super::node_facts::has_ancestor_fact(self.data(node), AncestorFact::IsAnonymousButtonContentBox) {+ let button = self.data(parent).parent.get();+ return (!button.is_invalid()+ && !super::node_facts::has_flag(self.data(button), NodeFlag::IsHtmlInputElement))+ .then_some(button);+ }+ let is_fieldset_content_wrapper = self.data(parent).kind.get() == NodeKind::FieldSetBox+ && super::node_facts::node_is_fieldset_content_wrapper(+ self.data(node),+ super::node_facts::node_style_view(self.data(node)),+ );+ is_fieldset_content_wrapper.then_some(parent)+ }+pub(crate) fn update_layout_style(&self,host_calls: HostCalls<'_>,@@ -3625,8 +3657,14 @@ impl LayoutNodeArena {self.reinherit_anonymous_descendants(host_calls, child);self.notify_shell_of_style_change(host_calls, child, true);} else {- let derived =- self.reinherit_anonymous_style_record(self.node_style_record(child), parent_style_record);+ let column_source = self+ .anonymous_box_column_source(child)+ .map(|source| self.node_style_record(source));+ let derived = self.reinherit_anonymous_style_record(+ self.node_style_record(child),+ parent_style_record,+ column_source,+ );self.apply_reinherited_style_record(host_calls, child, derived);self.reinherit_anonymous_children(host_calls, child, derived.record);}diff --git a/Libraries/LibWeb/Rust/src/layout/mod.rs b/Libraries/LibWeb/Rust/src/layout/mod.rsindex bf176588299..187b3de820e 100644--- a/Libraries/LibWeb/Rust/src/layout/mod.rs+++ b/Libraries/LibWeb/Rust/src/layout/mod.rs@@ -20,6 +20,7 @@ pub(crate) mod fc_run_cache;pub(crate) mod flex_formatting_context;pub mod formatting_context;pub(crate) mod fragment_tree;+pub(crate) mod fragmentation;pub(crate) mod generated_content;pub mod geometry;pub mod grid_formatting_context;diff --git a/Libraries/LibWeb/Rust/src/layout/sizing_context.rs b/Libraries/LibWeb/Rust/src/layout/sizing_context.rsindex a90b51867e0..2ddbd86a51b 100644--- a/Libraries/LibWeb/Rust/src/layout/sizing_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/sizing_context.rs@@ -3183,6 +3183,7 @@ impl<'pass> SizingContext<'pass> {treat_block_axis_percentage_insets_as_auto_beyond_root: false,fragments: None,previous_line_data: None,+ fragmentainer: None,};let mut table = table_formatting_context::TableFormattingContext::new(&table_run);let table_available = table_used.available_inner_space_or_constraints_from(available_space);diff --git a/Libraries/LibWeb/Rust/src/layout/tree_builder.rs b/Libraries/LibWeb/Rust/src/layout/tree_builder.rsindex 670a748c02b..0b005851a75 100644--- a/Libraries/LibWeb/Rust/src/layout/tree_builder.rs+++ b/Libraries/LibWeb/Rust/src/layout/tree_builder.rs@@ -4677,7 +4677,10 @@ fn wrap_button_contents_if_needed(host: &mut TreeBuilderHost<'_>, layout_node: Llet content_box = host.create_anonymous_box(layout_node,AnonymousStyleKind::ButtonContentBox,- host.anonymous_wrapper_overrides(layout_node),+ AnonymousStyleOverrides {+ columns_from_parent: !node_facts::has_flag(host.data(layout_node), NodeFlag::IsHtmlInputElement),+ ..host.anonymous_wrapper_overrides(layout_node)+ },NodeKind::BlockContainer,);let flex_wrapper_slot = flex_wrapper.slot();@@ -4733,6 +4736,7 @@ fn wrap_fieldset_contents_if_needed(host: &mut TreeBuilderHost<'_>, layout_node:inline_block_wrapper: false,overflow_x: style.box_values().overflow_x,overflow_y: style.box_values().overflow_y,+ columns_from_parent: true,};host.arena().update_layout_style(host.host_calls(), layout_node, |style| {diff --git a/Tests/LibWeb/Layout/expected/multicol-list-item-marker.txt b/Tests/LibWeb/Layout/expected/multicol-list-item-marker.txtnew file mode 100644index 00000000000..8fbdd02579d--- /dev/null+++ b/Tests/LibWeb/Layout/expected/multicol-list-item-marker.txt@@ -0,0 +1,17 @@+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 20 0+0+0] [BFC] children: not-inline+ BlockContainer <body> at [0,0] [0+0+0 800 0+0+0] [0+0+0 20 0+0+0] children: not-inline+ BlockContainer <ul> at [40,0] [0+0+40 760 0+0+0] [0+0+0 20 0+0+0] children: not-inline+ ListItemBox <li> at [40,0] [0+0+0 300 0+0+460] [0+0+0 20 0+0+0] [BFC] children: not-inline+ ListItemMarkerBox <(anonymous)> at [26,0] [0+0+0 13.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [26,0 13.84375x16] baseline: 12.796875+ "• "+ GeneratedTextNode <(anonymous)> (not painted)+ BlockContainer <div> at [40,0] [0+0+0 100 0+0+0] [0+0+0 20 0+0+0] children: not-inline+ BlockContainer <div.break> at [140,0] [0+0+0 100 0+0+0] [0+0+0 20 0+0+0] children: not-inline+ BlockContainer <div.break> at [240,0] [0+0+0 100 0+0+0] [0+0+0 20 0+0+0] children: not-inline+ BlockContainer <(anonymous)> at [0,20] [0+0+0 800 0+0+0] [0+0+0 0 0+0+0] children: inline+ TextNode <#text> (not painted)++SC for Viewport<#document> [0,0 800x600] (z-index: auto)+ SC for BlockContainer<HTML> [0,0 800x20] (z-index: auto)diff --git a/Tests/LibWeb/Layout/input/multicol-list-item-marker.html b/Tests/LibWeb/Layout/input/multicol-list-item-marker.htmlnew file mode 100644index 00000000000..3114e692f75--- /dev/null+++ b/Tests/LibWeb/Layout/input/multicol-list-item-marker.html@@ -0,0 +1,22 @@+<!DOCTYPE html>+<style>+ body {+ margin: 0;+ }+ ul {+ margin: 0;+ padding-left: 40px;+ }+ li {+ columns: 3;+ column-gap: 0;+ width: 300px;+ }+ li > div {+ height: 20px;+ }+ .break {+ break-before: column;+ }+</style>+<ul><li><div></div><div class="break"></div><div class="break"></div></li></ul>diff --git a/Tests/LibWeb/Ref/expected/multicol-fill-auto-block-children-ref.html b/Tests/LibWeb/Ref/expected/multicol-fill-auto-block-children-ref.htmlnew file mode 100644index 00000000000..6b1ebb6d0f0--- /dev/null+++ b/Tests/LibWeb/Ref/expected/multicol-fill-auto-block-children-ref.html@@ -0,0 +1,15 @@+<!DOCTYPE html>+<style>+body { margin: 0; }+.container { position: relative; height: 100px; width: 320px; background: lightgray; }+.container > div { position: absolute; width: 100px; height: 40px; }+</style>+<div class="container">+ <div style="background: red; left: 0; top: 0"></div>+ <div style="background: orange; left: 0; top: 40px"></div>+ <div style="background: yellow; left: 110px; top: 0"></div>+ <div style="background: green; left: 110px; top: 40px"></div>+ <div style="background: blue; left: 220px; top: 0; height: 60px"></div>+ <div style="background: purple; left: 220px; top: 60px"></div>+ <div style="background: black; left: 330px; top: 0"></div>+</div>diff --git a/Tests/LibWeb/Ref/expected/multicol-fill-auto-block-children-rtl-ref.html b/Tests/LibWeb/Ref/expected/multicol-fill-auto-block-children-rtl-ref.htmlnew file mode 100644index 00000000000..2ea9d64bd41--- /dev/null+++ b/Tests/LibWeb/Ref/expected/multicol-fill-auto-block-children-rtl-ref.html@@ -0,0 +1,11 @@+<!DOCTYPE html>+<style>+body { margin: 0; }+.container { position: relative; height: 100px; width: 320px; background: lightgray; }+.container > div { position: absolute; width: 100px; height: 60px; top: 0; }+</style>+<div class="container">+ <div style="background: red; left: 220px"></div>+ <div style="background: orange; left: 110px"></div>+ <div style="background: yellow; left: 0"></div>+</div>diff --git a/Tests/LibWeb/Ref/expected/multicol-forced-column-breaks-ref.html b/Tests/LibWeb/Ref/expected/multicol-forced-column-breaks-ref.htmlnew file mode 100644index 00000000000..ccc29c4e7cf--- /dev/null+++ b/Tests/LibWeb/Ref/expected/multicol-forced-column-breaks-ref.html@@ -0,0 +1,13 @@+<!DOCTYPE html>+<style>+body { margin: 0; }+.container { position: relative; height: 100px; width: 320px; background: lightgray; }+.container > div { position: absolute; width: 100px; height: 20px; }+</style>+<div class="container">+ <div style="background: red; left: 0; top: 10px"></div>+ <div style="background: orange; left: 0; top: 40px"></div>+ <div style="background: yellow; left: 110px; top: 10px"></div>+ <div style="background: green; left: 220px; top: 10px"></div>+ <div style="background: blue; left: 220px; top: 40px"></div>+</div>diff --git a/Tests/LibWeb/Ref/input/multicol-fill-auto-block-children-rtl.html b/Tests/LibWeb/Ref/input/multicol-fill-auto-block-children-rtl.htmlnew file mode 100644index 00000000000..0b91670de0b--- /dev/null+++ b/Tests/LibWeb/Ref/input/multicol-fill-auto-block-children-rtl.html@@ -0,0 +1,12 @@+<!DOCTYPE html>+<link rel="match" href="../expected/multicol-fill-auto-block-children-rtl-ref.html">+<style>+body { margin: 0; }+.multicol { direction: rtl; columns: 3; column-gap: 10px; column-fill: auto; height: 100px; width: 320px; background: lightgray; }+.multicol > div { height: 60px; overflow: hidden; }+</style>+<div class="multicol">+ <div style="background: red"></div>+ <div style="background: orange"></div>+ <div style="background: yellow"></div>+</div>diff --git a/Tests/LibWeb/Ref/input/multicol-fill-auto-block-children.html b/Tests/LibWeb/Ref/input/multicol-fill-auto-block-children.htmlnew file mode 100644index 00000000000..003f9dbfe06--- /dev/null+++ b/Tests/LibWeb/Ref/input/multicol-fill-auto-block-children.html@@ -0,0 +1,16 @@+<!DOCTYPE html>+<link rel="match" href="../expected/multicol-fill-auto-block-children-ref.html">+<style>+body { margin: 0; }+.multicol { columns: 3; column-gap: 10px; column-fill: auto; height: 100px; width: 320px; background: lightgray; }+.multicol > div { height: 40px; overflow: hidden; }+</style>+<div class="multicol">+ <div style="background: red"></div>+ <div style="background: orange"></div>+ <div style="background: yellow"></div>+ <div style="background: green"></div>+ <div style="background: blue; height: 60px"></div>+ <div style="background: purple"></div>+ <div style="background: black"></div>+</div>diff --git a/Tests/LibWeb/Ref/input/multicol-forced-column-breaks.html b/Tests/LibWeb/Ref/input/multicol-forced-column-breaks.htmlnew file mode 100644index 00000000000..ed8e0a15922--- /dev/null+++ b/Tests/LibWeb/Ref/input/multicol-forced-column-breaks.html@@ -0,0 +1,14 @@+<!DOCTYPE html>+<link rel="match" href="../expected/multicol-forced-column-breaks-ref.html">+<style>+body { margin: 0; }+.multicol { columns: 3; column-gap: 10px; column-fill: auto; height: 100px; width: 320px; background: lightgray; }+.multicol > div { height: 20px; margin-top: 10px; }+</style>+<div class="multicol">+ <div style="background: red"></div>+ <div style="background: orange; break-after: column"></div>+ <div style="background: yellow"></div>+ <div style="background: green; break-before: column"></div>+ <div style="background: blue"></div>+</div>diff --git a/Tests/LibWeb/Text/expected/multicol-huge-column-gap.txt b/Tests/LibWeb/Text/expected/multicol-huge-column-gap.txtnew file mode 100644index 00000000000..0029a3f6176--- /dev/null+++ b/Tests/LibWeb/Text/expected/multicol-huge-column-gap.txt@@ -0,0 +1,3 @@+one-column: 400x20+column-width: 400x20+two-columns: 0x20diff --git a/Tests/LibWeb/Text/input/multicol-huge-column-gap.html b/Tests/LibWeb/Text/input/multicol-huge-column-gap.htmlnew file mode 100644index 00000000000..6caffd844c7--- /dev/null+++ b/Tests/LibWeb/Text/input/multicol-huge-column-gap.html@@ -0,0 +1,18 @@+<!DOCTYPE html>+<script src="include.js"></script>+<style>+ body { margin: 0; }+ .mc { column-gap: 40000000px; width: 400px; }+ .item { height: 20px; }+</style>+<div class="mc" style="columns: 1"><div class="item" id="one-column"></div></div>+<div class="mc" style="column-width: 100px"><div class="item" id="column-width"></div></div>+<div class="mc" style="columns: 2"><div class="item" id="two-columns"></div><div class="item"></div></div>+<script>+ test(() => {+ for (const id of ["one-column", "column-width", "two-columns"]) {+ const rect = document.getElementById(id).getBoundingClientRect();+ println(`${id}: ${rect.width}x${rect.height}`);+ }+ });+</script>