diff options
author | Ms2ger <ms2ger@gmail.com> | 2015-06-29 14:51:26 +0200 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2015-06-29 15:07:50 +0200 |
commit | c214c03375e2d90898c502ceef1d50f83b99ccd4 (patch) | |
tree | adcda8a532a3e9c042034e991023848805ce4e71 /components/layout/parallel.rs | |
parent | 342ea7a44b26f9cc701b2a10757c4ac0aec93aeb (diff) | |
download | servo-c214c03375e2d90898c502ceef1d50f83b99ccd4.tar.gz servo-c214c03375e2d90898c502ceef1d50f83b99ccd4.zip |
Pass shared_layout_context to run_queue_with_custom_work_data_type.
Diffstat (limited to 'components/layout/parallel.rs')
-rw-r--r-- | components/layout/parallel.rs | 35 |
1 files 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<To,F>( queue: &mut WorkQueue<SharedLayoutContextWrapper, WorkQueueData>, - callback: F) + callback: F, + shared_layout_context: &SharedLayoutContext) where To: 'static + Send, F: FnOnce(&mut WorkQueue<SharedLayoutContextWrapper,To>) { - unsafe { - let queue: &mut WorkQueue<SharedLayoutContextWrapper,To> = mem::transmute(queue); - callback(queue); - queue.run(); - } + queue.data = SharedLayoutContextWrapper(shared_layout_context as *const _); + + let queue: &mut WorkQueue<SharedLayoutContextWrapper,To> = 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<SharedLayoutContextWrapper, WorkQueueData>) { - 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<SharedLayoutContextWrapper, WorkQueueData>) { - 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); } |