Skip to content

Truly independent web browser

LibWeb: Return a fragmentainer run's outcome as a value

Aliaksandr Kalenikc1e2443f8a7a
diff --git a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
index f32502c2925..7f3a6c827e9 100644
--- a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
@@ -3919,7 +3919,7 @@ impl<'pass> BlockFormattingContext<'pass> {
.as_ref()
.is_some_and(ChildrenSummary::has_unbreakable_lines);
let mut broken_token_of_box = None;
- if let Some(fragmentainer) = self.run.fragmentainer.as_deref() {
+ if let Some(fragmentainer) = self.run.fragmentainer.as_ref() {
let content_block_start_in_root = pending_position.map(|position| {
containing_block_position_in_root.y
+ self.block_offset_adjustment_from_pending_ancestor_block_start_margins(node)
@@ -4388,7 +4388,7 @@ impl<'pass> BlockFormattingContext<'pass> {
containing_block_position_in_root: FfiCssPixelPoint,
continues_from_previous_fragment: bool,
) -> InFlowReuse {
- if let Some(fragmentainer) = self.run.fragmentainer.as_deref() {
+ if let Some(fragmentainer) = self.run.fragmentainer.as_ref() {
// NB: A discarded run lays out every column afresh, so that the verification checks the column box layouts
// the run reuses.
if self.run.pass.is_discarded_run()
@@ -4472,7 +4472,7 @@ impl<'pass> BlockFormattingContext<'pass> {
&self,
node: Node,
block_container: Node,
- fragmentainer: &fragmentation::FragmentainerContext,
+ fragmentainer: &fragmentation::Fragmentainer<'_>,
layout: &fragmentation::ColumnBoxLayout,
containing_block_position_in_root: FfiCssPixelPoint,
) -> bool {
@@ -4858,7 +4858,7 @@ impl<'pass> BlockFormattingContext<'pass> {
depends_on_percentage_block_size,
fragment_identity: placed.fragment.identity,
};
- if let Some(fragmentainer) = self.run.fragmentainer.as_deref() {
+ if let Some(fragmentainer) = self.run.fragmentainer.as_ref() {
if broke_inside || in_open_top_margin_group {
return;
}
@@ -5215,9 +5215,8 @@ impl<'pass> BlockFormattingContext<'pass> {
let fragmentainer = self
.run
.fragmentainer
- .clone()
.filter(|_| self.break_mode.get() != BreakMode::NoBreaks);
- let mut fragmentation_state = fragmentainer.as_deref().map(|fragmentainer| {
+ let mut fragmentation_state = fragmentainer.as_ref().map(|fragmentainer| {
let incoming = if block_container.node == self.run.box_ {
fragmentainer.incoming.clone()
} else {
@@ -5245,7 +5244,7 @@ impl<'pass> BlockFormattingContext<'pass> {
.siblings_from(first_child, Node::INVALID)
.filter(|&child| self.facts(child).is_box())
{
- if let (Some(fragmentainer), Some(state)) = (fragmentainer.as_deref(), fragmentation_state.as_mut()) {
+ if let (Some(fragmentainer), Some(state)) = (fragmentainer.as_ref(), fragmentation_state.as_mut()) {
match self.fragmentation_step_before_child(fragmentainer, state, block_container.node, child) {
FragmentationStep::Stop => break,
FragmentationStep::LayOut => {}
@@ -5285,7 +5284,7 @@ impl<'pass> BlockFormattingContext<'pass> {
self.laying_out_invisible_line_clamp_content.set(false);
}
self.fold_in_child(&mut summary, block_container.node, child, outcome.as_ref());
- if let (Some(fragmentainer), Some(state)) = (fragmentainer.as_deref(), fragmentation_state.as_mut())
+ if let (Some(fragmentainer), Some(state)) = (fragmentainer.as_ref(), fragmentation_state.as_mut())
&& self.fragmentation_step_after_child(
fragmentainer,
state,
@@ -5304,7 +5303,7 @@ impl<'pass> BlockFormattingContext<'pass> {
fn fragmentation_step_before_child(
&self,
- fragmentainer: &fragmentation::FragmentainerContext,
+ fragmentainer: &fragmentation::Fragmentainer<'_>,
state: &mut FragmentationState,
block_container: Node,
child: Node,
@@ -5365,7 +5364,7 @@ impl<'pass> BlockFormattingContext<'pass> {
fn fragmentation_step_after_child(
&self,
- fragmentainer: &fragmentation::FragmentainerContext,
+ fragmentainer: &fragmentation::Fragmentainer<'_>,
state: &mut FragmentationState,
block_container: Node,
child: Node,
@@ -5590,7 +5589,7 @@ impl<'pass> BlockFormattingContext<'pass> {
if !self.allows_unforced_breaks() {
return None;
}
- let fragmentainer = self.run.fragmentainer.as_deref()?;
+ let fragmentainer = self.run.fragmentainer.as_ref()?;
let incoming = if line_root == self.run.box_ {
fragmentainer.incoming.clone()
} else {
@@ -5617,7 +5616,7 @@ impl<'pass> BlockFormattingContext<'pass> {
line_block_end_in_root: CssPixels,
is_kept: bool,
) {
- let Some(fragmentainer) = self.run.fragmentainer.as_deref() else {
+ let Some(fragmentainer) = self.run.fragmentainer.as_ref() else {
return;
};
fragmentainer.note_unbreakable_block_size(line_block_size);
@@ -5630,7 +5629,7 @@ impl<'pass> BlockFormattingContext<'pass> {
}
pub(crate) fn note_violated_break_avoidance(&self) {
- if let Some(fragmentainer) = self.run.fragmentainer.as_deref() {
+ if let Some(fragmentainer) = self.run.fragmentainer.as_ref() {
fragmentainer.outcome_mut().violates_break_avoidance = true;
}
}
@@ -5639,7 +5638,7 @@ impl<'pass> BlockFormattingContext<'pass> {
if line_root != self.run.box_ {
return;
}
- let Some(fragmentainer) = self.run.fragmentainer.as_deref() else {
+ let Some(fragmentainer) = self.run.fragmentainer.as_ref() else {
return;
};
fragmentainer.note_unbreakable_block_size(lines_block_end_in_root);
@@ -5650,13 +5649,13 @@ impl<'pass> BlockFormattingContext<'pass> {
}
pub(crate) fn note_overflowing_content(&self) {
- if let Some(fragmentainer) = self.run.fragmentainer.as_deref() {
+ if let Some(fragmentainer) = self.run.fragmentainer.as_ref() {
fragmentainer.outcome_mut().overflows = true;
}
}
pub(crate) fn request_early_break_before(&self, node: Node) {
- if let Some(fragmentainer) = self.run.fragmentainer.as_deref() {
+ if let Some(fragmentainer) = self.run.fragmentainer.as_ref() {
fragmentainer.request_early_break_before(node);
}
}
@@ -5669,7 +5668,7 @@ impl<'pass> BlockFormattingContext<'pass> {
line_root: Node,
line_start: fragmentation::LinePosition,
) -> Option<std::rc::Rc<fragmentation::BlockBreakToken>> {
- let fragmentainer = self.run.fragmentainer.as_deref()?;
+ let fragmentainer = self.run.fragmentainer.as_ref()?;
self.stop_fragmentainer(fragmentainer, line_root, fragmentation::BlockResume::AtLine(line_start))
}
@@ -5697,7 +5696,7 @@ impl<'pass> BlockFormattingContext<'pass> {
fn break_before_child(
&self,
- fragmentainer: &fragmentation::FragmentainerContext,
+ fragmentainer: &fragmentation::Fragmentainer<'_>,
state: &mut FragmentationState,
block_container: Node,
child: Node,
@@ -5726,7 +5725,7 @@ impl<'pass> BlockFormattingContext<'pass> {
#[must_use]
fn stop_fragmentainer(
&self,
- fragmentainer: &fragmentation::FragmentainerContext,
+ fragmentainer: &fragmentation::Fragmentainer<'_>,
block_container: Node,
resume: fragmentation::BlockResume,
) -> Option<std::rc::Rc<fragmentation::BlockBreakToken>> {
@@ -6162,29 +6161,33 @@ impl<'pass> BlockFormattingContext<'pass> {
let mut column_root_cells = self.root_cells;
column_root_cells.set_content_inline_size(column_inline_size);
loop {
- let fragmentainer = std::rc::Rc::new(fragmentation::FragmentainerContext::new(
+ let fragmentainer = fragmentation::FragmentainerSpace {
block_size,
honors_forced_breaks,
- incoming.clone(),
- inline_items.clone(),
- box_layouts.clone(),
+ incoming: incoming.clone(),
+ inline_items: inline_items.clone(),
+ box_layouts: box_layouts.clone(),
keeps_box_layouts,
early_break_before,
allows_early_break_requests,
- ));
- let layout = formatting_context::run_fragmentainer(
+ };
+ let fragmentation::FragmentainerRunResult {
+ layout,
+ mut outcome,
+ contents,
+ root_line_data,
+ } = formatting_context::run_fragmentainer(
&self.run,
column_root_cells,
builds_fragments,
input.clone(),
- fragmentainer.clone(),
+ &fragmentainer,
);
if layout.outcome.depends_on_percentage_block_size {
self.run
.state
.note_descendant_depends_on_percentage_block_size(self.run.box_);
}
- let mut outcome = fragmentainer.take_outcome();
outcome.minimal_space_shortage = match (
outcome.minimal_space_shortage,
minimal_space_shortage_of_discarded_attempts,
@@ -6217,8 +6220,8 @@ impl<'pass> BlockFormattingContext<'pass> {
outcome,
consumed_block_size: layout.outcome.automatic_content_block_size,
baselines: layout.outcome.baselines,
- root_line_data: fragmentainer.take_root_line_data(),
- contents: fragmentainer.take_contents(),
+ root_line_data,
+ contents,
};
}
}
@@ -6819,7 +6822,7 @@ impl<'pass> BlockFormattingContext<'pass> {
bottom_margin_edge + self.block_offset_adjustment_from_pending_ancestor_block_start_margins(node),
);
}
- if let Some(fragmentainer) = self.run.fragmentainer.as_deref()
+ if let Some(fragmentainer) = self.run.fragmentainer.as_ref()
&& self.allows_unforced_breaks()
{
let bottom_margin_edge_in_column =
diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
index 482d1f3cb4e..ac41558de8d 100644
--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
@@ -174,8 +174,8 @@ pub(crate) fn run_fragmentainer(
outer_root_cells: used_values::RootInputCells,
builds_fragments: bool,
input: LayoutInput,
- fragmentainer: std::rc::Rc<fragmentation::FragmentainerContext>,
-) -> LayoutResult {
+ fragmentainer: &fragmentation::FragmentainerSpace,
+) -> fragmentation::FragmentainerRunResult {
debug_assert_eq!(input.participation, ParticipationInParentFormattingContext::Root);
let box_ = outer.box_;
let root_containing_block = outer.pass.containing_block_for_child_run(box_, &input.participation);
@@ -198,7 +198,25 @@ pub(crate) fn run_fragmentainer(
fragmentainer: Some(fragmentainer),
..RunSideInputs::default()
};
- execute_formatting_context_run(outer.pass, &request, side, None)
+ let (layout, parts) = execute_run(outer.pass, &request, side, None);
+ let FragmentainerRunParts {
+ outcome,
+ contents,
+ root_line_data,
+ } = parts.expect("the run of a fragmentainer leaves its parts for the run it belongs to");
+ fragmentation::FragmentainerRunResult {
+ layout,
+ outcome,
+ contents,
+ root_line_data,
+ }
+}
+
+/// What the run of a fragmentainer leaves for the run of the box the fragmentainer belongs to besides its result.
+struct FragmentainerRunParts {
+ outcome: fragmentation::FragmentainerOutcome,
+ contents: Option<fragment_tree::RunContents>,
+ root_line_data: Option<std::sync::Arc<inline_content::InlineContent>>,
}
impl PixelFraction {
@@ -1287,7 +1305,7 @@ pub(crate) struct FormattingContextRun<'pass> {
pub(crate) treat_block_axis_percentage_insets_as_auto_beyond_root: bool,
/// The builder of the run's fragments, which `state` keeps exactly where `mode` builds them.
pub(crate) fragments: Option<&'pass fragment_tree::RunFragmentBuilder>,
- pub(crate) fragmentainer: Option<std::rc::Rc<fragmentation::FragmentainerContext>>,
+ pub(crate) fragmentainer: Option<fragmentation::Fragmentainer<'pass>>,
}
impl<'pass> FormattingContextRun<'pass> {
@@ -1298,7 +1316,7 @@ impl<'pass> FormattingContextRun<'pass> {
pass: LayoutPass<'pass>,
mode: RunMode,
treat_block_axis_percentage_insets_as_auto_beyond_root: bool,
- fragmentainer: Option<std::rc::Rc<fragmentation::FragmentainerContext>>,
+ fragmentainer: Option<&'pass fragmentation::FragmentainerSpace>,
) -> Self {
debug_assert_eq!(
mode.builds_fragments(),
@@ -1312,7 +1330,8 @@ impl<'pass> FormattingContextRun<'pass> {
mode,
treat_block_axis_percentage_insets_as_auto_beyond_root,
fragments: state.fragments(),
- fragmentainer,
+ fragmentainer: fragmentainer
+ .map(|space| fragmentation::Fragmentainer::new(space, state.fragmentainer_outcome())),
}
}
@@ -1338,7 +1357,7 @@ impl<'pass> FormattingContextRun<'pass> {
treat_block_axis_percentage_insets_as_auto_beyond_root: self
.treat_block_axis_percentage_insets_as_auto_beyond_root,
fragments: self.fragments,
- fragmentainer: self.fragmentainer.clone(),
+ fragmentainer: self.fragmentainer,
}
}
@@ -2100,7 +2119,7 @@ pub(crate) struct RunSideInputs<'a> {
pub(crate) subgrid_parent: Option<&'a grid_formatting_context::SubgridParent<'a>>,
/// For a table wrapper or its table box, the inline layout of the table box its parent found while sizing it.
pub(crate) table_inline_layout: Option<std::sync::Arc<table_formatting_context::TableInlineLayout>>,
- pub(crate) fragmentainer: Option<std::rc::Rc<fragmentation::FragmentainerContext>>,
+ pub(crate) fragmentainer: Option<&'a fragmentation::FragmentainerSpace>,
}
impl RunRequest {
@@ -2312,6 +2331,17 @@ fn execute_formatting_context_run(
side: RunSideInputs<'_>,
previous_line_data: Option<std::sync::Arc<inline_content::InlineContent>>,
) -> LayoutResult {
+ let (result, fragmentainer_parts) = execute_run(pass, request, side, previous_line_data);
+ debug_assert!(fragmentainer_parts.is_none());
+ result
+}
+
+fn execute_run(
+ pass: LayoutPass<'_>,
+ request: &RunRequest,
+ side: RunSideInputs<'_>,
+ previous_line_data: Option<std::sync::Arc<inline_content::InlineContent>>,
+) -> (LayoutResult, Option<FragmentainerRunParts>) {
let box_ = request.node;
let root_containing_block = request.root_containing_block;
let fc_run_cache::LayoutRequest {
@@ -2343,7 +2373,7 @@ fn execute_formatting_context_run(
(!root_containing_block.is_invalid()).then_some(root_containing_block),
)
});
- let (outputs, root_cells_left_by_run) = RunState::with_root_building_fragments(
+ let (outputs, root_cells_left_by_run, fragmentainer_parts) = RunState::with_root_building_fragments(
pass,
box_,
root_containing_block,
@@ -2374,7 +2404,7 @@ fn execute_formatting_context_run(
"the run of {box_:?} changed root cells its parent owns"
);
}
- outputs
+ (outputs, fragmentainer_parts)
}
/// The sizes and box sides of `cells`, with every flag cleared.
@@ -2396,7 +2426,7 @@ fn lay_out_run_root_and_contents<'pass>(
side: RunSideInputs<'pass>,
previous_line_data: Option<std::sync::Arc<inline_content::InlineContent>>,
parent_owns_root_input_cells: bool,
-) -> (LayoutResult, used_values::RootInputCells) {
+) -> (LayoutResult, used_values::RootInputCells, Option<FragmentainerRunParts>) {
let box_ = request.node;
let fc_run_cache::LayoutRequest {
fc_type,
@@ -2644,32 +2674,7 @@ fn lay_out_run_root_and_contents<'pass>(
inline_content::InlineContent::concatenate_translated(&[(content, content_alignment_offset)])
}
});
- if let Some(fragmentainer) = &run.fragmentainer {
- fragmentainer.keep_root_line_data(root_line_data.clone());
- }
result.depends_on_percentage_block_size = run.sizing().resolve_percentage_block_size_dependency(run.box_);
- // NB: The root's descendants are laid out in the frame the root establishes. A fragmentainer has no fragment of its
- // own, so the run hands what it laid out there to the run of the box the fragmentainer belongs to. Any other
- // run builds its root's fragment around what it laid out inside it.
- let take_run_fragments = || {
- let contents = run
- .fragments
- .as_ref()
- .map(|fragments| fragments.take_run_contents(&body_run.pass))?;
- if let Some(fragmentainer) = &run.fragmentainer {
- fragmentainer.keep_contents(contents);
- return None;
- }
- Some(contents.into_run_root_fragment(
- &pass,
- fragment_tree::FragmentGeometry {
- cells: root_cells_left_by_run,
- line_data: root_line_data.clone(),
- },
- root_payload,
- ))
- };
-
// NB: A run that builds no fragments could never lay out the absolutely positioned boxes it registers. Those whose
// containing block is the root are laid out against its final sizes and box sides, in the frame its contents
// are laid out in, so that the root's fragment holds them. The columns of a fragmentainer run leave them to the
@@ -2682,7 +2687,32 @@ fn lay_out_run_root_and_contents<'pass>(
let laid_out_abspos_contained_by_root = lays_out_abspos_contained_by_root
&& run.fragmentainer.is_none()
&& lay_out_abspos_contained_by_run_root(body_run, root_in_own_frame_left_by_run, own_frame);
- let root = take_run_fragments();
+ // NB: The root's descendants are laid out in the frame the root establishes. A fragmentainer has no fragment of its
+ // own, so the run hands what it laid out there to the run of the box the fragmentainer belongs to. Any other
+ // run builds its root's fragment around what it laid out inside it.
+ let contents = run
+ .fragments
+ .map(|fragments| fragments.take_run_contents(&body_run.pass));
+ let (root, fragmentainer_parts) = if run.fragmentainer.is_some() {
+ let parts = FragmentainerRunParts {
+ outcome: state.fragmentainer_outcome().take(),
+ contents,
+ root_line_data,
+ };
+ (None, Some(parts))
+ } else {
+ let root = contents.map(|contents| {
+ contents.into_run_root_fragment(
+ &pass,
+ fragment_tree::FragmentGeometry {
+ cells: root_cells_left_by_run,
+ line_data: root_line_data,
+ },
+ root_payload,
+ )
+ });
+ (root, None)
+ };
let observed = fc_run_cache::observations_of(
run,
request,
@@ -2715,7 +2745,7 @@ fn lay_out_run_root_and_contents<'pass>(
residue: state.take_residue(),
observed,
};
- (outputs, root_cells_left_by_run)
+ (outputs, root_cells_left_by_run, fragmentainer_parts)
}
pub(super) fn empty_root_needs_no_formatting_context_algorithm(
diff --git a/Libraries/LibWeb/Rust/src/layout/fragmentation.rs b/Libraries/LibWeb/Rust/src/layout/fragmentation.rs
index 7691af51400..5f5fc46ecca 100644
--- a/Libraries/LibWeb/Rust/src/layout/fragmentation.rs
+++ b/Libraries/LibWeb/Rust/src/layout/fragmentation.rs
@@ -257,7 +257,9 @@ pub(crate) struct FragmentainerOutcome {
pub(crate) overflows: bool,
}
-pub(crate) struct FragmentainerContext {
+/// The space a fragmentainer run lays out in: the fragmentainer's size, the break the run continues from, how it
+/// breaks, and the memos the columns of a multi-column box share.
+pub(crate) struct FragmentainerSpace {
pub(crate) block_size: Option<CssPixels>,
pub(crate) honors_forced_breaks: bool,
pub(crate) incoming: Option<Rc<BlockBreakToken>>,
@@ -267,58 +269,36 @@ pub(crate) struct FragmentainerContext {
pub(crate) keeps_box_layouts: bool,
pub(crate) early_break_before: Option<Node>,
pub(crate) allows_early_break_requests: bool,
- outcome: RefCell<FragmentainerOutcome>,
- /// What the run laid out in the fragmentainer, which the run of the box it belongs to takes in, as the
- /// fragmentainer has no fragment of its own.
- contents: RefCell<Option<super::fragment_tree::RunContents>>,
- /// The lines the run laid out in the fragmentainer, which the run of the box it belongs to takes in.
- root_line_data: RefCell<Option<std::sync::Arc<super::inline_content::InlineContent>>>,
}
-impl FragmentainerContext {
- #[allow(clippy::too_many_arguments)]
- pub(crate) fn new(
- block_size: Option<CssPixels>,
- honors_forced_breaks: bool,
- incoming: Option<Rc<BlockBreakToken>>,
- inline_items: Rc<inline_level_iterator::InlineItemCache>,
- box_layouts: Rc<ColumnBoxLayouts>,
- keeps_box_layouts: bool,
- early_break_before: Option<Node>,
- allows_early_break_requests: bool,
- ) -> Self {
- Self {
- block_size,
- honors_forced_breaks,
- incoming,
- inline_items,
- box_layouts,
- keeps_box_layouts,
- early_break_before,
- allows_early_break_requests,
- outcome: RefCell::new(FragmentainerOutcome::default()),
- contents: RefCell::new(None),
- root_line_data: RefCell::new(None),
- }
+impl FragmentainerSpace {
+ pub(crate) fn exceeds(&self, block_end: CssPixels) -> bool {
+ self.block_size.is_some_and(|block_size| block_end > block_size)
}
+}
- pub(crate) fn keep_contents(&self, contents: super::fragment_tree::RunContents) {
- *self.contents.borrow_mut() = Some(contents);
- }
+/// The fragmentainer a run lays out in, as the run sees it: its space, and what the run found out so far about
+/// breaking in it, which the run's state keeps.
+#[derive(Clone, Copy)]
+pub(crate) struct Fragmentainer<'run> {
+ space: &'run FragmentainerSpace,
+ outcome: &'run RefCell<FragmentainerOutcome>,
+}
- pub(crate) fn take_contents(&self) -> Option<super::fragment_tree::RunContents> {
- self.contents.take()
- }
+impl std::ops::Deref for Fragmentainer<'_> {
+ type Target = FragmentainerSpace;
- pub(crate) fn keep_root_line_data(&self, line_data: Option<std::sync::Arc<super::inline_content::InlineContent>>) {
- *self.root_line_data.borrow_mut() = line_data;
+ fn deref(&self) -> &FragmentainerSpace {
+ self.space
}
+}
- pub(crate) fn take_root_line_data(&self) -> Option<std::sync::Arc<super::inline_content::InlineContent>> {
- self.root_line_data.take()
+impl<'run> Fragmentainer<'run> {
+ pub(crate) fn new(space: &'run FragmentainerSpace, outcome: &'run RefCell<FragmentainerOutcome>) -> Self {
+ Self { space, outcome }
}
- pub(crate) fn outcome_mut(&self) -> RefMut<'_, FragmentainerOutcome> {
+ pub(crate) fn outcome_mut(&self) -> RefMut<'run, FragmentainerOutcome> {
self.outcome.borrow_mut()
}
@@ -333,14 +313,6 @@ impl FragmentainerContext {
true
}
- 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;
@@ -362,3 +334,14 @@ impl FragmentainerContext {
outcome.tallest_unbreakable_block_size = outcome.tallest_unbreakable_block_size.max(block_size);
}
}
+
+/// What the run of a fragmentainer hands the run of the box the fragmentainer belongs to.
+pub(crate) struct FragmentainerRunResult {
+ pub(crate) layout: super::formatting_context::LayoutResult,
+ pub(crate) outcome: FragmentainerOutcome,
+ /// What the run laid out in the fragmentainer, where it builds fragments, as the fragmentainer has no fragment of
+ /// its own.
+ pub(crate) contents: Option<super::fragment_tree::RunContents>,
+ /// The lines the run laid out in the fragmentainer.
+ pub(crate) root_line_data: Option<std::sync::Arc<super::inline_content::InlineContent>>,
+}
diff --git a/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs
index 51715b0d8dd..775486be368 100644
--- a/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs
@@ -2788,7 +2788,7 @@ impl<'context> InlineFormattingContext<'context> {
pub(crate) fn run(&mut self) -> block_formatting_context::ChildrenSummary {
assert!(self.facts(self.containing_block).children_are_inline());
let run = self.run;
- let iterator = match run.fragmentainer.as_deref() {
+ let iterator = match run.fragmentainer.as_ref() {
Some(fragmentainer) => {
inline_level_iterator::InlineLevelIterator::new_sharing_items(self, &fragmentainer.inline_items)
}
diff --git a/Libraries/LibWeb/Rust/src/layout/run_state.rs b/Libraries/LibWeb/Rust/src/layout/run_state.rs
index 82cfa3724ea..9e57cb2300a 100644
--- a/Libraries/LibWeb/Rust/src/layout/run_state.rs
+++ b/Libraries/LibWeb/Rust/src/layout/run_state.rs
@@ -222,6 +222,8 @@ pub(crate) struct RunState {
/// What the run found out for the host so far, which the pass the run is handed notes into.
host_findings: HostFindingsSink,
fragments: Option<fragment_tree::RunFragmentBuilder>,
+ /// For the run of a fragmentainer, what it found out so far about breaking in it.
+ fragmentainer_outcome: RefCell<super::fragmentation::FragmentainerOutcome>,
}
/// Where a box is placed: the offset of its content box in the containing block it is placed in.
@@ -417,6 +419,7 @@ impl RunState {
root_anchor_resolved_values,
host_findings: HostFindingsSink::default(),
fragments,
+ fragmentainer_outcome: RefCell::default(),
};
run(&state, pass.for_run(root, root_containing_block, &state.host_findings))
}
@@ -425,6 +428,11 @@ impl RunState {
self.fragments.as_ref()
}
+ /// Where the run of a fragmentainer keeps what it found out so far about breaking in it.
+ pub(crate) fn fragmentainer_outcome(&self) -> &RefCell<super::fragmentation::FragmentainerOutcome> {
+ &self.fragmentainer_outcome
+ }
+
/// What this run found out besides its result, which the result carries to the run that takes it in.
pub(crate) fn take_residue(&self) -> Option<Box<RunResidue>> {
let host_findings = self.host_findings.take();