Struct layout_2020::flow::float::PlacementAmongFloats
source · pub(crate) struct PlacementAmongFloats<'a> {
float_context: &'a FloatContext,
current_bands: VecDeque<FloatBand>,
next_band: FloatBand,
object_size: LogicalVec2<Au>,
ceiling: Au,
min_inline_start: Au,
max_inline_end: Au,
}
Expand description
This data strucure is used to try to place non-floating content among float content. This is used primarily to place replaced content and independent formatting contexts next to floats, as the specifcation dictates.
Fields§
§float_context: &'a FloatContext
The FloatContext to use for this placement.
current_bands: VecDeque<FloatBand>
The current bands we are considering for this placement.
next_band: FloatBand
The next band, needed to know the height of the last band in current_bands.
object_size: LogicalVec2<Au>
The size of the object to place.
ceiling: Au
The minimum position in the block direction for the placement. Objects should not be placed before this point.
min_inline_start: Au
The inline position where the object would be if there were no floats. The object can be placed after it due to floats, but not before it.
max_inline_end: Au
The maximum inline position that the object can attain when avoiding floats.
Implementations§
source§impl<'a> PlacementAmongFloats<'a>
impl<'a> PlacementAmongFloats<'a>
pub(crate) fn new( float_context: &'a FloatContext, ceiling: Au, object_size: LogicalVec2<Au>, pbm: &PaddingBorderMargin, ) -> Self
sourcefn top_of_bands(&self) -> Option<Au>
fn top_of_bands(&self) -> Option<Au>
The top of the bands under consideration. This is initially the ceiling provided
during creation of this PlacementAmongFloats
, but may be larger if the top
band is discarded.
sourcefn current_bands_height(&self) -> Au
fn current_bands_height(&self) -> Au
The height of the bands under consideration.
sourcefn add_one_band(&mut self)
fn add_one_band(&mut self)
Add a single band to the bands under consideration and calculate the new
PlacementAmongFloats::next_band
.
sourcefn accumulate_enough_bands_for_block_size(&mut self)
fn accumulate_enough_bands_for_block_size(&mut self)
Adds bands to the set of bands under consideration until their block size is at least large enough to contain the block size of the object being placed.
sourcefn calculate_inline_start_and_end(&self) -> (Au, Au)
fn calculate_inline_start_and_end(&self) -> (Au, Au)
Find the start and end of the inline space provided by the current set of bands under consideration.
sourcefn calculate_viable_inline_size(&self) -> Au
fn calculate_viable_inline_size(&self) -> Au
Find the total inline size provided by the current set of bands under consideration.
fn try_place_once(&mut self) -> Option<LogicalRect<Au>>
sourcefn has_bands_or_at_end(&self) -> bool
fn has_bands_or_at_end(&self) -> bool
Checks if we either have bands or we have gone past all of them. This is an invariant that should hold, otherwise we are in a broken state.
fn pop_front_band_ensuring_has_bands_or_at_end(&mut self)
sourcepub(crate) fn place(&mut self) -> LogicalRect<Au>
pub(crate) fn place(&mut self) -> LogicalRect<Au>
Run the placement algorithm for this PlacementAmongFloats.
sourcepub(crate) fn set_inline_size(
&mut self,
inline_size: Au,
pbm: &PaddingBorderMargin,
)
pub(crate) fn set_inline_size( &mut self, inline_size: Au, pbm: &PaddingBorderMargin, )
After placing a table and then laying it out, it may turn out wider than what we initially expected. This method takes care of updating the data so that the next place() can find the right area for the new size. Note that if the new size is smaller, placement won’t backtrack to consider areas that weren’t big enough for the old size.
sourcepub(crate) fn try_to_expand_for_auto_block_size(
&mut self,
block_size_after_layout: Au,
size_from_placement: &LogicalVec2<Au>,
) -> bool
pub(crate) fn try_to_expand_for_auto_block_size( &mut self, block_size_after_layout: Au, size_from_placement: &LogicalVec2<Au>, ) -> bool
After placing an object with height: auto
(and using the minimum inline and
block size as the object size) and then laying it out, try to fit the object into
the current set of bands, given block size after layout and the available inline
space from the original placement. This will return true if the object fits at the
original placement location or false if the placement and layout must be run again
(with this PlacementAmongFloats).
Auto Trait Implementations§
impl<'a> Freeze for PlacementAmongFloats<'a>
impl<'a> RefUnwindSafe for PlacementAmongFloats<'a>
impl<'a> Send for PlacementAmongFloats<'a>
impl<'a> Sync for PlacementAmongFloats<'a>
impl<'a> Unpin for PlacementAmongFloats<'a>
impl<'a> UnwindSafe for PlacementAmongFloats<'a>
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> 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