Skip to content

PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust

M12: docstrings for the layout helpers and test the flowed-border change touches

Eric Kaden3cf6b0e589ca
diff --git a/crates/xfa/src/layout.rs b/crates/xfa/src/layout.rs
index ca0d809f9..60c2e41ba 100644
--- a/crates/xfa/src/layout.rs
+++ b/crates/xfa/src/layout.rs
@@ -155,6 +155,8 @@ impl Ctx {
Ctx { font: self.font.apply(&c.font), para: self.para.apply(&c.para), som: self.som.clone() }
}
+ /// [`Self::child`] for object `c`, its SOM path extended by its name and `index` among the
+ /// siblings of that name (an unnamed object adds nothing).
fn with_som(&self, c: &Common, index: usize) -> Ctx {
let mut out = self.child(c);
if let Some(n) = &c.name {
@@ -619,6 +621,8 @@ impl Layouter<'_> {
self.new_page()
}
+ /// The current content area, how far down it the flow is, and whether anything has been
+ /// placed in it; before the first page, an empty letter-size page from its top.
fn cursor(&self) -> (Rect, f64, bool) {
match &self.cur {
Some(c) => (c.rect, c.y, c.placed),
diff --git a/crates/xfa/src/tests.rs b/crates/xfa/src/tests.rs
index 2bd19ddd2..110b89629 100644
--- a/crates/xfa/src/tests.rs
+++ b/crates/xfa/src/tests.rs
@@ -2021,6 +2021,8 @@ fn repeating_rows_in_a_wrapped_container_get_the_instances_the_data_holds() {
assert_eq!(form.pages.iter().flat_map(widgets).filter(|w| w.name.starts_with("what")).count(), 1);
}
+/// A multi-line field with a minimum height and no fixed one grows to hold its text, moving
+/// what follows down; one with a fixed height keeps it.
#[test]
fn a_multi_line_field_without_a_height_grows_to_hold_its_text() {
let place = |data: &str| {