summaryrefslogtreecommitdiff
path: root/src/model
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/model
parent6e3b1a2c80428d581d00b9d65e1c45401df2e210 (diff)
Move `Arc` into `Frame`
Diffstat (limited to 'src/model')
-rw-r--r--src/model/content.rs6
-rw-r--r--src/model/layout.rs24
-rw-r--r--src/model/locate.rs2
3 files changed, 16 insertions, 16 deletions
diff --git a/src/model/content.rs b/src/model/content.rs
index 3e27c02f..d2af4595 100644
--- a/src/model/content.rs
+++ b/src/model/content.rs
@@ -22,7 +22,7 @@ use crate::util::EcoString;
/// Layout content into a collection of pages.
///
/// Relayouts until all pinned locations are converged.
-pub fn layout(ctx: &mut Context, content: &Content) -> TypResult<Vec<Arc<Frame>>> {
+pub fn layout(ctx: &mut Context, content: &Content) -> TypResult<Vec<Frame>> {
let mut pass = 0;
let mut frames;
@@ -46,7 +46,7 @@ pub fn layout(ctx: &mut Context, content: &Content) -> TypResult<Vec<Arc<Frame>>
}
/// Layout content into a collection of pages once.
-fn layout_once(ctx: &mut Context, content: &Content) -> TypResult<Vec<Arc<Frame>>> {
+fn layout_once(ctx: &mut Context, content: &Content) -> TypResult<Vec<Frame>> {
let copy = ctx.config.styles.clone();
let styles = StyleChain::with_root(&copy);
let scratch = Scratch::default();
@@ -263,7 +263,7 @@ impl Layout for Content {
ctx: &mut Context,
regions: &Regions,
styles: StyleChain,
- ) -> TypResult<Vec<Arc<Frame>>> {
+ ) -> TypResult<Vec<Frame>> {
let scratch = Scratch::default();
let mut builder = Builder::new(ctx, &scratch, false);
builder.accept(self, styles)?;
diff --git a/src/model/layout.rs b/src/model/layout.rs
index c971197a..22797b48 100644
--- a/src/model/layout.rs
+++ b/src/model/layout.rs
@@ -28,7 +28,7 @@ pub trait Layout: 'static {
ctx: &mut Context,
regions: &Regions,
styles: StyleChain,
- ) -> TypResult<Vec<Arc<Frame>>>;
+ ) -> TypResult<Vec<Frame>>;
/// Convert to a packed node.
fn pack(self) -> LayoutNode
@@ -222,7 +222,7 @@ impl Layout for LayoutNode {
ctx: &mut Context,
regions: &Regions,
styles: StyleChain,
- ) -> TypResult<Vec<Arc<Frame>>> {
+ ) -> TypResult<Vec<Frame>> {
let prev = ctx.pins.dirty.replace(false);
let (result, at, fresh, dirty) = crate::memo::memoized(
@@ -238,7 +238,7 @@ impl Layout for LayoutNode {
if let Some(role) = styles.role() {
result = result.map(|mut frames| {
for frame in frames.iter_mut() {
- Arc::make_mut(frame).apply_role(role);
+ frame.apply_role(role);
}
frames
});
@@ -319,10 +319,10 @@ impl Layout for EmptyNode {
_: &mut Context,
regions: &Regions,
_: StyleChain,
- ) -> TypResult<Vec<Arc<Frame>>> {
- Ok(vec![Arc::new(Frame::new(
+ ) -> TypResult<Vec<Frame>> {
+ Ok(vec![Frame::new(
regions.expand.select(regions.first, Size::zero()),
- ))])
+ )])
}
}
@@ -341,7 +341,7 @@ impl Layout for SizedNode {
ctx: &mut Context,
regions: &Regions,
styles: StyleChain,
- ) -> TypResult<Vec<Arc<Frame>>> {
+ ) -> TypResult<Vec<Frame>> {
// The "pod" is the region into which the child will be layouted.
let pod = {
// Resolve the sizing to a concrete size.
@@ -367,7 +367,7 @@ impl Layout for SizedNode {
// Ensure frame size matches regions size if expansion is on.
let frame = &mut frames[0];
let target = regions.expand.select(regions.first, frame.size());
- Arc::make_mut(frame).resize(target, Align::LEFT_TOP);
+ frame.resize(target, Align::LEFT_TOP);
Ok(frames)
}
@@ -388,11 +388,11 @@ impl Layout for FillNode {
ctx: &mut Context,
regions: &Regions,
styles: StyleChain,
- ) -> TypResult<Vec<Arc<Frame>>> {
+ ) -> TypResult<Vec<Frame>> {
let mut frames = self.child.layout(ctx, regions, styles)?;
for frame in &mut frames {
let shape = Geometry::Rect(frame.size()).filled(self.fill);
- Arc::make_mut(frame).prepend(Point::zero(), Element::Shape(shape));
+ frame.prepend(Point::zero(), Element::Shape(shape));
}
Ok(frames)
}
@@ -413,11 +413,11 @@ impl Layout for StrokeNode {
ctx: &mut Context,
regions: &Regions,
styles: StyleChain,
- ) -> TypResult<Vec<Arc<Frame>>> {
+ ) -> TypResult<Vec<Frame>> {
let mut frames = self.child.layout(ctx, regions, styles)?;
for frame in &mut frames {
let shape = Geometry::Rect(frame.size()).stroked(self.stroke);
- Arc::make_mut(frame).prepend(Point::zero(), Element::Shape(shape));
+ frame.prepend(Point::zero(), Element::Shape(shape));
}
Ok(frames)
}
diff --git a/src/model/locate.rs b/src/model/locate.rs
index bda12ae9..f6432d43 100644
--- a/src/model/locate.rs
+++ b/src/model/locate.rs
@@ -272,7 +272,7 @@ impl PinBoard {
}
/// Locate all pins in the frames.
- pub fn locate(&mut self, frames: &[Arc<Frame>]) {
+ pub fn locate(&mut self, frames: &[Frame]) {
let mut flow = 0;
for (i, frame) in frames.iter().enumerate() {
locate_in_frame(