Implement native PDF links and vertical discard lists
This commit is contained in:
1 parent
b6567f67e2
commit
a53d9c9bf9
29 files changed
+980
-109
No files matched your search
@@ -95,6 +95,8 @@ pub struct NativePageState {
|
||||
pub max_depth: i32,
|
||||
pub nodes: Vec<NativeVerticalNode>,
|
||||
pub contributions: VecDeque<NativeVerticalNode>,
|
||||
#[serde(default)]
|
||||
pub(super) discards: Vec<NativeVerticalNode>,
|
||||
pub dead_cycles: i32,
|
||||
pub output_active: bool,
|
||||
#[serde(default)]
|
||||
@@ -157,6 +159,7 @@ impl NativePageState {
|
||||
}
|
||||
|
||||
pub(super) fn resume_contributions(&mut self, output_material: Vec<NativeVerticalNode>) {
|
||||
self.discards.clear();
|
||||
let held = self.insertions.held.drain(..);
|
||||
for node in held.chain(output_material).rev() {
|
||||
self.contributions.push_front(node);
|
||||
@@ -194,6 +197,23 @@ impl NativePageState {
|
||||
_ => 0,
|
||||
};
|
||||
let dimensions = front.dimensions();
|
||||
if !self.started
|
||||
&& matches!(
|
||||
front,
|
||||
NativeVerticalNode::Glue(_)
|
||||
| NativeVerticalNode::NamedGlue(_, _)
|
||||
| NativeVerticalNode::Kern(_)
|
||||
| NativeVerticalNode::ImplicitKern(_)
|
||||
| NativeVerticalNode::Penalty(_)
|
||||
)
|
||||
{
|
||||
let node = self.contributions.pop_front().unwrap();
|
||||
reads.insert(Dependency::Parameter(Parameter::Savingvdiscards));
|
||||
if state.parameter(Parameter::Savingvdiscards).width() > 0 {
|
||||
self.discards.push(node);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if !self.started && dimensions.is_some() {
|
||||
self.started = true;
|
||||
self.freeze_specs(state, trace);
|
||||
@@ -207,10 +227,6 @@ impl NativePageState {
|
||||
}
|
||||
let penalty = match front {
|
||||
NativeVerticalNode::Glue(_) | NativeVerticalNode::NamedGlue(_, _) => {
|
||||
if !self.started {
|
||||
self.contributions.pop_front();
|
||||
continue;
|
||||
}
|
||||
self.nodes
|
||||
.last()
|
||||
.filter(|n| {
|
||||
@@ -227,10 +243,6 @@ impl NativePageState {
|
||||
.map(|_| 0)
|
||||
}
|
||||
NativeVerticalNode::Kern(_) | NativeVerticalNode::ImplicitKern(_) => {
|
||||
if !self.started {
|
||||
self.contributions.pop_front();
|
||||
continue;
|
||||
}
|
||||
if self.contributions.len() == 1 {
|
||||
return Ok(None);
|
||||
}
|
||||
@@ -240,13 +252,7 @@ impl NativePageState {
|
||||
)
|
||||
.then_some(0)
|
||||
}
|
||||
NativeVerticalNode::Penalty(p) => {
|
||||
if !self.started {
|
||||
self.contributions.pop_front();
|
||||
continue;
|
||||
}
|
||||
Some(*p)
|
||||
}
|
||||
NativeVerticalNode::Penalty(p) => Some(*p),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(p) = penalty.filter(|p| *p < 10000) {
|
||||
|
||||
Reference in new issue
Block a user