pub(crate) struct TextRun {
pub base_fragment_info: BaseFragmentInfo,
pub parent_box: Option<WeakLayoutBox>,
pub inline_styles: SharedInlineStyles,
pub text_range: Range<usize>,
pub character_range: Range<usize>,
pub shaped_text: Vec<TextRunSegment>,
}Expand description
A single TextRun for the box tree. These are all descendants of
super::InlineBox or the root of the super::InlineFormattingContext. During
box tree construction, text is split into TextRuns based on their font, script,
etc. When these are created text is already shaped.
Fields§
§base_fragment_info: BaseFragmentInfoThe BaseFragmentInfo for this TextRun. Usually this comes from the
original text node in the DOM for the text.
parent_box: Option<WeakLayoutBox>A weak reference to the parent of this layout box. This becomes valid as soon as the parent of this box is added to the tree.
inline_styles: SharedInlineStylesThe crate::SharedStyle from this TextRuns parent element. This is
shared so that incremental layout can simply update the parent element and
this TextRun will be updated automatically.
text_range: Range<usize>The range of text in super::InlineFormattingContext::text_content of the
super::InlineFormattingContext that owns this TextRun. These are UTF-8 offsets.
character_range: Range<usize>The range of characters in this text in super::InlineFormattingContext::text_content
of the super::InlineFormattingContext that owns this TextRun. These are not
UTF-8 offsets.
shaped_text: Vec<TextRunSegment>The text of this TextRun with a font selected, broken into unbreakable
segments, and shaped.
Implementations§
Source§impl TextRun
impl TextRun
pub(crate) fn new( base_fragment_info: BaseFragmentInfo, inline_styles: SharedInlineStyles, text_range: Range<usize>, character_range: Range<usize>, ) -> Self
pub(super) fn segment_and_shape( &mut self, formatting_context_text: &str, layout_context: &LayoutContext<'_>, linebreaker: &mut LineBreaker, bidi_info: &BidiInfo<'_>, )
Sourcefn segment_text_by_font(
&mut self,
layout_context: &LayoutContext<'_>,
formatting_context_text: &str,
bidi_info: &BidiInfo<'_>,
parent_style: &ServoArc<ComputedValues>,
) -> Vec<TextRunSegment>
fn segment_text_by_font( &mut self, layout_context: &LayoutContext<'_>, formatting_context_text: &str, bidi_info: &BidiInfo<'_>, parent_style: &ServoArc<ComputedValues>, ) -> Vec<TextRunSegment>
Take the TextRun’s text and turn it into TextRunSegments. Each segment has a matched
font and script. Fonts may differ when glyphs are found in fallback fonts.
super::InlineFormattingContext.
pub(super) fn layout_into_line_items( &self, ifc: &mut InlineFormattingContextLayout<'_>, )
Trait Implementations§
Source§impl MallocSizeOf for TextRun
impl MallocSizeOf for TextRun
Source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Auto Trait Implementations§
impl Freeze for TextRun
impl !RefUnwindSafe for TextRun
impl Send for TextRun
impl Sync for TextRun
impl Unpin for TextRun
impl !UnwindSafe for TextRun
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