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 once
Dom<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 as
Dom<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ยง
- AsHandle
Value - Converts a rooted
Heap<Value>
into aHandleValue
. - 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.