From dbff26bce05d404027ef5bbfd85fb5995e4726bc Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Sun, 28 May 2023 22:43:55 -0400 Subject: Support arbitrary protos when wrapping DOM objects with constructors. --- components/script/dom/rtcdatachannelevent.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'components/script/dom/rtcdatachannelevent.rs') diff --git a/components/script/dom/rtcdatachannelevent.rs b/components/script/dom/rtcdatachannelevent.rs index 95935f68107..c8e5ab8c457 100644 --- a/components/script/dom/rtcdatachannelevent.rs +++ b/components/script/dom/rtcdatachannelevent.rs @@ -6,7 +6,7 @@ use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; use crate::dom::bindings::codegen::Bindings::RTCDataChannelEventBinding::RTCDataChannelEventInit; use crate::dom::bindings::codegen::Bindings::RTCDataChannelEventBinding::RTCDataChannelEventMethods; use crate::dom::bindings::inheritance::Castable; -use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; +use crate::dom::bindings::reflector::{reflect_dom_object2, DomObject}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::DOMString; use crate::dom::event::Event; @@ -14,6 +14,7 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::rtcdatachannel::RTCDataChannel; use crate::dom::window::Window; use dom_struct::dom_struct; +use js::rust::HandleObject; use servo_atoms::Atom; #[dom_struct] @@ -37,9 +38,21 @@ impl RTCDataChannelEvent { cancelable: bool, channel: &RTCDataChannel, ) -> DomRoot { - let event = reflect_dom_object( + Self::new_with_proto(global, None, type_, bubbles, cancelable, channel) + } + + fn new_with_proto( + global: &GlobalScope, + proto: Option, + type_: Atom, + bubbles: bool, + cancelable: bool, + channel: &RTCDataChannel, + ) -> DomRoot { + let event = reflect_dom_object2( Box::new(RTCDataChannelEvent::new_inherited(&channel)), global, + proto, ); { let event = event.upcast::(); @@ -51,11 +64,13 @@ impl RTCDataChannelEvent { #[allow(non_snake_case)] pub fn Constructor( window: &Window, + proto: Option, type_: DOMString, init: &RTCDataChannelEventInit, ) -> DomRoot { - RTCDataChannelEvent::new( + RTCDataChannelEvent::new_with_proto( &window.global(), + proto, Atom::from(type_), init.parent.bubbles, init.parent.cancelable, -- cgit v1.2.3