Struct script::dom::bindings::root::Root

source ·
pub struct Root<T: StableTraceObject> {
    value: T,
    root_list: *const RootCollection,
}
Expand description

A rooted value.

Fields§

§value: T

The value to root.

§root_list: *const RootCollection

List that ensures correct dynamic root ordering

Implementations§

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 cannot outlive its associated RootCollection, and it gives out references which cannot outlive this new Root.

source§

impl<T: Castable> Root<Dom<T>>

source

pub fn upcast<U>(root: Root<Dom<T>>) -> Root<Dom<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: Root<Dom<T>>) -> Option<Root<Dom<U>>>
where U: DerivedFrom<T>,

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

source§

impl<T: DomObject> Root<Dom<T>>

source

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

Generate a new root from a reference

source

pub(crate) 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<MaybeUnreflectedDom<T>>
where T: DomObject,

source

pub fn as_ptr(&self) -> *const T

source§

impl<T> Root<MaybeUnreflectedDom<T>>
where T: MutDomObject,

source

pub unsafe fn reflect_with(self, obj: *mut JSObject) -> Root<Dom<T>>

Trait Implementations§

source§

impl<T> Clone for Root<Dom<T>>
where T: DomObject,

source§

fn clone(&self) -> Root<Dom<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 Debug for Root<Dom<Element>>

source§

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

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

impl<T> Deref for Root<T>

§

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
source§

impl Element for Root<Dom<Element>>

§

type Impl = SelectorImpl

source§

fn opaque(&self) -> OpaqueElement

Converts self into an opaque representation.
source§

fn parent_element(&self) -> Option<Root<Dom<Element>>>

source§

fn parent_node_is_shadow_root(&self) -> bool

Whether the parent node of this element is a shadow root.
source§

fn containing_shadow_host(&self) -> Option<Self>

The host of the containing shadow root, if any.
source§

fn is_pseudo_element(&self) -> bool

Whether we’re matching on a pseudo-element.
source§

fn match_pseudo_element( &self, _pseudo: &PseudoElement, _context: &mut MatchingContext<'_, Self::Impl>, ) -> bool

source§

fn prev_sibling_element(&self) -> Option<Root<Dom<Element>>>

Skips non-element nodes
source§

fn next_sibling_element(&self) -> Option<Root<Dom<Element>>>

Skips non-element nodes
source§

fn first_element_child(&self) -> Option<Root<Dom<Element>>>

Skips non-element nodes
source§

fn attr_matches( &self, ns: &NamespaceConstraint<&Namespace>, local_name: &LocalName, operation: &AttrSelectorOperation<&AtomString>, ) -> bool

source§

fn is_root(&self) -> bool

Returns whether this element matches :root, i.e. whether it is the root element of a document. Read more
source§

fn is_empty(&self) -> bool

Returns whether this element matches :empty. Read more
source§

fn has_local_name(&self, local_name: &LocalName) -> bool

source§

fn has_namespace(&self, ns: &Namespace) -> bool

Empty string for no namespace
source§

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

Whether this element and the other element have the same local name and namespace.
source§

fn match_non_ts_pseudo_class( &self, pseudo_class: &NonTSPseudoClass, _: &mut MatchingContext<'_, Self::Impl>, ) -> bool

Whether this element is a link.
source§

fn has_id(&self, id: &AtomIdent, case_sensitivity: CaseSensitivity) -> bool

source§

fn is_part(&self, _name: &AtomIdent) -> bool

source§

fn imported_part(&self, _: &AtomIdent) -> Option<AtomIdent>

Returns the mapping from the exportparts attribute in the reverse direction, that is, in an outer-tree -> inner-tree direction.
source§

fn has_class(&self, name: &AtomIdent, case_sensitivity: CaseSensitivity) -> bool

source§

fn is_html_element_in_html_document(&self) -> bool

source§

fn is_html_slot_element(&self) -> bool

Returns whether the element is an HTML element.
source§

fn apply_selector_flags(&self, flags: ElementSelectorFlags)

Sets selector flags on the elemnt itself or the parent, depending on the flags, which indicate what kind of work may need to be performed when DOM state changes.
source§

fn add_element_unique_hashes(&self, filter: &mut BloomFilter) -> bool

Add hashes unique to this element to the given filter, returning true if any got added.
source§

fn has_custom_state(&self, _name: &AtomIdent) -> bool

source§

fn pseudo_element_originating_element(&self) -> Option<Self>

The parent of a given pseudo-element, after matching a pseudo-element selector. Read more
source§

fn has_attr_in_no_namespace( &self, local_name: &<Self::Impl as SelectorImpl>::LocalName, ) -> bool

source§

fn assigned_slot(&self) -> Option<Self>

Returns the assigned element this element is assigned to. Read more
source§

fn ignores_nth_child_selectors(&self) -> bool

Returns whether this element should ignore matching nth child selector.
source§

impl<T: DomObject + IDLInterface> FromJSValConvertible for Root<Dom<T>>

§

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<Root<Dom<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> MallocSizeOf for Root<Dom<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 Root<Dom<T>>
where T: DomObject,

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: DomObject> ToJSValConvertible for Root<Dom<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 Root<Dom<T>>
where T: DomObject,

source§

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

Trace self.

Auto Trait Implementations§

§

impl<T> Freeze for Root<T>
where T: Freeze,

§

impl<T> !RefUnwindSafe for Root<T>

§

impl<T> !Send for Root<T>

§

impl<T> !Sync for Root<T>

§

impl<T> Unpin for Root<T>
where T: Unpin,

§

impl<T> !UnwindSafe for Root<T>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> Downcast<T> for T

source§

fn downcast(&self) -> &T

source§

impl<T> Filterable for T

source§

fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>

Creates a filterable data provider with the given name for debugging. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> MaybeBoxed<Box<T>> for T

source§

fn maybe_boxed(self) -> Box<T>

Convert
source§

impl<T> MaybeBoxed<T> for T

source§

fn maybe_boxed(self) -> T

Convert
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> Upcast<T> for T

source§

fn upcast(&self) -> Option<&T>

source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> Formattable for T
where T: Deref, <T as Deref>::Target: Formattable,

source§

impl<T> MaybeSendSync for T

source§

impl<T> Parsable for T
where T: Deref, <T as Deref>::Target: Parsable,