mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Don’t mark flow_ref::deref_mut as unsafe.
See discussion in https://github.com/servo/servo/pull/7237
This commit is contained in:
parent
649250130b
commit
21d69314d4
10 changed files with 53 additions and 72 deletions
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue