pub(crate) struct TextRun {
pub base_fragment_info: BaseFragmentInfo,
pub inline_styles: SharedInlineStyles,
pub text_range: Range<usize>,
pub shaped_text: Vec<TextRunSegment>,
pub selection_range: Option<Range<ByteIndex>>,
}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.
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.
shaped_text: Vec<TextRunSegment>The text of this TextRun with a font selected, broken into unbreakable
segments, and shaped.
selection_range: Option<Range<ByteIndex>>The selection range for the DOM text node that originated this TextRun. This
comes directly from the DOM.
Implementations§
Source§impl TextRun
impl TextRun
pub(crate) fn new( base_fragment_info: BaseFragmentInfo, inline_styles: SharedInlineStyles, text_range: Range<usize>, selection_range: Option<ServoRange<ByteIndex>>, ) -> Self
pub(super) fn segment_and_shape( &mut self, formatting_context_text: &str, font_context: &FontContext, linebreaker: &mut LineBreaker, font_cache: &mut Vec<FontKeyAndMetrics>, bidi_info: &BidiInfo<'_>, rendering_group_id: RenderingGroupId, )
Sourcefn segment_text_by_font(
&mut self,
formatting_context_text: &str,
font_context: &FontContext,
font_cache: &mut Vec<FontKeyAndMetrics>,
bidi_info: &BidiInfo<'_>,
parent_style: &Arc<ComputedValues>,
rendering_group_id: RenderingGroupId,
) -> Vec<(TextRunSegment, FontRef)>
fn segment_text_by_font( &mut self, formatting_context_text: &str, font_context: &FontContext, font_cache: &mut Vec<FontKeyAndMetrics>, bidi_info: &BidiInfo<'_>, parent_style: &Arc<ComputedValues>, rendering_group_id: RenderingGroupId, ) -> Vec<(TextRunSegment, FontRef)>
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. Fonts are stored
in the font_cache which is a cache of all font keys and metrics used in this
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