Fix out-of-order floats (#3506)
This commit is contained in:
parent
79615a01bd
commit
ae31640c0a
@ -312,7 +312,7 @@ impl<'a> FlowLayouter<'a> {
|
||||
align.x().unwrap_or_default().resolve(styles)
|
||||
});
|
||||
let y_align = alignment.map(|align| align.y().map(|y| y.resolve(styles)));
|
||||
let mut frame = placed.layout(engine, styles, self.regions)?.into_frame();
|
||||
let mut frame = placed.layout(engine, styles, self.regions.base())?.into_frame();
|
||||
frame.meta(styles, false);
|
||||
let item = FlowItem::Placed { frame, x_align, y_align, delta, float, clearance };
|
||||
self.layout_item(engine, item)
|
||||
@ -427,9 +427,11 @@ impl<'a> FlowLayouter<'a> {
|
||||
clearance,
|
||||
..
|
||||
} => {
|
||||
// If the float doesn't fit, queue it for the next region.
|
||||
if !self.regions.size.y.fits(frame.height() + clearance)
|
||||
&& !self.regions.in_last()
|
||||
// If there is a queued float in front or if the float doesn't
|
||||
// fit, queue it for the next region.
|
||||
if !self.pending_floats.is_empty()
|
||||
|| (!self.regions.size.y.fits(frame.height() + clearance)
|
||||
&& !self.regions.in_last())
|
||||
{
|
||||
self.pending_floats.push(item);
|
||||
return Ok(());
|
||||
|
@ -2,7 +2,7 @@ use crate::diag::{bail, At, Hint, SourceResult};
|
||||
use crate::engine::Engine;
|
||||
use crate::foundations::{elem, Content, Packed, Smart, StyleChain};
|
||||
use crate::layout::{
|
||||
Alignment, Axes, Em, Fragment, LayoutMultiple, Length, Regions, Rel, VAlignment,
|
||||
Alignment, Axes, Em, Fragment, LayoutMultiple, Length, Regions, Rel, Size, VAlignment,
|
||||
};
|
||||
use crate::realize::{Behave, Behaviour};
|
||||
|
||||
@ -93,11 +93,10 @@ impl Packed<PlaceElem> {
|
||||
&self,
|
||||
engine: &mut Engine,
|
||||
styles: StyleChain,
|
||||
regions: Regions,
|
||||
base: Size,
|
||||
) -> SourceResult<Fragment> {
|
||||
// The pod is the base area of the region because for absolute
|
||||
// placement we don't really care about the already used area.
|
||||
let base = regions.base();
|
||||
let float = self.float(styles);
|
||||
let alignment = self.alignment(styles);
|
||||
|
||||
|
BIN
tests/ref/bugs/2715-float-order.png
Normal file
BIN
tests/ref/bugs/2715-float-order.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
19
tests/typ/bugs/2715-float-order.typ
Normal file
19
tests/typ/bugs/2715-float-order.typ
Normal file
@ -0,0 +1,19 @@
|
||||
#set page(height: 170pt)
|
||||
#set figure(placement: auto)
|
||||
|
||||
#figure(
|
||||
rect(height: 60pt),
|
||||
caption: [Rectangle I],
|
||||
)
|
||||
|
||||
#figure(
|
||||
rect(height: 50pt),
|
||||
caption: [Rectangle II],
|
||||
)
|
||||
|
||||
#figure(
|
||||
circle(),
|
||||
caption: [Circle],
|
||||
)
|
||||
|
||||
#lorem(20)
|
Loading…
x
Reference in New Issue
Block a user