Struct layout_2020::flow::inline::InlineFormattingContextLayout
source · pub(super) struct InlineFormattingContextLayout<'layout_data> {Show 19 fields
positioning_context: &'layout_data mut PositioningContext,
containing_block: &'layout_data ContainingBlock<'layout_data>,
sequential_layout_state: Option<&'layout_data mut SequentialLayoutState>,
layout_context: &'layout_data LayoutContext<'layout_data>,
ifc: &'layout_data InlineFormattingContext,
root_nesting_level: InlineContainerState,
inline_box_state_stack: Vec<Rc<InlineBoxContainerState>>,
inline_box_states: Vec<Rc<InlineBoxContainerState>>,
fragments: Vec<Fragment>,
current_line: LineUnderConstruction,
current_line_segment: UnbreakableSegmentUnderConstruction,
linebreak_before_new_content: bool,
deferred_br_clear: Clear,
pub have_deferred_soft_wrap_opportunity: bool,
had_inflow_content: bool,
depends_on_block_constraints: bool,
white_space_collapse: T,
text_wrap_mode: T,
baselines: Baselines,
}
Fields§
§positioning_context: &'layout_data mut PositioningContext
§containing_block: &'layout_data ContainingBlock<'layout_data>
§sequential_layout_state: Option<&'layout_data mut SequentialLayoutState>
§layout_context: &'layout_data LayoutContext<'layout_data>
§ifc: &'layout_data InlineFormattingContext
The InlineFormattingContext
that we are laying out.
root_nesting_level: InlineContainerState
The InlineContainerState
for the container formed by the root of the
InlineFormattingContext
. This is effectively the “root inline box” described
by https://drafts.csswg.org/css-inline/#model:
The block container also generates a root inline box, which is an anonymous inline box that holds all of its inline-level contents. (Thus, all text in an inline formatting context is directly contained by an inline box, whether the root inline box or one of its descendants.) The root inline box inherits from its parent block container, but is otherwise unstyleable.
inline_box_state_stack: Vec<Rc<InlineBoxContainerState>>
A stack of InlineBoxContainerState
that is used to produce LineItem
s either when we
reach the end of an inline box or when we reach the end of a line. Only at the end
of the inline box is the state popped from the stack.
inline_box_states: Vec<Rc<InlineBoxContainerState>>
A collection of InlineBoxContainerState
of all the inlines that are present
in this inline formatting context. We keep this as well as the stack, so that we
can access them during line layout, which may happen after relevant InlineBoxContainerState
s
have been popped of the the stack.
fragments: Vec<Fragment>
A vector of fragment that are laid out. This includes one Fragment::Positioning
per line that is currently laid out plus fragments for all floats, which
are currently laid out at the top-level of each InlineFormattingContext
.
current_line: LineUnderConstruction
Information about the line currently being laid out into LineItem
s.
current_line_segment: UnbreakableSegmentUnderConstruction
Information about the unbreakable line segment currently being laid out into LineItem
s.
linebreak_before_new_content: bool
After a forced line break (for instance from a <br>
element) we wait to actually
break the line until seeing more content. This allows ongoing inline boxes to finish,
since in the case where they have no more content they should not be on the next
line.
For instance:
<span style="border-right: 30px solid blue;">
first line<br>
</span>
second line
In this case, the <span>
should not extend to the second line. If we linebreak
as soon as we encounter the <br>
the <span>
’s ending inline borders would be
placed on the second line, because we add those borders in
InlineFormattingContextLayout::finish_inline_box()
.
deferred_br_clear: Clear
When a <br>
element has clear
, this needs to be applied after the linebreak,
which will be processed after the <br>
element is processed. This member
stores any deferred clear
to apply after a linebreak.
have_deferred_soft_wrap_opportunity: bool
Whether or not a soft wrap opportunity is queued. Soft wrap opportunities are queued after replaced content and they are processed when the next text content is encountered.
had_inflow_content: bool
Whether or not this InlineFormattingContext has processed any in flow content at all.
depends_on_block_constraints: bool
Whether or not the layout of this InlineFormattingContext depends on the block size of its container for the purposes of flexbox layout.
white_space_collapse: T
The currently white-space-collapse setting of this line. This is stored on the
InlineFormattingContextLayout
because when a soft wrap opportunity is defined
by the boundary between two characters, the white-space-collapse property of their
nearest common ancestor is used.
text_wrap_mode: T
The currently text-wrap-mode setting of this line. This is stored on the
InlineFormattingContextLayout
because when a soft wrap opportunity is defined
by the boundary between two characters, the text-wrap-mode property of their nearest
common ancestor is used.
baselines: Baselines
The offset of the first and last baselines in the inline formatting context that we
are laying out. This is used to propagate baselines to the ancestors of
display: inline-block
elements and table content.
Implementations§
source§impl<'layout_dta> InlineFormattingContextLayout<'layout_dta>
impl<'layout_dta> InlineFormattingContextLayout<'layout_dta>
fn current_inline_container_state(&self) -> &InlineContainerState
fn current_inline_box_identifier(&self) -> Option<InlineBoxIdentifier>
fn current_line_max_block_size_including_nested_containers( &self, ) -> LineBlockSizes
fn propagate_current_nesting_level_white_space_style(&mut self)
fn processing_br_element(&self) -> bool
sourcefn start_inline_box(&mut self, inline_box: &InlineBox)
fn start_inline_box(&mut self, inline_box: &InlineBox)
Start laying out a particular InlineBox
into line items. This will push
a new InlineBoxContainerState
onto Self::inline_box_state_stack
.
sourcefn finish_inline_box(&mut self)
fn finish_inline_box(&mut self)
Finish laying out a particular InlineBox
into line items. This will
pop its state off of Self::inline_box_state_stack
.
fn finish_last_line(&mut self)
sourcefn finish_current_line_and_reset(
&mut self,
last_line_or_forced_line_break: bool,
)
fn finish_current_line_and_reset( &mut self, last_line_or_forced_line_break: bool, )
Finish layout of all inline boxes for the current line. This will gather all
LineItem
s and turn them into Fragment
s, then reset the
InlineFormattingContextLayout
preparing it for laying out a new line.
sourcefn calculate_current_line_inline_start_and_justification_adjustment(
&self,
whitespace_trimmed: Au,
last_line_or_forced_line_break: bool,
) -> (Au, Au)
fn calculate_current_line_inline_start_and_justification_adjustment( &self, whitespace_trimmed: Au, last_line_or_forced_line_break: bool, ) -> (Au, Au)
Given the amount of whitespace trimmed from the line and taking into consideration
the text-align
property, calculate where the line under construction starts in
the inline axis as well as the adjustment needed for every justification opportunity
to account for text-align: justify
.
fn place_float_fragment(&mut self, fragment: &mut BoxFragment)
sourcefn place_float_line_item_for_commit_to_line(
&mut self,
float_item: &mut FloatLineItem,
line_inline_size_without_trailing_whitespace: Au,
)
fn place_float_line_item_for_commit_to_line( &mut self, float_item: &mut FloatLineItem, line_inline_size_without_trailing_whitespace: Au, )
Place a FloatLineItem. This is done when an unbreakable segment is committed to the current line. Placement of FloatLineItems might need to be deferred until the line is complete in the case that floats stop fitting on the current line.
When placing floats we do not want to take into account any trailing whitespace on the line, because that whitespace will be trimmed in the case that the line is broken. Thus this function takes as an argument the new size (without whitespace) of the line that these floats are joining.
sourcefn place_line_among_floats(
&self,
potential_line_size: &LogicalVec2<Au>,
) -> LogicalRect<Au>
fn place_line_among_floats( &self, potential_line_size: &LogicalVec2<Au>, ) -> LogicalRect<Au>
Given a new potential line size for the current line, create a “placement” for that line. This tells us whether or not the new potential line will fit in the current block position or need to be moved. In addition, the placement rect determines the inline start and end of the line if it’s used as the final placement among floats.
sourcefn new_potential_line_size_causes_line_break(
&mut self,
potential_line_size: &LogicalVec2<Au>,
) -> bool
fn new_potential_line_size_causes_line_break( &mut self, potential_line_size: &LogicalVec2<Au>, ) -> bool
Returns true if a new potential line size for the current line would require a line break. This takes into account floats and will also update the “placement among floats” for this line if the potential line size would not cause a line break. Thus, calling this method has side effects and should only be done while in the process of laying out line content that is always going to be committed to this line or the next.
pub(super) fn defer_forced_line_break(&mut self)
pub(super) fn possibly_flush_deferred_forced_line_break(&mut self)
fn push_line_item_to_unbreakable_segment(&mut self, line_item: LineItem)
pub(super) fn push_glyph_store_to_unbreakable_segment( &mut self, glyph_store: Arc<GlyphStore>, text_run: &TextRun, font_index: usize, bidi_level: Level, )
fn update_unbreakable_segment_for_new_content( &mut self, block_sizes_of_content: &LineBlockSizes, inline_size: Au, flags: SegmentContentFlags, )
fn process_line_break(&mut self, forced_line_break: bool)
pub(super) fn unbreakable_segment_fits_on_line(&mut self) -> bool
sourcepub(super) fn process_soft_wrap_opportunity(&mut self)
pub(super) fn process_soft_wrap_opportunity(&mut self)
Process a soft wrap opportunity. This will either commit the current unbreakble segment to the current line, if it fits within the containing block and float placement boundaries, or do a line break and then commit the segment.
sourcefn commit_current_segment_to_line(&mut self)
fn commit_current_segment_to_line(&mut self)
Commit the current unbrekable segment to the current line. In addition, this will place all floats in the unbreakable segment and expand the line dimensions.
Auto Trait Implementations§
impl<'layout_data> !Freeze for InlineFormattingContextLayout<'layout_data>
impl<'layout_data> !RefUnwindSafe for InlineFormattingContextLayout<'layout_data>
impl<'layout_data> !Send for InlineFormattingContextLayout<'layout_data>
impl<'layout_data> !Sync for InlineFormattingContextLayout<'layout_data>
impl<'layout_data> Unpin for InlineFormattingContextLayout<'layout_data>
impl<'layout_data> !UnwindSafe for InlineFormattingContextLayout<'layout_data>
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