From c214c03375e2d90898c502ceef1d50f83b99ccd4 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 29 Jun 2015 14:51:26 +0200 Subject: [PATCH] Pass shared_layout_context to run_queue_with_custom_work_data_type. --- components/layout/parallel.rs | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/components/layout/parallel.rs b/components/layout/parallel.rs index 3e186f06d95..99bed12911e 100644 --- a/components/layout/parallel.rs +++ b/components/layout/parallel.rs @@ -446,28 +446,29 @@ fn build_display_list(unsafe_flow: UnsafeFlow, fn run_queue_with_custom_work_data_type( queue: &mut WorkQueue, - callback: F) + callback: F, + shared_layout_context: &SharedLayoutContext) where To: 'static + Send, F: FnOnce(&mut WorkQueue) { - unsafe { - let queue: &mut WorkQueue = mem::transmute(queue); - callback(queue); - queue.run(); - } + queue.data = SharedLayoutContextWrapper(shared_layout_context as *const _); + + let queue: &mut WorkQueue = unsafe { + mem::transmute(queue) + }; + callback(queue); + queue.run(); + + queue.data = SharedLayoutContextWrapper(ptr::null()); } pub fn traverse_dom_preorder(root: LayoutNode, shared_layout_context: &SharedLayoutContext, queue: &mut WorkQueue) { - queue.data = SharedLayoutContextWrapper(shared_layout_context as *const _); - run_queue_with_custom_work_data_type(queue, |queue| { queue.push(WorkUnit { fun: recalc_style, data: (box vec![layout_node_to_unsafe_layout_node(&root)], 0), }); - }); - - queue.data = SharedLayoutContextWrapper(ptr::null()); + }, shared_layout_context); } pub fn traverse_flow_tree_preorder( @@ -482,8 +483,6 @@ pub fn traverse_flow_tree_preorder( root.traverse_postorder(&bubble_inline_sizes); } - queue.data = SharedLayoutContextWrapper(shared_layout_context as *const _); - run_queue_with_custom_work_data_type(queue, |queue| { profile(time::ProfilerCategory::LayoutParallelWarmup, profiler_metadata, time_profiler_chan, || { @@ -492,9 +491,7 @@ pub fn traverse_flow_tree_preorder( data: (box vec![mut_owned_flow_to_unsafe_flow(root)], 0), }) }); - }); - - queue.data = SharedLayoutContextWrapper(ptr::null()) + }, shared_layout_context); } pub fn build_display_list_for_subtree( @@ -503,8 +500,6 @@ pub fn build_display_list_for_subtree( time_profiler_chan: time::ProfilerChan, shared_layout_context: &SharedLayoutContext, queue: &mut WorkQueue) { - queue.data = SharedLayoutContextWrapper(shared_layout_context as *const _); - run_queue_with_custom_work_data_type(queue, |queue| { profile(time::ProfilerCategory::LayoutParallelWarmup, profiler_metadata, time_profiler_chan, || { @@ -513,7 +508,5 @@ pub fn build_display_list_for_subtree( data: (box vec![mut_owned_flow_to_unsafe_flow(root)], 0), }) }); - }); - - queue.data = SharedLayoutContextWrapper(ptr::null()) + }, shared_layout_context); }