diff options
author | Simon Sapin <simon.sapin@exyr.org> | 2015-08-18 19:37:15 +0200 |
---|---|---|
committer | Simon Sapin <simon.sapin@exyr.org> | 2015-08-21 21:16:25 +0200 |
commit | 21d69314d4752751f55a250b68a9b7f87368cb92 (patch) | |
tree | acd6f426a38655d622896fadf3b7d4039f79d2da /components/layout/construct.rs | |
parent | 649250130b221685dfa8e570ae07d0d2f634bd40 (diff) | |
download | servo-21d69314d4752751f55a250b68a9b7f87368cb92.tar.gz servo-21d69314d4752751f55a250b68a9b7f87368cb92.zip |
Don’t mark flow_ref::deref_mut as unsafe.
See discussion in https://github.com/servo/servo/pull/7237
Diffstat (limited to 'components/layout/construct.rs')
-rw-r--r-- | components/layout/construct.rs | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/components/layout/construct.rs b/components/layout/construct.rs index fe41ee5b922..f9d11e89915 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -415,7 +415,6 @@ impl<'a> FlowConstructor<'a> { /// `#[inline(always)]` because this is performance critical and LLVM will not inline it /// otherwise. #[inline(always)] - #[allow(unsafe_code)] fn flush_inline_fragments_to_flow_or_list(&mut self, fragment_accumulator: InlineFragmentsAccumulator, flow: &mut FlowRef, @@ -481,7 +480,7 @@ impl<'a> FlowConstructor<'a> { { // FIXME(#6503): Use Arc::get_mut().unwrap() here. - let inline_flow = unsafe { flow_ref::deref_mut(&mut inline_flow_ref) }.as_mut_inline(); + let inline_flow = flow_ref::deref_mut(&mut inline_flow_ref).as_mut_inline(); let (ascent, descent) = @@ -1283,7 +1282,6 @@ impl<'a> FlowConstructor<'a> { /// /// TODO(pcwalton): Add some more fast paths, like toggling `display: none`, adding block kids /// to block parents with no {ib} splits, adding out-of-flow kids, etc. - #[allow(unsafe_code)] pub fn repair_if_possible(&mut self, node: &ThreadSafeLayoutNode) -> bool { // We can skip reconstructing the flow if we don't have to reconstruct and none of our kids // did either. @@ -1314,7 +1312,7 @@ impl<'a> FlowConstructor<'a> { if !flow.is_block_flow() { return false } - let flow = unsafe { flow_ref::deref_mut(flow) }; + let flow = flow_ref::deref_mut(flow); flow::mut_base(flow).restyle_damage.insert(damage); flow.repair_style_and_bubble_inline_sizes(&style); true @@ -1339,26 +1337,22 @@ impl<'a> FlowConstructor<'a> { match fragment.specific { SpecificFragmentInfo::InlineBlock(ref mut inline_block_fragment) => { - let flow_ref = unsafe { - flow_ref::deref_mut(&mut inline_block_fragment.flow_ref) - }; + let flow_ref = flow_ref::deref_mut(&mut inline_block_fragment.flow_ref); flow::mut_base(flow_ref).restyle_damage.insert(damage); // FIXME(pcwalton): Fragment restyle damage too? flow_ref.repair_style_and_bubble_inline_sizes(&style); } SpecificFragmentInfo::InlineAbsoluteHypothetical( ref mut inline_absolute_hypothetical_fragment) => { - let flow_ref = unsafe { - flow_ref::deref_mut(&mut inline_absolute_hypothetical_fragment.flow_ref) - }; + let flow_ref = flow_ref::deref_mut( + &mut inline_absolute_hypothetical_fragment.flow_ref); flow::mut_base(flow_ref).restyle_damage.insert(damage); // FIXME(pcwalton): Fragment restyle damage too? flow_ref.repair_style_and_bubble_inline_sizes(&style); } SpecificFragmentInfo::InlineAbsolute(ref mut inline_absolute_fragment) => { - let flow_ref = unsafe { - flow_ref::deref_mut(&mut inline_absolute_fragment.flow_ref) - }; + let flow_ref = flow_ref::deref_mut( + &mut inline_absolute_fragment.flow_ref); flow::mut_base(flow_ref).restyle_damage.insert(damage); // FIXME(pcwalton): Fragment restyle damage too? flow_ref.repair_style_and_bubble_inline_sizes(&style); @@ -1655,14 +1649,13 @@ impl FlowConstructionUtils for FlowRef { /// Adds a new flow as a child of this flow. Fails if this flow is marked as a leaf. /// /// This must not be public because only the layout constructor can do this. - #[allow(unsafe_code)] fn add_new_child(&mut self, mut new_child: FlowRef) { { - let kid_base = flow::mut_base(unsafe { flow_ref::deref_mut(&mut new_child) }); + let kid_base = flow::mut_base(flow_ref::deref_mut(&mut new_child)); kid_base.parallel.parent = parallel::mut_owned_flow_to_unsafe_flow(self); } - let base = flow::mut_base(unsafe { flow_ref::deref_mut(self) }); + let base = flow::mut_base(flow_ref::deref_mut(self)); base.children.push_back(new_child); let _ = base.parallel.children_count.fetch_add(1, Ordering::Relaxed); } @@ -1675,10 +1668,9 @@ impl FlowConstructionUtils for FlowRef { /// properly computed. (This is not, however, a memory safety problem.) /// /// This must not be public because only the layout constructor can do this. - #[allow(unsafe_code)] fn finish(&mut self) { if !opts::get().bubble_inline_sizes_separately { - unsafe { flow_ref::deref_mut(self) }.bubble_inline_sizes() + flow_ref::deref_mut(self).bubble_inline_sizes() } } } |