summaryrefslogtreecommitdiff
path: root/library/src/layout/flow.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-02-13 15:14:25 +0100
committerLaurenz <laurmaedje@gmail.com>2023-02-13 16:04:25 +0100
commitb1b4e52af9e2da8f8ae1fc17a81ed6cbcbb8f525 (patch)
treee97ad140dac6d0414e9b49f7d01abccdcd717d4f /library/src/layout/flow.rs
parent72b60dfde751b4a2ab279aa1fcfa559b4a75eb51 (diff)
Block sizing
Diffstat (limited to 'library/src/layout/flow.rs')
-rw-r--r--library/src/layout/flow.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/library/src/layout/flow.rs b/library/src/layout/flow.rs
index db9eed8d..00eeb537 100644
--- a/library/src/layout/flow.rs
+++ b/library/src/layout/flow.rs
@@ -44,7 +44,10 @@ impl Layout for FlowNode {
} else if child.has::<dyn Layout>() {
layouter.layout_multiple(vt, child, styles)?;
} else if child.is::<ColbreakNode>() {
- layouter.finish_region();
+ if !layouter.regions.backlog.is_empty() || layouter.regions.last.is_some()
+ {
+ layouter.finish_region();
+ }
} else {
panic!("unexpected flow child: {child:?}");
}
@@ -207,7 +210,10 @@ impl<'a> FlowLayouter<'a> {
// Layout the block itself.
let sticky = styles.get(BlockNode::STICKY);
let fragment = block.layout(vt, styles, self.regions)?;
- for frame in fragment {
+ for (i, frame) in fragment.into_iter().enumerate() {
+ if i > 0 {
+ self.finish_region();
+ }
self.layout_item(FlowItem::Frame(frame, aligns, sticky));
}
@@ -264,8 +270,7 @@ impl<'a> FlowLayouter<'a> {
// Determine the size of the flow in this region depending on whether
// the region expands.
- let mut size = self.expand.select(self.full, used);
- size.y.set_min(self.full.y);
+ let mut size = self.expand.select(self.full, used).min(self.full);
// Account for fractional spacing in the size calculation.
let remaining = self.full.y - used.y;