script/dom/testing/
testbindingsetlikewithinterface.rs1use dom_struct::dom_struct;
8use indexmap::IndexSet;
9use js::context::JSContext;
10use js::rust::HandleObject;
11use script_bindings::cell::DomRefCell;
12use script_bindings::like::Setlike;
13use script_bindings::reflector::{Reflector, reflect_dom_object_with_proto_and_cx};
14
15use crate::dom::bindings::codegen::Bindings::TestBindingSetlikeWithInterfaceBinding::TestBindingSetlikeWithInterfaceMethods;
16use crate::dom::bindings::error::Fallible;
17use crate::dom::bindings::root::DomRoot;
18use crate::dom::globalscope::GlobalScope;
19use crate::dom::testbinding::TestBinding;
20use crate::setlike;
21
22#[dom_struct]
24pub(crate) struct TestBindingSetlikeWithInterface {
25 reflector: Reflector,
26 #[custom_trace]
27 internal: DomRefCell<IndexSet<DomRoot<TestBinding>>>,
28}
29
30impl TestBindingSetlikeWithInterface {
31 fn new(
32 cx: &mut JSContext,
33 global: &GlobalScope,
34 proto: Option<HandleObject>,
35 ) -> DomRoot<TestBindingSetlikeWithInterface> {
36 reflect_dom_object_with_proto_and_cx(
37 Box::new(TestBindingSetlikeWithInterface {
38 reflector: Reflector::new(),
39 internal: DomRefCell::new(IndexSet::new()),
40 }),
41 global,
42 proto,
43 cx,
44 )
45 }
46}
47
48impl TestBindingSetlikeWithInterfaceMethods<crate::DomTypeHolder>
49 for TestBindingSetlikeWithInterface
50{
51 fn Constructor(
52 cx: &mut JSContext,
53 global: &GlobalScope,
54 proto: Option<HandleObject>,
55 ) -> Fallible<DomRoot<TestBindingSetlikeWithInterface>> {
56 Ok(TestBindingSetlikeWithInterface::new(cx, global, proto))
57 }
58
59 fn Size(&self) -> u32 {
60 self.internal.size()
61 }
62}
63
64impl Setlike for TestBindingSetlikeWithInterface {
65 type Key = DomRoot<TestBinding>;
66
67 setlike!(self, internal);
68}