pub enum FragmentContent {
Text {
text: String,
format: TextFormat,
offset: usize,
length: usize,
element_id: u64,
word_starts: Vec<u8>,
},
FootnoteReference {
label: String,
marker: String,
format: TextFormat,
offset: usize,
element_id: u64,
},
Image {
name: String,
alt: String,
width: u32,
height: u32,
quality: u32,
format: TextFormat,
offset: usize,
element_id: u64,
},
}Expand description
A contiguous run of content with uniform formatting within a block.
Offsets are block-relative: offset is the character position
within the block where this fragment starts (0 = block start).
Variants§
Text
A text run. The layout engine shapes these into glyphs.
Fields
format: TextFormatelement_id: u64Stable synthesized id for the underlying format run
(see synth_element_id).
Survives edits that don’t delete the run (character insertions
inside the run keep the same id). Used by accessibility layers
to build stable NodeIds for AccessKit TextRun children.
FootnoteReference
A footnote reference. The layout engine draws marker at this position
and reserves what those glyphs advance to.
Occupies exactly one character of the document however many glyphs
marker shapes to — the same U+FFFC an image occupies. The two facts
are what make the reference atomic to the caret: a layout engine must
map every glyph of the marker back to this one offset.
Fields
marker: StringWhat to draw — a number, usually. Presentation only: derived from document order, or supplied by the host, and never part of the document. Storing it would mean rewriting the author’s prose every time a note was inserted above this one.
format: TextFormatImage
An inline image. The layout engine reserves space for it.
To retrieve the image pixel data, use the existing
TextDocument::resource(name) method.
Fields
alt: StringAlternative text describing the image. May be empty.
Carried through to layout so an accessibility layer can name the
image without a second lookup, in the same way word_starts is
precomputed for text runs.
format: TextFormatelement_id: u64Stable synthesized id for the underlying image anchor
(see synth_element_id).
Trait Implementations§
Source§impl Clone for FragmentContent
impl Clone for FragmentContent
Source§fn clone(&self) -> FragmentContent
fn clone(&self) -> FragmentContent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FragmentContent
impl Debug for FragmentContent
impl Eq for FragmentContent
Source§impl PartialEq for FragmentContent
impl PartialEq for FragmentContent
impl StructuralPartialEq for FragmentContent
Auto Trait Implementations§
impl Freeze for FragmentContent
impl RefUnwindSafe for FragmentContent
impl Send for FragmentContent
impl Sync for FragmentContent
impl Unpin for FragmentContent
impl UnsafeUnpin for FragmentContent
impl UnwindSafe for FragmentContent
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.