Skip to main content

Element

Struct Element 

Source
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>

Source

pub fn parent(&self) -> Option<Element<'a>>

Get the parent element. Returns None for the root element.

Source

pub fn children_count(&self) -> usize

Number of child elements.

Source

pub fn child_at(&self, index: usize) -> Option<Element<'a>>

Get the child at index. Returns None if out of bounds.

Source

pub fn is_text(&self) -> bool

Returns true if this element is a text node.

Source

pub fn font(&self) -> FontHandle

Font handle from the element’s computed CSS.

Source

pub fn font_size(&self) -> f32

Font size from the element’s computed CSS.

Source

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.

Source

pub fn placement(&self) -> Position

Absolute pixel bounding box after layout.

Source

pub fn get_text(&self) -> String

Recursive text content of this element and its children.

Source

pub fn inline_boxes_count(&self) -> usize

Number of per-line inline boxes (0 if not an inline element).

Source

pub fn inline_box_at(&self, index: usize) -> Option<Position>

Get the i-th inline box in absolute document coordinates.

Source

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).

Source

pub fn text_align(&self) -> TextAlign

Computed CSS text-align value.

Source

pub fn line_height(&self) -> f32

Computed line-height in pixels.

Auto Trait Implementations§

§

impl<'a> Freeze for Element<'a>

§

impl<'a> RefUnwindSafe for Element<'a>

§

impl<'a> !Send for Element<'a>

§

impl<'a> !Sync for Element<'a>

§

impl<'a> Unpin for Element<'a>

§

impl<'a> UnsafeUnpin for Element<'a>

§

impl<'a> UnwindSafe for Element<'a>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.