parent
8927f3d572
commit
8fb225feb4
@ -266,6 +266,7 @@ fn realize_block<'a>(
|
||||
// These elements implement `Layout` but still require a flow for
|
||||
// proper layout.
|
||||
if content.can::<dyn Layout>()
|
||||
&& !content.is::<BoxElem>()
|
||||
&& !content.is::<LineElem>()
|
||||
&& !content.is::<RectElem>()
|
||||
&& !content.is::<SquareElem>()
|
||||
|
@ -149,6 +149,12 @@ impl<'a, 'b, 'v> MathContext<'a, 'b, 'v> {
|
||||
Ok(self.layout_fragment(elem)?.into_frame())
|
||||
}
|
||||
|
||||
pub fn layout_box(&mut self, boxed: &BoxElem) -> SourceResult<Frame> {
|
||||
Ok(boxed
|
||||
.layout(self.vt, self.outer.chain(&self.local), self.regions)?
|
||||
.into_frame())
|
||||
}
|
||||
|
||||
pub fn layout_content(&mut self, content: &Content) -> SourceResult<Frame> {
|
||||
Ok(content
|
||||
.layout(self.vt, self.outer.chain(&self.local), self.regions)?
|
||||
|
@ -457,18 +457,20 @@ impl LayoutMath for Content {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if let Some(boxed) = self.to::<BoxElem>() {
|
||||
let frame = ctx.layout_box(boxed)?;
|
||||
ctx.push(FrameFragment::new(ctx, frame).with_spaced(true));
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if let Some(elem) = self.with::<dyn LayoutMath>() {
|
||||
return elem.layout_math(ctx);
|
||||
}
|
||||
|
||||
let mut frame = ctx.layout_content(self)?;
|
||||
if !frame.has_baseline() {
|
||||
if self.is::<BoxElem>() {
|
||||
frame.set_baseline(frame.height());
|
||||
} else {
|
||||
let axis = scaled!(ctx, axis_height);
|
||||
frame.set_baseline(frame.height() / 2.0 + axis);
|
||||
}
|
||||
let axis = scaled!(ctx, axis_height);
|
||||
frame.set_baseline(frame.height() / 2.0 + axis);
|
||||
}
|
||||
ctx.push(FrameFragment::new(ctx, frame).with_spaced(true));
|
||||
|
||||
|
BIN
tests/ref/bugs/block-width-box.png
Normal file
BIN
tests/ref/bugs/block-width-box.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
6
tests/typ/bugs/block-width-box.typ
Normal file
6
tests/typ/bugs/block-width-box.typ
Normal file
@ -0,0 +1,6 @@
|
||||
// Test box in 100% width block.
|
||||
|
||||
---
|
||||
#block(width: 100%, fill: red, box("a box"))
|
||||
|
||||
#block(width: 100%, fill: red, [#box("a box") #box()])
|
Loading…
x
Reference in New Issue
Block a user