diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-11-28 12:40:16 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-11-28 12:40:16 +0100 |
| commit | 989d170dc7318ca3cbaa5b76760eb14f4e6a8605 (patch) | |
| tree | 0a486ddb4d339b8a43313f7c6e18b9595b8fd955 /library/src/layout/flow.rs | |
| parent | 7caf98fe42797eab59a39ef71071030c9790245a (diff) | |
Fragments
Diffstat (limited to 'library/src/layout/flow.rs')
| -rw-r--r-- | library/src/layout/flow.rs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/library/src/layout/flow.rs b/library/src/layout/flow.rs index 3338da09..fd3e5fc7 100644 --- a/library/src/layout/flow.rs +++ b/library/src/layout/flow.rs @@ -11,23 +11,23 @@ use crate::text::ParNode; #[derive(Hash)] pub struct FlowNode(pub StyleVec<Content>); -#[node(LayoutBlock)] +#[node(Layout)] impl FlowNode {} -impl LayoutBlock for FlowNode { - fn layout_block( +impl Layout for FlowNode { + fn layout( &self, world: Tracked<dyn World>, styles: StyleChain, regions: &Regions, - ) -> SourceResult<Vec<Frame>> { + ) -> SourceResult<Fragment> { let mut layouter = FlowLayouter::new(regions); for (child, map) in self.0.iter() { let styles = styles.chain(&map); if let Some(&node) = child.to::<VNode>() { layouter.layout_spacing(node.amount, styles); - } else if child.has::<dyn LayoutBlock>() { + } else if child.has::<dyn Layout>() { layouter.layout_block(world, child, styles)?; } else if child.is::<ColbreakNode>() { layouter.finish_region(); @@ -136,7 +136,7 @@ impl FlowLayouter { // aligned later. if let Some(placed) = block.to::<PlaceNode>() { if placed.out_of_flow() { - let frame = block.layout_block(world, styles, &self.regions)?.remove(0); + let frame = block.layout(world, styles, &self.regions)?.into_frame(); self.items.push(FlowItem::Placed(frame)); return Ok(()); } @@ -166,9 +166,9 @@ impl FlowLayouter { } // Layout the block itself. - let frames = block.layout_block(world, chained, &self.regions)?; - let len = frames.len(); - for (i, frame) in frames.into_iter().enumerate() { + let fragment = block.layout(world, chained, &self.regions)?; + let len = fragment.len(); + for (i, frame) in fragment.into_iter().enumerate() { // Grow our size, shrink the region and save the frame for later. let size = frame.size(); self.used.y += size.y; @@ -234,8 +234,8 @@ impl FlowLayouter { self.finished.push(output); } - /// Finish layouting and return the resulting frames. - fn finish(mut self) -> Vec<Frame> { + /// Finish layouting and return the resulting fragment. + fn finish(mut self) -> Fragment { if self.expand.y { while !self.regions.backlog.is_empty() { self.finish_region(); @@ -243,6 +243,6 @@ impl FlowLayouter { } self.finish_region(); - self.finished + Fragment::frames(self.finished) } } |
