mirror of
https://github.com/servo/servo.git
synced 2025-08-07 22:45:34 +01:00
More miscellaneous script splitting changes (#36220)
* script: Move HasParent to script_bindings and update imports for InheritTypes. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Make principal creation generic over DOM interface. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Move a bunch of proxy-related code to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Make some proxy-related code generic over the DOM interface. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Move DomSlice to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Move some utility bindings code to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Make enumerating and resolving globals generic over the DOM interface. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Make realm helpers generic over the DOM interface. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Move implementations on concrete DOM types to concrete bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Make additional codegen helpers generic over the DOM interface. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Make iterator creation generic over the DOM interface. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Make reporting an exception a generic operation. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Move AsCCharPtrPtr to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Formatting. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Address clippy warnings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
971490084e
commit
b445053a7c
33 changed files with 806 additions and 628 deletions
|
@ -19,16 +19,21 @@ use js::rust::Runtime;
|
|||
use servo_url::MutableOrigin;
|
||||
|
||||
use super::structuredclone::StructuredCloneTags;
|
||||
use crate::dom::bindings::utils::DomHelpers;
|
||||
use crate::{DomTypeHolder, DomTypes};
|
||||
|
||||
/// An owned reference to Servo's `JSPrincipals` instance.
|
||||
#[repr(transparent)]
|
||||
pub(crate) struct ServoJSPrincipals(NonNull<JSPrincipals>);
|
||||
|
||||
impl ServoJSPrincipals {
|
||||
pub(crate) fn new(origin: &MutableOrigin) -> Self {
|
||||
pub(crate) fn new<D: DomTypes>(origin: &MutableOrigin) -> Self {
|
||||
unsafe {
|
||||
let private: Box<MutableOrigin> = Box::new(origin.clone());
|
||||
let raw = CreateRustJSPrincipals(&PRINCIPALS_CALLBACKS, Box::into_raw(private) as _);
|
||||
let raw = CreateRustJSPrincipals(
|
||||
<D as DomHelpers<D>>::principals_callbacks(),
|
||||
Box::into_raw(private) as _,
|
||||
);
|
||||
// The created `JSPrincipals` object has an initial reference
|
||||
// count of zero, so the following code will set it to one
|
||||
Self::from_raw_nonnull(NonNull::new_unchecked(raw))
|
||||
|
@ -175,14 +180,14 @@ pub(crate) unsafe extern "C" fn read_jsprincipal(
|
|||
let Ok(origin) = bincode::deserialize(&bytes[..]) else {
|
||||
return false;
|
||||
};
|
||||
let principal = ServoJSPrincipals::new(&origin);
|
||||
let principal = ServoJSPrincipals::new::<DomTypeHolder>(&origin);
|
||||
*principals = principal.as_raw();
|
||||
// we transferred ownership of principal to the caller
|
||||
std::mem::forget(principal);
|
||||
true
|
||||
}
|
||||
|
||||
const PRINCIPALS_CALLBACKS: JSPrincipalsCallbacks = JSPrincipalsCallbacks {
|
||||
pub(crate) const PRINCIPALS_CALLBACKS: JSPrincipalsCallbacks = JSPrincipalsCallbacks {
|
||||
write: Some(write_jsprincipal),
|
||||
isSystemOrAddonPrincipal: Some(principals_is_system_or_addon_principal),
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue