Skip to main content

DocGuard

Enum DocGuard 

Source
pub enum DocGuard<'a> {
    Ref(&'a BaseDocument),
    RefCell(Ref<'a, BaseDocument>),
    RwLock(RwLockReadGuard<'a, BaseDocument>),
    Mutex(MutexGuard<'a, BaseDocument>),
}

Variants§

Methods from Deref<Target = BaseDocument>§

Source

pub fn guard(&self) -> &SharedRwLock

Source

pub fn tree(&self) -> &Slab<Node>

Source

pub fn id(&self) -> usize

Source

pub fn get_node(&self, node_id: usize) -> Option<&Node>

Source

pub fn get_focussed_node_id(&self) -> Option<usize>

Source

pub fn label_bound_input_element(&self, label_node_id: usize) -> Option<&Node>

Find the label’s bound input elements: the element id referenced by the “for” attribute of a given label element or the first input element which is nested in the label Note that although there should only be one bound element, we return all possibilities instead of just the first in order to allow the caller to decide which one is correct

Source

pub fn root_node(&self) -> &Node

Source

pub fn try_root_element(&self) -> Option<&Node>

Source

pub fn root_element(&self) -> &Node

Source

pub fn has_changes(&self) -> bool

Whether the document has been mutated

Source

pub fn print_tree(&self)

Source

pub fn print_subtree(&self, node_id: usize)

Source

pub fn make_stylesheet( &self, css: impl AsRef<str>, origin: Origin, ) -> DocumentStyleSheet

Source

pub fn has_pending_critical_resources(&self) -> bool

Whether the Document has pending requests for “critical” resources (that should block rendering)

Source

pub fn hit(&self, x: f32, y: f32) -> Option<HitResult>

Source

pub fn get_hover_node_id(&self) -> Option<usize>

Source

pub fn media_type(&self) -> &MediaType

Returns the current CSS media type used to evaluate @media rules.

Source

pub fn viewport(&self) -> &Viewport

Source

pub fn get_viewport(&self) -> Viewport

Source

pub fn devtools(&self) -> &DevtoolSettings

Source

pub fn is_animating(&self) -> bool

Source

pub fn get_cursor(&self) -> Option<CursorIcon>

Source

pub fn viewport_scroll(&self) -> Point<f64>

Source

pub fn get_client_bounding_rect(&self, node_id: usize) -> Option<BoundingRect>

Computes the size and position of the Node relative to the viewport

Source

pub fn find_title_node(&self) -> Option<&Node>

Source

pub fn find_text_position(&self, x: f32, y: f32) -> Option<(usize, usize)>

Find the text position (inline_root_id, byte_offset) at a given point. Uses hit() for proper coordinate transformation, then finds the inline root and byte offset.

Source

pub fn has_text_selection(&self) -> bool

Check if there is an active (non-empty) text selection

Source

pub fn get_selected_text(&self) -> Option<String>

Get the selected text content, supporting selection across multiple inline roots.

Source

pub fn get_text_selection_ranges(&self) -> Vec<(usize, usize, usize)>

Get all selection ranges as Vec<(node_id, start_offset, end_offset)>. Returns empty vec if no selection.

Source

pub fn print_taffy_tree(&self)

Source

pub fn debug_log_node(&self, node_id: usize)

Source

pub fn submit_form(&self, node_id: usize, submitter_id: usize)

Submits a form with the given form node ID and submitter node ID

§Arguments
  • node_id - The ID of the form node to submit
  • submitter_id - The ID of the node that triggered the submission

https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#form-submission-algorithm

Source

pub fn get_element_by_id(&self, id: &str) -> Option<usize>

Find the node with the specified id attribute (if one exists)

Source

pub fn query_selector<'input>( &self, selector: &'input str, ) -> Result<Option<usize>, ParseError<'input>>

Find the first node that matches the selector specified as a string Returns:

  • Err(_) if parsing the selector fails
  • Ok(None) if nothing matches
  • Ok(Some(node_id)) with the first node ID that matches if one is found
Source

pub fn query_selector_raw( &self, selector_list: &SelectorList<SelectorImpl>, ) -> Option<usize>

Find the first node that matches the selector(s) specified in selector_list

Source

pub fn query_selector_all<'input>( &self, selector: &'input str, ) -> Result<SmallVec<[usize; 32]>, ParseError<'input>>

Find all nodes that match the selector specified as a string Returns:

  • Err(_) if parsing the selector fails
  • Ok(SmallVec<usize>) with all matching nodes otherwise
Source

pub fn query_selector_all_raw( &self, selector_list: &SelectorList<SelectorImpl>, ) -> SmallVec<[usize; 32]>

Find all nodes that match the selector(s) specified in selector_list

Source

pub fn try_parse_selector_list<'input>( &self, input: &'input str, ) -> Result<SelectorList<SelectorImpl>, ParseError<'input>>

Source

pub fn node_chain(&self, node_id: usize) -> Vec<usize>

Collect the nodes into a chain by traversing upwards

Source

pub fn visit<F>(&self, visit: F)
where F: FnMut(usize, &Node),

Source

pub fn non_anon_ancestor_if_anon(&self, node_id: usize) -> usize

If the node is non-anonymous then returns the node’s id Else find’s the first non-anonymous ancester of the node

Source

pub fn next_node( &self, start: &Node, filter: impl FnMut(&Node) -> bool, ) -> Option<usize>

Source

pub fn node_layout_ancestors(&self, node_id: usize) -> Vec<usize>

Source

pub fn maybe_node_layout_ancestors(&self, node_id: Option<usize>) -> Vec<usize>

Source

pub fn compare_document_order(&self, node_a: usize, node_b: usize) -> Ordering

Compare the document order of two nodes. Returns Ordering::Less if node_a comes before node_b in document order. Returns Ordering::Greater if node_a comes after node_b. Returns Ordering::Equal if they are the same node.

Source

pub fn collect_inline_roots_in_range( &self, start_node: usize, end_node: usize, ) -> Vec<usize>

Collect all inline root nodes between start_node and end_node in document order. Both start and end are assumed to be inline roots. Returns the nodes in document order (from first to last).

Source

pub fn build_accessibility_tree(&self) -> TreeUpdate

Trait Implementations§

Source§

impl Deref for DocGuard<'_>

Source§

type Target = BaseDocument

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<'a> Freeze for DocGuard<'a>

§

impl<'a> !RefUnwindSafe for DocGuard<'a>

§

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

§

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

§

impl<'a> Unpin for DocGuard<'a>

§

impl<'a> UnsafeUnpin for DocGuard<'a>

§

impl<'a> !UnwindSafe for DocGuard<'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> 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> MaybeBoxed<Box<T>> for T

Source§

fn maybe_boxed(self) -> Box<T>

Convert
Source§

impl<T> MaybeBoxed<T> for T

Source§

fn maybe_boxed(self) -> T

Convert
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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,