pub(crate) struct InlineFormattingContextBuilder {
pub shared_inline_styles_stack: Vec<SharedInlineStyles>,
pub text_segments: Vec<String>,
current_text_offset: usize,
last_inline_box_ended_with_collapsible_white_space: bool,
on_word_boundary: bool,
pub contains_floats: bool,
pub inline_items: Vec<ArcRefCell<InlineItem>>,
pub inline_boxes: InlineBoxes,
inline_box_stack: Vec<InlineBoxIdentifier>,
block_in_inline_splits: Vec<Vec<ArcRefCell<InlineItem>>>,
old_block_in_inline_splits: Vec<Vec<ArcRefCell<InlineBox>>>,
pub is_empty: bool,
}
Fields§
A stack of SharedInlineStyles
including one for the root, one for each inline box on the
inline box stack, and importantly, one for every display: contents
element that we are
currently processing. Normally display: contents
elements don’t affect the structure of
the InlineFormattingContext
, but the styles they provide do style their children.
text_segments: Vec<String>
The collection of text strings that make up this InlineFormattingContext
under
construction.
current_text_offset: usize
The current offset in the final text string of this InlineFormattingContext
,
used to properly set the text range of new InlineItem::TextRun
s.
last_inline_box_ended_with_collapsible_white_space: bool
Whether the last processed node ended with whitespace. This is used to implement rule 4 of https://www.w3.org/TR/css-text-3/#collapse:
Any collapsible space immediately following another collapsible space—even one outside the boundary of the inline containing that space, provided both spaces are within the same inline formatting context—is collapsed to have zero advance width. (It is invisible, but retains its soft wrap opportunity, if any.)
on_word_boundary: bool
Whether or not the current state of the inline formatting context is on a word boundary
for the purposes of text-transform: capitalize
.
contains_floats: bool
Whether or not this inline formatting context will contain floats.
inline_items: Vec<ArcRefCell<InlineItem>>
The current list of InlineItem
s in this InlineFormattingContext
under
construction. This is stored in a flat list to make it easy to access the last
item.
inline_boxes: InlineBoxes
The current InlineBox
tree of this InlineFormattingContext
under construction.
inline_box_stack: Vec<InlineBoxIdentifier>
The ongoing stack of inline boxes stack of the builder.
Contains all the currently ongoing inline boxes we entered so far.
The traversal is at all times as deep in the tree as this stack is,
which is why the code doesn’t need to keep track of the actual
container root (see handle_inline_level_element
).
When an inline box ends, it’s removed from this stack.
block_in_inline_splits: Vec<Vec<ArcRefCell<InlineItem>>>
Normally, an inline box produces a single box tree InlineItem
. When a block
element causes an inline box to be split, it can produce multiple
InlineItem
s, all inserted into different InlineFormattingContext
s.
Self::block_in_inline_splits
is responsible for tracking all of these split
inline box results, so that they can be inserted into the crate::dom::BoxSlot
for the DOM element once it has been processed for BoxTree construction.
old_block_in_inline_splits: Vec<Vec<ArcRefCell<InlineBox>>>
If the InlineBox
of an inline-level element is not damaged, it can be reused
to support incremental layout. An InlineBox
can be split by block elements
into multiple InlineBox
es, all inserted into different
InlineFormattingContext
s. Therefore, Self::old_block_in_inline_splits
is
used to hold all these split inline boxes from the previous box tree construction
that are about to be reused, ensuring they can be sequentially inserted into each
newly built InlineFormattingContext
.
is_empty: bool
Whether this InlineFormattingContextBuilder
is empty for the purposes of ignoring
during box tree construction. An IFC is empty if it only contains TextRuns with
completely collapsible whitespace. When that happens it can be ignored completely.
Implementations§
Source§impl InlineFormattingContextBuilder
impl InlineFormattingContextBuilder
pub(crate) fn new(info: &NodeAndStyleInfo<'_>) -> Self
pub(crate) fn currently_processing_inline_box(&self) -> bool
fn push_control_character_string(&mut self, string_to_push: &str)
pub(crate) fn push_atomic( &mut self, independent_formatting_context_creator: impl FnOnce() -> ArcRefCell<IndependentFormattingContext>, old_layout_box: Option<LayoutBox>, ) -> ArcRefCell<InlineItem>
pub(crate) fn push_absolutely_positioned_box( &mut self, absolutely_positioned_box_creator: impl FnOnce() -> ArcRefCell<AbsolutelyPositionedBox>, old_layout_box: Option<LayoutBox>, ) -> ArcRefCell<InlineItem>
pub(crate) fn push_float_box( &mut self, float_box_creator: impl FnOnce() -> ArcRefCell<FloatBox>, old_layout_box: Option<LayoutBox>, ) -> ArcRefCell<InlineItem>
pub(crate) fn start_inline_box( &mut self, inline_box_creator: impl FnOnce() -> ArcRefCell<InlineBox>, block_in_inline_splits: Option<Vec<ArcRefCell<InlineItem>>>, old_layout_box: Option<LayoutBox>, )
pub fn start_inline_box_internal( &mut self, inline_box_creator: impl FnOnce() -> ArcRefCell<InlineBox>, block_in_inline_splits: Option<Vec<ArcRefCell<InlineItem>>>, old_block_in_inline_splits: Vec<ArcRefCell<InlineBox>>, )
Sourcepub(crate) fn end_inline_box(&mut self) -> Vec<ArcRefCell<InlineItem>>
pub(crate) fn end_inline_box(&mut self) -> Vec<ArcRefCell<InlineItem>>
End the ongoing inline box in this InlineFormattingContextBuilder
, returning
shared references to all of the box tree items that were created for it. More than
a single box tree items may be produced for a single inline box when that inline
box is split around a block-level element.
fn end_inline_box_internal( &mut self, ) -> (InlineBoxIdentifier, Option<Vec<ArcRefCell<InlineItem>>>)
pub(crate) fn push_text<'dom>( &mut self, text: Cow<'dom, str>, info: &NodeAndStyleInfo<'dom>, )
pub(crate) fn enter_display_contents( &mut self, shared_inline_styles: SharedInlineStyles, )
pub(crate) fn leave_display_contents(&mut self)
pub(crate) fn split_around_block_and_finish( &mut self, layout_context: &LayoutContext<'_>, has_first_formatted_line: bool, default_bidi_level: Level, ) -> Option<InlineFormattingContext>
Sourcepub(crate) fn finish(
self,
layout_context: &LayoutContext<'_>,
has_first_formatted_line: bool,
is_single_line_text_input: bool,
default_bidi_level: Level,
) -> Option<InlineFormattingContext>
pub(crate) fn finish( self, layout_context: &LayoutContext<'_>, has_first_formatted_line: bool, is_single_line_text_input: bool, default_bidi_level: Level, ) -> Option<InlineFormattingContext>
Finish the current inline formatting context, returning None
if the context was empty.
Trait Implementations§
Source§impl Default for InlineFormattingContextBuilder
impl Default for InlineFormattingContextBuilder
Source§fn default() -> InlineFormattingContextBuilder
fn default() -> InlineFormattingContextBuilder
Auto Trait Implementations§
impl Freeze for InlineFormattingContextBuilder
impl !RefUnwindSafe for InlineFormattingContextBuilder
impl Send for InlineFormattingContextBuilder
impl Sync for InlineFormattingContextBuilder
impl Unpin for InlineFormattingContextBuilder
impl !UnwindSafe for InlineFormattingContextBuilder
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> Filterable for T
impl<T> Filterable for T
Source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
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 moreSource§impl<T> MaybeBoxed<Box<T>> for T
impl<T> MaybeBoxed<Box<T>> for T
Source§fn maybe_boxed(self) -> Box<T>
fn maybe_boxed(self) -> Box<T>
Source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
Source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.