Paint a footnote separator above insertions
This commit is contained in:
1 parent
493180125a
commit
6e1ee13d68
3 files changed
+54
No files matched your search
@@ -1372,6 +1372,38 @@ mod tests {
|
|||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn footnote_separator_sits_above_the_insertion_area() {
|
||||||
|
let page = Page {
|
||||||
|
items: vec![
|
||||||
|
VerticalItem::Box(VerticalBox {
|
||||||
|
width: 100 * 65_536,
|
||||||
|
height: 100 * 65_536,
|
||||||
|
}),
|
||||||
|
VerticalItem::Insertion(Insertion {
|
||||||
|
class: 0,
|
||||||
|
height: 20 * 65_536,
|
||||||
|
items: vec![VerticalItem::Rule {
|
||||||
|
width: 100 * 65_536,
|
||||||
|
height: 2 * 65_536,
|
||||||
|
}],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
insertions: Vec::new(),
|
||||||
|
marks: Vec::new(),
|
||||||
|
floats: Vec::new(),
|
||||||
|
sources: Vec::new(),
|
||||||
|
hash: 0,
|
||||||
|
};
|
||||||
|
let list = page.display_list_with_goal(700 * 65_536);
|
||||||
|
let separator = list.items.iter().find_map(|item| match item {
|
||||||
|
crate::render::DisplayItem::Rule { y, width, .. } if *width == 40 * 65_536 => Some(*y),
|
||||||
|
_ => None,
|
||||||
|
});
|
||||||
|
let y = separator.expect("separator rule");
|
||||||
|
assert!(y > 690 * 65_536);
|
||||||
|
assert!(y < 700 * 65_536);
|
||||||
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn insertion_material_sits_at_the_page_bottom() {
|
fn insertion_material_sits_at_the_page_bottom() {
|
||||||
let page = Page {
|
let page = Page {
|
||||||
|
|||||||
@@ -238,6 +238,17 @@ impl Page {
|
|||||||
pub fn display_list_with_goal(&self, page_goal: i64) -> DisplayList {
|
pub fn display_list_with_goal(&self, page_goal: i64) -> DisplayList {
|
||||||
let mut list = DisplayList::default();
|
let mut list = DisplayList::default();
|
||||||
let mut y = 0_i64;
|
let mut y = 0_i64;
|
||||||
|
let body_width = self
|
||||||
|
.items
|
||||||
|
.iter()
|
||||||
|
.map(|item| match item {
|
||||||
|
VerticalItem::Halign(halign) => halign.width,
|
||||||
|
VerticalItem::Rule { width, .. } => *width,
|
||||||
|
VerticalItem::Box(box_) => box_.width,
|
||||||
|
_ => 0,
|
||||||
|
})
|
||||||
|
.max()
|
||||||
|
.unwrap_or(0);
|
||||||
let items: Vec<VerticalItem> = self
|
let items: Vec<VerticalItem> = self
|
||||||
.items
|
.items
|
||||||
.iter()
|
.iter()
|
||||||
@@ -336,6 +347,15 @@ impl Page {
|
|||||||
};
|
};
|
||||||
insertion_list.place(0, top);
|
insertion_list.place(0, top);
|
||||||
let width = insertion_list.width.max(list.width);
|
let width = insertion_list.width.max(list.width);
|
||||||
|
if page_goal > 0 && top > y + 26_214 {
|
||||||
|
let separator_width = (body_width * 2 / 5).max(65_536);
|
||||||
|
list.push(DisplayItem::Rule {
|
||||||
|
x: 0,
|
||||||
|
y: top - 26_214,
|
||||||
|
width: separator_width,
|
||||||
|
height: 26_214,
|
||||||
|
});
|
||||||
|
}
|
||||||
y = top + insertion_list.height;
|
y = top + insertion_list.height;
|
||||||
list.items.extend(insertion_list.items);
|
list.items.extend(insertion_list.items);
|
||||||
list.images.extend(insertion_list.images);
|
list.images.extend(insertion_list.images);
|
||||||
|
|||||||
@@ -261,3 +261,5 @@ M7 (partial): DisplayList::special injects raw PDF content-stream operators; SVG
|
|||||||
M2 (partial): insertion material is expanded into the page display list at its reserved position, so footnote/float material is no longer dropped by the painter; page-bottom placement and rules remain to be modelled.
|
M2 (partial): insertion material is expanded into the page display list at its reserved position, so footnote/float material is no longer dropped by the painter; page-bottom placement and rules remain to be modelled.
|
||||||
|
|
||||||
M2 (partial): Page::display_list_with_goal places insertion material at page_goal minus its height; page builders can pass the real goal. Footnote rules and float-page policy remain.
|
M2 (partial): Page::display_list_with_goal places insertion material at page_goal minus its height; page builders can pass the real goal. Footnote rules and float-page policy remain.
|
||||||
|
|
||||||
|
M2 (partial): a 0.4pt rule at 40% of the body width is painted above insertion material when a page goal is supplied.
|
||||||
Reference in new issue
Block a user