Paint float content in the route-D display list
This commit is contained in:
1 parent
fb22be1a49
commit
e791c94cfe
2 files changed
+68
-14
No files matched your search
@@ -8,7 +8,7 @@
|
||||
use crate::cmr10::Cmr10Metrics;
|
||||
use crate::math::{self, MathAtom};
|
||||
use crate::paragraph::ParagraphFont;
|
||||
use crate::{FloatPlacement, Halign, HorizontalItem, Page, VerticalItem};
|
||||
use crate::{Float, FloatPlacement, Halign, HorizontalItem, Page, VerticalItem};
|
||||
|
||||
/// One absolute drawing primitive in scaled points.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
@@ -283,12 +283,7 @@ impl Page {
|
||||
.iter()
|
||||
.filter(|float| float.placement == FloatPlacement::Top)
|
||||
{
|
||||
list.push(DisplayItem::Rule {
|
||||
x: 0,
|
||||
y: float_y,
|
||||
width: float.width,
|
||||
height: float.height,
|
||||
});
|
||||
Self::paint_float(float, 0, float_y, &mut list);
|
||||
float_y += float.height;
|
||||
}
|
||||
y = top_height;
|
||||
@@ -435,14 +430,8 @@ impl Page {
|
||||
.iter()
|
||||
.filter(|float| float.placement == FloatPlacement::Bottom)
|
||||
{
|
||||
list.push(DisplayItem::Rule {
|
||||
x: 0,
|
||||
y: float_y,
|
||||
width: float.width,
|
||||
height: float.height,
|
||||
});
|
||||
Self::paint_float(float, 0, float_y, &mut list);
|
||||
float_y += float.height;
|
||||
list.width = list.width.max(float.width);
|
||||
}
|
||||
y = y.max(float_y);
|
||||
}
|
||||
@@ -462,6 +451,33 @@ impl Page {
|
||||
list
|
||||
}
|
||||
|
||||
/// Paint a float's vertical material, or a dimension rectangle when the
|
||||
/// float carries no content.
|
||||
fn paint_float(float: &Float, x: i64, y: i64, list: &mut DisplayList) {
|
||||
if float.content.is_empty() {
|
||||
list.push(DisplayItem::Rule {
|
||||
x,
|
||||
y,
|
||||
width: float.width,
|
||||
height: float.height,
|
||||
});
|
||||
list.width = list.width.max(float.width);
|
||||
return;
|
||||
}
|
||||
let page = Page {
|
||||
items: float.content.clone(),
|
||||
insertions: Vec::new(),
|
||||
marks: Vec::new(),
|
||||
floats: Vec::new(),
|
||||
sources: Vec::new(),
|
||||
hash: 0,
|
||||
};
|
||||
let mut content = page.display_list();
|
||||
content.place(x, y);
|
||||
list.items.extend(content.items);
|
||||
list.images.extend(content.images);
|
||||
list.width = list.width.max(content.width);
|
||||
}
|
||||
fn paint_math(
|
||||
atom: &MathAtom,
|
||||
font: &Cmr10Metrics,
|
||||
|
||||
Reference in new issue
Block a user