mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #6463 - Ms2ger:layout-reduce-unsafe, r=SimonSapin
Reduce the scope of the unsafe block in ParallelPostorderDomTraversal. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6463) <!-- Reviewable:end -->
This commit is contained in:
commit
f812390d3a
1 changed files with 14 additions and 18 deletions
|
@ -12,7 +12,6 @@ use context::{LayoutContext, SharedLayoutContextWrapper, SharedLayoutContext};
|
|||
use flow::{Flow, MutableFlowUtils, PreorderFlowTraversal, PostorderFlowTraversal};
|
||||
use flow;
|
||||
use flow_ref::FlowRef;
|
||||
use data::LayoutDataWrapper;
|
||||
use traversal::{BubbleISizes, AssignISizes, AssignBSizesAndStoreOverflow};
|
||||
use traversal::{ComputeAbsolutePositions, BuildDisplayList};
|
||||
use traversal::{RecalcStyleForNode, ConstructFlows};
|
||||
|
@ -187,24 +186,21 @@ trait ParallelPostorderDomTraversal : PostorderDomTraversal {
|
|||
Some(parent) => parent,
|
||||
};
|
||||
|
||||
unsafe {
|
||||
let parent_layout_data =
|
||||
(*parent.borrow_layout_data_unchecked()).as_ref().expect("no layout data");
|
||||
let parent_layout_data = unsafe {
|
||||
&*parent.borrow_layout_data_unchecked()
|
||||
};
|
||||
let parent_layout_data = parent_layout_data.as_ref().expect("no layout data");
|
||||
unsafe_node = layout_node_to_unsafe_layout_node(&parent);
|
||||
|
||||
unsafe_node = layout_node_to_unsafe_layout_node(&parent);
|
||||
|
||||
let parent_layout_data: &LayoutDataWrapper =
|
||||
mem::transmute(parent_layout_data);
|
||||
if parent_layout_data
|
||||
.data
|
||||
.parallel
|
||||
.children_count
|
||||
.fetch_sub(1, Ordering::Relaxed) == 1 {
|
||||
// We were the last child of our parent. Construct flows for our parent.
|
||||
} else {
|
||||
// Get out of here and find another node to work on.
|
||||
break
|
||||
}
|
||||
if parent_layout_data
|
||||
.data
|
||||
.parallel
|
||||
.children_count
|
||||
.fetch_sub(1, Ordering::Relaxed) == 1 {
|
||||
// We were the last child of our parent. Construct flows for our parent.
|
||||
} else {
|
||||
// Get out of here and find another node to work on.
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue