mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Support arbitrary protos when wrapping DOM objects with constructors.
This commit is contained in:
parent
d9600ff50f
commit
dbff26bce0
197 changed files with 2028 additions and 586 deletions
|
@ -5,13 +5,14 @@
|
|||
use crate::dom::bindings::codegen::Bindings::RTCIceCandidateBinding::RTCIceCandidateInit;
|
||||
use crate::dom::bindings::codegen::Bindings::RTCIceCandidateBinding::RTCIceCandidateMethods;
|
||||
use crate::dom::bindings::error::{Error, Fallible};
|
||||
use crate::dom::bindings::reflector::reflect_dom_object;
|
||||
use crate::dom::bindings::reflector::reflect_dom_object2;
|
||||
use crate::dom::bindings::reflector::{DomObject, Reflector};
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::window::Window;
|
||||
use dom_struct::dom_struct;
|
||||
use js::rust::HandleObject;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct RTCIceCandidate {
|
||||
|
@ -45,7 +46,18 @@ impl RTCIceCandidate {
|
|||
sdp_m_line_index: Option<u16>,
|
||||
username_fragment: Option<DOMString>,
|
||||
) -> DomRoot<RTCIceCandidate> {
|
||||
reflect_dom_object(
|
||||
Self::new_with_proto(global, None, candidate, sdp_m_id, sdp_m_line_index, username_fragment)
|
||||
}
|
||||
|
||||
fn new_with_proto(
|
||||
global: &GlobalScope,
|
||||
proto: Option<HandleObject>,
|
||||
candidate: DOMString,
|
||||
sdp_m_id: Option<DOMString>,
|
||||
sdp_m_line_index: Option<u16>,
|
||||
username_fragment: Option<DOMString>,
|
||||
) -> DomRoot<RTCIceCandidate> {
|
||||
reflect_dom_object2(
|
||||
Box::new(RTCIceCandidate::new_inherited(
|
||||
candidate,
|
||||
sdp_m_id,
|
||||
|
@ -53,12 +65,14 @@ impl RTCIceCandidate {
|
|||
username_fragment,
|
||||
)),
|
||||
global,
|
||||
proto,
|
||||
)
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn Constructor(
|
||||
window: &Window,
|
||||
proto: Option<HandleObject>,
|
||||
config: &RTCIceCandidateInit,
|
||||
) -> Fallible<DomRoot<RTCIceCandidate>> {
|
||||
if config.sdpMid.is_none() && config.sdpMLineIndex.is_none() {
|
||||
|
@ -66,8 +80,9 @@ impl RTCIceCandidate {
|
|||
"one of sdpMid and sdpMLineIndex must be set"
|
||||
)));
|
||||
}
|
||||
Ok(RTCIceCandidate::new(
|
||||
Ok(RTCIceCandidate::new_with_proto(
|
||||
&window.global(),
|
||||
proto,
|
||||
config.candidate.clone(),
|
||||
config.sdpMid.clone(),
|
||||
config.sdpMLineIndex,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue