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

source

pub(crate) fn new(max_inline_size: Au) -> SequentialLayoutState

Creates a new empty SequentialLayoutState.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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

source

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.
source

pub(crate) fn adjoin_assign(&mut self, margin: &CollapsedMargin)

Adds a new adjoining margin.

source

pub(crate) fn current_containing_block_offset(&self) -> Au

Get the offset of the current containing block and any uncollapsed margins.

source

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

source§

fn clone(&self) -> SequentialLayoutState

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> Downcast<T> for T

source§

fn downcast(&self) -> &T

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> MaybeBoxed<Box<T>> for T

source§

fn maybe_boxed(self) -> Box<T>

Convert
source§

impl<T> MaybeBoxed<T> for T

source§

fn maybe_boxed(self) -> T

Convert
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
source§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> Upcast<T> for T

source§

fn upcast(&self) -> Option<&T>

source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T

source§

impl<T> WasmNotSend for T
where T: Send,

source§

impl<T> WasmNotSendSync for T

source§

impl<T> WasmNotSync for T
where T: Sync,