script::dom::bindings

Module root

Source
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
  • DomOnceCell ๐Ÿ”’
    A holder that allows to lazily initialize the value only once Dom<T>, using OnceCell Essentially a OnceCell<Dom<T>>.
  • LayoutDom ๐Ÿ”’
    An unrooted reference to a DOM object for use in layout. Layout*Helpers traits must be implemented on this.
  • 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 a Cell<Dom<T>>, but safer.
  • MutNullableDom ๐Ÿ”’
    A holder that provides interior mutability for GC-managed values such as Dom<T>, with nullability represented by an enclosing Option wrapper. Essentially a Cell<Option<Dom<T>>>, but safer.
  • Root ๐Ÿ”’
    A rooted value.
  • RootCollection ๐Ÿ”’
    A rooting mechanism for reflectors on the stack. LIFO is not required.

Constantsยง

Traitsยง

  • DomSlice ๐Ÿ”’
    Get a slice of references to DOM objects.
  • StableTraceObject ๐Ÿ”’
    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ยง

Type Aliasesยง

  • DomRoot ๐Ÿ”’
    A rooted reference to a DOM object.