Skip to content

Truly independent web browser

LibWeb: Name the layout pass "pass" rather than "callbacks"

Aliaksandr Kalenikdd20c7615825
diff --git a/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs b/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs
index 810e42e819d..5fa50509f2f 100644
--- a/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs
+++ b/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs
@@ -170,7 +170,7 @@ impl<'a> OutOfFlowBox<'a> {
pub(crate) struct AbsposEngine<'pass> {
state: &'pass RunState,
- callbacks: LayoutPass<'pass>,
+ pass: LayoutPass<'pass>,
fragments: Option<&'pass fragment_tree::RunFragmentBuilder>,
}
@@ -178,7 +178,7 @@ impl<'pass> AbsposEngine<'pass> {
pub(crate) fn for_run(run: &FormattingContextRun<'pass>) -> Self {
Self {
state: run.state,
- callbacks: run.callbacks,
+ pass: run.pass,
fragments: run.fragments,
}
}
@@ -190,7 +190,7 @@ impl<'pass> AbsposEngine<'pass> {
let containing_block = entry.containing_block();
let Some(containing_block_cells) = self
.placed_box_fragments()
- .cells_of_placed_containing_block(containing_block, self.callbacks.frame)
+ .cells_of_placed_containing_block(containing_block, self.pass.frame)
else {
panic!(
"the run placed no containing block for slot {} (cb slot {})",
@@ -250,7 +250,7 @@ impl<'pass> AbsposEngine<'pass> {
return FfiCssPixelPoint::default();
}
let mut merge_point = from_space;
- while merge_point != to_space && !self.callbacks.is_ancestor(merge_point, to_space, self.state.root()) {
+ while merge_point != to_space && !self.pass.is_ancestor(merge_point, to_space, self.state.root()) {
merge_point = self.placement_containing_block(merge_point);
assert!(!merge_point.is_invalid());
}
@@ -283,22 +283,21 @@ impl<'pass> AbsposEngine<'pass> {
/// Where the run placed `node`, if it placed the box.
fn placement_of(&self, node: Node) -> Option<run_state::BoxPlacement> {
- self.placed_box_fragments().placement_of(&self.callbacks, node)
+ self.placed_box_fragments().placement_of(&self.pass, node)
}
fn placement_containing_block(&self, node: Node) -> Node {
- self.placed_box_fragments()
- .placement_containing_block(&self.callbacks, node)
+ self.placed_box_fragments().placement_containing_block(&self.pass, node)
}
#[inline]
fn sizing(&self) -> sizing_context::SizingContext<'pass, 'static> {
- sizing_context::SizingContext::new(self.state, self.callbacks)
+ sizing_context::SizingContext::new(self.state, self.pass)
}
#[inline]
fn style(&self, node: Node) -> StyleValues<'pass> {
- StyleValues::for_node(&self.callbacks, node)
+ StyleValues::for_node(&self.pass, node)
}
/// The style of `sized`, an absolutely positioned box this engine sizes, with its anchor-size() resolutions.
@@ -306,12 +305,12 @@ impl<'pass> AbsposEngine<'pass> {
where
'pass: 'sized,
{
- StyleValues::for_node(&self.callbacks, sized.node).with_anchor_resolved_values(sized.anchor_resolved_values)
+ StyleValues::for_node(&self.pass, sized.node).with_anchor_resolved_values(sized.anchor_resolved_values)
}
#[inline]
fn facts(&self, node: Node) -> NodeFacts<'_> {
- NodeFacts::new(&self.callbacks, node)
+ NodeFacts::new(&self.pass, node)
}
fn base_containing_block_info(
@@ -451,7 +450,7 @@ impl AbsposEngine<'_> {
/// in, and when that is a shadow tree and nothing acceptable is found there, it continues in the
/// tree scope of the shadow host, up to the document tree.
fn anchor_lookup(&self, positioned_box: Node, anchor_name: usize) -> Option<Node> {
- let arena = self.callbacks.arena();
+ let arena = self.pass.arena();
// A pseudo-element queries from its generator. Any other anonymous box stands for no element
// and has no tree scope to search.
let is_pseudo_element = arena.node_is_generated_for_pseudo_element(positioned_box);
@@ -495,7 +494,7 @@ impl AbsposEngine<'_> {
anchor_name: usize,
scope_host: Option<StyleNodeID>,
) -> Option<StyleNodeID> {
- let arena = self.callbacks.arena();
+ let arena = self.pass.arena();
let mut candidate = Some(element);
while let Some(current) = candidate {
if let Some(style) = arena.style_node_style(current) {
@@ -517,7 +516,7 @@ impl AbsposEngine<'_> {
/// Whether `anchor_box` may act as the anchor of `positioned_box`: it must have used values
/// from this pass, and its containing block chain must reach the positioned box's own.
fn anchor_is_acceptable(&self, anchor_box: Node, positioned_box: Node, containing_block: Node) -> bool {
- let arena = self.callbacks.arena();
+ let arena = self.pass.arena();
if anchor_box == positioned_box
|| !arena
.node_kind_if_live(anchor_box)
@@ -583,7 +582,7 @@ impl AbsposEngine<'_> {
is_from_end: bool,
is_horizontal_axis: bool,
) -> Option<CssPixels> {
- let frame = self.callbacks.frame;
+ let frame = self.pass.frame;
// NB: The physical sides an anchor() names lie on the sides of the frame the box is laid out in.
let side = match side {
AnchorSide::Top | AnchorSide::Right | AnchorSide::Bottom | AnchorSide::Left if !frame.is_physical() => {
@@ -681,7 +680,7 @@ impl AbsposEngine<'_> {
// the physical vertical axis in a vertical writing mode.
let measures_width = match anchor_size {
None => is_horizontal_axis,
- Some(anchor_size) => measures_physical_width(anchor_size) != self.callbacks.frame.is_transposed(),
+ Some(anchor_size) => measures_physical_width(anchor_size) != self.pass.frame.is_transposed(),
};
if measures_width { rect.width } else { rect.height }
}
@@ -772,18 +771,17 @@ impl AbsposEngine<'_> {
None => default_scroll_shift,
};
// NB: Scrolling is physical, while the axes the shift was resolved in are those of the frame.
- let (compensates_for_horizontal_scroll, compensates_for_vertical_scroll) =
- if self.callbacks.frame.is_transposed() {
- (
- default_scroll_shift.compensates_for_vertical_scroll,
- default_scroll_shift.compensates_for_horizontal_scroll,
- )
- } else {
- (
- default_scroll_shift.compensates_for_horizontal_scroll,
- default_scroll_shift.compensates_for_vertical_scroll,
- )
- };
+ let (compensates_for_horizontal_scroll, compensates_for_vertical_scroll) = if self.pass.frame.is_transposed() {
+ (
+ default_scroll_shift.compensates_for_vertical_scroll,
+ default_scroll_shift.compensates_for_horizontal_scroll,
+ )
+ } else {
+ (
+ default_scroll_shift.compensates_for_horizontal_scroll,
+ default_scroll_shift.compensates_for_vertical_scroll,
+ )
+ };
(
resolved,
abspos_inputs::DefaultScrollShift {
@@ -902,7 +900,7 @@ impl AbsposEngine<'_> {
) -> style_values::ResolvedAnchorSizes {
// NB: Read the computed values themselves, not what an earlier resolution made of them, in the frame the box
// is laid out in.
- let style = StyleValues::for_node(&self.callbacks, node);
+ let style = StyleValues::for_node(&self.pass, node);
// NB: Each resolution also tells whether any of its anchor functions resolved against an anchor box.
let resolve = |calculated: *const c_void, is_horizontal: bool, containing_block_extent: CssPixels| {
let mut resolution_state = AnchorResolutionState::NO_SCROLL_SHIFT;
@@ -1126,7 +1124,7 @@ impl AbsposEngine<'_> {
direction: style.direction(),
},
)?
- .in_frame(self.callbacks.frame);
+ .in_frame(self.pass.frame);
let anchor_box = self.anchor_lookup(positioned_box, style.position_anchor_name())?;
let anchor_rect = self.anchor_rect(anchor_box, containing_block_geometry, entry_coordinate_space_box);
@@ -1813,7 +1811,7 @@ impl AbsposEngine<'_> {
};
let frame_horizontal = matches!(axis, SizingAxis::Inline);
let containing_inline_is_frame_horizontal =
- (writing_mode == writing_mode::HORIZONTAL_TB) != self.callbacks.frame.is_transposed();
+ (writing_mode == writing_mode::HORIZONTAL_TB) != self.pass.frame.is_transposed();
if frame_horizontal != containing_inline_is_frame_horizontal {
return AutoMarginOverflow::Split;
}
@@ -1822,7 +1820,7 @@ impl AbsposEngine<'_> {
// space is negative and both margins are auto, the start margin resolves to zero and the end margin receives
// the remaining space.
// NB: The negative remainder goes to the containing block's inline-end in this frame.
- if geometry::start_is_low_side_in_frame(self.callbacks.frame, writing_mode, direction, frame_horizontal) {
+ if geometry::start_is_low_side_in_frame(self.pass.frame, writing_mode, direction, frame_horizontal) {
AutoMarginOverflow::HighSide
} else {
AutoMarginOverflow::LowSide
@@ -3252,12 +3250,7 @@ impl<'pass> AbsposEngine<'pass> {
}
};
let own_start_is_low_side = || {
- geometry::start_is_low_side_in_frame(
- self.callbacks.frame,
- style.writing_mode(),
- style.direction(),
- inline_axis,
- )
+ geometry::start_is_low_side_in_frame(self.pass.frame, style.writing_mode(), style.direction(), inline_axis)
};
match value {
justify_self::CENTER => Some(AbsposAlignment::Center),
@@ -3408,9 +3401,9 @@ impl<'pass> AbsposEngine<'pass> {
let child_box = child.child_box;
let position_option = self.determine_position_fallback_styles(&child);
self.with_position_option_style(child_box, position_option.style, |engine| {
- let run = run.with_callbacks(engine.callbacks);
+ let run = run.with_pass(engine.pass);
let cells =
- used_values::cells_before_sizing(&engine.callbacks, child_box, ContainingBlockConstraints::default());
+ used_values::cells_before_sizing(&engine.pass, child_box, ContainingBlockConstraints::default());
let (mut inputs, default_scroll_shift) = engine.pending_child_layout_inputs(&mut child);
inputs.position_option = position_option.choice;
engine.layout_element(&run, child_box, cells, inputs, Some(default_scroll_shift))
@@ -3427,9 +3420,9 @@ impl<'pass> AbsposEngine<'pass> {
style: None,
option_styles: Vec::new(),
};
- let style = StyleValues::for_node(&self.callbacks, node);
+ let style = StyleValues::for_node(&self.pass, node);
let anchor = style.anchor();
- let arena = self.callbacks.arena();
+ let arena = self.pass.arena();
if anchor.position_try_fallbacks.length == 0 || !style.is_absolutely_positioned() {
return styles;
}
@@ -3442,7 +3435,7 @@ impl<'pass> AbsposEngine<'pass> {
let (writing_mode, direction) = if containing_block.is_invalid() {
(writing_mode::HORIZONTAL_TB, direction::LTR)
} else {
- let containing_block_style = StyleValues::for_node(&self.callbacks, containing_block);
+ let containing_block_style = StyleValues::for_node(&self.pass, containing_block);
(
containing_block_style.writing_mode(),
containing_block_style.direction(),
@@ -3516,7 +3509,7 @@ impl<'pass> AbsposEngine<'pass> {
let mut child = *child;
let (inputs, _) = engine.pending_child_layout_inputs(&mut child);
let size = engine.inset_modified_containing_block_size(node, &inputs);
- let horizontal_is_frame_inline = !engine.callbacks.frame.is_transposed();
+ let horizontal_is_frame_inline = !engine.pass.frame.is_transposed();
let inline_axis_is_horizontal = writing_mode == writing_mode::HORIZONTAL_TB;
let (horizontal, vertical) = if horizontal_is_frame_inline {
(size.inline_size, size.block_size)
@@ -3610,10 +3603,10 @@ impl<'pass> AbsposEngine<'pass> {
let Some(style) = style else {
return callback(self);
};
- self.callbacks.with_position_option_style(node, style, |callbacks| {
+ self.pass.with_position_option_style(node, style, |pass| {
callback(&AbsposEngine {
state: self.state,
- callbacks,
+ pass,
fragments: self.fragments,
})
})
@@ -3664,9 +3657,9 @@ impl<'pass> AbsposEngine<'pass> {
// abspos's inset-modified containing block, when laid out with adjusted styles.
let (available_space, constraints) = out_of_flow_root_space(&inputs);
let laid_out = formatting_context::run_root_without_parent_fragments(
- self.callbacks,
+ self.pass,
node,
- used_values::cells_before_sizing(&self.callbacks, node, ContainingBlockConstraints::default()),
+ used_values::cells_before_sizing(&self.pass, node, ContainingBlockConstraints::default()),
LayoutInput::new(
available_space,
constraints,
@@ -3893,7 +3886,7 @@ impl<'pass> AbsposEngine<'pass> {
pub(super) fn replay(&self, run: &FormattingContextRun<'pass>, node: Node) {
let mut inputs = self
- .callbacks
+ .pass
.saved_abspos_layout_inputs(node)
.expect("abspos relayout root must have committed layout inputs");
if !inputs.containing_block_info.derives_from_own_computed_values {
@@ -3907,9 +3900,9 @@ impl<'pass> AbsposEngine<'pass> {
}
// Partial relayout uses a fresh state and keeps the replay root
// exactly once.
- let cells = used_values::cells_before_sizing(&self.callbacks, node, ContainingBlockConstraints::default());
+ let cells = used_values::cells_before_sizing(&self.pass, node, ContainingBlockConstraints::default());
let default_scroll_shift = self
- .callbacks
+ .pass
.committed_fragment_link(node)
.and_then(|link| link.default_scroll_shift);
self.layout_element(run, node, cells, inputs, default_scroll_shift);
@@ -3937,7 +3930,7 @@ impl<'pass> AbsposEngine<'pass> {
// an anchor-bearing box resolves its insets even when it turns out not
// to be relatively positioned.
let resolved = if has_anchor_insets {
- let in_flow_containing_block = self.callbacks.in_flow_containing_block(node);
+ let in_flow_containing_block = self.pass.in_flow_containing_block(node);
let containing_block_geometry =
ContainingBlockGeometry::from_box_metrics(containing_block, FfiCssPixelPoint::default());
let (resolved, default_scroll_shift) = self.resolve_anchor_insets(
@@ -3957,10 +3950,7 @@ impl<'pass> AbsposEngine<'pass> {
return insets;
}
formatting_context::propagate_percentage_block_size_dependency_to_containing_block(
- self.state,
- &self.callbacks,
- node,
- false,
+ self.state, &self.pass, node, false,
);
let resolve_opposing = |first: style_values::InsetValue, second: style_values::InsetValue, basis: CssPixels| {
@@ -4006,7 +3996,7 @@ impl<'pass> AbsposEngine<'pass> {
pub(crate) fn drain_abspos_with_placed_containing_blocks(
state: &RunState,
- callbacks: LayoutPass<'_>,
+ pass: LayoutPass<'_>,
should_collect_devtools_layout_data: bool,
entry_fragments: &fragment_tree::RunFragmentBuilder,
) {
@@ -4014,14 +4004,14 @@ pub(crate) fn drain_abspos_with_placed_containing_blocks(
let run = FormattingContextRun {
state,
box_: accumulator_root,
- callbacks,
+ pass,
should_collect_devtools_layout_data,
treat_block_axis_percentage_insets_as_auto_beyond_root: false,
fragments: Some(entry_fragments),
fragmentainer: None,
};
loop {
- let batch = entry_fragments.take_drainable_abspos(accumulator_root, &callbacks);
+ let batch = entry_fragments.take_drainable_abspos(accumulator_root, &pass);
if batch.is_empty() {
break;
}
diff --git a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
index 8c78cd004c9..5b1aaea627c 100644
--- a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
@@ -130,7 +130,7 @@ impl BlockContainer {
/// `node`, laid out with `cells` in `containing_block`, as the block container of the boxes laid out in it.
fn laid_out_in(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
node: Node,
cells: used_values::RootInputCells,
containing_block: BlockContainer,
@@ -140,7 +140,7 @@ impl BlockContainer {
cells,
percentage_block_insets_have_definite_basis:
formatting_context::percentage_block_insets_have_definite_basis_in(
- callbacks,
+ pass,
node,
|| cells.has_definite_block_size,
containing_block.percentage_block_insets_have_definite_basis,
@@ -735,20 +735,20 @@ impl ChildJobAhead {
}
}
- fn lay_out(self, callbacks: LayoutPass<'_>) -> Option<InFlowChildLaidOutAhead> {
+ fn lay_out(self, pass: LayoutPass<'_>) -> Option<InFlowChildLaidOutAhead> {
match self {
Self::Run(shape) => {
- formatting_context::lay_out_shape_for_its_result(callbacks, shape);
+ formatting_context::lay_out_shape_for_its_result(pass, shape);
None
}
- Self::InFlow(job) => lay_out_in_flow_child_ahead(callbacks, *job),
+ Self::InFlow(job) => lay_out_in_flow_child_ahead(pass, *job),
}
}
}
/// Lays out an in-flow child in a flow of its own with no floats, at its true inline position and the block position
/// zero, and leaves it unplaced.
-fn lay_out_in_flow_child_ahead(callbacks: LayoutPass<'_>, job: InFlowChildJob) -> Option<InFlowChildLaidOutAhead> {
+fn lay_out_in_flow_child_ahead(pass: LayoutPass<'_>, job: InFlowChildJob) -> Option<InFlowChildLaidOutAhead> {
let InFlowChildJob {
child,
run_root,
@@ -761,18 +761,18 @@ fn lay_out_in_flow_child_ahead(callbacks: LayoutPass<'_>, job: InFlowChildJob) -
} = job;
let treat_block_axis_percentage_insets_as_auto_beyond_root =
key.treat_block_axis_percentage_insets_as_auto_beyond_root;
- let fragments = fragment_tree::RunFragmentBuilder::new(&callbacks, child, Some(block_container.node));
+ let fragments = fragment_tree::RunFragmentBuilder::new(&pass, child, Some(block_container.node));
RunState::with_root_building_fragments(
- callbacks,
+ pass,
child,
block_container.node,
None,
Some(fragments),
- |state, callbacks| {
+ |state, pass| {
let run = FormattingContextRun {
state,
box_: run_root,
- callbacks,
+ pass,
should_collect_devtools_layout_data: false,
treat_block_axis_percentage_insets_as_auto_beyond_root,
fragments: state.fragments(),
@@ -797,7 +797,7 @@ fn lay_out_in_flow_child_ahead(callbacks: LayoutPass<'_>, job: InFlowChildJob) -
);
// NB: The walk reuses this layout as a box whose margins do not collapse through it.
if outcome.cells.border_box_block_size(false) == CssPixels::default()
- || !fragments.hands_everything_to_the_placement_of_its_root(&run.callbacks)
+ || !fragments.hands_everything_to_the_placement_of_its_root(&run.pass)
{
return None;
}
@@ -811,8 +811,8 @@ fn lay_out_in_flow_child_ahead(callbacks: LayoutPass<'_>, job: InFlowChildJob) -
containing_block_position_in_root,
);
let root = fragments
- .take_run_contents(&run.callbacks)
- .into_run_root_fragment(&run.callbacks, outcome.geometry);
+ .take_run_contents(&run.pass)
+ .into_run_root_fragment(&run.pass, outcome.geometry);
let entry = in_flow_block_cache::InFlowBlockEntry {
key,
validity,
@@ -1120,7 +1120,7 @@ pub(crate) fn root_lays_out_content_against_its_own_block_size(
&& sizing.own_style_depends_on_percentage_block_size(outside_marker);
facts.is_fieldset_box()
|| facts.lays_out_in_columns()
- || is_line_clamp_container(sizing.callbacks(), root)
+ || is_line_clamp_container(sizing.pass(), root)
|| facts.uses_button_layout()
|| facts.is_text_input()
|| facts.is_anonymous_button_content_wrapper()
@@ -1165,9 +1165,9 @@ impl<'pass> BlockFormattingContext<'pass> {
root_cells: used_values::RootInputCells,
previous_line_data: Option<std::sync::Arc<inline_content::InlineContent>>,
) -> Self {
- let style = StyleValues::for_node(&run.callbacks, run.box_);
+ let style = StyleValues::for_node(&run.pass, run.box_);
let computed_continue = style.continue_();
- let is_line_clamp_container = is_line_clamp_container(&run.callbacks, run.box_);
+ let is_line_clamp_container = is_line_clamp_container(&run.pass, run.box_);
// AD-HOC: Content after a -webkit-legacy clamp point stays scrollable overflow, matching other engines. Sites
// detect clamped text by comparing scrollHeight with clientHeight.
let clamped_content_is_scrollable_overflow =
@@ -1176,7 +1176,7 @@ impl<'pass> BlockFormattingContext<'pass> {
run: run.clone(),
root_cells,
previous_line_data: previous_line_data
- .filter(|_| !aligns_content_in_block_axis(&NodeFacts::new(&run.callbacks, run.box_))),
+ .filter(|_| !aligns_content_in_block_axis(&NodeFacts::new(&run.pass, run.box_))),
block_offset_of_current_block_container: Cell::new(None),
margin_states: RefCell::new(vec![BlockMarginState::of_flow_root(run.box_)]),
outside_marker_line: Cell::new(None),
@@ -1286,12 +1286,12 @@ impl<'pass> BlockFormattingContext<'pass> {
#[inline]
fn facts(&self, node: Node) -> NodeFacts<'_> {
- NodeFacts::new(&self.run.callbacks, node)
+ NodeFacts::new(&self.run.pass, node)
}
#[inline]
fn style(&self, node: Node) -> StyleValues<'pass> {
- StyleValues::for_node(&self.run.callbacks, node)
+ StyleValues::for_node(&self.run.pass, node)
}
/// Keeps `layout`, the inline layout of the table box inside `child`, for the run of `child`.
@@ -1313,23 +1313,20 @@ impl<'pass> BlockFormattingContext<'pass> {
}
fn next_sibling(&self, node: Node) -> Node {
- self.run.callbacks.next_sibling(node)
+ self.run.pass.next_sibling(node)
}
fn containing_block(&self, node: Node) -> Node {
- self.run.callbacks.in_flow_containing_block(node)
+ self.run.pass.in_flow_containing_block(node)
}
/// The boxes among the children of `node`.
fn children(&self, node: Node) -> impl Iterator<Item = Node> + '_ {
- self.run
- .callbacks
- .children(node)
- .filter(|&child| self.facts(child).is_box())
+ self.run.pass.children(node).filter(|&child| self.facts(child).is_box())
}
fn is_ancestor_of(&self, ancestor: Node, node: Node) -> bool {
- self.run.callbacks.is_ancestor(ancestor, node, self.run.box_)
+ self.run.pass.is_ancestor(ancestor, node, self.run.box_)
}
fn is_inclusive_ancestor_of(&self, ancestor: Node, node: Node) -> bool {
@@ -1399,7 +1396,7 @@ impl<'pass> BlockFormattingContext<'pass> {
#[inline]
pub(crate) fn sizing(&self) -> sizing_context::SizingContext<'pass, '_> {
- sizing_context::SizingContext::new(self.run.state, self.run.callbacks)
+ sizing_context::SizingContext::new(self.run.state, self.run.pass)
}
/// The sizes, size constraints and box sides of `child`, a box this block formatting context sizes.
@@ -1426,7 +1423,7 @@ impl<'pass> BlockFormattingContext<'pass> {
/// `child`, a box this block formatting context lays out itself, as a box its sizing steps size there.
#[track_caller]
fn sized_cells_of<'cells>(&self, child: ChildSizedHere<'cells>) -> sizing_context::SizedCells<'cells> {
- sizing_context::SizedCells::new(child.node, self.cells_laid_out_here(child), self.run.callbacks.frame)
+ sizing_context::SizedCells::new(child.node, self.cells_laid_out_here(child), self.run.pass.frame)
}
fn register_contained_abspos_child(&self, node: Node, block_offset: CssPixels, block_container: BlockContainer) {
@@ -1454,7 +1451,7 @@ impl<'pass> BlockFormattingContext<'pass> {
alignment_derives_from_own_computed_values: false,
};
formatting_context::register_contained_abspos_child(
- &self.run.callbacks,
+ &self.run.pass,
self.run.fragments,
coordinate_space_box,
node,
@@ -1483,7 +1480,7 @@ impl<'pass> BlockFormattingContext<'pass> {
.borrow_mut()
.push(RootFlowChild::of(child, outcome));
}
- if formatting_context::child_gives_container_baselines(&self.run.callbacks, block_container, child) {
+ if formatting_context::child_gives_container_baselines(&self.run.pass, block_container, child) {
summary
.baselines
.fold_in_later_child(outcome.baselines_in_containing_block);
@@ -1607,7 +1604,7 @@ impl<'pass> BlockFormattingContext<'pass> {
}
fn box_should_avoid_floats_because_it_establishes_fc(&self, node: Node) -> bool {
- box_avoids_floats_because_it_establishes_formatting_context(&self.run.callbacks, node)
+ box_avoids_floats_because_it_establishes_formatting_context(&self.run.pass, node)
}
/// The definite inline space left for this box after the float bands that intrude at its position are subtracted,
@@ -2863,7 +2860,7 @@ impl<'pass> BlockFormattingContext<'pass> {
.then_some(list_item_cells.content_block_size),
..ContainingBlockConstraints::default()
};
- used_values::cells_before_sizing(&self.run.callbacks, marker, marker_constraints)
+ used_values::cells_before_sizing(&self.run.pass, marker, marker_constraints)
}
/// Lays out and places the outside marker of `list_item`, and returns the block end of the marker's border box in
@@ -3160,7 +3157,7 @@ impl<'pass> BlockFormattingContext<'pass> {
let cells = laid_out_box.cells;
let content_baselines = laid_out_box.baselines;
let baselines_in_containing_block = formatting_context::baselines_laid_out_child_gives_container(
- &self.run.callbacks,
+ &self.run.pass,
formatting_context::LaidOutChild {
node,
metrics: &cells,
@@ -3234,7 +3231,7 @@ impl<'pass> BlockFormattingContext<'pass> {
// NB: A child with a formatting context of its own is sized in these cells ahead of its run, which takes them.
// A box without one is laid out in them.
let cells_of_child = Cell::new(used_values::cells_before_sizing(
- &self.run.callbacks,
+ &self.run.pass,
node,
input.containing_block_constraints,
));
@@ -3403,7 +3400,7 @@ impl<'pass> BlockFormattingContext<'pass> {
eprintln!("FIXME: Block-level box is not BlockContainer but does not create formatting context");
formatting_context::propagate_percentage_block_size_dependency_to_containing_block(
run.state,
- &self.run.callbacks,
+ &self.run.pass,
node,
self.sizing().resolve_percentage_block_size_dependency(node),
);
@@ -3743,7 +3740,7 @@ impl<'pass> BlockFormattingContext<'pass> {
};
self.incoming_container_token.replace(continuation.clone());
let node_as_block_container =
- BlockContainer::laid_out_in(&self.run.callbacks, node, self.metrics_of(sized_child), block_container);
+ BlockContainer::laid_out_in(&self.run.pass, node, self.metrics_of(sized_child), block_container);
if is_list_item_box && continuation.is_none() {
outside_marker_laid_out_before_contents =
Some(self.layout_outside_marker_before_contents(run, node_as_block_container));
@@ -3930,12 +3927,7 @@ impl<'pass> BlockFormattingContext<'pass> {
let marker_border_box_block_end = outside_marker.map(|outside_marker| {
self.place_outside_marker(
outside_marker,
- BlockContainer::laid_out_in(
- &self.run.callbacks,
- node,
- self.metrics_of(sized_child),
- block_container,
- ),
+ BlockContainer::laid_out_in(&self.run.pass, node, self.metrics_of(sized_child), block_container),
inline_space_used_before_children_formatted,
list_item_first_baseline,
)
@@ -3947,7 +3939,7 @@ impl<'pass> BlockFormattingContext<'pass> {
summary.include_placed_child(marker_border_box_block_end);
}
// NB: The laid-out marker has a formatting context of its own, so margins do not collapse through it.
- if self.run.callbacks.parent(marker) == node {
+ if self.run.pass.parent(marker) == node {
summary.has_child_whose_margins_do_not_collapse_through = true;
}
}
@@ -3959,7 +3951,7 @@ impl<'pass> BlockFormattingContext<'pass> {
depends_on_percentage_block_size = self.sizing().resolve_percentage_block_size_dependency(node);
formatting_context::propagate_percentage_block_size_dependency_to_containing_block(
run.state,
- &self.run.callbacks,
+ &self.run.pass,
node,
depends_on_percentage_block_size,
);
@@ -4049,7 +4041,7 @@ impl<'pass> BlockFormattingContext<'pass> {
&& let Some(placed) = placed.as_mut()
{
for abspos_child in std::mem::take(&mut placed.abspos_boxes_placed_with_it) {
- if self.run.callbacks.parent(abspos_child.box_) == node {
+ if self.run.pass.parent(abspos_child.box_) == node {
summary.include_placed_child(abspos_child.border_box_block_end);
}
}
@@ -4127,7 +4119,7 @@ impl<'pass> BlockFormattingContext<'pass> {
containing_block_position_in_root: FfiCssPixelPoint,
) -> OutcomeOfChildLaidOutAhead {
let cells_of_child = Cell::new(used_values::cells_before_sizing(
- &self.run.callbacks,
+ &self.run.pass,
node,
input.containing_block_constraints,
));
@@ -4241,7 +4233,7 @@ impl<'pass> BlockFormattingContext<'pass> {
) -> bool {
let facts = self.facts(node);
let container_facts = self.facts(block_container);
- !self.run.callbacks.reads_no_memoized_layout()
+ !self.run.pass.reads_no_memoized_layout()
&& self.run.fragmentainer.is_none()
&& self.run.fragments.is_some()
&& !self.run.should_collect_devtools_layout_data
@@ -4265,7 +4257,7 @@ impl<'pass> BlockFormattingContext<'pass> {
input: LayoutInput,
) -> in_flow_block_cache::InFlowBlockKey {
let stretch_fit_block_margins = sizing_context::stretch_fit_block_margins(
- &self.run.callbacks,
+ &self.run.pass,
node,
input.containing_block_constraints.inline_basis(),
);
@@ -4290,17 +4282,13 @@ impl<'pass> BlockFormattingContext<'pass> {
std::sync::Arc<in_flow_block_cache::InFlowBlockEntry>,
std::sync::Arc<fragment_tree::Fragment>,
)> {
- let callbacks = &self.run.callbacks;
- callbacks
- .arena()
+ let pass = &self.run.pass;
+ pass.arena()
.with_current_committed_fragment(node, |fragment| fragment.clone())
.and_then(|fragment| {
- let entry = callbacks.in_flow_block_cache_store().matching(
- node.slot_index(),
- validity,
- key,
- fragment.identity,
- )?;
+ let entry =
+ pass.in_flow_block_cache_store()
+ .matching(node.slot_index(), validity, key, fragment.identity)?;
Some((entry, fragment))
})
}
@@ -4317,9 +4305,9 @@ impl<'pass> BlockFormattingContext<'pass> {
if !self.in_flow_child_may_be_reused(node, block_container, containing_line_box_fragment) {
return InFlowReuse::Ineligible;
}
- let callbacks = &self.run.callbacks;
+ let pass = &self.run.pass;
let key = self.in_flow_block_key_of(node, block_container, block_container_inline_size, input);
- let validity = fc_run_cache::run_root_validity(callbacks, node);
+ let validity = fc_run_cache::run_root_validity(pass, node);
let hit = self
.stored_in_flow_layout_of(node, validity, &key)
.filter(|(entry, _)| {
@@ -4333,7 +4321,7 @@ impl<'pass> BlockFormattingContext<'pass> {
validity,
abspos_containing_block_info_contributions_received: self
.abspos_containing_block_info_contributions_received(),
- host_findings_noted_so_far: callbacks.host_findings_noted_so_far(),
+ host_findings_noted_so_far: pass.host_findings_noted_so_far(),
float_reads_before_child: self.float_reads.take(),
float_count_before_child: self.floating_box_count(),
margins_before_box: self.margin_state().margins_since_reset,
@@ -4478,7 +4466,7 @@ impl<'pass> BlockFormattingContext<'pass> {
containing_block_position_in_root: FfiCssPixelPoint,
) -> ReusedInFlowChild {
let node = sized_child.node;
- self.run.callbacks.layout_trace().reused_in_flow_subtree(node);
+ self.run.pass.layout_trace().reused_in_flow_subtree(node);
self.cells_laid_out_here(sized_child).set(entry.cells);
let metrics = self.metrics_of(sized_child);
let introduces_clearance = self.clear_floating_boxes(node, None, containing_block_position_in_root);
@@ -4492,7 +4480,7 @@ impl<'pass> BlockFormattingContext<'pass> {
self.outside_marker_line.set(entry.outgoing_outside_marker_line);
formatting_context::propagate_percentage_block_size_dependency_to_containing_block(
self.run.state,
- &self.run.callbacks,
+ &self.run.pass,
node,
entry.depends_on_percentage_block_size,
);
@@ -4627,7 +4615,7 @@ impl<'pass> BlockFormattingContext<'pass> {
before_top_margins_settled: in_open_top_margin_group && float_reads_of_contents.before_top_margins_settled,
..float_reads_of_contents
}));
- let arena = self.run.callbacks.arena();
+ let arena = self.run.pass.arena();
let Some((content_offset, placed)) = placed else {
return;
};
@@ -4637,7 +4625,7 @@ impl<'pass> BlockFormattingContext<'pass> {
let reusable = !placed.exports_payloads
&& self.abspos_containing_block_info_contributions_received()
== abspos_containing_block_info_contributions_received
- && self.run.callbacks.host_findings_noted_so_far() == host_findings_noted_so_far
+ && self.run.pass.host_findings_noted_so_far() == host_findings_noted_so_far
&& used.border_box_block_size(false) != CssPixels::default();
if !reusable {
return;
@@ -4678,7 +4666,7 @@ impl<'pass> BlockFormattingContext<'pass> {
};
let committed_identity = arena.with_current_committed_fragment(node, |fragment| fragment.identity);
self.run
- .callbacks
+ .pass
.in_flow_block_cache_store()
.store(node.slot_index(), entry, committed_identity);
}
@@ -4729,11 +4717,7 @@ impl<'pass> BlockFormattingContext<'pass> {
return None;
}
let constraints = child_input.containing_block_constraints;
- let cells = Cell::new(used_values::cells_before_sizing(
- &self.run.callbacks,
- child,
- constraints,
- ));
+ let cells = Cell::new(used_values::cells_before_sizing(&self.run.pass, child, constraints));
let sized_child = ChildSizedHere::ahead_of_its_run(child, &cells);
self.resolve_vertical_box_model_metrics(sized_child, block_container.cells.content_inline_size, constraints);
let input = if facts.is_floating() {
@@ -4790,7 +4774,7 @@ impl<'pass> BlockFormattingContext<'pass> {
child_input: &LayoutInput,
containing_block_position_in_root: FfiCssPixelPoint,
) -> Option<ChildJobAhead> {
- let callbacks = &self.run.callbacks;
+ let pass = &self.run.pass;
let facts = self.facts(child);
if facts.is_box()
&& !facts.is_floating_or_absolutely_positioned()
@@ -4803,7 +4787,7 @@ impl<'pass> BlockFormattingContext<'pass> {
block_container.cells.content_inline_size,
child_input.clone(),
);
- let validity = fc_run_cache::run_root_validity(callbacks, child);
+ let validity = fc_run_cache::run_root_validity(pass, child);
if self.stored_in_flow_layout_of(child, validity, &key).is_some() {
return None;
}
@@ -4820,7 +4804,7 @@ impl<'pass> BlockFormattingContext<'pass> {
}
let shape =
self.run_shape_of_child_ahead(child, block_container, child_input, containing_block_position_in_root)?;
- (!formatting_context::shape_would_reuse_stored_run(callbacks, &shape)).then_some(ChildJobAhead::Run(shape))
+ (!formatting_context::shape_would_reuse_stored_run(pass, &shape)).then_some(ChildJobAhead::Run(shape))
}
/// Lays out `first_child` and the siblings after it that a block container can lay out on other threads, which the
@@ -4832,8 +4816,8 @@ impl<'pass> BlockFormattingContext<'pass> {
child_input: &LayoutInput,
containing_block_position_in_root: FfiCssPixelPoint,
) {
- let callbacks = self.run.callbacks;
- if callbacks.lays_out_with_position_option()
+ let pass = self.run.pass;
+ if pass.lays_out_with_position_option()
|| self.run.fragments.is_none()
|| self.run.should_collect_devtools_layout_data
|| self.is_line_clamp_container
@@ -4844,21 +4828,16 @@ impl<'pass> BlockFormattingContext<'pass> {
}
// NB: Sizing a child ahead reads floats only to be repeated when the child is laid out in this flow.
let float_reads = self.float_reads.get();
- let jobs = parallel_layout::fork_candidates(
- &callbacks,
- callbacks.siblings_from(first_child, Node::INVALID),
- |child| child,
- )
- .into_iter()
- .filter_map(|child| {
- self.job_of_child_ahead(child, block_container, child_input, containing_block_position_in_root)
- })
- .collect();
+ let jobs =
+ parallel_layout::fork_candidates(&pass, pass.siblings_from(first_child, Node::INVALID), |child| child)
+ .into_iter()
+ .filter_map(|child| {
+ self.job_of_child_ahead(child, block_container, child_input, containing_block_position_in_root)
+ })
+ .collect();
self.float_reads.set(float_reads);
let Ok(tasks) =
- parallel_layout::lay_out_in_parallel(&callbacks, jobs, ChildJobAhead::child, |callbacks, job| {
- job.lay_out(callbacks)
- })
+ parallel_layout::lay_out_in_parallel(&pass, jobs, ChildJobAhead::child, |pass, job| job.lay_out(pass))
else {
return;
};
@@ -4959,8 +4938,8 @@ impl<'pass> BlockFormattingContext<'pass> {
let in_open_top_margin_group = self.margin_state().has_open_top_margin_group();
let abspos_containing_block_info_contributions_received =
self.abspos_containing_block_info_contributions_received();
- let host_findings_noted_so_far = self.run.callbacks.host_findings_noted_so_far();
- self.run.callbacks.receive_host_findings(host_findings);
+ let host_findings_noted_so_far = self.run.pass.host_findings_noted_so_far();
+ self.run.pass.receive_host_findings(host_findings);
let reused = self.reuse_in_flow_child(
sized_child,
block_container,
@@ -4979,7 +4958,7 @@ impl<'pass> BlockFormattingContext<'pass> {
// NB: Reuse hands the box nothing past its fragment, and has the host hear nothing.
if self.abspos_containing_block_info_contributions_received()
== abspos_containing_block_info_contributions_received
- && self.run.callbacks.host_findings_noted_so_far() == host_findings_noted_so_far
+ && self.run.pass.host_findings_noted_so_far() == host_findings_noted_so_far
&& let Some(placed) = reused.placed.as_ref().filter(|placed| !placed.exports_payloads)
{
entry.fragment_identity = placed.fragment.identity;
@@ -4988,11 +4967,11 @@ impl<'pass> BlockFormattingContext<'pass> {
entry.floats_read_by_contents.introduced_clearance = reused.introduced_clearance;
let committed_identity = self
.run
- .callbacks
+ .pass
.arena()
.with_current_committed_fragment(node, |fragment| fragment.identity);
self.run
- .callbacks
+ .pass
.in_flow_block_cache_store()
.store(node.slot_index(), entry, committed_identity);
}
@@ -5044,7 +5023,7 @@ impl<'pass> BlockFormattingContext<'pass> {
let first_child = fragmentation_state
.as_ref()
.and_then(|state| state.resume.as_ref()?.resume_child())
- .unwrap_or_else(|| self.run.callbacks.first_child(block_container.node));
+ .unwrap_or_else(|| self.run.pass.first_child(block_container.node));
if block_container.node == self.run.box_ {
self.root_flow_children.borrow_mut().clear();
}
@@ -5052,7 +5031,7 @@ impl<'pass> BlockFormattingContext<'pass> {
let mut summary = ChildrenSummary::default();
for child in self
.run
- .callbacks
+ .pass
.siblings_from(first_child, Node::INVALID)
.filter(|&child| self.facts(child).is_box())
{
@@ -5286,7 +5265,7 @@ impl<'pass> BlockFormattingContext<'pass> {
|style| style.break_after(),
|node| {
self.run
- .callbacks
+ .pass
.children_rev(node)
.filter(|&child| self.facts(child).is_box())
.find(|&child| self.is_first_or_last_in_flow_candidate(child))
@@ -5353,7 +5332,7 @@ impl<'pass> BlockFormattingContext<'pass> {
if !facts.is_flow_layout_participant() || facts.is_floating() {
return false;
}
- !(self.run.callbacks.can_skip_is_anonymous_text_run(child)
+ !(self.run.pass.can_skip_is_anonymous_text_run(child)
&& self.style(child).white_space_collapse() == white_space_collapse::COLLAPSE)
}
@@ -5499,7 +5478,7 @@ impl<'pass> BlockFormattingContext<'pass> {
fn unbreakable_content_floor(&self, node: Node, children: Option<&ChildrenSummary>) -> CssPixels {
let marker_floor =
- floor_list_item_automatic_block_size_by_marker_line_height(self.run.callbacks, node, CssPixels::default());
+ floor_list_item_automatic_block_size_by_marker_line_height(self.run.pass, node, CssPixels::default());
if self.facts(node).is_editing_host() && !children.is_some_and(ChildrenSummary::has_in_flow_content_edge) {
return marker_floor.max(self.style(node).line_height());
}
@@ -5755,12 +5734,12 @@ impl<'pass> BlockFormattingContext<'pass> {
}
fn is_column_spanner(&self, node: Node) -> bool {
- is_column_spanner(&self.run.callbacks, node)
+ is_column_spanner(&self.run.pass, node)
}
fn sibling_boxes_from(&self, first: Node) -> impl Iterator<Item = Node> + '_ {
self.run
- .callbacks
+ .pass
.siblings_from(first, Node::INVALID)
.filter(|&sibling| self.facts(sibling).is_box())
}
@@ -5771,7 +5750,7 @@ impl<'pass> BlockFormattingContext<'pass> {
}
let first = incoming
.and_then(|token| token.resume.resume_child())
- .unwrap_or_else(|| self.run.callbacks.first_child(self.run.box_));
+ .unwrap_or_else(|| self.run.pass.first_child(self.run.box_));
self.sibling_boxes_from(first)
.find(|&child| self.is_column_spanner(child))
}
@@ -6014,7 +5993,7 @@ impl<'pass> BlockFormattingContext<'pass> {
);
}
// NB: Only the attempt that is kept tells the host what it found out.
- self.run.callbacks.receive_host_findings(outputs.host_findings);
+ self.run.pass.receive_host_findings(outputs.host_findings);
return ColumnLayout {
outcome,
consumed_block_size: outputs.result.automatic_content_block_size,
@@ -6051,7 +6030,7 @@ impl<'pass> BlockFormattingContext<'pass> {
.replace(Some(CssPixels::default()));
self.root_flow_children.borrow_mut().clear();
let mut summary = ChildrenSummary::default();
- for child in table_wrapper_flow_children(self.run.callbacks, wrapper) {
+ for child in table_wrapper_flow_children(self.run.pass, wrapper) {
let child_input = if self.style(child).display().is_table_inside() {
table_box_input.clone()
} else {
@@ -6230,7 +6209,7 @@ impl<'pass> BlockFormattingContext<'pass> {
self.automatic_line_clamp_block_size.set(automatic_block_size);
} else if automatic_block_size.is_some() {
let measurement_result = formatting_context::lay_out_measurement_root_for_its_result(
- self.run.callbacks,
+ self.run.pass,
self.run.box_,
self.root_cells,
LayoutInput {
@@ -6406,7 +6385,7 @@ impl<'pass> BlockFormattingContext<'pass> {
content_offset: outcome.content_offset,
cells: outcome.cells,
baselines: formatting_context::baselines_of_block_level_box_on_line(
- &self.run.callbacks,
+ &self.run.pass,
node,
&outcome.cells,
outcome.content_baselines,
@@ -6833,7 +6812,7 @@ impl<'pass> BlockFormattingContext<'pass> {
block_container,
inline_input,
containing_block_position_in_root,
- self.run.callbacks,
+ self.run.pass,
self,
);
let summary = context.run();
@@ -6860,16 +6839,12 @@ impl<'pass> BlockFormattingContext<'pass> {
true,
children,
);
- floor_list_item_automatic_block_size_by_marker_line_height(
- self.run.callbacks,
- node,
- automatic_content_block_size,
- )
- .max(
- children
- .and_then(|children| children.outside_marker_line_box_block_size)
- .unwrap_or_default(),
- )
+ floor_list_item_automatic_block_size_by_marker_line_height(self.run.pass, node, automatic_content_block_size)
+ .max(
+ children
+ .and_then(|children| children.outside_marker_line_box_block_size)
+ .unwrap_or_default(),
+ )
}
fn automatic_block_size_for_block_level_element_disregarding_marker(
@@ -6998,14 +6973,14 @@ impl<'pass> BlockFormattingContext<'pass> {
return None;
}
let mut block_size = sizing.calculate_inner_block_size(
- sizing_context::SizedBox::of_own_metrics(self.run.box_, &self.root_cells, self.run.callbacks.frame),
+ sizing_context::SizedBox::of_own_metrics(self.run.box_, &self.root_cells, self.run.pass.frame),
input.available_space,
style.max_height(),
input.containing_block_constraints,
);
if !crate::layout::sizing_context::is_plain_auto(style.min_height()) {
block_size = block_size.max(sizing.calculate_inner_block_size(
- sizing_context::SizedBox::of_own_metrics(self.run.box_, &self.root_cells, self.run.callbacks.frame),
+ sizing_context::SizedBox::of_own_metrics(self.run.box_, &self.root_cells, self.run.pass.frame),
input.available_space,
style.min_height(),
input.containing_block_constraints,
@@ -7043,7 +7018,7 @@ impl<'pass> BlockFormattingContext<'pass> {
let line_clamp_reached = self.line_clamp_reached();
let block_size = automatic_block_size_for_bfc_root(
self.root_lines.borrow().last_line(),
- self.run.callbacks,
+ self.run.pass,
self.run.box_,
&self.root_flow_children.borrow(),
honors_size_containment,
@@ -7057,7 +7032,7 @@ impl<'pass> BlockFormattingContext<'pass> {
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).max(
+ floor_list_item_automatic_block_size_by_marker_line_height(self.run.pass, self.run.box_, block_size).max(
self.outside_marker_line_box_block_size_of_root
.get()
.unwrap_or_default(),
@@ -7067,11 +7042,7 @@ impl<'pass> BlockFormattingContext<'pass> {
fn line_clamp_subtree_contains_line(&self, node: Node) -> bool {
let facts = self.facts(node);
if facts.is_text_node() {
- return !self
- .run
- .callbacks
- .text_content(node)
- .untransformed_text_is_ascii_whitespace;
+ return !self.run.pass.text_content(node).untransformed_text_is_ascii_whitespace;
}
if facts.is_atomic_inline() || (facts.is_anonymous() && facts.children_are_inline()) {
return true;
@@ -7105,14 +7076,14 @@ impl<'pass> BlockFormattingContext<'pass> {
}
sibling = self.next_sibling(sibling);
}
- node = self.run.callbacks.parent(node);
+ node = self.run.pass.parent(node);
}
has_intervening_in_flow_box.then_some(true)
}
}
-pub(crate) fn is_line_clamp_container(callbacks: &LayoutPass<'_>, node: Node) -> bool {
- let style = StyleValues::for_node(callbacks, node);
+pub(crate) fn is_line_clamp_container(pass: &LayoutPass<'_>, node: Node) -> bool {
+ let style = StyleValues::for_node(pass, node);
let computed_continue = style.continue_();
// https://drafts.csswg.org/css-overflow-4/#continue
// If the box is a block container, then it must establish an independent formatting context that also becomes
@@ -7125,21 +7096,18 @@ pub(crate) fn is_line_clamp_container(callbacks: &LayoutPass<'_>, node: Node) ->
|| (computed_continue == continue_value::_WEBKIT_LEGACY
&& style.display_before_box_type_transformation().is_webkit_box_inside()
&& style.webkit_box_orient() == webkit_box_orient::VERTICAL))
- && !NodeFacts::new(callbacks, node).lays_out_in_columns()
+ && !NodeFacts::new(pass, node).lays_out_in_columns()
}
-pub(crate) fn is_column_spanner(callbacks: &LayoutPass<'_>, node: Node) -> bool {
- let facts = NodeFacts::new(callbacks, node);
+pub(crate) fn is_column_spanner(pass: &LayoutPass<'_>, node: Node) -> bool {
+ let facts = NodeFacts::new(pass, node);
facts.is_flow_layout_participant()
&& !facts.is_floating()
&& facts.display().is_block_outside()
- && StyleValues::for_node(callbacks, node).column_span() == column_span::ALL
+ && StyleValues::for_node(pass, node).column_span() == column_span::ALL
}
-pub(crate) fn box_avoids_floats_because_it_establishes_formatting_context(
- callbacks: &LayoutPass<'_>,
- node: Node,
-) -> bool {
+pub(crate) fn box_avoids_floats_because_it_establishes_formatting_context(pass: &LayoutPass<'_>, node: Node) -> bool {
// https://drafts.csswg.org/css2/#floats
// The border box of a table, a block-level replaced element, or an element in the normal flow that establishes
// a new block formatting context (such as an element with 'overflow' other than 'visible') must not overlap the
@@ -7160,7 +7128,7 @@ pub(crate) fn box_avoids_floats_because_it_establishes_formatting_context(
// This is the same as establishing an independent block formatting context, except that grid layout is used
// instead of block layout: floats do not intrude into the grid container, and the grid container’s margins do
// not collapse with the margins of its contents.
- let facts = NodeFacts::new(callbacks, node);
+ let facts = NodeFacts::new(pass, node);
facts.is_replaced_box()
|| matches!(
formatting_context::formatting_context_type_created_by_box(facts),
@@ -7173,11 +7141,9 @@ pub(crate) fn box_avoids_floats_because_it_establishes_formatting_context(
)
}
-fn table_box_of_wrapper(callbacks: LayoutPass<'_>, wrapper: Node) -> Node {
- for child in callbacks.children(wrapper) {
- if NodeFacts::new(&callbacks, child).is_box()
- && StyleValues::for_node(&callbacks, child).display().is_table_inside()
- {
+fn table_box_of_wrapper(pass: LayoutPass<'_>, wrapper: Node) -> Node {
+ for child in pass.children(wrapper) {
+ if NodeFacts::new(&pass, child).is_box() && StyleValues::for_node(&pass, child).display().is_table_inside() {
return child;
}
}
@@ -7188,14 +7154,14 @@ fn table_box_of_wrapper(callbacks: LayoutPass<'_>, wrapper: Node) -> Node {
// order, then the table box, then bottom captions in document order. Captions are tree children
// of the table box; absolutely positioned captions are out of flow and are registered by
// register_table_abspos_descendants instead.
-pub(crate) fn table_wrapper_flow_children(callbacks: LayoutPass<'_>, wrapper: Node) -> Vec<Node> {
- let table_box = table_box_of_wrapper(callbacks, wrapper);
+pub(crate) fn table_wrapper_flow_children(pass: LayoutPass<'_>, wrapper: Node) -> Vec<Node> {
+ let table_box = table_box_of_wrapper(pass, wrapper);
let mut flow_children = Vec::new();
let mut bottom_captions = Vec::new();
- for child in callbacks.children(table_box) {
- let facts = NodeFacts::new(&callbacks, child);
+ for child in pass.children(table_box) {
+ let facts = NodeFacts::new(&pass, child);
if facts.is_box() && facts.is_table_caption() && !facts.is_absolutely_positioned() {
- if StyleValues::for_node(&callbacks, child).caption_side() == caption_side::TOP {
+ if StyleValues::for_node(&pass, child).caption_side() == caption_side::TOP {
flow_children.push(child);
} else {
bottom_captions.push(child);
@@ -7247,14 +7213,14 @@ pub(crate) fn margins_can_collapse_through_box_itself(
// https://www.w3.org/TR/CSS22/visudet.html#root-height
pub(crate) fn automatic_block_size_for_bfc_root(
root_last_line: Option<inline_content::LineRecord>,
- callbacks: LayoutPass<'_>,
+ pass: LayoutPass<'_>,
root: Node,
flow_children: &[RootFlowChild],
honors_size_containment: bool,
lowest_floating_descendant_bottom_margin_edge: Option<CssPixels>,
trailing_collapsed_margin: Option<(usize, CssPixels)>,
) -> CssPixels {
- let facts = NodeFacts::new(&callbacks, root);
+ let facts = NodeFacts::new(&pass, root);
// https://drafts.csswg.org/css-contain-2/#containment-size
// A size-contained box is sized as if it had no contents.
if honors_size_containment && facts.node_has_size_containment() {
@@ -7280,7 +7246,7 @@ pub(crate) fn automatic_block_size_for_bfc_root(
// NB: Captions flow in a table wrapper's formatting context while remaining tree children of the table box, so
// the flow children of a wrapper are its captions and its table box.
let participates = |child: &RootFlowChild| {
- let child_facts = NodeFacts::new(&callbacks, child.node);
+ let child_facts = NodeFacts::new(&pass, child.node);
child_facts.is_flow_layout_participant() && !child_facts.is_floating()
};
let last_participant = flow_children.iter().rposition(participates);
@@ -7298,7 +7264,7 @@ pub(crate) fn automatic_block_size_for_bfc_root(
_ if Some(index) != last_participant
&& child.border_box_block_size == CssPixels::default()
&& formatting_context::formatting_context_type_created_by_box(NodeFacts::new(
- &callbacks, child.node,
+ &pass, child.node,
))
.is_none() =>
{
@@ -7328,9 +7294,9 @@ pub(crate) fn automatic_block_size_of_independent_root_ahead_of_its_contents(
constraints: ContainingBlockConstraints,
) -> CssPixels {
let node = sized.node;
- let callbacks = *sizing.callbacks();
- let facts = NodeFacts::new(&callbacks, node);
- let style = StyleValues::for_node(&callbacks, node);
+ let pass = *sizing.pass();
+ let facts = NodeFacts::new(&pass, node);
+ let style = StyleValues::for_node(&pass, node);
let display = style.display();
let automatic_content_block_size = if facts.node_has_size_containment() {
if style.contain_intrinsic_height_has_length() {
@@ -7349,15 +7315,15 @@ pub(crate) fn automatic_block_size_of_independent_root_ahead_of_its_contents(
} else {
CssPixels::default()
};
- floor_list_item_automatic_block_size_by_marker_line_height(callbacks, node, automatic_content_block_size)
+ floor_list_item_automatic_block_size_by_marker_line_height(pass, node, automatic_content_block_size)
}
pub(crate) fn floor_list_item_automatic_block_size_by_marker_line_height(
- callbacks: LayoutPass<'_>,
+ pass: LayoutPass<'_>,
node: Node,
automatic_content_block_size: CssPixels,
) -> CssPixels {
- let facts = NodeFacts::new(&callbacks, node);
+ let facts = NodeFacts::new(&pass, node);
if !facts.is_list_item_box() {
return automatic_content_block_size;
}
@@ -7365,7 +7331,7 @@ pub(crate) fn floor_list_item_automatic_block_size_by_marker_line_height(
if marker.is_invalid() {
return automatic_content_block_size;
}
- automatic_content_block_size.max(StyleValues::for_node(&callbacks, marker).line_height())
+ automatic_content_block_size.max(StyleValues::for_node(&pass, marker).line_height())
}
/// The inline layout of the table box inside `child` that `kept` holds for the run of `child`, which stays kept for
diff --git a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs
index 7ad30154ac9..9e23adad8b6 100644
--- a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs
+++ b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs
@@ -729,8 +729,8 @@ fn shared_entry_in_allocation_of(
}
}
-pub(super) fn run_root_validity(callbacks: &LayoutPass<'_>, box_: Node) -> FcRunCacheValidity {
- let data = NodeFacts::new(callbacks, box_).data();
+pub(super) fn run_root_validity(pass: &LayoutPass<'_>, box_: Node) -> FcRunCacheValidity {
+ let data = NodeFacts::new(pass, box_).data();
FcRunCacheValidity {
slot_generation: data.slot_generation.get(),
fragment_cache_epoch: data.fragment_cache_epoch,
@@ -780,7 +780,7 @@ impl FcRunCacheAttempt {
builds_fragments: bool,
should_collect_devtools_layout_data: bool,
measurement_root_keeps_its_result: bool,
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
key: &FcRunCacheKey,
) -> Result<Self, FcRunCacheHit> {
if !can_describe_run(
@@ -788,20 +788,20 @@ impl FcRunCacheAttempt {
runs_as_subgrid,
should_collect_devtools_layout_data,
measurement_root_keeps_its_result,
- callbacks,
+ pass,
key,
) {
return Ok(Self::Bypass);
}
- let store = callbacks.fc_run_cache_store();
- let validity = run_root_validity(callbacks, box_);
+ let store = pass.fc_run_cache_store();
+ let validity = run_root_validity(pass, box_);
if !builds_fragments {
if let Some(entry) = store.first_entry_where_summary_allows(
box_.slot_index(),
|summary| summary.may_answer_probe(validity, false),
|entry| entry.validity == validity && entry.answers_probe_for(key),
) {
- entry.note_used_at_layout_commit(callbacks.arena().layout_commit_count());
+ entry.note_used_at_layout_commit(pass.arena().layout_commit_count());
return Err(FcRunCacheHit { entry });
}
return Ok(Self::StoreResultOnly { validity });
@@ -813,7 +813,7 @@ impl FcRunCacheAttempt {
) {
// NB: Once the replayed fragments are committed, the sweep keeps the entry beside later ones.
store.enqueue_for_sweep(box_.slot_index());
- entry.note_used_at_layout_commit(callbacks.arena().layout_commit_count());
+ entry.note_used_at_layout_commit(pass.arena().layout_commit_count());
return Err(FcRunCacheHit { entry });
}
let structurally_damaged_entry = store.structurally_damaged_entry(box_, validity, key);
@@ -828,7 +828,7 @@ impl FcRunCacheAttempt {
builds_fragments: bool,
should_collect_devtools_layout_data: bool,
measurement_root_keeps_its_result: bool,
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
key: &FcRunCacheKey,
) -> bool {
if !can_describe_run(
@@ -836,14 +836,13 @@ impl FcRunCacheAttempt {
false,
should_collect_devtools_layout_data,
measurement_root_keeps_its_result,
- callbacks,
+ pass,
key,
) {
return false;
}
- let validity = run_root_validity(callbacks, box_);
- callbacks
- .fc_run_cache_store()
+ let validity = run_root_validity(pass, box_);
+ pass.fc_run_cache_store()
.first_entry_where_summary_allows(
box_.slot_index(),
|summary| summary.may_answer_probe(validity, builds_fragments),
@@ -871,12 +870,12 @@ impl FcRunCacheAttempt {
/// that the parent takes in what it keeps of them without a copy, or as they are.
pub(super) fn conclude(
self,
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
box_: Node,
key: &FcRunCacheKey,
outputs: formatting_context::RunOutputs,
) -> formatting_context::RunOutputsHandle {
- let store = callbacks.fc_run_cache_store();
+ let store = pass.fc_run_cache_store();
let (validity, structurally_damaged_entry) = match self {
Self::Bypass => return formatting_context::RunOutputsHandle::Owned(outputs),
Self::StoreResultOnly { validity } => {
@@ -889,11 +888,11 @@ impl FcRunCacheAttempt {
outputs,
table_cell_block_paddings_unobserved: false,
last_used_at_layout_commit: std::sync::atomic::AtomicU64::new(
- callbacks.arena().layout_commit_count(),
+ pass.arena().layout_commit_count(),
),
structural_epoch_bumps_when_stored: 0,
},
- |entry| entry.holds_committed_fragments(callbacks.arena(), box_),
+ |entry| entry.holds_committed_fragments(pass.arena(), box_),
));
}
Self::Store {
@@ -906,20 +905,20 @@ impl FcRunCacheAttempt {
if outputs.root.is_none() {
return formatting_context::RunOutputsHandle::Owned(outputs);
}
- let table_cell_block_paddings_unobserved = NodeFacts::new(callbacks, box_).is_table_cell()
+ let table_cell_block_paddings_unobserved = NodeFacts::new(pass, box_).is_table_cell()
&& outputs.root_outcome.parent_owns_root_input_cells()
- && !run_observes_root_block_padding(callbacks, box_, &outputs);
+ && !run_observes_root_block_padding(pass, box_, &outputs);
let entry = FcRunCacheEntry {
key: key.clone(),
validity,
outputs,
table_cell_block_paddings_unobserved,
- last_used_at_layout_commit: std::sync::atomic::AtomicU64::new(callbacks.arena().layout_commit_count()),
+ last_used_at_layout_commit: std::sync::atomic::AtomicU64::new(pass.arena().layout_commit_count()),
structural_epoch_bumps_when_stored: 0,
};
- formatting_context::RunOutputsHandle::Stored(store.store(box_, entry, |entry| {
- entry.holds_committed_fragments(callbacks.arena(), box_)
- }))
+ formatting_context::RunOutputsHandle::Stored(
+ store.store(box_, entry, |entry| entry.holds_committed_fragments(pass.arena(), box_)),
+ )
}
}
@@ -928,7 +927,7 @@ pub(super) fn can_describe_run(
runs_as_subgrid: bool,
should_collect_devtools_layout_data: bool,
measurement_root_keeps_its_result: bool,
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
key: &FcRunCacheKey,
) -> bool {
let fc_type = key.fc_type;
@@ -940,7 +939,7 @@ pub(super) fn can_describe_run(
// Replaying a stored output costs more than rebuilding it and retains an entry needlessly.
|| (fc_type == formatting_context::FormattingContextType::Block
&& input.participation == ParticipationInParentFormattingContext::AtomicInline
- && callbacks.first_child(box_).is_invalid())
+ && pass.first_child(box_).is_invalid())
{
return false;
}
@@ -955,10 +954,7 @@ pub(super) fn can_describe_run(
// pass; scroll compensation compares chains that converge at the run root; and
// anchor-size() resolves to None today, so inset properties are the only anchor
// dependency a run can have.
- !node_facts::has_flag(
- NodeFacts::new(callbacks, box_).data(),
- NodeFlag::InsetsUseAnchorFunctions,
- )
+ !node_facts::has_flag(NodeFacts::new(pass, box_).data(), NodeFlag::InsetsUseAnchorFunctions)
}
/// Whether a run's outputs may depend on its root's block paddings. They hold the content in content box coordinates,
@@ -968,11 +964,11 @@ pub(super) fn can_describe_run(
/// containing block rects, anchors), which are placed against its padding box. Outputs without a root fragment cannot
/// show those payloads.
pub(super) fn run_observes_root_block_padding(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
box_: Node,
outputs: &formatting_context::RunOutputs,
) -> bool {
- let facts = NodeFacts::new(callbacks, box_);
+ let facts = NodeFacts::new(pass, box_);
let places_rendered_legend_on_its_border_box = facts.is_fieldset_box() && !facts.rendered_legend().is_invalid();
facts.is_scroll_container()
|| places_rendered_legend_on_its_border_box
diff --git a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
index d2d51876e33..f9825b6d01c 100644
--- a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
@@ -314,11 +314,10 @@ struct FlexContainerConstants<'pass> {
impl<'pass> FlexContainerConstants<'pass> {
// https://www.w3.org/TR/css-flexbox-1/#flex-direction-property
fn of(run: &FormattingContextRun<'pass>) -> Self {
- let style = StyleValues::for_node(&run.callbacks, run.box_);
+ let style = StyleValues::for_node(&run.pass, run.box_);
let flex_direction = style.effective_flex_direction();
let is_row_layout = matches!(flex_direction, flex_direction::ROW | flex_direction::ROW_REVERSE);
- let inline_axis_is_horizontal =
- !geometry::Frame::of(style.writing_mode()).is_orthogonal_to(run.callbacks.frame);
+ let inline_axis_is_horizontal = !geometry::Frame::of(style.writing_mode()).is_orthogonal_to(run.pass.frame);
let main_axis_is_horizontal = inline_axis_is_horizontal == is_row_layout;
let is_legacy_webkit_box = style.display().inside == display_inside::_WEBKIT_BOX;
// AD-HOC: A legacy webkit box is always single-line; `flex-wrap` does not apply, matching other engines.
@@ -442,22 +441,22 @@ impl<'pass> FlexFormattingContext<'pass> {
#[inline]
fn style(&self, node: Node) -> StyleValues<'pass> {
- StyleValues::for_node(&self.run.callbacks, node)
+ StyleValues::for_node(&self.run.pass, node)
}
#[inline]
fn facts(&self, node: Node) -> NodeFacts<'_> {
- NodeFacts::new(&self.run.callbacks, node)
+ NodeFacts::new(&self.run.pass, node)
}
#[inline]
fn sizing(&self) -> sizing_context::SizingContext<'pass, '_> {
- sizing_context::SizingContext::new(self.run.state, self.run.callbacks).with_child_run_shapes(self)
+ sizing_context::SizingContext::new(self.run.state, self.run.pass).with_child_run_shapes(self)
}
fn keep_item_for_its_run(&self, node: Node) -> used_values::RootInputCells {
let constraints = self.item_percentage_bases;
- used_values::cells_before_sizing(&self.run.callbacks, node, constraints)
+ used_values::cells_before_sizing(&self.run.pass, node, constraints)
}
/// The constraints the children of the container are laid out with, where the container is laid out with the
@@ -540,8 +539,8 @@ impl<'pass> FlexFormattingContext<'pass> {
justify_content::LEFT => {
if self.is_row_layout() {
false
- } else if self.run.callbacks.frame.is_transposed() {
- self.run.callbacks.frame.frame_side(geometry::Side::Left) == geometry::Side::Bottom
+ } else if self.run.pass.frame.is_transposed() {
+ self.run.pass.frame.frame_side(geometry::Side::Left) == geometry::Side::Bottom
} else {
start_is_reverse
}
@@ -553,8 +552,8 @@ impl<'pass> FlexFormattingContext<'pass> {
justify_content::RIGHT => {
if self.is_row_layout() {
true
- } else if self.run.callbacks.frame.is_transposed() {
- self.run.callbacks.frame.frame_side(geometry::Side::Right) == geometry::Side::Bottom
+ } else if self.run.pass.frame.is_transposed() {
+ self.run.pass.frame.frame_side(geometry::Side::Right) == geometry::Side::Bottom
} else {
start_is_reverse
}
@@ -1114,8 +1113,7 @@ impl<'pass> FlexFormattingContext<'pass> {
is_scroll_container: facts.is_scroll_container(),
preferred_aspect_ratio: facts.preferred_aspect_ratio(),
auto_content_size: facts.auto_content_size(),
- inline_axis_is_horizontal: !geometry::Frame::of(style.writing_mode())
- .is_orthogonal_to(self.run.callbacks.frame),
+ inline_axis_is_horizontal: !geometry::Frame::of(style.writing_mode()).is_orthogonal_to(self.run.pass.frame),
establishes_orthogonal_flow: self.sizing().establishes_orthogonal_flow(node),
};
(inputs, alignment_facts)
@@ -1130,15 +1128,15 @@ impl<'pass> FlexFormattingContext<'pass> {
// This is particularly important since we take references to the items stored in flex_items
// later, whose addresses won't be stable if we added or removed any items.
let first_new_item = self.flex_items.len();
- let child_count = self.run.callbacks.children(self.run.box_).count();
+ let child_count = self.run.pass.children(self.run.box_).count();
self.flex_items.reserve(child_count);
self.flex_item_details.reserve(child_count);
let mut order_of_first_item = None;
let mut items_have_different_orders = false;
- for child in self.run.callbacks.children(self.run.box_) {
+ for child in self.run.pass.children(self.run.box_) {
let facts = self.facts(child);
if facts.is_box() {
- let skip = self.run.callbacks.can_skip_is_anonymous_text_run(child);
+ let skip = self.run.pass.can_skip_is_anonymous_text_run(child);
// Skip any "out-of-flow" children
if !skip && !facts.is_absolutely_positioned() {
// Flex inhibits floating, so only absolute positioning is out of flow here.
@@ -2245,7 +2243,7 @@ impl<'pass> FlexFormattingContext<'pass> {
fn fork_candidates(&self) -> Vec<usize> {
self.items_to_fork
.get_or_init(|| {
- parallel_layout::fork_candidates(&self.run.callbacks, 0..self.flex_items.len(), |index| {
+ parallel_layout::fork_candidates(&self.run.pass, 0..self.flex_items.len(), |index| {
self.flex_items[index].box_
})
})
@@ -2300,7 +2298,7 @@ impl<'pass> FlexFormattingContext<'pass> {
)
})
.collect();
- parallel_layout::lay_out_shapes_ahead(&self.run.callbacks, shapes);
+ parallel_layout::lay_out_shapes_ahead(&self.run.pass, shapes);
}
// https://drafts.csswg.org/css-flexbox/#hypothetical-cross-size
@@ -2953,7 +2951,7 @@ impl<'pass> FlexFormattingContext<'pass> {
let item_cross_axis_is_reverse = || {
let item_style = item_style();
!geometry::start_is_low_side_in_frame(
- self.run.callbacks.frame,
+ self.run.pass.frame,
item_style.writing_mode(),
item_style.direction(),
self.cross_axis_is_horizontal(),
@@ -3147,7 +3145,7 @@ impl<'pass> FlexFormattingContext<'pass> {
// https://drafts.csswg.org/css-align-3/#synthesize-baseline
// NB: An item in another writing mode has no baseline in this container's axis, so it synthesizes one.
fn item_baseline_is_synthesized(&self, index: usize) -> bool {
- if self.run.callbacks.frame.is_transposed() {
+ if self.run.pass.frame.is_transposed() {
// NB: An item has a baseline across its block axis, so only in the cross axis that its block axis runs
// along.
return self.item_establishes_orthogonal_flow(index) != self.cross_axis_is_horizontal();
@@ -3163,13 +3161,13 @@ impl<'pass> FlexFormattingContext<'pass> {
// FIXME: Items in a horizontal-tb container only align by baselines across the vertical axis, where a
// horizontal-tb item is aligned by its own baselines and any other item by synthesized ones.
self.flex_items[index].alignment_facts.alignment == align_items::BASELINE
- && (!self.item_baseline_is_synthesized(index) || !self.run.callbacks.frame.is_transposed())
+ && (!self.item_baseline_is_synthesized(index) || !self.run.pass.frame.is_transposed())
}
fn item_box_baseline(&self, index: usize) -> CssPixels {
let extras = &self.flex_item_details[index];
let metrics = &self.flex_item_details[index].cells;
- if self.run.callbacks.frame.is_transposed() && self.cross_axis_is_horizontal() {
+ if self.run.pass.frame.is_transposed() && self.cross_axis_is_horizontal() {
// NB: The cross axis is the horizontal axis of the frame, along which an item in an orthogonal flow
// has its baselines.
let collapsed = metrics.uses_collapsing_borders_model();
@@ -3186,7 +3184,7 @@ impl<'pass> FlexFormattingContext<'pass> {
+ metrics.border_box_bottom(collapsed);
}
formatting_context::box_baseline_with_content_baselines(
- &self.run.callbacks,
+ &self.run.pass,
self.flex_items[index].box_,
metrics,
formatting_context::BaselineSet::First,
@@ -3405,7 +3403,7 @@ impl<'pass> FlexFormattingContext<'pass> {
let plan = formatting_context::child_run_plan(
&self.run,
node,
- formatting_context::formatting_context_type_created_by_box(NodeFacts::new(&self.run.callbacks, node)),
+ formatting_context::formatting_context_type_created_by_box(NodeFacts::new(&self.run.pass, node)),
input,
false,
self.run
@@ -3606,7 +3604,7 @@ impl<'pass> FlexFormattingContext<'pass> {
let main_min_size_property = self.select_main(style.min_width(), style.min_height());
let main_max_size_property = self.select_main(style.max_width(), style.max_height());
items.push(formatting_context::FlexLayoutItem {
- style_node: self.run.callbacks.arena().dom_node_style_node(node),
+ style_node: self.run.pass.arena().dom_node_style_node(node),
rect,
main_base_size: item.flex_base_size,
main_delta_size: item.target_main_size - item.flex_base_size,
@@ -3895,7 +3893,7 @@ impl<'pass> FlexFormattingContext<'pass> {
fn resolve_own_auto_block_size(&self, automatic_block_size: CssPixels, resolution_space: AvailableSpace) {
self.sizing().resolve_used_block_size_if_treated_as_auto(
- sizing_context::SizedCells::new(self.run.box_, &self.container_cells, self.run.callbacks.frame),
+ sizing_context::SizedCells::new(self.run.box_, &self.container_cells, self.run.pass.frame),
resolution_space,
self.layout_input.as_ref().unwrap().containing_block_constraints,
Some(automatic_block_size),
@@ -4418,7 +4416,7 @@ impl<'pass> FlexFormattingContext<'pass> {
};
match planned {
formatting_context::PlannedChildRun::Job(job) if job.reuses_stored_run() => {
- formatting_context::lay_out_child_run_job(run.callbacks, job)
+ formatting_context::lay_out_child_run_job(run.pass, job)
}
formatting_context::PlannedChildRun::Job(job) => {
for later in index + 1..self.flex_items.len() {
@@ -4524,11 +4522,11 @@ impl<'pass> FlexFormattingContext<'pass> {
fn margin_box_block_extent_of_placed_in_flow_items(&self) -> Option<CssPixels> {
let mut block_start = CssPixels::default();
let mut block_end = CssPixels::default();
- for child in self.run.callbacks.children(self.run.box_) {
+ for child in self.run.pass.children(self.run.box_) {
let facts = self.facts(child);
if facts.is_box()
&& !facts.is_absolutely_positioned()
- && !self.run.callbacks.can_skip_is_anonymous_text_run(child)
+ && !self.run.pass.can_skip_is_anonymous_text_run(child)
{
let index = self.index_of_flex_item(child)?;
let metrics = &self.flex_item_details[index].cells;
@@ -4582,7 +4580,7 @@ impl<'pass> FlexFormattingContext<'pass> {
})?;
let source = self.baseline_source_for_item(item);
formatting_context::baseline_of_laid_out_child_for_purpose(
- &self.run.callbacks,
+ &self.run.pass,
formatting_context::LaidOutChild {
node: self.flex_items[item].box_,
metrics: &self.flex_item_details[item].cells,
@@ -4599,7 +4597,7 @@ impl<'pass> FlexFormattingContext<'pass> {
// If the button's inner box has no in-flow boxes, avoid synthesizing a baseline from it: it is vertically
// centered, so that would place adjacent text too high. Use its content-box bottom edge instead.
if self.facts(self.run.box_).is_anonymous_button_content_wrapper() {
- let has_in_flow_boxes = self.run.callbacks.children(self.flex_items[item].box_).any(|child| {
+ let has_in_flow_boxes = self.run.pass.children(self.flex_items[item].box_).any(|child| {
let facts = self.facts(child);
facts.is_flow_layout_participant() && !facts.is_floating()
});
@@ -4619,11 +4617,11 @@ impl<'pass> FlexFormattingContext<'pass> {
pub(super) fn parent_did_dimension(&self, root_after_epilogue: used_values::RootInputCells) {
// NB: The static positions of the abspos children use the container as the run sized it.
self.container_cells.set(root_after_epilogue);
- for child in self.run.callbacks.children(self.run.box_) {
+ for child in self.run.pass.children(self.run.box_) {
let facts = self.facts(child);
if facts.is_box() && facts.is_absolutely_positioned() {
formatting_context::register_contained_abspos_child(
- &self.run.callbacks,
+ &self.run.pass,
self.run.fragments,
self.run.box_,
child,
@@ -4889,19 +4887,19 @@ mod stretch_cross_limit_tests {
arena.insert_child(container, child, Node::INVALID);
}
let host_findings_outside_runs = crate::layout::run_state::HostFindingsSink::default();
- let callbacks = LayoutPass::for_test(&arena, &scratch, &host_findings_outside_runs);
+ let pass = LayoutPass::for_test(&arena, &scratch, &host_findings_outside_runs);
let px = |value: i32| CssPixels::from_integer(i64::from(value));
let constraints = ContainingBlockConstraints {
percentage_basis_inline_size: (!column || definite_cross_basis).then_some(px(100)),
percentage_basis_block_size: (column || definite_cross_basis).then_some(px(100)),
..ContainingBlockConstraints::default()
};
- let container_cells = used_values::cells_before_sizing(&callbacks, container, constraints);
- RunState::with_root(callbacks, container, Node::INVALID, None, |state, callbacks| {
+ let container_cells = used_values::cells_before_sizing(&pass, container, constraints);
+ RunState::with_root(pass, container, Node::INVALID, None, |state, pass| {
let run = FormattingContextRun {
state,
box_: container,
- callbacks,
+ pass,
should_collect_devtools_layout_data: false,
treat_block_axis_percentage_insets_as_auto_beyond_root: false,
fragments: None,
diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
index 2b9f2fe40ef..8a0590c6b6f 100644
--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
@@ -111,7 +111,7 @@ pub(crate) struct RootLaidOutWithoutParentFragments {
}
pub(crate) fn run_root_without_parent_fragments(
- callbacks: LayoutPass<'_>,
+ pass: LayoutPass<'_>,
node: Node,
root_cells: used_values::RootInputCells,
input: LayoutInput,
@@ -121,8 +121,8 @@ pub(crate) fn run_root_without_parent_fragments(
ParticipationInParentFormattingContext::Item,
"an item run leaves its root's input cells to its parent, so they would come back unchanged"
);
- let fc_type = independent_formatting_context_type(node, &callbacks);
- let root_containing_block = callbacks.containing_block_for_child_run(node, &input.participation);
+ let fc_type = independent_formatting_context_type(node, &pass);
+ let root_containing_block = pass.containing_block_for_child_run(node, &input.participation);
let ChildLayout {
outcome: ChildLayoutOutcome::Created(result),
laid_out_box,
@@ -135,7 +135,7 @@ pub(crate) fn run_root_without_parent_fragments(
None,
fc_type,
false,
- callbacks,
+ pass,
input,
None,
)
@@ -161,9 +161,7 @@ pub(crate) fn run_fragmentainer(
) -> 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);
+ let root_containing_block = outer.pass.containing_block_for_child_run(box_, &input.participation);
execute_formatting_context_run(
builds_fragments,
outer_root_cells,
@@ -172,7 +170,7 @@ pub(crate) fn run_fragmentainer(
None,
FormattingContextType::Block,
outer.should_collect_devtools_layout_data,
- outer.callbacks,
+ outer.pass,
&input,
None,
None,
@@ -317,8 +315,8 @@ pub(crate) fn lay_out_pending_abspos_children(
for entry in batch {
let child_box = entry.child_box;
let containing_block = entry.containing_block();
- let containing_block_frame = frame_established_by(&run.callbacks, containing_block);
- let border_box_block_end = if containing_block_frame == run.callbacks.frame {
+ let containing_block_frame = frame_established_by(&run.pass, containing_block);
+ let border_box_block_end = if containing_block_frame == run.pass.frame {
engine.layout_pending_child(run, entry)
} else {
let framed_run = run.in_frame_of(containing_block_frame);
@@ -380,7 +378,7 @@ impl PlacedChild {
lines: Option<used_values::LineData>,
run: &FormattingContextRun,
) -> Self {
- let callbacks = &run.callbacks;
+ let pass = &run.pass;
Self::new(fragment_tree::FragmentGeometry {
cells,
// NB: Only a run that builds fragments shows the lines it laid out in the boxes it places.
@@ -391,9 +389,9 @@ impl PlacedChild {
lines.map(|lines| {
std::sync::Arc::new(inline_content::InlineContent::finish(
lines,
- callbacks.arena(),
+ pass.arena(),
cells.content_inline_size,
- callbacks.frame.writing_mode(),
+ pass.frame.writing_mode(),
))
})
})
@@ -439,10 +437,10 @@ pub(crate) fn place_child(
) -> Option<fragment_tree::PlacedFragment> {
let abspos_layout_inputs = placed_child.abspos_layout_inputs;
let containing_block = abspos_layout_inputs.as_ref().map_or_else(
- || run.callbacks.in_flow_containing_block(node),
+ || run.pass.in_flow_containing_block(node),
|inputs| inputs.containing_block,
);
- let callbacks = &run.callbacks;
+ let pass = &run.pass;
let placement = run_state::BoxPlacement {
content_offset_in_containing_block: offset,
containing_block,
@@ -455,7 +453,7 @@ pub(crate) fn place_child(
return None;
};
fragments.note_placed_box(
- &run.callbacks,
+ &run.pass,
node,
placement,
cells_kept_for_contained_abspos(run, node, || placed_child.geometry.cells),
@@ -481,18 +479,18 @@ pub(crate) fn place_child(
"a box is placed with fragments handed to it for another box, or after it was left unplaced"
);
match fragment_arrival {
- Some(root) => fragments.take_in_child_root_at_placement(node, root, callbacks),
+ Some(root) => fragments.take_in_child_root_at_placement(node, root, pass),
None => fragments.open_fragment_of_placed_box(node),
}
let mut abspos_boxes_placed_with_it = Vec::new();
loop {
- let batch = fragments.take_drainable_abspos(node, callbacks);
+ let batch = fragments.take_drainable_abspos(node, pass);
if batch.is_empty() {
break;
}
abspos_boxes_placed_with_it.extend(lay_out_pending_abspos_children(run, batch));
}
- let node_facts = NodeFacts::new(callbacks, node);
+ let node_facts = NodeFacts::new(pass, node);
let own_anchor_candidate_border_box_rect = (node_facts.is_box() && node_facts.has_anchor_names()).then(|| {
let metrics = &geometry.cells;
let collapsed = metrics.uses_collapsing_borders_model();
@@ -504,17 +502,17 @@ pub(crate) fn place_child(
}
});
let placed = fragments.build_fragment_for_placed_box(
- callbacks,
+ pass,
node,
(!containing_block.is_invalid()).then_some(containing_block),
geometry,
facts_decided_by_parent,
abspos_layout_inputs,
- resolve_containing_line_box_index(callbacks, node, containing_line_box_fragment),
+ resolve_containing_line_box_index(pass, node, containing_line_box_fragment),
point_add(
offset,
committed_offset_delta_at_placement(
- callbacks,
+ pass,
node,
facts_decided_by_parent.used_insets,
offset_from_relatively_positioned_inline_ancestors,
@@ -535,13 +533,13 @@ fn cells_kept_for_contained_abspos(
node: Node,
cells_in_run_frame: impl FnOnce() -> used_values::RootInputCells,
) -> Option<fragment_tree::CellsInFrame> {
- let data = run.callbacks.node_data(node);
+ let data = run.pass.node_data(node);
let may_contain_abspos = node_facts::has_flag(data, NodeFlag::EstablishesAbsolutePositionContainingBlock)
|| node_facts::has_flag(data, NodeFlag::EstablishesFixedPositionContainingBlock)
|| data.parent.get().is_invalid();
may_contain_abspos.then(|| fragment_tree::CellsInFrame {
cells: cells_in_run_frame(),
- frame: run.callbacks.frame,
+ frame: run.pass.frame,
})
}
@@ -549,24 +547,24 @@ fn cells_kept_for_contained_abspos(
/// atomic inlines are placed while walking the laid-out lines, and an interrupting block gets its line before it is
/// laid out.
fn resolve_containing_line_box_index(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
node: Node,
coordinate: Option<used_values::LineBoxFragmentCoordinate>,
) -> Option<u32> {
let coordinate = coordinate?;
- NodeFacts::new(callbacks, node)
+ NodeFacts::new(pass, node)
.is_non_fragmented_box()
.then(|| u32::try_from(coordinate.line_box_index).expect("a line box index fits in 32 bits"))
}
fn committed_offset_delta_at_placement(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
node: Node,
used_insets: run_state::UsedInsets,
offset_from_relatively_positioned_inline_ancestors: FfiCssPixelPoint,
) -> FfiCssPixelPoint {
let mut delta = FfiCssPixelPoint::default();
- let facts = NodeFacts::new(callbacks, node);
+ let facts = NodeFacts::new(pass, node);
if !facts.is_non_fragmented_box() {
return delta;
}
@@ -580,7 +578,7 @@ fn committed_offset_delta_at_placement(
}
pub(crate) fn register_contained_abspos_child(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
fragments: Option<&fragment_tree::RunFragmentBuilder>,
coordinate_space_box: Node,
child: Node,
@@ -597,48 +595,45 @@ pub(crate) fn register_contained_abspos_child(
containing_block_info_override,
containing_block_search: abspos_inputs::ContainingBlockSearch::starting_at(
child,
- NodeFacts::new(callbacks, child).is_fixed_position(),
+ NodeFacts::new(pass, child).is_fixed_position(),
),
};
- resolve_pending_abspos_containing_block(callbacks, &mut entry, fragments.root_node());
+ resolve_pending_abspos_containing_block(pass, &mut entry, fragments.root_node());
fragments.register_pending_abspos(coordinate_space_box, entry);
}
/// The containing block `node` is laid out in, within the run rooted at `run_root`.
-pub(crate) fn containing_block_laid_out_in(callbacks: &LayoutPass<'_>, node: Node, run_root: Node) -> Node {
- let facts = NodeFacts::new(callbacks, node);
+pub(crate) fn containing_block_laid_out_in(pass: &LayoutPass<'_>, node: Node, run_root: Node) -> Node {
+ let facts = NodeFacts::new(pass, node);
if !facts.is_absolutely_positioned() {
- return callbacks.in_flow_containing_block(node);
+ return pass.in_flow_containing_block(node);
}
let mut search = abspos_inputs::ContainingBlockSearch::starting_at(node, facts.is_fixed_position());
- callbacks
- .arena()
- .continue_containing_block_search(&mut search, run_root);
+ pass.arena().continue_containing_block_search(&mut search, run_root);
search.containing_block
}
pub(crate) fn resolve_pending_abspos_containing_block(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
entry: &mut abspos_inputs::PendingAbsposChild,
limit: Node,
) {
if !entry.containing_block().is_invalid() {
return;
}
- callbacks
- .arena()
+ pass.arena()
.continue_containing_block_search(&mut entry.containing_block_search, limit);
}
pub(crate) fn box_baseline_with_content_baselines(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
box_: Node,
metrics: &impl BoxMetricCells,
baseline_set: BaselineSet,
content_baselines: DerivedBaselines,
) -> CssPixels {
- let facts = NodeFacts::new(callbacks, box_);
- let style = StyleValues::for_node(callbacks, box_);
+ let facts = NodeFacts::new(pass, box_);
+ let style = StyleValues::for_node(pass, box_);
let collapsed = metrics.uses_collapsing_borders_model();
// https://drafts.csswg.org/css2/#propdef-vertical-align
@@ -650,9 +645,9 @@ pub(crate) fn box_baseline_with_content_baselines(
}
vertical_align::MIDDLE => {
// Middle: Align the vertical midpoint of the box with the baseline of the parent box plus half the x-height of the parent.
- let containing_block = callbacks.in_flow_containing_block(box_);
+ let containing_block = pass.in_flow_containing_block(box_);
assert!(!containing_block.is_invalid());
- let containing_style = StyleValues::for_node(callbacks, containing_block);
+ let containing_style = StyleValues::for_node(pass, containing_block);
return metrics.margin_box_block_size(collapsed) / 2
+ CssPixels::nearest_value_for_f32(containing_style.font_x_height() / 2.0);
}
@@ -670,9 +665,9 @@ pub(crate) fn box_baseline_with_content_baselines(
}
vertical_align::TEXT_BOTTOM => {
// TextBottom: Align the bottom of the box with the bottom of the parent's content area (see 10.6.1).
- let containing_block = callbacks.in_flow_containing_block(box_);
+ let containing_block = pass.in_flow_containing_block(box_);
assert!(!containing_block.is_invalid());
- let containing_style = StyleValues::for_node(callbacks, containing_block);
+ let containing_style = StyleValues::for_node(pass, containing_block);
return metrics.margin_box_block_size(collapsed)
- CssPixels::nearest_value_for_f32(containing_style.font_descent());
}
@@ -737,13 +732,13 @@ pub(crate) enum BaselinePurpose {
}
pub(crate) fn inline_box_baseline(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
box_: Node,
metrics: &impl BoxMetricCells,
content_baselines: DerivedBaselines,
) -> CssPixels {
box_baseline_for_purpose(
- callbacks,
+ pass,
box_,
metrics,
BaselineSet::Last,
@@ -753,7 +748,7 @@ pub(crate) fn inline_box_baseline(
}
fn box_baseline_for_purpose(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
box_: Node,
metrics: &impl BoxMetricCells,
mut baseline_set: BaselineSet,
@@ -761,7 +756,7 @@ fn box_baseline_for_purpose(
purpose: BaselinePurpose,
) -> CssPixels {
if purpose == BaselinePurpose::InlineAlignment {
- let facts = NodeFacts::new(callbacks, box_);
+ let facts = NodeFacts::new(pass, box_);
let display = facts.display();
// https://drafts.csswg.org/css-inline-3/#baseline-source
// auto: Specifies last-baseline alignment for inline-block, first-baseline alignment for everything else.
@@ -773,7 +768,7 @@ fn box_baseline_for_purpose(
// The baseline of an 'inline-table' is the baseline of the first row of the table.
let inline_table_baseline = display.is_inline_outside() && facts.is_table_wrapper();
use crate::css::css_enums::baseline_source;
- match StyleValues::for_node(callbacks, box_).baseline_source() {
+ match StyleValues::for_node(pass, box_).baseline_source() {
// https://drafts.csswg.org/css-inline-3/#baseline-source
// Specifies first-baseline alignment.
baseline_source::FIRST => baseline_set = BaselineSet::First,
@@ -783,7 +778,7 @@ fn box_baseline_for_purpose(
_ => content_baselines.last = content_baselines.inline_alignment.or(content_baselines.last),
}
}
- box_baseline_with_content_baselines(callbacks, box_, metrics, baseline_set, content_baselines)
+ box_baseline_with_content_baselines(pass, box_, metrics, baseline_set, content_baselines)
}
/// First and last baseline sets derived for one box, relative to its content
@@ -810,7 +805,7 @@ pub(crate) struct LineBaselines {
/// The baselines a line gives its block container where it holds `box_`, a block-level box with `cells` and
/// `content_baselines` whose content box sits `content_block_offset` into the container's content box.
pub(crate) fn baselines_of_block_level_box_on_line(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
box_: Node,
cells: &used_values::RootInputCells,
content_baselines: DerivedBaselines,
@@ -818,8 +813,7 @@ pub(crate) fn baselines_of_block_level_box_on_line(
) -> LineBaselines {
let offset_from_margin_edge = content_block_offset - cells.margin_box_top(cells.uses_collapsing_borders_model);
let baseline = |baseline_set, purpose| {
- offset_from_margin_edge
- + box_baseline_for_purpose(callbacks, box_, cells, baseline_set, content_baselines, purpose)
+ offset_from_margin_edge + box_baseline_for_purpose(pass, box_, cells, baseline_set, content_baselines, purpose)
};
LineBaselines {
first: baseline(BaselineSet::First, BaselinePurpose::Container),
@@ -870,9 +864,9 @@ impl DerivedBaselines {
}
/// Whether `container`, a block container with block-level children, derives its baselines from those of `child`.
-pub(crate) fn child_gives_container_baselines(callbacks: &LayoutPass<'_>, container: Node, child: Node) -> bool {
- let facts = NodeFacts::new(callbacks, container);
- let child_facts = NodeFacts::new(callbacks, child);
+pub(crate) fn child_gives_container_baselines(pass: &LayoutPass<'_>, container: Node, child: Node) -> bool {
+ let facts = NodeFacts::new(pass, container);
+ let child_facts = NodeFacts::new(pass, child);
// NB: Flex and grid containers derive their baselines from their items instead.
child_facts.is_flow_layout_participant()
&& !child_facts.is_floating()
@@ -886,11 +880,11 @@ pub(crate) fn child_gives_container_baselines(callbacks: &LayoutPass<'_>, contai
/// The baselines `child` gives its container, relative to the container's content box.
pub(crate) fn baselines_laid_out_child_gives_container(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
child: LaidOutChild<'_, impl BoxMetricCells>,
) -> DerivedBaselines {
let baseline = |baseline_set, purpose| {
- baseline_of_laid_out_child_for_purpose(callbacks, child, baseline_set, ChildBaselineSource::Own, purpose)
+ baseline_of_laid_out_child_for_purpose(pass, child, baseline_set, ChildBaselineSource::Own, purpose)
};
DerivedBaselines {
first: baseline(BaselineSet::First, BaselinePurpose::Container),
@@ -926,7 +920,7 @@ impl<Metrics: BoxMetricCells> Copy for LaidOutChild<'_, Metrics> {}
/// The baseline of `child`, relative to its container's margin edge. A synthesized baseline comes from the child's
/// border box.
pub(crate) fn baseline_of_laid_out_child_for_purpose(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
child: LaidOutChild<'_, impl BoxMetricCells>,
baseline_set: BaselineSet,
source: ChildBaselineSource,
@@ -956,7 +950,7 @@ pub(crate) fn baseline_of_laid_out_child_for_purpose(
let child_offset_from_margin_edge = content_offset.y - child_metrics.margin_box_top(collapsed);
Some(
child_offset_from_margin_edge
- + box_baseline_for_purpose(callbacks, node, child_metrics, baseline_set, content_baselines, purpose),
+ + box_baseline_for_purpose(pass, node, child_metrics, baseline_set, content_baselines, purpose),
)
}
@@ -1143,7 +1137,7 @@ impl ChildLayoutOutcome {
pub(crate) fn report_percentage_block_size_dependency_of(&self, run: &FormattingContextRun, child: Node) {
propagate_percentage_block_size_dependency_to_containing_block(
run.state,
- &run.callbacks,
+ &run.pass,
child,
self.child_depends_on_percentage_block_size(),
);
@@ -1303,7 +1297,7 @@ pub unsafe extern "C" fn document_host_set_layout_host_callbacks(
pub(crate) struct FormattingContextRun<'pass> {
pub(crate) state: &'pass RunState,
pub(crate) box_: Node,
- pub(crate) callbacks: LayoutPass<'pass>,
+ pub(crate) pass: LayoutPass<'pass>,
pub(crate) should_collect_devtools_layout_data: bool,
pub(crate) treat_block_axis_percentage_insets_as_auto_beyond_root: bool,
pub(crate) fragments: Option<&'pass fragment_tree::RunFragmentBuilder>,
@@ -1313,18 +1307,18 @@ pub(crate) struct FormattingContextRun<'pass> {
impl<'pass> FormattingContextRun<'pass> {
/// This run, laying out in `frame`.
pub(crate) fn in_frame_of(&self, frame: geometry::Frame) -> Self {
- self.with_callbacks(self.callbacks.in_frame_of(frame.writing_mode()))
+ self.with_pass(self.pass.in_frame_of(frame.writing_mode()))
}
- /// This run, laying out with the pass view `callbacks`.
- pub(crate) fn with_callbacks<'view>(&self, callbacks: LayoutPass<'view>) -> FormattingContextRun<'view>
+ /// This run, laying out with the pass view `pass`.
+ pub(crate) fn with_pass<'view>(&self, pass: LayoutPass<'view>) -> FormattingContextRun<'view>
where
'pass: 'view,
{
FormattingContextRun {
state: self.state,
box_: self.box_,
- callbacks,
+ pass,
should_collect_devtools_layout_data: self.should_collect_devtools_layout_data,
treat_block_axis_percentage_insets_as_auto_beyond_root: self
.treat_block_axis_percentage_insets_as_auto_beyond_root,
@@ -1335,7 +1329,7 @@ impl<'pass> FormattingContextRun<'pass> {
#[inline]
pub(crate) fn sizing(&self) -> sizing_context::SizingContext<'pass, 'static> {
- sizing_context::SizingContext::new(self.state, self.callbacks)
+ sizing_context::SizingContext::new(self.state, self.pass)
}
/// Whether the block-axis percentage insets of the boxes whose containing block is the run's root, laid out in
@@ -1345,7 +1339,7 @@ impl<'pass> FormattingContextRun<'pass> {
root: &impl BoxMetricCells,
) -> bool {
percentage_block_insets_have_definite_basis_in(
- &self.callbacks,
+ &self.pass,
self.box_,
|| root.has_definite_block_size(),
!self.treat_block_axis_percentage_insets_as_auto_beyond_root,
@@ -1521,12 +1515,12 @@ fn create_formatting_context_implementation<'pass>(
}
fn register_table_abspos_descendants(run: &FormattingContextRun, parent: Node) {
- for child in run.callbacks.children(parent) {
- let facts = NodeFacts::new(&run.callbacks, child);
+ for child in run.pass.children(parent) {
+ let facts = NodeFacts::new(&run.pass, child);
if facts.is_box() {
if facts.is_absolutely_positioned() {
register_contained_abspos_child(
- &run.callbacks,
+ &run.pass,
run.fragments,
run.box_,
child,
@@ -1560,11 +1554,11 @@ pub(crate) fn independent_root_automatic_block_size(
{
return automatic_content_block_size_reported_by_completed_run;
}
- let callbacks = sizing.callbacks();
- if NodeFacts::new(callbacks, node).creates_block_formatting_context() {
+ let pass = sizing.pass();
+ if NodeFacts::new(pass, node).creates_block_formatting_context() {
return CssPixels::default();
}
- let style = StyleValues::for_node(callbacks, node);
+ let style = StyleValues::for_node(pass, node);
// https://w3c.github.io/mathml-core/#layout-algorithms
// After calculating the line-ascent and line-descent of a math content box, its block size is set to their sum.
if style.display().is_math_inside() {
@@ -1616,7 +1610,7 @@ fn eagerly_resolve_atomic_flex_root_auto_block_size(
) {
let node = run.box_;
let sizing = run.sizing();
- if !StyleValues::for_node(&run.callbacks, node).display().is_flex_inside()
+ if !StyleValues::for_node(&run.pass, node).display().is_flex_inside()
|| sizing.box_is_sized_as_replaced_element(
sized_root.sized_box(),
input.available_space,
@@ -1737,7 +1731,7 @@ fn dimension_block_level_root(
let available_space = input.available_space;
let constraints = input.containing_block_constraints;
let sizing = run.sizing();
- let style = StyleValues::for_node(&run.callbacks, node);
+ let style = StyleValues::for_node(&run.pass, node);
let mut body_input = body_input_with_inner_available_space(sized_root.cells, input);
if let Some(block_size) = input.sizing.forced_content_block_size.get() {
let used = sized_root.cells;
@@ -1749,7 +1743,7 @@ fn dimension_block_level_root(
let mut measured_content_block_size = None;
if sizing.should_treat_block_size_as_auto(sized_root.sized_box(), available_space, constraints)
&& !crate::layout::sizing_context::is_plain_auto(style.min_height())
- && lays_out_content_against_min_block_size(NodeFacts::new(&run.callbacks, node), fc_type)
+ && lays_out_content_against_min_block_size(NodeFacts::new(&run.pass, node), fc_type)
{
let content_block_size = sizing.measure_automatic_content_block_size(
sized_root.sized_box(),
@@ -1784,7 +1778,7 @@ fn size_block_level_root_ahead_of_its_contents(
let root = sized_root.cells;
let constraints = input.containing_block_constraints;
let sizing = run.sizing();
- let facts = NodeFacts::new(&run.callbacks, node);
+ let facts = NodeFacts::new(&run.pass, node);
let flex_self_resolution_space =
flex_self_block_size_resolution_space(&sizing, sized_root.sized_box(), input.available_space, constraints);
let resolution_space = sizing.available_space_for_block_size_resolution(node, input.available_space, constraints);
@@ -1794,8 +1788,7 @@ fn size_block_level_root_ahead_of_its_contents(
&& sizing.box_is_sized_as_replaced_element(sized_root.sized_box(), resolution_space, constraints);
if facts.has_auto_content_box_size()
|| block_size_is_definite_from_aspect_ratio
- || (StyleValues::for_node(&run.callbacks, node).display().is_flex_inside()
- && flex_self_resolution_space.is_none())
+ || (StyleValues::for_node(&run.pass, node).display().is_flex_inside() && flex_self_resolution_space.is_none())
{
sizing.resolve_used_block_size_if_treated_as_auto(sized_root, resolution_space, constraints, None, || {
block_formatting_context::automatic_block_size_of_independent_root_ahead_of_its_contents(
@@ -1830,14 +1823,14 @@ fn resolve_float_root_block_size_ahead_of_its_contents(
let available_space = input.available_space;
let constraints = input.containing_block_constraints;
let sizing = run.sizing();
- let facts = NodeFacts::new(&run.callbacks, node);
+ let facts = NodeFacts::new(&run.pass, node);
sizing.resolve_used_block_size_if_not_treated_as_auto(sized_root, available_space, constraints);
let block_size_is_definite_from_aspect_ratio = root.has_definite_inline_size()
&& facts.has_preferred_aspect_ratio()
&& sizing.box_is_sized_as_replaced_element(sized_root.sized_box(), available_space, constraints);
if facts.has_auto_content_box_size()
|| block_size_is_definite_from_aspect_ratio
- || (StyleValues::for_node(&run.callbacks, node).display().is_flex_inside()
+ || (StyleValues::for_node(&run.pass, node).display().is_flex_inside()
&& !float_flex_container_resolves_its_own_automatic_block_size(input))
{
sizing.resolve_used_block_size_if_treated_as_auto(sized_root, available_space, constraints, None, || {
@@ -1864,12 +1857,12 @@ fn lays_out_content_against_min_block_size(facts: NodeFacts<'_>, fc_type: Format
/// The content block size of a laid out box, for growing a block size transferred through its aspect ratio. Chrome
/// derives it from the layout at the transferred size, so percentages inside resolve against that size.
pub(crate) fn content_block_size_for_aspect_ratio_minimum(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
node: Node,
result: &ChildLayoutResult,
) -> Option<CssPixels> {
let automatic_content_block_size = result.automatic_content_block_size;
- let facts = NodeFacts::new(callbacks, node);
+ let facts = NodeFacts::new(pass, node);
if facts.node_has_size_containment() {
// NB: The automatic content block size of a size containment box already ignores its content.
return Some(automatic_content_block_size);
@@ -1898,7 +1891,7 @@ fn finalize_block_level_root(
if let Some(inline_size) = body_result.table_wrapper_content_inline_size {
sized_root.cells.set_content_inline_size(inline_size);
}
- let style = StyleValues::for_node(&run.callbacks, node);
+ let style = StyleValues::for_node(&run.pass, node);
if !style.display().is_table_inside() && input.sizing.forced_content_block_size.is_none() {
let sizing = run.sizing();
let resolution_space = sizing.available_space_for_block_size_resolution(
@@ -1958,12 +1951,11 @@ fn size_skipped_independent_root(
}
ParticipationInParentFormattingContext::AbsolutelyPositioned(abspos_inputs) => {
let engine = abspos_engine::AbsposEngine::for_run(run);
- let anchor_resolved_values = (!abspos_inputs.resolved_anchor_sizes.is_empty()).then(|| {
- style_values::AnchorResolvedValues::new(&abspos_inputs.resolved_anchor_sizes, run.callbacks.frame)
- });
+ let anchor_resolved_values = (!abspos_inputs.resolved_anchor_sizes.is_empty())
+ .then(|| style_values::AnchorResolvedValues::new(&abspos_inputs.resolved_anchor_sizes, run.pass.frame));
let used_insets = Cell::new(run_state::UsedInsets::default());
let sized_child = abspos_engine::OutOfFlowBox::new(
- sizing_context::SizedCells::new(child, cells, run.callbacks.frame),
+ sizing_context::SizedCells::new(child, cells, run.pass.frame),
&used_insets,
anchor_resolved_values.as_ref(),
);
@@ -1997,7 +1989,7 @@ pub(super) fn run_formatting_context(
subgrid_parent: Option<&grid_formatting_context::SubgridParent>,
fc_type: FormattingContextType,
should_collect_devtools_layout_data: bool,
- callbacks: LayoutPass<'_>,
+ pass: LayoutPass<'_>,
input: LayoutInput,
table_inline_layout: Option<table_formatting_context::TableInlineLayout>,
) -> ChildLayout {
@@ -2006,7 +1998,7 @@ pub(super) fn run_formatting_context(
!parent_collects_fragments || builds_fragments,
"the run of {box_:?} builds no fragments for its parent to commit"
);
- if callbacks.reads_no_memoized_layout() {
+ if pass.reads_no_memoized_layout() {
let outputs = execute_formatting_context_run(
builds_fragments,
root_cells,
@@ -2015,14 +2007,14 @@ pub(super) fn run_formatting_context(
subgrid_parent,
fc_type,
should_collect_devtools_layout_data,
- callbacks,
+ pass,
&input,
None,
table_inline_layout,
None,
);
return child_layout_from_outputs(
- &callbacks,
+ &pass,
parent_collects_fragments,
box_,
&input,
@@ -2042,7 +2034,7 @@ pub(super) fn run_formatting_context(
builds_fragments,
should_collect_devtools_layout_data,
false,
- &callbacks,
+ &pass,
&key,
);
run_formatting_context_after_probe(
@@ -2051,7 +2043,7 @@ pub(super) fn run_formatting_context(
root_containing_block,
subgrid_parent,
should_collect_devtools_layout_data,
- callbacks,
+ pass,
&key,
table_inline_layout,
attempt,
@@ -2065,7 +2057,7 @@ fn run_formatting_context_after_probe(
root_containing_block: Node,
subgrid_parent: Option<&grid_formatting_context::SubgridParent>,
should_collect_devtools_layout_data: bool,
- callbacks: LayoutPass<'_>,
+ pass: LayoutPass<'_>,
key: &fc_run_cache::FcRunCacheKey,
table_inline_layout: Option<table_formatting_context::TableInlineLayout>,
attempt: Result<fc_run_cache::FcRunCacheAttempt, fc_run_cache::FcRunCacheHit>,
@@ -2079,17 +2071,17 @@ fn run_formatting_context_after_probe(
let cache_attempt = match attempt {
Ok(attempt) => attempt,
Err(hit) => {
- let _trace = callbacks.layout_trace().run(box_, fc_type, || {
+ let _trace = pass.layout_trace().run(box_, fc_type, || {
if !builds_fragments {
"READ RESULT"
- } else if hit.entry.holds_committed_fragments(callbacks.arena(), box_) {
+ } else if hit.entry.holds_committed_fragments(pass.arena(), box_) {
"REUSE SUBTREE"
} else {
"REPLAY FRAGMENTS"
}
});
return child_layout_from_outputs(
- &callbacks,
+ &pass,
parent_collects_fragments,
box_,
input,
@@ -2099,11 +2091,9 @@ fn run_formatting_context_after_probe(
);
}
};
- let _trace = callbacks
- .layout_trace()
- .run(box_, fc_type, || cache_attempt.trace_action());
+ let _trace = pass.layout_trace().run(box_, fc_type, || cache_attempt.trace_action());
let previous_line_data = cache_attempt.previous_line_data();
- let discarded_outputs = run_repeatability::lay_out_discarded_run(&callbacks, |callbacks| {
+ let discarded_outputs = run_repeatability::lay_out_discarded_run(&pass, |pass| {
execute_formatting_context_run(
builds_fragments,
root_cells,
@@ -2112,7 +2102,7 @@ fn run_formatting_context_after_probe(
subgrid_parent,
fc_type,
should_collect_devtools_layout_data,
- callbacks,
+ pass,
input,
None,
table_inline_layout.clone(),
@@ -2127,7 +2117,7 @@ fn run_formatting_context_after_probe(
subgrid_parent,
fc_type,
should_collect_devtools_layout_data,
- callbacks,
+ pass,
input,
previous_line_data,
table_inline_layout,
@@ -2138,12 +2128,12 @@ fn run_formatting_context_after_probe(
}
if cache_attempt.stores_outputs() {
run_repeatability::verify_run_ignores_its_unobserved_own_block_size_and_block_margins(
- &callbacks,
+ &pass,
box_,
root_cells,
input,
&outputs,
- |callbacks, other_root_cells, other_input| {
+ |pass, other_root_cells, other_input| {
execute_formatting_context_run(
builds_fragments,
other_root_cells,
@@ -2152,7 +2142,7 @@ fn run_formatting_context_after_probe(
subgrid_parent,
fc_type,
should_collect_devtools_layout_data,
- callbacks,
+ pass,
&other_input,
None,
None,
@@ -2161,9 +2151,9 @@ fn run_formatting_context_after_probe(
},
);
}
- let outputs = cache_attempt.conclude(&callbacks, box_, key, outputs);
+ let outputs = cache_attempt.conclude(&pass, box_, key, outputs);
child_layout_from_outputs(
- &callbacks,
+ &pass,
parent_collects_fragments,
box_,
input,
@@ -2202,14 +2192,14 @@ fn execute_formatting_context_run(
subgrid_parent: Option<&grid_formatting_context::SubgridParent>,
fc_type: FormattingContextType,
should_collect_devtools_layout_data: bool,
- callbacks: LayoutPass<'_>,
+ pass: LayoutPass<'_>,
input: &LayoutInput,
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 parent_owns_root_input_cells = parent_owns_root_input_cells(&callbacks, box_, input);
+ let parent_owns_root_input_cells = parent_owns_root_input_cells(&pass, box_, input);
let checks_root_input_cells_its_parent_owns =
parent_owns_root_input_cells && (cfg!(debug_assertions) || run_repeatability::verification_is_enabled());
// NB: The anchor-size() resolutions apply only in the parent's frame, where the root's own box is sized.
@@ -2219,28 +2209,28 @@ fn execute_formatting_context_run(
{
Some(Box::new(style_values::AnchorResolvedValues::new(
&inputs.resolved_anchor_sizes,
- callbacks.frame,
+ pass.frame,
)))
}
_ => None,
};
let fragments = builds_fragments.then(|| {
fragment_tree::RunFragmentBuilder::new(
- &callbacks,
+ &pass,
box_,
(!root_containing_block.is_invalid()).then_some(root_containing_block),
)
});
let (outputs, root_cells_left_by_run) = RunState::with_root_building_fragments(
- callbacks,
+ pass,
box_,
root_containing_block,
root_anchor_resolved_values,
fragments,
- |state, callbacks| {
+ |state, pass| {
lay_out_run_root_and_contents(
state,
- callbacks,
+ pass,
root_cells,
box_,
subgrid_parent,
@@ -2286,7 +2276,7 @@ fn sizes_and_box_sides(cells: used_values::RootInputCells) -> used_values::RootI
#[expect(clippy::too_many_arguments)]
fn lay_out_run_root_and_contents<'pass>(
state: &'pass RunState,
- callbacks: LayoutPass<'pass>,
+ pass: LayoutPass<'pass>,
root_cells: used_values::RootInputCells,
box_: Node,
subgrid_parent: Option<&grid_formatting_context::SubgridParent<'pass>>,
@@ -2302,7 +2292,7 @@ fn lay_out_run_root_and_contents<'pass>(
let run = FormattingContextRun {
state,
box_,
- callbacks,
+ pass,
should_collect_devtools_layout_data,
treat_block_axis_percentage_insets_as_auto_beyond_root: input
.sizing
@@ -2313,8 +2303,8 @@ fn lay_out_run_root_and_contents<'pass>(
let run = &run;
// NB: The root's own box is sized and placed in the frame of its parent's formatting context, while
// its contents are laid out in the frame of the writing mode the root establishes.
- let parent_frame = callbacks.frame;
- let own_frame = frame_established_by(&callbacks, box_);
+ let parent_frame = pass.frame;
+ let own_frame = frame_established_by(&pass, box_);
let changes_frame = own_frame != parent_frame;
let body_run_in_own_frame;
let body_run = if changes_frame {
@@ -2364,7 +2354,7 @@ fn lay_out_run_root_and_contents<'pass>(
let mut root_lines = used_values::LineDataState::Empty;
let mut laid_out_content_block_size = None;
let (mut result, own_root_after_body) = if empty_root_needs_no_formatting_context_algorithm(
- &callbacks,
+ &pass,
box_,
fc_type,
input,
@@ -2373,7 +2363,7 @@ fn lay_out_run_root_and_contents<'pass>(
// An empty root context has no body output. Root sizing and finalization still
// run through the shared paths around this branch.
(
- result_of_empty_root(&callbacks, box_, fc_type, own_root.get()),
+ result_of_empty_root(&pass, box_, fc_type, own_root.get()),
own_root.get(),
)
} else {
@@ -2407,7 +2397,7 @@ fn lay_out_run_root_and_contents<'pass>(
// https://w3c.github.io/mathml-core/#layout-of-operators
// NB: An operator lays out its text in a block formatting context, unless it is drawn with a
// stretched or large glyph.
- if NodeFacts::new(&body_run.callbacks, box_).display().is_math_inside() {
+ if NodeFacts::new(&body_run.pass, box_).display().is_math_inside() {
math_formatting_context::layout_operator(body_run, input, &mut result, &mut root_after_body);
}
root_lines = context.take_root_lines();
@@ -2479,7 +2469,7 @@ fn lay_out_run_root_and_contents<'pass>(
//
// Every formatting context reports its content sizes through ChildLayoutResult, so overriding here covers them all
// rather than one context's root-height path.
- let containment_facts = NodeFacts::new(&body_run.callbacks, run.box_);
+ let containment_facts = NodeFacts::new(&body_run.pass, run.box_);
let lays_out_own_content = run.fragmentainer.is_none();
if lays_out_own_content && containment_facts.node_has_size_containment() {
let style = containment_facts.style();
@@ -2501,7 +2491,7 @@ fn lay_out_run_root_and_contents<'pass>(
// NB: The lines are finished at the inline size the contents were laid out at, before the root's own box is
// sized in its parent's frame.
root_lines.finish(
- callbacks.arena(),
+ pass.arena(),
own_root_after_body.content_inline_size,
own_frame.writing_mode(),
);
@@ -2511,7 +2501,7 @@ fn lay_out_run_root_and_contents<'pass>(
if containment_facts.has_preferred_aspect_ratio() {
result.content_block_size_for_aspect_ratio_minimum =
- content_block_size_for_aspect_ratio_minimum(&run.callbacks, run.box_, &result);
+ content_block_size_for_aspect_ratio_minimum(&run.pass, run.box_, &result);
}
match &input.participation {
@@ -2580,7 +2570,7 @@ fn lay_out_run_root_and_contents<'pass>(
};
if content_alignment_offset.y != CssPixels::default() {
if let Some(fragments) = run.fragments {
- fragments.translate_root_contents(&callbacks, content_alignment_offset);
+ fragments.translate_root_contents(&pass, content_alignment_offset);
}
let shift = |baseline: Option<CssPixels>| baseline.map(|baseline| baseline + content_alignment_offset.y);
let shifted_baselines = DerivedBaselines {
@@ -2601,7 +2591,7 @@ fn lay_out_run_root_and_contents<'pass>(
}
let root_line_data = root_lines
.finish(
- callbacks.arena(),
+ pass.arena(),
root_in_own_frame_left_by_run.content_inline_size,
own_frame.writing_mode(),
)
@@ -2640,13 +2630,13 @@ fn lay_out_run_root_and_contents<'pass>(
let contents = run
.fragments
.as_ref()
- .map(|fragments| fragments.take_run_contents(&body_run.callbacks))?;
+ .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(
- &callbacks,
+ &pass,
fragment_tree::FragmentGeometry {
cells: root_cells_left_by_run,
line_data: root_line_data.clone(),
@@ -2720,7 +2710,7 @@ fn lay_out_run_root_and_contents<'pass>(
}
pub(super) fn empty_root_needs_no_formatting_context_algorithm(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
box_: Node,
fc_type: FormattingContextType,
input: &LayoutInput,
@@ -2728,13 +2718,13 @@ pub(super) fn empty_root_needs_no_formatting_context_algorithm(
) -> bool {
if input.participation == ParticipationInParentFormattingContext::Root
|| should_collect_devtools_layout_data
- || !callbacks.first_child(box_).is_invalid()
- || frame_established_by(callbacks, box_) != callbacks.frame
+ || !pass.first_child(box_).is_invalid()
+ || frame_established_by(pass, box_) != pass.frame
{
return false;
}
match fc_type {
- FormattingContextType::Block => !NodeFacts::new(callbacks, box_).display().is_math_inside(),
+ FormattingContextType::Block => !NodeFacts::new(pass, box_).display().is_math_inside(),
FormattingContextType::Flex => {
!float_flex_container_resolves_its_own_automatic_block_size(input)
&& !input.sizing.root_is_measured_for_its_content_block_size
@@ -2744,7 +2734,7 @@ pub(super) fn empty_root_needs_no_formatting_context_algorithm(
}
fn result_of_empty_root(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
box_: Node,
fc_type: FormattingContextType,
root_cells: used_values::RootInputCells,
@@ -2752,7 +2742,7 @@ fn result_of_empty_root(
match fc_type {
FormattingContextType::Flex => ChildLayoutResult {
automatic_content_block_size: root_cells.content_block_size,
- in_flow_children_margin_box_block_extent: NodeFacts::new(callbacks, box_)
+ in_flow_children_margin_box_block_extent: NodeFacts::new(pass, box_)
.has_preferred_aspect_ratio()
.then_some(CssPixels::default()),
..ChildLayoutResult::default()
@@ -2771,7 +2761,7 @@ fn lay_out_abspos_contained_by_run_root(
let Some(fragments) = body_run.fragments else {
return false;
};
- let mut batch = fragments.take_abspos_contained_by_root(&body_run.callbacks);
+ let mut batch = fragments.take_abspos_contained_by_root(&body_run.pass);
if batch.is_empty() {
return false;
}
@@ -2783,16 +2773,15 @@ fn lay_out_abspos_contained_by_run_root(
// whose containing block is the root.
while !batch.is_empty() {
lay_out_pending_abspos_children(body_run, batch);
- batch = fragments.take_abspos_contained_by_root(&body_run.callbacks);
+ batch = fragments.take_abspos_contained_by_root(&body_run.pass);
}
true
}
/// The frame in which `node` lays out its contents: that of its writing mode.
-pub(crate) fn frame_established_by(callbacks: &LayoutPass<'_>, node: Node) -> geometry::Frame {
- callbacks
- .computed_values_view_if_styled(node)
- .map_or(callbacks.frame, |style| geometry::Frame::of(style.writing_mode()))
+pub(crate) fn frame_established_by(pass: &LayoutPass<'_>, node: Node) -> geometry::Frame {
+ pass.computed_values_view_if_styled(node)
+ .map_or(pass.frame, |style| geometry::Frame::of(style.writing_mode()))
}
/// The input for laying out the contents of a run root whose writing mode establishes a frame other than its parent's,
@@ -2835,7 +2824,7 @@ fn body_input_in_own_frame(
// NB: A flex or grid container sizes its items in both axes before laying out their contents, even where it
// leaves a size indefinite for the percentages of their contents.
let inline_size = if input.participation == ParticipationInParentFormattingContext::Item
- && NodeFacts::new(&run.callbacks, node).parent_is_flex_or_grid_container()
+ && NodeFacts::new(&run.pass, node).parent_is_flex_or_grid_container()
{
used.content_inline_size()
} else {
@@ -2940,13 +2929,13 @@ fn finalize_atomic_root_block_size(
}
if sizing.should_treat_block_size_as_auto(sized_root.sized_box(), available_space, constraints) {
let parent_lays_out_root_as_math_content =
- formatting_context_type_created_by_box(NodeFacts::new(&run.callbacks, run.callbacks.parent(node)))
+ formatting_context_type_created_by_box(NodeFacts::new(&run.pass, run.pass.parent(node)))
== Some(FormattingContextType::Math);
let automatic_block_size = if parent_lays_out_root_as_math_content {
automatic_content_block_size_of_completed_body_run
} else {
block_formatting_context::floor_list_item_automatic_block_size_by_marker_line_height(
- run.callbacks,
+ run.pass,
node,
automatic_content_block_size_of_completed_body_run,
)
@@ -2965,7 +2954,7 @@ fn finalize_atomic_root_block_size(
pub(crate) fn propagate_percentage_block_size_dependency_to_containing_block(
state: &RunState,
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
child: Node,
child_depends_on_percentage_block_size: bool,
) {
@@ -2973,13 +2962,13 @@ pub(crate) fn propagate_percentage_block_size_dependency_to_containing_block(
if run_root_reports_its_dependency_through_its_run_result {
return;
}
- let facts = NodeFacts::new(callbacks, child);
+ let facts = NodeFacts::new(pass, child);
let resolves_against_containing_blocks_final_size = facts.is_absolutely_positioned();
if resolves_against_containing_blocks_final_size {
return;
}
let relative_block_insets_resolve_against_containing_block = facts.is_relatively_positioned() && {
- let style = StyleValues::for_node(callbacks, child);
+ let style = StyleValues::for_node(pass, child);
style.inset_top().contains_percentage() || style.inset_bottom().contains_percentage()
};
if !child_depends_on_percentage_block_size && !relative_block_insets_resolve_against_containing_block {
@@ -2987,11 +2976,11 @@ pub(crate) fn propagate_percentage_block_size_dependency_to_containing_block(
}
// NB: The nearest box at or above the containing block whose dependency this run resolves hears of it, which is
// the run root where the containing block lies above it.
- let mut box_resolving_the_dependency = callbacks.in_flow_containing_block(child);
+ let mut box_resolving_the_dependency = pass.in_flow_containing_block(child);
while !box_resolving_the_dependency.is_invalid()
&& !state.resolves_percentage_block_size_dependency_of(box_resolving_the_dependency)
{
- box_resolving_the_dependency = callbacks.parent(box_resolving_the_dependency);
+ box_resolving_the_dependency = pass.parent(box_resolving_the_dependency);
}
if box_resolving_the_dependency.is_invalid() {
box_resolving_the_dependency = state.root();
@@ -3036,7 +3025,7 @@ pub(crate) fn layout_inside_child_with_input_cells(
force_independent_context_run: bool,
percentage_block_insets_of_containing_block_have_definite_basis: bool,
) -> ChildLayout {
- let facts = NodeFacts::new(&run.callbacks, child);
+ let facts = NodeFacts::new(&run.pass, child);
let created_fc_type = formatting_context_type_created_by_box(facts);
let child_run_builds_fragments = run_builds_fragments(&input, run.fragments.is_some());
let skipped = |out_of_flow_root_used_insets| ChildLayoutOutcome::Skipped {
@@ -3055,7 +3044,7 @@ pub(crate) fn layout_inside_child_with_input_cells(
// parent run, which will also construct its fragment when placing the box.
let cells_of_this_layout = Cell::new(child_input_cells);
run.sizing().dimension_empty_atomic_root(
- sizing_context::SizedCells::new(child, &cells_of_this_layout, run.callbacks.frame),
+ sizing_context::SizedCells::new(child, &cells_of_this_layout, run.pass.frame),
input.available_space,
input.containing_block_constraints,
child_run_builds_fragments,
@@ -3095,7 +3084,7 @@ pub(crate) fn layout_inside_child_with_input_cells(
subgrid_parent.as_ref(),
fc_type,
run.should_collect_devtools_layout_data,
- run.callbacks,
+ run.pass,
input,
parent_block
.and_then(|block| block.take_table_inline_layout_of(child))
@@ -3118,7 +3107,7 @@ fn is_empty_atomic_block_sized_in_parent_run(
ParticipationInParentFormattingContext::AtomicInline
)
&& created_fc_type == Some(FormattingContextType::Block)
- && run.callbacks.first_child(child).is_invalid()
+ && run.pass.first_child(child).is_invalid()
}
fn is_childless_box_sized_in_parent_run(facts: NodeFacts<'_>, created_fc_type: Option<FormattingContextType>) -> bool {
@@ -3168,7 +3157,7 @@ pub(crate) fn plan_child_run(
child_input_cells: used_values::RootInputCells,
percentage_block_insets_of_containing_block_have_definite_basis: bool,
) -> PlannedChildRun {
- let facts = NodeFacts::new(&run.callbacks, child);
+ let facts = NodeFacts::new(&run.pass, child);
let created_fc_type = formatting_context_type_created_by_box(facts);
if is_empty_atomic_block_sized_in_parent_run(run, child, facts, created_fc_type, &input, false)
|| is_childless_box_sized_in_parent_run(facts, created_fc_type)
@@ -3199,7 +3188,7 @@ pub(crate) fn plan_child_run(
run_builds_fragments(&key.input, parent_collects_fragments),
run.should_collect_devtools_layout_data,
false,
- &run.callbacks,
+ &run.pass,
&key,
);
PlannedChildRun::Job(ChildRunJob {
@@ -3212,9 +3201,9 @@ pub(crate) fn plan_child_run(
})
}
-fn lay_out_child_run_job_noting_its_host_findings(callbacks: LayoutPass<'_>, job: ChildRunJob) -> LaidOutChildRun {
+fn lay_out_child_run_job_noting_its_host_findings(pass: LayoutPass<'_>, job: ChildRunJob) -> LaidOutChildRun {
let host_findings = run_state::HostFindingsSink::default();
- let layout = lay_out_child_run_job(callbacks.noting_host_findings_in(&host_findings), job);
+ let layout = lay_out_child_run_job(pass.noting_host_findings_in(&host_findings), job);
LaidOutChildRun {
layout,
host_findings: host_findings.take(),
@@ -3241,20 +3230,17 @@ impl ChildRunsLaidOutAhead {
for (index, child, cells, input) in later {
match plan_child_run(run, child, input, cells, percentage_block_insets_have_definite_basis) {
PlannedChildRun::Job(job) if job.reuses_stored_run() => {
- laid_out.keep(
- index,
- lay_out_child_run_job_noting_its_host_findings(run.callbacks, job),
- );
+ laid_out.keep(index, lay_out_child_run_job_noting_its_host_findings(run.pass, job));
}
PlannedChildRun::Job(job) => jobs.push((index, job)),
PlannedChildRun::Unplanned(..) => {}
}
}
match parallel_layout::lay_out_in_parallel(
- &run.callbacks,
+ &run.pass,
jobs,
|(_, job)| job.child(),
- |callbacks, (index, job)| (index, lay_out_child_run_job(callbacks, job)),
+ |pass, (index, job)| (index, lay_out_child_run_job(pass, job)),
) {
Ok(tasks) => {
for parallel_layout::ForkedTask {
@@ -3267,10 +3253,7 @@ impl ChildRunsLaidOutAhead {
}
Err(jobs) => {
for (index, job) in jobs {
- laid_out.keep(
- index,
- lay_out_child_run_job_noting_its_host_findings(run.callbacks, job),
- );
+ laid_out.keep(index, lay_out_child_run_job_noting_its_host_findings(run.pass, job));
}
}
}
@@ -3287,33 +3270,33 @@ impl ChildRunsLaidOutAhead {
pub(crate) fn take(&mut self, run: &FormattingContextRun, index: usize) -> Option<ChildLayout> {
let LaidOutChildRun { layout, host_findings } = self.0.get_mut(index)?.take()?;
if !host_findings.is_empty() {
- run.callbacks.note_host_findings(|into| into.receive(host_findings));
+ run.pass.note_host_findings(|into| into.receive(host_findings));
}
Some(layout)
}
}
-pub(crate) fn lay_out_child_run_job(callbacks: LayoutPass<'_>, job: ChildRunJob) -> ChildLayout {
+pub(crate) fn lay_out_child_run_job(pass: LayoutPass<'_>, job: ChildRunJob) -> ChildLayout {
run_formatting_context_after_probe(
job.parent_collects_fragments,
job.child,
job.root_containing_block,
None,
job.should_collect_devtools_layout_data,
- callbacks,
+ pass,
&job.key,
None,
job.attempt,
)
}
-pub(crate) fn shape_would_reuse_stored_run(callbacks: &LayoutPass<'_>, shape: &ChildRunShape) -> bool {
+pub(crate) fn shape_would_reuse_stored_run(pass: &LayoutPass<'_>, shape: &ChildRunShape) -> bool {
fc_run_cache::FcRunCacheAttempt::would_reuse_stored_run(
shape.node,
run_builds_fragments(&shape.key.input, false),
false,
true,
- callbacks,
+ pass,
&shape.key,
)
}
@@ -3351,7 +3334,7 @@ pub(crate) fn table_cell_run_shape_ahead_of_its_intrinsic_block_padding(
let plan = child_run_plan(
run,
cell,
- formatting_context_type_created_by_box(NodeFacts::new(&run.callbacks, cell)),
+ formatting_context_type_created_by_box(NodeFacts::new(&run.pass, cell)),
input,
false,
run.percentage_block_insets_of_root_children_have_definite_basis(table_box),
@@ -3408,7 +3391,7 @@ pub(crate) fn item_is_block_container_whose_committing_run_can_adopt_its_measure
impl ChildRunShape {
pub(crate) fn of_measurement_root(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
node: Node,
root_cells: used_values::RootInputCells,
input: LayoutInput,
@@ -3416,9 +3399,9 @@ impl ChildRunShape {
debug_assert_eq!(input.participation, ParticipationInParentFormattingContext::Root);
Self {
node,
- root_containing_block: callbacks.containing_block_for_child_run(node, &input.participation),
+ root_containing_block: pass.containing_block_for_child_run(node, &input.participation),
key: fc_run_cache::FcRunCacheKey {
- fc_type: independent_formatting_context_type(node, callbacks),
+ fc_type: independent_formatting_context_type(node, pass),
input,
root_cells,
},
@@ -3443,7 +3426,7 @@ pub(crate) fn child_run_plan(
force_independent_context_run: bool,
percentage_block_insets_of_containing_block_have_definite_basis: bool,
) -> ChildRunPlan {
- let child_facts = NodeFacts::new(&run.callbacks, child);
+ let child_facts = NodeFacts::new(&run.pass, child);
let fc_type = created_fc_type.unwrap_or_else(|| {
assert!(
force_independent_context_run,
@@ -3455,9 +3438,7 @@ pub(crate) fn child_run_plan(
);
FormattingContextType::Block
});
- let root_containing_block = run
- .callbacks
- .containing_block_for_child_run(child, &input.participation);
+ let root_containing_block = run.pass.containing_block_for_child_run(child, &input.participation);
// NB: Percentages see through an anonymous root to the block size of its containing block.
input.sizing.treat_block_axis_percentage_insets_as_auto_beyond_root = child_facts.is_anonymous()
&& !child_facts.is_table_cell()
@@ -3470,18 +3451,15 @@ pub(crate) fn child_run_plan(
}
pub(crate) fn lay_out_measurement_root_for_its_result(
- callbacks: LayoutPass<'_>,
+ pass: LayoutPass<'_>,
node: Node,
root_cells: used_values::RootInputCells,
input: LayoutInput,
) -> ChildLayoutResult {
- lay_out_shape_for_its_result(
- callbacks,
- ChildRunShape::of_measurement_root(&callbacks, node, root_cells, input),
- )
+ lay_out_shape_for_its_result(pass, ChildRunShape::of_measurement_root(&pass, node, root_cells, input))
}
-pub(crate) fn lay_out_shape_for_its_result(callbacks: LayoutPass<'_>, shape: ChildRunShape) -> ChildLayoutResult {
+pub(crate) fn lay_out_shape_for_its_result(pass: LayoutPass<'_>, shape: ChildRunShape) -> ChildLayoutResult {
let ChildRunShape {
node,
key,
@@ -3493,7 +3471,7 @@ pub(crate) fn lay_out_shape_for_its_result(callbacks: LayoutPass<'_>, shape: Chi
root_cells,
} = key;
let builds_fragments = run_builds_fragments(input, false);
- let lay_out = |callbacks: LayoutPass<'_>, root_cells, input: &LayoutInput, previous_line_data| {
+ let lay_out = |pass: LayoutPass<'_>, root_cells, input: &LayoutInput, previous_line_data| {
execute_formatting_context_run(
builds_fragments,
root_cells,
@@ -3502,7 +3480,7 @@ pub(crate) fn lay_out_shape_for_its_result(callbacks: LayoutPass<'_>, shape: Chi
None,
fc_type,
false,
- callbacks,
+ pass,
input,
previous_line_data,
None,
@@ -3513,16 +3491,16 @@ pub(crate) fn lay_out_shape_for_its_result(callbacks: LayoutPass<'_>, shape: Chi
let RunOutputParts {
result, host_findings, ..
} = outputs.into_parts(false);
- callbacks.receive_host_findings(host_findings);
+ pass.receive_host_findings(host_findings);
result
};
- if callbacks.reads_no_memoized_layout() {
- return result_with_host_findings(RunOutputsHandle::Owned(lay_out(callbacks, root_cells, input, None)));
+ if pass.reads_no_memoized_layout() {
+ return result_with_host_findings(RunOutputsHandle::Owned(lay_out(pass, root_cells, input, None)));
}
// NB: The only shapes of table cells are those laid out ahead of the intrinsic block padding their table hands them.
- let runs_ahead_of_intrinsic_block_padding = builds_fragments && NodeFacts::new(&callbacks, node).is_table_cell();
+ let runs_ahead_of_intrinsic_block_padding = builds_fragments && NodeFacts::new(&pass, node).is_table_cell();
let cache_attempt =
- match fc_run_cache::FcRunCacheAttempt::probe(node, false, builds_fragments, false, true, &callbacks, &key) {
+ match fc_run_cache::FcRunCacheAttempt::probe(node, false, builds_fragments, false, true, &pass, &key) {
Ok(attempt) => attempt,
Err(hit) => {
let action = if runs_ahead_of_intrinsic_block_padding {
@@ -3530,7 +3508,7 @@ pub(crate) fn lay_out_shape_for_its_result(callbacks: LayoutPass<'_>, shape: Chi
} else {
"READ RESULT"
};
- let _trace = callbacks.layout_trace().run(node, fc_type, || action);
+ let _trace = pass.layout_trace().run(node, fc_type, || action);
return result_with_host_findings(RunOutputsHandle::Stored(hit.entry));
}
};
@@ -3539,33 +3517,33 @@ pub(crate) fn lay_out_shape_for_its_result(callbacks: LayoutPass<'_>, shape: Chi
} else {
cache_attempt.trace_action()
};
- let _trace = callbacks.layout_trace().run(node, fc_type, || action);
+ let _trace = pass.layout_trace().run(node, fc_type, || action);
let previous_line_data = cache_attempt.previous_line_data();
let discarded_outputs =
- run_repeatability::lay_out_discarded_run(&callbacks, |callbacks| lay_out(callbacks, root_cells, input, None));
- let outputs = lay_out(callbacks, root_cells, input, previous_line_data);
+ run_repeatability::lay_out_discarded_run(&pass, |pass| lay_out(pass, root_cells, input, None));
+ let outputs = lay_out(pass, root_cells, input, previous_line_data);
if let Some(discarded_outputs) = &discarded_outputs {
run_repeatability::verify_repeated_run(node, discarded_outputs, &outputs);
}
if cache_attempt.stores_outputs() {
run_repeatability::verify_run_ignores_its_unobserved_own_block_size_and_block_margins(
- &callbacks,
+ &pass,
node,
root_cells,
input,
&outputs,
- |callbacks, other_root_cells, other_input| lay_out(callbacks, other_root_cells, &other_input, None),
+ |pass, other_root_cells, other_input| lay_out(pass, other_root_cells, &other_input, None),
);
}
- let outputs = cache_attempt.conclude(&callbacks, node, &key, outputs);
+ let outputs = cache_attempt.conclude(&pass, node, &key, outputs);
result_with_host_findings(outputs)
}
// NB: An item that establishes an orthogonal flow sizes itself along its container's block axis, so its run owns its
// root input cells.
-pub(super) fn parent_owns_root_input_cells(callbacks: &LayoutPass<'_>, box_: Node, input: &LayoutInput) -> bool {
+pub(super) fn parent_owns_root_input_cells(pass: &LayoutPass<'_>, box_: Node, input: &LayoutInput) -> bool {
input.participation == ParticipationInParentFormattingContext::Item
- && !frame_established_by(callbacks, box_).is_orthogonal_to(callbacks.frame)
+ && !frame_established_by(pass, box_).is_orthogonal_to(pass.frame)
}
fn own_block_size_observation_of_item_run(
@@ -3575,15 +3553,15 @@ fn own_block_size_observation_of_item_run(
result: &ChildLayoutResult,
) -> OwnBlockSizeObservation {
let item_is_plain_block_container_laid_out_without_its_own_block_size = fc_type == FormattingContextType::Block
- && !run.callbacks.frame.is_transposed()
- && parent_owns_root_input_cells(&run.callbacks, run.box_, input)
+ && !run.pass.frame.is_transposed()
+ && parent_owns_root_input_cells(&run.pass, run.box_, input)
&& !result.depends_on_percentage_block_size
&& !run
.state
.percentage_block_size_dependency_of(run.box_)
.has_descendant_that_depends_on_percentage_block_size
&& !block_formatting_context::root_lays_out_content_against_its_own_block_size(&run.sizing(), run.box_)
- && !root_content_includes_an_orthogonal_flow_sized_by_the_root_block_size(&run.callbacks, run.box_);
+ && !root_content_includes_an_orthogonal_flow_sized_by_the_root_block_size(&run.pass, run.box_);
if item_is_plain_block_container_laid_out_without_its_own_block_size {
OwnBlockSizeObservation::Unobserved
} else {
@@ -3591,18 +3569,15 @@ fn own_block_size_observation_of_item_run(
}
}
-fn root_content_includes_an_orthogonal_flow_sized_by_the_root_block_size(
- callbacks: &LayoutPass<'_>,
- root: Node,
-) -> bool {
+fn root_content_includes_an_orthogonal_flow_sized_by_the_root_block_size(pass: &LayoutPass<'_>, root: Node) -> bool {
let mut boxes_whose_children_the_root_contains: smallvec::SmallVec<[Node; 8]> = smallvec::smallvec![root];
while let Some(container) = boxes_whose_children_the_root_contains.pop() {
- for child in callbacks.children(container) {
- let facts = NodeFacts::new(callbacks, child);
+ for child in pass.children(container) {
+ let facts = NodeFacts::new(pass, child);
if facts.is_text_node() || facts.is_absolutely_positioned() {
continue;
}
- if frame_established_by(callbacks, child).is_orthogonal_to(callbacks.frame) {
+ if frame_established_by(pass, child).is_orthogonal_to(pass.frame) {
return true;
}
if facts.is_anonymous() || (facts.is_inline() && !facts.is_atomic_inline()) {
@@ -3620,18 +3595,17 @@ fn is_run_of_table_wrapper_sized_by_its_parent(
) -> bool {
fc_type == FormattingContextType::Block
&& input.participation == ParticipationInParentFormattingContext::BlockLevel
- && NodeFacts::new(&run.callbacks, run.box_).is_table_wrapper()
+ && NodeFacts::new(&run.pass, run.box_).is_table_wrapper()
}
fn table_in_wrapper_never_observes_percentage_inline_basis(run: &FormattingContextRun, wrapper: Node) -> bool {
- let mut children_of_wrapper = run.callbacks.children(wrapper);
+ let mut children_of_wrapper = run.pass.children(wrapper);
let (Some(table_box), None) = (children_of_wrapper.next(), children_of_wrapper.next()) else {
return false;
};
let resolves_percentage_against_inline_basis = |node| {
sizing_context::SizingContext::own_box_resolves_percentage_against_inline_basis(StyleValues::for_node(
- &run.callbacks,
- node,
+ &run.pass, node,
))
};
if resolves_percentage_against_inline_basis(table_box) {
@@ -3639,8 +3613,8 @@ fn table_in_wrapper_never_observes_percentage_inline_basis(run: &FormattingConte
}
let mut boxes_whose_children_are_internal_table_boxes = vec![table_box];
while let Some(parent) = boxes_whose_children_are_internal_table_boxes.pop() {
- for child in run.callbacks.children(parent) {
- let facts = NodeFacts::new(&run.callbacks, child);
+ for child in run.pass.children(parent) {
+ let facts = NodeFacts::new(&run.pass, child);
if facts.is_text_node() {
continue;
}
@@ -3662,7 +3636,7 @@ fn item_run_never_observes_percentage_inline_basis(
input: &LayoutInput,
) -> bool {
fc_type == FormattingContextType::Block
- && parent_owns_root_input_cells(&run.callbacks, run.box_, input)
+ && parent_owns_root_input_cells(&run.pass, run.box_, input)
&& !run.sizing().measurement_root_observes_percentage_inline_basis(run.box_)
}
@@ -3695,7 +3669,7 @@ pub(super) fn content_block_size_run_leaves_root_whose_cells_its_parent_owns(
}
fn child_layout_from_outputs(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
parent_collects_fragments: bool,
child: Node,
input: &LayoutInput,
@@ -3710,7 +3684,7 @@ fn child_layout_from_outputs(
inputs_never_observed,
host_findings,
} = outputs.into_parts(parent_collects_fragments);
- callbacks.receive_host_findings(host_findings);
+ pass.receive_host_findings(host_findings);
let content_block_size_adopted_after_run =
content_block_size_adopted_after_run(input, result.automatic_content_block_size);
let mut laid_out_box = root_outcome.laid_out_child_box(root_cells, &result, content_block_size_adopted_after_run);
@@ -3724,7 +3698,7 @@ fn child_layout_from_outputs(
);
// NB: A stored run's fragment can show the box as it was committed since through another fragment.
let fragment = outputs_are_stored_ones
- .then(|| fragment_tree::previously_committed_fragment_matching(callbacks, &root.fragment))
+ .then(|| fragment_tree::previously_committed_fragment_matching(pass, &root.fragment))
.flatten()
.unwrap_or(root.fragment);
fragment_tree::RunRootFragment {
@@ -3739,8 +3713,8 @@ fn child_layout_from_outputs(
}
}
-pub(super) fn independent_formatting_context_type(box_: Node, callbacks: &LayoutPass<'_>) -> FormattingContextType {
- let facts = NodeFacts::new(callbacks, box_);
+pub(super) fn independent_formatting_context_type(box_: Node, pass: &LayoutPass<'_>) -> FormattingContextType {
+ let facts = NodeFacts::new(pass, box_);
if let Some(fc_type) = formatting_context_type_created_by_box(facts) {
return fc_type;
}
@@ -3755,12 +3729,12 @@ pub(super) fn independent_formatting_context_type(box_: Node, callbacks: &Layout
/// definite block size: whether the box has a definite block size, or, where it is an anonymous box percentages see
/// through, whether `basis_beyond_it_is_definite`.
pub(crate) fn percentage_block_insets_have_definite_basis_in(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
containing_block: Node,
containing_block_has_definite_block_size: impl FnOnce() -> bool,
basis_beyond_it_is_definite: bool,
) -> bool {
- let facts = NodeFacts::new(callbacks, containing_block);
+ let facts = NodeFacts::new(pass, containing_block);
if !facts.is_anonymous() || facts.is_table_cell() {
return containing_block_has_definite_block_size();
}
@@ -3923,9 +3897,9 @@ fn compute_root_layout(input: LayoutStageInput<'_>, should_collect_devtools_layo
stage,
} = input;
let host_findings_outside_runs = super::run_state::HostFindingsSink::default();
- let mut callbacks = LayoutPass::new(arena, scratch, &host_findings_outside_runs, stage);
+ let mut pass = LayoutPass::new(arena, scratch, &host_findings_outside_runs, stage);
if !should_collect_devtools_layout_data {
- callbacks = callbacks.forking_runs();
+ pass = pass.forking_runs();
}
let viewport_inline_size = stage.viewport_inline_size;
let viewport_block_size = stage.viewport_block_size;
@@ -3936,14 +3910,12 @@ fn compute_root_layout(input: LayoutStageInput<'_>, should_collect_devtools_layo
..ContainingBlockConstraints::default()
};
RunState::with_root_building_fragments(
- callbacks,
+ pass,
root,
Node::INVALID,
None,
- Some(fragment_tree::RunFragmentBuilder::new_entry_accumulator(
- &callbacks, root,
- )),
- |entry_run_state, callbacks| {
+ Some(fragment_tree::RunFragmentBuilder::new_entry_accumulator(&pass, root)),
+ |entry_run_state, pass| {
let _trace = scratch.layout_trace.pass(None);
let entry_fragments = entry_run_state
.fragments()
@@ -3951,41 +3923,40 @@ fn compute_root_layout(input: LayoutStageInput<'_>, should_collect_devtools_layo
let entry_run = FormattingContextRun {
state: entry_run_state,
box_: root,
- callbacks,
+ pass,
should_collect_devtools_layout_data,
treat_block_axis_percentage_insets_as_auto_beyond_root: false,
fragments: Some(entry_fragments),
fragmentainer: None,
};
- let first_child = callbacks.first_child(root);
- let root_for_layout =
- if !first_child.is_invalid() && NodeFacts::new(&callbacks, first_child).is_svg_svg_box() {
- let mut viewport_cells = used_values::cells_before_sizing(&callbacks, root, root_constraints);
- viewport_cells.set_content_inline_size(viewport_inline_size);
- viewport_cells.set_content_block_size(viewport_block_size);
- place_child(
- &entry_run,
- root,
- PlacedChild::new(fragment_tree::FragmentGeometry {
- cells: viewport_cells,
- line_data: None,
- }),
- FfiCssPixelPoint::default(),
- None,
- None,
- );
- first_child
- } else {
- root
- };
- let mut root_cells = used_values::cells_before_sizing(&callbacks, root_for_layout, root_constraints);
+ let first_child = pass.first_child(root);
+ let root_for_layout = if !first_child.is_invalid() && NodeFacts::new(&pass, first_child).is_svg_svg_box() {
+ let mut viewport_cells = used_values::cells_before_sizing(&pass, root, root_constraints);
+ viewport_cells.set_content_inline_size(viewport_inline_size);
+ viewport_cells.set_content_block_size(viewport_block_size);
+ place_child(
+ &entry_run,
+ root,
+ PlacedChild::new(fragment_tree::FragmentGeometry {
+ cells: viewport_cells,
+ line_data: None,
+ }),
+ FfiCssPixelPoint::default(),
+ None,
+ None,
+ );
+ first_child
+ } else {
+ root
+ };
+ let mut root_cells = used_values::cells_before_sizing(&pass, root_for_layout, root_constraints);
root_cells.set_content_inline_size(viewport_inline_size);
root_cells.set_content_block_size(viewport_block_size);
root_cells.has_definite_block_size = true;
if root_for_layout != root {
svg_formatting_context::size_document_element_svg_from_its_width_and_height(
- &callbacks,
+ &pass,
root_for_layout,
&mut root_cells,
);
@@ -3998,16 +3969,16 @@ fn compute_root_layout(input: LayoutStageInput<'_>, should_collect_devtools_layo
ContainingBlockConstraints::default(),
ParticipationInParentFormattingContext::Root,
);
- let fc_type = independent_formatting_context_type(root_for_layout, &callbacks);
+ let fc_type = independent_formatting_context_type(root_for_layout, &pass);
let root_outcome = run_formatting_context(
true,
root_cells,
root_for_layout,
- callbacks.in_flow_containing_block(root_for_layout),
+ pass.in_flow_containing_block(root_for_layout),
None,
fc_type,
should_collect_devtools_layout_data,
- callbacks,
+ pass,
input,
None,
);
@@ -4022,7 +3993,7 @@ fn compute_root_layout(input: LayoutStageInput<'_>, should_collect_devtools_layo
finish_entry_pass(
entry_run_state,
entry_fragments,
- &callbacks,
+ &pass,
&host_findings_outside_runs,
should_collect_devtools_layout_data,
)
@@ -4046,17 +4017,17 @@ fn prepare_layout_stage(state: &mut super::ArenaHandle, kind: LayoutStageKind) {
fn finish_entry_pass(
entry_run_state: &RunState,
entry_fragments: &fragment_tree::RunFragmentBuilder,
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
host_findings_outside_runs: &super::run_state::HostFindingsSink,
should_collect_devtools_layout_data: bool,
) -> LayoutStageOutput {
abspos_engine::drain_abspos_with_placed_containing_blocks(
entry_run_state,
- *callbacks,
+ *pass,
should_collect_devtools_layout_data,
entry_fragments,
);
- let pass_fragments = entry_fragments.take_completed_pass(callbacks);
+ let pass_fragments = entry_fragments.take_completed_pass(pass);
debug_assert!(
!pass_fragments.roots.is_empty(),
"an entry pass always produces the entry root's fragment"
@@ -4081,32 +4052,32 @@ fn compute_subtree_layout_fragments(input: LayoutStageInput<'_>, containing_bloc
stage,
} = input;
let host_findings_outside_runs = super::run_state::HostFindingsSink::default();
- let callbacks = LayoutPass::new(arena, scratch, &host_findings_outside_runs, stage).forking_runs();
+ let pass = LayoutPass::new(arena, scratch, &host_findings_outside_runs, stage).forking_runs();
// NB: Either way, the boundary root's own geometry lies in the frame of its containing block.
- let callbacks = if containing_block.is_invalid() {
- callbacks
+ let pass = if containing_block.is_invalid() {
+ pass
} else {
- callbacks.in_frame_of(frame_established_by(&callbacks, containing_block).writing_mode())
+ pass.in_frame_of(frame_established_by(&pass, containing_block).writing_mode())
};
// Abspos boundaries recompute their size and position in their containing block's space.
// In-flow SVG boundaries keep their committed geometry and lay out only their contents.
- let root_is_absolutely_positioned = NodeFacts::new(&callbacks, root).is_absolutely_positioned();
+ let root_is_absolutely_positioned = NodeFacts::new(&pass, root).is_absolutely_positioned();
let (entry_root, entry_root_containing_block) = if root_is_absolutely_positioned {
(containing_block, NodeSlotId::INVALID)
} else {
(root, containing_block)
};
RunState::with_root_building_fragments(
- callbacks,
+ pass,
entry_root,
entry_root_containing_block,
None,
Some(fragment_tree::RunFragmentBuilder::new_entry_accumulator(
- &callbacks, entry_root,
+ &pass, entry_root,
)),
- |entry_run_state, callbacks| {
+ |entry_run_state, pass| {
let _trace = scratch.layout_trace.pass(Some(root));
let entry_fragments = entry_run_state
.fragments()
@@ -4114,7 +4085,7 @@ fn compute_subtree_layout_fragments(input: LayoutStageInput<'_>, containing_bloc
let entry_run = FormattingContextRun {
state: entry_run_state,
box_: entry_root,
- callbacks,
+ pass,
should_collect_devtools_layout_data: false,
treat_block_axis_percentage_insets_as_auto_beyond_root: false,
fragments: Some(entry_fragments),
@@ -4128,7 +4099,7 @@ fn compute_subtree_layout_fragments(input: LayoutStageInput<'_>, containing_bloc
finish_entry_pass(
entry_run_state,
entry_fragments,
- &callbacks,
+ &pass,
&host_findings_outside_runs,
false,
)
@@ -4138,8 +4109,8 @@ fn compute_subtree_layout_fragments(input: LayoutStageInput<'_>, containing_bloc
fn layout_subtree_with_frozen_root_geometry(run: &FormattingContextRun<'_>) {
let root = run.box_;
- let callbacks = &run.callbacks;
- let committed_root = used_values::committed_box_from_fragment_link(callbacks, root)
+ let pass = &run.pass;
+ let committed_root = used_values::committed_box_from_fragment_link(pass, root)
.expect("partial relayout root must have committed geometry");
let root_cells = committed_root.cells;
let fragments = run.fragments.expect("partial relayout must build fragments");
@@ -4154,7 +4125,7 @@ fn layout_subtree_with_frozen_root_geometry(run: &FormattingContextRun<'_>) {
ParticipationInParentFormattingContext::Root,
);
- let facts = NodeFacts::new(callbacks, root);
+ let facts = NodeFacts::new(pass, root);
debug_assert!(facts.is_svg_svg_box());
let fc_type = formatting_context_type_created_by_box(facts)
.expect("partial relayout root must establish an independent formatting context");
@@ -4162,11 +4133,11 @@ fn layout_subtree_with_frozen_root_geometry(run: &FormattingContextRun<'_>) {
true,
root_cells,
root,
- callbacks.in_flow_containing_block(root),
+ pass.in_flow_containing_block(root),
None,
fc_type,
run.should_collect_devtools_layout_data,
- *callbacks,
+ *pass,
input,
None,
);
@@ -4189,7 +4160,7 @@ fn layout_subtree_with_frozen_root_geometry(run: &FormattingContextRun<'_>) {
.placement
.expect("the root of a partial relayout keeps the placement it committed");
fragments.note_placed_box(
- &run.callbacks,
+ &run.pass,
root,
placement,
cells_kept_for_contained_abspos(run, root, || root_geometry.cells),
@@ -4199,9 +4170,9 @@ fn layout_subtree_with_frozen_root_geometry(run: &FormattingContextRun<'_>) {
let Some(run_root_fragment) = fragment_arrival else {
panic!("the root of a partial relayout is laid out by a run of its own");
};
- fragments.take_in_child_root_at_placement(root, run_root_fragment, callbacks);
+ fragments.take_in_child_root_at_placement(root, run_root_fragment, pass);
fragments.build_fragment_for_placed_box(
- callbacks,
+ pass,
root,
None,
root_geometry,
@@ -4259,7 +4230,7 @@ mod baseline_tests {
arena.set_node_style(child, 0, Some(child_style.style()));
arena.insert_child(parent, child, Node::INVALID);
let host_findings_outside_runs = super::run_state::HostFindingsSink::default();
- let callbacks = LayoutPass::new(
+ let pass = LayoutPass::new(
&arena,
&scratch,
&host_findings_outside_runs,
@@ -4269,12 +4240,12 @@ mod baseline_tests {
document_in_quirks_mode: false,
},
);
- RunState::with_root(callbacks, parent, Node::INVALID, None, |_, callbacks| {
+ RunState::with_root(pass, parent, Node::INVALID, None, |_, pass| {
let child_cells = used_values::RootInputCells::default();
- assert!(child_gives_container_baselines(&callbacks, parent, child));
+ assert!(child_gives_container_baselines(&pass, parent, child));
let mut baselines = DerivedBaselines::default();
baselines.fold_in_later_child(baselines_laid_out_child_gives_container(
- &callbacks,
+ &pass,
LaidOutChild {
node: child,
metrics: &child_cells,
diff --git a/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs b/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs
index d84507f8959..2502f0d54dc 100644
--- a/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs
+++ b/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs
@@ -429,15 +429,14 @@ fn propagate_payload_toward_run_root_space<Payload: PropagatedPayload>(
payload: &mut Payload,
run_root: crate::layout::node_data::NodeSlotId,
placed_boxes: &PlacementsOfBuilder<'_>,
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
) {
while payload.coordinate_space_box() != run_root {
let Some(placement) = placed_boxes.placement_of(payload.coordinate_space_box()) else {
break;
};
payload.translate_by(placement.content_offset_in_containing_block);
- let containing_block =
- placed_boxes.placement_containing_block(callbacks, payload.coordinate_space_box(), run_root);
+ let containing_block = placed_boxes.placement_containing_block(pass, payload.coordinate_space_box(), run_root);
if containing_block.is_invalid() {
break;
}
@@ -445,11 +444,11 @@ fn propagate_payload_toward_run_root_space<Payload: PropagatedPayload>(
}
}
-fn sort_in_tree_order(entries: &mut [abspos_inputs::PendingAbsposChild], callbacks: &LayoutPass<'_>) {
+fn sort_in_tree_order(entries: &mut [abspos_inputs::PendingAbsposChild], pass: &LayoutPass<'_>) {
entries.sort_by(|left, right| {
if left.child_box == right.child_box {
std::cmp::Ordering::Equal
- } else if callbacks.is_before(left.child_box, right.child_box) {
+ } else if pass.is_before(left.child_box, right.child_box) {
std::cmp::Ordering::Less
} else {
std::cmp::Ordering::Greater
@@ -575,13 +574,13 @@ impl PlacementsOfBuilder<'_> {
/// out in, within the run rooted at `run_root`.
pub(crate) fn placement_containing_block(
&self,
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
node: crate::layout::node_data::NodeSlotId,
run_root: crate::layout::node_data::NodeSlotId,
) -> crate::layout::node_data::NodeSlotId {
match self.placement_of(node) {
Some(placement) if !placement.containing_block.is_invalid() => placement.containing_block,
- _ => formatting_context::containing_block_laid_out_in(callbacks, node, run_root),
+ _ => formatting_context::containing_block_laid_out_in(pass, node, run_root),
}
}
@@ -590,13 +589,13 @@ impl PlacementsOfBuilder<'_> {
&self,
mut space: crate::layout::node_data::NodeSlotId,
run_root: crate::layout::node_data::NodeSlotId,
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
) -> bool {
while space != run_root {
if !self.is_placed(space) {
return false;
}
- space = self.placement_containing_block(callbacks, space, run_root);
+ space = self.placement_containing_block(pass, space, run_root);
}
true
}
@@ -605,32 +604,28 @@ impl PlacementsOfBuilder<'_> {
/// The fragment the box of `candidate` committed, where `candidate` builds identically to it. A fragment that continues
/// in another fragment of its box matches none.
pub(crate) fn previously_committed_fragment_matching(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
candidate: &Fragment,
) -> Option<std::sync::Arc<Fragment>> {
- previously_committed_fragment_where(callbacks, candidate, Fragment::builds_identically_to)
+ previously_committed_fragment_where(pass, candidate, Fragment::builds_identically_to)
}
-fn previously_committed_fragment_like(
- callbacks: &LayoutPass<'_>,
- candidate: &Fragment,
-) -> Option<std::sync::Arc<Fragment>> {
- previously_committed_fragment_where(callbacks, candidate, Fragment::builds_like_apart_from_overflow)
+fn previously_committed_fragment_like(pass: &LayoutPass<'_>, candidate: &Fragment) -> Option<std::sync::Arc<Fragment>> {
+ previously_committed_fragment_where(pass, candidate, Fragment::builds_like_apart_from_overflow)
}
fn previously_committed_fragment_where(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
candidate: &Fragment,
matches: impl FnOnce(&Fragment, &Fragment) -> bool,
) -> Option<std::sync::Arc<Fragment>> {
if candidate.continues_from_previous_fragment
|| candidate.continues_in_next_fragment
- || !callbacks.has_committed_fragment_link(candidate.node)
+ || !pass.has_committed_fragment_link(candidate.node)
{
return None;
}
- callbacks
- .arena()
+ pass.arena()
.with_committed_fragment_link(candidate.node, |previous_link| {
previous_link
.filter(|previous_link| matches(candidate, &previous_link.fragment))
@@ -701,7 +696,7 @@ impl FragmentGeometry {
}
fn snapshot_fragment(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
node: crate::layout::node_data::NodeSlotId,
children: Vec<FragmentLink>,
geometry: FragmentGeometry,
@@ -758,18 +753,18 @@ fn snapshot_fragment(
children,
};
fragment.scrollable_overflow = fragment_overflow::scrollable_overflow_of(
- callbacks.arena(),
+ pass.arena(),
&fragment,
- callbacks.frame,
+ pass.frame,
fragment_overflow::contained_links(&fragment),
);
- if let Some(previous) = previously_committed_fragment_like(callbacks, &fragment) {
+ if let Some(previous) = previously_committed_fragment_like(pass, &fragment) {
if previous.scrollable_overflow == fragment.scrollable_overflow {
return previous;
}
return std::sync::Arc::new(previous.with_scrollable_overflow(fragment.scrollable_overflow));
}
- fragment.identity = next_unique_identity(callbacks.worker_scratch());
+ fragment.identity = next_unique_identity(pass.worker_scratch());
std::sync::Arc::new(fragment)
}
@@ -777,7 +772,7 @@ fn snapshot_fragment(
/// box as placed and nothing else was placed in it, or else a fragment of the box's `geometry` around the arrived
/// fragment's children and the `children` placed in it here.
fn fragment_of_placed_box(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
node: crate::layout::node_data::NodeSlotId,
arrived: Option<std::sync::Arc<Fragment>>,
children: Vec<FragmentLink>,
@@ -786,7 +781,7 @@ fn fragment_of_placed_box(
payloads: Option<Box<FragmentPayloads>>,
) -> std::sync::Arc<Fragment> {
let Some(arrived) = arrived else {
- return snapshot_fragment(callbacks, node, children, geometry, fragment_facts, payloads);
+ return snapshot_fragment(pass, node, children, geometry, fragment_facts, payloads);
};
let shows_box_as_placed = children.is_empty()
&& geometry.shows_box_of_fragment(&arrived)
@@ -798,7 +793,7 @@ fn fragment_of_placed_box(
let mut all_children = arrived.children.clone();
all_children.extend(children);
snapshot_fragment(
- callbacks,
+ pass,
node,
all_children,
geometry,
@@ -960,11 +955,7 @@ pub(crate) struct RunContents {
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,
- callbacks: &LayoutPass<'_>,
- geometry: FragmentGeometry,
- ) -> RunRootFragment {
+ pub(crate) fn into_run_root_fragment(self, pass: &LayoutPass<'_>, geometry: FragmentGeometry) -> RunRootFragment {
let Self {
node,
mut scoped_descendants,
@@ -974,14 +965,14 @@ impl RunContents {
} = self;
if holds_links_beside_their_sealed_containing_blocks {
fragment_overflow::include_links_held_beside_their_containing_blocks(
- callbacks.arena(),
+ pass.arena(),
node,
&mut scoped_descendants,
);
}
RunRootFragment::new(
snapshot_fragment(
- callbacks,
+ pass,
node,
scoped_descendants,
geometry,
@@ -1130,12 +1121,12 @@ impl RunFragmentBuilderInner {
impl RunFragmentBuilder {
pub(crate) fn new(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
root_node: crate::layout::node_data::NodeSlotId,
root_containing_block: Option<crate::layout::node_data::NodeSlotId>,
) -> Self {
Self::with_spare_buffers(
- callbacks.worker_scratch(),
+ pass.worker_scratch(),
root_node,
root_containing_block.map(|node| node.slot_index()),
false,
@@ -1143,10 +1134,10 @@ impl RunFragmentBuilder {
}
pub(crate) fn new_entry_accumulator(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
root_node: crate::layout::node_data::NodeSlotId,
) -> Self {
- Self::with_spare_buffers(callbacks.worker_scratch(), root_node, None, true)
+ Self::with_spare_buffers(pass.worker_scratch(), root_node, None, true)
}
fn with_spare_buffers(
@@ -1173,9 +1164,9 @@ impl RunFragmentBuilder {
}
}
- fn with_placements<R>(&self, callbacks: &LayoutPass<'_>, read: impl FnOnce(&PlacementsOfBuilder<'_>) -> R) -> R {
+ fn with_placements<R>(&self, pass: &LayoutPass<'_>, read: impl FnOnce(&PlacementsOfBuilder<'_>) -> R) -> R {
read(&PlacementsOfBuilder {
- scratch: callbacks.fragment_builder_scratch(),
+ scratch: pass.fragment_builder_scratch(),
builder: self.builder,
})
}
@@ -1188,14 +1179,12 @@ impl RunFragmentBuilder {
/// `cells_for_contained_abspos` of a box that may be the containing block of absolutely positioned boxes.
pub(crate) fn note_placed_box(
&self,
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
node: crate::layout::node_data::NodeSlotId,
placement: run_state::BoxPlacement,
cells_for_contained_abspos: Option<CellsInFrame>,
) {
- let was_placed = callbacks
- .fragment_builder_scratch()
- .place(self.builder, node, placement);
+ let was_placed = pass.fragment_builder_scratch().place(self.builder, node, placement);
debug_assert!(!was_placed, "a box is placed once");
let placed_boxes = &mut self.inner.borrow_mut().placed_boxes;
placed_boxes.placed_slots.push(node.slot_index());
@@ -1225,21 +1214,21 @@ impl RunFragmentBuilder {
/// Where the run placed `node`, if it placed the box.
pub(crate) fn placement_of(
&self,
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
node: crate::layout::node_data::NodeSlotId,
) -> Option<run_state::BoxPlacement> {
- self.with_placements(callbacks, |placements| placements.placement_of(node))
+ self.with_placements(pass, |placements| placements.placement_of(node))
}
/// The containing block `node` is placed in, or for a box the run did not place yet, the containing block it is
/// laid out in.
pub(crate) fn placement_containing_block(
&self,
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
node: crate::layout::node_data::NodeSlotId,
) -> crate::layout::node_data::NodeSlotId {
- self.with_placements(callbacks, |placements| {
- placements.placement_containing_block(callbacks, node, self.root_node)
+ self.with_placements(pass, |placements| {
+ placements.placement_containing_block(pass, node, self.root_node)
})
}
@@ -1445,7 +1434,7 @@ impl RunFragmentBuilder {
pub(crate) fn take_drainable_abspos(
&self,
placed: crate::layout::node_data::NodeSlotId,
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
) -> Vec<abspos_inputs::PendingAbsposChild> {
let mut inner = self.inner.borrow_mut();
let RunFragmentBuilderInner {
@@ -1457,7 +1446,7 @@ impl RunFragmentBuilder {
if pending_abspos_at_root.is_empty() && !*holds_pending_abspos_below_root {
return Vec::new();
}
- let mut taken = self.with_placements(callbacks, |placements| {
+ let mut taken = self.with_placements(pass, |placements| {
let containing_block_is_owned_and_placed = |entry: &abspos_inputs::PendingAbsposChild| {
let containing_block = entry.containing_block();
!containing_block.is_invalid()
@@ -1476,7 +1465,7 @@ impl RunFragmentBuilder {
}
taken
});
- sort_in_tree_order(&mut taken, callbacks);
+ sort_in_tree_order(&mut taken, pass);
taken
}
@@ -1500,20 +1489,20 @@ impl RunFragmentBuilder {
/// places its cells in the space of its wrapper.
pub(crate) fn take_abspos_contained_by_root(
&self,
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
) -> Vec<abspos_inputs::PendingAbsposChild> {
let root = self.root_node;
let mut inner = self.inner.borrow_mut();
- let mut taken: Vec<abspos_inputs::PendingAbsposChild> = self.with_placements(callbacks, |placements| {
+ let mut taken: Vec<abspos_inputs::PendingAbsposChild> = self.with_placements(pass, |placements| {
inner
.pending_abspos_at_root
.extract_if(.., |entry| {
entry.containing_block() == root
- && placements.chain_of_space_reaches(entry.coordinate_space_box, root, callbacks)
+ && placements.chain_of_space_reaches(entry.coordinate_space_box, root, pass)
})
.collect()
});
- sort_in_tree_order(&mut taken, callbacks);
+ sort_in_tree_order(&mut taken, pass);
taken
}
@@ -1538,11 +1527,11 @@ impl RunFragmentBuilder {
/// root. A child it left unplaced or a box beside its sealed containing block belongs at the top of the fragments of
/// the run its root is in, and only placing a box in this builder lays out an absolutely positioned box whose
/// containing block this builder placed.
- pub(crate) fn hands_everything_to_the_placement_of_its_root(&self, callbacks: &LayoutPass<'_>) -> bool {
+ pub(crate) fn hands_everything_to_the_placement_of_its_root(&self, pass: &LayoutPass<'_>) -> bool {
let inner = self.inner.borrow();
inner.children_left_unplaced.is_empty()
&& !inner.holds_links_beside_their_sealed_containing_blocks
- && self.with_placements(callbacks, |placements| {
+ && self.with_placements(pass, |placements| {
!inner.iter_pending_abspos().any(|entry| {
let containing_block = entry.containing_block();
!containing_block.is_invalid() && placements.is_placed(containing_block)
@@ -1613,7 +1602,7 @@ impl RunFragmentBuilder {
inner.receive_abspos_containing_block_info(contents.payloads_past_run.abspos_containing_block_info);
}
- pub(crate) fn translate_root_contents(&self, callbacks: &LayoutPass<'_>, offset: FfiCssPixelPoint) {
+ pub(crate) fn translate_root_contents(&self, pass: &LayoutPass<'_>, offset: FfiCssPixelPoint) {
let root = self.root_node;
let mut inner = self.inner.borrow_mut();
for link in inner
@@ -1624,7 +1613,7 @@ impl RunFragmentBuilder {
link.committed_offset = formatting_context::point_add(link.committed_offset, offset);
}
{
- let scratch = callbacks.fragment_builder_scratch();
+ let scratch = pass.fragment_builder_scratch();
for &slot in &inner.placed_boxes.placed_slots {
scratch.placed_box_slots.with_row_mut(slot as usize, |placed| {
debug_assert!(
@@ -1666,9 +1655,9 @@ impl RunFragmentBuilder {
&self,
node: crate::layout::node_data::NodeSlotId,
root: RunRootFragment,
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
) {
- self.merge_child_root_into_pending_fragment(node, root, callbacks);
+ self.merge_child_root_into_pending_fragment(node, root, pass);
}
/// Opens the fragment of `node`, which is being placed without fragments handed to it, so that the fragments of
@@ -1730,7 +1719,7 @@ impl RunFragmentBuilder {
&self,
node: crate::layout::node_data::NodeSlotId,
root: RunRootFragment,
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
) {
let mut inner = self.inner.borrow_mut();
let slot = node.slot_index();
@@ -1760,7 +1749,7 @@ impl RunFragmentBuilder {
pending_fragment
.pending_abspos
.extend(pending_abspos.into_iter().map(|mut entry| {
- formatting_context::resolve_pending_abspos_containing_block(callbacks, &mut entry, self.root_node);
+ formatting_context::resolve_pending_abspos_containing_block(pass, &mut entry, self.root_node);
entry
}));
pending_fragment.anchor_candidates.extend(anchor_candidates);
@@ -1774,7 +1763,7 @@ impl RunFragmentBuilder {
#[allow(clippy::too_many_arguments)]
pub(crate) fn build_fragment_for_placed_box(
&self,
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
node: crate::layout::node_data::NodeSlotId,
containing_block: Option<crate::layout::node_data::NodeSlotId>,
geometry: FragmentGeometry,
@@ -1806,19 +1795,11 @@ impl RunFragmentBuilder {
abspos_layout_inputs,
containing_line_box_index,
committed_offset,
- callbacks.frame,
- );
- let fragment = fragment_of_placed_box(
- callbacks,
- node,
- arrived,
- children,
- geometry,
- facts.fragment_facts,
- payloads,
+ pass.frame,
);
+ let fragment = fragment_of_placed_box(pass, node, arrived, children, geometry, facts.fragment_facts, payloads);
let link = link_fragment(fragment.clone(), link_placement);
- self.attach(callbacks, &mut inner, link, containing_block);
+ self.attach(pass, &mut inner, link, containing_block);
let exports_payloads = !pending_abspos_from_placed_box.is_empty()
|| !anchor_candidates_from_placed_box.is_empty()
|| !inline_containing_block_rects_from_placed_box.is_empty()
@@ -1826,11 +1807,11 @@ impl RunFragmentBuilder {
let content_offset = placement.content_offset_in_containing_block;
let frames = exports_payloads
.then(|| {
- let own = formatting_context::frame_established_by(callbacks, node);
- (own != callbacks.frame).then(|| PlacedBoxFrames {
+ let own = formatting_context::frame_established_by(pass, node);
+ (own != pass.frame).then(|| PlacedBoxFrames {
own,
- containing_block: callbacks.frame,
- physical_content_size: callbacks.frame.size_to_physical(content_size.0, content_size.1),
+ containing_block: pass.frame,
+ physical_content_size: pass.frame.size_to_physical(content_size.0, content_size.1),
})
})
.flatten();
@@ -1898,7 +1879,7 @@ impl RunFragmentBuilder {
fn attach(
&self,
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
inner: &mut RunFragmentBuilderInner,
link: FragmentLink,
containing_block: Option<crate::layout::node_data::NodeSlotId>,
@@ -1917,8 +1898,7 @@ impl RunFragmentBuilder {
return;
}
// NB: A containing block the run placed already is sealed, so the box goes to the top of the run's fragments.
- if self.is_entry_accumulator
- || self.with_placements(callbacks, |placements| placements.is_placed(containing_block))
+ if self.is_entry_accumulator || self.with_placements(pass, |placements| placements.is_placed(containing_block))
{
inner.holds_links_beside_their_sealed_containing_blocks |= !self.is_entry_accumulator;
inner.top_scope_links.push(link);
@@ -1931,26 +1911,26 @@ impl RunFragmentBuilder {
.insert(containing_block.slot_index(), pending_fragment);
}
- pub(crate) fn take_run_contents(&self, callbacks: &LayoutPass<'_>) -> RunContents {
+ pub(crate) fn take_run_contents(&self, pass: &LayoutPass<'_>) -> RunContents {
debug_assert!(
!self.is_entry_accumulator,
"an entry accumulator closes as a pass, not a run"
);
- self.close(callbacks)
+ self.close(pass)
}
- pub(crate) fn take_completed_pass(&self, callbacks: &LayoutPass<'_>) -> CompletedPassFragments {
+ pub(crate) fn take_completed_pass(&self, pass: &LayoutPass<'_>) -> CompletedPassFragments {
debug_assert!(
self.is_entry_accumulator,
"an ordinary run closes into the contents of its root"
);
- let root = self.close(callbacks);
+ let root = self.close(pass);
CompletedPassFragments {
roots: root.scoped_descendants,
}
}
- fn close(&self, callbacks: &LayoutPass<'_>) -> RunContents {
+ fn close(&self, pass: &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),
@@ -1979,10 +1959,10 @@ impl RunFragmentBuilder {
// subtree goes with it.
for ChildLeftUnplaced { root, unplaced_child } in std::mem::take(&mut inner.children_left_unplaced) {
let node = root.fragment.node;
- let placement = PlacementData::of_unplaced_child(&unplaced_child, callbacks.frame);
+ let placement = PlacementData::of_unplaced_child(&unplaced_child, pass.frame);
inner.top_scope_links.push(link_fragment(
fragment_of_placed_box(
- callbacks,
+ pass,
node,
Some(root.fragment),
Vec::new(),
@@ -1993,7 +1973,7 @@ impl RunFragmentBuilder {
placement,
));
}
- self.with_placements(callbacks, |placements| {
+ self.with_placements(pass, |placements| {
for entry in &mut payloads_past_run.pending_abspos {
debug_assert!(
{
@@ -2005,20 +1985,20 @@ impl RunFragmentBuilder {
"a drainable abspos registration survived its containing block's run (slot {})",
entry.child_box.slot_index()
);
- propagate_payload_toward_run_root_space(entry, self.root_node, placements, callbacks);
+ propagate_payload_toward_run_root_space(entry, self.root_node, placements, pass);
}
for candidate in &mut payloads_past_run.anchor_candidates {
- propagate_payload_toward_run_root_space(candidate, self.root_node, placements, callbacks);
+ propagate_payload_toward_run_root_space(candidate, self.root_node, placements, pass);
}
for payload in &mut payloads_past_run.inline_containing_block_rects {
- propagate_payload_toward_run_root_space(payload, self.root_node, placements, callbacks);
+ propagate_payload_toward_run_root_space(payload, self.root_node, placements, pass);
}
});
let mut placed_boxes = std::mem::take(&mut inner.placed_boxes);
placed_boxes.placed_slots.clear();
placed_boxes.cells_of_abspos_containing_blocks.clear();
return_spare_fragment_builder_buffers(
- callbacks.worker_scratch(),
+ pass.worker_scratch(),
FragmentBuilderBuffers {
pending_fragments,
placed_boxes,
diff --git a/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs
index 1deff2b0a89..48c08a5ffc8 100644
--- a/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs
@@ -1443,8 +1443,8 @@ pub(crate) struct SubgridParent<'pass> {
/// Conservative superset of is_subgridded() for callers outside a live grid run
/// (the fc-run-cache probe): a declared subgrid axis counts regardless of the
/// parent-grid placement check only a run in progress can make.
-pub(super) fn grid_template_declares_a_subgrid_axis(callbacks: &LayoutPass<'_>, box_: Node) -> bool {
- let grid_style = callbacks.style_view(box_).grid_values();
+pub(super) fn grid_template_declares_a_subgrid_axis(pass: &LayoutPass<'_>, box_: Node) -> bool {
+ let grid_style = pass.style_view(box_).grid_values();
grid_style.template_columns.is_subgrid || grid_style.template_rows.is_subgrid
}
@@ -1455,7 +1455,7 @@ impl<'pass> GridFormattingContext<'pass> {
subgrid_parent: Option<&SubgridParent<'pass>>,
) -> Self {
let grid_container = run.box_;
- let container_style = StyleValues::for_node(&run.callbacks, grid_container);
+ let container_style = StyleValues::for_node(&run.pass, grid_container);
Self {
run: run.clone(),
container_cells: Cell::new(container_cells),
@@ -1489,15 +1489,15 @@ impl<'pass> GridFormattingContext<'pass> {
use_row_sizes_for_column_percentages: false,
transfer_stretched_block_sizes: false,
grid_axes_are_transposed: geometry::Frame::of(container_style.writing_mode())
- .is_orthogonal_to(run.callbacks.frame),
+ .is_orthogonal_to(run.pass.frame),
columns_are_reversed: !geometry::start_is_low_side_in_frame(
- run.callbacks.frame,
+ run.pass.frame,
container_style.writing_mode(),
container_style.direction(),
true,
),
rows_are_reversed: !geometry::start_is_low_side_in_frame(
- run.callbacks.frame,
+ run.pass.frame,
container_style.writing_mode(),
container_style.direction(),
false,
@@ -1550,7 +1550,7 @@ impl<'pass> GridFormattingContext<'pass> {
/// What `child`, an item of this grid laid out in a grid formatting context of its own, takes from this grid as
/// its parent grid, where it declares a subgrid axis.
pub(crate) fn subgrid_parent_of(&self, child: Node) -> Option<SubgridParent<'pass>> {
- grid_template_declares_a_subgrid_axis(&self.run.callbacks, child).then(|| SubgridParent {
+ grid_template_declares_a_subgrid_axis(&self.run.pass, child).then(|| SubgridParent {
grid: ParentGridData::for_child_container(self, child),
block_size_memo: self.subgrid_block_size_memo().clone(),
})
@@ -1623,19 +1623,19 @@ impl<'pass> GridFormattingContext<'pass> {
#[inline]
fn style(&self, node: Node) -> StyleValues<'pass> {
- StyleValues::for_node(&self.run.callbacks, node)
+ StyleValues::for_node(&self.run.pass, node)
}
#[inline]
fn facts(&self, node: Node) -> NodeFacts<'_> {
- NodeFacts::new(&self.run.callbacks, node)
+ NodeFacts::new(&self.run.pass, node)
}
/// The node's computed grid style group, read in place. The payload
/// outlives the pass because the node's ComputedValues keep it alive and
/// style containers are only replaced between passes.
fn grid_style(&self, node: Node) -> &'pass GridValues {
- self.run.callbacks.style_view(node).grid_values()
+ self.run.pass.style_view(node).grid_values()
}
/// Picks whichever of the per-grid-axis values (as in grid-template-columns and grid-template-rows) belongs to the
@@ -1664,7 +1664,7 @@ impl<'pass> GridFormattingContext<'pass> {
#[inline]
fn sizing(&self) -> sizing_context::SizingContext<'pass, '_> {
- sizing_context::SizingContext::new(self.run.state, self.run.callbacks).with_child_run_shapes(self)
+ sizing_context::SizingContext::new(self.run.state, self.run.pass).with_child_run_shapes(self)
}
fn parent_grid(&self) -> Option<&ParentGridData<'pass>> {
@@ -1918,11 +1918,7 @@ impl<'pass> GridFormattingContext<'pass> {
return None;
}
Some(self.sizing().calculate_inner_size_for_property(
- sizing_context::SizedBox::of_own_metrics(
- self.run.box_,
- &self.container_cells,
- self.run.callbacks.frame,
- ),
+ sizing_context::SizedBox::of_own_metrics(self.run.box_, &self.container_cells, self.run.pass.frame),
axis.sizing_axis(),
axis.select(SizingProperty::MinWidth, SizingProperty::MinHeight),
self.container_available_space(),
@@ -2137,11 +2133,11 @@ impl<'pass> GridFormattingContext<'pass> {
fn collect_grid_items(&mut self) -> Vec<PlacementInput> {
self.collected_items.clear();
let mut inputs = Vec::new();
- for child in self.run.callbacks.children(self.run.box_) {
+ for child in self.run.pass.children(self.run.box_) {
let box_facts = self.facts(child);
if box_facts.is_box()
&& !box_facts.is_absolutely_positioned()
- && !self.run.callbacks.can_skip_is_anonymous_text_run(child)
+ && !self.run.pass.can_skip_is_anonymous_text_run(child)
{
debug_assert!(
node_facts::has_flag(box_facts.data(), NodeFlag::IsGridItem),
@@ -2197,7 +2193,7 @@ impl<'pass> GridFormattingContext<'pass> {
),
});
let cells =
- used_values::cells_before_sizing(&self.run.callbacks, child, ContainingBlockConstraints::default());
+ used_values::cells_before_sizing(&self.run.pass, child, ContainingBlockConstraints::default());
self.collected_items.push(CollectedGridItem {
box_: child,
inputs: item_inputs,
@@ -3269,7 +3265,7 @@ impl<'pass> GridFormattingContext<'pass> {
let available = self.container_available_space();
let constraints = self.layout_input.as_ref().unwrap().containing_block_constraints;
self.sizing().calculate_inner_size_for_property(
- sizing_context::SizedBox::of_own_metrics(self.run.box_, &self.container_cells, self.run.callbacks.frame),
+ sizing_context::SizedBox::of_own_metrics(self.run.box_, &self.container_cells, self.run.pass.frame),
axis.sizing_axis(),
axis.select(SizingProperty::MaxWidth, SizingProperty::MaxHeight),
available,
@@ -3544,28 +3540,22 @@ impl<'pass> GridFormattingContext<'pass> {
is_collapsed_borders_table_box: false,
..live
};
- let containing_block = self.run.callbacks.in_flow_containing_block(subgrid.box_);
- RunState::with_root(
- self.run.callbacks,
- subgrid.box_,
- containing_block,
- None,
- |state, callbacks| {
- let scratch_run = FormattingContextRun {
- state,
- box_: subgrid.box_,
- callbacks,
- should_collect_devtools_layout_data: false,
- treat_block_axis_percentage_insets_as_auto_beyond_root: false,
- fragments: None,
- fragmentainer: None,
- };
- let subgrid_parent = self.subgrid_parent_of(subgrid.box_);
- let mut context = GridFormattingContext::new(&scratch_run, scratch_root, subgrid_parent.as_ref());
- context.subgrid_tracks_act_empty = true;
- measure(&mut context, &scratch_run)
- },
- )
+ let containing_block = self.run.pass.in_flow_containing_block(subgrid.box_);
+ RunState::with_root(self.run.pass, subgrid.box_, containing_block, None, |state, pass| {
+ let scratch_run = FormattingContextRun {
+ state,
+ box_: subgrid.box_,
+ pass,
+ should_collect_devtools_layout_data: false,
+ treat_block_axis_percentage_insets_as_auto_beyond_root: false,
+ fragments: None,
+ fragmentainer: None,
+ };
+ let subgrid_parent = self.subgrid_parent_of(subgrid.box_);
+ let mut context = GridFormattingContext::new(&scratch_run, scratch_root, subgrid_parent.as_ref());
+ context.subgrid_tracks_act_empty = true;
+ measure(&mut context, &scratch_run)
+ })
}
/// The content block size of an item that's a subgrid in the column axis only. Its rows are its own,
@@ -3731,9 +3721,7 @@ impl<'pass> GridFormattingContext<'pass> {
fn fork_candidates(&self) -> Vec<usize> {
self.items_to_fork
.get_or_init(|| {
- parallel_layout::fork_candidates(&self.run.callbacks, 0..self.items.len(), |index| {
- self.items[index].box_
- })
+ parallel_layout::fork_candidates(&self.run.pass, 0..self.items.len(), |index| self.items[index].box_)
})
.clone()
}
@@ -3777,7 +3765,7 @@ impl<'pass> GridFormattingContext<'pass> {
)
})
.collect();
- parallel_layout::lay_out_shapes_ahead(&self.run.callbacks, shapes);
+ parallel_layout::lay_out_shapes_ahead(&self.run.pass, shapes);
}
}
@@ -3867,7 +3855,7 @@ impl<'pass> GridFormattingContext<'pass> {
Alignment::SelfStart | Alignment::SelfEnd => {
let horizontal = axis.is_column();
let item_start_is_left_or_top = geometry::start_is_low_side_in_frame(
- self.run.callbacks.frame,
+ self.run.pass.frame,
item_style.writing_mode(),
item_style.direction(),
horizontal,
@@ -3953,7 +3941,7 @@ impl<'pass> GridFormattingContext<'pass> {
fn resolve_left_or_right(&self, axis: Axis, alignment: Alignment) -> Alignment {
// NB: The Column axis is the inline axis of the frame, whose line-left side is its left side. Along the Row
// axis, left and right are physical sides, which a transposed frame may run either way.
- let frame = self.run.callbacks.frame;
+ let frame = self.run.pass.frame;
let line_left_is_left_or_top = axis.is_column()
|| !frame.is_transposed()
|| matches!(
@@ -4634,11 +4622,7 @@ impl<'pass> GridFormattingContext<'pass> {
&& !sizing.should_treat_max_block_size_as_none(self.run.box_, available.block_size, constraints)
{
block_size = block_size.min(sizing.calculate_inner_size_for_property(
- sizing_context::SizedBox::of_own_metrics(
- self.run.box_,
- &self.container_cells,
- self.run.callbacks.frame,
- ),
+ sizing_context::SizedBox::of_own_metrics(self.run.box_, &self.container_cells, self.run.pass.frame),
SizingAxis::Block,
SizingProperty::MaxHeight,
available,
@@ -4649,11 +4633,7 @@ impl<'pass> GridFormattingContext<'pass> {
&& !(self.own_block_size_is_being_measured() && style.min_height().is_intrinsic_sizing_constraint())
{
block_size = block_size.max(sizing.calculate_inner_size_for_property(
- sizing_context::SizedBox::of_own_metrics(
- self.run.box_,
- &self.container_cells,
- self.run.callbacks.frame,
- ),
+ sizing_context::SizedBox::of_own_metrics(self.run.box_, &self.container_cells, self.run.pass.frame),
SizingAxis::Block,
SizingProperty::MinHeight,
available,
@@ -4898,7 +4878,7 @@ impl<'pass> GridFormattingContext<'pass> {
let plan = formatting_context::child_run_plan(
&self.run,
item.box_,
- formatting_context::formatting_context_type_created_by_box(NodeFacts::new(&self.run.callbacks, item.box_)),
+ formatting_context::formatting_context_type_created_by_box(NodeFacts::new(&self.run.pass, item.box_)),
input,
false,
self.run
@@ -4948,7 +4928,7 @@ impl<'pass> GridFormattingContext<'pass> {
};
match planned {
formatting_context::PlannedChildRun::Job(job) if job.reuses_stored_run() => {
- formatting_context::lay_out_child_run_job(run.callbacks, job)
+ formatting_context::lay_out_child_run_job(run.pass, job)
}
formatting_context::PlannedChildRun::Job(job) => {
handed_over_to_runs_laid_out_ahead = true;
@@ -5085,7 +5065,7 @@ impl<'pass> GridFormattingContext<'pass> {
}
fn item_may_be_laid_out_ahead(&self, run: &FormattingContextRun<'pass>, item: GridItem) -> bool {
- !self.item_facts(item).is_table_wrapper() && !grid_template_declares_a_subgrid_axis(&run.callbacks, item.box_)
+ !self.item_facts(item).is_table_wrapper() && !grid_template_declares_a_subgrid_axis(&run.pass, item.box_)
}
// NB: Only the vertical Row axis aligns items by their baselines, using the horizontal baselines of items in a
@@ -5131,7 +5111,7 @@ impl<'pass> GridFormattingContext<'pass> {
// by their baselines too: items in an orthogonal flow by their own, which lie across that axis, and other
// items by synthesized ones.
fn item_participates_in_column_baseline_alignment(&self, item: GridItem) -> bool {
- if !self.run.callbacks.frame.is_transposed()
+ if !self.run.pass.frame.is_transposed()
|| self.columns_are_reversed
|| self.item_alignment(item, Axis::Column) != Alignment::Baseline
{
@@ -5177,7 +5157,7 @@ impl<'pass> GridFormattingContext<'pass> {
let distance_from_margin_box_top =
if !self.item_establishes_orthogonal_flow(item) && content_baselines.first.is_some() {
formatting_context::box_baseline_with_content_baselines(
- &self.run.callbacks,
+ &self.run.pass,
item.box_,
&metrics,
formatting_context::BaselineSet::First,
@@ -5288,7 +5268,7 @@ impl<'pass> GridFormattingContext<'pass> {
) -> Option<CssPixels> {
let laid_out_item = self.laid_out_item(item);
formatting_context::baseline_of_laid_out_child_for_purpose(
- &self.run.callbacks,
+ &self.run.pass,
formatting_context::LaidOutChild {
node: item.box_,
metrics: &self.cells_of(item),
@@ -5644,11 +5624,7 @@ impl<'pass> GridFormattingContext<'pass> {
self.automatic_content_block_size = intrinsic_block_size;
} else if let AvailableSize::Definite(block_size) = available.block_size
&& self.sizing().should_treat_block_size_as_auto(
- sizing_context::SizedBox::of_own_metrics(
- self.run.box_,
- &self.container_cells,
- self.run.callbacks.frame,
- ),
+ sizing_context::SizedBox::of_own_metrics(self.run.box_, &self.container_cells, self.run.pass.frame),
available,
self.layout_input.as_ref().unwrap().containing_block_constraints,
)
@@ -5713,7 +5689,7 @@ impl<'pass> GridFormattingContext<'pass> {
} else {
(Axis::Column, Axis::Row)
};
- for child in self.run.callbacks.children(self.run.box_) {
+ for child in self.run.pass.children(self.run.box_) {
if self.facts(child).is_absolutely_positioned() {
let rect = abspos_inputs::StaticPositionRect {
rect: geometry::LogicalRect {
@@ -5730,12 +5706,12 @@ impl<'pass> GridFormattingContext<'pass> {
// The grid area supplies both the containing block and the
// static position for the grid's own abspos children.
let containing_block_info = node_facts::has_flag(
- self.run.callbacks.node_data(self.run.box_),
+ self.run.pass.node_data(self.run.box_),
node_facts::containing_block_establishment_flag(self.facts(child).is_fixed_position()),
)
.then(|| self.abspos_containing_block_info(child));
formatting_context::register_contained_abspos_child(
- &self.run.callbacks,
+ &self.run.pass,
self.run.fragments,
self.run.box_,
child,
diff --git a/Libraries/LibWeb/Rust/src/layout/in_flow_block_cache.rs b/Libraries/LibWeb/Rust/src/layout/in_flow_block_cache.rs
index b4f879cc3a7..e679ee7df98 100644
--- a/Libraries/LibWeb/Rust/src/layout/in_flow_block_cache.rs
+++ b/Libraries/LibWeb/Rust/src/layout/in_flow_block_cache.rs
@@ -54,10 +54,10 @@ impl InFlowBlockKey {
treat_block_axis_percentage_insets_as_auto_beyond_root: run
.treat_block_axis_percentage_insets_as_auto_beyond_root,
initial_containing_block_size: (
- run.callbacks.initial_containing_block_inline_size,
- run.callbacks.initial_containing_block_block_size,
+ run.pass.initial_containing_block_inline_size,
+ run.pass.initial_containing_block_block_size,
),
- document_in_quirks_mode: run.callbacks.document_in_quirks_mode,
+ document_in_quirks_mode: run.pass.document_in_quirks_mode,
}
}
}
diff --git a/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs
index bd69dceca0b..89dc3c95f36 100644
--- a/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs
@@ -905,7 +905,7 @@ pub(crate) struct InlineAncestorChainRelativeOffset {
/// the first ancestor that is not inline-flow. `used_insets_of` gives the
/// used insets of a relatively positioned ancestor in the chain.
pub(crate) fn accumulated_relative_insets_from_inline_ancestor_chain(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
first_ancestor: Node,
stop_at: Node,
used_insets_of: impl Fn(Node) -> run_state::UsedInsets,
@@ -913,7 +913,7 @@ pub(crate) fn accumulated_relative_insets_from_inline_ancestor_chain(
let mut result = InlineAncestorChainRelativeOffset::default();
let mut ancestor = first_ancestor;
while !ancestor.is_invalid() && ancestor != stop_at {
- let facts = NodeFacts::new(callbacks, ancestor);
+ let facts = NodeFacts::new(pass, ancestor);
if !facts.has_box_model_metrics() {
break;
}
@@ -930,7 +930,7 @@ pub(crate) fn accumulated_relative_insets_from_inline_ancestor_chain(
result.offset_x += insets.left;
result.offset_y += insets.top;
}
- ancestor = callbacks.parent(ancestor);
+ ancestor = pass.parent(ancestor);
}
result
}
@@ -982,7 +982,7 @@ pub(crate) struct InlineFormattingContext<'context> {
block_container: block_formatting_context::BlockContainer,
pub(crate) input: LayoutInput,
containing_block_position_in_bfc_root: FfiCssPixelPoint,
- pub(crate) callbacks: LayoutPass<'context>,
+ pub(crate) pass: LayoutPass<'context>,
pub(crate) parent: &'context block_formatting_context::BlockFormattingContext<'context>,
/// The lines this context lays out, which it hands back once they are laid out.
line_data: RefCell<used_values::LineData>,
@@ -1024,7 +1024,7 @@ impl<'context> InlineFormattingContext<'context> {
block_container: block_formatting_context::BlockContainer,
input: LayoutInput,
containing_block_position_in_bfc_root: FfiCssPixelPoint,
- callbacks: LayoutPass<'context>,
+ pass: LayoutPass<'context>,
parent: &'context block_formatting_context::BlockFormattingContext<'context>,
) -> Self {
Self {
@@ -1033,7 +1033,7 @@ impl<'context> InlineFormattingContext<'context> {
block_container,
input,
containing_block_position_in_bfc_root,
- callbacks,
+ pass,
parent,
line_data: RefCell::new(used_values::LineData::default()),
fragmented_inlines_in_pre_order: Vec::new(),
@@ -1207,12 +1207,12 @@ impl<'context> InlineFormattingContext<'context> {
#[inline]
pub(crate) fn style(&self, node: Node) -> StyleValues<'context> {
- StyleValues::for_node(&self.callbacks, node)
+ StyleValues::for_node(&self.pass, node)
}
#[inline]
pub(crate) fn facts(&self, node: Node) -> NodeFacts<'_> {
- NodeFacts::new(&self.callbacks, node)
+ NodeFacts::new(&self.pass, node)
}
pub(crate) fn style_source(&self, node: Node) -> Node {
@@ -1299,7 +1299,7 @@ impl<'context> InlineFormattingContext<'context> {
.expect("a relatively positioned inline ancestor in the chain is a box the context laid out")
};
accumulated_relative_insets_from_inline_ancestor_chain(
- &self.callbacks,
+ &self.pass,
first_ancestor,
self.containing_block,
used_insets_of_entered_inline_box,
@@ -1309,15 +1309,15 @@ impl<'context> InlineFormattingContext<'context> {
/// Starts holding `node`, an atomic inline-level box, which a run of its own lays out in the formatting context it
/// establishes. Returns the cells the box starts out with.
pub(crate) fn hold_atomic_inline(&self, node: Node) -> used_values::RootInputCells {
- used_values::cells_before_sizing(&self.callbacks, node, self.input.containing_block_constraints)
+ used_values::cells_before_sizing(&self.pass, node, self.input.containing_block_constraints)
}
pub(crate) fn parent_node(&self, node: Node) -> Node {
- self.callbacks.parent(node)
+ self.pass.parent(node)
}
pub(crate) fn first_child(&self, node: Node) -> Node {
- self.callbacks.first_child(node)
+ self.pass.first_child(node)
}
fn fragmented_inline_ancestors(&self, node: Node) -> Vec<Node> {
@@ -1739,7 +1739,7 @@ impl<'context> InlineFormattingContext<'context> {
return false;
}
let style = self.style(self.parent_node(item.node));
- let text_content = self.callbacks.text_content(item.node);
+ let text_content = self.pass.text_content(item.node);
let letter_spacing = style.letter_spacing().to_double() as f32;
let word_spacing = style.word_spacing().to_double() as f32;
loop {
@@ -1763,7 +1763,7 @@ impl<'context> InlineFormattingContext<'context> {
line_builder.break_line(line_builder::ForcedBreak::No, NodeSlotId::INVALID, None);
continue;
}
- let split_item = self.callbacks.with_grapheme_segmenter(item.node, |grapheme_segmenter| {
+ let split_item = self.pass.with_grapheme_segmenter(item.node, |grapheme_segmenter| {
item.split_for_overflow_break(
prepared,
&text_content.text,
@@ -1842,7 +1842,7 @@ impl<'context> InlineFormattingContext<'context> {
) -> block_formatting_context::FloatLaidOutAheadOfItsPosition {
// NB: Every float is sized in cells ahead of its layout, which takes them.
let cells_of_float_ahead_of_its_layout = Cell::new(used_values::cells_before_sizing(
- &self.callbacks,
+ &self.pass,
node,
self.input.containing_block_constraints,
));
@@ -2058,7 +2058,7 @@ impl<'context> InlineFormattingContext<'context> {
&& offset_in_node > item.offset_in_node
{
let style = self.style(self.parent_node(item.node));
- let text_content = self.callbacks.text_content(item.node);
+ let text_content = self.pass.text_content(item.node);
item.drop_prefix_before(
iterator.prepared_content(),
offset_in_node,
@@ -2193,7 +2193,7 @@ impl<'context> InlineFormattingContext<'context> {
if self.stops_at_line_clamp_point(line_builder, &mut state_at_clamp_point) {
break;
}
- let relative_insets = self.relative_insets_of_inline_ancestors(self.callbacks.parent(item.node));
+ let relative_insets = self.relative_insets_of_inline_ancestors(self.pass.parent(item.node));
let collapses_through = self.parent.layout_interrupting_block_inside_inline_context(
self.run,
item.node,
@@ -2522,7 +2522,7 @@ impl<'context> InlineFormattingContext<'context> {
for fragment in line.visible_fragments() {
let (x, y) = fragment.offset();
let relative_insets =
- self.relative_insets_of_inline_ancestors(self.callbacks.parent(fragment.layout_node));
+ self.relative_insets_of_inline_ancestors(self.pass.parent(fragment.layout_node));
let position = FfiCssPixelPoint {
x: x + relative_insets.offset_x,
y: y + relative_insets.offset_y,
@@ -2570,11 +2570,8 @@ impl<'context> InlineFormattingContext<'context> {
&& self.facts(node).is_box()
&& self.line_data().line_boxes.iter().any(|line| {
line.visible_fragments().any(|fragment| {
- self.callbacks.is_ancestor(
- self.callbacks.parent(node),
- fragment.layout_node,
- self.containing_block,
- )
+ self.pass
+ .is_ancestor(self.pass.parent(node), fragment.layout_node, self.containing_block)
})
})
{
@@ -2707,8 +2704,7 @@ impl<'context> InlineFormattingContext<'context> {
let (x, y) = fragment.offset();
// Atomic boxes are painted independently of their line fragments. Apply the inline ancestors'
// relative insets to their placement as well as to the line data folded below.
- let relative_insets =
- self.relative_insets_of_inline_ancestors(self.callbacks.parent(fragment.layout_node));
+ let relative_insets = self.relative_insets_of_inline_ancestors(self.pass.parent(fragment.layout_node));
let fragment_arrival = self.take_atomic_inline_fragment_arrival(fragment.layout_node);
formatting_context::place_child(
self.run,
@@ -2772,7 +2768,7 @@ impl<'context> InlineFormattingContext<'context> {
}
}
formatting_context::register_contained_abspos_child(
- &self.callbacks,
+ &self.pass,
self.run.fragments,
self.containing_block,
box_,
@@ -2822,7 +2818,7 @@ impl<'context> InlineFormattingContext<'context> {
/// Whether margins collapse through the children of `node`, the containing block or an inline box in it: through
/// each inline-level box this context holds, and through each block-level box it interrupted its lines for.
fn children_let_margins_collapse_through(&self, node: Node) -> bool {
- self.callbacks.children(node).all(|child| {
+ self.pass.children(node).all(|child| {
let facts = self.facts(child);
if !facts.is_box() || facts.is_absolutely_positioned() || facts.is_floating() {
return true;
@@ -2854,7 +2850,7 @@ impl<'context> InlineFormattingContext<'context> {
fn leave_atomic_inlines_without_a_line_unplaced(&self) {
let mut unplaced: Vec<_> = self.atomic_inline_fragment_arrivals.take().into_iter().collect();
unplaced.sort_by(|(left, _), (right, _)| {
- if self.callbacks.is_before(*left, *right) {
+ if self.pass.is_before(*left, *right) {
std::cmp::Ordering::Less
} else {
std::cmp::Ordering::Greater
@@ -3044,7 +3040,7 @@ impl<'context> InlineFormattingContext<'context> {
let childless_inline_boxes = entered_inline_boxes
.iter()
.copied()
- .filter(|node| is_first_fragment && self.callbacks.first_child(*node).is_invalid());
+ .filter(|node| is_first_fragment && self.pass.first_child(*node).is_invalid());
present.extend(childless_inline_boxes.clone());
let mut walked = HashSet::<Node>::default();
for node in kept_item_nodes
@@ -3055,11 +3051,11 @@ impl<'context> InlineFormattingContext<'context> {
let mut ancestor = if self.facts(node).is_fragmented_inline() {
node
} else {
- self.callbacks.parent(node)
+ self.pass.parent(node)
};
while !ancestor.is_invalid() && ancestor != self.containing_block && walked.insert(ancestor) {
present.insert(ancestor);
- ancestor = self.callbacks.parent(ancestor);
+ ancestor = self.pass.parent(ancestor);
}
}
present
@@ -3093,7 +3089,7 @@ impl<'context> InlineFormattingContext<'context> {
let first_ancestor = if self.facts(fragment.layout_node).is_fragmented_inline() {
fragment.layout_node
} else {
- self.callbacks.parent(fragment.layout_node)
+ self.pass.parent(fragment.layout_node)
};
fragment.relpos_delta = accumulated_relative_offset_from(first_ancestor);
}
@@ -3587,18 +3583,16 @@ impl ContentSizingLines {
border_and_padding_start: CssPixels,
trailing_whitespace_inline_size: CssPixels,
) {
- let text_content = context.callbacks.text_content(item.node);
- let cluster_inline_sizes = context
- .callbacks
- .with_grapheme_segmenter(item.node, |grapheme_segmenter| {
- item.grapheme_cluster_inline_sizes(
- prepared,
- &text_content.text,
- grapheme_segmenter,
- style.letter_spacing().to_double() as f32,
- style.word_spacing().to_double() as f32,
- )
- });
+ let text_content = context.pass.text_content(item.node);
+ let cluster_inline_sizes = context.pass.with_grapheme_segmenter(item.node, |grapheme_segmenter| {
+ item.grapheme_cluster_inline_sizes(
+ prepared,
+ &text_content.text,
+ grapheme_segmenter,
+ style.letter_spacing().to_double() as f32,
+ style.word_spacing().to_double() as f32,
+ )
+ });
let border_and_padding_end = item.padding_end + item.border_end;
if border_and_padding_start + item.inline_size + border_and_padding_end > CssPixels::default() {
self.lines.finish();
diff --git a/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs b/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs
index 0a125c712f2..2b107c8b87e 100644
--- a/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs
+++ b/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs
@@ -297,7 +297,7 @@ impl Item {
pub(crate) fn is_ascii_whitespace(&self, context: &inline_formatting_context::InlineFormattingContext<'_>) -> bool {
assert_eq!(self.type_, ItemType::Text);
- let text = &context.callbacks.text_content(self.node).text;
+ let text = &context.pass.text_content(self.node).text;
text[self.offset_in_node..self.offset_in_node + self.length_in_node]
.iter()
.all(|unit| *unit <= 0x7f && (*unit as u8).is_ascii_whitespace())
@@ -305,7 +305,7 @@ impl Item {
pub(crate) fn ends_in_ascii_space(&self, context: &inline_formatting_context::InlineFormattingContext<'_>) -> bool {
assert_eq!(self.type_, ItemType::Text);
- let text = &context.callbacks.text_content(self.node).text;
+ let text = &context.pass.text_content(self.node).text;
text[self.offset_in_node..self.offset_in_node + self.length_in_node]
.last()
.is_some_and(|unit| line_box_fragment::is_ascii_space(*unit))
@@ -1686,7 +1686,7 @@ fn lay_out_entered_inline_box(
node: Node,
) -> used_values::RootInputCells {
let constraints = context.input.containing_block_constraints;
- let mut sides = used_values::cells_before_sizing(&context.callbacks, node, constraints);
+ let mut sides = used_values::cells_before_sizing(&context.pass, node, constraints);
let style = context.style(node);
let basis = constraints.inline_basis();
sides.resolve_box_model(&style, basis);
@@ -1697,7 +1697,7 @@ fn lay_out_entered_inline_box(
context.run,
node,
formatting_context::PlacedChild::new(fragment_tree::FragmentGeometry {
- cells: sides.in_frame(context.callbacks.frame, context.run.callbacks.frame),
+ cells: sides.in_frame(context.pass.frame, context.run.pass.frame),
line_data: None,
})
.with_in_flow_box_insets(insets),
@@ -1841,7 +1841,7 @@ impl InlineLevelIterator {
context: &mut inline_formatting_context::InlineFormattingContext<'_>,
atomic_sizing: AtomicInlineSizing,
) -> Self {
- PreparedInlineContent::for_block_container(context.callbacks, context.containing_block)
+ PreparedInlineContent::for_block_container(context.pass, context.containing_block)
.resolve_items_for_run(context, atomic_sizing)
}
@@ -2011,8 +2011,8 @@ fn first_grapheme_cluster(
item: &Item,
) -> Item {
let style = context.style(context.style_source(item.node));
- let text_content = context.callbacks.text_content(item.node);
- let first_grapheme_cluster_inline_size = context.callbacks.with_grapheme_segmenter(item.node, |segmenter| {
+ let text_content = context.pass.text_content(item.node);
+ let first_grapheme_cluster_inline_size = context.pass.with_grapheme_segmenter(item.node, |segmenter| {
item.first_grapheme_cluster_inline_size(
prepared,
&text_content.text,
diff --git a/Libraries/LibWeb/Rust/src/layout/intrinsic_sizing.rs b/Libraries/LibWeb/Rust/src/layout/intrinsic_sizing.rs
index 63e2c36c09f..5c30d776cf7 100644
--- a/Libraries/LibWeb/Rust/src/layout/intrinsic_sizing.rs
+++ b/Libraries/LibWeb/Rust/src/layout/intrinsic_sizing.rs
@@ -13,12 +13,12 @@ pub(super) struct ContentSizingScope {
impl ContentSizingScope {
pub(super) fn new(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
node: Node,
constraints: ContainingBlockConstraints,
block_size: Option<CssPixels>,
) -> Self {
- let mut root_cells = used_values::cells_before_sizing(callbacks, node, constraints);
+ let mut root_cells = used_values::cells_before_sizing(pass, node, constraints);
// NB: A parent layout can assign a definite block size that is not present in computed style,
// such as the stretched cross size of a flex item. Preserve it so descendant percentages
// resolve against the same size during intrinsic measurement.
@@ -44,25 +44,25 @@ impl ContentSizingScope {
fn measure(
&self,
- callbacks: LayoutPass<'_>,
+ pass: LayoutPass<'_>,
size_content: impl FnOnce(&FormattingContextRun<'_>) -> sizing_context::ContentSizes,
) -> sizing_context::ContentInlineSizes {
- self.enter(callbacks, |run| {
+ self.enter(pass, |run| {
let sizes = size_content(run);
content_inline_sizes_measured_without_layout(&run.sizing(), self.node, sizes)
})
}
- fn enter<R>(&self, callbacks: LayoutPass<'_>, size_content: impl FnOnce(&FormattingContextRun<'_>) -> R) -> R {
+ fn enter<R>(&self, pass: LayoutPass<'_>, size_content: impl FnOnce(&FormattingContextRun<'_>) -> R) -> R {
RunState::with_content_inline_sizes_root(
- callbacks,
+ pass,
self.node,
- callbacks.in_flow_containing_block(self.node),
- |state, callbacks| {
+ pass.in_flow_containing_block(self.node),
+ |state, pass| {
size_content(&FormattingContextRun {
state,
box_: self.node,
- callbacks,
+ pass,
should_collect_devtools_layout_data: false,
treat_block_axis_percentage_insets_as_auto_beyond_root: false,
fragments: None,
@@ -91,22 +91,22 @@ fn content_inline_sizes_measured_without_layout(
}
pub(super) fn content_sizes_of_inline_content(
- callbacks: LayoutPass<'_>,
+ pass: LayoutPass<'_>,
scope: &ContentSizingScope,
constraints: ContainingBlockConstraints,
) -> sizing_context::ContentInlineSizes {
let node = scope.node;
- let facts = NodeFacts::new(&callbacks, node);
- let style = StyleValues::for_node(&callbacks, node);
- scope.enter(callbacks, |run| {
+ let facts = NodeFacts::new(&pass, node);
+ let style = StyleValues::for_node(&pass, node);
+ scope.enter(pass, |run| {
let child_constraints = run
.sizing()
.constraints_for_child_context(node, &scope.root_cells(), constraints);
- let sizes = if inline_content_has_no_in_flow_content(&callbacks, node) {
+ let sizes = if inline_content_has_no_in_flow_content(&pass, node) {
let sizing = run.sizing();
let mut contributions_of_floats = BlockLevelContributions::default();
contributions_of_floats.place_floats_among_children_of(
- &callbacks,
+ &pass,
&sizing,
node,
scope.available_block_size(),
@@ -128,7 +128,7 @@ pub(super) fn content_sizes_of_inline_content(
block_formatting_context::BlockContainer::root_of(run, scope.root_cells()),
input,
FfiCssPixelPoint::default(),
- run.callbacks,
+ run.pass,
&parent,
);
let iterator = inline_level_iterator::InlineLevelIterator::for_intrinsic_inline_size(&mut context);
@@ -252,20 +252,20 @@ impl BlockLevelContributions {
fn place_floats_among_children_of(
&mut self,
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
sizing: &sizing_context::SizingContext<'_, '_>,
container: Node,
available_block_size: AvailableSize,
constraints: ContainingBlockConstraints,
) {
- for float in callbacks
+ for float in pass
.children(container)
- .filter(|&child| NodeFacts::new(callbacks, child).is_floating())
+ .filter(|&child| NodeFacts::new(pass, child).is_floating())
{
let margin_box_contributions = sizing
.outer_inline_contributions(float, available_block_size, constraints)
.margin_box_contributions();
- self.place_float(StyleValues::for_node(callbacks, float), margin_box_contributions);
+ self.place_float(StyleValues::for_node(pass, float), margin_box_contributions);
}
}
@@ -283,59 +283,57 @@ fn is_anonymous_wrapper_of_inline_content(facts: NodeFacts<'_>) -> bool {
&& !facts.is_table_wrapper()
}
-fn text_is_collapsible_whitespace(callbacks: &LayoutPass<'_>, text_node: Node) -> bool {
- StyleValues::for_node(callbacks, callbacks.parent(text_node)).white_space_collapse()
- == white_space_collapse::COLLAPSE
- && !NodeFacts::new(callbacks, text_node).produces_line_box_fragment_when_empty()
- && callbacks
+fn text_is_collapsible_whitespace(pass: &LayoutPass<'_>, text_node: Node) -> bool {
+ StyleValues::for_node(pass, pass.parent(text_node)).white_space_collapse() == white_space_collapse::COLLAPSE
+ && !NodeFacts::new(pass, text_node).produces_line_box_fragment_when_empty()
+ && pass
.text_content(text_node)
.text
.iter()
.all(|unit| matches!(unit, 0x09..=0x0d | 0x20))
}
-fn inline_content_has_no_in_flow_content(callbacks: &LayoutPass<'_>, block_container: Node) -> bool {
- callbacks.children(block_container).all(|child| {
- let facts = NodeFacts::new(callbacks, child);
+fn inline_content_has_no_in_flow_content(pass: &LayoutPass<'_>, block_container: Node) -> bool {
+ pass.children(block_container).all(|child| {
+ let facts = NodeFacts::new(pass, child);
if facts.is_text_node() {
- text_is_collapsible_whitespace(callbacks, child)
+ text_is_collapsible_whitespace(pass, child)
} else {
facts.is_box() && (facts.is_floating() || facts.is_absolutely_positioned())
}
})
}
-fn is_anonymous_wrapper_without_in_flow_content(callbacks: &LayoutPass<'_>, node: Node) -> bool {
- is_anonymous_wrapper_of_inline_content(NodeFacts::new(callbacks, node))
- && inline_content_has_no_in_flow_content(callbacks, node)
+fn is_anonymous_wrapper_without_in_flow_content(pass: &LayoutPass<'_>, node: Node) -> bool {
+ is_anonymous_wrapper_of_inline_content(NodeFacts::new(pass, node))
+ && inline_content_has_no_in_flow_content(pass, node)
}
-fn rendered_legend_with_automatic_inline_size(callbacks: &LayoutPass<'_>, fieldset: Node) -> Option<Node> {
- let legend = NodeFacts::new(callbacks, fieldset).rendered_legend();
- (!legend.is_invalid() && StyleValues::for_node(callbacks, legend).width().is_auto()).then_some(legend)
+fn rendered_legend_with_automatic_inline_size(pass: &LayoutPass<'_>, fieldset: Node) -> Option<Node> {
+ let legend = NodeFacts::new(pass, fieldset).rendered_legend();
+ (!legend.is_invalid() && StyleValues::for_node(pass, legend).width().is_auto()).then_some(legend)
}
fn measure_outer_inline_contributions_of_children_ahead(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
node: Node,
available_block_size: AvailableSize,
child_constraints: ContainingBlockConstraints,
legend_sized_to_fit_its_content: Option<Node>,
) {
- let children = parallel_layout::fork_candidates(callbacks, callbacks.children(node), |child| child)
+ let children = parallel_layout::fork_candidates(pass, pass.children(node), |child| child)
.into_iter()
.filter(|&child| {
- let child_facts = NodeFacts::new(callbacks, child);
+ let child_facts = NodeFacts::new(pass, child);
child_facts.is_flow_layout_participant()
&& !child_facts.is_table_wrapper()
&& legend_sized_to_fit_its_content != Some(child)
- && (block_formatting_context::box_avoids_floats_because_it_establishes_formatting_context(
- callbacks, child,
- ) || !is_anonymous_wrapper_without_in_flow_content(callbacks, child))
+ && (block_formatting_context::box_avoids_floats_because_it_establishes_formatting_context(pass, child)
+ || !is_anonymous_wrapper_without_in_flow_content(pass, child))
})
.collect();
sizing_context::measure_ahead(
- callbacks,
+ pass,
children,
|&child| child,
|sizing, child| {
@@ -345,20 +343,20 @@ fn measure_outer_inline_contributions_of_children_ahead(
}
pub(super) fn content_sizes_of_block_container(
- callbacks: LayoutPass<'_>,
+ pass: LayoutPass<'_>,
scope: &ContentSizingScope,
constraints: ContainingBlockConstraints,
) -> sizing_context::ContentInlineSizes {
let node = scope.node;
- let facts = NodeFacts::new(&callbacks, node);
- let style = StyleValues::for_node(&callbacks, node);
- scope.measure(callbacks, |run| {
+ let facts = NodeFacts::new(&pass, node);
+ let style = StyleValues::for_node(&pass, node);
+ scope.measure(pass, |run| {
let sizing = run.sizing();
let child_constraints = sizing.constraints_for_child_context(node, &scope.root_cells(), constraints);
let collects_column_spanners = facts.lays_out_in_columns();
- let legend_sized_to_fit_its_content = rendered_legend_with_automatic_inline_size(&callbacks, node);
+ let legend_sized_to_fit_its_content = rendered_legend_with_automatic_inline_size(&pass, node);
measure_outer_inline_contributions_of_children_ahead(
- &run.callbacks,
+ &run.pass,
node,
scope.available_block_size(),
child_constraints,
@@ -366,18 +364,16 @@ pub(super) fn content_sizes_of_block_container(
);
let mut contributions_of_children = BlockLevelContributions::default();
let mut largest_column_spanner_contributions = sizing_context::ContentSizes::default();
- for child in callbacks.children(node) {
- let child_facts = NodeFacts::new(&callbacks, child);
+ for child in pass.children(node) {
+ let child_facts = NodeFacts::new(&pass, child);
if !child_facts.is_flow_layout_participant() {
continue;
}
let child_avoids_floats =
- block_formatting_context::box_avoids_floats_because_it_establishes_formatting_context(
- &callbacks, child,
- );
- if !child_avoids_floats && is_anonymous_wrapper_without_in_flow_content(&callbacks, child) {
+ block_formatting_context::box_avoids_floats_because_it_establishes_formatting_context(&pass, child);
+ if !child_avoids_floats && is_anonymous_wrapper_without_in_flow_content(&pass, child) {
contributions_of_children.place_floats_among_children_of(
- &callbacks,
+ &pass,
&sizing,
child,
scope.available_block_size(),
@@ -399,12 +395,12 @@ pub(super) fn content_sizes_of_block_container(
sizing.outer_inline_contributions(child, scope.available_block_size(), child_constraints)
};
let margin_box_contributions = contributions.margin_box_contributions();
- if collects_column_spanners && block_formatting_context::is_column_spanner(&callbacks, child) {
+ if collects_column_spanners && block_formatting_context::is_column_spanner(&pass, child) {
largest_column_spanner_contributions =
largest_column_spanner_contributions.largest_of(margin_box_contributions);
continue;
}
- let child_style = StyleValues::for_node(&callbacks, child);
+ let child_style = StyleValues::for_node(&pass, child);
if child_facts.is_floating() {
contributions_of_children.place_float(child_style, margin_box_contributions);
continue;
@@ -446,14 +442,14 @@ pub(super) fn content_sizes_of_block_container(
}
pub(super) fn content_sizes_of_table(
- callbacks: LayoutPass<'_>,
+ pass: LayoutPass<'_>,
scope: &ContentSizingScope,
constraints: ContainingBlockConstraints,
) -> sizing_context::ContentInlineSizes {
let node = scope.node;
- let is_table_box = formatting_context::independent_formatting_context_type(node, &callbacks)
+ let is_table_box = formatting_context::independent_formatting_context_type(node, &pass)
== formatting_context::FormattingContextType::Table;
- scope.measure(callbacks, |run| {
+ scope.measure(pass, |run| {
if is_table_box {
table_formatting_context::TableFormattingContext::new(
run,
@@ -476,30 +472,30 @@ pub(super) fn content_sizes_of_table(
}
pub(super) fn content_sizes_of_flex_container(
- callbacks: LayoutPass<'_>,
+ pass: LayoutPass<'_>,
node: Node,
constraints: ContainingBlockConstraints,
block_size: Option<CssPixels>,
) -> sizing_context::ContentInlineSizes {
- let scope = ContentSizingScope::new(&callbacks, node, constraints, block_size);
- scope.measure(callbacks, |run| {
+ let scope = ContentSizingScope::new(&pass, node, constraints, block_size);
+ scope.measure(pass, |run| {
flex_formatting_context::FlexFormattingContext::new(run, scope.root_cells())
.content_inline_sizes(scope.available_block_size(), constraints)
})
}
pub(super) fn content_sizes_of_grid_container(
- callbacks: LayoutPass<'_>,
+ pass: LayoutPass<'_>,
node: Node,
constraints: ContainingBlockConstraints,
block_size: Option<CssPixels>,
) -> sizing_context::ContentInlineSizes {
content_sizes_of_container_under_each_inline_size_constraint(
- callbacks,
+ pass,
node,
constraints,
block_size,
- content_size_named_by_maximum_inline_size(&callbacks, node),
+ content_size_named_by_maximum_inline_size(&pass, node),
|run, root_cells, input, maximum_inline_size_resolved_by_caller| {
grid_formatting_context::GridFormattingContext::new(run, root_cells, None)
.content_inline_size(input, maximum_inline_size_resolved_by_caller)
@@ -523,10 +519,10 @@ impl ContentSizeNamedByMaximum {
}
pub(super) fn content_size_named_by_maximum_inline_size(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
node: Node,
) -> Option<ContentSizeNamedByMaximum> {
- let maximum = StyleValues::for_node(callbacks, node).max_width();
+ let maximum = StyleValues::for_node(pass, node).max_width();
if maximum.calc_size().is_some() {
None
} else if maximum.is_min_content() {
@@ -548,7 +544,7 @@ pub(super) fn available_inline_size_under_content_size_named_by_maximum(
}
fn content_sizes_of_container_under_each_inline_size_constraint(
- callbacks: LayoutPass<'_>,
+ pass: LayoutPass<'_>,
node: Node,
constraints: ContainingBlockConstraints,
block_size: Option<CssPixels>,
@@ -562,8 +558,8 @@ fn content_sizes_of_container_under_each_inline_size_constraint(
) -> sizing_context::ContentInlineSizes {
let content_inline_size_under =
|available_inline_size: AvailableSize, content_size_named_by_maximum: Option<CssPixels>| {
- let scope = ContentSizingScope::new(&callbacks, node, constraints, block_size);
- scope.enter(callbacks, |run| {
+ let scope = ContentSizingScope::new(&pass, node, constraints, block_size);
+ scope.enter(pass, |run| {
let sizing = run.sizing();
let input = LayoutInput::new(
AvailableSpace {
@@ -575,7 +571,7 @@ fn content_sizes_of_container_under_each_inline_size_constraint(
);
let maximum_inline_size_resolved_by_caller = content_size_named_by_maximum.map(|content_size| {
sizing.apply_transferred_limits_to_intrinsic_inline_size(
- sizing_context::SizedBox::of_own_metrics(node, &scope.root_cells(), run.callbacks.frame),
+ sizing_context::SizedBox::of_own_metrics(node, &scope.root_cells(), run.pass.frame),
clamp_to_max_dimension_value(content_size),
available_inline_size_under_content_size_named_by_maximum(
content_size_named_by_maximum_inline_size,
@@ -629,14 +625,14 @@ pub(super) fn measure_under_each_inline_size_constraint_named_maximum_first<Meas
}
pub(super) fn content_sizes_of_replaced_content(
- callbacks: LayoutPass<'_>,
+ pass: LayoutPass<'_>,
scope: &ContentSizingScope,
) -> sizing_context::ContentInlineSizes {
- let size = match formatting_context::independent_formatting_context_type(scope.node, &callbacks) {
+ let size = match formatting_context::independent_formatting_context_type(scope.node, &pass) {
formatting_context::FormattingContextType::ReplacedWithChildren => scope.root_cells().content_inline_size,
_ => CssPixels::default(),
};
- scope.measure(callbacks, |_| sizing_context::ContentSizes { min: size, max: size })
+ scope.measure(pass, |_| sizing_context::ContentSizes { min: size, max: size })
}
// https://drafts.csswg.org/css-writing-modes-4/#orthogonal-shrink-to-fit
@@ -644,36 +640,35 @@ pub(super) fn content_sizes_of_replaced_content(
// calculated to fit its content; and this resulting content-based size is used as input to the inline-axis
// min-content size and max-content size of the parent."
pub(super) fn content_sizes_of_orthogonal_flow(
- callbacks: LayoutPass<'_>,
+ pass: LayoutPass<'_>,
scope: &ContentSizingScope,
constraints: ContainingBlockConstraints,
) -> sizing_context::ContentInlineSizes {
let node = scope.node;
- let own_frame = formatting_context::frame_established_by(&callbacks, node);
- let callbacks_in_own_frame = callbacks.in_frame_of(own_frame.writing_mode());
+ let own_frame = formatting_context::frame_established_by(&pass, node);
+ let pass_in_own_frame = pass.in_frame_of(own_frame.writing_mode());
let constraints_in_own_frame = ContainingBlockConstraints {
percentage_basis_inline_size: constraints.percentage_basis_block_size,
percentage_basis_block_size: constraints.percentage_basis_inline_size,
quirks_mode_percentage_basis_block_size: None,
};
- let (observes_percentage_inline_basis, own_style_depends_on_percentage_block_size) =
- scope.enter(callbacks, |run| {
- let sizing = run.sizing();
- (
- sizing.measurement_root_observes_percentage_inline_basis(node),
- sizing.own_style_depends_on_percentage_block_size(node),
- )
- });
+ let (observes_percentage_inline_basis, own_style_depends_on_percentage_block_size) = scope.enter(pass, |run| {
+ let sizing = run.sizing();
+ (
+ sizing.measurement_root_observes_percentage_inline_basis(node),
+ sizing.own_style_depends_on_percentage_block_size(node),
+ )
+ });
let available_inline_size_in_own_frame = scope.available_block_size();
- let mut root_cells = scope.root_cells().in_frame(callbacks.frame, own_frame);
+ let mut root_cells = scope.root_cells().in_frame(pass.frame, own_frame);
let inline_size_is_sized_from_parent_block_size = !root_cells.has_definite_inline_size;
let inline_size = if root_cells.has_definite_inline_size {
root_cells.content_inline_size
} else {
let scope_in_own_frame = ContentSizingScope { node, root_cells };
- scope_in_own_frame.enter(callbacks_in_own_frame, |run| {
+ scope_in_own_frame.enter(pass_in_own_frame, |run| {
run.sizing().orthogonal_flow_inline_size(
- sizing_context::SizedBox::of_own_metrics(node, &scope_in_own_frame.root_cells(), run.callbacks.frame),
+ sizing_context::SizedBox::of_own_metrics(node, &scope_in_own_frame.root_cells(), run.pass.frame),
AvailableSpace {
inline_size: available_inline_size_in_own_frame,
block_size: AvailableSize::Indefinite,
@@ -693,11 +688,11 @@ pub(super) fn content_sizes_of_orthogonal_flow(
ParticipationInParentFormattingContext::Root,
);
input.sizing.root_is_measured_for_its_content_block_size = matches!(
- formatting_context::independent_formatting_context_type(node, &callbacks_in_own_frame),
+ formatting_context::independent_formatting_context_type(node, &pass_in_own_frame),
formatting_context::FormattingContextType::Flex | formatting_context::FormattingContextType::Grid
);
let result =
- formatting_context::lay_out_measurement_root_for_its_result(callbacks_in_own_frame, node, root_cells, input);
+ formatting_context::lay_out_measurement_root_for_its_result(pass_in_own_frame, node, root_cells, input);
let size = result.automatic_content_block_size;
sizing_context::ContentInlineSizes {
sizes: sizing_context::ContentSizes { min: size, max: size },
@@ -716,7 +711,7 @@ pub(super) fn content_sizes_of_orthogonal_flow(
// NB: MathML layout does not break lines, so the min-content and max-content inline sizes of a MathML box are both the
// inline size its layout gives it.
pub(super) fn content_sizes_of_math(
- callbacks: LayoutPass<'_>,
+ pass: LayoutPass<'_>,
scope: &ContentSizingScope,
constraints: ContainingBlockConstraints,
) -> sizing_context::ContentInlineSizes {
@@ -729,9 +724,9 @@ pub(super) fn content_sizes_of_math(
constraints,
ParticipationInParentFormattingContext::Root,
);
- let laid_out = formatting_context::run_root_without_parent_fragments(callbacks, node, scope.root_cells(), input);
+ let laid_out = formatting_context::run_root_without_parent_fragments(pass, node, scope.root_cells(), input);
let size = laid_out.root_cells_left_by_run.content_inline_size;
- let observes_percentage_inline_basis = scope.enter(callbacks, |run| {
+ let observes_percentage_inline_basis = scope.enter(pass, |run| {
run.sizing().measurement_root_observes_percentage_inline_basis(node)
});
sizing_context::ContentInlineSizes {
diff --git a/Libraries/LibWeb/Rust/src/layout/line_builder.rs b/Libraries/LibWeb/Rust/src/layout/line_builder.rs
index a1630ab7401..b026c94de9a 100644
--- a/Libraries/LibWeb/Rust/src/layout/line_builder.rs
+++ b/Libraries/LibWeb/Rust/src/layout/line_builder.rs
@@ -225,9 +225,9 @@ impl<'builder, 'context> LineBuilder<'builder, 'context> {
if let Some((cached_node, data, style_payloads)) = self.facts_cache.get()
&& cached_node == node
{
- return NodeFacts::from_lookups(&self.context.callbacks, node, data, style_payloads);
+ return NodeFacts::from_lookups(&self.context.pass, node, data, style_payloads);
}
- let facts = NodeFacts::new(&self.context.callbacks, node);
+ let facts = NodeFacts::new(&self.context.pass, node);
self.facts_cache.set(Some((node, facts.data(), facts.style_view())));
facts
}
@@ -242,7 +242,7 @@ impl<'builder, 'context> LineBuilder<'builder, 'context> {
let style = self.style(style_source);
let facts = self.facts(node);
let (text_utf16, text_length) = if facts.is_text_node() {
- let text = &self.context().callbacks.text_content(node).text;
+ let text = &self.context().pass.text_content(node).text;
(text.as_ptr(), text.len())
} else {
(std::ptr::null(), 0)
@@ -990,7 +990,7 @@ impl<'builder, 'context> LineBuilder<'builder, 'context> {
} else {
let box_cells = box_cells.expect("the fragment of an element item carries the cells of its box");
formatting_context::inline_box_baseline(
- &self.context().callbacks,
+ &self.context().pass,
node,
&box_cells,
content_baselines
diff --git a/Libraries/LibWeb/Rust/src/layout/math_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/math_formatting_context.rs
index c4bb13b0018..af3035032dc 100644
--- a/Libraries/LibWeb/Rust/src/layout/math_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/math_formatting_context.rs
@@ -1503,15 +1503,15 @@ impl<'pass> MathFormattingContext<'pass> {
}
fn style(&self, node: Node) -> StyleValues<'pass> {
- StyleValues::for_node(&self.run.callbacks, node)
+ StyleValues::for_node(&self.run.pass, node)
}
fn facts(&self, node: Node) -> NodeFacts<'_> {
- NodeFacts::new(&self.run.callbacks, node)
+ NodeFacts::new(&self.run.pass, node)
}
fn kind(&self, node: Node) -> MathLayoutKind {
- self.run.callbacks.arena().math_layout_kind(node)
+ self.run.pass.arena().math_layout_kind(node)
}
fn in_flow_children(&self) -> Vec<Node> {
@@ -1523,13 +1523,13 @@ impl<'pass> MathFormattingContext<'pass> {
// The float property does not create floating of elements whose parent's computed display value is block
// math or inline math, and does not take them out-of-flow.
self.run
- .callbacks
+ .pass
.children(parent)
.filter(|&child| {
let facts = self.facts(child);
facts.is_box()
&& !facts.is_absolutely_positioned()
- && !self.run.callbacks.can_skip_is_anonymous_text_run(child)
+ && !self.run.pass.can_skip_is_anonymous_text_run(child)
})
.collect()
}
@@ -1594,13 +1594,13 @@ impl<'pass> MathFormattingContext<'pass> {
/// The text of an operator that contains only text content.
fn operator_text_content(&self, operator: Node) -> Option<Vec<u16>> {
- let callbacks = &self.run.callbacks;
+ let pass = &self.run.pass;
let mut content = Vec::new();
- for child in callbacks.children(operator) {
- if !node_facts::kind_is_text(callbacks.node_data(child).kind.get()) {
+ for child in pass.children(operator) {
+ if !node_facts::kind_is_text(pass.node_data(child).kind.get()) {
return Option::None;
}
- content.extend_from_slice(&callbacks.text_content(child).text);
+ content.extend_from_slice(&pass.text_content(child).text);
}
let is_whitespace = |unit: &u16| *unit <= 0x7f && (*unit as u8).is_ascii_whitespace();
let start = content
@@ -1683,7 +1683,7 @@ impl<'pass> MathFormattingContext<'pass> {
first_and_last_non_space_like: Option<(usize, usize)>,
) -> Option<OperatorProperties> {
let core_operator = self.core_operator(siblings[index])?;
- let attributes = self.run.callbacks.arena().math_attribute_facts(core_operator);
+ let attributes = self.run.pass.arena().math_attribute_facts(core_operator);
// 2. Otherwise, run the algorithm for determining the form of an embellished operator.
let explicit_form = OperatorForm::from_attribute(attributes.form);
let form = explicit_form
@@ -1748,17 +1748,17 @@ impl<'pass> MathFormattingContext<'pass> {
/// The properties of an operator, as the core operator of the outermost embellished operator it is the core
/// operator of.
fn core_operator_properties(&self, operator: Node) -> Option<OperatorProperties> {
- let callbacks = &self.run.callbacks;
+ let pass = &self.run.pass;
let lays_out_math = |node: Node| !node.is_invalid() && self.kind(node).uses_math_layout();
let mut embellished_operator = operator;
loop {
- let parent = callbacks.parent(embellished_operator);
+ let parent = pass.parent(embellished_operator);
if !lays_out_math(parent) || self.core_operator(parent) != Some(operator) {
break;
}
embellished_operator = parent;
}
- let parent = callbacks.parent(embellished_operator);
+ let parent = pass.parent(embellished_operator);
if lays_out_math(parent) {
let siblings = self.in_flow_children_of(parent);
if let Some(index) = siblings.iter().position(|&sibling| sibling == embellished_operator) {
@@ -1864,7 +1864,7 @@ impl<'pass> MathFormattingContext<'pass> {
// maxsize:
// NB: Font-relative lengths for minsize and maxsize rely on the font style of the core operator. The
// dictionary sets minsize to 100% and maxsize to ∞, which is represented by `None`.
- let attributes = self.run.callbacks.arena().math_attribute_facts(operator);
+ let attributes = self.run.pass.arena().math_attribute_facts(operator);
let glyph_metrics = font.glyph_metrics(glyph_id);
let glyph_height = CssPixels::nearest_value_for_f32(glyph_metrics.ascent + glyph_metrics.descent);
let mut minsize = attributes.minsize.resolve(&style, glyph_height).unwrap_or(glyph_height);
@@ -2157,7 +2157,7 @@ impl<'pass> MathFormattingContext<'pass> {
stretch_size_constraint: Option<MathStretchSizeConstraint>,
) -> Child {
let run = &self.run;
- let child_cells = used_values::cells_before_sizing(&run.callbacks, child, constraints);
+ let child_cells = used_values::cells_before_sizing(&run.pass, child, constraints);
// NB: MathML layout does not break lines, so each child is laid out at its max-content inline size, as an
// atomic box whose block size follows from its content.
let mut input = LayoutInput::new(
@@ -2453,7 +2453,7 @@ impl<'pass> MathFormattingContext<'pass> {
/// Whether the accentunder and accent attributes of an <munder>, <mover> or <munderover> are a match to true.
// https://w3c.github.io/mathml-core/#dfn-accent
fn accents(&self, node: Node) -> (bool, bool) {
- let attributes = self.run.callbacks.arena().math_attribute_facts(node);
+ let attributes = self.run.pass.arena().math_attribute_facts(node);
(
attributes.accentunder == math_boolean::TRUE,
attributes.accent == math_boolean::TRUE,
@@ -2462,7 +2462,7 @@ impl<'pass> MathFormattingContext<'pass> {
// https://w3c.github.io/mathml-core/#adjust-space-around-content-mpadded
fn layout_padded(&self, inner: MathContent, style: &StyleValues<'_>) -> MathContent {
- let attributes = self.run.callbacks.arena().math_attribute_facts(self.run.box_);
+ let attributes = self.run.pass.arena().math_attribute_facts(self.run.box_);
let resolve = |length: FfiMathLength| {
(!length.is_percentage())
.then(|| length.resolve(style, CssPixels::default()))
@@ -2511,7 +2511,7 @@ impl<'pass> MathFormattingContext<'pass> {
fn layout_space(&self, style: &StyleValues<'_>) -> MathContent {
// If the height attribute is absent, invalid or a percentage then the requested line-ascent is 0. Otherwise
// the requested line-ascent is the resolved value of the height attribute, clamping negative values to 0.
- let height = self.run.callbacks.arena().math_attribute_facts(self.run.box_).height;
+ let height = self.run.pass.arena().math_attribute_facts(self.run.box_).height;
let requested_line_ascent = if height.is_percentage() {
CssPixels::default()
} else {
@@ -2539,7 +2539,7 @@ impl<'pass> MathFormattingContext<'pass> {
// value. A negative value is interpreted as 0.
let line_thickness = self
.run
- .callbacks
+ .pass
.arena()
.math_attribute_facts(self.run.box_)
.linethickness
@@ -2643,7 +2643,7 @@ impl<'pass> MathFormattingContext<'pass> {
}
pub(super) fn parent_did_dimension(&self, root_after_epilogue: used_values::RootInputCells) {
- for child in self.run.callbacks.children(self.run.box_) {
+ for child in self.run.pass.children(self.run.box_) {
let facts = self.facts(child);
if !facts.is_box() || !facts.is_absolutely_positioned() {
continue;
@@ -2661,7 +2661,7 @@ impl<'pass> MathFormattingContext<'pass> {
alignment_derives_from_own_computed_values: false,
};
formatting_context::register_contained_abspos_child(
- &self.run.callbacks,
+ &self.run.pass,
self.run.fragments,
self.run.box_,
child,
diff --git a/Libraries/LibWeb/Rust/src/layout/node_facts.rs b/Libraries/LibWeb/Rust/src/layout/node_facts.rs
index 2d72d174d31..a1f7c90fdf4 100644
--- a/Libraries/LibWeb/Rust/src/layout/node_facts.rs
+++ b/Libraries/LibWeb/Rust/src/layout/node_facts.rs
@@ -343,7 +343,7 @@ fn auto_content_size(
}
/// The node's own computed style, read off the style container the node data points at. Callers inside a layout pass go
-/// through the pass callbacks instead; this is for the node-data entry points the C++ side calls directly.
+/// through the pass instead; this is for the node-data entry points the C++ side calls directly.
pub(crate) fn node_style_view(data: &NodeData) -> Option<ComputedValuesView<'_>> {
// SAFETY: The arena pins the style of each of its rows while the row holds it.
data.style.get().map(|style| unsafe { style.view() })
@@ -808,7 +808,7 @@ pub(crate) fn kind_is_svg_box(kind: NodeKind) -> bool {
/// Nothing is materialized per node, so every answer is as live as its source.
#[derive(Clone, Copy)]
pub(crate) struct NodeFacts<'pass> {
- callbacks: LayoutPass<'pass>,
+ pass: LayoutPass<'pass>,
node: Node,
data: &'pass NodeData,
style: Option<ComputedValuesView<'pass>>,
@@ -816,21 +816,21 @@ pub(crate) struct NodeFacts<'pass> {
impl<'pass> NodeFacts<'pass> {
#[inline]
- pub(crate) fn new(callbacks: &LayoutPass<'pass>, node: Node) -> Self {
- let (data, style) = callbacks.row_and_style(node);
- Self::from_lookups(callbacks, node, data, style)
+ pub(crate) fn new(pass: &LayoutPass<'pass>, node: Node) -> Self {
+ let (data, style) = pass.row_and_style(node);
+ Self::from_lookups(pass, node, data, style)
}
/// The facts of `node`, from the node data and style payloads that [`Self::new`] looked up for it.
#[inline]
pub(super) fn from_lookups(
- callbacks: &LayoutPass<'pass>,
+ pass: &LayoutPass<'pass>,
node: Node,
data: &'pass NodeData,
style: Option<ComputedValuesView<'pass>>,
) -> Self {
Self {
- callbacks: *callbacks,
+ pass: *pass,
node,
data,
style,
@@ -854,7 +854,7 @@ impl<'pass> NodeFacts<'pass> {
fn parent_data(&self) -> Option<&'pass NodeData> {
let parent = self.data().parent.get();
- (!parent.is_invalid()).then(|| self.callbacks.node_data(parent))
+ (!parent.is_invalid()).then(|| self.pass.node_data(parent))
}
pub(super) fn style(&self) -> StyleValues<'pass> {
@@ -863,7 +863,7 @@ impl<'pass> NodeFacts<'pass> {
.expect("styled node must publish its style container before layout"),
)
.for_kind(self.data().kind.get())
- .in_frame(self.callbacks.frame)
+ .in_frame(self.pass.frame)
}
pub(super) fn computed_values_view_if_styled(&self) -> Option<ComputedValuesView<'pass>> {
@@ -875,12 +875,12 @@ impl<'pass> NodeFacts<'pass> {
if parent.is_invalid() {
return None;
}
- self.callbacks.computed_values_view_if_styled(parent)
+ self.pass.computed_values_view_if_styled(parent)
}
#[inline]
fn may_have_replaced_content_facts(&self) -> bool {
- node_may_have_replaced_content_facts(self.data()) || self.callbacks.has_replaced_content_facts(self.node)
+ node_may_have_replaced_content_facts(self.data()) || self.pass.has_replaced_content_facts(self.node)
}
#[inline]
@@ -901,7 +901,7 @@ impl<'pass> NodeFacts<'pass> {
#[inline(never)]
fn replaced_content_of_box_with_facts(&self) -> ReplacedContentFacts {
let facts = self.physical_replaced_content();
- if self.callbacks.frame.is_transposed() {
+ if self.pass.frame.is_transposed() {
facts.transposed()
} else {
facts
@@ -955,7 +955,7 @@ impl<'pass> NodeFacts<'pass> {
if self.data().kind.get() == NodeKind::SVGSVGBox {
return self.svg_root_replaced_content();
}
- self.callbacks
+ self.pass
.replaced_content_facts(self.node)
.expect("replaced content facts were not synced to the arena before layout")
}
@@ -965,14 +965,13 @@ impl<'pass> NodeFacts<'pass> {
#[cold]
fn svg_root_replaced_content(&self) -> ReplacedContentFacts {
let mut facts = derived_replaced_content_facts(self.data(), ReplacedContentInput::None);
- let arena = self.callbacks.arena();
+ let arena = self.pass.arena();
let is_document_element_box = arena.is_document_svg_root_box(self.node);
let size_contained = self.node_has_size_containment();
if size_contained && !is_document_element_box {
return facts;
}
- let (width, height, aspect_ratio) =
- super::svg_formatting_context::svg_root_natural_size(&self.callbacks, self.node);
+ let (width, height, aspect_ratio) = super::svg_formatting_context::svg_root_natural_size(&self.pass, self.node);
// An <object> showing the document is sized from what its <svg> document element would be
// without size containment.
if is_document_element_box {
@@ -982,7 +981,7 @@ impl<'pass> NodeFacts<'pass> {
aspect_ratio: aspect_ratio
.map(|(numerator, denominator)| (numerator.raw_value(), denominator.raw_value())),
};
- self.callbacks.note_host_findings(|findings| {
+ self.pass.note_host_findings(|findings| {
findings.document_svg_root_natural_size = Some((self.node, natural_size));
});
}
@@ -1246,7 +1245,7 @@ impl<'pass> NodeFacts<'pass> {
/// Whether the box is generated for a MathML element whose tag name selects a MathML layout algorithm.
pub(crate) fn uses_math_layout(&self) -> bool {
- self.callbacks.arena().math_layout_kind(self.node).uses_math_layout()
+ self.pass.arena().math_layout_kind(self.node).uses_math_layout()
}
// https://drafts.csswg.org/css2/#propdef-vertical-align
@@ -1285,9 +1284,9 @@ impl<'pass> NodeFacts<'pass> {
}
let mut child = data.first_child.get();
while !child.is_invalid() {
- let child_data = self.callbacks.node_data(child);
+ let child_data = self.pass.node_data(child);
if child_data.kind.get() == NodeKind::LegendBox
- && !node_is_out_of_flow(child_data, self.callbacks.computed_values_view_if_styled(child))
+ && !node_is_out_of_flow(child_data, self.pass.computed_values_view_if_styled(child))
{
return child;
}
@@ -1309,8 +1308,8 @@ impl<'pass> NodeFacts<'pass> {
}
let mut child = data.first_child.get();
while !child.is_invalid() {
- let child_data = self.callbacks.node_data(child);
- if node_is_fieldset_content_wrapper(child_data, self.callbacks.computed_values_view_if_styled(child)) {
+ let child_data = self.pass.node_data(child);
+ if node_is_fieldset_content_wrapper(child_data, self.pass.computed_values_view_if_styled(child)) {
return true;
}
child = child_data.next_sibling.get();
@@ -1327,7 +1326,7 @@ impl<'pass> NodeFacts<'pass> {
// Walk those wrappers, but not nested authored or generated list items.
let mut candidate = self.data().first_child.get();
while !candidate.is_invalid() {
- let data = self.callbacks.node_data(candidate);
+ let data = self.pass.node_data(candidate);
if data.kind.get() == NodeKind::ListItemMarkerBox {
return candidate;
}
@@ -1348,7 +1347,7 @@ impl<'pass> NodeFacts<'pass> {
if current_data.parent.get() == self.node {
return Node::INVALID;
}
- current_data = self.callbacks.node_data(current_data.parent.get());
+ current_data = self.pass.node_data(current_data.parent.get());
}
}
Node::INVALID
@@ -1407,7 +1406,7 @@ impl<'pass> NodeFacts<'pass> {
}
pub(crate) fn initial_containing_block_inline_size(&self) -> crate::layout::CssPixels {
- self.callbacks.initial_containing_block_inline_size
+ self.pass.initial_containing_block_inline_size
}
pub(crate) fn is_scroll_container(&self) -> bool {
@@ -1478,7 +1477,7 @@ impl<'pass> NodeFacts<'pass> {
}
pub(crate) fn document_in_quirks_mode(&self) -> bool {
- self.callbacks.document_in_quirks_mode
+ self.pass.document_in_quirks_mode
}
pub(crate) fn is_in_user_agent_shadow_tree(&self) -> bool {
diff --git a/Libraries/LibWeb/Rust/src/layout/parallel_layout.rs b/Libraries/LibWeb/Rust/src/layout/parallel_layout.rs
index 8e0f0b3b728..bc91c05ad1c 100644
--- a/Libraries/LibWeb/Rust/src/layout/parallel_layout.rs
+++ b/Libraries/LibWeb/Rust/src/layout/parallel_layout.rs
@@ -98,8 +98,8 @@ pub(crate) fn lay_out_shapes_ahead(pass: &LayoutPass<'_>, shapes: Vec<formatting
pass,
shapes,
|shape| shape.node,
- |callbacks, shape| {
- formatting_context::lay_out_shape_for_its_result(callbacks, shape);
+ |pass, shape| {
+ formatting_context::lay_out_shape_for_its_result(pass, shape);
},
);
}
diff --git a/Libraries/LibWeb/Rust/src/layout/replaced_with_children_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/replaced_with_children_formatting_context.rs
index 57ad70b6e73..b983aec4ffa 100644
--- a/Libraries/LibWeb/Rust/src/layout/replaced_with_children_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/replaced_with_children_formatting_context.rs
@@ -27,9 +27,9 @@ pub(super) fn layout_replaced_with_children(
// The TreeBuilder wraps shadow DOM children in an anonymous BlockContainer.
// Delegate layout to a BFC for that wrapper.
let Some(wrapper) = run
- .callbacks
+ .pass
.children(run.box_)
- .find(|&child| node_facts::NodeFacts::new(&run.callbacks, child).is_block_container())
+ .find(|&child| node_facts::NodeFacts::new(&run.pass, child).is_block_container())
else {
return formatting_context::ChildLayoutResult::default();
};
@@ -37,18 +37,18 @@ pub(super) fn layout_replaced_with_children(
let wrapper_constraints =
run.sizing()
.constraints_for_child_context(run.box_, &*root, layout_input.containing_block_constraints);
- let mut wrapper_cells = used_values::cells_before_sizing(&run.callbacks, wrapper, wrapper_constraints);
+ let mut wrapper_cells = used_values::cells_before_sizing(&run.pass, wrapper, wrapper_constraints);
wrapper_cells.set_content_inline_size(content_inline_size);
let wrapper_outcome = formatting_context::run_formatting_context(
run.fragments.is_some(),
wrapper_cells,
wrapper,
- run.callbacks.in_flow_containing_block(wrapper),
+ run.pass.in_flow_containing_block(wrapper),
None,
formatting_context::FormattingContextType::Block,
run.should_collect_devtools_layout_data,
- run.callbacks,
+ run.pass,
geometry::LayoutInput {
available_space: child_available_space,
containing_block_constraints: wrapper_constraints,
@@ -65,7 +65,7 @@ pub(super) fn layout_replaced_with_children(
};
formatting_context::propagate_percentage_block_size_dependency_to_containing_block(
run.state,
- &run.callbacks,
+ &run.pass,
wrapper,
wrapper_result.depends_on_percentage_block_size,
);
diff --git a/Libraries/LibWeb/Rust/src/layout/run_repeatability.rs b/Libraries/LibWeb/Rust/src/layout/run_repeatability.rs
index eb160043acd..c0f9899135a 100644
--- a/Libraries/LibWeb/Rust/src/layout/run_repeatability.rs
+++ b/Libraries/LibWeb/Rust/src/layout/run_repeatability.rs
@@ -37,13 +37,13 @@ pub(super) fn verification_is_enabled() -> bool {
/// Lays out a run whose result is discarded through `run`, where the verification is on and no such run is in
/// progress around it already. Nothing it does is traced.
pub(super) fn lay_out_discarded_run(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
run: impl for<'discarded> FnOnce(LayoutPass<'discarded>) -> formatting_context::RunOutputs,
) -> Option<formatting_context::RunOutputs> {
- if run_repeatability_verification() == RunRepeatabilityVerification::Off || callbacks.reads_no_memoized_layout() {
+ if run_repeatability_verification() == RunRepeatabilityVerification::Off || pass.reads_no_memoized_layout() {
return None;
}
- Some(callbacks.lay_out_discarded_run(run))
+ Some(pass.lay_out_discarded_run(run))
}
/// Checks that the run of `box_` that produced `used` repeated what the discarded run that produced `discarded` did.
@@ -175,7 +175,7 @@ fn root_cells_at_other_block_margins(
}
pub(super) fn verify_run_ignores_its_unobserved_own_block_size_and_block_margins(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
box_: Node,
root_cells: used_values::RootInputCells,
input: &LayoutInput,
@@ -186,7 +186,7 @@ pub(super) fn verify_run_ignores_its_unobserved_own_block_size_and_block_margins
LayoutInput,
) -> formatting_context::RunOutputs,
) {
- if !unobserved_own_block_size_verification_is_enabled() || callbacks.reads_no_memoized_layout() {
+ if !unobserved_own_block_size_verification_is_enabled() || pass.reads_no_memoized_layout() {
return;
}
let checked = format!("the run of {box_:?}, which never observed its own block size or block margins,");
@@ -215,8 +215,7 @@ pub(super) fn verify_run_ignores_its_unobserved_own_block_size_and_block_margins
reference_inputs.push((cells, input.clone(), reference));
}
for (reference_cells, reference_input, reference) in reference_inputs {
- let reference_outputs =
- callbacks.lay_out_discarded_run(|callbacks| lay_out(callbacks, reference_cells, reference_input));
+ let reference_outputs = pass.lay_out_discarded_run(|pass| lay_out(pass, reference_cells, reference_input));
ComparedLayouts {
checked: &checked,
reference: &reference,
diff --git a/Libraries/LibWeb/Rust/src/layout/run_state.rs b/Libraries/LibWeb/Rust/src/layout/run_state.rs
index 82ce3ccc588..96005b7898a 100644
--- a/Libraries/LibWeb/Rust/src/layout/run_state.rs
+++ b/Libraries/LibWeb/Rust/src/layout/run_state.rs
@@ -328,14 +328,14 @@ impl RunState {
/// Runs `run` with what a run rooted at `root` keeps, and the pass as that run sees it. The style reads of an
/// absolutely positioned root see `root_anchor_resolved_values`.
pub(crate) fn with_root<R>(
- callbacks: LayoutPass<'_>,
+ pass: LayoutPass<'_>,
root: Node,
root_containing_block: Node,
root_anchor_resolved_values: Option<Box<style_values::AnchorResolvedValues>>,
run: impl for<'run> FnOnce(&'run Self, LayoutPass<'run>) -> R,
) -> R {
Self::enter(
- callbacks,
+ pass,
root,
root_containing_block,
root_anchor_resolved_values,
@@ -346,7 +346,7 @@ impl RunState {
}
pub(crate) fn with_root_building_fragments<R>(
- callbacks: LayoutPass<'_>,
+ pass: LayoutPass<'_>,
root: Node,
root_containing_block: Node,
root_anchor_resolved_values: Option<Box<style_values::AnchorResolvedValues>>,
@@ -354,7 +354,7 @@ impl RunState {
run: impl for<'run> FnOnce(&'run Self, LayoutPass<'run>) -> R,
) -> R {
Self::enter(
- callbacks,
+ pass,
root,
root_containing_block,
root_anchor_resolved_values,
@@ -365,13 +365,13 @@ impl RunState {
}
pub(crate) fn with_content_sizing_root<R>(
- callbacks: LayoutPass<'_>,
+ pass: LayoutPass<'_>,
root: Node,
root_containing_block: Node,
run: impl for<'run> FnOnce(&'run Self, LayoutPass<'run>) -> R,
) -> R {
Self::enter(
- callbacks,
+ pass,
root,
root_containing_block,
None,
@@ -382,13 +382,13 @@ impl RunState {
}
pub(crate) fn with_content_inline_sizes_root<R>(
- callbacks: LayoutPass<'_>,
+ pass: LayoutPass<'_>,
root: Node,
root_containing_block: Node,
run: impl for<'run> FnOnce(&'run Self, LayoutPass<'run>) -> R,
) -> R {
Self::enter(
- callbacks,
+ pass,
root,
root_containing_block,
None,
@@ -399,7 +399,7 @@ impl RunState {
}
fn enter<R>(
- callbacks: LayoutPass<'_>,
+ pass: LayoutPass<'_>,
root: Node,
root_containing_block: Node,
root_anchor_resolved_values: Option<Box<style_values::AnchorResolvedValues>>,
@@ -418,10 +418,7 @@ impl RunState {
host_findings: HostFindingsSink::default(),
fragments,
};
- run(
- &state,
- callbacks.for_run(root, root_containing_block, &state.host_findings),
- )
+ run(&state, pass.for_run(root, root_containing_block, &state.host_findings))
}
pub(crate) fn fragments(&self) -> Option<&fragment_tree::RunFragmentBuilder> {
@@ -540,15 +537,15 @@ mod tests {
root,
NodeSlotId::INVALID,
None,
- |parent, parent_callbacks| {
+ |parent, parent_pass| {
assert_eq!(parent.root(), root);
- let nested_findings = RunState::with_root(parent_callbacks, child, root, None, |nested, callbacks| {
+ let nested_findings = RunState::with_root(parent_pass, child, root, None, |nested, pass| {
assert_eq!(nested.root(), child);
assert!(nested.resolves_percentage_block_size_dependency_of(child));
assert!(!nested.resolves_percentage_block_size_dependency_of(root));
assert!(!parent.resolves_percentage_block_size_dependency_of(child));
assert!(nested.anchor_resolved_values_of(child).is_none());
- callbacks.note_host_findings(|findings| {
+ pass.note_host_findings(|findings| {
findings.document_svg_root_natural_size =
Some((child, crate::css::style::NaturalSize::default()));
});
diff --git a/Libraries/LibWeb/Rust/src/layout/sizing_context.rs b/Libraries/LibWeb/Rust/src/layout/sizing_context.rs
index 066549fc2be..b961c8daf62 100644
--- a/Libraries/LibWeb/Rust/src/layout/sizing_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/sizing_context.rs
@@ -225,19 +225,16 @@ impl<'cells> SizedCells<'cells> {
}
pub(crate) fn measure_ahead<J: Send>(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
jobs: Vec<J>,
root_of: impl Fn(&J) -> Node + Sync,
measure: impl Fn(&SizingContext<'_, '_>, J) + Sync,
) {
- let _ = parallel_layout::lay_out_in_parallel(callbacks, jobs, &root_of, |callbacks, job| {
+ let _ = parallel_layout::lay_out_in_parallel(pass, jobs, &root_of, |pass, job| {
let root = root_of(&job);
- RunState::with_content_inline_sizes_root(
- callbacks,
- root,
- callbacks.in_flow_containing_block(root),
- |state, _| measure(&SizingContext::new(state, callbacks), job),
- );
+ RunState::with_content_inline_sizes_root(pass, root, pass.in_flow_containing_block(root), |state, _| {
+ measure(&SizingContext::new(state, pass), job);
+ });
});
}
@@ -249,7 +246,7 @@ pub(crate) struct ContentInlineSizeMeasurementAhead {
pub(crate) struct SizingContext<'pass, 'container> {
state: &'pass RunState,
- callbacks: LayoutPass<'pass>,
+ pass: LayoutPass<'pass>,
child_run_shapes: Option<&'container dyn formatting_context::ChildRunShapes>,
}
@@ -262,30 +259,29 @@ pub(crate) fn is_plain_auto(size: &ComputedSize) -> bool {
/// `margin_basis`.
/// https://drafts.csswg.org/css-sizing-3/#stretch-fit-sizing
pub(crate) fn stretch_fit_block_margins(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
node: Node,
margin_basis: CssPixels,
) -> (CssPixels, CssPixels) {
- let style = StyleValues::for_node(callbacks, node);
+ let style = StyleValues::for_node(pass, node);
let mut margin_top = style.margin_top().to_px(margin_basis);
let mut margin_bottom = style.margin_bottom().to_px(margin_basis);
// For in-flow block-level boxes when resolving the block axis size: if the ancestor element percentages resolve
// against does not have a block-start border or padding and is not an independent formatting context, treat the
// element's block-start margin as zero for the purpose of calculating this size. Do the same for the block-end
// margin, analogously.
- let facts = NodeFacts::new(callbacks, node);
+ let facts = NodeFacts::new(pass, node);
if !(facts.is_in_flow() && !facts.is_inline() && facts.parent_is_unfloated_flow_container()) {
return (margin_top, margin_bottom);
}
- let containing_block = callbacks.in_flow_containing_block(node);
+ let containing_block = pass.in_flow_containing_block(node);
if containing_block.is_invalid()
- || formatting_context::formatting_context_type_created_by_box(NodeFacts::new(callbacks, containing_block))
- .is_some()
+ || formatting_context::formatting_context_type_created_by_box(NodeFacts::new(pass, containing_block)).is_some()
{
return (margin_top, margin_bottom);
}
// NB: The containing block's used values belong to another run, so its padding is resolved from its style.
- let containing_block_style = StyleValues::for_node(callbacks, containing_block);
+ let containing_block_style = StyleValues::for_node(pass, containing_block);
if containing_block_style.border_top_width() == CssPixels::default()
&& containing_block_style.padding_top().to_px(margin_basis) == CssPixels::default()
{
@@ -301,10 +297,10 @@ pub(crate) fn stretch_fit_block_margins(
impl<'pass, 'container> SizingContext<'pass, 'container> {
#[inline]
- pub(crate) fn new(state: &'pass RunState, callbacks: LayoutPass<'pass>) -> Self {
+ pub(crate) fn new(state: &'pass RunState, pass: LayoutPass<'pass>) -> Self {
Self {
state,
- callbacks,
+ pass,
child_run_shapes: None,
}
}
@@ -319,17 +315,17 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
}
}
- pub(super) fn callbacks(&self) -> &LayoutPass<'pass> {
- &self.callbacks
+ pub(super) fn pass(&self) -> &LayoutPass<'pass> {
+ &self.pass
}
#[inline]
pub(super) fn facts(&self, node: Node) -> NodeFacts<'_> {
- NodeFacts::new(&self.callbacks, node)
+ NodeFacts::new(&self.pass, node)
}
pub(super) fn style(&self, node: Node) -> StyleValues<'pass> {
- let style = StyleValues::for_node(&self.callbacks, node);
+ let style = StyleValues::for_node(&self.pass, node);
if !style.is_absolutely_positioned() {
return style;
}
@@ -337,7 +333,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
}
fn first_child(&self, node: Node) -> Node {
- self.callbacks.first_child(node)
+ self.pass.first_child(node)
}
/// Whether a box without children can still have an intrinsic size, as a grid container does from its tracks.
@@ -347,13 +343,11 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
}
fn has_children(&self, node: Node) -> bool {
- !self.callbacks.first_child(node).is_invalid()
+ !self.pass.first_child(node).is_invalid()
}
fn contains_only_text(&self, node: Node) -> bool {
- self.callbacks
- .children(node)
- .all(|child| self.facts(child).is_text_node())
+ self.pass.children(node).all(|child| self.facts(child).is_text_node())
}
/// Whether the content inline sizes of `root` may read its block size: the root takes its inline size from it, or
@@ -367,7 +361,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
if container != root && self.facts(container).is_svg_svg_box() {
continue;
}
- for child in self.callbacks.children(container) {
+ for child in self.pass.children(container) {
let facts = self.facts(child);
if facts.is_text_node() || facts.is_absolutely_positioned() {
continue;
@@ -499,7 +493,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
fn default_replaced_size(&self, axis: SizingAxis) -> CssPixels {
// NB: The 300px by 150px default object size is physical, while sizing uses the current frame's axes.
- let physical_width = matches!(axis, SizingAxis::Inline) != self.callbacks.frame.is_transposed();
+ let physical_width = matches!(axis, SizingAxis::Inline) != self.pass.frame.is_transposed();
CssPixels::from_integer(if physical_width { 300 } else { 150 })
}
@@ -1263,7 +1257,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
if !facts.is_anonymous() || !facts.is_block_container() || facts.is_table_wrapper() {
return false;
}
- let parent = self.callbacks.parent(node);
+ let parent = self.pass.parent(node);
if parent.is_invalid() {
return false;
}
@@ -1508,7 +1502,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
}
let marker_content_may_read_its_containing_block_inline_size = style.text_indent().contains_percentage()
|| self
- .callbacks
+ .pass
.children(marker)
.any(|content| self.facts(content).is_replaced_box());
marker_content_may_read_its_containing_block_inline_size && self.is_anonymous_block_box_in_block_flow(marker)
@@ -1535,10 +1529,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
}
self.state.note_box_depends_on_percentage_block_size(node);
formatting_context::propagate_percentage_block_size_dependency_to_containing_block(
- self.state,
- &self.callbacks,
- node,
- true,
+ self.state, &self.pass, node, true,
);
}
@@ -2016,12 +2007,12 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
}
return self.measure_intrinsic_block_size(content_box, other_axis_size, content_constraints);
}
- let mut root = used_values::cells_before_sizing(&self.callbacks, node, constraints);
+ let mut root = used_values::cells_before_sizing(&self.pass, node, constraints);
root.set_content_inline_size(other_axis_size);
root.set_content_block_size(transferred_size);
root.has_definite_block_size = true;
let result = formatting_context::lay_out_measurement_root_for_its_result(
- self.callbacks,
+ self.pass,
node,
root,
LayoutInput::new(
@@ -2277,7 +2268,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
return false;
}
let used = sized_cells.cells;
- self.callbacks
+ self.pass
.arena()
.with_current_committed_fragment_link(node, |link| {
used.update_cells(|cells| cells.take_box_metrics_of_committed_link(link));
@@ -2523,19 +2514,19 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
available_block_size: AvailableSize,
constraints: ContainingBlockConstraints,
) -> OuterInlineContributions {
- let mut root = used_values::cells_before_sizing(&self.callbacks, node, constraints);
+ let mut root = used_values::cells_before_sizing(&self.pass, node, constraints);
let indefinite_inline_basis = CssPixels::default();
root.resolve_box_model(&self.style(node), indefinite_inline_basis);
let (contributions, percentage_block_size_dependency_its_layout_would_report) =
RunState::with_content_sizing_root(
- self.callbacks,
+ self.pass,
node,
- self.callbacks.in_flow_containing_block(node),
- |state, callbacks| {
- let sizing = SizingContext::new(state, callbacks);
+ self.pass.in_flow_containing_block(node),
+ |state, pass| {
+ let sizing = SizingContext::new(state, pass);
let inline_size_under = |inline_size| {
sizing.atomic_root_content_inline_size(
- SizedBox::of_own_metrics(node, &root, callbacks.frame),
+ SizedBox::of_own_metrics(node, &root, pass.frame),
AvailableSpace {
inline_size,
block_size: available_block_size,
@@ -2565,7 +2556,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
);
formatting_context::propagate_percentage_block_size_dependency_to_containing_block(
self.state,
- &self.callbacks,
+ &self.pass,
node,
percentage_block_size_dependency_its_layout_would_report,
);
@@ -2635,7 +2626,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
/// Whether `node` lays out its contents in a frame orthogonal to the one this context sizes it in.
pub(crate) fn establishes_orthogonal_flow(&self, node: Node) -> bool {
- formatting_context::frame_established_by(&self.callbacks, node).is_orthogonal_to(self.callbacks.frame)
+ formatting_context::frame_established_by(&self.pass, node).is_orthogonal_to(self.pass.frame)
}
fn intrinsic_size_cache_key(
@@ -2648,7 +2639,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
percentage_basis_inline_size: constraints.percentage_basis_inline_size,
percentage_basis_block_size: constraints.percentage_basis_block_size,
quirks_mode_percentage_basis_block_size: constraints.quirks_mode_percentage_basis_block_size,
- measured_in_transposed_frame: self.callbacks.frame.is_transposed(),
+ measured_in_transposed_frame: self.pass.frame.is_transposed(),
}
}
@@ -2658,7 +2649,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
key: IntrinsicSizeCacheKey,
) -> Option<IntrinsicBlockSizeMeasurement> {
let measurement = self
- .callbacks
+ .pass
.intrinsic_size_caches()
.max_content_block_size_cache_get(node, key)?;
self.charge_measurement_dependency_to_measured_box_and_containing_block(
@@ -2678,7 +2669,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
node,
value.depends_on_percentage_block_size,
);
- self.callbacks
+ self.pass
.intrinsic_size_caches()
.max_content_block_size_cache_put(node, key, value);
}
@@ -2689,7 +2680,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
key: IntrinsicSizeCacheKey,
) -> Option<IntrinsicInlineSizeMeasurement> {
let measurement = self
- .callbacks
+ .pass
.intrinsic_size_caches()
.intrinsic_inline_size_measurement_cache_get(node, key)?;
self.charge_measurement_dependency_to_measured_box_and_containing_block(
@@ -2709,7 +2700,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
node,
value.depends_on_percentage_block_size,
);
- self.callbacks
+ self.pass
.intrinsic_size_caches()
.intrinsic_inline_size_measurement_cache_put(node, key, value);
}
@@ -3259,7 +3250,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
let node = sized.node;
let key = self.intrinsic_size_cache_key(block_size, constraints);
if self
- .callbacks
+ .pass
.intrinsic_size_caches()
.intrinsic_inline_size_measurement_cache_get(node, key)
.is_some()
@@ -3298,7 +3289,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
pub(crate) fn measure_content_inline_sizes_ahead(&self, measurements: Vec<ContentInlineSizeMeasurementAhead>) {
measure_ahead(
- &self.callbacks,
+ &self.pass,
measurements,
|measurement| measurement.node,
|sizing, measurement| sizing.measure_content_inline_sizes(measurement),
@@ -3319,54 +3310,54 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
}
let key = self.intrinsic_size_cache_key(block_size, constraints);
if let Some(cached) = self.intrinsic_inline_measurement_cache_get(node, key) {
- self.callbacks.layout_trace().intrinsic_size_hit(node, kind);
+ self.pass.layout_trace().intrinsic_size_hit(node, kind);
return ContentInlineSizeAnswers::from_measurement(cached);
}
- let trace = self.callbacks.layout_trace().intrinsic_size_miss(node, kind);
- let scope = || intrinsic_sizing::ContentSizingScope::new(&self.callbacks, node, constraints, block_size);
+ let trace = self.pass.layout_trace().intrinsic_size_miss(node, kind);
+ let scope = || intrinsic_sizing::ContentSizingScope::new(&self.pass, node, constraints, block_size);
let facts = self.facts(node);
let (source, mut sizes) = if self.establishes_orthogonal_flow(node) {
(
"ORTHOGONAL FLOW",
- intrinsic_sizing::content_sizes_of_orthogonal_flow(self.callbacks, &scope(), constraints),
+ intrinsic_sizing::content_sizes_of_orthogonal_flow(self.pass, &scope(), constraints),
)
} else if facts.is_table_wrapper() {
(
"COLUMNS",
- intrinsic_sizing::content_sizes_of_table(self.callbacks, &scope(), constraints),
+ intrinsic_sizing::content_sizes_of_table(self.pass, &scope(), constraints),
)
} else {
- match formatting_context::independent_formatting_context_type(node, &self.callbacks) {
+ match formatting_context::independent_formatting_context_type(node, &self.pass) {
formatting_context::FormattingContextType::Block if facts.children_are_inline() => (
"ITEMS",
- intrinsic_sizing::content_sizes_of_inline_content(self.callbacks, &scope(), constraints),
+ intrinsic_sizing::content_sizes_of_inline_content(self.pass, &scope(), constraints),
),
formatting_context::FormattingContextType::Block => (
"CHILDREN",
- intrinsic_sizing::content_sizes_of_block_container(self.callbacks, &scope(), constraints),
+ intrinsic_sizing::content_sizes_of_block_container(self.pass, &scope(), constraints),
),
formatting_context::FormattingContextType::Table => (
"COLUMNS",
- intrinsic_sizing::content_sizes_of_table(self.callbacks, &scope(), constraints),
+ intrinsic_sizing::content_sizes_of_table(self.pass, &scope(), constraints),
),
formatting_context::FormattingContextType::Flex => (
"FLEX ITEMS",
- intrinsic_sizing::content_sizes_of_flex_container(self.callbacks, node, constraints, block_size),
+ intrinsic_sizing::content_sizes_of_flex_container(self.pass, node, constraints, block_size),
),
formatting_context::FormattingContextType::Grid => (
"GRID TRACKS",
- intrinsic_sizing::content_sizes_of_grid_container(self.callbacks, node, constraints, block_size),
+ intrinsic_sizing::content_sizes_of_grid_container(self.pass, node, constraints, block_size),
),
formatting_context::FormattingContextType::Svg
| formatting_context::FormattingContextType::InternalReplaced
| formatting_context::FormattingContextType::ReplacedWithChildren => (
"REPLACED CONTENT",
- intrinsic_sizing::content_sizes_of_replaced_content(self.callbacks, &scope()),
+ intrinsic_sizing::content_sizes_of_replaced_content(self.pass, &scope()),
),
formatting_context::FormattingContextType::Math => (
"MATH LAYOUT",
- intrinsic_sizing::content_sizes_of_math(self.callbacks, &scope(), constraints),
+ intrinsic_sizing::content_sizes_of_math(self.pass, &scope(), constraints),
),
}
};
@@ -3420,16 +3411,16 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
let kind = IntrinsicSizeCacheKind::MaxContentBlock;
let key = self.intrinsic_size_cache_key(Some(inline_size), constraints);
if let Some(cached) = self.max_content_block_size_cache_get(node, key) {
- self.callbacks.layout_trace().intrinsic_size_hit(node, kind);
+ self.pass.layout_trace().intrinsic_size_hit(node, kind);
return cached.size;
}
let result = if let Some(child_run_shapes) = self.child_run_shapes
&& let Some(shape) = child_run_shapes.child_run_shape_at(node, inline_size, constraints)
{
- formatting_context::lay_out_shape_for_its_result(self.callbacks, shape)
+ formatting_context::lay_out_shape_for_its_result(self.pass, shape)
} else {
- let _trace = self.callbacks.layout_trace().intrinsic_size_miss(node, kind);
+ let _trace = self.pass.layout_trace().intrinsic_size_miss(node, kind);
self.measure_block_size_with_normal_layout(node, inline_size, constraints)
};
let value = clamp_to_max_dimension_value(result.automatic_content_block_size);
@@ -3454,7 +3445,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
let node = sized.node;
let key = self.intrinsic_size_cache_key(Some(inline_size), constraints);
if self
- .callbacks
+ .pass
.intrinsic_size_caches()
.max_content_block_size_cache_get(node, key)
.is_some()
@@ -3481,7 +3472,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
.child_run_shapes
.and_then(|child_run_shapes| child_run_shapes.child_run_shape_at(node, inline_size, constraints))
.unwrap_or_else(|| self.normal_layout_measurement_shape(node, inline_size, constraints));
- (!formatting_context::shape_would_reuse_stored_run(&self.callbacks, &shape)).then_some(shape)
+ (!formatting_context::shape_would_reuse_stored_run(&self.pass, &shape)).then_some(shape)
}
fn normal_layout_measurement_shape(
@@ -3490,7 +3481,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
inline_size: CssPixels,
constraints: ContainingBlockConstraints,
) -> formatting_context::ChildRunShape {
- let mut root = used_values::cells_before_sizing(&self.callbacks, node, constraints);
+ let mut root = used_values::cells_before_sizing(&self.pass, node, constraints);
root.has_definite_block_size = false;
root.set_content_inline_size(inline_size);
let mut input = LayoutInput::new(
@@ -3502,10 +3493,10 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
ParticipationInParentFormattingContext::Root,
);
input.sizing.root_is_measured_for_its_content_block_size = matches!(
- formatting_context::independent_formatting_context_type(node, &self.callbacks),
+ formatting_context::independent_formatting_context_type(node, &self.pass),
formatting_context::FormattingContextType::Flex | formatting_context::FormattingContextType::Grid
);
- formatting_context::ChildRunShape::of_measurement_root(&self.callbacks, node, root, input)
+ formatting_context::ChildRunShape::of_measurement_root(&self.pass, node, root, input)
}
fn measure_block_size_with_normal_layout(
@@ -3515,7 +3506,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
constraints: ContainingBlockConstraints,
) -> formatting_context::ChildLayoutResult {
formatting_context::lay_out_shape_for_its_result(
- self.callbacks,
+ self.pass,
self.normal_layout_measurement_shape(node, inline_size, constraints),
)
}
@@ -3531,8 +3522,8 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
kind: IntrinsicSizeCacheKind,
) -> CssPixels {
let node = sized.node;
- let own_frame = formatting_context::frame_established_by(&self.callbacks, node);
- let sizing = SizingContext::new(self.state, self.callbacks.in_frame_of(own_frame.writing_mode()));
+ let own_frame = formatting_context::frame_established_by(&self.pass, node);
+ let sizing = SizingContext::new(self.state, self.pass.in_frame_of(own_frame.writing_mode()));
let constraints_in_own_frame = ContainingBlockConstraints {
percentage_basis_inline_size: constraints.percentage_basis_block_size,
percentage_basis_block_size: constraints.percentage_basis_inline_size,
@@ -3541,9 +3532,9 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
// NB: The box's own metrics are read in the box's own frame. Cells its parent sizes it in are read as they are.
let own_metrics_in_own_frame = sized
.own_metrics_frame
- .map(|held_in| sized.metrics().cells().in_frame(held_in, sizing.callbacks.frame));
+ .map(|held_in| sized.metrics().cells().in_frame(held_in, sizing.pass.frame));
let sized_in_own_frame = match &own_metrics_in_own_frame {
- Some(cells) => SizedBox::of_own_metrics(node, cells, sizing.callbacks.frame),
+ Some(cells) => SizedBox::of_own_metrics(node, cells, sizing.pass.frame),
None => sized,
};
let answer = sizing.content_inline_size(sized_in_own_frame, constraints_in_own_frame, Some(inline_size), kind);
@@ -3673,9 +3664,9 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
);
}
formatting_context::lay_out_measurement_root_for_its_result(
- self.callbacks,
+ self.pass,
node,
- used_values::cells_before_sizing(&self.callbacks, node, constraints),
+ used_values::cells_before_sizing(&self.pass, node, constraints),
LayoutInput::new(
inner_available_space,
constraints,
@@ -3782,7 +3773,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
pub(crate) fn table_box_inside_wrapper(&self, wrapper: Node) -> Node {
fn find(context: &SizingContext, parent: Node) -> Option<Node> {
- context.callbacks.children(parent).find_map(|child| {
+ context.pass.children(parent).find_map(|child| {
let facts = context.facts(child);
if facts.is_box() && facts.display().is_table_inside() {
return Some(child);
@@ -3802,7 +3793,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
size_table: impl FnOnce(&FormattingContextRun<'_>, used_values::RootInputCells) -> R,
) -> R {
let table_box = self.table_box_inside_wrapper(wrapper);
- let mut table_cells = used_values::cells_before_sizing(&self.callbacks, table_box, table_constraints);
+ let mut table_cells = used_values::cells_before_sizing(&self.pass, table_box, table_constraints);
let table_style = self.style(table_box);
table_cells.border_left = table_style.border_left_width();
table_cells.border_right = table_style.border_right_width();
@@ -3810,14 +3801,14 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
table_cells.padding_right = table_style.padding_right().to_px(padding_percentage_basis);
RunState::with_content_sizing_root(
- self.callbacks,
+ self.pass,
table_box,
- self.callbacks.in_flow_containing_block(table_box),
- |state, callbacks| {
+ self.pass.in_flow_containing_block(table_box),
+ |state, pass| {
let table_run = FormattingContextRun {
state,
box_: table_box,
- callbacks,
+ pass,
should_collect_devtools_layout_data: false,
treat_block_axis_percentage_insets_as_auto_beyond_root: false,
fragments: None,
@@ -3936,7 +3927,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
);
formatting_context::propagate_percentage_block_size_dependency_to_containing_block(
self.state,
- &self.callbacks,
+ &self.pass,
table_box,
table_depends_on_percentage_block_size,
);
@@ -3966,7 +3957,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
let wrapper_inner_space = sized
.metrics()
.available_inner_space_or_constraints_from(available_space);
- let mut wrapper_cells = used_values::cells_before_sizing(&self.callbacks, wrapper, table_wrapper_constraints);
+ let mut wrapper_cells = used_values::cells_before_sizing(&self.pass, wrapper, table_wrapper_constraints);
if let AvailableSize::Definite(inline_size) = wrapper_inner_space.inline_size {
wrapper_cells.set_content_inline_size(inline_size);
}
@@ -3976,7 +3967,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
wrapper_cells.has_definite_block_size = false;
}
let wrapper_outputs = formatting_context::lay_out_measurement_root_for_its_result(
- self.callbacks,
+ self.pass,
wrapper,
wrapper_cells,
LayoutInput::new(
@@ -4125,7 +4116,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
+ style.border_right_width(),
),
SizingAxis::Block => {
- let (margin_top, margin_bottom) = stretch_fit_block_margins(&self.callbacks, node, margin_basis);
+ let (margin_top, margin_bottom) = stretch_fit_block_margins(&self.pass, node, margin_basis);
(
margin_top + margin_bottom,
style.border_top_width()
@@ -4148,10 +4139,10 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
) -> CssPixels {
let node = sized.node;
let style = self.style(node);
- let initial_containing_block_size = if self.callbacks.frame.is_transposed() {
- self.callbacks.initial_containing_block_block_size
+ let initial_containing_block_size = if self.pass.frame.is_transposed() {
+ self.pass.initial_containing_block_block_size
} else {
- self.callbacks.initial_containing_block_inline_size
+ self.pass.initial_containing_block_inline_size
};
// https://drafts.csswg.org/css-writing-modes-4/#orthogonal-auto
// In these cases, an additional constraint is used as a fallback in place of the available inline space for
@@ -4164,7 +4155,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
let fixed_size = |size: &ComputedSize| {
(size.is_length_percentage() && !size.contains_percentage()).then(|| size.to_px(CssPixels::default()))
};
- let containing_block = self.callbacks.in_flow_containing_block(node);
+ let containing_block = self.pass.in_flow_containing_block(node);
let mut scrollport_size = None;
let mut ancestor = containing_block;
while !ancestor.is_invalid() {
@@ -4191,7 +4182,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
.map(|size| minimum.map_or(size, |minimum| size.max(minimum)));
break;
}
- ancestor = self.callbacks.parent(ancestor);
+ ancestor = self.pass.parent(ancestor);
}
let scrollport_and_initial_containing_block_size = scrollport_size
.map_or(initial_containing_block_size, |size| {
@@ -4562,7 +4553,7 @@ mod replaced_ratio_tests {
},
);
let host_findings_outside_runs = crate::layout::run_state::HostFindingsSink::default();
- let callbacks = LayoutPass::new(
+ let pass = LayoutPass::new(
&arena,
&scratch,
&host_findings_outside_runs,
@@ -4572,8 +4563,8 @@ mod replaced_ratio_tests {
document_in_quirks_mode: false,
},
);
- let result = RunState::with_root(callbacks, node, Node::INVALID, None, |state, callbacks| {
- let context = SizingContext::new(state, callbacks);
+ let result = RunState::with_root(pass, node, Node::INVALID, None, |state, pass| {
+ let context = SizingContext::new(state, pass);
let mut metrics = used_values::RootInputCells::default();
let available = AvailableSpace {
inline_size: AvailableSize::Definite(CssPixels::from_integer(800)),
diff --git a/Libraries/LibWeb/Rust/src/layout/style_values.rs b/Libraries/LibWeb/Rust/src/layout/style_values.rs
index 6dee978ba9f..833d8d7c623 100644
--- a/Libraries/LibWeb/Rust/src/layout/style_values.rs
+++ b/Libraries/LibWeb/Rust/src/layout/style_values.rs
@@ -221,11 +221,11 @@ impl<'a> StyleValues<'a> {
}
#[inline]
- pub(crate) fn for_node(callbacks: &LayoutPass<'a>, node: Node) -> Self {
- let (data, style) = callbacks.row_and_style(node);
+ pub(crate) fn for_node(pass: &LayoutPass<'a>, node: Node) -> Self {
+ let (data, style) = pass.row_and_style(node);
StyleValues::new(style.expect("styled node must publish its style container before layout"))
.for_kind(data.kind.get())
- .in_frame(callbacks.frame)
+ .in_frame(pass.frame)
}
/// The view as seen from `frame`, whose sides and axes the box's sizes and box model properties are read in.
diff --git a/Libraries/LibWeb/Rust/src/layout/svg_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/svg_formatting_context.rs
index 520245dd4ce..c80ecb6804f 100644
--- a/Libraries/LibWeb/Rust/src/layout/svg_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/svg_formatting_context.rs
@@ -633,19 +633,19 @@ impl<'pass> SvgFormattingContext<'pass> {
}
fn first_child(&self, node: Node) -> Node {
- self.run.callbacks.node_data(node).first_child.get()
+ self.run.pass.node_data(node).first_child.get()
}
fn next_sibling(&self, node: Node) -> Node {
- self.run.callbacks.node_data(node).next_sibling.get()
+ self.run.pass.node_data(node).next_sibling.get()
}
fn parent(&self, node: Node) -> Node {
- self.run.callbacks.node_data(node).parent.get()
+ self.run.pass.node_data(node).parent.get()
}
fn node_kind(&self, node: Node) -> NodeKind {
- self.run.callbacks.node_data(node).kind.get()
+ self.run.pass.node_data(node).kind.get()
}
}
@@ -1253,7 +1253,7 @@ impl<'pass> SvgFormattingContext<'pass> {
/// The geometry a shape element draws, in the user units of the viewport it sits in.
fn svg_geometry_path(&self, node: Node) -> libgfx_rust::path::Path {
- let points = self.run.callbacks.arena().svg_points(node);
+ let points = self.run.pass.arena().svg_points(node);
self.shape_geometry()
.path(self.svg_attributes(node), self.style(node), points.as_deref())
}
@@ -1266,7 +1266,7 @@ impl<'pass> SvgFormattingContext<'pass> {
SVG_LENGTH_KIND_PERCENTAGE => {
CssPixels::truncated_value_for(reference.to_double() * value.value / 100.0).to_float()
}
- SVG_LENGTH_KIND_LENGTH => resolve_svg_length(&self.run.callbacks, node, value).to_float(),
+ SVG_LENGTH_KIND_LENGTH => resolve_svg_length(&self.run.pass, node, value).to_float(),
_ => 0.0,
}
}
@@ -1277,7 +1277,7 @@ impl<'pass> SvgFormattingContext<'pass> {
/// text the row kept beside its rendering.
fn svg_text_contents(&self, node: Node) -> Vec<u16> {
let mut text: Vec<u16> = Vec::new();
- for child in self.run.callbacks.children(node) {
+ for child in self.run.pass.children(node) {
if node_facts::kind_is_text(self.node_kind(child)) {
self.append_svg_source_text(child, &mut text);
}
@@ -1322,7 +1322,7 @@ impl<'pass> SvgFormattingContext<'pass> {
}
fn append_svg_source_text(&self, text_node: Node, out: &mut Vec<u16>) {
- let content = self.run.callbacks.arena().text_content(text_node);
+ let content = self.run.pass.arena().text_content(text_node);
debug_assert!(content.is_some(), "SVG text child was not synced before layout");
if let Some(source) = content.and_then(|content| content.svg_source_text.as_deref()) {
out.extend_from_slice(source);
@@ -1665,7 +1665,7 @@ impl<'pass> SvgFormattingContext<'pass> {
/// published rather than from a box: a `<textPath>`'s target is normally a `<path>` inside a
/// `<defs>`, and a `<defs>` builds no box at all.
fn svg_referenced_shape_path(&self, referring_box: Node) -> Option<libgfx_rust::path::Path> {
- let arena = self.run.callbacks.arena();
+ let arena = self.run.pass.arena();
let referrer = arena.node_style_node(referring_box)?;
let atom = self.svg_attributes(referring_box).reference_fragment_atom;
let shape = arena.element_by_svg_reference(referrer, atom)?;
@@ -1684,14 +1684,14 @@ impl<'pass> SvgFormattingContext<'pass> {
}
fn svg_attributes(&self, node: Node) -> FfiSvgAttributeFacts {
- self.run.callbacks.arena().svg_attribute_facts(node)
+ self.run.pass.arena().svg_attribute_facts(node)
}
fn svg_facts(&self, node: Node) -> SvgElementFacts {
- let data = self.run.callbacks.node_data(node);
+ let data = self.run.pass.node_data(node);
let mut facts = SvgElementFacts {
is_document_element: node_facts::has_flag(data, NodeFlag::IsDocumentElement),
- document_is_decoded_svg: self.run.callbacks.arena().document_is_decoded_svg(),
+ document_is_decoded_svg: self.run.pass.arena().document_is_decoded_svg(),
..Default::default()
};
// Everything below is a graphics element's business; a <mask> or <clipPath> box answers
@@ -1722,7 +1722,7 @@ impl<'pass> SvgFormattingContext<'pass> {
node: Node,
matches: impl Fn(FfiSvgAttributeFacts) -> bool,
) -> Option<StyleNodeID> {
- let arena = self.run.callbacks.arena();
+ let arena = self.run.pass.arena();
let mut style_node = arena
.node_style_node(node)
.and_then(|style_node| arena.flat_tree_parent(style_node));
@@ -1740,7 +1740,7 @@ impl<'pass> SvgFormattingContext<'pass> {
/// Percentages resolve against nothing here, since layout has not sized the element yet when a
/// descendant asks.
fn svg_viewport_element_size(&self, element: StyleNodeID) -> FfiCssPixelSize {
- let arena = self.run.callbacks.arena();
+ let arena = self.run.pass.arena();
let attributes = arena.style_node_svg_attribute_facts(element);
if attributes.has_active_view_box {
return FfiCssPixelSize {
@@ -1831,7 +1831,7 @@ impl<'pass> SvgFormattingContext<'pass> {
#[inline]
fn style(&self, node: Node) -> StyleValues<'_> {
- StyleValues::for_node(&self.run.callbacks, node)
+ StyleValues::for_node(&self.run.pass, node)
}
/// Cells for `node`, a box this context lays out in them.
@@ -1840,7 +1840,7 @@ impl<'pass> SvgFormattingContext<'pass> {
// SVG layout resolves percentages against the SVG viewport, not a CSS containing
// block, so boxes inside the SVG subtree carry no percentage basis.
Cell::new(used_values::cells_before_sizing(
- &self.run.callbacks,
+ &self.run.pass,
node,
ContainingBlockConstraints::default(),
))
@@ -1932,7 +1932,7 @@ impl<'pass> SvgFormattingContext<'pass> {
fn first_child_of_kind(&self, node: Node, kind: NodeKind) -> Option<Node> {
self.run
- .callbacks
+ .pass
.children(node)
.find(|&child| self.node_kind(child) == kind)
}
@@ -2039,7 +2039,7 @@ impl<'pass> SvgFormattingContext<'pass> {
self.viewport_is_committed_viewport = kind == NodeKind::SVGSVGBox
&& self.run.fragments.is_some()
&& crate::painting::paint_read::GeometryRead::with_committed_fragment_link(
- self.run.callbacks.arena(),
+ self.run.pass.arena(),
self.run.box_,
|link| {
link.is_some_and(|link| {
@@ -2058,8 +2058,8 @@ impl<'pass> SvgFormattingContext<'pass> {
.containing_block_constraints
.quirks_mode_percentage_basis_block_size;
- for child in self.run.callbacks.children(self.run.box_) {
- if NodeFacts::new(&self.run.callbacks, child).is_box() {
+ for child in self.run.pass.children(self.run.box_) {
+ if NodeFacts::new(&self.run.pass, child).is_box() {
self.layout_svg_element(run, child);
}
}
@@ -2073,7 +2073,7 @@ impl<'pass> SvgFormattingContext<'pass> {
} else if kind == NodeKind::SVGForeignObjectBox {
// SVG descendants carry no percentage basis, as `cells_of_svg_box` explains.
let mut child_cells =
- used_values::cells_before_sizing(&self.run.callbacks, child, ContainingBlockConstraints::default());
+ used_values::cells_before_sizing(&self.run.pass, child, ContainingBlockConstraints::default());
let style = self.style(child);
let rect = SvgCssPixelRect {
x: style.x().to_px(self.viewport_width),
@@ -2203,7 +2203,7 @@ impl<'pass> SvgFormattingContext<'pass> {
if let Some(clip) = self.first_child_of_kind(graphics_box, NodeKind::SVGClipBox) {
self.layout_mask_or_clip(run, clip, &laid_out.cells);
}
- for child in self.run.callbacks.children(graphics_box) {
+ for child in self.run.pass.children(graphics_box) {
if self.node_kind(child) == NodeKind::SVGPatternBox {
self.layout_mask_or_clip(run, child, &laid_out.cells);
}
@@ -2236,7 +2236,7 @@ impl<'pass> SvgFormattingContext<'pass> {
// A committed fragment stops being current when something marks its box for layout.
let link = self
.run
- .callbacks
+ .pass
.arena()
.with_current_committed_fragment_link(shape, |link| link.clone())?;
let fragment = link.fragment.clone();
@@ -2313,7 +2313,7 @@ impl<'pass> SvgFormattingContext<'pass> {
if kind == NodeKind::SVGTextBox {
// <text> and <tspan> elements can contain more text elements, whose glyph cells count toward this box too.
- for child in self.run.callbacks.children(graphics_box) {
+ for child in self.run.pass.children(graphics_box) {
if matches!(self.node_kind(child), NodeKind::SVGTextBox | NodeKind::SVGTextPathBox) {
let laid_out_child = self.layout_graphics_element(run, child);
let offset = laid_out_child.content_offset;
@@ -2353,7 +2353,7 @@ impl<'pass> SvgFormattingContext<'pass> {
let facts = self
.run
- .callbacks
+ .pass
.arena()
.replaced_content_facts(image_box)
.unwrap_or_default();
@@ -2456,9 +2456,9 @@ impl<'pass> SvgFormattingContext<'pass> {
let mut min_y = CssPixels::default();
let mut max_x = CssPixels::default();
let mut max_y = CssPixels::default();
- for child in self.run.callbacks.children(container) {
+ for child in self.run.pass.children(container) {
// Masks/clips/patterns do not change the bounding box of their parents.
- if NodeFacts::new(&self.run.callbacks, child).is_box()
+ if NodeFacts::new(&self.run.pass, child).is_box()
&& !node_facts::kind_is_svg_resource_box(self.node_kind(child))
{
let laid_out_child = self
@@ -2521,26 +2521,26 @@ fn font_metrics_for_length_resolution(style: StyleValues<'_>) -> crate::css::sty
/// What a length one of an SVG element's attributes gives resolves against: the element's own style,
/// the document element's, and the viewport.
fn length_resolution_context(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
node: Node,
unit: u8,
) -> crate::css::style_compute::FfiLengthResolutionContext {
- let style = StyleValues::for_node(callbacks, node);
- let root_style = document_element_style(callbacks, node).unwrap_or(style);
- let viewport_width = callbacks.initial_containing_block_inline_size.to_double();
- let viewport_height = callbacks.initial_containing_block_block_size.to_double();
+ let style = StyleValues::for_node(pass, node);
+ let root_style = document_element_style(pass, node).unwrap_or(style);
+ let viewport_width = pass.initial_containing_block_inline_size.to_double();
+ let viewport_height = pass.initial_containing_block_block_size.to_double();
// A container unit resolves against the committed content box of the nearest size query container on its axis, or
// the viewport without one. Finding that container is style's business, so it is asked only for a length that
// needs it, and the host hears which containers the lengths depend on once the layout is committed.
let container_bases = crate::css::style_compute::length_unit_is_container_relative(unit).then(|| {
- let element = callbacks
+ let element = pass
.arena()
.dom_node_style_node(node)
.expect("an SVG element's attribute length is resolved for the element's own box");
- let bases = callbacks
+ let bases = pass
.arena()
.with_style_store(|engine| engine.container_unit_bases(element, false));
- callbacks.note_host_findings(|findings| findings.note_container_length_dependencies(node, element, &bases));
+ pass.note_host_findings(|findings| findings.note_container_length_dependencies(node, element, &bases));
bases
});
let mut context = crate::css::style_compute::FfiLengthResolutionContext {
@@ -2568,12 +2568,12 @@ fn length_resolution_context(
}
/// The style of the document element, which a root-relative length resolves against.
-fn document_element_style<'pass>(callbacks: &LayoutPass<'pass>, node: Node) -> Option<StyleValues<'pass>> {
+fn document_element_style<'pass>(pass: &LayoutPass<'pass>, node: Node) -> Option<StyleValues<'pass>> {
let mut ancestor = node;
while !ancestor.is_invalid() {
- let data = callbacks.node_data(ancestor);
+ let data = pass.node_data(ancestor);
if node_facts::has_flag(data, NodeFlag::IsDocumentElement) {
- return callbacks.arena().style_view(ancestor).map(StyleValues::new);
+ return pass.arena().style_view(ancestor).map(StyleValues::new);
}
ancestor = data.parent.get();
}
@@ -2581,8 +2581,8 @@ fn document_element_style<'pass>(callbacks: &LayoutPass<'pass>, node: Node) -> O
}
/// The pixels an absolute or relative `<length>` an SVG element's attribute gives resolves to.
-fn resolve_svg_length(callbacks: &LayoutPass<'_>, node: Node, length: FfiSvgLengthValue) -> CssPixels {
- let context = length_resolution_context(callbacks, node, length.unit);
+fn resolve_svg_length(pass: &LayoutPass<'_>, node: Node, length: FfiSvgLengthValue) -> CssPixels {
+ let context = length_resolution_context(pass, node, length.unit);
let absolutized =
crate::css::style_compute::absolutize_length_for_calc(length.value, length.unit as usize, &context);
CssPixels::nearest_value_for(absolutized.px)
@@ -2591,15 +2591,15 @@ fn resolve_svg_length(callbacks: &LayoutPass<'_>, node: Node, length: FfiSvgLeng
// https://www.w3.org/TR/SVG2/coords.html#SizingSVGInCSS
/// The natural size of an `<svg>` root's box, negotiated from what its element published.
pub(crate) fn svg_root_natural_size(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
node: Node,
) -> (Option<CssPixels>, Option<CssPixels>, Option<(CssPixels, CssPixels)>) {
- let attributes = callbacks.arena().svg_attribute_facts(node);
+ let attributes = pass.arena().svg_attribute_facts(node);
// The intrinsic dimensions must also be determined from the width and height sizing properties. If either width or
// height are not specified, the used value is the initial value 'auto'. 'auto' and percentage lengths must not be
// used to determine an intrinsic width or intrinsic height.
let resolve = |length: FfiSvgLengthValue| {
- (length.kind == SVG_LENGTH_KIND_LENGTH).then(|| resolve_svg_length(callbacks, node, length))
+ (length.kind == SVG_LENGTH_KIND_LENGTH).then(|| resolve_svg_length(pass, node, length))
};
let width = resolve(attributes.natural_width);
let height = resolve(attributes.natural_height);
@@ -2618,17 +2618,16 @@ pub(crate) fn svg_root_natural_size(
/// `cells`, with its styled width and height (from <svg width height ...>) where they are lengths. A decoded SVG image
/// keeps the size of the viewport it is drawn into.
pub(crate) fn size_document_element_svg_from_its_width_and_height(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
svg: Node,
cells: &mut used_values::RootInputCells,
) {
- if !node_facts::has_flag(callbacks.node_data(svg), NodeFlag::IsDocumentElement)
- || callbacks.arena().document_is_decoded_svg()
+ if !node_facts::has_flag(pass.node_data(svg), NodeFlag::IsDocumentElement) || pass.arena().document_is_decoded_svg()
{
return;
}
// NOTE: If a height had not been provided by the svg element, it was set to the height of the container
- let style = StyleValues::for_node(callbacks, svg);
+ let style = StyleValues::for_node(pass, svg);
if style.width().is_length() {
cells.set_content_inline_size(style.width().to_px(CssPixels::default()));
}
diff --git a/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs
index e8fe2f5e14f..744b04fb709 100644
--- a/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs
@@ -1090,20 +1090,20 @@ struct TableParticipantBox {
impl TableTree for TableFormattingContext<'_> {
fn first_child(&self, node: Node) -> Node {
- self.run.callbacks.first_child(node)
+ self.run.pass.first_child(node)
}
fn next_sibling(&self, node: Node) -> Node {
- self.run.callbacks.next_sibling(node)
+ self.run.pass.next_sibling(node)
}
fn node_data(&self, node: Node) -> &NodeData {
- self.run.callbacks.node_data(node)
+ self.run.pass.node_data(node)
}
fn display(&self, node: Node) -> FfiDisplay {
self.run
- .callbacks
+ .pass
.computed_values_view_if_styled(node)
.map_or_else(FfiDisplay::block, |style| style.display())
}
@@ -1162,12 +1162,12 @@ impl TableFormattingContext<'_> {
impl<'pass> TableFormattingContext<'pass> {
fn node_facts(&self, node: Node) -> NodeFacts<'_> {
- NodeFacts::new(&self.run.callbacks, node)
+ NodeFacts::new(&self.run.pass, node)
}
#[inline]
fn style(&self, node: Node) -> StyleValues<'pass> {
- StyleValues::for_node(&self.run.callbacks, node)
+ StyleValues::for_node(&self.run.pass, node)
}
pub(super) fn new(
@@ -1259,16 +1259,16 @@ impl<'pass> TableFormattingContext<'pass> {
#[inline]
fn sizing(&self) -> sizing_context::SizingContext<'pass, 'static> {
- sizing_context::SizingContext::new(self.run.state, self.run.callbacks)
+ sizing_context::SizingContext::new(self.run.state, self.run.pass)
}
fn parent(&self, node: Node) -> Node {
- self.run.callbacks.parent(node)
+ self.run.pass.parent(node)
}
fn matching_children(&mut self, parent: Node, predicate: impl Fn(NodeFacts<'_>) -> bool) -> Vec<Node> {
self.run
- .callbacks
+ .pass
.children(parent)
.filter(|&child| {
let facts = self.node_facts(child);
@@ -1635,7 +1635,7 @@ impl<'pass> TableFormattingContext<'pass> {
};
let participant_box = |participant| TableParticipantBox {
cells: Cell::new(used_values::cells_before_sizing(
- &self.run.callbacks,
+ &self.run.pass,
participant,
self.participant_constraints,
)),
@@ -1669,8 +1669,7 @@ impl<'pass> TableFormattingContext<'pass> {
.cells
.iter()
.map(|cell| {
- let cells =
- used_values::cells_before_sizing(&self.run.callbacks, cell.box_, self.participant_constraints);
+ let cells = used_values::cells_before_sizing(&self.run.pass, cell.box_, self.participant_constraints);
note_percentage_block_size_dependency_of(cell.box_);
cells
})
@@ -2940,7 +2939,7 @@ impl<'pass> TableFormattingContext<'pass> {
adopt_automatic_content_block_size: bool,
) -> Option<TableCellMeasurement> {
let cell = self.cells[cell_index];
- let facts = NodeFacts::new(&self.run.callbacks, cell.box_);
+ let facts = NodeFacts::new(&self.run.pass, cell.box_);
if !facts.can_have_children() {
return None;
}
@@ -2963,7 +2962,7 @@ impl<'pass> TableFormattingContext<'pass> {
participation: ParticipationInParentFormattingContext::Item,
},
);
- let result = formatting_context::lay_out_shape_for_its_result(run.callbacks, shape);
+ let result = formatting_context::lay_out_shape_for_its_result(run.pass, shape);
Some(TableCellMeasurement {
automatic_content_block_size: result.automatic_content_block_size,
baselines: result.baselines,
@@ -3447,7 +3446,7 @@ impl<'pass> TableFormattingContext<'pass> {
self.content_baselines_of_handed_back_cells[cell_index] = Some(laid_out.baselines);
formatting_context::propagate_percentage_block_size_dependency_to_containing_block(
run.state,
- &run.callbacks,
+ &run.pass,
cell.box_,
measurement.depends_on_percentage_block_size,
);
@@ -3682,7 +3681,7 @@ impl<'pass> TableFormattingContext<'pass> {
let mut y = block_start;
if let Some((group, group_box)) =
group_placement.map(|group_placement| &self.column_group_and_column_boxes[group_placement])
- && self.run.callbacks.in_flow_containing_block(node) == *group
+ && self.run.pass.in_flow_containing_block(node) == *group
{
let group_offset = group_box.content_offset.get();
x -= group_offset.x;
diff --git a/Libraries/LibWeb/Rust/src/layout/text_chunker.rs b/Libraries/LibWeb/Rust/src/layout/text_chunker.rs
index 649fd4ae0c2..132497037b9 100644
--- a/Libraries/LibWeb/Rust/src/layout/text_chunker.rs
+++ b/Libraries/LibWeb/Rust/src/layout/text_chunker.rs
@@ -1368,13 +1368,13 @@ enum ChunkFont<'text> {
}
pub(crate) fn text_chunks(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
node: Node,
should_wrap_lines: bool,
should_respect_linebreaks: bool,
unidirectional_ltr: bool,
) -> std::sync::Arc<super::rendered_text::CachedTextChunks> {
- let parent_style = StyleValues::for_node(callbacks, callbacks.parent(node));
+ let parent_style = StyleValues::for_node(pass, pass.parent(node));
let frozen_font_list = parent_style.frozen_font_list();
let counted_frozen_font_list = &parent_style.font().frozen_font_list;
let key = super::rendered_text::TextChunkCacheKey {
@@ -1385,7 +1385,7 @@ pub(crate) fn text_chunks(
word_break: parent_style.word_break(),
line_break: parent_style.line_break(),
line_break_language: if parent_style.line_break() == line_break::LOOSE {
- callbacks.arena().text_line_break_language(node)
+ pass.arena().text_line_break_language(node)
} else {
LineBreakLanguage::Other
},
@@ -1397,8 +1397,8 @@ pub(crate) fn text_chunks(
writing_mode::VERTICAL_RL | writing_mode::VERTICAL_LR
) && parent_style.text_orientation() == text_orientation::MIXED,
};
- let text = &callbacks.text_content(node).text;
- callbacks.text_chunks(node, &key, || ChunkedText {
+ let text = &pass.text_content(node).text;
+ pass.text_chunks(node, &key, || ChunkedText {
frozen_font_list_held_for_memo_key: Some(parent_style.frozen_font_list_ref()),
..chunk_text(TextChunkInputs {
text,
diff --git a/Libraries/LibWeb/Rust/src/layout/used_values.rs b/Libraries/LibWeb/Rust/src/layout/used_values.rs
index d04eda39282..6e7b95fb6fc 100644
--- a/Libraries/LibWeb/Rust/src/layout/used_values.rs
+++ b/Libraries/LibWeb/Rust/src/layout/used_values.rs
@@ -489,14 +489,14 @@ pub(crate) fn collapsed_border_share(width: CssPixels, start_edge: bool, is_tabl
/// The input cells of `node` before anything sizes the box: the sizes its style makes definite without layout.
pub(crate) fn cells_before_sizing(
- callbacks: &LayoutPass<'_>,
+ pass: &LayoutPass<'_>,
node: Node,
constraints: ContainingBlockConstraints,
) -> RootInputCells {
assert!(!node.is_invalid());
- let facts = NodeFacts::new(callbacks, node);
+ let facts = NodeFacts::new(pass, node);
- let style = StyleValues::for_node(callbacks, node);
+ let style = StyleValues::for_node(pass, node);
let percentage_basis_inline_size = constraints.percentage_basis_inline_size;
let percentage_basis_block_size = constraints.percentage_basis_block_size;
@@ -571,7 +571,7 @@ pub(crate) fn cells_before_sizing(
&& facts.display().is_block_outside()
&& facts.parent_is_unfloated_flow_container()
&& containing_block_has_definite_size(Axis::Inline)
- && !formatting_context::frame_established_by(callbacks, node).is_orthogonal_to(callbacks.frame)
+ && !formatting_context::frame_established_by(pass, node).is_orthogonal_to(pass.frame)
{
let available = containing_block_size_for_axis(Axis::Inline);
return Some(clamp_to_max_dimension_value(
@@ -600,7 +600,7 @@ pub(crate) fn cells_before_sizing(
}
Axis::Block => {
let (margin_top, margin_bottom) =
- crate::layout::sizing_context::stretch_fit_block_margins(callbacks, node, inline_basis);
+ crate::layout::sizing_context::stretch_fit_block_margins(pass, node, inline_basis);
margin_top
+ style.border_top_width()
+ style.padding_top().to_px(inline_basis)
@@ -670,8 +670,8 @@ pub(crate) struct CommittedBox {
pub(crate) facts_decided_by_parent: super::run_state::FactsDecidedByParent,
}
-pub(crate) fn committed_box_from_fragment_link(callbacks: &LayoutPass<'_>, node: Node) -> Option<CommittedBox> {
- let link = callbacks.committed_fragment_link(node)?;
+pub(crate) fn committed_box_from_fragment_link(pass: &LayoutPass<'_>, node: Node) -> Option<CommittedBox> {
+ let link = pass.committed_fragment_link(node)?;
Some(CommittedBox {
cells: RootInputCells::of_committed_fragment_link(&link),