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
impl LineBreaker
sourcefn new(
float_context: Floats,
first_line_indentation: Au,
minimum_line_metrics: &LineMetrics,
) -> LineBreaker
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.
sourcefn reset_scanner(&mut self)
fn reset_scanner(&mut self)
Resets the LineBreaker
to the initial state it had after a call to new
.
sourcefn reset_line(&mut self)
fn reset_line(&mut self)
Reinitializes the pending line to blank data.
sourcefn scan_for_lines(
&mut self,
flow: &mut InlineFlow,
layout_context: &LayoutContext<'_>,
)
fn scan_for_lines( &mut self, flow: &mut InlineFlow, layout_context: &LayoutContext<'_>, )
Reflows fragments for the given inline flow.
sourcefn reflow_fragments<I>(
&mut self,
old_fragment_iter: I,
flow: &InlineFlow,
layout_context: &LayoutContext<'_>,
)
fn reflow_fragments<I>( &mut self, old_fragment_iter: I, flow: &InlineFlow, layout_context: &LayoutContext<'_>, )
Reflows the given fragments, which have been plucked out of the inline flow.
sourcefn next_fragment<I>(&mut self, old_fragment_iter: &mut I) -> Option<Fragment>
fn next_fragment<I>(&mut self, old_fragment_iter: &mut I) -> Option<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.
sourcefn next_unbroken_fragment<I>(
&mut self,
old_fragment_iter: &mut I,
) -> Option<Fragment>
fn next_unbroken_fragment<I>( &mut self, old_fragment_iter: &mut I, ) -> Option<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
.
sourcefn flush_current_line(&mut self)
fn flush_current_line(&mut self)
Commits a line to the list.
sourcefn strip_trailing_whitespace_from_pending_line_if_necessary(&mut self)
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.
sourcefn initial_line_placement(
&self,
flow: &InlineFlow,
first_fragment: &Fragment,
ceiling: Au,
) -> (LogicalRect<Au>, Au)
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.
sourcefn avoid_floats(
&mut self,
flow: &InlineFlow,
in_fragment: Fragment,
new_block_size: Au,
) -> bool
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:
- Move the entire line so that it doesn’t collide any more.
- 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.
sourcefn reflow_fragment(
&mut self,
fragment: Fragment,
flow: &InlineFlow,
layout_context: &LayoutContext<'_>,
)
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.
sourcefn push_fragment_to_line(
&mut self,
layout_context: &LayoutContext<'_>,
fragment: Fragment,
line_flush_mode: LineFlushMode,
)
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;
sourcefn push_fragment_to_line_ignoring_text_overflow(
&mut self,
fragment: Fragment,
layout_context: &LayoutContext<'_>,
)
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
.
fn split_line_at_last_known_good_position( &mut self, layout_context: &LayoutContext<'_>, cur_fragment: Fragment, line_flush_mode: LineFlushMode, )
sourcefn indentation_for_pending_fragment(&self) -> Au
fn indentation_for_pending_fragment(&self) -> Au
Returns the indentation that needs to be applied before the fragment we’re reflowing.
sourcefn pending_line_is_empty(&self) -> bool
fn pending_line_is_empty(&self) -> bool
Returns true if the pending line is empty and false otherwise.
Auto Trait Implementations§
impl Freeze for LineBreaker
impl !RefUnwindSafe for LineBreaker
impl Send for LineBreaker
impl Sync for LineBreaker
impl Unpin for LineBreaker
impl !UnwindSafe for LineBreaker
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