pub(crate) struct InlineFormattingContextBuilder {
pub shared_inline_styles_stack: Vec<SharedInlineStyles>,
pub text_segments: Vec<String>,
current_text_offset: usize,
current_character_offset: usize,
pub shared_selection: Option<SharedSelection>,
last_inline_box_ended_with_collapsible_white_space: bool,
on_word_boundary: bool,
pub contains_floats: bool,
pub inline_items: Vec<InlineItem>,
pub inline_boxes: InlineBoxes,
inline_box_stack: Vec<InlineBoxIdentifier>,
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: usizeThe current offset in the final text string of this InlineFormattingContext,
used to properly set the text range of new InlineItem::TextRuns.
current_character_offset: usizeThe current character offset in the final text string of this InlineFormattingContext,
used to properly set the text range of new InlineItem::TextRuns. Note that this is
different from the UTF-8 code point offset.
If the InlineFormattingContext that we are building has a selection shared with its
originating node in the DOM, this will not be None.
last_inline_box_ended_with_collapsible_white_space: boolWhether 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: boolWhether or not the current state of the inline formatting context is on a word boundary
for the purposes of text-transform: capitalize.
contains_floats: boolWhether or not this inline formatting context will contain floats.
inline_items: Vec<InlineItem>The current list of InlineItems in this InlineFormattingContext under
construction. This is stored in a flat list to make it easy to access the last
item.
inline_boxes: InlineBoxesThe 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.
is_empty: boolWhether 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>, ) -> InlineItem
pub(crate) fn push_absolutely_positioned_box( &mut self, absolutely_positioned_box_creator: impl FnOnce() -> ArcRefCell<AbsolutelyPositionedBox>, old_layout_box: Option<LayoutBox>, ) -> InlineItem
pub(crate) fn push_float_box( &mut self, float_box_creator: impl FnOnce() -> ArcRefCell<FloatBox>, old_layout_box: Option<LayoutBox>, ) -> InlineItem
pub(crate) fn push_block_level_box( &mut self, block_level_box: ArcRefCell<BlockLevelBox>, block_builder_info: &NodeAndStyleInfo<'_>, layout_context: &LayoutContext<'_>, )
pub(crate) fn start_inline_box( &mut self, inline_box_creator: impl FnOnce() -> ArcRefCell<InlineBox>, old_layout_box: Option<LayoutBox>, )
Sourcepub(crate) fn end_inline_box(&mut self)
pub(crate) fn end_inline_box(&mut self)
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.
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)
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 more