summaryrefslogtreecommitdiff
path: root/library
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-11-09 22:49:25 +0100
committerLaurenz <laurmaedje@gmail.com>2022-11-09 22:49:25 +0100
commitd9ce194fe71076314955dd25896f64d48bccd6e5 (patch)
tree1f81453d8f2bd0701863c18c4a742e89510d4375 /library
parent010cc2effc2fd0e1c4e52d5c914cb4d74506bc0a (diff)
Remove role applications
Diffstat (limited to 'library')
-rw-r--r--library/src/graphics/shape.rs4
-rw-r--r--library/src/layout/flow.rs5
-rw-r--r--library/src/layout/grid.rs15
-rw-r--r--library/src/layout/page.rs21
-rw-r--r--library/src/layout/stack.rs5
-rw-r--r--library/src/math/tex.rs1
-rw-r--r--library/src/text/par.rs3
7 files changed, 9 insertions, 45 deletions
diff --git a/library/src/graphics/shape.rs b/library/src/graphics/shape.rs
index d980b64a..be67532a 100644
--- a/library/src/graphics/shape.rs
+++ b/library/src/graphics/shape.rs
@@ -92,10 +92,6 @@ impl<const S: ShapeKind> LayoutInline for ShapeNode<S> {
let mut pod = Regions::one(regions.first, regions.base, regions.expand);
frames = child.layout_inline(world, &pod, styles)?;
- for frame in frames.iter_mut() {
- frame.apply_role(Role::GenericBlock);
- }
-
// Relayout with full expansion into square region to make sure
// the result is really a square or circle.
if is_quadratic(S) {
diff --git a/library/src/layout/flow.rs b/library/src/layout/flow.rs
index cc5dcd50..822d2c38 100644
--- a/library/src/layout/flow.rs
+++ b/library/src/layout/flow.rs
@@ -207,10 +207,7 @@ impl<'a> FlowLayouter<'a> {
let frames = block.layout_block(world, &self.regions, styles)?;
let len = frames.len();
- for (i, mut frame) in frames.into_iter().enumerate() {
- // Set the generic block role.
- frame.apply_role(Role::GenericBlock);
-
+ for (i, frame) in frames.into_iter().enumerate() {
// Grow our size, shrink the region and save the frame for later.
let size = frame.size();
self.used.y += size.y;
diff --git a/library/src/layout/grid.rs b/library/src/layout/grid.rs
index 8af69b9a..7f58090b 100644
--- a/library/src/layout/grid.rs
+++ b/library/src/layout/grid.rs
@@ -481,14 +481,6 @@ impl<'a> GridLayouter<'a> {
let pod = Regions::one(size, base, Axes::splat(true));
let frame = cell.layout_block(self.world, &pod, self.styles)?.remove(0);
- match frame.role() {
- Some(Role::ListLabel | Role::ListItemBody) => {
- output.apply_role(Role::ListItem)
- }
- Some(Role::TableCell) => output.apply_role(Role::TableRow),
- _ => {}
- }
-
output.push_frame(pos, frame);
}
@@ -530,13 +522,6 @@ impl<'a> GridLayouter<'a> {
// Push the layouted frames into the individual output frames.
let frames = cell.layout_block(self.world, &pod, self.styles)?;
for (output, frame) in outputs.iter_mut().zip(frames) {
- match frame.role() {
- Some(Role::ListLabel | Role::ListItemBody) => {
- output.apply_role(Role::ListItem)
- }
- Some(Role::TableCell) => output.apply_role(Role::TableRow),
- _ => {}
- }
output.push_frame(pos, frame);
}
}
diff --git a/library/src/layout/page.rs b/library/src/layout/page.rs
index c308571c..6a0a3dfd 100644
--- a/library/src/layout/page.rs
+++ b/library/src/layout/page.rs
@@ -110,23 +110,16 @@ impl PageNode {
let pad = padding.resolve(styles).relative_to(size);
let pw = size.x - pad.left - pad.right;
let py = size.y - pad.bottom;
- for (role, marginal, pos, area) in [
- (Role::Header, header, Point::with_x(pad.left), Size::new(pw, pad.top)),
- (
- Role::Footer,
- footer,
- Point::new(pad.left, py),
- Size::new(pw, pad.bottom),
- ),
- (Role::Foreground, foreground, Point::zero(), size),
- (Role::Background, background, Point::zero(), size),
+ for (marginal, pos, area) in [
+ (header, Point::with_x(pad.left), Size::new(pw, pad.top)),
+ (footer, Point::new(pad.left, py), Size::new(pw, pad.bottom)),
+ (foreground, Point::zero(), size),
+ (background, Point::zero(), size),
] {
if let Some(content) = marginal.resolve(world, page)? {
let pod = Regions::one(area, area, Axes::splat(true));
- let mut sub = content.layout_block(world, &pod, styles)?.remove(0);
- sub.apply_role(role);
-
- if role == Role::Background {
+ let sub = content.layout_block(world, &pod, styles)?.remove(0);
+ if std::ptr::eq(marginal, background) {
frame.prepend_frame(pos, sub);
} else {
frame.push_frame(pos, sub);
diff --git a/library/src/layout/stack.rs b/library/src/layout/stack.rs
index ec1063fd..02129e1f 100644
--- a/library/src/layout/stack.rs
+++ b/library/src/layout/stack.rs
@@ -198,10 +198,7 @@ impl<'a> StackLayouter<'a> {
let frames = block.layout_block(world, &self.regions, styles)?;
let len = frames.len();
- for (i, mut frame) in frames.into_iter().enumerate() {
- // Set the generic block role.
- frame.apply_role(Role::GenericBlock);
-
+ for (i, frame) in frames.into_iter().enumerate() {
// Grow our size, shrink the region and save the frame for later.
let size = frame.size();
let size = match self.axis {
diff --git a/library/src/math/tex.rs b/library/src/math/tex.rs
index f924ebbe..d7c5493b 100644
--- a/library/src/math/tex.rs
+++ b/library/src/math/tex.rs
@@ -87,7 +87,6 @@ pub fn layout_tex(
frame: {
let mut frame = Frame::new(size);
frame.set_baseline(top);
- frame.apply_role(Role::Formula);
frame
},
baseline: top,
diff --git a/library/src/text/par.rs b/library/src/text/par.rs
index 0c4ec7af..b49e4914 100644
--- a/library/src/text/par.rs
+++ b/library/src/text/par.rs
@@ -530,7 +530,6 @@ fn prepare<'a>(
let pod = Regions::one(size, regions.base, Axes::splat(false));
let mut frame = inline.layout_inline(world, &pod, styles)?.remove(0);
frame.translate(Point::with_y(styles.get(TextNode::BASELINE)));
- frame.apply_role(Role::GenericInline);
items.push(Item::Frame(frame));
}
}
@@ -1040,7 +1039,6 @@ fn stack(
let mut finished = vec![];
let mut first = true;
let mut output = Frame::new(Size::with_x(width));
- output.apply_role(Role::Paragraph);
// Stack the lines into one frame per region.
for line in lines {
@@ -1050,7 +1048,6 @@ fn stack(
while !regions.first.y.fits(height) && !regions.in_last() {
finished.push(output);
output = Frame::new(Size::with_x(width));
- output.apply_role(Role::Paragraph);
regions.next();
first = true;
}