Struct layout_2013::inline::Line

source ·
pub struct Line {
    pub range: Range<FragmentIndex>,
    pub visual_runs: Option<Vec<(Range<FragmentIndex>, Level)>>,
    pub bounds: LogicalRect<Au>,
    pub green_zone: LogicalSize<Au>,
    pub minimum_metrics: LineMetrics,
    pub metrics: LineMetrics,
}
Expand description

Lines are represented as offsets into the child list, rather than as an object that “owns” fragments. Choosing a different set of line breaks requires a new list of offsets, and possibly some splitting and merging of TextFragments.

A similar list will keep track of the mapping between CSS fragments and the corresponding fragments in the inline flow.

After line breaks are determined, render fragments in the inline flow may overlap visually. For example, in the case of nested inline CSS fragments, outer inlines must be at least as large as the inner inlines, for purposes of drawing noninherited things like backgrounds, borders, outlines.

N.B. roc has an alternative design where the list instead consists of things like “start outer fragment, text, start inner fragment, text, end inner fragment, text, end outer fragment, text”. This seems a little complicated to serve as the starting point, but the current design doesn’t make it hard to try out that alternative.

Line fragments also contain some metadata used during line breaking. The green zone is the area that the line can expand to before it collides with a float or a horizontal wall of the containing block. The block-start inline-start corner of the green zone is the same as that of the line, but the green zone can be taller and wider than the line itself.

Fields§

§range: Range<FragmentIndex>

A range of line indices that describe line breaks.

For example, consider the following HTML and rendered element with linebreaks:

<span>I <span>like truffles, <img></span> yes I do.</span>
+------------+
| I like     |
| truffles,  |
| +----+     |
| |    |     |
| +----+ yes |
| I do.      |
+------------+

The ranges that describe these lines would be:

[0, 2)[2, 3)[3, 5)[5, 6)
‘I like’‘truffles,’ yes’‘I do.’
§visual_runs: Option<Vec<(Range<FragmentIndex>, Level)>>

The bidirectional embedding level runs for this line, in visual order.

Can be set to None if the line is 100% left-to-right.

§bounds: LogicalRect<Au>

The bounds are the exact position and extents of the line with respect to the parent box.

For example, for the HTML below…

<div><span>I like      truffles, <img></span></div>

…the bounds would be:

+-----------------------------------------------------------+
|               ^                                           |
|               |                                           |
|            origin.y                                       |
|               |                                           |
|               v                                           |
|< - origin.x ->+ - - - - - - - - +---------+----           |
|               |                 |         |   ^           |
|               |                 |  <img>  |  size.block   |
|               I like truffles,  |         |   v           |
|               + - - - - - - - - +---------+----           |
|               |                           |               |
|               |<------ size.inline ------>|               |
|                                                           |
|                                                           |
+-----------------------------------------------------------+
§green_zone: LogicalSize<Au>

The green zone is the greatest extent from which a line can extend to before it collides with a float.

+-----------------------+
|:::::::::::::::::      |
|:::::::::::::::::FFFFFF|
|============:::::FFFFFF|
|:::::::::::::::::FFFFFF|
|:::::::::::::::::FFFFFF|
|:::::::::::::::::      |
|    FFFFFFFFF          |
|    FFFFFFFFF          |
|    FFFFFFFFF          |
|                       |
+-----------------------+

=== line
::: green zone
FFF float
§minimum_metrics: LineMetrics

The minimum metrics for this line, as specified by the style.

§metrics: LineMetrics

The actual metrics for this line.

Implementations§

source§

impl Line

source

fn new(writing_mode: WritingMode, minimum_metrics: &LineMetrics) -> Line

source

fn new_metrics_for_fragment( &self, new_fragment: &Fragment, layout_context: &LayoutContext<'_>, ) -> LineMetrics

Returns the new metrics that this line would have if new_fragment were added to it.

FIXME(pcwalton): this assumes that the tallest fragment in the line determines the line block-size. This might not be the case with some weird text fonts.

source

fn new_block_size_for_fragment( &self, new_fragment: &Fragment, new_line_metrics: &LineMetrics, layout_context: &LayoutContext<'_>, ) -> Au

Returns the new block size that this line would have if new_fragment were added to it. new_inline_metrics represents the new inline metrics that this line would have; it can be computed with new_inline_metrics().

Trait Implementations§

source§

impl Clone for Line

source§

fn clone(&self) -> Line

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Line

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Serialize for Line

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Line

§

impl RefUnwindSafe for Line

§

impl Send for Line

§

impl Sync for Line

§

impl Unpin for Line

§

impl UnwindSafe for Line

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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,