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
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
Root object. These references are not allowed to outlive their
Dom<T>, using OnceCell Essentially a
Layout*Helperstraits must be implemented on this.
Dom<T>. Essentially a
Cell<Dom<T>>, but safer.
Dom<T>, with nullability represented by an enclosing Option wrapper. Essentially a
Cell<Option<Dom<T>>>, but safer.