From d0a29c3951a3c8b473cf9dc83101281f555deae2 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 24 Jun 2015 22:33:32 +0200 Subject: [PATCH] Use a dedicated type for the opaque type parameter to WorkQueue in layout. Currently, we use UnsafeFlow and UnsafeLayoutNode, both of which are aliases for (usize, usize) and thus interconvertible. This change should make it clearer that the WorkQueue is not limited to one particular type. --- components/layout/layout_task.rs | 4 ++-- components/layout/parallel.rs | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index 58a12cf9472..e3349ef19de 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -19,7 +19,7 @@ use fragment::{Fragment, FragmentBorderBoxIterator}; use incremental::{LayoutDamageComputation, REFLOW, REFLOW_ENTIRE_DOCUMENT, REPAINT}; use layout_debug; use opaque_node::OpaqueNodeMethods; -use parallel::{self, UnsafeFlow}; +use parallel::{self, WorkQueueData}; use sequential; use wrapper::LayoutNode; @@ -109,7 +109,7 @@ pub struct LayoutTaskData { pub stylist: Box, /// The workers that we use for parallel operation. - pub parallel_traversal: Option>, + pub parallel_traversal: Option>, /// The dirty rect. Used during display list construction. pub dirty: Rect, diff --git a/components/layout/parallel.rs b/components/layout/parallel.rs index 9cc60f31aee..474874ebc1c 100644 --- a/components/layout/parallel.rs +++ b/components/layout/parallel.rs @@ -29,6 +29,8 @@ use util::workqueue::{WorkQueue, WorkUnit, WorkerProxy}; const CHUNK_SIZE: usize = 64; +pub struct WorkQueueData(usize, usize); + #[allow(dead_code)] fn static_assertion(node: UnsafeLayoutNode) { unsafe { @@ -447,7 +449,7 @@ fn build_display_list(unsafe_flow: UnsafeFlow, } fn run_queue_with_custom_work_data_type( - queue: &mut WorkQueue, + queue: &mut WorkQueue, callback: F) where To: 'static + Send, F: FnOnce(&mut WorkQueue) { unsafe { @@ -459,7 +461,7 @@ fn run_queue_with_custom_work_data_type( pub fn traverse_dom_preorder(root: LayoutNode, shared_layout_context: &SharedLayoutContext, - queue: &mut WorkQueue) { + queue: &mut WorkQueue) { queue.data = SharedLayoutContextWrapper(shared_layout_context as *const _); run_queue_with_custom_work_data_type(queue, |queue| { @@ -477,7 +479,7 @@ pub fn traverse_flow_tree_preorder( profiler_metadata: ProfilerMetadata, time_profiler_chan: time::ProfilerChan, shared_layout_context: &SharedLayoutContext, - queue: &mut WorkQueue) { + queue: &mut WorkQueue) { if opts::get().bubble_inline_sizes_separately { let layout_context = LayoutContext::new(shared_layout_context); let bubble_inline_sizes = BubbleISizes { layout_context: &layout_context }; @@ -504,7 +506,7 @@ pub fn build_display_list_for_subtree( profiler_metadata: ProfilerMetadata, time_profiler_chan: time::ProfilerChan, shared_layout_context: &SharedLayoutContext, - queue: &mut WorkQueue) { + queue: &mut WorkQueue) { queue.data = SharedLayoutContextWrapper(shared_layout_context as *const _); run_queue_with_custom_work_data_type(queue, |queue| {