diff options
author | Josh Matthews <josh@joshmatthews.net> | 2025-02-23 09:25:46 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-23 14:25:46 +0000 |
commit | 381e168877d1ddba81a73493ca8e2814ae9b07c3 (patch) | |
tree | d2fc48902138717013a6f8c11d6eb4bf381355b7 /components/script/dom/bindings/iterable.rs | |
parent | 0383ba9a5b940de76823462ebc1b95298ea50903 (diff) | |
download | servo-381e168877d1ddba81a73493ca8e2814ae9b07c3.tar.gz servo-381e168877d1ddba81a73493ca8e2814ae9b07c3.zip |
Move more bindings types to script_bindings (#35620)
* Move weak references implementation to script_bindings.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Move maplike/setlike definitions to script_bindings.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Move base error types to script_bindings.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Formatting.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
---------
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Diffstat (limited to 'components/script/dom/bindings/iterable.rs')
-rw-r--r-- | components/script/dom/bindings/iterable.rs | 34 |
1 files changed, 1 insertions, 33 deletions
diff --git a/components/script/dom/bindings/iterable.rs b/components/script/dom/bindings/iterable.rs index 4b932dfc262..ddb45348de3 100644 --- a/components/script/dom/bindings/iterable.rs +++ b/components/script/dom/bindings/iterable.rs @@ -17,6 +17,7 @@ use js::jsapi::{Heap, JSObject}; use js::jsval::UndefinedValue; use js::rust::{HandleObject, HandleValue, MutableHandleObject}; use script_bindings::conversions::IDLInterface; +pub(crate) use script_bindings::iterable::*; use script_bindings::utils::DOMClass; use crate::dom::bindings::codegen::Bindings::IterableIteratorBinding::{ @@ -31,31 +32,6 @@ use crate::dom::bindings::trace::{JSTraceable, NoTrace, RootedTraceableBox}; use crate::script_runtime::{CanGc, JSContext}; use crate::DomTypes; -/// The values that an iterator will iterate over. -#[derive(JSTraceable, MallocSizeOf)] -pub(crate) enum IteratorType { - /// The keys of the iterable object. - Keys, - /// The values of the iterable object. - Values, - /// The keys and values of the iterable object combined. - Entries, -} - -/// A DOM object that can be iterated over using a pair value iterator. -pub(crate) trait Iterable { - /// The type of the key of the iterator pair. - type Key: ToJSValConvertible; - /// The type of the value of the iterator pair. - type Value: ToJSValConvertible; - /// Return the number of entries that can be iterated over. - fn get_iterable_length(&self) -> u32; - /// Return the value at the provided index. - fn get_value_at_index(&self, index: u32) -> Self::Value; - /// Return the key at the provided index. - fn get_key_at_index(&self, index: u32) -> Self::Key; -} - /// An iterator over the iterable entries of a given DOM interface. #[dom_struct] pub(crate) struct IterableIterator< @@ -162,14 +138,6 @@ impl<D: DomTypes, T: DomObjectIteratorWrap<D> + JSTraceable + Iterable + DomGlob ) -> Root<Dom<Self>> = T::ITER_WRAP; } -/// A version of the [IDLInterface] trait that is specific to types that have -/// iterators defined for them. This allows the `script` crate to define the -/// derives check for the concrete interface type, while the [IteratableIterator] -/// type defined in this module can be parameterized over an unknown generic. -pub trait IteratorDerives { - fn derives(class: &'static DOMClass) -> bool; -} - fn dict_return( cx: JSContext, mut result: MutableHandleObject, |