Struct layout_2013::inline::LineBreaker

source ·
struct LineBreaker {
    floats: Floats,
    new_fragments: Vec<Fragment>,
    work_list: VecDeque<Fragment>,
    pending_line: Line,
    lines: Vec<Line>,
    last_known_line_breaking_opportunity: Option<FragmentIndex>,
    cur_b: Au,
    first_line_indentation: Au,
    minimum_metrics: LineMetrics,
}
Expand description

Arranges fragments into lines, splitting them up as necessary.

Fields§

§floats: Floats

The floats we need to flow around.

§new_fragments: Vec<Fragment>

The resulting fragment list for the flow, consisting of possibly-broken fragments.

§work_list: VecDeque<Fragment>

The next fragment or fragments that we need to work on.

§pending_line: Line

The line we’re currently working on.

§lines: Vec<Line>

The lines we’ve already committed.

§last_known_line_breaking_opportunity: Option<FragmentIndex>

The index of the last known good line breaking opportunity. The opportunity will either be inside this fragment (if it is splittable) or immediately prior to it.

§cur_b: Au

The current position in the block direction.

§first_line_indentation: Au

The computed value of the indentation for the first line (text-indent, CSS 2.1 § 16.1).

§minimum_metrics: LineMetrics

The minimum metrics for each line, as specified by the line height and font style.

Implementations§

source§

impl LineBreaker

source

fn new( float_context: Floats, first_line_indentation: Au, minimum_line_metrics: &LineMetrics, ) -> LineBreaker

Creates a new LineBreaker with a set of floats and the indentation of the first line.

source

fn reset_scanner(&mut self)

Resets the LineBreaker to the initial state it had after a call to new.

source

fn reset_line(&mut self)

Reinitializes the pending line to blank data.

source

fn scan_for_lines( &mut self, flow: &mut InlineFlow, layout_context: &LayoutContext<'_>, )

Reflows fragments for the given inline flow.

source

fn reflow_fragments<I>( &mut self, old_fragment_iter: I, flow: &InlineFlow, layout_context: &LayoutContext<'_>, )
where I: Iterator<Item = Fragment>,

Reflows the given fragments, which have been plucked out of the inline flow.

source

fn next_fragment<I>(&mut self, old_fragment_iter: &mut I) -> Option<Fragment>
where I: Iterator<Item = Fragment>,

Acquires a new fragment to lay out from the work list or fragment list as appropriate. Note that you probably don’t want to call this method directly in order to be incremental- reflow-safe; try next_unbroken_fragment instead.

source

fn next_unbroken_fragment<I>( &mut self, old_fragment_iter: &mut I, ) -> Option<Fragment>
where I: Iterator<Item = Fragment>,

Acquires a new fragment to lay out from the work list or fragment list, merging it with any subsequent fragments as appropriate. In effect, what this method does is to return the next fragment to lay out, undoing line break operations that any previous reflows may have performed. You probably want to be using this method instead of next_fragment.

source

fn flush_current_line(&mut self)

Commits a line to the list.

source

fn strip_trailing_whitespace_from_pending_line_if_necessary(&mut self)

Removes trailing whitespace from the pending line if necessary. This is done right before flushing it.

source

fn initial_line_placement( &self, flow: &InlineFlow, first_fragment: &Fragment, ceiling: Au, ) -> (LogicalRect<Au>, Au)

Computes the position of a line that has only the provided fragment. Returns the bounding rect of the line’s green zone (whose origin coincides with the line’s origin) and the actual inline-size of the first fragment after splitting.

source

fn avoid_floats( &mut self, flow: &InlineFlow, in_fragment: Fragment, new_block_size: Au, ) -> bool

Performs float collision avoidance. This is called when adding a fragment is going to increase the block-size, and because of that we will collide with some floats.

We have two options here:

  1. Move the entire line so that it doesn’t collide any more.
  2. Break the line and put the new fragment on the next line.

The problem with option 1 is that we might move the line and then wind up breaking anyway, which violates the standard. But option 2 is going to look weird sometimes.

So we’ll try to move the line whenever we can, but break if we have to.

Returns false if and only if we should break the line.

source

fn reflow_fragment( &mut self, fragment: Fragment, flow: &InlineFlow, layout_context: &LayoutContext<'_>, )

Tries to append the given fragment to the line, splitting it if necessary. Commits the current line if needed.

source

fn push_fragment_to_line( &mut self, layout_context: &LayoutContext<'_>, fragment: Fragment, line_flush_mode: LineFlushMode, )

Pushes a fragment to the current line unconditionally, possibly truncating it and placing an ellipsis based on the value of text-overflow. If flush_line is Flush, then flushes the line afterward;

source

fn push_fragment_to_line_ignoring_text_overflow( &mut self, fragment: Fragment, layout_context: &LayoutContext<'_>, )

Pushes a fragment to the current line unconditionally, without placing an ellipsis in the case of text-overflow: ellipsis.

source

fn split_line_at_last_known_good_position( &mut self, layout_context: &LayoutContext<'_>, cur_fragment: Fragment, line_flush_mode: LineFlushMode, )

source

fn indentation_for_pending_fragment(&self) -> Au

Returns the indentation that needs to be applied before the fragment we’re reflowing.

source

fn pending_line_is_empty(&self) -> bool

Returns true if the pending line is empty and false otherwise.

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

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

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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,