mirror of
https://github.com/typst/typst
synced 2025-05-16 10:05:28 +08:00
fix header height and rows state calculations
- remove non-repeating header height on pending flush - use lrows - reset current region dataon orphan prevention row wipe
This commit is contained in:
parent
fbb0306ebc
commit
e73c561f16
@ -1460,6 +1460,9 @@ impl<'a> GridLayouter<'a> {
|
||||
// Header and footer would be alone in this region, but there are more
|
||||
// rows beyond the header and the footer. Push an empty region.
|
||||
self.lrows.clear();
|
||||
self.current_last_repeated_header_end = 0;
|
||||
self.current_repeating_header_rows = 0;
|
||||
self.current_header_rows = 0;
|
||||
true
|
||||
} else {
|
||||
false
|
||||
|
@ -152,10 +152,14 @@ impl<'a> GridLayouter<'a> {
|
||||
// space in future regions anymore.
|
||||
for removed_height in self.repeating_header_heights.drain(first_conflicting_pos..)
|
||||
{
|
||||
self.header_height -= removed_height;
|
||||
self.repeating_header_height -= removed_height;
|
||||
}
|
||||
|
||||
// Non-repeating headers stop at the pending stage for orphan
|
||||
// prevention only. Flushing pending headers, so those will no longer
|
||||
// appear in a future region.
|
||||
self.header_height = self.repeating_header_height;
|
||||
|
||||
// Let's try to place them at least once.
|
||||
// This might be a waste as we could generate an orphan and thus have
|
||||
// to try to place old and new headers all over again, but that happens
|
||||
@ -308,10 +312,6 @@ impl<'a> GridLayouter<'a> {
|
||||
self.pending_headers.into_iter().map(Repeatable::unwrap),
|
||||
);
|
||||
|
||||
// Include both repeating and pending header rows as this number is
|
||||
// used for orphan prevention.
|
||||
self.current_header_rows = repeating_header_rows + pending_header_rows;
|
||||
self.current_repeating_header_rows = repeating_header_rows;
|
||||
self.unbreakable_rows_left += repeating_header_rows + pending_header_rows;
|
||||
|
||||
self.current_last_repeated_header_end =
|
||||
@ -355,6 +355,8 @@ impl<'a> GridLayouter<'a> {
|
||||
i += 1;
|
||||
}
|
||||
|
||||
self.current_repeating_header_rows = self.lrows.len();
|
||||
|
||||
for header in self.pending_headers {
|
||||
let header_height =
|
||||
self.layout_header_rows(header.unwrap(), engine, disambiguator)?;
|
||||
@ -364,6 +366,10 @@ impl<'a> GridLayouter<'a> {
|
||||
self.repeating_header_heights.push(header_height);
|
||||
}
|
||||
}
|
||||
|
||||
// Include both repeating and pending header rows as this number is
|
||||
// used for orphan prevention.
|
||||
self.current_header_rows = self.lrows.len();
|
||||
}
|
||||
|
||||
if let HeadersToLayout::NewHeaders { headers, short_lived } = headers {
|
||||
|
Loading…
x
Reference in New Issue
Block a user