Skip to content

Truly independent web browser

LibWeb: Name what a run laid out inside its root RunContents

Aliaksandr Kalenik7a21ab325399
diff --git a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
index ad729ffdfe9..9d41423de7f 100644
--- a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
@@ -22,7 +22,7 @@ struct ColumnLayout {
consumed_block_size: CssPixels,
baselines: formatting_context::DerivedBaselines,
root_line_data: Option<std::sync::Arc<inline_content::InlineContent>>,
- root: Option<fragment_tree::UnplacedRootFragment>,
+ contents: Option<fragment_tree::RunContents>,
}
#[derive(Clone, Copy)]
@@ -3972,7 +3972,7 @@ impl<'pass> BlockFormattingContext<'pass> {
consumed_block_size,
baselines: column_baselines,
root_line_data,
- root,
+ contents,
} = self.layout_column(
ColumnLayoutUse::ContainerContent,
column_input,
@@ -3984,8 +3984,8 @@ impl<'pass> BlockFormattingContext<'pass> {
incoming.take(),
column_index,
);
- if let (Some(fragments), Some(root)) = (self.run.fragments.as_deref(), root) {
- fragments.adopt_fragmentainer_root(root, origin, root_line_count);
+ if let (Some(fragments), Some(contents)) = (self.run.fragments.as_deref(), contents) {
+ fragments.adopt_fragmentainer_contents(contents, origin, root_line_count);
}
let filled_column = outcome
.outgoing
@@ -4346,7 +4346,7 @@ impl<'pass> BlockFormattingContext<'pass> {
consumed_block_size: outputs.result.automatic_content_block_size,
baselines: outputs.result.baselines,
root_line_data: outputs.root_outcome.line_data,
- root: fragmentainer.take_contents(),
+ contents: fragmentainer.take_contents(),
};
}
}
diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
index e56032eba4e..51f9290620f 100644
--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
@@ -2503,7 +2503,7 @@ fn lay_out_run_root_and_contents<'pass>(
let contents = run
.fragments
.as_ref()
- .map(|fragments| fragments.take_unplaced_root(&body_run.callbacks))?;
+ .map(|fragments| fragments.take_run_contents(&body_run.callbacks))?;
if let Some(fragmentainer) = &run.fragmentainer {
fragmentainer.keep_contents(contents);
return None;
diff --git a/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs b/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs
index b1f3b2a15a2..0cefa147ded 100644
--- a/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs
+++ b/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs
@@ -764,8 +764,10 @@ impl PayloadsPastRun {
}
/// What a run laid out inside its root, before the root's fragment exists: the links at the top of the run's
-/// fragments, and what goes past the run.
-pub(crate) struct UnplacedRootFragment {
+/// fragments, what goes past the run, and what the run's layout of its root hands the root's fragment. A normal run
+/// turns them into its root's fragment, a fragmentainer's run hands them to the run of the box it belongs to, and a
+/// whole layout pass hands its links to commit.
+pub(crate) struct RunContents {
pub(crate) node: crate::layout::node_data::NodeSlotId,
pub(crate) scoped_descendants: Vec<FragmentLink>,
pub(crate) payloads_past_run: PayloadsPastRun,
@@ -773,7 +775,7 @@ pub(crate) struct UnplacedRootFragment {
pub(crate) root_payloads: Option<Box<FragmentPayloads>>,
}
-impl UnplacedRootFragment {
+impl RunContents {
/// The root's fragment around what the run laid out inside it, showing the root's own layout `geometry`.
pub(crate) fn into_run_root_fragment(
self,
@@ -1440,18 +1442,20 @@ impl RunFragmentBuilder {
.any(|child| child.root.fragment.node == node)
}
- pub(crate) fn adopt_fragmentainer_root(
+ /// Takes in what the run of a fragmentainer of this run's root laid out, `offset` to where the fragmentainer
+ /// sits, with its lines after the `root_line_index_offset` lines of the root's earlier fragmentainers.
+ pub(crate) fn adopt_fragmentainer_contents(
&self,
- root: UnplacedRootFragment,
+ contents: RunContents,
offset: FfiCssPixelPoint,
root_line_index_offset: usize,
) {
debug_assert!(
- root.node == self.root_node,
+ contents.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();
- for mut link in root.scoped_descendants {
+ for mut link in contents.scoped_descendants {
link.committed_offset = formatting_context::point_add(link.committed_offset, offset);
if link.containing_block == self.root_node
&& let Some(line_index) = link.containing_line_box_index.as_mut()
@@ -1460,7 +1464,7 @@ impl RunFragmentBuilder {
}
inner.top_scope_links.push(link);
}
- for mut entry in root.payloads_past_run.pending_abspos {
+ for mut entry in contents.payloads_past_run.pending_abspos {
entry.translate_by(offset);
inner.pending_abspos_at_root.push(entry);
}
@@ -1472,7 +1476,7 @@ impl RunFragmentBuilder {
.enumerate()
.map(|(index, candidate)| ((candidate.node, candidate.coordinate_space_box), index))
.collect();
- for mut candidate in root.payloads_past_run.anchor_candidates {
+ for mut candidate in contents.payloads_past_run.anchor_candidates {
candidate.translate_by(offset);
let key = (candidate.node, candidate.coordinate_space_box);
if let Some(&index) = anchor_indices.get(&key) {
@@ -1484,11 +1488,11 @@ impl RunFragmentBuilder {
inner.anchor_candidates_at_root.push(candidate);
}
}
- for mut payload in root.payloads_past_run.inline_containing_block_rects {
+ for mut payload in contents.payloads_past_run.inline_containing_block_rects {
payload.translate_by(offset);
inner.inline_containing_block_rects_at_root.push(payload);
}
- inner.receive_abspos_containing_block_info(root.payloads_past_run.abspos_containing_block_info);
+ inner.receive_abspos_containing_block_info(contents.payloads_past_run.abspos_containing_block_info);
}
/// Takes in the root fragment of the run that laid out `node`, which is being placed, and what goes past that run.
@@ -1745,7 +1749,7 @@ impl RunFragmentBuilder {
.insert(containing_block.slot_index(), pending_fragment);
}
- pub(crate) fn take_unplaced_root(&self, callbacks: &LayoutPass<'_>) -> UnplacedRootFragment {
+ pub(crate) fn take_run_contents(&self, callbacks: &LayoutPass<'_>) -> RunContents {
debug_assert!(
!self.is_entry_accumulator,
"an entry accumulator closes as a pass, not a run"
@@ -1756,7 +1760,7 @@ impl RunFragmentBuilder {
pub(crate) fn take_completed_pass(&self, callbacks: &LayoutPass<'_>) -> CompletedPassFragments {
debug_assert!(
self.is_entry_accumulator,
- "an ordinary run closes as a singular unplaced root"
+ "an ordinary run closes into the contents of its root"
);
let root = self.close(callbacks);
CompletedPassFragments {
@@ -1764,7 +1768,7 @@ impl RunFragmentBuilder {
}
}
- fn close(&self, callbacks: &LayoutPass<'_>) -> UnplacedRootFragment {
+ fn close(&self, callbacks: &LayoutPass<'_>) -> RunContents {
let mut inner = self.inner.take();
let mut payloads_past_run = PayloadsPastRun {
pending_abspos: std::mem::take(&mut inner.pending_abspos_at_root),
@@ -1827,7 +1831,7 @@ impl RunFragmentBuilder {
for payload in &mut payloads_past_run.inline_containing_block_rects {
propagate_payload_toward_run_root_space(payload, self.root_node, placed_boxes, callbacks);
}
- UnplacedRootFragment {
+ RunContents {
node: self.root_node,
scoped_descendants: inner.top_scope_links,
payloads_past_run,
diff --git a/Libraries/LibWeb/Rust/src/layout/fragmentation.rs b/Libraries/LibWeb/Rust/src/layout/fragmentation.rs
index 3e087463133..55d7095e18e 100644
--- a/Libraries/LibWeb/Rust/src/layout/fragmentation.rs
+++ b/Libraries/LibWeb/Rust/src/layout/fragmentation.rs
@@ -241,7 +241,7 @@ pub(crate) struct FragmentainerContext {
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::UnplacedRootFragment>>,
+ contents: RefCell<Option<super::fragment_tree::RunContents>>,
}
impl FragmentainerContext {
@@ -265,11 +265,11 @@ impl FragmentainerContext {
}
}
- pub(crate) fn keep_contents(&self, contents: super::fragment_tree::UnplacedRootFragment) {
+ pub(crate) fn keep_contents(&self, contents: super::fragment_tree::RunContents) {
*self.contents.borrow_mut() = Some(contents);
}
- pub(crate) fn take_contents(&self) -> Option<super::fragment_tree::UnplacedRootFragment> {
+ pub(crate) fn take_contents(&self) -> Option<super::fragment_tree::RunContents> {
self.contents.take()
}