Struct layout_2020::flow::float::SequentialLayoutState
source · pub(crate) struct SequentialLayoutState {
pub(crate) floats: FloatContext,
pub(crate) bfc_relative_block_position: Au,
pub(crate) current_margin: CollapsedMargin,
}
Expand description
Layout state that we maintain when doing sequential traversals of the box tree in document order.
This data is only needed for float placement and float interaction, and as such is only present if the current block formatting context contains floats.
All coordinates here are relative to the start of the nearest ancestor block formatting context.
This structure is expected to be cheap to clone, in order to allow for “snapshots” that enable restarting layout at any point in the tree.
Fields§
§floats: FloatContext
Holds all floats in this block formatting context.
bfc_relative_block_position: Au
The (logically) bottom border edge or top padding edge of the last in-flow block. Floats cannot be placed above this line.
This is often, but not always, the same as the float ceiling. The float ceiling can be lower than this value because this value is calculated based on in-flow boxes only, while out-of-flow floats can affect the ceiling as well (see CSS 2.1 § 9.5.1 rule 6).
current_margin: CollapsedMargin
Any collapsible margins that we’ve encountered after bfc_relative_block_position
.
Implementations§
source§impl SequentialLayoutState
impl SequentialLayoutState
sourcepub(crate) fn new(max_inline_size: Au) -> SequentialLayoutState
pub(crate) fn new(max_inline_size: Au) -> SequentialLayoutState
Creates a new empty SequentialLayoutState
.
sourcepub(crate) fn advance_block_position(&mut self, block_distance: Au)
pub(crate) fn advance_block_position(&mut self, block_distance: Au)
Moves the current block position (logically) down by block_distance
. This may be
a negative advancement in the case that that block content overflows its
container, when the container is adjusting the block position of the
SequentialLayoutState
after processing its overflowing content.
Floats may not be placed higher than the current block position.
sourcepub(crate) fn replace_containing_block_position_info(
&mut self,
position_info: ContainingBlockPositionInfo,
) -> ContainingBlockPositionInfo
pub(crate) fn replace_containing_block_position_info( &mut self, position_info: ContainingBlockPositionInfo, ) -> ContainingBlockPositionInfo
Replace the entire ContainingBlockPositionInfo data structure stored by this SequentialLayoutState. Return the old data structure.
sourcepub(crate) fn current_block_position_including_margins(&self) -> Au
pub(crate) fn current_block_position_including_margins(&self) -> Au
Return the current block position in the float containing block formatting context and any uncollapsed block margins.
sourcepub(crate) fn collapse_margins(&mut self)
pub(crate) fn collapse_margins(&mut self)
Collapses margins, moving the block position down by the collapsed value of current_margin
and resetting current_margin
to zero.
Call this method before laying out children when it is known that the start margin of the current fragment can’t collapse with the margins of any of its children.
sourcepub(crate) fn position_without_clearance(
&self,
block_start_margin: &CollapsedMargin,
) -> Au
pub(crate) fn position_without_clearance( &self, block_start_margin: &CollapsedMargin, ) -> Au
Computes the position of the block-start border edge of an element
with the provided block_start_margin
, assuming no clearance.
sourcepub(crate) fn position_with_zero_clearance(
&self,
block_start_margin: &CollapsedMargin,
) -> Au
pub(crate) fn position_with_zero_clearance( &self, block_start_margin: &CollapsedMargin, ) -> Au
Computes the position of the block-start border edge of an element
with the provided block_start_margin
, assuming a clearance of 0px.
sourcepub(crate) fn calculate_clear_position(
&self,
clear: Clear,
block_start_margin: &CollapsedMargin,
) -> Option<Au>
pub(crate) fn calculate_clear_position( &self, clear: Clear, block_start_margin: &CollapsedMargin, ) -> Option<Au>
Returns the block-end outer edge of the lowest float that is to be cleared (if any)
by an element with the provided clear
and block_start_margin
.
sourcepub(crate) fn calculate_clearance(
&self,
clear: Clear,
block_start_margin: &CollapsedMargin,
) -> Option<Au>
pub(crate) fn calculate_clearance( &self, clear: Clear, block_start_margin: &CollapsedMargin, ) -> Option<Au>
Returns the amount of clearance (if any) that a block with the given clear
value
needs to have at current_block_position_including_margins()
.
block_start_margin
is the top margin of the block, after collapsing (if possible)
with the margin of its contents. This must not be included in current_margin
,
since adding clearance will prevent current_margin
and block_start_margin
from collapsing together.
https://www.w3.org/TR/2011/REC-CSS2-20110607/visuren.html#flow-control
sourcepub(crate) fn calculate_clearance_and_inline_adjustment(
&self,
clear: Clear,
block_start_margin: &CollapsedMargin,
pbm: &PaddingBorderMargin,
object_size: LogicalVec2<Au>,
) -> (Option<Au>, LogicalRect<Au>)
pub(crate) fn calculate_clearance_and_inline_adjustment( &self, clear: Clear, block_start_margin: &CollapsedMargin, pbm: &PaddingBorderMargin, object_size: LogicalVec2<Au>, ) -> (Option<Au>, LogicalRect<Au>)
A block that is replaced or establishes an independent formatting context can’t overlap floats, it has to be placed next to them, and may get some clearance if there isn’t enough space. Given such a block with the provided ‘clear’, ‘block_start_margin’, ‘pbm’ and ‘object_size’, this method finds an area that is big enough and doesn’t overlap floats. It returns a tuple with:
- The clearance amount (if any), which includes both the effect of ‘clear’ and the extra space to avoid floats.
- The LogicalRect in which the block can be placed without overlapping floats.
sourcepub(crate) fn adjoin_assign(&mut self, margin: &CollapsedMargin)
pub(crate) fn adjoin_assign(&mut self, margin: &CollapsedMargin)
Adds a new adjoining margin.
sourcepub(crate) fn current_containing_block_offset(&self) -> Au
pub(crate) fn current_containing_block_offset(&self) -> Au
Get the offset of the current containing block and any uncollapsed margins.
sourcepub(crate) fn place_float_fragment(
&mut self,
box_fragment: &mut BoxFragment,
containing_block: &ContainingBlock<'_>,
margins_collapsing_with_parent_containing_block: CollapsedMargin,
block_offset_from_containing_block_top: Au,
)
pub(crate) fn place_float_fragment( &mut self, box_fragment: &mut BoxFragment, containing_block: &ContainingBlock<'_>, margins_collapsing_with_parent_containing_block: CollapsedMargin, block_offset_from_containing_block_top: Au, )
This function places a Fragment that has been created for a FloatBox.
Trait Implementations§
source§impl Clone for SequentialLayoutState
impl Clone for SequentialLayoutState
source§fn clone(&self) -> SequentialLayoutState
fn clone(&self) -> SequentialLayoutState
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for SequentialLayoutState
impl RefUnwindSafe for SequentialLayoutState
impl Send for SequentialLayoutState
impl Sync for SequentialLayoutState
impl Unpin for SequentialLayoutState
impl UnwindSafe for SequentialLayoutState
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more