Resolve FitR destinations using shipped box geometry
This commit is contained in:
1 parent
22154b53a6
commit
003d5d8726
8 files changed
+123
-40
No files matched your search
@@ -151,8 +151,8 @@ pub(super) enum BoxPaint<'a> {
|
||||
PdfColor,
|
||||
PdfGraphics,
|
||||
PdfTextSpace(crate::pdf_device::text_spaces::SpaceOperation),
|
||||
RowStart(RowLayout),
|
||||
PdfLink(&'a OutputNode, Option<RowLayout>),
|
||||
RowStart(BoxLayout),
|
||||
PdfLink(&'a OutputNode, BoxLayout),
|
||||
Output(&'a OutputNode),
|
||||
}
|
||||
|
||||
@@ -197,7 +197,8 @@ pub(super) struct LeaderEffects {
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub(super) struct RowLayout {
|
||||
pub(super) struct BoxLayout {
|
||||
pub horizontal: bool,
|
||||
pub left: i64,
|
||||
pub baseline: i64,
|
||||
pub width: i64,
|
||||
@@ -802,14 +803,30 @@ impl NativeBox {
|
||||
match &self.content {
|
||||
BoxContent::Horizontal(nodes) => {
|
||||
budget.inside_leader(nodes.len())?;
|
||||
let row = RowLayout { left: x, baseline: y, width: self.width,
|
||||
height: self.height, depth: self.depth, level };
|
||||
let row = BoxLayout {
|
||||
horizontal: true,
|
||||
left: x,
|
||||
baseline: y,
|
||||
width: self.width,
|
||||
height: self.height,
|
||||
depth: self.depth,
|
||||
level,
|
||||
};
|
||||
if links {
|
||||
emit(x, y, BoxPaint::RowStart(row));
|
||||
}
|
||||
walk_row(&self.packed_horizontal().unwrap(), row, links, budget, emit)?;
|
||||
}
|
||||
BoxContent::Vertical(nodes) => {
|
||||
let container = BoxLayout {
|
||||
horizontal: false,
|
||||
left: x,
|
||||
baseline: y,
|
||||
width: self.width,
|
||||
height: self.height,
|
||||
depth: self.depth,
|
||||
level,
|
||||
};
|
||||
let mut cursor = y - self.height;
|
||||
let (mut cumulative, mut previous) = (0, 0);
|
||||
for node in nodes {
|
||||
@@ -872,7 +889,7 @@ impl NativeBox {
|
||||
cursor += b.depth;
|
||||
}
|
||||
NativeVerticalNode::Output(node) => {
|
||||
walk_output(node, x, cursor, None, links, emit);
|
||||
walk_output(node, x, cursor, container, links, emit);
|
||||
if let Some(image) = node.image_box() {
|
||||
cursor += image.height;
|
||||
emit(x, cursor, BoxPaint::Box(&image));
|
||||
@@ -922,7 +939,7 @@ pub(super) fn bp(n: i64) -> i64 {
|
||||
}
|
||||
fn walk_row(
|
||||
items: &[PackedHorizontal<'_>],
|
||||
row: RowLayout,
|
||||
row: BoxLayout,
|
||||
links: bool,
|
||||
budget: &mut WalkBudget<'_>,
|
||||
emit: &mut dyn FnMut(i64, i64, BoxPaint<'_>),
|
||||
@@ -963,7 +980,7 @@ fn walk_row(
|
||||
x += width;
|
||||
}
|
||||
PackedHorizontal::Output(node) => {
|
||||
walk_output(node, x, y, Some(row), links, emit);
|
||||
walk_output(node, x, y, row, links, emit);
|
||||
if let Some(image) = node.image_box() {
|
||||
emit(x, y, BoxPaint::Box(&image));
|
||||
x += image.width;
|
||||
@@ -979,7 +996,7 @@ fn walk_output(
|
||||
node: &OutputNode,
|
||||
x: i64,
|
||||
y: i64,
|
||||
row: Option<RowLayout>,
|
||||
container: BoxLayout,
|
||||
links: bool,
|
||||
emit: &mut dyn FnMut(i64, i64, BoxPaint<'_>),
|
||||
) {
|
||||
@@ -991,7 +1008,7 @@ fn walk_output(
|
||||
} else if let OutputOperation::PdfTextSpace(operation) = node.operation {
|
||||
emit(x, y, BoxPaint::PdfTextSpace(operation));
|
||||
} else if links && node.is_pdf_link() {
|
||||
emit(x, y, BoxPaint::PdfLink(node, row));
|
||||
emit(x, y, BoxPaint::PdfLink(node, container));
|
||||
}
|
||||
}
|
||||
pub(super) fn box_paragraph(mut b: NativeBox) -> Paragraph {
|
||||
|
||||
Reference in new issue
Block a user