Skip to main content

DomElement

Struct DomElement 

Source
pub struct DomElement<'a> {
    pub dom: &'a Dom,
    pub id: NodeId,
}
Expand description

Cheap (Copy) handle that pairs a NodeId with the Dom arena. Implements crate::html_css::css::matcher::Element so the CSS cascade matches selectors against real document nodes.

Fields§

§dom: &'a Dom

Backing arena.

§id: NodeId

Node id (must point to an Element).

Implementations§

Source§

impl<'a> DomElement<'a>

Source

pub fn attrs(&self) -> &[(String, String)]

All attribute (name, value) pairs.

Source§

impl<'a> DomElement<'a>

Source

pub fn children_iter(&self) -> ElementChildren<DomElement<'a>>

Iterator alias matching Element::element_children.

Trait Implementations§

Source§

impl<'a> Clone for DomElement<'a>

Source§

fn clone(&self) -> DomElement<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for DomElement<'a>

Source§

impl<'a> Debug for DomElement<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Element for DomElement<'a>

Source§

fn local_name(&self) -> &str

Lowercase HTML tag name ("div", "p", …).
Source§

fn id(&self) -> Option<&str>

id="..." attribute value, if present.
Source§

fn has_class(&self, c: &str) -> bool

True if the class attribute contains class_name as a whitespace-separated token.
Source§

fn attribute(&self, name: &str) -> Option<&str>

Get an attribute value by name (case-insensitive in HTML; the matcher passes the selector’s exact casing — implementor normalises).
Source§

fn has_attribute(&self, name: &str) -> bool

True if the named attribute is present (regardless of value).
Source§

fn parent(&self) -> Option<Self>

Parent element, if any. None for the root.
Source§

fn prev_element_sibling(&self) -> Option<Self>

Previous element sibling (skip text/comment nodes).
Source§

fn next_element_sibling(&self) -> Option<Self>

Next element sibling.
Source§

fn is_empty(&self) -> bool

True iff the element has no element children and no non-whitespace text content. CSS :empty.
Source§

fn first_element_child(&self) -> Option<Self>

First element child, if any.
Source§

fn is_root(&self) -> bool

True iff this is the document root (no parent).
Source§

fn sibling_index(&self) -> usize

1-indexed sibling position among element siblings. Used by :nth-child and :first-child/:last-child.
Source§

fn sibling_count(&self) -> usize

Total number of element siblings including this one. Used by :nth-last-child and :last-child.
Source§

fn sibling_index_of_type(&self) -> usize

1-indexed position among siblings sharing the same local_name.
Source§

fn sibling_count_of_type(&self) -> usize

Total number of siblings sharing the same local_name (incl. self).
Source§

fn any_descendant<F: FnMut(Self) -> bool>(&self, pred: F) -> bool

True iff some descendant matches pred. Default: depth-first walk via an explicit stack so generics don’t blow up instantiation depth on :has() calls. Implementors with an arena can override for speed.
Source§

fn element_children(&self) -> ElementChildren<Self>

Iterator over direct element children. Default walks via next_element_sibling() from first_element_child().

Auto Trait Implementations§

§

impl<'a> Freeze for DomElement<'a>

§

impl<'a> RefUnwindSafe for DomElement<'a>

§

impl<'a> Send for DomElement<'a>

§

impl<'a> Sync for DomElement<'a>

§

impl<'a> Unpin for DomElement<'a>

§

impl<'a> UnsafeUnpin for DomElement<'a>

§

impl<'a> UnwindSafe for DomElement<'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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

Source§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
Source§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

Source§

fn to_owned_table(&self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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

impl<T> Ungil for T
where T: Send,