Use the Deref traits for FlowRefs.

This patch switches FlowRefs to using the Deref and DerefMut traits, instead of
the custom `get` and `get_mut` functions.
This commit is contained in:
Clark Gaebel 2014-10-15 10:57:25 -07:00
parent afc144aa39
commit 76ed7484eb
10 changed files with 76 additions and 74 deletions

View file

@ -224,12 +224,12 @@ trait ParallelPostorderFlowTraversal : PostorderFlowTraversal {
let flow: &mut FlowRef = mem::transmute(&unsafe_flow);
// Perform the appropriate traversal.
if self.should_process(flow.get_mut()) {
self.process(flow.get_mut());
if self.should_process(flow.deref_mut()) {
self.process(flow.deref_mut());
}
let base = flow::mut_base(flow.get_mut());
let base = flow::mut_base(flow.deref_mut());
// Reset the count of children for the next layout traversal.
base.parallel.children_count.store(base.children.len() as int, Relaxed);
@ -245,7 +245,7 @@ trait ParallelPostorderFlowTraversal : PostorderFlowTraversal {
// of our parent to finish processing? If so, we can continue
// on with our parent; otherwise, we've gotta wait.
let parent: &mut FlowRef = mem::transmute(&unsafe_parent);
let parent_base = flow::mut_base(parent.get_mut());
let parent_base = flow::mut_base(parent.deref_mut());
if parent_base.parallel.children_count.fetch_sub(1, SeqCst) == 1 {
// We were the last child of our parent. Reflow our parent.
unsafe_flow = unsafe_parent
@ -279,13 +279,13 @@ trait ParallelPreorderFlowTraversal : PreorderFlowTraversal {
// Get a real flow.
let flow: &mut FlowRef = mem::transmute(&unsafe_flow);
if self.should_process(flow.get_mut()) {
if self.should_process(flow.deref_mut()) {
// Perform the appropriate traversal.
self.process(flow.get_mut());
self.process(flow.deref_mut());
}
// Possibly enqueue the children.
for kid in flow::child_iter(flow.get_mut()) {
for kid in flow::child_iter(flow.deref_mut()) {
had_children = true;
proxy.push(WorkUnit {
fun: top_down_func,
@ -397,9 +397,11 @@ fn build_display_list(unsafe_flow: UnsafeFlow,
proxy: &mut WorkerProxy<*const SharedLayoutContext, UnsafeFlow>) {
let shared_layout_context = unsafe { &**proxy.user_data() };
let layout_context = LayoutContext::new(shared_layout_context);
let build_display_list_traversal = BuildDisplayList {
layout_context: &layout_context,
};
build_display_list_traversal.run_parallel(unsafe_flow, proxy);
}
@ -428,7 +430,7 @@ pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
if shared_layout_context.opts.bubble_inline_sizes_separately {
let layout_context = LayoutContext::new(shared_layout_context);
let bubble_inline_sizes = BubbleISizes { layout_context: &layout_context };
root.get_mut().traverse_postorder(&bubble_inline_sizes);
root.traverse_postorder(&bubble_inline_sizes);
}
queue.data = shared_layout_context as *const _;