pub struct Element<'a> { /* private fields */ }Expand description
Opaque handle to a litehtml element. Borrows from the parent Document.
Implementations§
Source§impl<'a> Element<'a>
impl<'a> Element<'a>
Sourcepub fn parent(&self) -> Option<Element<'a>>
pub fn parent(&self) -> Option<Element<'a>>
Get the parent element. Returns None for the root element.
Sourcepub fn children_count(&self) -> usize
pub fn children_count(&self) -> usize
Number of child elements.
Sourcepub fn child_at(&self, index: usize) -> Option<Element<'a>>
pub fn child_at(&self, index: usize) -> Option<Element<'a>>
Get the child at index. Returns None if out of bounds.
Sourcepub fn font(&self) -> FontHandle
pub fn font(&self) -> FontHandle
Font handle from the element’s computed CSS.
Sourcepub fn select_one(&self, selector: &str) -> Option<Element<'a>>
pub fn select_one(&self, selector: &str) -> Option<Element<'a>>
Find the first descendant matching a CSS selector.
Useful for locating elements by ID ("#myid") or attribute
("[name=anchor]"). Returns None if no match is found.
Sourcepub fn inline_boxes_count(&self) -> usize
pub fn inline_boxes_count(&self) -> usize
Number of per-line inline boxes (0 if not an inline element).
Sourcepub fn inline_box_at(&self, index: usize) -> Option<Position>
pub fn inline_box_at(&self, index: usize) -> Option<Position>
Get the i-th inline box in absolute document coordinates.
Sourcepub fn inline_boxes(&self) -> Vec<Position>
pub fn inline_boxes(&self) -> Vec<Position>
All per-line inline boxes in absolute document coordinates.
Uses a single C call with a callback to avoid recomputing boxes N+1 times (which the count+index pattern would do).
Sourcepub fn text_align(&self) -> TextAlign
pub fn text_align(&self) -> TextAlign
Computed CSS text-align value.
Sourcepub fn line_height(&self) -> f32
pub fn line_height(&self) -> f32
Computed line-height in pixels.