Paint float content in the route-D display list

This commit is contained in:
gloamxun committed 2026-10-20 18:40:37 +08:00
1 parent fb22be1a49
commit e791c94cfe
2 files changed
+68 -14

No files matched your search

+38
View File
@@ -1753,6 +1753,44 @@ mod tests {
let svg = list.to_svg();
assert!(svg.contains(">x</text>"));
}
#[test]
fn float_content_is_painted_at_the_top_of_the_page() {
let mut document = Document::new(1000, Vec::new());
document.top_skip = 0;
document.units.push(Unit::float_with_content(
1,
FloatPlacement::Top,
100,
20,
vec![VerticalItem::Rule {
width: 80,
height: 2,
}],
));
document.units.push(Unit::paragraph(2, "hello world"));
let engine = Engine::layout(&document);
let list = engine.pages()[0].display_list();
assert!(list.items.iter().any(|item| matches!(
item,
DisplayItem::Rule {
y: 0,
width: 80,
height: 2,
..
}
)));
let text_y = list
.items
.iter()
.filter_map(|item| match item {
DisplayItem::Text { y, text, .. } if text == "h" => Some(y),
_ => None,
})
.min()
.unwrap();
assert!(*text_y >= 20, "body text starts below the top float");
}
#[test]
fn paragraph_display_list_paints_characters() {
let document = Document::new(400, vec![Unit::paragraph(1, "hello world")]);