mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01: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
|
/// `#[inline(always)]` because this is performance critical and LLVM will not inline it
|
||||||
/// otherwise.
|
/// otherwise.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[allow(unsafe_code)]
|
|
||||||
fn flush_inline_fragments_to_flow_or_list(&mut self,
|
fn flush_inline_fragments_to_flow_or_list(&mut self,
|
||||||
fragment_accumulator: InlineFragmentsAccumulator,
|
fragment_accumulator: InlineFragmentsAccumulator,
|
||||||
flow: &mut FlowRef,
|
flow: &mut FlowRef,
|
||||||
|
@ -481,7 +480,7 @@ impl<'a> FlowConstructor<'a> {
|
||||||
|
|
||||||
{
|
{
|
||||||
// FIXME(#6503): Use Arc::get_mut().unwrap() here.
|
// 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) =
|
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
|
/// 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.
|
/// 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 {
|
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
|
// We can skip reconstructing the flow if we don't have to reconstruct and none of our kids
|
||||||
// did either.
|
// did either.
|
||||||
|
@ -1314,7 +1312,7 @@ impl<'a> FlowConstructor<'a> {
|
||||||
if !flow.is_block_flow() {
|
if !flow.is_block_flow() {
|
||||||
return false
|
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::mut_base(flow).restyle_damage.insert(damage);
|
||||||
flow.repair_style_and_bubble_inline_sizes(&style);
|
flow.repair_style_and_bubble_inline_sizes(&style);
|
||||||
true
|
true
|
||||||
|
@ -1339,26 +1337,22 @@ impl<'a> FlowConstructor<'a> {
|
||||||
|
|
||||||
match fragment.specific {
|
match fragment.specific {
|
||||||
SpecificFragmentInfo::InlineBlock(ref mut inline_block_fragment) => {
|
SpecificFragmentInfo::InlineBlock(ref mut inline_block_fragment) => {
|
||||||
let flow_ref = unsafe {
|
let flow_ref = flow_ref::deref_mut(&mut inline_block_fragment.flow_ref);
|
||||||
flow_ref::deref_mut(&mut inline_block_fragment.flow_ref)
|
|
||||||
};
|
|
||||||
flow::mut_base(flow_ref).restyle_damage.insert(damage);
|
flow::mut_base(flow_ref).restyle_damage.insert(damage);
|
||||||
// FIXME(pcwalton): Fragment restyle damage too?
|
// FIXME(pcwalton): Fragment restyle damage too?
|
||||||
flow_ref.repair_style_and_bubble_inline_sizes(&style);
|
flow_ref.repair_style_and_bubble_inline_sizes(&style);
|
||||||
}
|
}
|
||||||
SpecificFragmentInfo::InlineAbsoluteHypothetical(
|
SpecificFragmentInfo::InlineAbsoluteHypothetical(
|
||||||
ref mut inline_absolute_hypothetical_fragment) => {
|
ref mut inline_absolute_hypothetical_fragment) => {
|
||||||
let flow_ref = unsafe {
|
let flow_ref = flow_ref::deref_mut(
|
||||||
flow_ref::deref_mut(&mut inline_absolute_hypothetical_fragment.flow_ref)
|
&mut inline_absolute_hypothetical_fragment.flow_ref);
|
||||||
};
|
|
||||||
flow::mut_base(flow_ref).restyle_damage.insert(damage);
|
flow::mut_base(flow_ref).restyle_damage.insert(damage);
|
||||||
// FIXME(pcwalton): Fragment restyle damage too?
|
// FIXME(pcwalton): Fragment restyle damage too?
|
||||||
flow_ref.repair_style_and_bubble_inline_sizes(&style);
|
flow_ref.repair_style_and_bubble_inline_sizes(&style);
|
||||||
}
|
}
|
||||||
SpecificFragmentInfo::InlineAbsolute(ref mut inline_absolute_fragment) => {
|
SpecificFragmentInfo::InlineAbsolute(ref mut inline_absolute_fragment) => {
|
||||||
let flow_ref = unsafe {
|
let flow_ref = flow_ref::deref_mut(
|
||||||
flow_ref::deref_mut(&mut inline_absolute_fragment.flow_ref)
|
&mut inline_absolute_fragment.flow_ref);
|
||||||
};
|
|
||||||
flow::mut_base(flow_ref).restyle_damage.insert(damage);
|
flow::mut_base(flow_ref).restyle_damage.insert(damage);
|
||||||
// FIXME(pcwalton): Fragment restyle damage too?
|
// FIXME(pcwalton): Fragment restyle damage too?
|
||||||
flow_ref.repair_style_and_bubble_inline_sizes(&style);
|
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.
|
/// 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.
|
/// 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) {
|
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);
|
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);
|
base.children.push_back(new_child);
|
||||||
let _ = base.parallel.children_count.fetch_add(1, Ordering::Relaxed);
|
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.)
|
/// properly computed. (This is not, however, a memory safety problem.)
|
||||||
///
|
///
|
||||||
/// This must not be public because only the layout constructor can do this.
|
/// This must not be public because only the layout constructor can do this.
|
||||||
#[allow(unsafe_code)]
|
|
||||||
fn finish(&mut self) {
|
fn finish(&mut self) {
|
||||||
if !opts::get().bubble_inline_sizes_separately {
|
if !opts::get().bubble_inline_sizes_separately {
|
||||||
unsafe { flow_ref::deref_mut(self) }.bubble_inline_sizes()
|
flow_ref::deref_mut(self).bubble_inline_sizes()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1771,7 +1771,6 @@ pub trait InlineFlowDisplayListBuilding {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InlineFlowDisplayListBuilding for InlineFlow {
|
impl InlineFlowDisplayListBuilding for InlineFlow {
|
||||||
#[allow(unsafe_code)]
|
|
||||||
fn build_display_list_for_inline(&mut self, layout_context: &LayoutContext) {
|
fn build_display_list_for_inline(&mut self, layout_context: &LayoutContext) {
|
||||||
// TODO(#228): Once we form lines and have their cached bounds, we can be smarter and
|
// TODO(#228): Once we form lines and have their cached bounds, we can be smarter and
|
||||||
// not recurse on a line if nothing in it can intersect the dirty region.
|
// not recurse on a line if nothing in it can intersect the dirty region.
|
||||||
|
@ -1798,17 +1797,17 @@ impl InlineFlowDisplayListBuilding for InlineFlow {
|
||||||
|
|
||||||
match fragment.specific {
|
match fragment.specific {
|
||||||
SpecificFragmentInfo::InlineBlock(ref mut block_flow) => {
|
SpecificFragmentInfo::InlineBlock(ref mut block_flow) => {
|
||||||
let block_flow = unsafe { flow_ref::deref_mut(&mut block_flow.flow_ref) };
|
let block_flow = flow_ref::deref_mut(&mut block_flow.flow_ref);
|
||||||
flow::mut_base(block_flow).display_list_building_result
|
flow::mut_base(block_flow).display_list_building_result
|
||||||
.add_to(&mut *display_list)
|
.add_to(&mut *display_list)
|
||||||
}
|
}
|
||||||
SpecificFragmentInfo::InlineAbsoluteHypothetical(ref mut block_flow) => {
|
SpecificFragmentInfo::InlineAbsoluteHypothetical(ref mut block_flow) => {
|
||||||
let block_flow = unsafe { flow_ref::deref_mut(&mut block_flow.flow_ref) };
|
let block_flow = flow_ref::deref_mut(&mut block_flow.flow_ref);
|
||||||
flow::mut_base(block_flow).display_list_building_result
|
flow::mut_base(block_flow).display_list_building_result
|
||||||
.add_to(&mut *display_list)
|
.add_to(&mut *display_list)
|
||||||
}
|
}
|
||||||
SpecificFragmentInfo::InlineAbsolute(ref mut block_flow) => {
|
SpecificFragmentInfo::InlineAbsolute(ref mut block_flow) => {
|
||||||
let block_flow = unsafe { flow_ref::deref_mut(&mut block_flow.flow_ref) };
|
let block_flow = flow_ref::deref_mut(&mut block_flow.flow_ref);
|
||||||
flow::mut_base(block_flow).display_list_building_result
|
flow::mut_base(block_flow).display_list_building_result
|
||||||
.add_to(&mut *display_list)
|
.add_to(&mut *display_list)
|
||||||
}
|
}
|
||||||
|
|
|
@ -771,9 +771,8 @@ pub struct AbsoluteDescendantIter<'a> {
|
||||||
|
|
||||||
impl<'a> Iterator for AbsoluteDescendantIter<'a> {
|
impl<'a> Iterator for AbsoluteDescendantIter<'a> {
|
||||||
type Item = &'a mut Flow;
|
type Item = &'a mut Flow;
|
||||||
#[allow(unsafe_code)]
|
|
||||||
fn next(&mut self) -> Option<&'a mut Flow> {
|
fn next(&mut self) -> Option<&'a mut Flow> {
|
||||||
self.iter.next().map(|info| unsafe { flow_ref::deref_mut(&mut info.flow) })
|
self.iter.next().map(|info| flow_ref::deref_mut(&mut info.flow))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1353,10 +1352,9 @@ impl MutableOwnedFlowUtils for FlowRef {
|
||||||
/// This is called during flow construction, so nothing else can be accessing the descendant
|
/// This is called during flow construction, so nothing else can be accessing the descendant
|
||||||
/// flows. This is enforced by the fact that we have a mutable `FlowRef`, which only flow
|
/// flows. This is enforced by the fact that we have a mutable `FlowRef`, which only flow
|
||||||
/// construction is allowed to possess.
|
/// construction is allowed to possess.
|
||||||
#[allow(unsafe_code)]
|
|
||||||
fn set_absolute_descendants(&mut self, abs_descendants: AbsoluteDescendants) {
|
fn set_absolute_descendants(&mut self, abs_descendants: AbsoluteDescendants) {
|
||||||
let this = self.clone();
|
let this = self.clone();
|
||||||
let base = mut_base(unsafe { flow_ref::deref_mut(self) });
|
let base = mut_base(flow_ref::deref_mut(self));
|
||||||
base.abs_descendants = abs_descendants;
|
base.abs_descendants = abs_descendants;
|
||||||
for descendant_link in base.abs_descendants.iter() {
|
for descendant_link in base.abs_descendants.iter() {
|
||||||
let descendant_base = mut_base(descendant_link);
|
let descendant_base = mut_base(descendant_link);
|
||||||
|
|
|
@ -33,7 +33,7 @@ impl FlowList {
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
pub unsafe fn front_mut<'a>(&'a mut self) -> Option<&'a mut Flow> {
|
pub unsafe fn front_mut<'a>(&'a mut self) -> Option<&'a mut Flow> {
|
||||||
self.flows.front_mut().map(|head| flow_ref::deref_mut(head))
|
self.flows.front_mut().map(flow_ref::deref_mut)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Provide a reference to the back element, or None if the list is empty
|
/// Provide a reference to the back element, or None if the list is empty
|
||||||
|
@ -46,7 +46,7 @@ impl FlowList {
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
pub unsafe fn back_mut<'a>(&'a mut self) -> Option<&'a mut Flow> {
|
pub unsafe fn back_mut<'a>(&'a mut self) -> Option<&'a mut Flow> {
|
||||||
self.flows.back_mut().map(|tail| flow_ref::deref_mut(tail))
|
self.flows.back_mut().map(flow_ref::deref_mut)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add an element first in the list
|
/// Add an element first in the list
|
||||||
|
@ -123,9 +123,8 @@ impl<'a> Iterator for FlowListIterator<'a> {
|
||||||
impl<'a> Iterator for MutFlowListIterator<'a> {
|
impl<'a> Iterator for MutFlowListIterator<'a> {
|
||||||
type Item = &'a mut Flow;
|
type Item = &'a mut Flow;
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(unsafe_code)]
|
|
||||||
fn next(&mut self) -> Option<&'a mut Flow> {
|
fn next(&mut self) -> Option<&'a mut Flow> {
|
||||||
self.it.next().map(|x| unsafe { flow_ref::deref_mut(x) })
|
self.it.next().map(flow_ref::deref_mut)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
//! be superfluous. This design is largely duplicating logic of Arc<T> and
|
//! be superfluous. This design is largely duplicating logic of Arc<T> and
|
||||||
//! Weak<T>; please see comments there for details.
|
//! Weak<T>; please see comments there for details.
|
||||||
|
|
||||||
#![allow(unsafe_code)]
|
|
||||||
|
|
||||||
use flow::Flow;
|
use flow::Flow;
|
||||||
use std::sync::{Arc, Weak};
|
use std::sync::{Arc, Weak};
|
||||||
|
@ -16,9 +15,14 @@ use std::sync::{Arc, Weak};
|
||||||
pub type FlowRef = Arc<Flow>;
|
pub type FlowRef = Arc<Flow>;
|
||||||
pub type WeakFlowRef = Weak<Flow>;
|
pub type WeakFlowRef = Weak<Flow>;
|
||||||
|
|
||||||
// FIXME(https://github.com/servo/servo/issues/6503) This introduces unsound mutable aliasing.
|
/// WARNING: This should only be used when there is no aliasing:
|
||||||
// Try to replace it with Arc::get_mut (which checks that the reference count is 1).
|
/// when the traversal ensures that no other threads accesses the same flow at the same time.
|
||||||
pub unsafe fn deref_mut<'a>(r: &'a mut FlowRef) -> &'a mut Flow {
|
/// See https://github.com/servo/servo/issues/6503
|
||||||
|
/// Use Arc::get_mut instead when possible (e.g. on an Arc that was just created).
|
||||||
|
#[allow(unsafe_code)]
|
||||||
|
pub fn deref_mut<'a>(r: &'a mut FlowRef) -> &'a mut Flow {
|
||||||
let ptr: *const Flow = &**r;
|
let ptr: *const Flow = &**r;
|
||||||
&mut *(ptr as *mut Flow)
|
unsafe {
|
||||||
|
&mut *(ptr as *mut Flow)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1248,7 +1248,6 @@ impl Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Computes the intrinsic inline-sizes of this fragment.
|
/// Computes the intrinsic inline-sizes of this fragment.
|
||||||
#[allow(unsafe_code)]
|
|
||||||
pub fn compute_intrinsic_inline_sizes(&mut self) -> IntrinsicISizesContribution {
|
pub fn compute_intrinsic_inline_sizes(&mut self) -> IntrinsicISizesContribution {
|
||||||
let mut result = self.style_specified_intrinsic_inline_size();
|
let mut result = self.style_specified_intrinsic_inline_size();
|
||||||
match self.specific {
|
match self.specific {
|
||||||
|
@ -1620,7 +1619,6 @@ impl Fragment {
|
||||||
|
|
||||||
/// Assigns replaced inline-size, padding, and margins for this fragment only if it is replaced
|
/// Assigns replaced inline-size, padding, and margins for this fragment only if it is replaced
|
||||||
/// content per CSS 2.1 § 10.3.2.
|
/// content per CSS 2.1 § 10.3.2.
|
||||||
#[allow(unsafe_code)]
|
|
||||||
pub fn assign_replaced_inline_size_if_necessary<'a>(&'a mut self, container_inline_size: Au) {
|
pub fn assign_replaced_inline_size_if_necessary<'a>(&'a mut self, container_inline_size: Au) {
|
||||||
match self.specific {
|
match self.specific {
|
||||||
SpecificFragmentInfo::Generic |
|
SpecificFragmentInfo::Generic |
|
||||||
|
@ -1649,7 +1647,7 @@ impl Fragment {
|
||||||
|
|
||||||
match self.specific {
|
match self.specific {
|
||||||
SpecificFragmentInfo::InlineAbsoluteHypothetical(ref mut info) => {
|
SpecificFragmentInfo::InlineAbsoluteHypothetical(ref mut info) => {
|
||||||
let block_flow = unsafe { flow_ref::deref_mut(&mut info.flow_ref) }.as_mut_block();
|
let block_flow = flow_ref::deref_mut(&mut info.flow_ref).as_mut_block();
|
||||||
block_flow.base.position.size.inline =
|
block_flow.base.position.size.inline =
|
||||||
block_flow.base.intrinsic_inline_sizes.preferred_inline_size;
|
block_flow.base.intrinsic_inline_sizes.preferred_inline_size;
|
||||||
|
|
||||||
|
@ -1657,7 +1655,7 @@ impl Fragment {
|
||||||
self.border_box.size.inline = Au(0);
|
self.border_box.size.inline = Au(0);
|
||||||
}
|
}
|
||||||
SpecificFragmentInfo::InlineBlock(ref mut info) => {
|
SpecificFragmentInfo::InlineBlock(ref mut info) => {
|
||||||
let block_flow = unsafe { flow_ref::deref_mut(&mut info.flow_ref) }.as_mut_block();
|
let block_flow = flow_ref::deref_mut(&mut info.flow_ref).as_mut_block();
|
||||||
self.border_box.size.inline =
|
self.border_box.size.inline =
|
||||||
max(block_flow.base.intrinsic_inline_sizes.minimum_inline_size,
|
max(block_flow.base.intrinsic_inline_sizes.minimum_inline_size,
|
||||||
block_flow.base.intrinsic_inline_sizes.preferred_inline_size);
|
block_flow.base.intrinsic_inline_sizes.preferred_inline_size);
|
||||||
|
@ -1665,7 +1663,7 @@ impl Fragment {
|
||||||
block_flow.base.block_container_writing_mode = self.style.writing_mode;
|
block_flow.base.block_container_writing_mode = self.style.writing_mode;
|
||||||
}
|
}
|
||||||
SpecificFragmentInfo::InlineAbsolute(ref mut info) => {
|
SpecificFragmentInfo::InlineAbsolute(ref mut info) => {
|
||||||
let block_flow = unsafe { flow_ref::deref_mut(&mut info.flow_ref) }.as_mut_block();
|
let block_flow = flow_ref::deref_mut(&mut info.flow_ref).as_mut_block();
|
||||||
self.border_box.size.inline =
|
self.border_box.size.inline =
|
||||||
max(block_flow.base.intrinsic_inline_sizes.minimum_inline_size,
|
max(block_flow.base.intrinsic_inline_sizes.minimum_inline_size,
|
||||||
block_flow.base.intrinsic_inline_sizes.preferred_inline_size);
|
block_flow.base.intrinsic_inline_sizes.preferred_inline_size);
|
||||||
|
@ -1713,7 +1711,6 @@ impl Fragment {
|
||||||
/// been assigned first.
|
/// been assigned first.
|
||||||
///
|
///
|
||||||
/// Ideally, this should follow CSS 2.1 § 10.6.2.
|
/// Ideally, this should follow CSS 2.1 § 10.6.2.
|
||||||
#[allow(unsafe_code)]
|
|
||||||
pub fn assign_replaced_block_size_if_necessary(&mut self, containing_block_block_size: Option<Au>) {
|
pub fn assign_replaced_block_size_if_necessary(&mut self, containing_block_block_size: Option<Au>) {
|
||||||
match self.specific {
|
match self.specific {
|
||||||
SpecificFragmentInfo::Generic |
|
SpecificFragmentInfo::Generic |
|
||||||
|
@ -1770,18 +1767,18 @@ impl Fragment {
|
||||||
}
|
}
|
||||||
SpecificFragmentInfo::InlineBlock(ref mut info) => {
|
SpecificFragmentInfo::InlineBlock(ref mut info) => {
|
||||||
// Not the primary fragment, so we do not take the noncontent size into account.
|
// Not the primary fragment, so we do not take the noncontent size into account.
|
||||||
let block_flow = unsafe { flow_ref::deref_mut(&mut info.flow_ref) }.as_block();
|
let block_flow = flow_ref::deref_mut(&mut info.flow_ref).as_block();
|
||||||
self.border_box.size.block = block_flow.base.position.size.block +
|
self.border_box.size.block = block_flow.base.position.size.block +
|
||||||
block_flow.fragment.margin.block_start_end()
|
block_flow.fragment.margin.block_start_end()
|
||||||
}
|
}
|
||||||
SpecificFragmentInfo::InlineAbsoluteHypothetical(ref mut info) => {
|
SpecificFragmentInfo::InlineAbsoluteHypothetical(ref mut info) => {
|
||||||
// Not the primary fragment, so we do not take the noncontent size into account.
|
// Not the primary fragment, so we do not take the noncontent size into account.
|
||||||
let block_flow = unsafe { flow_ref::deref_mut(&mut info.flow_ref) }.as_block();
|
let block_flow = flow_ref::deref_mut(&mut info.flow_ref).as_block();
|
||||||
self.border_box.size.block = block_flow.base.position.size.block;
|
self.border_box.size.block = block_flow.base.position.size.block;
|
||||||
}
|
}
|
||||||
SpecificFragmentInfo::InlineAbsolute(ref mut info) => {
|
SpecificFragmentInfo::InlineAbsolute(ref mut info) => {
|
||||||
// Not the primary fragment, so we do not take the noncontent size into account.
|
// Not the primary fragment, so we do not take the noncontent size into account.
|
||||||
let block_flow = unsafe { flow_ref::deref_mut(&mut info.flow_ref) }.as_block();
|
let block_flow = flow_ref::deref_mut(&mut info.flow_ref).as_block();
|
||||||
self.border_box.size.block = block_flow.base.position.size.block +
|
self.border_box.size.block = block_flow.base.position.size.block +
|
||||||
block_flow.fragment.margin.block_start_end()
|
block_flow.fragment.margin.block_start_end()
|
||||||
}
|
}
|
||||||
|
@ -1907,10 +1904,9 @@ impl Fragment {
|
||||||
/// Determines the inline sizes of inline-block fragments. These cannot be fully computed until
|
/// Determines the inline sizes of inline-block fragments. These cannot be fully computed until
|
||||||
/// inline size assignment has run for the child flow: thus it is computed "late", during
|
/// inline size assignment has run for the child flow: thus it is computed "late", during
|
||||||
/// block size assignment.
|
/// block size assignment.
|
||||||
#[allow(unsafe_code)]
|
|
||||||
pub fn update_late_computed_replaced_inline_size_if_necessary(&mut self) {
|
pub fn update_late_computed_replaced_inline_size_if_necessary(&mut self) {
|
||||||
if let SpecificFragmentInfo::InlineBlock(ref mut inline_block_info) = self.specific {
|
if let SpecificFragmentInfo::InlineBlock(ref mut inline_block_info) = self.specific {
|
||||||
let block_flow = unsafe { flow_ref::deref_mut(&mut inline_block_info.flow_ref) }.as_block();
|
let block_flow = flow_ref::deref_mut(&mut inline_block_info.flow_ref).as_block();
|
||||||
let margin = block_flow.fragment.style.logical_margin();
|
let margin = block_flow.fragment.style.logical_margin();
|
||||||
self.border_box.size.inline = block_flow.fragment.border_box.size.inline +
|
self.border_box.size.inline = block_flow.fragment.border_box.size.inline +
|
||||||
MaybeAuto::from_style(margin.inline_start, Au(0)).specified_or_zero() +
|
MaybeAuto::from_style(margin.inline_start, Au(0)).specified_or_zero() +
|
||||||
|
@ -1918,24 +1914,22 @@ impl Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
|
||||||
pub fn update_late_computed_inline_position_if_necessary(&mut self) {
|
pub fn update_late_computed_inline_position_if_necessary(&mut self) {
|
||||||
match self.specific {
|
match self.specific {
|
||||||
SpecificFragmentInfo::InlineAbsoluteHypothetical(ref mut info) => {
|
SpecificFragmentInfo::InlineAbsoluteHypothetical(ref mut info) => {
|
||||||
let position = self.border_box.start.i;
|
let position = self.border_box.start.i;
|
||||||
unsafe { flow_ref::deref_mut(&mut info.flow_ref) }
|
flow_ref::deref_mut(&mut info.flow_ref)
|
||||||
.update_late_computed_inline_position_if_necessary(position)
|
.update_late_computed_inline_position_if_necessary(position)
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
|
||||||
pub fn update_late_computed_block_position_if_necessary(&mut self) {
|
pub fn update_late_computed_block_position_if_necessary(&mut self) {
|
||||||
match self.specific {
|
match self.specific {
|
||||||
SpecificFragmentInfo::InlineAbsoluteHypothetical(ref mut info) => {
|
SpecificFragmentInfo::InlineAbsoluteHypothetical(ref mut info) => {
|
||||||
let position = self.border_box.start.b;
|
let position = self.border_box.start.b;
|
||||||
unsafe { flow_ref::deref_mut(&mut info.flow_ref) }
|
flow_ref::deref_mut(&mut info.flow_ref)
|
||||||
.update_late_computed_block_position_if_necessary(position)
|
.update_late_computed_block_position_if_necessary(position)
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
|
@ -1597,7 +1597,6 @@ impl Flow for InlineFlow {
|
||||||
self.base.restyle_damage.remove(REFLOW_OUT_OF_FLOW | REFLOW);
|
self.base.restyle_damage.remove(REFLOW_OUT_OF_FLOW | REFLOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
|
||||||
fn compute_absolute_position(&mut self, _: &LayoutContext) {
|
fn compute_absolute_position(&mut self, _: &LayoutContext) {
|
||||||
// First, gather up the positions of all the containing blocks (if any).
|
// First, gather up the positions of all the containing blocks (if any).
|
||||||
//
|
//
|
||||||
|
@ -1658,7 +1657,7 @@ impl Flow for InlineFlow {
|
||||||
let is_positioned = fragment.is_positioned();
|
let is_positioned = fragment.is_positioned();
|
||||||
match fragment.specific {
|
match fragment.specific {
|
||||||
SpecificFragmentInfo::InlineBlock(ref mut info) => {
|
SpecificFragmentInfo::InlineBlock(ref mut info) => {
|
||||||
let flow = unsafe { flow_ref::deref_mut(&mut info.flow_ref) };
|
let flow = flow_ref::deref_mut(&mut info.flow_ref);
|
||||||
flow::mut_base(flow).clip = clip;
|
flow::mut_base(flow).clip = clip;
|
||||||
|
|
||||||
let block_flow = flow.as_mut_block();
|
let block_flow = flow.as_mut_block();
|
||||||
|
@ -1679,7 +1678,7 @@ impl Flow for InlineFlow {
|
||||||
self.base.stacking_relative_position_of_display_port;
|
self.base.stacking_relative_position_of_display_port;
|
||||||
}
|
}
|
||||||
SpecificFragmentInfo::InlineAbsoluteHypothetical(ref mut info) => {
|
SpecificFragmentInfo::InlineAbsoluteHypothetical(ref mut info) => {
|
||||||
let flow = unsafe { flow_ref::deref_mut(&mut info.flow_ref) };
|
let flow = flow_ref::deref_mut(&mut info.flow_ref);
|
||||||
flow::mut_base(flow).clip = clip;
|
flow::mut_base(flow).clip = clip;
|
||||||
let block_flow = flow.as_mut_block();
|
let block_flow = flow.as_mut_block();
|
||||||
block_flow.base.absolute_position_info = self.base.absolute_position_info;
|
block_flow.base.absolute_position_info = self.base.absolute_position_info;
|
||||||
|
@ -1690,7 +1689,7 @@ impl Flow for InlineFlow {
|
||||||
self.base.stacking_relative_position_of_display_port;
|
self.base.stacking_relative_position_of_display_port;
|
||||||
}
|
}
|
||||||
SpecificFragmentInfo::InlineAbsolute(ref mut info) => {
|
SpecificFragmentInfo::InlineAbsolute(ref mut info) => {
|
||||||
let flow = unsafe { flow_ref::deref_mut(&mut info.flow_ref) };
|
let flow = flow_ref::deref_mut(&mut info.flow_ref);
|
||||||
flow::mut_base(flow).clip = clip;
|
flow::mut_base(flow).clip = clip;
|
||||||
|
|
||||||
let block_flow = flow.as_mut_block();
|
let block_flow = flow.as_mut_block();
|
||||||
|
|
|
@ -781,7 +781,7 @@ impl LayoutTask {
|
||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
|
|
||||||
unsafe { flow_ref::deref_mut(&mut flow) }.mark_as_root();
|
flow_ref::deref_mut(&mut flow).mark_as_root();
|
||||||
|
|
||||||
Some(flow)
|
Some(flow)
|
||||||
}
|
}
|
||||||
|
@ -999,11 +999,11 @@ impl LayoutTask {
|
||||||
self.profiler_metadata(),
|
self.profiler_metadata(),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|| {
|
|| {
|
||||||
flow::mut_base(unsafe { flow_ref::deref_mut(layout_root) }).stacking_relative_position =
|
flow::mut_base(flow_ref::deref_mut(layout_root)).stacking_relative_position =
|
||||||
LogicalPoint::zero(writing_mode).to_physical(writing_mode,
|
LogicalPoint::zero(writing_mode).to_physical(writing_mode,
|
||||||
rw_data.screen_size);
|
rw_data.screen_size);
|
||||||
|
|
||||||
flow::mut_base(unsafe { flow_ref::deref_mut(layout_root) }).clip =
|
flow::mut_base(flow_ref::deref_mut(layout_root)).clip =
|
||||||
ClippingRegion::from_rect(&data.page_clip_rect);
|
ClippingRegion::from_rect(&data.page_clip_rect);
|
||||||
|
|
||||||
match (&mut rw_data.parallel_traversal, opts::get().parallel_display_list_building) {
|
match (&mut rw_data.parallel_traversal, opts::get().parallel_display_list_building) {
|
||||||
|
@ -1024,13 +1024,13 @@ impl LayoutTask {
|
||||||
debug!("Done building display list.");
|
debug!("Done building display list.");
|
||||||
|
|
||||||
let root_background_color = get_root_flow_background_color(
|
let root_background_color = get_root_flow_background_color(
|
||||||
unsafe { flow_ref::deref_mut(layout_root) });
|
flow_ref::deref_mut(layout_root));
|
||||||
let root_size = {
|
let root_size = {
|
||||||
let root_flow = flow::base(&**layout_root);
|
let root_flow = flow::base(&**layout_root);
|
||||||
root_flow.position.size.to_physical(root_flow.writing_mode)
|
root_flow.position.size.to_physical(root_flow.writing_mode)
|
||||||
};
|
};
|
||||||
let mut display_list = box DisplayList::new();
|
let mut display_list = box DisplayList::new();
|
||||||
flow::mut_base(unsafe { flow_ref::deref_mut(layout_root) })
|
flow::mut_base(flow_ref::deref_mut(layout_root))
|
||||||
.display_list_building_result
|
.display_list_building_result
|
||||||
.add_to(&mut *display_list);
|
.add_to(&mut *display_list);
|
||||||
let paint_layer = PaintLayer::new(layout_root.layer_id(0),
|
let paint_layer = PaintLayer::new(layout_root.layer_id(0),
|
||||||
|
@ -1130,7 +1130,7 @@ impl LayoutTask {
|
||||||
}
|
}
|
||||||
if needs_reflow {
|
if needs_reflow {
|
||||||
if let Some(mut flow) = self.try_get_layout_root(*node) {
|
if let Some(mut flow) = self.try_get_layout_root(*node) {
|
||||||
LayoutTask::reflow_all_nodes(unsafe { flow_ref::deref_mut(&mut flow) });
|
LayoutTask::reflow_all_nodes(flow_ref::deref_mut(&mut flow));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1291,7 +1291,7 @@ impl LayoutTask {
|
||||||
self.profiler_metadata(),
|
self.profiler_metadata(),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|| {
|
|| {
|
||||||
animation::recalc_style_for_animations(unsafe { flow_ref::deref_mut(&mut root_flow) },
|
animation::recalc_style_for_animations(flow_ref::deref_mut(&mut root_flow),
|
||||||
animations)
|
animations)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1311,10 +1311,10 @@ impl LayoutTask {
|
||||||
self.profiler_metadata(),
|
self.profiler_metadata(),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|| {
|
|| {
|
||||||
if opts::get().nonincremental_layout || unsafe { flow_ref::deref_mut(&mut root_flow) }
|
if opts::get().nonincremental_layout || flow_ref::deref_mut(&mut root_flow)
|
||||||
.compute_layout_damage()
|
.compute_layout_damage()
|
||||||
.contains(REFLOW_ENTIRE_DOCUMENT) {
|
.contains(REFLOW_ENTIRE_DOCUMENT) {
|
||||||
unsafe { flow_ref::deref_mut(&mut root_flow) }.reflow_entire_document()
|
flow_ref::deref_mut(&mut root_flow).reflow_entire_document()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -470,7 +470,7 @@ pub fn traverse_flow_tree_preorder(
|
||||||
if opts::get().bubble_inline_sizes_separately {
|
if opts::get().bubble_inline_sizes_separately {
|
||||||
let layout_context = LayoutContext::new(shared_layout_context);
|
let layout_context = LayoutContext::new(shared_layout_context);
|
||||||
let bubble_inline_sizes = BubbleISizes { layout_context: &layout_context };
|
let bubble_inline_sizes = BubbleISizes { layout_context: &layout_context };
|
||||||
unsafe { flow_ref::deref_mut(root) }.traverse_postorder(&bubble_inline_sizes);
|
flow_ref::deref_mut(root).traverse_postorder(&bubble_inline_sizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
run_queue_with_custom_work_data_type(queue, |queue| {
|
run_queue_with_custom_work_data_type(queue, |queue| {
|
||||||
|
|
|
@ -40,7 +40,6 @@ pub fn traverse_dom_preorder(root: LayoutNode,
|
||||||
doit(root, recalc_style, construct_flows);
|
doit(root, recalc_style, construct_flows);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
|
||||||
pub fn resolve_generated_content(root: &mut FlowRef, shared_layout_context: &SharedLayoutContext) {
|
pub fn resolve_generated_content(root: &mut FlowRef, shared_layout_context: &SharedLayoutContext) {
|
||||||
fn doit(flow: &mut Flow, level: u32, traversal: &mut ResolveGeneratedContent) {
|
fn doit(flow: &mut Flow, level: u32, traversal: &mut ResolveGeneratedContent) {
|
||||||
if !traversal.should_process(flow) {
|
if !traversal.should_process(flow) {
|
||||||
|
@ -56,10 +55,9 @@ pub fn resolve_generated_content(root: &mut FlowRef, shared_layout_context: &Sha
|
||||||
|
|
||||||
let layout_context = LayoutContext::new(shared_layout_context);
|
let layout_context = LayoutContext::new(shared_layout_context);
|
||||||
let mut traversal = ResolveGeneratedContent::new(&layout_context);
|
let mut traversal = ResolveGeneratedContent::new(&layout_context);
|
||||||
doit(unsafe { flow_ref::deref_mut(root) }, 0, &mut traversal)
|
doit(flow_ref::deref_mut(root), 0, &mut traversal)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
|
||||||
pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
|
pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
|
||||||
shared_layout_context: &SharedLayoutContext) {
|
shared_layout_context: &SharedLayoutContext) {
|
||||||
fn doit(flow: &mut Flow,
|
fn doit(flow: &mut Flow,
|
||||||
|
@ -80,7 +78,7 @@ pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
|
||||||
|
|
||||||
let layout_context = LayoutContext::new(shared_layout_context);
|
let layout_context = LayoutContext::new(shared_layout_context);
|
||||||
|
|
||||||
let root = unsafe { flow_ref::deref_mut(root) };
|
let root = flow_ref::deref_mut(root);
|
||||||
|
|
||||||
if opts::get().bubble_inline_sizes_separately {
|
if opts::get().bubble_inline_sizes_separately {
|
||||||
let bubble_inline_sizes = BubbleISizes { layout_context: &layout_context };
|
let bubble_inline_sizes = BubbleISizes { layout_context: &layout_context };
|
||||||
|
@ -96,7 +94,6 @@ pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
|
||||||
doit(root, assign_inline_sizes, assign_block_sizes);
|
doit(root, assign_inline_sizes, assign_block_sizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
|
||||||
pub fn build_display_list_for_subtree(root: &mut FlowRef,
|
pub fn build_display_list_for_subtree(root: &mut FlowRef,
|
||||||
shared_layout_context: &SharedLayoutContext) {
|
shared_layout_context: &SharedLayoutContext) {
|
||||||
fn doit(flow: &mut Flow,
|
fn doit(flow: &mut Flow,
|
||||||
|
@ -119,10 +116,9 @@ pub fn build_display_list_for_subtree(root: &mut FlowRef,
|
||||||
let compute_absolute_positions = ComputeAbsolutePositions { layout_context: &layout_context };
|
let compute_absolute_positions = ComputeAbsolutePositions { layout_context: &layout_context };
|
||||||
let build_display_list = BuildDisplayList { layout_context: &layout_context };
|
let build_display_list = BuildDisplayList { layout_context: &layout_context };
|
||||||
|
|
||||||
doit(unsafe { flow_ref::deref_mut(root) }, compute_absolute_positions, build_display_list);
|
doit(flow_ref::deref_mut(root), compute_absolute_positions, build_display_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
|
||||||
pub fn iterate_through_flow_tree_fragment_border_boxes(root: &mut FlowRef,
|
pub fn iterate_through_flow_tree_fragment_border_boxes(root: &mut FlowRef,
|
||||||
iterator: &mut FragmentBorderBoxIterator) {
|
iterator: &mut FragmentBorderBoxIterator) {
|
||||||
fn doit(flow: &mut Flow,
|
fn doit(flow: &mut Flow,
|
||||||
|
@ -145,5 +141,5 @@ pub fn iterate_through_flow_tree_fragment_border_boxes(root: &mut FlowRef,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
doit(unsafe { flow_ref::deref_mut(root) }, 0, iterator, &ZERO_POINT);
|
doit(flow_ref::deref_mut(root), 0, iterator, &ZERO_POINT);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue