Support arbitrary protos when wrapping DOM objects with constructors.

This commit is contained in:
Josh Matthews 2023-05-28 22:43:55 -04:00
parent d9600ff50f
commit dbff26bce0
197 changed files with 2028 additions and 586 deletions

View file

@ -8,11 +8,12 @@ use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::TestBindingPairIterableBinding::TestBindingPairIterableMethods;
use crate::dom::bindings::error::Fallible;
use crate::dom::bindings::iterable::Iterable;
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
use crate::dom::bindings::reflector::{reflect_dom_object2, Reflector};
use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::str::DOMString;
use crate::dom::globalscope::GlobalScope;
use dom_struct::dom_struct;
use js::rust::HandleObject;
#[dom_struct]
pub struct TestBindingPairIterable {
@ -47,19 +48,20 @@ impl Iterable for TestBindingPairIterable {
}
impl TestBindingPairIterable {
fn new(global: &GlobalScope) -> DomRoot<TestBindingPairIterable> {
reflect_dom_object(
fn new(global: &GlobalScope, proto: Option<HandleObject>) -> DomRoot<TestBindingPairIterable> {
reflect_dom_object2(
Box::new(TestBindingPairIterable {
reflector: Reflector::new(),
map: DomRefCell::new(vec![]),
}),
global,
proto,
)
}
#[allow(non_snake_case)]
pub fn Constructor(global: &GlobalScope) -> Fallible<DomRoot<TestBindingPairIterable>> {
Ok(TestBindingPairIterable::new(global))
pub fn Constructor(global: &GlobalScope, proto: Option<HandleObject>) -> Fallible<DomRoot<TestBindingPairIterable>> {
Ok(TestBindingPairIterable::new(global, proto))
}
}