Don't label empty orphan frames

Adding a label makes a previously empty frame non-empty, but we want to
keep orphans empty.
This commit is contained in:
Eric Biedert 2025-05-27 15:18:20 +02:00
parent 693edb475d
commit 02f07e7912
2 changed files with 5 additions and 6 deletions

View File

@ -204,13 +204,11 @@ pub fn layout_multi_block(
let has_inset = !inset.is_zero(); let has_inset = !inset.is_zero();
let is_explicit = matches!(body, None | Some(BlockBody::Content(_))); let is_explicit = matches!(body, None | Some(BlockBody::Content(_)));
// Skip filling/stroking the first frame if it is empty and a non-empty // Skip filling, stroking and labeling the first frame if it is empty and
// one follows. // a non-empty one follows.
let mut skip_first = false; let mut skip_first = false;
if let [first, rest @ ..] = fragment.as_slice() { if let [first, rest @ ..] = fragment.as_slice() {
skip_first = has_fill_or_stroke skip_first = first.is_empty() && rest.iter().any(|frame| !frame.is_empty());
&& first.is_empty()
&& rest.iter().any(|frame| !frame.is_empty());
} }
// Post-process to apply insets, clipping, fills, and strokes. // Post-process to apply insets, clipping, fills, and strokes.
@ -242,7 +240,8 @@ pub fn layout_multi_block(
// Assign label to each frame in the fragment. // Assign label to each frame in the fragment.
if let Some(label) = elem.label() { if let Some(label) = elem.label() {
for frame in fragment.iter_mut() { // Skip empty orphan frames, as a label would make them non-empty.
for frame in fragment.iter_mut().skip(if skip_first { 1 } else { 0 }) {
frame.label(label); frame.label(label);
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 311 B

After

Width:  |  Height:  |  Size: 312 B