mirror of
https://github.com/servo/servo.git
synced 2025-08-12 00:45:33 +01:00
layout: Make ParallelPreorderFlowTraversal
more generic
This commit is contained in:
parent
2cec5c6c5e
commit
3b363d4e5d
1 changed files with 23 additions and 5 deletions
|
@ -163,7 +163,17 @@ trait ParallelPostorderFlowTraversal : PostorderFlowTraversal {
|
||||||
trait ParallelPreorderFlowTraversal : PreorderFlowTraversal {
|
trait ParallelPreorderFlowTraversal : PreorderFlowTraversal {
|
||||||
fn run_parallel(&mut self,
|
fn run_parallel(&mut self,
|
||||||
unsafe_flow: UnsafeFlow,
|
unsafe_flow: UnsafeFlow,
|
||||||
proxy: &mut WorkerProxy<*mut LayoutContext,PaddedUnsafeFlow>) {
|
proxy: &mut WorkerProxy<*mut LayoutContext,PaddedUnsafeFlow>);
|
||||||
|
|
||||||
|
fn run_parallel_helper(&mut self,
|
||||||
|
unsafe_flow: UnsafeFlow,
|
||||||
|
proxy: &mut WorkerProxy<*mut LayoutContext,PaddedUnsafeFlow>,
|
||||||
|
top_down_func: extern "Rust" fn(PaddedUnsafeFlow,
|
||||||
|
&mut WorkerProxy<*mut LayoutContext,
|
||||||
|
PaddedUnsafeFlow>),
|
||||||
|
bottom_up_func: extern "Rust" fn(PaddedUnsafeFlow,
|
||||||
|
&mut WorkerProxy<*mut LayoutContext,
|
||||||
|
PaddedUnsafeFlow>)) {
|
||||||
let mut had_children = false;
|
let mut had_children = false;
|
||||||
unsafe {
|
unsafe {
|
||||||
// Get a real flow.
|
// Get a real flow.
|
||||||
|
@ -176,7 +186,7 @@ trait ParallelPreorderFlowTraversal : PreorderFlowTraversal {
|
||||||
for kid in flow::child_iter(*flow) {
|
for kid in flow::child_iter(*flow) {
|
||||||
had_children = true;
|
had_children = true;
|
||||||
proxy.push(WorkUnit {
|
proxy.push(WorkUnit {
|
||||||
fun: assign_widths,
|
fun: top_down_func,
|
||||||
data: UnsafeFlowConversions::from_flow(&borrowed_flow_to_unsafe_flow(kid)),
|
data: UnsafeFlowConversions::from_flow(&borrowed_flow_to_unsafe_flow(kid)),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -185,15 +195,23 @@ trait ParallelPreorderFlowTraversal : PreorderFlowTraversal {
|
||||||
|
|
||||||
// If there were no more children, start assigning heights.
|
// If there were no more children, start assigning heights.
|
||||||
if !had_children {
|
if !had_children {
|
||||||
assign_heights_and_store_overflow(UnsafeFlowConversions::from_flow(&unsafe_flow),
|
bottom_up_func(UnsafeFlowConversions::from_flow(&unsafe_flow), proxy)
|
||||||
proxy)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ParallelPostorderFlowTraversal for BubbleWidthsTraversal<'a> {}
|
impl<'a> ParallelPostorderFlowTraversal for BubbleWidthsTraversal<'a> {}
|
||||||
|
|
||||||
impl<'a> ParallelPreorderFlowTraversal for AssignWidthsTraversal<'a> {}
|
impl<'a> ParallelPreorderFlowTraversal for AssignWidthsTraversal<'a> {
|
||||||
|
fn run_parallel(&mut self,
|
||||||
|
unsafe_flow: UnsafeFlow,
|
||||||
|
proxy: &mut WorkerProxy<*mut LayoutContext,PaddedUnsafeFlow>) {
|
||||||
|
self.run_parallel_helper(unsafe_flow,
|
||||||
|
proxy,
|
||||||
|
assign_widths,
|
||||||
|
assign_heights_and_store_overflow)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a> ParallelPostorderFlowTraversal for AssignHeightsAndStoreOverflowTraversal<'a> {}
|
impl<'a> ParallelPostorderFlowTraversal for AssignHeightsAndStoreOverflowTraversal<'a> {}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue