mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Merge branch 'master' into tojson
This commit is contained in:
commit
caf7a2488e
88 changed files with 1028 additions and 1122 deletions
|
@ -13,6 +13,7 @@ use crate::dom::bindings::settings_stack::{AutoEntryScript, AutoIncumbentScript}
|
|||
use crate::dom::bindings::utils::AsCCharPtrPtr;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::window::Window;
|
||||
use crate::script_runtime::JSContext as SafeJSContext;
|
||||
use js::jsapi::Heap;
|
||||
use js::jsapi::JSAutoRealm;
|
||||
use js::jsapi::{AddRawValueRoot, IsCallable, JSContext, JSObject};
|
||||
|
@ -112,7 +113,7 @@ impl PartialEq for CallbackObject {
|
|||
/// callback interface types.
|
||||
pub trait CallbackContainer {
|
||||
/// Create a new CallbackContainer object for the given `JSObject`.
|
||||
unsafe fn new(cx: *mut JSContext, callback: *mut JSObject) -> Rc<Self>;
|
||||
unsafe fn new(cx: SafeJSContext, callback: *mut JSObject) -> Rc<Self>;
|
||||
/// Returns the underlying `CallbackObject`.
|
||||
fn callback_holder(&self) -> &CallbackObject;
|
||||
/// Returns the underlying `JSObject`.
|
||||
|
@ -151,8 +152,8 @@ impl CallbackFunction {
|
|||
|
||||
/// Initialize the callback function with a value.
|
||||
/// Should be called once this object is done moving.
|
||||
pub unsafe fn init(&mut self, cx: *mut JSContext, callback: *mut JSObject) {
|
||||
self.object.init(cx, callback);
|
||||
pub unsafe fn init(&mut self, cx: SafeJSContext, callback: *mut JSObject) {
|
||||
self.object.init(*cx, callback);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,8 +179,8 @@ impl CallbackInterface {
|
|||
|
||||
/// Initialize the callback function with a value.
|
||||
/// Should be called once this object is done moving.
|
||||
pub unsafe fn init(&mut self, cx: *mut JSContext, callback: *mut JSObject) {
|
||||
self.object.init(cx, callback);
|
||||
pub unsafe fn init(&mut self, cx: SafeJSContext, callback: *mut JSObject) {
|
||||
self.object.init(*cx, callback);
|
||||
}
|
||||
|
||||
/// Returns the property with the given `name`, if it is a callable object,
|
||||
|
@ -254,8 +255,8 @@ impl CallSetup {
|
|||
let ais = callback.incumbent().map(AutoIncumbentScript::new);
|
||||
CallSetup {
|
||||
exception_global: global,
|
||||
cx: cx,
|
||||
old_realm: unsafe { EnterRealm(cx, callback.callback()) },
|
||||
cx: *cx,
|
||||
old_realm: unsafe { EnterRealm(*cx, callback.callback()) },
|
||||
handling: handling,
|
||||
entry_script: Some(aes),
|
||||
incumbent_script: ais,
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -76,6 +76,7 @@ use crate::dom::customelementregistry::{ConstructionStackEntry, CustomElementSta
|
|||
use crate::dom::element::{Element, ElementCreator};
|
||||
use crate::dom::htmlelement::HTMLElement;
|
||||
use crate::dom::window::Window;
|
||||
use crate::script_runtime::JSContext as SafeJSContext;
|
||||
use crate::script_thread::ScriptThread;
|
||||
use html5ever::interface::QualName;
|
||||
use html5ever::LocalName;
|
||||
|
@ -99,7 +100,7 @@ where
|
|||
// Step 2 is checked in the generated caller code
|
||||
|
||||
// Step 3
|
||||
rooted!(in(window.get_cx()) let new_target = call_args.new_target().to_object());
|
||||
rooted!(in(*window.get_cx()) let new_target = call_args.new_target().to_object());
|
||||
let definition = match registry.lookup_definition_by_constructor(new_target.handle()) {
|
||||
Some(definition) => definition,
|
||||
None => {
|
||||
|
@ -109,15 +110,15 @@ where
|
|||
},
|
||||
};
|
||||
|
||||
rooted!(in(window.get_cx()) let callee = UnwrapObjectStatic(call_args.callee()));
|
||||
rooted!(in(*window.get_cx()) let callee = UnwrapObjectStatic(call_args.callee()));
|
||||
if callee.is_null() {
|
||||
return Err(Error::Security);
|
||||
}
|
||||
|
||||
{
|
||||
let _ac = JSAutoRealm::new(window.get_cx(), callee.get());
|
||||
rooted!(in(window.get_cx()) let mut constructor = ptr::null_mut::<JSObject>());
|
||||
rooted!(in(window.get_cx()) let global_object = CurrentGlobalOrNull(window.get_cx()));
|
||||
let _ac = JSAutoRealm::new(*window.get_cx(), callee.get());
|
||||
rooted!(in(*window.get_cx()) let mut constructor = ptr::null_mut::<JSObject>());
|
||||
rooted!(in(*window.get_cx()) let global_object = CurrentGlobalOrNull(*window.get_cx()));
|
||||
|
||||
if definition.is_autonomous() {
|
||||
// Step 4
|
||||
|
@ -133,7 +134,7 @@ where
|
|||
// Step 5
|
||||
get_constructor_object_from_local_name(
|
||||
definition.local_name.clone(),
|
||||
window.get_cx(),
|
||||
*window.get_cx(),
|
||||
global_object.handle(),
|
||||
constructor.handle_mut(),
|
||||
);
|
||||
|
@ -201,7 +202,7 @@ pub fn get_constructor_object_from_local_name(
|
|||
) -> bool {
|
||||
macro_rules! get_constructor(
|
||||
($binding:ident) => ({
|
||||
unsafe { $binding::GetConstructorObject(cx, global, rval); }
|
||||
unsafe { $binding::GetConstructorObject(SafeJSContext::from_ptr(cx), global, rval); }
|
||||
true
|
||||
})
|
||||
);
|
||||
|
|
|
@ -13,6 +13,7 @@ use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
|
|||
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||
use crate::dom::bindings::trace::{JSTraceable, RootedTraceableBox};
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::script_runtime::JSContext as SafeJSContext;
|
||||
use dom_struct::dom_struct;
|
||||
use js::conversions::ToJSValConvertible;
|
||||
use js::jsapi::{Heap, JSContext, JSObject};
|
||||
|
@ -62,7 +63,7 @@ impl<T: DomObject + JSTraceable + Iterable> IterableIterator<T> {
|
|||
pub fn new(
|
||||
iterable: &T,
|
||||
type_: IteratorType,
|
||||
wrap: unsafe fn(*mut JSContext, &GlobalScope, Box<IterableIterator<T>>) -> DomRoot<Self>,
|
||||
wrap: unsafe fn(SafeJSContext, &GlobalScope, Box<IterableIterator<T>>) -> DomRoot<Self>,
|
||||
) -> DomRoot<Self> {
|
||||
let iterator = Box::new(IterableIterator {
|
||||
reflector: Reflector::new(),
|
||||
|
@ -75,41 +76,41 @@ impl<T: DomObject + JSTraceable + Iterable> IterableIterator<T> {
|
|||
|
||||
/// Return the next value from the iterable object.
|
||||
#[allow(non_snake_case)]
|
||||
pub fn Next(&self, cx: *mut JSContext) -> Fallible<NonNull<JSObject>> {
|
||||
pub fn Next(&self, cx: SafeJSContext) -> Fallible<NonNull<JSObject>> {
|
||||
let index = self.index.get();
|
||||
rooted!(in(cx) let mut value = UndefinedValue());
|
||||
rooted!(in(cx) let mut rval = ptr::null_mut::<JSObject>());
|
||||
rooted!(in(*cx) let mut value = UndefinedValue());
|
||||
rooted!(in(*cx) let mut rval = ptr::null_mut::<JSObject>());
|
||||
let result = if index >= self.iterable.get_iterable_length() {
|
||||
dict_return(cx, rval.handle_mut(), true, value.handle())
|
||||
dict_return(*cx, rval.handle_mut(), true, value.handle())
|
||||
} else {
|
||||
match self.type_ {
|
||||
IteratorType::Keys => {
|
||||
unsafe {
|
||||
self.iterable
|
||||
.get_key_at_index(index)
|
||||
.to_jsval(cx, value.handle_mut());
|
||||
.to_jsval(*cx, value.handle_mut());
|
||||
}
|
||||
dict_return(cx, rval.handle_mut(), false, value.handle())
|
||||
dict_return(*cx, rval.handle_mut(), false, value.handle())
|
||||
},
|
||||
IteratorType::Values => {
|
||||
unsafe {
|
||||
self.iterable
|
||||
.get_value_at_index(index)
|
||||
.to_jsval(cx, value.handle_mut());
|
||||
.to_jsval(*cx, value.handle_mut());
|
||||
}
|
||||
dict_return(cx, rval.handle_mut(), false, value.handle())
|
||||
dict_return(*cx, rval.handle_mut(), false, value.handle())
|
||||
},
|
||||
IteratorType::Entries => {
|
||||
rooted!(in(cx) let mut key = UndefinedValue());
|
||||
rooted!(in(*cx) let mut key = UndefinedValue());
|
||||
unsafe {
|
||||
self.iterable
|
||||
.get_key_at_index(index)
|
||||
.to_jsval(cx, key.handle_mut());
|
||||
.to_jsval(*cx, key.handle_mut());
|
||||
self.iterable
|
||||
.get_value_at_index(index)
|
||||
.to_jsval(cx, value.handle_mut());
|
||||
.to_jsval(*cx, value.handle_mut());
|
||||
}
|
||||
key_and_value_return(cx, rval.handle_mut(), key.handle(), value.handle())
|
||||
key_and_value_return(*cx, rval.handle_mut(), key.handle(), value.handle())
|
||||
},
|
||||
}
|
||||
};
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
use crate::dom::bindings::conversions::DerivedFrom;
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use js::jsapi::{Heap, JSContext, JSObject};
|
||||
use crate::script_runtime::JSContext;
|
||||
use js::jsapi::{Heap, JSObject};
|
||||
use js::rust::HandleObject;
|
||||
use std::default::Default;
|
||||
|
||||
|
@ -16,7 +17,7 @@ use std::default::Default;
|
|||
pub fn reflect_dom_object<T, U>(
|
||||
obj: Box<T>,
|
||||
global: &U,
|
||||
wrap_fn: unsafe fn(*mut JSContext, &GlobalScope, Box<T>) -> DomRoot<T>,
|
||||
wrap_fn: unsafe fn(JSContext, &GlobalScope, Box<T>) -> DomRoot<T>,
|
||||
) -> DomRoot<T>
|
||||
where
|
||||
T: DomObject,
|
||||
|
|
|
@ -321,7 +321,7 @@ impl StructuredCloneData {
|
|||
WriteBytesToJSStructuredCloneData(data as *const u8, nbytes, scdata);
|
||||
|
||||
assert!(JS_ReadStructuredClone(
|
||||
cx,
|
||||
*cx,
|
||||
scdata,
|
||||
JS_STRUCTURED_CLONE_VERSION,
|
||||
StructuredCloneScope::DifferentProcess,
|
||||
|
|
|
@ -13,6 +13,7 @@ use crate::dom::bindings::inheritance::TopTypeId;
|
|||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::bindings::trace::trace_object;
|
||||
use crate::dom::windowproxy;
|
||||
use crate::script_runtime::JSContext as SafeJSContext;
|
||||
use js::glue::{CallJitGetterOp, CallJitMethodOp, CallJitSetterOp, IsWrapper};
|
||||
use js::glue::{GetCrossCompartmentWrapper, JS_GetReservedSlot, WrapperNew};
|
||||
use js::glue::{UnwrapObjectDynamic, RUST_JSID_TO_INT, RUST_JSID_TO_STRING};
|
||||
|
@ -353,7 +354,7 @@ pub unsafe extern "C" fn enumerate_global(
|
|||
return false;
|
||||
}
|
||||
for init_fun in InterfaceObjectMap::MAP.values() {
|
||||
init_fun(cx, Handle::from_raw(obj));
|
||||
init_fun(SafeJSContext::from_ptr(cx), Handle::from_raw(obj));
|
||||
}
|
||||
true
|
||||
}
|
||||
|
@ -388,7 +389,7 @@ pub unsafe extern "C" fn resolve_global(
|
|||
let bytes = slice::from_raw_parts(ptr, length as usize);
|
||||
|
||||
if let Some(init_fun) = InterfaceObjectMap::MAP.get(bytes) {
|
||||
init_fun(cx, Handle::from_raw(obj));
|
||||
init_fun(SafeJSContext::from_ptr(cx), Handle::from_raw(obj));
|
||||
*rval = true;
|
||||
} else {
|
||||
*rval = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue