mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Add RTCSessionDescription::ToJSON
This commit is contained in:
parent
0d9f538561
commit
ab04f0429b
2 changed files with 17 additions and 1 deletions
|
@ -15,6 +15,10 @@ use crate::dom::bindings::str::DOMString;
|
|||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::window::Window;
|
||||
use dom_struct::dom_struct;
|
||||
use js::conversions::ToJSValConvertible;
|
||||
use js::jsapi::{JSContext, JSObject};
|
||||
use js::jsval::UndefinedValue;
|
||||
use std::ptr::NonNull;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct RTCSessionDescription {
|
||||
|
@ -66,4 +70,16 @@ impl RTCSessionDescriptionMethods for RTCSessionDescription {
|
|||
fn Sdp(&self) -> DOMString {
|
||||
self.sdp.clone()
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
/// https://w3c.github.io/webrtc-pc/#dom-rtcsessiondescription-tojson
|
||||
unsafe fn ToJSON(&self, cx: *mut JSContext) -> NonNull<JSObject> {
|
||||
let init = RTCSessionDescriptionInit {
|
||||
type_: self.ty,
|
||||
sdp: self.sdp.clone(),
|
||||
};
|
||||
rooted!(in(cx) let mut jsval = UndefinedValue());
|
||||
init.to_jsval(cx, jsval.handle_mut());
|
||||
NonNull::new(jsval.to_object()).unwrap()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
interface RTCSessionDescription {
|
||||
readonly attribute RTCSdpType type;
|
||||
readonly attribute DOMString sdp;
|
||||
// [Default] object toJSON();
|
||||
[Default] object toJSON();
|
||||
};
|
||||
|
||||
dictionary RTCSessionDescriptionInit {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue