mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
auto merge of #4678 : Ms2ger/servo/doc-clone, r=jdm
This commit is contained in:
commit
89645391bf
1 changed files with 10 additions and 0 deletions
|
@ -2,6 +2,11 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
//! This module implements structured cloning, as defined by [HTML]
|
||||||
|
//! (https://html.spec.whatwg.org/multipage/#safe-passing-of-structured-data).
|
||||||
|
|
||||||
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::error::Error::DataClone;
|
use dom::bindings::error::Error::DataClone;
|
||||||
use dom::bindings::global::GlobalRef;
|
use dom::bindings::global::GlobalRef;
|
||||||
|
@ -15,12 +20,14 @@ use js::jsval::{JSVal, UndefinedValue};
|
||||||
use libc::size_t;
|
use libc::size_t;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
|
/// A buffer for a structured clone.
|
||||||
pub struct StructuredCloneData {
|
pub struct StructuredCloneData {
|
||||||
data: *mut u64,
|
data: *mut u64,
|
||||||
nbytes: size_t,
|
nbytes: size_t,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StructuredCloneData {
|
impl StructuredCloneData {
|
||||||
|
/// Writes a structured clone. Returns a `DataClone` error if that fails.
|
||||||
pub fn write(cx: *mut JSContext, message: JSVal)
|
pub fn write(cx: *mut JSContext, message: JSVal)
|
||||||
-> Fallible<StructuredCloneData> {
|
-> Fallible<StructuredCloneData> {
|
||||||
let mut data = ptr::null_mut();
|
let mut data = ptr::null_mut();
|
||||||
|
@ -39,6 +46,9 @@ impl StructuredCloneData {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Reads a structured clone.
|
||||||
|
///
|
||||||
|
/// Panics if `JS_ReadStructuredClone` fails.
|
||||||
pub fn read(self, global: GlobalRef) -> JSVal {
|
pub fn read(self, global: GlobalRef) -> JSVal {
|
||||||
let mut message = UndefinedValue();
|
let mut message = UndefinedValue();
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue