pub struct DomSnapshot { /* private fields */ }Expand description
An owned snapshot of a DOM subtree.
Nodes are stored in pre-order so id == index. roots lists the ids of
top-level nodes (a snapshot has exactly one root in practice).
Implementations§
Source§impl DomSnapshot
impl DomSnapshot
Sourcepub fn from_tree(
root: &NodeRef<HtmlNodeType>,
) -> (Self, Vec<Weak<RefCell<TreeNode<HtmlNodeType>>>>)
pub fn from_tree( root: &NodeRef<HtmlNodeType>, ) -> (Self, Vec<Weak<RefCell<TreeNode<HtmlNodeType>>>>)
Builds a snapshot of root and the matching live-node references.
dom_refs[i] is the live DOM node for snapshot node id i. The refs
are kept separate (and are not Send) so the UI thread can apply
attribute write-backs after the background thread finished building.
Sourcepub fn from_mirror(
root: &NodeRef<HtmlNodeType>,
dom_ids: &HashMap<usize, u64>,
) -> Self
pub fn from_mirror( root: &NodeRef<HtmlNodeType>, dom_ids: &HashMap<usize, u64>, ) -> Self
Builds a snapshot of a JS thread’s mirror tree.
dom_ids maps Rc::as_ptr addresses of mirror nodes to the stable id
assigned by the JS runtime, so node identities survive the snapshot
round trip. Mirrored nodes that were never exposed to scripts carry
SnapNode::dom_id zero.
Sourcepub fn into_tree(&self) -> (DomTree, HashMap<usize, u64>)
pub fn into_tree(&self) -> (DomTree, HashMap<usize, u64>)
Rebuilds a live DOM tree from the snapshot.
The returned map keyed by Rc::as_ptr address pairs every non-zero
SnapNode::dom_id with the freshly built node, so the caller can
re-register the JS runtime’s node references after committing.
Sourcepub fn inner_text(&self, id: NodeId) -> String
pub fn inner_text(&self, id: NodeId) -> String
Concatenated text content of a node, including descendants.
Trait Implementations§
Source§impl Debug for DomSnapshot
impl Debug for DomSnapshot
Source§impl Default for DomSnapshot
impl Default for DomSnapshot
Source§fn default() -> DomSnapshot
fn default() -> DomSnapshot
Auto Trait Implementations§
impl Freeze for DomSnapshot
impl RefUnwindSafe for DomSnapshot
impl Send for DomSnapshot
impl Sync for DomSnapshot
impl Unpin for DomSnapshot
impl UnsafeUnpin for DomSnapshot
impl UnwindSafe for DomSnapshot
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().