Replay paged layouts from the edited page

This commit is contained in:
gloamxun committed 2026-10-23 03:46:12 +08:00
1 parent 6c3636c7c5
commit 043ae7f072
5 files changed
+236 -31

No files matched your search

+20
View File
@@ -155,6 +155,26 @@ impl PageBuilder {
pages
}
/// Build pages starting at a node that begins a page.
///
/// Insertion material is not carried over here: the incremental replay in
/// `Engine` refuses documents that raise insertions, because held-over
/// material can add pages that have no node start of their own.
pub fn build_from(&self, nodes: &[VerticalNode], start: usize) -> Vec<PageFragment> {
let mut pages = Vec::new();
let mut next = self.skip_leading(nodes, start);
while next < nodes.len() {
let Some((fragment, after, _)) = self.best_fragment(nodes, next, &BTreeMap::new())
else {
break;
};
let after = after.max(next + 1);
pages.push(fragment);
next = self.skip_leading(nodes, after);
}
pages
}
fn skip_leading(&self, nodes: &[VerticalNode], mut index: usize) -> usize {
while index < nodes.len() {
match nodes[index] {