Struct InlineFormattingContextBuilder

Source
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§

§shared_inline_styles_stack: Vec<SharedInlineStyles>

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::TextRuns.

§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 InlineItems 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 InlineItems, all inserted into different InlineFormattingContexts. 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 InlineBoxes, all inserted into different InlineFormattingContexts. 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

Source

pub(crate) fn new(info: &NodeAndStyleInfo<'_>) -> Self

Source

pub(crate) fn new_for_shared_styles( shared_inline_styles_stack: Vec<SharedInlineStyles>, ) -> Self

Source

pub(crate) fn currently_processing_inline_box(&self) -> bool

Source

fn push_control_character_string(&mut self, string_to_push: &str)

Source

fn shared_inline_styles(&self) -> SharedInlineStyles

Source

pub(crate) fn push_atomic( &mut self, independent_formatting_context_creator: impl FnOnce() -> ArcRefCell<IndependentFormattingContext>, old_layout_box: Option<LayoutBox>, ) -> ArcRefCell<InlineItem>

Source

pub(crate) fn push_absolutely_positioned_box( &mut self, absolutely_positioned_box_creator: impl FnOnce() -> ArcRefCell<AbsolutelyPositionedBox>, old_layout_box: Option<LayoutBox>, ) -> ArcRefCell<InlineItem>

Source

pub(crate) fn push_float_box( &mut self, float_box_creator: impl FnOnce() -> ArcRefCell<FloatBox>, old_layout_box: Option<LayoutBox>, ) -> ArcRefCell<InlineItem>

Source

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>, )

Source

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>>, )

Source

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.

Source

fn end_inline_box_internal( &mut self, ) -> (InlineBoxIdentifier, Option<Vec<ArcRefCell<InlineItem>>>)

Source

pub(crate) fn push_text<'dom>( &mut self, text: Cow<'dom, str>, info: &NodeAndStyleInfo<'dom>, )

Source

pub(crate) fn enter_display_contents( &mut self, shared_inline_styles: SharedInlineStyles, )

Source

pub(crate) fn leave_display_contents(&mut self)

Source

pub(crate) fn split_around_block_and_finish( &mut self, layout_context: &LayoutContext<'_>, has_first_formatted_line: bool, default_bidi_level: Level, ) -> Option<InlineFormattingContext>

Source

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§

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> AsVoidPtr for T

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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Filterable for T

Source§

fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>

Creates a filterable data provider with the given name for debugging. Read more
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<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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,