Remove redundant code in stack

This commit is contained in:
mkorje 2025-02-23 20:03:52 +11:00 committed by mkorje
parent 9818d257f1
commit db46115891
No known key found for this signature in database
2 changed files with 6 additions and 20 deletions

View File

@ -117,7 +117,6 @@ pub fn stack(
gap: Abs,
baseline: usize,
alternator: LeftRightAlternator,
minimum_ascent_descent: Option<(Abs, Abs)>,
) -> Frame {
let AlignmentResult { points, width } = alignments(&rows);
let rows: Vec<_> = rows
@ -125,13 +124,9 @@ pub fn stack(
.map(|row| row.into_line_frame(&points, alternator))
.collect();
let padded_height = |height: Abs| {
height.max(minimum_ascent_descent.map_or(Abs::zero(), |(a, d)| a + d))
};
let mut frame = Frame::soft(Size::new(
width,
rows.iter().map(|row| padded_height(row.height())).sum::<Abs>()
rows.iter().map(|row| row.height()).sum::<Abs>()
+ rows.len().saturating_sub(1) as f64 * gap,
));
@ -142,14 +137,11 @@ pub fn stack(
} else {
Abs::zero()
};
let ascent_padded_part = minimum_ascent_descent
.map_or(Abs::zero(), |(a, _)| (a - row.ascent()))
.max(Abs::zero());
let pos = Point::new(x, y + ascent_padded_part);
let pos = Point::new(x, y);
if i == baseline {
frame.set_baseline(y + row.baseline() + ascent_padded_part);
frame.set_baseline(y + row.baseline());
}
y += padded_height(row.height()) + gap;
y += row.height() + gap;
frame.push_frame(pos, row);
}

View File

@ -312,14 +312,8 @@ fn layout_underoverspreader(
}
};
let frame = stack(
rows,
FixedAlignment::Center,
gap,
baseline,
LeftRightAlternator::Right,
None,
);
let frame =
stack(rows, FixedAlignment::Center, gap, baseline, LeftRightAlternator::Right);
ctx.push(FrameFragment::new(styles, frame).with_class(body_class));
Ok(())