Expand description
Smart pointers for the JS-managed DOM objects.
The DOM is made up of DOM objects whose lifetime is entirely controlled by the whims of the SpiderMonkey garbage collector. The types in this module are designed to ensure that any interactions with said Rust types only occur on values that will remain alive the entire time.
Here is a brief overview of the important types:
Root<T>
: a stack-based rooted value.DomRoot<T>
: a stack-based reference to a rooted DOM object.Dom<T>
: a reference to a DOM object that can automatically be traced by the GC when encountered as a field of a Rust structure.
Dom<T>
does not allow access to their inner value without explicitly
creating a stack-based root via the root
method. This returns a DomRoot<T>
,
which causes the JS-owned value to be uncollectable for the duration of the
Root
objectโs lifetime. A reference to the object can then be obtained
from the Root
object. These references are not allowed to outlive their
originating DomRoot<T>
.
Structsยง
- Dom ๐A traced reference to a DOM object
- DomOnce
Cell ๐A holder that allows to lazily initialize the value only onceDom<T>
, using OnceCell Essentially aOnceCell<Dom<T>>
. - Layout
Dom ๐An unrooted reference to a DOM object for use in layout.Layout*Helpers
traits must be implemented on this. - Maybe
Unreflected ๐Dom A traced reference to a DOM object that may not be reflected yet. - MutDom ๐A holder that provides interior mutability for GC-managed values such as
Dom<T>
. Essentially aCell<Dom<T>>
, but safer. - MutNullable
Dom ๐A holder that provides interior mutability for GC-managed values such asDom<T>
, with nullability represented by an enclosing Option wrapper. Essentially aCell<Option<Dom<T>>>
, but safer. - Root ๐A rooted value.
- Root
Collection ๐A rooting mechanism for reflectors on the stack. LIFO is not required.
Constantsยง
- STACK_
ROOTS ๐
Traitsยง
- DomSlice ๐Get a slice of references to DOM objects.
- Stable
Trace ๐Object StableTraceObject
represents values that can be rooted through a stable address that will not change for their whole lifetime. It is an unsafe trait that requires implementors to ensure certain safety guarantees. - ToLayout ๐
Functionsยง
- assert_
in_ ๐layout - assert_
in_ ๐script - trace_
roots ๐ โSM Callback that traces the rooted reflectors
Type Aliasesยง
- DomRoot ๐A rooted reference to a DOM object.