script_bindings::root

Type Alias DomRoot

Source
pub type DomRoot<T> = Root<Dom<T>>;
Expand description

A rooted reference to a DOM object.

Aliased Type§

struct DomRoot<T> {
    value: Dom<T>,
    root_list: *const RootCollection,
}

Fields§

§value: Dom<T>

The value to root.

§root_list: *const RootCollection

List that ensures correct dynamic root ordering

Implementations§

Source§

impl<T: Castable> DomRoot<T>

Source

pub fn upcast<U>(root: DomRoot<T>) -> DomRoot<U>
where U: Castable, T: DerivedFrom<U>,

Cast a DOM object root upwards to one of the interfaces it derives from.

Source

pub fn downcast<U>(root: DomRoot<T>) -> Option<DomRoot<U>>
where U: DerivedFrom<T>,

Cast a DOM object root downwards to one of the interfaces it might implement.

Source§

impl<T: DomObject> DomRoot<T>

Source

pub fn from_ref(unrooted: &T) -> DomRoot<T>

Generate a new root from a reference

Source

pub fn as_traced(&self) -> Dom<T>

Create a traced version of this rooted object.

§Safety

This should never be used to create on-stack values. Instead these values should always end up as members of other DOM objects.

Source§

impl<T> Root<T>
where T: StableTraceObject + 'static,

Source

pub unsafe fn new(value: T) -> Self

Create a new stack-bounded root for the provided value. It gives out references which cannot outlive this new Root.

§Safety

It must not outlive its associated RootCollection.

Trait Implementations§

Source§

impl<T> Clone for DomRoot<T>
where T: DomObject,

Source§

fn clone(&self) -> DomRoot<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: DomObject + IDLInterface> FromJSValConvertible for DomRoot<T>

Source§

type Config = ()

Optional configurable behaviour switch; use () for no configuration.
Source§

unsafe fn from_jsval( cx: *mut JSContext, value: HandleValue<'_>, _config: Self::Config, ) -> Result<ConversionResult<DomRoot<T>>, ()>

Convert val to type Self. Optional configuration of type T can be passed as the option argument. If it returns Err(()), a JSAPI exception is pending. If it returns Ok(Failure(reason)), there is no pending JSAPI exception.
Source§

impl<T: DomObject> Hash for DomRoot<T>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T> MallocSizeOf for DomRoot<T>

Source§

fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize

Measure the heap usage of all descendant heap-allocated structures, but not the space taken up by the value itself.
Source§

impl<T> PartialEq for DomRoot<T>
where T: DomObject,

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: DomObject> ToJSValConvertible for DomRoot<T>

Source§

unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue<'_>)

Convert self to a JSVal. JSAPI failure causes a panic.
Source§

impl<T> Traceable for DomRoot<T>
where T: DomObject,

Source§

unsafe fn trace(&self, _: *mut JSTracer)

Trace self.
Source§

impl<T: DomObject> Eq for DomRoot<T>

Source§

impl<T: Debug + StableTraceObject> Debug for Root<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Deref for Root<T>

Source§

type Target = <T as Deref>::Target

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T> Drop for Root<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more