diff options
| author | Martin <mhaug@live.de> | 2021-06-18 13:01:55 +0200 |
|---|---|---|
| committer | Martin <mhaug@live.de> | 2021-06-18 13:01:55 +0200 |
| commit | 80a9b300d1acb8821ac0600aad3d2135ad9587bd (patch) | |
| tree | 6626ba8891fa4db4e3a1cb13f7f4b27fc05989bf /src/layout/par.rs | |
| parent | 7db78d83bedf62adea0d715c9a2a179ce23a1a48 (diff) | |
Ref count the frames
Diffstat (limited to 'src/layout/par.rs')
| -rw-r--r-- | src/layout/par.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/layout/par.rs b/src/layout/par.rs index 814f88ed..2208f9ee 100644 --- a/src/layout/par.rs +++ b/src/layout/par.rs @@ -37,7 +37,7 @@ impl Layout for ParNode { &self, ctx: &mut LayoutContext, regions: &Regions, - ) -> Vec<Constrained<Frame>> { + ) -> Vec<Constrained<Rc<Frame>>> { // Collect all text into one string used for BiDi analysis. let text = self.collect_text(); @@ -169,7 +169,7 @@ impl<'a> ParLayouter<'a> { self, ctx: &mut LayoutContext, regions: Regions, - ) -> Vec<Constrained<Frame>> { + ) -> Vec<Constrained<Rc<Frame>>> { let mut stack = LineStack::new(self.line_spacing, regions); // The current line attempt. @@ -277,7 +277,7 @@ enum ParItem<'a> { /// A shaped text run with consistent direction. Text(ShapedText<'a>, Align), /// A layouted child node. - Frame(Frame, Align), + Frame(Rc<Frame>, Align), } impl ParItem<'_> { @@ -306,7 +306,7 @@ struct LineStack<'a> { regions: Regions, size: Size, lines: Vec<LineLayout<'a>>, - finished: Vec<Constrained<Frame>>, + finished: Vec<Constrained<Rc<Frame>>>, constraints: Constraints, } @@ -357,7 +357,7 @@ impl<'a> LineStack<'a> { } offset += frame.size.height + self.line_spacing; - output.push_frame(pos, frame); + output.merge_frame(pos, frame); } self.finished.push(output.constrain(self.constraints)); @@ -367,7 +367,7 @@ impl<'a> LineStack<'a> { } /// Finish the last region and return the built frames. - fn finish(mut self, ctx: &LayoutContext) -> Vec<Constrained<Frame>> { + fn finish(mut self, ctx: &LayoutContext) -> Vec<Constrained<Rc<Frame>>> { self.finish_region(ctx); self.finished } @@ -504,7 +504,7 @@ impl<'a> LineLayout<'a> { } ParItem::Text(ref shaped, align) => { ruler = ruler.max(align); - shaped.build(ctx) + Rc::new(shaped.build(ctx)) } ParItem::Frame(ref frame, align) => { ruler = ruler.max(align); |
