Share packed native lists across copied boxes and shipouts
This commit is contained in:
1 parent
ca3730338e
commit
da48cf9cad
16 files changed
+157
-67
No files matched your search
@@ -9,8 +9,8 @@ impl NativeBox {
|
||||
visit: &mut impl FnMut(&mut Arc<NativeFont>),
|
||||
) {
|
||||
match &mut self.content {
|
||||
BoxContent::Horizontal(nodes) => rebind_horizontal(nodes, visit),
|
||||
BoxContent::Vertical(nodes) => rebind_vertical(nodes, visit),
|
||||
BoxContent::Horizontal(nodes) => rebind_horizontal(Arc::make_mut(nodes).as_mut_slice(), visit),
|
||||
BoxContent::Vertical(nodes) => rebind_vertical(Arc::make_mut(nodes).as_mut_slice(), visit),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ fn prepare(
|
||||
match &mut packed.content {
|
||||
BoxContent::Horizontal(nodes) => {
|
||||
packed.interword_runs = shape_row(nodes, packed.setting, remaining, cancellation)?;
|
||||
for node in nodes {
|
||||
for node in Arc::make_mut(nodes) {
|
||||
let child = match node {
|
||||
TextNode::Box(item)
|
||||
| TextNode::MathChar(item)
|
||||
@@ -56,7 +56,7 @@ fn prepare(
|
||||
}
|
||||
}
|
||||
BoxContent::Vertical(nodes) => {
|
||||
for node in nodes {
|
||||
for node in Arc::make_mut(nodes) {
|
||||
let child = match node {
|
||||
NativeVerticalNode::Box(item)
|
||||
| NativeVerticalNode::Line(item)
|
||||
|
||||
@@ -50,8 +50,8 @@ fn descend_mut<'a>(b: &'a mut NativeBox, path: &[usize]) -> &'a mut NativeBox {
|
||||
None => b,
|
||||
Some((&i, rest)) => descend_mut(
|
||||
match &mut b.content {
|
||||
BoxContent::Vertical(v) => vertical_box_mut(&mut v[i]),
|
||||
BoxContent::Horizontal(v) => text_box_mut(&mut v[i]),
|
||||
BoxContent::Vertical(v) => vertical_box_mut(&mut Arc::make_mut(v)[i]),
|
||||
BoxContent::Horizontal(v) => text_box_mut(&mut Arc::make_mut(v)[i]),
|
||||
},
|
||||
rest,
|
||||
),
|
||||
@@ -60,8 +60,8 @@ fn descend_mut<'a>(b: &'a mut NativeBox, path: &[usize]) -> &'a mut NativeBox {
|
||||
fn refresh(b: &mut NativeBox, path: &[usize]) {
|
||||
if let Some((&i, rest)) = path.split_first() {
|
||||
let child = match &mut b.content {
|
||||
BoxContent::Vertical(v) => vertical_box_mut(&mut v[i]),
|
||||
BoxContent::Horizontal(v) => text_box_mut(&mut v[i]),
|
||||
BoxContent::Vertical(v) => vertical_box_mut(&mut Arc::make_mut(v)[i]),
|
||||
BoxContent::Horizontal(v) => text_box_mut(&mut Arc::make_mut(v)[i]),
|
||||
};
|
||||
refresh(child, rest);
|
||||
}
|
||||
@@ -130,8 +130,8 @@ impl VerticalBuilder {
|
||||
pub(in crate::execution) fn push(&mut self, node: NativeVerticalNode) {
|
||||
match self.tail_box_mut().map(|b| &mut b.content) {
|
||||
None => self.nodes.push(node),
|
||||
Some(BoxContent::Vertical(v)) => v.push(node),
|
||||
Some(BoxContent::Horizontal(v)) => v.push(horizontal(node)),
|
||||
Some(BoxContent::Vertical(v)) => Arc::make_mut(v).push(node),
|
||||
Some(BoxContent::Horizontal(v)) => Arc::make_mut(v).push(horizontal(node)),
|
||||
}
|
||||
self.refresh_tail();
|
||||
}
|
||||
@@ -169,8 +169,8 @@ impl VerticalBuilder {
|
||||
fn pop(&mut self) -> Option<Removed> {
|
||||
let node = match self.tail_box_mut().map(|b| &mut b.content) {
|
||||
None => self.nodes.pop().map(Removed::Vertical),
|
||||
Some(BoxContent::Vertical(v)) => v.pop().map(Removed::Vertical),
|
||||
Some(BoxContent::Horizontal(v)) => v.pop().map(Removed::Text),
|
||||
Some(BoxContent::Vertical(v)) => Arc::make_mut(v).pop().map(Removed::Vertical),
|
||||
Some(BoxContent::Horizontal(v)) => Arc::make_mut(v).pop().map(Removed::Text),
|
||||
};
|
||||
self.refresh_tail();
|
||||
node
|
||||
|
||||
Reference in new issue
Block a user