pub enum DocGuard<'a> {
Ref(&'a BaseDocument),
RefCell(Ref<'a, BaseDocument>),
RwLock(RwLockReadGuard<'a, BaseDocument>),
Mutex(MutexGuard<'a, BaseDocument>),
}Variants§
Ref(&'a BaseDocument)
RefCell(Ref<'a, BaseDocument>)
RwLock(RwLockReadGuard<'a, BaseDocument>)
Mutex(MutexGuard<'a, BaseDocument>)
Methods from Deref<Target = BaseDocument>§
Sourcepub fn get_event_listeners(&self, node_id: usize, event_name: &str) -> &[u64]
pub fn get_event_listeners(&self, node_id: usize, event_name: &str) -> &[u64]
Query registered event listeners for a given node ID and event name. Returns an empty Vec if no listeners are registered.
pub fn guard(&self) -> &SharedRwLock
pub fn tree(&self) -> &Slab<Node>
pub fn id(&self) -> usize
pub fn get_node(&self, node_id: usize) -> Option<&Node>
pub fn get_focussed_node_id(&self) -> Option<usize>
Sourcepub fn label_bound_input_element(&self, label_node_id: usize) -> Option<&Node>
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
pub fn root_node(&self) -> &Node
pub fn root_element(&self) -> Option<&Node>
Sourcepub fn try_root_element(&self) -> Option<&Node>
pub fn try_root_element(&self) -> Option<&Node>
Deprecated alias for BaseDocument::root_element.
Both return Option<&Node> after D-2c-followup widened the signature
to eliminate the chained-unwrap panic when the document has no
element child (e.g. before any HTML is parsed into it). Retained for
callers that want explicit Option-style naming.
Sourcepub fn has_changes(&self) -> bool
pub fn has_changes(&self) -> bool
Whether the document has been mutated
pub fn print_tree(&self)
pub fn print_subtree(&self, node_id: usize)
pub fn make_stylesheet( &self, css: impl AsRef<str>, origin: Origin, ) -> DocumentStyleSheet
pub fn hit(&self, x: f32, y: f32) -> Option<HitResult>
pub fn get_hover_node_id(&self) -> Option<usize>
pub fn viewport(&self) -> &Viewport
pub fn get_viewport(&self) -> Viewport
pub fn devtools(&self) -> &DevtoolSettings
pub fn is_animating(&self) -> bool
pub fn get_cursor(&self) -> Option<CursorIcon>
pub fn viewport_scroll(&self) -> Point<f64>
Sourcepub fn get_client_bounding_rect(&self, node_id: usize) -> Option<BoundingRect>
pub fn get_client_bounding_rect(&self, node_id: usize) -> Option<BoundingRect>
Computes the size and position of the Node relative to the viewport
pub fn find_title_node(&self) -> Option<&Node>
Sourcepub fn find_text_position(&self, x: f32, y: f32) -> Option<(usize, usize)>
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.
Sourcepub fn has_text_selection(&self) -> bool
pub fn has_text_selection(&self) -> bool
Check if there is an active (non-empty) text selection
Sourcepub fn get_selected_text(&self) -> Option<String>
pub fn get_selected_text(&self) -> Option<String>
Get the selected text content, supporting selection across multiple inline roots.
Sourcepub fn get_text_selection_ranges(&self) -> Vec<(usize, usize, usize)>
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.
pub fn print_taffy_tree(&self)
pub fn debug_log_node(&self, node_id: usize)
Sourcepub fn submit_form(&self, node_id: usize, submitter_id: usize)
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 submitsubmitter_id- The ID of the node that triggered the submission
https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#form-submission-algorithm
Sourcepub fn get_element_by_id(&self, id: &str) -> Option<usize>
pub fn get_element_by_id(&self, id: &str) -> Option<usize>
Find the node with the specified id attribute (if one exists)
Sourcepub fn query_selector<'input>(
&self,
selector: &'input str,
) -> Result<Option<usize>, ParseError<'input>>
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
Sourcepub fn query_selector_raw(
&self,
selector_list: &SelectorList<SelectorImpl>,
) -> Option<usize>
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
Sourcepub fn query_selector_all<'input>(
&self,
selector: &'input str,
) -> Result<SmallVec<[usize; 32]>, ParseError<'input>>
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 failsOk(SmallVec<usize>)with all matching nodes otherwise
Sourcepub fn query_selector_all_raw(
&self,
selector_list: &SelectorList<SelectorImpl>,
) -> SmallVec<[usize; 32]>
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
Sourcepub fn query_selector_all_from<'input>(
&self,
root_id: usize,
selector: &'input str,
) -> Result<SmallVec<[usize; 32]>, ParseError<'input>>
pub fn query_selector_all_from<'input>( &self, root_id: usize, selector: &'input str, ) -> Result<SmallVec<[usize; 32]>, ParseError<'input>>
Element-scoped query: all nodes matching selector within the subtree
rooted at root_id, EXCLUDING the root itself — DOM
element.querySelectorAll semantics. Unlike the document-global
query_selector_all, this traverses from the
given node, so it also queries detached subtrees (e.g. a cloneNode
result not yet inserted) that the global query cannot reach.
Sourcepub fn query_selector_all_from_raw(
&self,
root_id: usize,
selector_list: &SelectorList<SelectorImpl>,
) -> SmallVec<[usize; 32]>
pub fn query_selector_all_from_raw( &self, root_id: usize, selector_list: &SelectorList<SelectorImpl>, ) -> SmallVec<[usize; 32]>
Find all nodes matching selector_list in the subtree rooted at
root_id, excluding the root. Empty if root_id is absent.
pub fn try_parse_selector_list<'input>( &self, input: &'input str, ) -> Result<SelectorList<SelectorImpl>, ParseError<'input>>
Sourcepub fn node_chain(&self, node_id: usize) -> Vec<usize>
pub fn node_chain(&self, node_id: usize) -> Vec<usize>
Collect the nodes into a chain by traversing upwards
pub fn visit<F>(&self, visit: F)
Sourcepub fn non_anon_ancestor_if_anon(&self, node_id: usize) -> usize
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
pub fn prev_node( &self, start: &Node, filter: impl FnMut(&Node) -> bool, ) -> Option<usize>
pub fn next_node( &self, start: &Node, filter: impl FnMut(&Node) -> bool, ) -> Option<usize>
pub fn node_layout_ancestors(&self, node_id: usize) -> Vec<usize>
pub fn maybe_node_layout_ancestors(&self, node_id: Option<usize>) -> Vec<usize>
Sourcepub fn compare_document_order(&self, node_a: usize, node_b: usize) -> Ordering
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.
Trait Implementations§
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for DocGuard<'a>
impl<'a> !Send for DocGuard<'a>
impl<'a> !Sync for DocGuard<'a>
impl<'a> !UnwindSafe for DocGuard<'a>
impl<'a> Freeze for DocGuard<'a>
impl<'a> Unpin for DocGuard<'a>
impl<'a> UnsafeUnpin for DocGuard<'a>
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
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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