summaryrefslogtreecommitdiff
path: root/src/library/layout
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-06-12 17:45:52 +0200
committerLaurenz <laurmaedje@gmail.com>2022-06-12 20:51:31 +0200
commit7660978ee5d842648e244e2972273264d94ca37b (patch)
tree74e1c8bc578afa616ddcd6c4c9e79c3c3d311d78 /src/library/layout
parent6e3b1a2c80428d581d00b9d65e1c45401df2e210 (diff)
Move `Arc` into `Frame`
Diffstat (limited to 'src/library/layout')
-rw-r--r--src/library/layout/align.rs4
-rw-r--r--src/library/layout/columns.rs4
-rw-r--r--src/library/layout/flow.rs16
-rw-r--r--src/library/layout/grid.rs8
-rw-r--r--src/library/layout/pad.rs3
-rw-r--r--src/library/layout/page.rs8
-rw-r--r--src/library/layout/place.rs4
-rw-r--r--src/library/layout/stack.rs14
8 files changed, 28 insertions, 33 deletions
diff --git a/src/library/layout/align.rs b/src/library/layout/align.rs
index c5adcf9f..e7a27c04 100644
--- a/src/library/layout/align.rs
+++ b/src/library/layout/align.rs
@@ -31,7 +31,7 @@ impl Layout for AlignNode {
ctx: &mut Context,
regions: &Regions,
styles: StyleChain,
- ) -> TypResult<Vec<Arc<Frame>>> {
+ ) -> TypResult<Vec<Frame>> {
// The child only needs to expand along an axis if there's no alignment.
let mut pod = regions.clone();
pod.expand &= self.aligns.map_is_none();
@@ -53,7 +53,7 @@ impl Layout for AlignNode {
.map(|align| align.resolve(styles))
.unwrap_or(Spec::new(Align::Left, Align::Top));
- Arc::make_mut(frame).resize(target, aligns);
+ frame.resize(target, aligns);
}
Ok(frames)
diff --git a/src/library/layout/columns.rs b/src/library/layout/columns.rs
index b9e308f2..33ceab86 100644
--- a/src/library/layout/columns.rs
+++ b/src/library/layout/columns.rs
@@ -31,7 +31,7 @@ impl Layout for ColumnsNode {
ctx: &mut Context,
regions: &Regions,
styles: StyleChain,
- ) -> TypResult<Vec<Arc<Frame>>> {
+ ) -> TypResult<Vec<Frame>> {
// Separating the infinite space into infinite columns does not make
// much sense.
if !regions.first.x.is_finite() {
@@ -94,7 +94,7 @@ impl Layout for ColumnsNode {
cursor += width + gutter;
}
- finished.push(Arc::new(output));
+ finished.push(output);
}
Ok(finished)
diff --git a/src/library/layout/flow.rs b/src/library/layout/flow.rs
index b6844f55..c6d2999e 100644
--- a/src/library/layout/flow.rs
+++ b/src/library/layout/flow.rs
@@ -28,7 +28,7 @@ impl Layout for FlowNode {
ctx: &mut Context,
regions: &Regions,
styles: StyleChain,
- ) -> TypResult<Vec<Arc<Frame>>> {
+ ) -> TypResult<Vec<Frame>> {
let mut layouter = FlowLayouter::new(regions);
for (child, map) in self.0.iter() {
@@ -92,7 +92,7 @@ pub struct FlowLayouter {
/// Spacing and layouted nodes.
items: Vec<FlowItem>,
/// Finished frames for previous regions.
- finished: Vec<Arc<Frame>>,
+ finished: Vec<Frame>,
}
/// A prepared item in a flow layout.
@@ -102,9 +102,9 @@ enum FlowItem {
/// Fractional spacing between other items.
Fractional(Fraction),
/// A frame for a layouted child node and how to align it.
- Frame(Arc<Frame>, Spec<Align>),
+ Frame(Frame, Spec<Align>),
/// An absolutely placed frame.
- Placed(Arc<Frame>),
+ Placed(Frame),
}
impl FlowLayouter {
@@ -184,9 +184,7 @@ impl FlowLayouter {
let len = frames.len();
for (i, mut frame) in frames.into_iter().enumerate() {
// Set the generic block role.
- if frame.role().map_or(true, Role::is_weak) {
- Arc::make_mut(&mut frame).apply_role(Role::GenericBlock);
- }
+ frame.apply_role(Role::GenericBlock);
// Grow our size, shrink the region and save the frame for later.
let size = frame.size();
@@ -248,11 +246,11 @@ impl FlowLayouter {
self.full = self.regions.first;
self.used = Size::zero();
self.fr = Fraction::zero();
- self.finished.push(Arc::new(output));
+ self.finished.push(output);
}
/// Finish layouting and return the resulting frames.
- pub fn finish(mut self) -> Vec<Arc<Frame>> {
+ pub fn finish(mut self) -> Vec<Frame> {
if self.expand.y {
while self.regions.backlog.len() > 0 {
self.finish_region();
diff --git a/src/library/layout/grid.rs b/src/library/layout/grid.rs
index c04913a1..c02662a6 100644
--- a/src/library/layout/grid.rs
+++ b/src/library/layout/grid.rs
@@ -36,7 +36,7 @@ impl Layout for GridNode {
ctx: &mut Context,
regions: &Regions,
styles: StyleChain,
- ) -> TypResult<Vec<Arc<Frame>>> {
+ ) -> TypResult<Vec<Frame>> {
// Prepare grid layout by unifying content and gutter tracks.
let layouter = GridLayouter::new(
ctx,
@@ -116,7 +116,7 @@ pub struct GridLayouter<'a> {
/// The sum of fractions in the current region.
fr: Fraction,
/// Frames for finished regions.
- finished: Vec<Arc<Frame>>,
+ finished: Vec<Frame>,
}
/// Produced by initial row layout, auto and relative rows are already finished,
@@ -203,7 +203,7 @@ impl<'a> GridLayouter<'a> {
}
/// Determines the columns sizes and then layouts the grid row-by-row.
- pub fn layout(mut self) -> TypResult<Vec<Arc<Frame>>> {
+ pub fn layout(mut self) -> TypResult<Vec<Frame>> {
self.ctx.pins.freeze();
self.measure_columns()?;
self.ctx.pins.unfreeze();
@@ -567,7 +567,7 @@ impl<'a> GridLayouter<'a> {
pos.y += height;
}
- self.finished.push(Arc::new(output));
+ self.finished.push(output);
self.regions.next();
self.full = self.regions.first.y;
self.used.y = Length::zero();
diff --git a/src/library/layout/pad.rs b/src/library/layout/pad.rs
index 29a72588..dfd425bd 100644
--- a/src/library/layout/pad.rs
+++ b/src/library/layout/pad.rs
@@ -31,7 +31,7 @@ impl Layout for PadNode {
ctx: &mut Context,
regions: &Regions,
styles: StyleChain,
- ) -> TypResult<Vec<Arc<Frame>>> {
+ ) -> TypResult<Vec<Frame>> {
// Layout child into padded regions.
let padding = self.padding.resolve(styles);
let pod = regions.map(|size| shrink(size, padding));
@@ -45,7 +45,6 @@ impl Layout for PadNode {
let offset = Point::new(padding.left, padding.top);
// Grow the frame and translate everything in the frame inwards.
- let frame = Arc::make_mut(frame);
frame.set_size(padded);
frame.translate(offset);
}
diff --git a/src/library/layout/page.rs b/src/library/layout/page.rs
index e22bb4f7..e2f414ab 100644
--- a/src/library/layout/page.rs
+++ b/src/library/layout/page.rs
@@ -60,7 +60,7 @@ impl PageNode {
ctx: &mut Context,
mut page: usize,
styles: StyleChain,
- ) -> TypResult<Vec<Arc<Frame>>> {
+ ) -> TypResult<Vec<Frame>> {
// When one of the lengths is infinite the page fits its content along
// that axis.
let width = styles.get(Self::WIDTH).unwrap_or(Length::inf());
@@ -129,12 +129,12 @@ impl PageNode {
if let Some(content) = marginal.resolve(ctx, page)? {
let pod = Regions::one(area, area, Spec::splat(true));
let mut sub = content.layout(ctx, &pod, styles)?.remove(0);
- Arc::make_mut(&mut sub).apply_role(role);
+ sub.apply_role(role);
if role == Role::Background {
- Arc::make_mut(frame).prepend_frame(pos, sub);
+ frame.prepend_frame(pos, sub);
} else {
- Arc::make_mut(frame).push_frame(pos, sub);
+ frame.push_frame(pos, sub);
}
}
}
diff --git a/src/library/layout/place.rs b/src/library/layout/place.rs
index 408ca129..67e46d3b 100644
--- a/src/library/layout/place.rs
+++ b/src/library/layout/place.rs
@@ -24,7 +24,7 @@ impl Layout for PlaceNode {
ctx: &mut Context,
regions: &Regions,
styles: StyleChain,
- ) -> TypResult<Vec<Arc<Frame>>> {
+ ) -> TypResult<Vec<Frame>> {
let out_of_flow = self.out_of_flow();
// The pod is the base area of the region because for absolute
@@ -41,7 +41,7 @@ impl Layout for PlaceNode {
// space in our parent. Otherwise, respect the expand settings.
let frame = &mut frames[0];
let target = regions.expand.select(regions.first, Size::zero());
- Arc::make_mut(frame).resize(target, Align::LEFT_TOP);
+ frame.resize(target, Align::LEFT_TOP);
Ok(frames)
}
diff --git a/src/library/layout/stack.rs b/src/library/layout/stack.rs
index 5d3e1786..b1268404 100644
--- a/src/library/layout/stack.rs
+++ b/src/library/layout/stack.rs
@@ -30,7 +30,7 @@ impl Layout for StackNode {
ctx: &mut Context,
regions: &Regions,
styles: StyleChain,
- ) -> TypResult<Vec<Arc<Frame>>> {
+ ) -> TypResult<Vec<Frame>> {
let mut layouter = StackLayouter::new(self.dir, regions, styles);
// Spacing to insert before the next node.
@@ -107,7 +107,7 @@ pub struct StackLayouter<'a> {
/// fractional spacing.
items: Vec<StackItem>,
/// Finished frames for previous regions.
- finished: Vec<Arc<Frame>>,
+ finished: Vec<Frame>,
}
/// A prepared item in a stack layout.
@@ -117,7 +117,7 @@ enum StackItem {
/// Fractional spacing between other items.
Fractional(Fraction),
/// A frame for a layouted child node.
- Frame(Arc<Frame>, Align),
+ Frame(Frame, Align),
}
impl<'a> StackLayouter<'a> {
@@ -196,9 +196,7 @@ impl<'a> StackLayouter<'a> {
let len = frames.len();
for (i, mut frame) in frames.into_iter().enumerate() {
// Set the generic block role.
- if frame.role().map_or(true, Role::is_weak) {
- Arc::make_mut(&mut frame).apply_role(Role::GenericBlock);
- }
+ frame.apply_role(Role::GenericBlock);
// Grow our size, shrink the region and save the frame for later.
let size = frame.size().to_gen(self.axis);
@@ -268,11 +266,11 @@ impl<'a> StackLayouter<'a> {
self.full = self.regions.first;
self.used = Gen::zero();
self.fr = Fraction::zero();
- self.finished.push(Arc::new(output));
+ self.finished.push(output);
}
/// Finish layouting and return the resulting frames.
- pub fn finish(mut self) -> Vec<Arc<Frame>> {
+ pub fn finish(mut self) -> Vec<Frame> {
self.finish_region();
self.finished
}