mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Adapt Servo for mozjs 0.6 and the changes introduced in servo/rust-mozjs#393
This commit is contained in:
parent
e04d517bff
commit
356c57e628
48 changed files with 403 additions and 307 deletions
8
Cargo.lock
generated
8
Cargo.lock
generated
|
@ -1635,7 +1635,7 @@ dependencies = [
|
|||
"cssparser 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hashglobe 0.1.0",
|
||||
"mozjs 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mozjs 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.19.0",
|
||||
"serde_bytes 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"servo_arc 0.1.1",
|
||||
|
@ -1813,7 +1813,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "mozjs"
|
||||
version = "0.5.0"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cmake 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2502,7 +2502,7 @@ dependencies = [
|
|||
"mime_guess 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mitochondria 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mozangle 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mozjs 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mozjs 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"msg 0.0.1",
|
||||
"net_traits 0.0.1",
|
||||
"num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -3904,7 +3904,7 @@ dependencies = [
|
|||
"checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919"
|
||||
"checksum mitochondria 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9de3eca27871df31c33b807f834b94ef7d000956f57aa25c5aed9c5f0aae8f6f"
|
||||
"checksum mozangle 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1f0583e6792917f498bb3a7440f777a59353102063445ab7f5e9d1dc4ed593aa"
|
||||
"checksum mozjs 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71268984a252907b3ee8c7dec2c0dffcf6acaba8af35a45865fa7626bc393c38"
|
||||
"checksum mozjs 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "469f86d1ce125f1a9960e9f5f924388e47b58ac6bf7525f8f98fdc1160decf58"
|
||||
"checksum mozjs_sys 0.50.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e61a792a125b1364c5ec50255ed8343ce02dc56098f8868dd209d472c8de006a"
|
||||
"checksum mp3-metadata 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ab5f1d2693586420208d1200ce5a51cd44726f055b635176188137aff42c7de"
|
||||
"checksum mp4parse 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f821e3799bc0fd16d9b861fb02fa7ee1b5fba29f45ad591dade105c48ca9a1a0"
|
||||
|
|
|
@ -19,7 +19,6 @@ opt-level = 3
|
|||
# lto = false
|
||||
|
||||
[patch.crates-io]
|
||||
|
||||
# If you need to temporarily test Servo with a local fork of some upstream
|
||||
# crate, add that here. Use the form:
|
||||
#
|
||||
|
|
|
@ -40,7 +40,7 @@ fn expand_dom_object(input: syn::DeriveInput) -> quote::Tokens {
|
|||
#[allow(unsafe_code)]
|
||||
unsafe fn to_jsval(&self,
|
||||
cx: *mut ::js::jsapi::JSContext,
|
||||
rval: ::js::jsapi::MutableHandleValue) {
|
||||
rval: ::js::rust::MutableHandleValue) {
|
||||
let object = ::dom::bindings::reflector::DomObject::reflector(self).get_jsobject();
|
||||
object.to_jsval(cx, rval)
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ app_units = "0.6"
|
|||
cssparser = "0.23.0"
|
||||
euclid = "0.17"
|
||||
hashglobe = { path = "../hashglobe" }
|
||||
mozjs = { version = "0.5.0", features = ["promises"], optional = true }
|
||||
mozjs = { version = "0.6", features = ["promises"], optional = true }
|
||||
selectors = { path = "../selectors" }
|
||||
serde_bytes = { version = "0.10", optional = true }
|
||||
servo_arc = { path = "../servo_arc" }
|
||||
|
|
|
@ -63,7 +63,7 @@ metrics = {path = "../metrics"}
|
|||
mitochondria = "1.1.2"
|
||||
mime = "0.2.1"
|
||||
mime_guess = "1.8.0"
|
||||
mozjs = { version = "0.5.0", features = ["promises"]}
|
||||
mozjs = { version = "0.6", features = ["promises"]}
|
||||
msg = {path = "../msg"}
|
||||
net_traits = {path = "../net_traits"}
|
||||
num-traits = "0.1.32"
|
||||
|
|
|
@ -16,11 +16,11 @@ use js::jsapi::Heap;
|
|||
use js::jsapi::JSContext;
|
||||
use js::jsapi::JSObject;
|
||||
use js::jsapi::JS_ClearPendingException;
|
||||
use js::jsapi::JS_GetPendingException;
|
||||
use js::jsapi::JS_ParseJSON;
|
||||
use js::jsapi::Value as JSValue;
|
||||
use js::jsval::JSVal;
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::rust::wrappers::JS_GetPendingException;
|
||||
use js::rust::wrappers::JS_ParseJSON;
|
||||
use js::typedarray::{ArrayBuffer, CreateWith};
|
||||
use mime::{Mime, TopLevel, SubLevel};
|
||||
use std::cell::Ref;
|
||||
|
|
|
@ -22,8 +22,9 @@ use dom::globalscope::GlobalScope;
|
|||
use dom::node::{Node, window_from_node};
|
||||
use dom::window::Window;
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use js::jsapi::{JSAutoCompartment, ObjectClassName};
|
||||
use js::jsapi::JSAutoCompartment;
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::rust::wrappers::ObjectClassName;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use script_thread::Documents;
|
||||
use std::ffi::CStr;
|
||||
|
|
|
@ -10,13 +10,13 @@ use dom::bindings::root::{Dom, DomRoot};
|
|||
use dom::bindings::settings_stack::{AutoEntryScript, AutoIncumbentScript};
|
||||
use dom::bindings::utils::AsCCharPtrPtr;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use js::jsapi::{Heap, MutableHandleObject};
|
||||
use js::jsapi::{IsCallable, JSContext, JSObject, JS_WrapObject, AddRawValueRoot};
|
||||
use js::jsapi::{IsCallable, JSContext, JSObject, AddRawValueRoot};
|
||||
use js::jsapi::{JSCompartment, JS_EnterCompartment, JS_LeaveCompartment, RemoveRawValueRoot};
|
||||
use js::jsapi::Heap;
|
||||
use js::jsapi::JSAutoCompartment;
|
||||
use js::jsapi::JS_GetProperty;
|
||||
use js::jsval::{JSVal, UndefinedValue, ObjectValue};
|
||||
use js::rust::Runtime;
|
||||
use js::rust::{MutableHandleObject, Runtime};
|
||||
use js::rust::wrappers::{JS_WrapObject, JS_GetProperty};
|
||||
use std::default::Default;
|
||||
use std::ffi::CString;
|
||||
use std::mem::drop;
|
||||
|
@ -206,7 +206,7 @@ impl CallbackInterface {
|
|||
/// Wraps the reflector for `p` into the compartment of `cx`.
|
||||
pub fn wrap_call_this_object<T: DomObject>(cx: *mut JSContext,
|
||||
p: &T,
|
||||
rval: MutableHandleObject) {
|
||||
mut rval: MutableHandleObject) {
|
||||
rval.set(p.reflector().get_jsobject().get());
|
||||
assert!(!rval.get().is_null());
|
||||
|
||||
|
|
|
@ -2326,11 +2326,11 @@ def UnionTypes(descriptors, dictionaries, callbacks, typedefs, config):
|
|||
'dom::bindings::trace::RootedTraceableBox',
|
||||
'dom::types::*',
|
||||
'js::error::throw_type_error',
|
||||
'js::jsapi::HandleValue',
|
||||
'js::rust::HandleValue',
|
||||
'js::jsapi::Heap',
|
||||
'js::jsapi::JSContext',
|
||||
'js::jsapi::JSObject',
|
||||
'js::jsapi::MutableHandleValue',
|
||||
'js::rust::MutableHandleValue',
|
||||
'js::jsval::JSVal',
|
||||
'js::typedarray'
|
||||
]
|
||||
|
@ -2590,7 +2590,7 @@ def CopyUnforgeablePropertiesToInstance(descriptor):
|
|||
if descriptor.proxy:
|
||||
copyCode += """\
|
||||
rooted!(in(cx) let mut expando = ptr::null_mut::<JSObject>());
|
||||
ensure_expando_object(cx, obj.handle(), expando.handle_mut());
|
||||
ensure_expando_object(cx, obj.handle().into(), expando.handle_mut());
|
||||
"""
|
||||
obj = "expando"
|
||||
else:
|
||||
|
@ -2887,13 +2887,13 @@ assert!(!prototype_proto.is_null());""" % getPrototypeProto)]
|
|||
code.append(CGGeneric("""
|
||||
rooted!(in(cx) let mut prototype = ptr::null_mut::<JSObject>());
|
||||
create_interface_prototype_object(cx,
|
||||
prototype_proto.handle(),
|
||||
prototype_proto.handle().into(),
|
||||
&PrototypeClass,
|
||||
%(methods)s,
|
||||
%(attrs)s,
|
||||
%(consts)s,
|
||||
%(unscopables)s,
|
||||
prototype.handle_mut());
|
||||
prototype.handle_mut().into());
|
||||
assert!(!prototype.is_null());
|
||||
assert!((*cache)[PrototypeList::ID::%(id)s as usize].is_null());
|
||||
(*cache)[PrototypeList::ID::%(id)s as usize] = prototype.get();
|
||||
|
@ -2922,7 +2922,7 @@ assert!(!interface_proto.is_null());
|
|||
|
||||
rooted!(in(cx) let mut interface = ptr::null_mut::<JSObject>());
|
||||
create_noncallback_interface_object(cx,
|
||||
global,
|
||||
global.into(),
|
||||
interface_proto.handle(),
|
||||
&INTERFACE_OBJECT_CLASS,
|
||||
%(static_methods)s,
|
||||
|
@ -3044,7 +3044,7 @@ class CGGetPerInterfaceObject(CGAbstractMethod):
|
|||
def __init__(self, descriptor, name, idPrefix="", pub=False):
|
||||
args = [Argument('*mut JSContext', 'cx'),
|
||||
Argument('HandleObject', 'global'),
|
||||
Argument('MutableHandleObject', 'rval')]
|
||||
Argument('MutableHandleObject', 'mut rval')]
|
||||
CGAbstractMethod.__init__(self, descriptor, name,
|
||||
'void', args, pub=pub, unsafe=True)
|
||||
self.id = idPrefix + "::" + MakeNativeName(self.descriptor.name)
|
||||
|
@ -4080,7 +4080,8 @@ pub enum %s {
|
|||
|
||||
inner = string.Template("""\
|
||||
use dom::bindings::conversions::ToJSValConvertible;
|
||||
use js::jsapi::{JSContext, MutableHandleValue};
|
||||
use js::jsapi::JSContext;
|
||||
use js::rust::MutableHandleValue;
|
||||
use js::jsval::JSVal;
|
||||
|
||||
pub const pairs: &'static [(&'static str, super::${ident})] = &[
|
||||
|
@ -4856,7 +4857,7 @@ class CGProxyNamedOperation(CGProxySpecialOperation):
|
|||
def define(self):
|
||||
# Our first argument is the id we're getting.
|
||||
argName = self.arguments[0].identifier.name
|
||||
return ("let %s = jsid_to_string(cx, id).expect(\"Not a string-convertible JSID?\");\n"
|
||||
return ("let %s = jsid_to_string(cx, Handle::from_raw(id)).expect(\"Not a string-convertible JSID?\");\n"
|
||||
"let this = UnwrapProxy(proxy);\n"
|
||||
"let this = &*this;\n" % argName +
|
||||
CGProxySpecialOperation.define(self))
|
||||
|
@ -4899,7 +4900,7 @@ class CGProxyNamedDeleter(CGProxyNamedOperation):
|
|||
|
||||
class CGProxyUnwrap(CGAbstractMethod):
|
||||
def __init__(self, descriptor):
|
||||
args = [Argument('HandleObject', 'obj')]
|
||||
args = [Argument('RawHandleObject', 'obj')]
|
||||
CGAbstractMethod.__init__(self, descriptor, "UnwrapProxy",
|
||||
'*const ' + descriptor.concreteType, args,
|
||||
alwaysInline=True, unsafe=True)
|
||||
|
@ -4916,9 +4917,9 @@ return box_;""" % self.descriptor.concreteType)
|
|||
|
||||
class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
||||
def __init__(self, descriptor):
|
||||
args = [Argument('*mut JSContext', 'cx'), Argument('HandleObject', 'proxy'),
|
||||
Argument('HandleId', 'id'),
|
||||
Argument('MutableHandle<PropertyDescriptor>', 'desc')]
|
||||
args = [Argument('*mut JSContext', 'cx'), Argument('RawHandleObject', 'proxy'),
|
||||
Argument('RawHandleId', 'id'),
|
||||
Argument('RawMutableHandle<PropertyDescriptor>', 'desc')]
|
||||
CGAbstractExternMethod.__init__(self, descriptor, "getOwnPropertyDescriptor",
|
||||
"bool", args)
|
||||
self.descriptor = descriptor
|
||||
|
@ -4929,14 +4930,14 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
|||
|
||||
get = ""
|
||||
if indexedGetter:
|
||||
get = "let index = get_array_index_from_id(cx, id);\n"
|
||||
get = "let index = get_array_index_from_id(cx, Handle::from_raw(id));\n"
|
||||
|
||||
attrs = "JSPROP_ENUMERATE"
|
||||
if self.descriptor.operations['IndexedSetter'] is None:
|
||||
attrs += " | JSPROP_READONLY"
|
||||
# FIXME(#11868) Should assign to desc.value, desc.get() is a copy.
|
||||
fillDescriptor = ("desc.get().value = result_root.get();\n"
|
||||
"fill_property_descriptor(desc, proxy.get(), %s);\n"
|
||||
"fill_property_descriptor(MutableHandle::from_raw(desc), proxy.get(), %s);\n"
|
||||
"return true;" % attrs)
|
||||
templateValues = {
|
||||
'jsvalRef': 'result_root.handle_mut()',
|
||||
|
@ -4962,7 +4963,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
|||
attrs = "0"
|
||||
# FIXME(#11868) Should assign to desc.value, desc.get() is a copy.
|
||||
fillDescriptor = ("desc.get().value = result_root.get();\n"
|
||||
"fill_property_descriptor(desc, proxy.get(), %s);\n"
|
||||
"fill_property_descriptor(MutableHandle::from_raw(desc), proxy.get(), %s);\n"
|
||||
"return true;" % attrs)
|
||||
templateValues = {
|
||||
'jsvalRef': 'result_root.handle_mut()',
|
||||
|
@ -4980,7 +4981,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
|||
namedGet = """
|
||||
if %s {
|
||||
let mut has_on_proto = false;
|
||||
if !has_property_on_prototype(cx, proxy, id, &mut has_on_proto) {
|
||||
if !has_property_on_prototype(cx, proxy_lt, id_lt, &mut has_on_proto) {
|
||||
return false;
|
||||
}
|
||||
if !has_on_proto {
|
||||
|
@ -4996,8 +4997,10 @@ if %s {
|
|||
rooted!(in(cx) let mut expando = ptr::null_mut::<JSObject>());
|
||||
get_expando_object(proxy, expando.handle_mut());
|
||||
//if (!xpc::WrapperFactory::IsXrayWrapper(proxy) && (expando = GetExpandoObject(proxy))) {
|
||||
let proxy_lt = Handle::from_raw(proxy);
|
||||
let id_lt = Handle::from_raw(id);
|
||||
if !expando.is_null() {
|
||||
if !JS_GetPropertyDescriptorById(cx, expando.handle(), id, desc) {
|
||||
if !JS_GetPropertyDescriptorById(cx, expando.handle().into(), id, desc) {
|
||||
return false;
|
||||
}
|
||||
if !desc.obj.is_null() {
|
||||
|
@ -5016,9 +5019,9 @@ return true;"""
|
|||
|
||||
class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
|
||||
def __init__(self, descriptor):
|
||||
args = [Argument('*mut JSContext', 'cx'), Argument('HandleObject', 'proxy'),
|
||||
Argument('HandleId', 'id'),
|
||||
Argument('Handle<PropertyDescriptor>', 'desc'),
|
||||
args = [Argument('*mut JSContext', 'cx'), Argument('RawHandleObject', 'proxy'),
|
||||
Argument('RawHandleId', 'id'),
|
||||
Argument('RawHandle<PropertyDescriptor>', 'desc'),
|
||||
Argument('*mut ObjectOpResult', 'opresult')]
|
||||
CGAbstractExternMethod.__init__(self, descriptor, "defineProperty", "bool", args)
|
||||
self.descriptor = descriptor
|
||||
|
@ -5028,7 +5031,7 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
|
|||
|
||||
indexedSetter = self.descriptor.operations['IndexedSetter']
|
||||
if indexedSetter:
|
||||
set += ("let index = get_array_index_from_id(cx, id);\n" +
|
||||
set += ("let index = get_array_index_from_id(cx, Handle::from_raw(id));\n" +
|
||||
"if let Some(index) = index {\n" +
|
||||
" let this = UnwrapProxy(proxy);\n" +
|
||||
" let this = &*this;\n" +
|
||||
|
@ -5036,7 +5039,7 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
|
|||
" return (*opresult).succeed();\n" +
|
||||
"}\n")
|
||||
elif self.descriptor.operations['IndexedGetter']:
|
||||
set += ("if get_array_index_from_id(cx, id).is_some() {\n" +
|
||||
set += ("if get_array_index_from_id(cx, Handle::from_raw(id)).is_some() {\n" +
|
||||
" return (*opresult).failNoIndexedSetter();\n" +
|
||||
"}\n")
|
||||
|
||||
|
@ -5065,8 +5068,8 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
|
|||
|
||||
class CGDOMJSProxyHandler_delete(CGAbstractExternMethod):
|
||||
def __init__(self, descriptor):
|
||||
args = [Argument('*mut JSContext', 'cx'), Argument('HandleObject', 'proxy'),
|
||||
Argument('HandleId', 'id'),
|
||||
args = [Argument('*mut JSContext', 'cx'), Argument('RawHandleObject', 'proxy'),
|
||||
Argument('RawHandleId', 'id'),
|
||||
Argument('*mut ObjectOpResult', 'res')]
|
||||
CGAbstractExternMethod.__init__(self, descriptor, "delete", "bool", args)
|
||||
self.descriptor = descriptor
|
||||
|
@ -5088,7 +5091,7 @@ class CGDOMJSProxyHandler_delete(CGAbstractExternMethod):
|
|||
class CGDOMJSProxyHandler_ownPropertyKeys(CGAbstractExternMethod):
|
||||
def __init__(self, descriptor):
|
||||
args = [Argument('*mut JSContext', 'cx'),
|
||||
Argument('HandleObject', 'proxy'),
|
||||
Argument('RawHandleObject', 'proxy'),
|
||||
Argument('*mut AutoIdVector', 'props')]
|
||||
CGAbstractExternMethod.__init__(self, descriptor, "own_property_keys", "bool", args)
|
||||
self.descriptor = descriptor
|
||||
|
@ -5143,7 +5146,7 @@ class CGDOMJSProxyHandler_getOwnEnumerablePropertyKeys(CGAbstractExternMethod):
|
|||
assert (descriptor.operations["IndexedGetter"] and
|
||||
descriptor.interface.getExtendedAttribute("LegacyUnenumerableNamedProperties"))
|
||||
args = [Argument('*mut JSContext', 'cx'),
|
||||
Argument('HandleObject', 'proxy'),
|
||||
Argument('RawHandleObject', 'proxy'),
|
||||
Argument('*mut AutoIdVector', 'props')]
|
||||
CGAbstractExternMethod.__init__(self, descriptor,
|
||||
"getOwnEnumerablePropertyKeys", "bool", args)
|
||||
|
@ -5183,15 +5186,15 @@ class CGDOMJSProxyHandler_getOwnEnumerablePropertyKeys(CGAbstractExternMethod):
|
|||
|
||||
class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod):
|
||||
def __init__(self, descriptor):
|
||||
args = [Argument('*mut JSContext', 'cx'), Argument('HandleObject', 'proxy'),
|
||||
Argument('HandleId', 'id'), Argument('*mut bool', 'bp')]
|
||||
args = [Argument('*mut JSContext', 'cx'), Argument('RawHandleObject', 'proxy'),
|
||||
Argument('RawHandleId', 'id'), Argument('*mut bool', 'bp')]
|
||||
CGAbstractExternMethod.__init__(self, descriptor, "hasOwn", "bool", args)
|
||||
self.descriptor = descriptor
|
||||
|
||||
def getBody(self):
|
||||
indexedGetter = self.descriptor.operations['IndexedGetter']
|
||||
if indexedGetter:
|
||||
indexed = ("let index = get_array_index_from_id(cx, id);\n" +
|
||||
indexed = ("let index = get_array_index_from_id(cx, Handle::from_raw(id));\n" +
|
||||
"if let Some(index) = index {\n" +
|
||||
" let this = UnwrapProxy(proxy);\n" +
|
||||
" let this = &*this;\n" +
|
||||
|
@ -5210,7 +5213,7 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod):
|
|||
named = """\
|
||||
if %s {
|
||||
let mut has_on_proto = false;
|
||||
if !has_property_on_prototype(cx, proxy, id, &mut has_on_proto) {
|
||||
if !has_property_on_prototype(cx, proxy_lt, id_lt, &mut has_on_proto) {
|
||||
return false;
|
||||
}
|
||||
if !has_on_proto {
|
||||
|
@ -5226,9 +5229,11 @@ if %s {
|
|||
|
||||
return indexed + """\
|
||||
rooted!(in(cx) let mut expando = ptr::null_mut::<JSObject>());
|
||||
let proxy_lt = Handle::from_raw(proxy);
|
||||
let id_lt = Handle::from_raw(id);
|
||||
get_expando_object(proxy, expando.handle_mut());
|
||||
if !expando.is_null() {
|
||||
let ok = JS_HasPropertyById(cx, expando.handle(), id, bp);
|
||||
let ok = JS_HasPropertyById(cx, expando.handle().into(), id, bp);
|
||||
if !ok || *bp {
|
||||
return ok;
|
||||
}
|
||||
|
@ -5243,9 +5248,9 @@ return true;"""
|
|||
|
||||
class CGDOMJSProxyHandler_get(CGAbstractExternMethod):
|
||||
def __init__(self, descriptor):
|
||||
args = [Argument('*mut JSContext', 'cx'), Argument('HandleObject', 'proxy'),
|
||||
Argument('HandleValue', 'receiver'), Argument('HandleId', 'id'),
|
||||
Argument('MutableHandleValue', 'vp')]
|
||||
args = [Argument('*mut JSContext', 'cx'), Argument('RawHandleObject', 'proxy'),
|
||||
Argument('RawHandleValue', 'receiver'), Argument('RawHandleId', 'id'),
|
||||
Argument('RawMutableHandleValue', 'vp')]
|
||||
CGAbstractExternMethod.__init__(self, descriptor, "get", "bool", args)
|
||||
self.descriptor = descriptor
|
||||
|
||||
|
@ -5256,23 +5261,23 @@ rooted!(in(cx) let mut expando = ptr::null_mut::<JSObject>());
|
|||
get_expando_object(proxy, expando.handle_mut());
|
||||
if !expando.is_null() {
|
||||
let mut hasProp = false;
|
||||
if !JS_HasPropertyById(cx, expando.handle(), id, &mut hasProp) {
|
||||
if !JS_HasPropertyById(cx, expando.handle().into(), id, &mut hasProp) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if hasProp {
|
||||
return JS_ForwardGetPropertyTo(cx, expando.handle(), id, receiver, vp);
|
||||
return JS_ForwardGetPropertyTo(cx, expando.handle().into(), id, receiver, vp);
|
||||
}
|
||||
}"""
|
||||
|
||||
templateValues = {
|
||||
'jsvalRef': 'vp',
|
||||
'jsvalRef': 'vp_lt',
|
||||
'successCode': 'return true;',
|
||||
}
|
||||
|
||||
indexedGetter = self.descriptor.operations['IndexedGetter']
|
||||
if indexedGetter:
|
||||
getIndexedOrExpando = ("let index = get_array_index_from_id(cx, id);\n" +
|
||||
getIndexedOrExpando = ("let index = get_array_index_from_id(cx, id_lt);\n" +
|
||||
"if let Some(index) = index {\n" +
|
||||
" let this = UnwrapProxy(proxy);\n" +
|
||||
" let this = &*this;\n" +
|
||||
|
@ -5305,10 +5310,14 @@ if !expando.is_null() {
|
|||
return """\
|
||||
//MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
|
||||
//"Should not have a XrayWrapper here");
|
||||
let proxy_lt = Handle::from_raw(proxy);
|
||||
let vp_lt = MutableHandle::from_raw(vp);
|
||||
let id_lt = Handle::from_raw(id);
|
||||
let receiver_lt = Handle::from_raw(receiver);
|
||||
|
||||
%s
|
||||
let mut found = false;
|
||||
if !get_property_on_prototype(cx, proxy, receiver, id, &mut found, vp) {
|
||||
if !get_property_on_prototype(cx, proxy_lt, receiver_lt, id_lt, &mut found, vp_lt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -5325,7 +5334,7 @@ return true;""" % (getIndexedOrExpando, getNamed)
|
|||
|
||||
class CGDOMJSProxyHandler_className(CGAbstractExternMethod):
|
||||
def __init__(self, descriptor):
|
||||
args = [Argument('*mut JSContext', 'cx'), Argument('HandleObject', '_proxy')]
|
||||
args = [Argument('*mut JSContext', 'cx'), Argument('RawHandleObject', '_proxy')]
|
||||
CGAbstractExternMethod.__init__(self, descriptor, "className", "*const i8", args, doesNotPanic=True)
|
||||
self.descriptor = descriptor
|
||||
|
||||
|
@ -5660,16 +5669,20 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
|
|||
'js::error::throw_type_error',
|
||||
'js::error::throw_internal_error',
|
||||
'js::jsapi::AutoIdVector',
|
||||
'js::jsapi::Call',
|
||||
'js::rust::wrappers::Call',
|
||||
'js::jsapi::CallArgs',
|
||||
'js::jsapi::CurrentGlobalOrNull',
|
||||
'js::jsapi::FreeOp',
|
||||
'js::jsapi::GetPropertyKeys',
|
||||
'js::rust::wrappers::GetPropertyKeys',
|
||||
'js::jsapi::GetWellKnownSymbol',
|
||||
'js::jsapi::Handle',
|
||||
'js::jsapi::HandleId',
|
||||
'js::jsapi::HandleObject',
|
||||
'js::jsapi::HandleValue',
|
||||
'js::rust::Handle',
|
||||
'js::jsapi::Handle as RawHandle',
|
||||
'js::rust::HandleId',
|
||||
'js::jsapi::HandleId as RawHandleId',
|
||||
'js::rust::HandleObject',
|
||||
'js::jsapi::HandleObject as RawHandleObject',
|
||||
'js::rust::HandleValue',
|
||||
'js::jsapi::HandleValue as RawHandleValue',
|
||||
'js::jsapi::HandleValueArray',
|
||||
'js::jsapi::Heap',
|
||||
'js::jsapi::INTERNED_STRING_TO_JSID',
|
||||
|
@ -5704,37 +5717,40 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
|
|||
'js::jsapi::JSTypedMethodJitInfo',
|
||||
'js::jsapi::JSValueType',
|
||||
'js::jsapi::JS_AtomizeAndPinString',
|
||||
'js::jsapi::JS_CallFunctionValue',
|
||||
'js::jsapi::JS_CopyPropertiesFrom',
|
||||
'js::jsapi::JS_DefineProperty',
|
||||
'js::jsapi::JS_DefinePropertyById2',
|
||||
'js::rust::wrappers::JS_CallFunctionValue',
|
||||
'js::rust::wrappers::JS_CopyPropertiesFrom',
|
||||
'js::rust::wrappers::JS_DefineProperty',
|
||||
'js::rust::wrappers::JS_DefinePropertyById2',
|
||||
'js::jsapi::JS_ForwardGetPropertyTo',
|
||||
'js::jsapi::JS_GetErrorPrototype',
|
||||
'js::jsapi::JS_GetFunctionPrototype',
|
||||
'js::rust::wrappers::JS_GetFunctionPrototype',
|
||||
'js::jsapi::JS_GetGlobalForObject',
|
||||
'js::jsapi::JS_GetIteratorPrototype',
|
||||
'js::jsapi::JS_GetObjectPrototype',
|
||||
'js::jsapi::JS_GetProperty',
|
||||
'js::rust::wrappers::JS_GetObjectPrototype',
|
||||
'js::rust::wrappers::JS_GetProperty',
|
||||
'js::jsapi::JS_GetPropertyById',
|
||||
'js::jsapi::JS_GetPropertyDescriptorById',
|
||||
'js::jsapi::JS_GetReservedSlot',
|
||||
'js::jsapi::JS_HasProperty',
|
||||
'js::jsapi::JS_HasPropertyById',
|
||||
'js::jsapi::JS_InitializePropertiesFromCompatibleNativeObject',
|
||||
'js::rust::wrappers::JS_InitializePropertiesFromCompatibleNativeObject',
|
||||
'js::jsapi::JS_NewObject',
|
||||
'js::jsapi::JS_NewObjectWithGivenProto',
|
||||
'js::jsapi::JS_NewObjectWithoutMetadata',
|
||||
'js::jsapi::JS_ObjectIsDate',
|
||||
'js::jsapi::JS_SetImmutablePrototype',
|
||||
'js::jsapi::JS_SetProperty',
|
||||
'js::jsapi::JS_SetPrototype',
|
||||
'js::rust::wrappers::JS_NewObjectWithGivenProto',
|
||||
'js::rust::wrappers::JS_NewObjectWithoutMetadata',
|
||||
'js::rust::wrappers::JS_ObjectIsDate',
|
||||
'js::rust::wrappers::JS_SetImmutablePrototype',
|
||||
'js::rust::wrappers::JS_SetProperty',
|
||||
'js::rust::wrappers::JS_SetPrototype',
|
||||
'js::jsapi::JS_SetReservedSlot',
|
||||
'js::jsapi::JS_SplicePrototype',
|
||||
'js::jsapi::JS_WrapValue',
|
||||
'js::jsapi::JS_WrapObject',
|
||||
'js::jsapi::MutableHandle',
|
||||
'js::jsapi::MutableHandleObject',
|
||||
'js::jsapi::MutableHandleValue',
|
||||
'js::rust::wrappers::JS_SplicePrototype',
|
||||
'js::rust::wrappers::JS_WrapValue',
|
||||
'js::rust::wrappers::JS_WrapObject',
|
||||
'js::rust::MutableHandle',
|
||||
'js::jsapi::MutableHandle as RawMutableHandle',
|
||||
'js::rust::MutableHandleObject',
|
||||
'js::jsapi::MutableHandleObject as RawMutableHandleObject',
|
||||
'js::rust::MutableHandleValue',
|
||||
'js::jsapi::MutableHandleValue as RawMutableHandleValue',
|
||||
'js::jsapi::ObjectOpResult',
|
||||
'js::jsapi::PropertyDescriptor',
|
||||
'js::jsapi::Rooted',
|
||||
|
@ -5755,7 +5771,7 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
|
|||
'js::glue::CallJitSetterOp',
|
||||
'js::glue::CreateProxyHandler',
|
||||
'js::glue::GetProxyPrivate',
|
||||
'js::glue::NewProxyObject',
|
||||
'js::rust::wrappers::NewProxyObject',
|
||||
'js::glue::ProxyTraps',
|
||||
'js::glue::RUST_JSID_IS_INT',
|
||||
'js::glue::RUST_JSID_IS_STRING',
|
||||
|
@ -6241,7 +6257,7 @@ class CGDictionary(CGThing):
|
|||
"}\n"
|
||||
"\n"
|
||||
"impl ToJSValConvertible for ${selfName} {\n"
|
||||
" unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {\n"
|
||||
" unsafe fn to_jsval(&self, cx: *mut JSContext, mut rval: MutableHandleValue) {\n"
|
||||
" rooted!(in(cx) let obj = JS_NewObject(cx, ptr::null()));\n"
|
||||
"${insertMembers}"
|
||||
" rval.set(ObjectOrNullValue(obj.get()))\n"
|
||||
|
@ -7132,7 +7148,8 @@ class GlobalGenRoots():
|
|||
def InterfaceObjectMap(config):
|
||||
mods = [
|
||||
"dom::bindings::codegen",
|
||||
"js::jsapi::{HandleObject, JSContext}",
|
||||
"js::jsapi::JSContext",
|
||||
"js::rust::HandleObject",
|
||||
"phf",
|
||||
]
|
||||
imports = CGList([CGGeneric("use %s;" % mod) for mod in mods], "\n")
|
||||
|
@ -7166,7 +7183,7 @@ class GlobalGenRoots():
|
|||
pairs.append((ctor.identifier.name, binding, binding))
|
||||
pairs.sort(key=operator.itemgetter(0))
|
||||
mappings = [
|
||||
CGGeneric('"%s": "codegen::Bindings::%s::%s::DefineDOMInterface as unsafe fn(_, _)"' % pair)
|
||||
CGGeneric('"%s": "codegen::Bindings::%s::%s::DefineDOMInterface"' % pair)
|
||||
for pair in pairs
|
||||
]
|
||||
return CGWrapper(
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
|
||||
//! WebIDL constants.
|
||||
|
||||
use js::jsapi::{HandleObject, JSContext, JSPROP_ENUMERATE, JSPROP_PERMANENT};
|
||||
use js::jsapi::{JSPROP_READONLY, JS_DefineProperty};
|
||||
use js::jsapi::{JSContext, JSPROP_ENUMERATE, JSPROP_PERMANENT};
|
||||
use js::jsapi::JSPROP_READONLY;
|
||||
use js::jsval::{BooleanValue, DoubleValue, Int32Value, JSVal, NullValue, UInt32Value};
|
||||
use js::rust::HandleObject;
|
||||
use js::rust::wrappers::JS_DefineProperty;
|
||||
use libc;
|
||||
|
||||
/// Representation of an IDL constant.
|
||||
|
|
|
@ -41,19 +41,21 @@ use dom::bindings::str::{ByteString, DOMString, USVString};
|
|||
use dom::bindings::trace::{JSTraceable, RootedTraceableBox};
|
||||
use dom::bindings::utils::DOMClass;
|
||||
use js;
|
||||
pub use js::conversions::{FromJSValConvertible, ToJSValConvertible, ConversionResult};
|
||||
pub use js::conversions::{ConversionResult, FromJSValConvertible, ToJSValConvertible};
|
||||
pub use js::conversions::ConversionBehavior;
|
||||
use js::conversions::latin1_to_string;
|
||||
use js::error::throw_type_error;
|
||||
use js::glue::{GetProxyPrivate, IsWrapper};
|
||||
use js::glue::{RUST_JSID_IS_INT, RUST_JSID_TO_INT};
|
||||
use js::glue::{RUST_JSID_IS_STRING, RUST_JSID_TO_STRING, UnwrapObject};
|
||||
use js::jsapi::{HandleId, HandleObject, HandleValue, Heap, JSContext, JSObject, JSString};
|
||||
use js::jsapi::{JS_GetLatin1StringCharsAndLength, JS_GetProperty, JS_GetReservedSlot};
|
||||
use js::jsapi::{JS_GetTwoByteStringCharsAndLength, JS_IsArrayObject, JS_IsExceptionPending};
|
||||
use js::jsapi::{JS_NewStringCopyN, JS_StringHasLatin1Chars, MutableHandleValue};
|
||||
use js::glue::{UnwrapObject, RUST_JSID_IS_STRING, RUST_JSID_TO_STRING};
|
||||
use js::jsapi::{Heap, JSContext, JSObject, JSString};
|
||||
use js::jsapi::{JS_GetLatin1StringCharsAndLength, JS_GetReservedSlot};
|
||||
use js::jsapi::{JS_GetTwoByteStringCharsAndLength, JS_IsExceptionPending};
|
||||
use js::jsapi::{JS_NewStringCopyN, JS_StringHasLatin1Chars};
|
||||
use js::jsval::{ObjectValue, StringValue, UndefinedValue};
|
||||
use js::rust::{ToString, get_object_class, is_dom_class, is_dom_object, maybe_wrap_value};
|
||||
use js::rust::{HandleId, HandleObject, HandleValue, MutableHandleValue};
|
||||
use js::rust::{get_object_class, is_dom_class, is_dom_object, maybe_wrap_value, ToString};
|
||||
use js::rust::wrappers::{JS_GetProperty, JS_IsArrayObject};
|
||||
use libc;
|
||||
use num_traits::Float;
|
||||
use servo_config::opts;
|
||||
|
@ -149,12 +151,13 @@ impl<T> FromJSValConvertible for RootedTraceableBox<Heap<T>>
|
|||
///
|
||||
/// Handling of invalid UTF-16 in strings depends on the relevant option.
|
||||
pub unsafe fn jsid_to_string(cx: *mut JSContext, id: HandleId) -> Option<DOMString> {
|
||||
if RUST_JSID_IS_STRING(id) {
|
||||
return Some(jsstring_to_str(cx, RUST_JSID_TO_STRING(id)));
|
||||
let id_raw = id.into();
|
||||
if RUST_JSID_IS_STRING(id_raw) {
|
||||
return Some(jsstring_to_str(cx, RUST_JSID_TO_STRING(id_raw)));
|
||||
}
|
||||
|
||||
if RUST_JSID_IS_INT(id) {
|
||||
return Some(RUST_JSID_TO_INT(id).to_string().into());
|
||||
if RUST_JSID_IS_INT(id_raw) {
|
||||
return Some(RUST_JSID_TO_INT(id_raw).to_string().into());
|
||||
}
|
||||
|
||||
None
|
||||
|
@ -269,7 +272,7 @@ impl FromJSValConvertible for USVString {
|
|||
|
||||
// http://heycam.github.io/webidl/#es-ByteString
|
||||
impl ToJSValConvertible for ByteString {
|
||||
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
|
||||
unsafe fn to_jsval(&self, cx: *mut JSContext, mut rval: MutableHandleValue) {
|
||||
let jsstr = JS_NewStringCopyN(cx,
|
||||
self.as_ptr() as *const libc::c_char,
|
||||
self.len() as libc::size_t);
|
||||
|
@ -319,7 +322,7 @@ impl FromJSValConvertible for ByteString {
|
|||
|
||||
|
||||
impl ToJSValConvertible for Reflector {
|
||||
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
|
||||
unsafe fn to_jsval(&self, cx: *mut JSContext, mut rval: MutableHandleValue) {
|
||||
let obj = self.get_jsobject().get();
|
||||
assert!(!obj.is_null());
|
||||
rval.set(ObjectValue(obj));
|
||||
|
@ -485,7 +488,7 @@ pub unsafe fn is_array_like(cx: *mut JSContext, value: HandleValue) -> bool {
|
|||
pub unsafe fn get_property_jsval(cx: *mut JSContext,
|
||||
object: HandleObject,
|
||||
name: &str,
|
||||
rval: MutableHandleValue)
|
||||
mut rval: MutableHandleValue)
|
||||
-> Fallible<()>
|
||||
{
|
||||
rval.set(UndefinedValue());
|
||||
|
|
|
@ -12,15 +12,15 @@ use dom::bindings::str::USVString;
|
|||
use dom::domexception::{DOMErrorName, DOMException};
|
||||
use dom::globalscope::GlobalScope;
|
||||
use js::error::{throw_range_error, throw_type_error};
|
||||
use js::jsapi::HandleObject;
|
||||
use js::jsapi::JSContext;
|
||||
use js::jsapi::JS_ClearPendingException;
|
||||
use js::jsapi::JS_ErrorFromException;
|
||||
use js::jsapi::JS_GetPendingException;
|
||||
use js::jsapi::JS_IsExceptionPending;
|
||||
use js::jsapi::JS_SetPendingException;
|
||||
use js::jsapi::MutableHandleValue;
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::rust::HandleObject;
|
||||
use js::rust::MutableHandleValue;
|
||||
use js::rust::wrappers::JS_ErrorFromException;
|
||||
use js::rust::wrappers::JS_GetPendingException;
|
||||
use js::rust::wrappers::JS_SetPendingException;
|
||||
use libc::c_uint;
|
||||
use std::slice::from_raw_parts;
|
||||
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
|
||||
//! Machinery to conditionally expose things.
|
||||
|
||||
use js::jsapi::{HandleObject, JSContext};
|
||||
use js::jsapi::JSContext;
|
||||
use js::rust::HandleObject;
|
||||
use servo_config::prefs::PREFS;
|
||||
|
||||
/// A container with a condition.
|
||||
|
|
|
@ -82,8 +82,8 @@ use html5ever::interface::QualName;
|
|||
use js::glue::UnwrapObject;
|
||||
use js::jsapi::{CallArgs, CurrentGlobalOrNull};
|
||||
use js::jsapi::{JSAutoCompartment, JSContext, JSObject};
|
||||
use js::jsapi::HandleObject;
|
||||
use js::jsapi::MutableHandleObject;
|
||||
use js::rust::HandleObject;
|
||||
use js::rust::MutableHandleObject;
|
||||
use script_thread::ScriptThread;
|
||||
use std::ptr;
|
||||
|
||||
|
|
|
@ -6,27 +6,31 @@
|
|||
|
||||
use dom::bindings::codegen::InterfaceObjectMap::Globals;
|
||||
use dom::bindings::codegen::PrototypeList;
|
||||
use dom::bindings::constant::{ConstantSpec, define_constants};
|
||||
use dom::bindings::conversions::{DOM_OBJECT_SLOT, get_dom_class};
|
||||
use dom::bindings::constant::{define_constants, ConstantSpec};
|
||||
use dom::bindings::conversions::{get_dom_class, DOM_OBJECT_SLOT};
|
||||
use dom::bindings::guard::Guard;
|
||||
use dom::bindings::utils::{DOM_PROTOTYPE_SLOT, ProtoOrIfaceArray, get_proto_or_iface_array};
|
||||
use dom::bindings::utils::{get_proto_or_iface_array, ProtoOrIfaceArray, DOM_PROTOTYPE_SLOT};
|
||||
use js::error::throw_type_error;
|
||||
use js::glue::{RUST_SYMBOL_TO_JSID, UncheckedUnwrapObject};
|
||||
use js::glue::{UncheckedUnwrapObject, RUST_SYMBOL_TO_JSID};
|
||||
use js::jsapi::{Class, ClassOps, CompartmentOptions};
|
||||
use js::jsapi::{GetGlobalForObjectCrossCompartment, GetWellKnownSymbol, HandleObject, HandleValue};
|
||||
use js::jsapi::{JSAutoCompartment, JSClass, JSContext, JSFUN_CONSTRUCTOR, JSFunctionSpec, JSObject};
|
||||
use js::jsapi::{GetGlobalForObjectCrossCompartment, GetWellKnownSymbol};
|
||||
use js::jsapi::{JSAutoCompartment, JSClass, JSContext, JSFunctionSpec, JSObject, JSFUN_CONSTRUCTOR};
|
||||
use js::jsapi::{JSPROP_PERMANENT, JSPROP_READONLY, JSPROP_RESOLVING};
|
||||
use js::jsapi::{JSPropertySpec, JSString, JSTracer, JSVersion, JS_AtomizeAndPinString};
|
||||
use js::jsapi::{JS_DefineProperty, JS_DefineProperty1, JS_DefineProperty2};
|
||||
use js::jsapi::{JS_DefineProperty4, JS_DefinePropertyById3, JS_FireOnNewGlobalObject};
|
||||
use js::jsapi::{JS_GetFunctionObject, JS_GetPrototype};
|
||||
use js::jsapi::{JS_LinkConstructorAndPrototype, JS_NewFunction, JS_NewGlobalObject};
|
||||
use js::jsapi::{JS_NewObject, JS_NewObjectWithUniqueType, JS_NewPlainObject};
|
||||
use js::jsapi::{JS_NewStringCopyN, JS_SetReservedSlot, MutableHandleObject};
|
||||
use js::jsapi::{MutableHandleValue, ObjectOps, OnNewGlobalHookOption, SymbolCode};
|
||||
use js::jsapi::{JS_GetFunctionObject, JS_NewFunction, JS_NewGlobalObject};
|
||||
use js::jsapi::{JS_NewObject, JS_NewPlainObject};
|
||||
use js::jsapi::{JS_NewStringCopyN, JS_SetReservedSlot};
|
||||
use js::jsapi::{ObjectOps, OnNewGlobalHookOption, SymbolCode};
|
||||
use js::jsapi::{TrueHandleValue, Value};
|
||||
use js::jsapi::HandleObject as RawHandleObject;
|
||||
use js::jsapi::MutableHandleValue as RawMutableHandleValue;
|
||||
use js::jsval::{JSVal, PrivateValue};
|
||||
use js::rust::{HandleObject, HandleValue, MutableHandleObject};
|
||||
use js::rust::{define_methods, define_properties, get_object_class};
|
||||
use js::rust::wrappers::{JS_DefineProperty, JS_DefineProperty1, JS_DefineProperty2};
|
||||
use js::rust::wrappers::{JS_DefineProperty4, JS_DefinePropertyById3};
|
||||
use js::rust::wrappers::{JS_FireOnNewGlobalObject, JS_GetPrototype};
|
||||
use js::rust::wrappers::{JS_LinkConstructorAndPrototype, JS_NewObjectWithUniqueType};
|
||||
use libc;
|
||||
use std::ptr;
|
||||
|
||||
|
@ -130,7 +134,7 @@ pub unsafe fn create_global_object(
|
|||
class: &'static JSClass,
|
||||
private: *const libc::c_void,
|
||||
trace: TraceHook,
|
||||
rval: MutableHandleObject) {
|
||||
mut rval: MutableHandleObject) {
|
||||
assert!(rval.is_null());
|
||||
|
||||
let mut options = CompartmentOptions::default();
|
||||
|
@ -164,10 +168,10 @@ pub unsafe fn create_callback_interface_object(
|
|||
global: HandleObject,
|
||||
constants: &[Guard<&[ConstantSpec]>],
|
||||
name: &[u8],
|
||||
rval: MutableHandleObject) {
|
||||
mut rval: MutableHandleObject) {
|
||||
assert!(!constants.is_empty());
|
||||
rval.set(JS_NewObject(cx, ptr::null()));
|
||||
assert!(!rval.ptr.is_null());
|
||||
assert!(!rval.is_null());
|
||||
define_guarded_constants(cx, rval.handle(), constants);
|
||||
define_name(cx, rval.handle(), name);
|
||||
define_on_global_object(cx, global, name, rval.handle());
|
||||
|
@ -265,9 +269,9 @@ pub unsafe fn create_object(
|
|||
methods: &[Guard<&'static [JSFunctionSpec]>],
|
||||
properties: &[Guard<&'static [JSPropertySpec]>],
|
||||
constants: &[Guard<&[ConstantSpec]>],
|
||||
rval: MutableHandleObject) {
|
||||
mut rval: MutableHandleObject) {
|
||||
rval.set(JS_NewObjectWithUniqueType(cx, class, proto));
|
||||
assert!(!rval.ptr.is_null());
|
||||
assert!(!rval.is_null());
|
||||
define_guarded_methods(cx, rval.handle(), methods);
|
||||
define_guarded_properties(cx, rval.handle(), properties);
|
||||
define_guarded_constants(cx, rval.handle(), constants);
|
||||
|
@ -349,7 +353,7 @@ const OBJECT_OPS: ObjectOps = ObjectOps {
|
|||
};
|
||||
|
||||
unsafe extern "C" fn fun_to_string_hook(cx: *mut JSContext,
|
||||
obj: HandleObject,
|
||||
obj: RawHandleObject,
|
||||
_indent: u32)
|
||||
-> *mut JSString {
|
||||
let js_class = get_object_class(obj.get());
|
||||
|
@ -363,10 +367,12 @@ unsafe extern "C" fn fun_to_string_hook(cx: *mut JSContext,
|
|||
|
||||
/// Hook for instanceof on interface objects.
|
||||
unsafe extern "C" fn has_instance_hook(cx: *mut JSContext,
|
||||
obj: HandleObject,
|
||||
value: MutableHandleValue,
|
||||
obj: RawHandleObject,
|
||||
value: RawMutableHandleValue,
|
||||
rval: *mut bool) -> bool {
|
||||
match has_instance(cx, obj, value.handle()) {
|
||||
let obj_raw = HandleObject::from_raw(obj);
|
||||
let val_raw = HandleValue::from_raw(value.handle());
|
||||
match has_instance(cx, obj_raw, val_raw) {
|
||||
Ok(result) => {
|
||||
*rval = result;
|
||||
true
|
||||
|
@ -386,6 +392,8 @@ unsafe fn has_instance(
|
|||
// Step 1.
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
rooted!(in(cx) let mut value_out = value.to_object());
|
||||
rooted!(in(cx) let mut value = value.to_object());
|
||||
|
||||
let js_class = get_object_class(interface_object.get());
|
||||
|
@ -407,7 +415,8 @@ unsafe fn has_instance(
|
|||
assert!(!prototype.is_null());
|
||||
// Step 3 only concern legacy callback interface objects (i.e. NodeFilter).
|
||||
|
||||
while JS_GetPrototype(cx, value.handle(), value.handle_mut()) {
|
||||
while JS_GetPrototype(cx, value.handle(), value_out.handle_mut()) {
|
||||
*value = *value_out;
|
||||
if value.is_null() {
|
||||
// Step 5.2.
|
||||
return Ok(false);
|
||||
|
@ -423,16 +432,22 @@ unsafe fn has_instance(
|
|||
unsafe fn create_unscopable_object(
|
||||
cx: *mut JSContext,
|
||||
names: &[&[u8]],
|
||||
rval: MutableHandleObject) {
|
||||
mut rval: MutableHandleObject) {
|
||||
assert!(!names.is_empty());
|
||||
assert!(rval.is_null());
|
||||
rval.set(JS_NewPlainObject(cx));
|
||||
assert!(!rval.ptr.is_null());
|
||||
assert!(!rval.is_null());
|
||||
for &name in names {
|
||||
assert_eq!(*name.last().unwrap(), b'\0');
|
||||
assert!(JS_DefineProperty(
|
||||
cx, rval.handle(), name.as_ptr() as *const libc::c_char, TrueHandleValue,
|
||||
JSPROP_READONLY, None, None));
|
||||
cx,
|
||||
rval.handle(),
|
||||
name.as_ptr() as *const libc::c_char,
|
||||
HandleValue::from_raw(TrueHandleValue),
|
||||
JSPROP_READONLY,
|
||||
None,
|
||||
None
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -443,7 +458,7 @@ unsafe fn define_name(cx: *mut JSContext, obj: HandleObject, name: &[u8]) {
|
|||
assert!(JS_DefineProperty2(cx,
|
||||
obj,
|
||||
b"name\0".as_ptr() as *const libc::c_char,
|
||||
name.handle(),
|
||||
name.handle().into(),
|
||||
JSPROP_READONLY,
|
||||
None, None));
|
||||
}
|
||||
|
|
|
@ -15,8 +15,9 @@ use dom::bindings::trace::{JSTraceable, RootedTraceableBox};
|
|||
use dom::globalscope::GlobalScope;
|
||||
use dom_struct::dom_struct;
|
||||
use js::conversions::ToJSValConvertible;
|
||||
use js::jsapi::{HandleValue, Heap, JSContext, MutableHandleObject, JSObject};
|
||||
use js::jsapi::{Heap, JSContext, JSObject};
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::rust::{HandleValue, MutableHandleObject};
|
||||
use std::cell::Cell;
|
||||
use std::ptr;
|
||||
use std::ptr::NonNull;
|
||||
|
@ -111,7 +112,7 @@ impl<T: DomObject + JSTraceable + Iterable> IterableIterator<T> {
|
|||
}
|
||||
|
||||
fn dict_return(cx: *mut JSContext,
|
||||
result: MutableHandleObject,
|
||||
mut result: MutableHandleObject,
|
||||
done: bool,
|
||||
value: HandleValue) -> Fallible<()> {
|
||||
let mut dict = unsafe { IterableKeyOrValueResult::empty(cx) };
|
||||
|
@ -126,7 +127,7 @@ fn dict_return(cx: *mut JSContext,
|
|||
}
|
||||
|
||||
fn key_and_value_return(cx: *mut JSContext,
|
||||
result: MutableHandleObject,
|
||||
mut result: MutableHandleObject,
|
||||
key: HandleValue,
|
||||
value: HandleValue) -> Fallible<()> {
|
||||
let mut dict = unsafe { IterableKeyAndValueResult::empty(cx) };
|
||||
|
|
|
@ -6,19 +6,19 @@
|
|||
|
||||
use dom::bindings::conversions::jsid_to_string;
|
||||
use dom::bindings::str::DOMString;
|
||||
use js::conversions::{FromJSValConvertible, ToJSValConvertible, ConversionResult};
|
||||
use js::jsapi::GetPropertyKeys;
|
||||
use js::jsapi::HandleValue;
|
||||
use js::conversions::{ConversionResult, FromJSValConvertible, ToJSValConvertible};
|
||||
use js::jsapi::JSContext;
|
||||
use js::jsapi::JSITER_OWNONLY;
|
||||
use js::jsapi::JSPROP_ENUMERATE;
|
||||
use js::jsapi::JS_DefineUCProperty2;
|
||||
use js::jsapi::JS_GetPropertyById;
|
||||
use js::jsapi::JS_NewPlainObject;
|
||||
use js::jsapi::MutableHandleValue;
|
||||
use js::jsval::ObjectValue;
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::rust::HandleValue;
|
||||
use js::rust::IdVector;
|
||||
use js::rust::MutableHandleValue;
|
||||
use js::rust::wrappers::GetPropertyKeys;
|
||||
use js::rust::wrappers::JS_DefineUCProperty2;
|
||||
use js::rust::wrappers::JS_GetPropertyById;
|
||||
use std::collections::HashMap;
|
||||
use std::ops::Deref;
|
||||
|
||||
|
@ -86,7 +86,7 @@ impl<T, C> FromJSValConvertible for MozMap<T>
|
|||
|
||||
impl<T: ToJSValConvertible> ToJSValConvertible for MozMap<T> {
|
||||
#[inline]
|
||||
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
|
||||
unsafe fn to_jsval(&self, cx: *mut JSContext, mut rval: MutableHandleValue) {
|
||||
rooted!(in(cx) let js_object = JS_NewPlainObject(cx));
|
||||
assert!(!js_object.handle().is_null());
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
use dom::bindings::guard::Guard;
|
||||
use dom::bindings::interface::{create_object, define_on_global_object};
|
||||
use js::jsapi::{HandleObject, JSClass, JSContext, JSFunctionSpec, MutableHandleObject};
|
||||
use js::jsapi::{JSClass, JSContext, JSFunctionSpec};
|
||||
use js::rust::{HandleObject, MutableHandleObject};
|
||||
use libc;
|
||||
|
||||
/// The class of a namespace object.
|
||||
|
|
|
@ -11,15 +11,22 @@ use dom::bindings::utils::delete_property_by_id;
|
|||
use js::glue::{GetProxyHandler, GetProxyHandlerFamily, SetProxyExtra};
|
||||
use js::glue::GetProxyExtra;
|
||||
use js::glue::InvokeGetOwnPropertyDescriptor;
|
||||
use js::jsapi::{DOMProxyShadowsResult, JSContext, JSObject, JSPROP_GETTER, PropertyDescriptor};
|
||||
use js::jsapi::{Handle, HandleId, HandleObject, MutableHandle, ObjectOpResult};
|
||||
use js::jsapi::{JSErrNum, JS_AlreadyHasOwnPropertyById, JS_StrictPropertyStub};
|
||||
use js::jsapi::{JS_DefinePropertyById, JS_NewObjectWithGivenProto, SetDOMProxyInformation};
|
||||
use js::jsapi::{DOMProxyShadowsResult, JSContext, JSObject, PropertyDescriptor, JSPROP_GETTER};
|
||||
use js::jsapi::{JSErrNum, JS_StrictPropertyStub, SetDOMProxyInformation};
|
||||
use js::jsapi::GetObjectProto;
|
||||
use js::jsapi::GetStaticPrototype;
|
||||
use js::jsapi::Handle as RawHandle;
|
||||
use js::jsapi::HandleId as RawHandleId;
|
||||
use js::jsapi::HandleObject as RawHandleObject;
|
||||
use js::jsapi::JS_DefinePropertyById;
|
||||
use js::jsapi::JS_GetPropertyDescriptorById;
|
||||
use js::jsapi::MutableHandleObject;
|
||||
use js::jsapi::MutableHandle as RawMutableHandle;
|
||||
use js::jsapi::MutableHandleObject as RawMutableHandleObject;
|
||||
use js::jsapi::ObjectOpResult;
|
||||
use js::jsval::ObjectValue;
|
||||
use js::rust::{Handle, HandleObject, MutableHandle, MutableHandleObject};
|
||||
use js::rust::wrappers::JS_AlreadyHasOwnPropertyById;
|
||||
use js::rust::wrappers::JS_NewObjectWithGivenProto;
|
||||
use std::ptr;
|
||||
|
||||
|
||||
|
@ -27,8 +34,8 @@ static JSPROXYSLOT_EXPANDO: u32 = 0;
|
|||
|
||||
/// Determine if this id shadows any existing properties for this proxy.
|
||||
pub unsafe extern "C" fn shadow_check_callback(cx: *mut JSContext,
|
||||
object: HandleObject,
|
||||
id: HandleId)
|
||||
object: RawHandleObject,
|
||||
id: RawHandleId)
|
||||
-> DOMProxyShadowsResult {
|
||||
// TODO: support OverrideBuiltins when #12978 is fixed.
|
||||
|
||||
|
@ -36,7 +43,9 @@ pub unsafe extern "C" fn shadow_check_callback(cx: *mut JSContext,
|
|||
get_expando_object(object, expando.handle_mut());
|
||||
if !expando.get().is_null() {
|
||||
let mut has_own = false;
|
||||
if !JS_AlreadyHasOwnPropertyById(cx, expando.handle(), id, &mut has_own) {
|
||||
let raw_id = Handle::from_raw(id);
|
||||
|
||||
if !JS_AlreadyHasOwnPropertyById(cx, expando.handle(), raw_id, &mut has_own) {
|
||||
return DOMProxyShadowsResult::ShadowCheckFailed;
|
||||
}
|
||||
|
||||
|
@ -61,9 +70,9 @@ pub unsafe fn init() {
|
|||
/// Otherwise, walk along the prototype chain to find a property with that
|
||||
/// name.
|
||||
pub unsafe extern "C" fn get_property_descriptor(cx: *mut JSContext,
|
||||
proxy: HandleObject,
|
||||
id: HandleId,
|
||||
desc: MutableHandle<PropertyDescriptor>)
|
||||
proxy: RawHandleObject,
|
||||
id: RawHandleId,
|
||||
desc: RawMutableHandle<PropertyDescriptor>)
|
||||
-> bool {
|
||||
let handler = GetProxyHandler(proxy.get());
|
||||
if !InvokeGetOwnPropertyDescriptor(handler, cx, proxy, id, desc) {
|
||||
|
@ -74,20 +83,20 @@ pub unsafe extern "C" fn get_property_descriptor(cx: *mut JSContext,
|
|||
}
|
||||
|
||||
rooted!(in(cx) let mut proto = ptr::null_mut::<JSObject>());
|
||||
if !GetObjectProto(cx, proxy, proto.handle_mut()) {
|
||||
if !GetObjectProto(cx, proxy, proto.handle_mut().into()) {
|
||||
// FIXME(#11868) Should assign to desc.obj, desc.get() is a copy.
|
||||
desc.get().obj = ptr::null_mut();
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_GetPropertyDescriptorById(cx, proto.handle(), id, desc)
|
||||
JS_GetPropertyDescriptorById(cx, proto.handle().into(), id, desc)
|
||||
}
|
||||
|
||||
/// Defines an expando on the given `proxy`.
|
||||
pub unsafe extern "C" fn define_property(cx: *mut JSContext,
|
||||
proxy: HandleObject,
|
||||
id: HandleId,
|
||||
desc: Handle<PropertyDescriptor>,
|
||||
proxy: RawHandleObject,
|
||||
id: RawHandleId,
|
||||
desc: RawHandle<PropertyDescriptor>,
|
||||
result: *mut ObjectOpResult)
|
||||
-> bool {
|
||||
if (desc.get().attrs & JSPROP_GETTER) != 0 && desc.get().setter == Some(JS_StrictPropertyStub) {
|
||||
|
@ -97,13 +106,13 @@ pub unsafe extern "C" fn define_property(cx: *mut JSContext,
|
|||
|
||||
rooted!(in(cx) let mut expando = ptr::null_mut::<JSObject>());
|
||||
ensure_expando_object(cx, proxy, expando.handle_mut());
|
||||
JS_DefinePropertyById(cx, expando.handle(), id, desc, result)
|
||||
JS_DefinePropertyById(cx, expando.handle().into(), id, desc, result)
|
||||
}
|
||||
|
||||
/// Deletes an expando off the given `proxy`.
|
||||
pub unsafe extern "C" fn delete(cx: *mut JSContext,
|
||||
proxy: HandleObject,
|
||||
id: HandleId,
|
||||
proxy: RawHandleObject,
|
||||
id: RawHandleId,
|
||||
bp: *mut ObjectOpResult)
|
||||
-> bool {
|
||||
rooted!(in(cx) let mut expando = ptr::null_mut::<JSObject>());
|
||||
|
@ -113,12 +122,12 @@ pub unsafe extern "C" fn delete(cx: *mut JSContext,
|
|||
return true;
|
||||
}
|
||||
|
||||
delete_property_by_id(cx, expando.handle(), id, bp)
|
||||
delete_property_by_id(cx, expando.handle(), Handle::from_raw(id), bp)
|
||||
}
|
||||
|
||||
/// Controls whether the Extensible bit can be changed
|
||||
pub unsafe extern "C" fn prevent_extensions(_cx: *mut JSContext,
|
||||
_proxy: HandleObject,
|
||||
_proxy: RawHandleObject,
|
||||
result: *mut ObjectOpResult)
|
||||
-> bool {
|
||||
(*result).code_ = JSErrNum::JSMSG_CANT_PREVENT_EXTENSIONS as ::libc::uintptr_t;
|
||||
|
@ -127,7 +136,7 @@ pub unsafe extern "C" fn prevent_extensions(_cx: *mut JSContext,
|
|||
|
||||
/// Reports whether the object is Extensible
|
||||
pub unsafe extern "C" fn is_extensible(_cx: *mut JSContext,
|
||||
_proxy: HandleObject,
|
||||
_proxy: RawHandleObject,
|
||||
succeeded: *mut bool)
|
||||
-> bool {
|
||||
*succeeded = true;
|
||||
|
@ -144,9 +153,9 @@ pub unsafe extern "C" fn is_extensible(_cx: *mut JSContext,
|
|||
/// `[[GetPrototypeOf]]` behavior. An alternative implementation will be
|
||||
/// necessary for the Location object.
|
||||
pub unsafe extern "C" fn get_prototype_if_ordinary(_: *mut JSContext,
|
||||
proxy: HandleObject,
|
||||
proxy: RawHandleObject,
|
||||
is_ordinary: *mut bool,
|
||||
proto: MutableHandleObject)
|
||||
proto: RawMutableHandleObject)
|
||||
-> bool {
|
||||
*is_ordinary = true;
|
||||
proto.set(GetStaticPrototype(proxy.get()));
|
||||
|
@ -154,7 +163,7 @@ pub unsafe extern "C" fn get_prototype_if_ordinary(_: *mut JSContext,
|
|||
}
|
||||
|
||||
/// Get the expando object, or null if there is none.
|
||||
pub unsafe fn get_expando_object(obj: HandleObject, expando: MutableHandleObject) {
|
||||
pub unsafe fn get_expando_object(obj: RawHandleObject, mut expando: MutableHandleObject) {
|
||||
assert!(is_dom_proxy(obj.get()));
|
||||
let val = GetProxyExtra(obj.get(), JSPROXYSLOT_EXPANDO);
|
||||
expando.set(if val.is_undefined() {
|
||||
|
@ -166,7 +175,7 @@ pub unsafe fn get_expando_object(obj: HandleObject, expando: MutableHandleObject
|
|||
|
||||
/// Get the expando object, or create it if it doesn't exist yet.
|
||||
/// Fails on JSAPI failure.
|
||||
pub unsafe fn ensure_expando_object(cx: *mut JSContext, obj: HandleObject, expando: MutableHandleObject) {
|
||||
pub unsafe fn ensure_expando_object(cx: *mut JSContext, obj: RawHandleObject, mut expando: MutableHandleObject) {
|
||||
assert!(is_dom_proxy(obj.get()));
|
||||
get_expando_object(obj, expando);
|
||||
if expando.is_null() {
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
use dom::bindings::conversions::DerivedFrom;
|
||||
use dom::bindings::root::DomRoot;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use js::jsapi::{HandleObject, JSContext, JSObject, Heap};
|
||||
use js::jsapi::{JSContext, JSObject, Heap};
|
||||
use js::rust::HandleObject;
|
||||
use std::default::Default;
|
||||
|
||||
/// Create the reflector for a new DOM object and yield ownership to the
|
||||
|
|
|
@ -11,13 +11,17 @@ use dom::bindings::reflector::DomObject;
|
|||
use dom::bindings::root::DomRoot;
|
||||
use dom::blob::{Blob, BlobImpl};
|
||||
use dom::globalscope::GlobalScope;
|
||||
use js::jsapi::{Handle, HandleObject, HandleValue, MutableHandleValue, JSAutoCompartment, JSContext};
|
||||
use js::jsapi::{JSAutoCompartment, JSContext};
|
||||
use js::jsapi::{JSStructuredCloneCallbacks, JSStructuredCloneReader, JSStructuredCloneWriter};
|
||||
use js::jsapi::{JS_ClearPendingException, JSObject, JS_ReadStructuredClone};
|
||||
use js::jsapi::{JS_ClearPendingException, JSObject};
|
||||
use js::jsapi::{JS_ReadBytes, JS_WriteBytes};
|
||||
use js::jsapi::{JS_ReadUint32Pair, JS_WriteUint32Pair};
|
||||
use js::jsapi::{JS_STRUCTURED_CLONE_VERSION, JS_WriteStructuredClone};
|
||||
use js::jsapi::{MutableHandleObject, TransferableOwnership};
|
||||
use js::jsapi::HandleObject as RawHandleObject;
|
||||
use js::jsapi::JS_STRUCTURED_CLONE_VERSION;
|
||||
use js::jsapi::MutableHandleObject as RawMutableHandleObject;
|
||||
use js::jsapi::TransferableOwnership;
|
||||
use js::rust::{Handle, HandleValue, MutableHandleValue};
|
||||
use js::rust::wrappers::{JS_WriteStructuredClone, JS_ReadStructuredClone};
|
||||
use libc::size_t;
|
||||
use std::os::raw;
|
||||
use std::ptr;
|
||||
|
@ -137,10 +141,10 @@ unsafe extern "C" fn read_callback(cx: *mut JSContext,
|
|||
|
||||
unsafe extern "C" fn write_callback(_cx: *mut JSContext,
|
||||
w: *mut JSStructuredCloneWriter,
|
||||
obj: HandleObject,
|
||||
obj: RawHandleObject,
|
||||
_closure: *mut raw::c_void)
|
||||
-> bool {
|
||||
if let Ok(blob) = root_from_handleobject::<Blob>(obj) {
|
||||
if let Ok(blob) = root_from_handleobject::<Blob>(Handle::from_raw(obj)) {
|
||||
return write_blob(blob, w).is_ok()
|
||||
}
|
||||
return false
|
||||
|
@ -152,13 +156,13 @@ unsafe extern "C" fn read_transfer_callback(_cx: *mut JSContext,
|
|||
_content: *mut raw::c_void,
|
||||
_extra_data: u64,
|
||||
_closure: *mut raw::c_void,
|
||||
_return_object: MutableHandleObject)
|
||||
_return_object: RawMutableHandleObject)
|
||||
-> bool {
|
||||
false
|
||||
}
|
||||
|
||||
unsafe extern "C" fn write_transfer_callback(_cx: *mut JSContext,
|
||||
_obj: Handle<*mut JSObject>,
|
||||
_obj: RawHandleObject,
|
||||
_closure: *mut raw::c_void,
|
||||
_tag: *mut u32,
|
||||
_ownership: *mut TransferableOwnership,
|
||||
|
|
|
@ -59,9 +59,9 @@ use hyper::mime::Mime;
|
|||
use hyper::status::StatusCode;
|
||||
use ipc_channel::ipc::{IpcReceiver, IpcSender};
|
||||
use js::glue::{CallObjectTracer, CallValueTracer};
|
||||
use js::jsapi::{GCTraceKindToAscii, Heap, Handle, JSObject, JSTracer, TraceKind};
|
||||
use js::jsapi::{GCTraceKindToAscii, Heap, JSObject, JSTracer, TraceKind};
|
||||
use js::jsval::JSVal;
|
||||
use js::rust::{GCMethods, Runtime};
|
||||
use js::rust::{GCMethods, Handle, Runtime};
|
||||
use js::typedarray::TypedArray;
|
||||
use js::typedarray::TypedArrayElement;
|
||||
use metrics::{InteractiveMetrics, InteractiveWindow};
|
||||
|
|
|
@ -20,16 +20,24 @@ use js::glue::{GetCrossCompartmentWrapper, WrapperNew};
|
|||
use js::glue::{RUST_FUNCTION_VALUE_TO_JITINFO, RUST_JSID_IS_INT, RUST_JSID_IS_STRING};
|
||||
use js::glue::{RUST_JSID_TO_INT, RUST_JSID_TO_STRING, UnwrapObject};
|
||||
use js::jsapi::{CallArgs, DOMCallbacks, GetGlobalForObjectCrossCompartment};
|
||||
use js::jsapi::{HandleId, HandleObject, HandleValue, Heap, JSAutoCompartment, JSContext};
|
||||
use js::jsapi::{Heap, JSAutoCompartment, JSContext};
|
||||
use js::jsapi::{JSJitInfo, JSObject, JSTracer, JSWrapObjectCallbacks};
|
||||
use js::jsapi::{JS_DeletePropertyById, JS_EnumerateStandardClasses};
|
||||
use js::jsapi::{JS_ForwardGetPropertyTo, JS_GetLatin1StringCharsAndLength};
|
||||
use js::jsapi::{JS_GetProperty, JS_GetPrototype, JS_GetReservedSlot, JS_HasProperty};
|
||||
use js::jsapi::{JS_HasPropertyById, JS_IsExceptionPending, JS_IsGlobalObject};
|
||||
use js::jsapi::{JS_ResolveStandardClass, JS_SetProperty, ToWindowProxyIfWindow};
|
||||
use js::jsapi::{JS_StringHasLatin1Chars, MutableHandleValue, ObjectOpResult};
|
||||
use js::jsapi::{JS_EnumerateStandardClasses, JS_GetLatin1StringCharsAndLength};
|
||||
use js::jsapi::{JS_GetReservedSlot, JS_IsExceptionPending, JS_IsGlobalObject};
|
||||
use js::jsapi::{JS_ResolveStandardClass, ToWindowProxyIfWindow};
|
||||
use js::jsapi::{JS_StringHasLatin1Chars, ObjectOpResult};
|
||||
use js::jsapi::HandleId as RawHandleId;
|
||||
use js::jsapi::HandleObject as RawHandleObject;
|
||||
use js::jsval::{JSVal, UndefinedValue};
|
||||
use js::rust::{GCMethods, ToString, get_object_class, is_dom_class};
|
||||
use js::rust::{Handle, HandleId, HandleObject, HandleValue, MutableHandleValue};
|
||||
use js::rust::wrappers::JS_DeletePropertyById;
|
||||
use js::rust::wrappers::JS_ForwardGetPropertyTo;
|
||||
use js::rust::wrappers::JS_GetProperty;
|
||||
use js::rust::wrappers::JS_GetPrototype;
|
||||
use js::rust::wrappers::JS_HasProperty;
|
||||
use js::rust::wrappers::JS_HasPropertyById;
|
||||
use js::rust::wrappers::JS_SetProperty;
|
||||
use libc;
|
||||
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
||||
use std::ffi::CString;
|
||||
|
@ -144,8 +152,7 @@ pub unsafe fn get_property_on_prototype(cx: *mut JSContext,
|
|||
return false;
|
||||
}
|
||||
*found = has_property;
|
||||
let no_output = vp.ptr.is_null();
|
||||
if !has_property || no_output {
|
||||
if !has_property {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -155,9 +162,10 @@ pub unsafe fn get_property_on_prototype(cx: *mut JSContext,
|
|||
/// Get an array index from the given `jsid`. Returns `None` if the given
|
||||
/// `jsid` is not an integer.
|
||||
pub fn get_array_index_from_id(_cx: *mut JSContext, id: HandleId) -> Option<u32> {
|
||||
let raw_id = id.into();
|
||||
unsafe {
|
||||
if RUST_JSID_IS_INT(id) {
|
||||
return Some(RUST_JSID_TO_INT(id) as u32);
|
||||
if RUST_JSID_IS_INT(raw_id) {
|
||||
return Some(RUST_JSID_TO_INT(raw_id) as u32);
|
||||
}
|
||||
None
|
||||
}
|
||||
|
@ -320,13 +328,13 @@ pub unsafe fn trace_global(tracer: *mut JSTracer, obj: *mut JSObject) {
|
|||
}
|
||||
|
||||
/// Enumerate lazy properties of a global object.
|
||||
pub unsafe extern "C" fn enumerate_global(cx: *mut JSContext, obj: HandleObject) -> bool {
|
||||
pub unsafe extern "C" fn enumerate_global(cx: *mut JSContext, obj: RawHandleObject) -> bool {
|
||||
assert!(JS_IsGlobalObject(obj.get()));
|
||||
if !JS_EnumerateStandardClasses(cx, obj) {
|
||||
return false;
|
||||
}
|
||||
for init_fun in InterfaceObjectMap::MAP.values() {
|
||||
init_fun(cx, obj);
|
||||
init_fun(cx, Handle::from_raw(obj));
|
||||
}
|
||||
true
|
||||
}
|
||||
|
@ -334,8 +342,8 @@ pub unsafe extern "C" fn enumerate_global(cx: *mut JSContext, obj: HandleObject)
|
|||
/// Resolve a lazy global property, for interface objects and named constructors.
|
||||
pub unsafe extern "C" fn resolve_global(
|
||||
cx: *mut JSContext,
|
||||
obj: HandleObject,
|
||||
id: HandleId,
|
||||
obj: RawHandleObject,
|
||||
id: RawHandleId,
|
||||
rval: *mut bool)
|
||||
-> bool {
|
||||
assert!(JS_IsGlobalObject(obj.get()));
|
||||
|
@ -361,7 +369,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, obj);
|
||||
init_fun(cx, Handle::from_raw(obj));
|
||||
*rval = true;
|
||||
} else {
|
||||
*rval = false;
|
||||
|
@ -370,8 +378,8 @@ pub unsafe extern "C" fn resolve_global(
|
|||
}
|
||||
|
||||
unsafe extern "C" fn wrap(cx: *mut JSContext,
|
||||
_existing: HandleObject,
|
||||
obj: HandleObject)
|
||||
_existing: RawHandleObject,
|
||||
obj: RawHandleObject)
|
||||
-> *mut JSObject {
|
||||
// FIXME terrible idea. need security wrappers
|
||||
// https://github.com/servo/servo/issues/2382
|
||||
|
@ -379,9 +387,9 @@ unsafe extern "C" fn wrap(cx: *mut JSContext,
|
|||
}
|
||||
|
||||
unsafe extern "C" fn pre_wrap(cx: *mut JSContext,
|
||||
_existing: HandleObject,
|
||||
obj: HandleObject,
|
||||
_object_passed_to_wrap: HandleObject)
|
||||
_existing: RawHandleObject,
|
||||
obj: RawHandleObject,
|
||||
_object_passed_to_wrap: RawHandleObject)
|
||||
-> *mut JSObject {
|
||||
let _ac = JSAutoCompartment::new(cx, obj.get());
|
||||
let obj = ToWindowProxyIfWindow(obj.get());
|
||||
|
@ -409,7 +417,7 @@ unsafe fn generic_call(cx: *mut JSContext,
|
|||
vp: *mut JSVal,
|
||||
is_lenient: bool,
|
||||
call: unsafe extern fn(*const JSJitInfo, *mut JSContext,
|
||||
HandleObject, *mut libc::c_void, u32,
|
||||
RawHandleObject, *mut libc::c_void, u32,
|
||||
*mut JSVal)
|
||||
-> bool)
|
||||
-> bool {
|
||||
|
@ -447,7 +455,7 @@ unsafe fn generic_call(cx: *mut JSContext,
|
|||
}
|
||||
}
|
||||
};
|
||||
call(info, cx, obj.handle(), this as *mut libc::c_void, argc, vp)
|
||||
call(info, cx, obj.handle().into(), this as *mut libc::c_void, argc, vp)
|
||||
}
|
||||
|
||||
/// Generic method of IDL interface.
|
||||
|
@ -476,7 +484,7 @@ pub unsafe extern "C" fn generic_lenient_getter(cx: *mut JSContext,
|
|||
|
||||
unsafe extern "C" fn call_setter(info: *const JSJitInfo,
|
||||
cx: *mut JSContext,
|
||||
handle: HandleObject,
|
||||
handle: RawHandleObject,
|
||||
this: *mut libc::c_void,
|
||||
argc: u32,
|
||||
vp: *mut JSVal)
|
||||
|
|
|
@ -28,9 +28,11 @@ use dom_struct::dom_struct;
|
|||
use html5ever::{LocalName, Namespace, Prefix};
|
||||
use js::conversions::ToJSValConvertible;
|
||||
use js::glue::UnwrapObject;
|
||||
use js::jsapi::{Construct1, IsCallable, IsConstructor, HandleValueArray, HandleObject, MutableHandleValue};
|
||||
use js::jsapi::{Heap, JS_GetProperty, JS_SameValue, JSAutoCompartment, JSContext, JSObject};
|
||||
use js::jsapi::{Heap, IsCallable, IsConstructor, HandleValueArray};
|
||||
use js::jsapi::{JSAutoCompartment, JSContext, JSObject};
|
||||
use js::jsval::{JSVal, NullValue, ObjectValue, UndefinedValue};
|
||||
use js::rust::{HandleObject, MutableHandleValue};
|
||||
use js::rust::wrappers::{JS_GetProperty, Construct1, JS_SameValue};
|
||||
use microtask::Microtask;
|
||||
use script_thread::ScriptThread;
|
||||
use std::cell::Cell;
|
||||
|
|
|
@ -14,8 +14,9 @@ use dom::bindings::trace::RootedTraceableBox;
|
|||
use dom::event::Event;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom_struct::dom_struct;
|
||||
use js::jsapi::{Heap, HandleValue, JSContext};
|
||||
use js::jsapi::{Heap, JSContext};
|
||||
use js::jsval::JSVal;
|
||||
use js::rust::HandleValue;
|
||||
use servo_atoms::Atom;
|
||||
|
||||
// https://dom.spec.whatwg.org/#interface-customevent
|
||||
|
|
|
@ -25,9 +25,9 @@ use dom::workerglobalscope::WorkerGlobalScope;
|
|||
use dom_struct::dom_struct;
|
||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||
use ipc_channel::router::ROUTER;
|
||||
use js::jsapi::{HandleValue, JS_SetInterruptCallback};
|
||||
use js::jsapi::{JSAutoCompartment, JSContext, NullHandleValue};
|
||||
use js::jsapi::{JS_SetInterruptCallback, JSAutoCompartment, JSContext};
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::rust::HandleValue;
|
||||
use msg::constellation_msg::TopLevelBrowsingContextId;
|
||||
use net_traits::{IpcSend, load_whole_resource};
|
||||
use net_traits::request::{CredentialsMode, Destination, RequestInit};
|
||||
|
@ -373,14 +373,14 @@ impl DedicatedWorkerGlobalScope {
|
|||
error_info.filename.as_str().into(),
|
||||
error_info.lineno,
|
||||
error_info.column,
|
||||
unsafe { NullHandleValue },
|
||||
HandleValue::null(),
|
||||
);
|
||||
let event_status =
|
||||
event.upcast::<Event>().fire(worker.upcast::<EventTarget>());
|
||||
|
||||
// Step 2.
|
||||
if event_status == EventStatus::NotCanceled {
|
||||
global.report_an_error(error_info, unsafe { NullHandleValue });
|
||||
global.report_an_error(error_info, HandleValue::null());
|
||||
}
|
||||
}));
|
||||
// TODO: Should use the DOM manipulation task source.
|
||||
|
|
|
@ -14,8 +14,9 @@ use dom::globalscope::GlobalScope;
|
|||
use dom::windowproxy::WindowProxy;
|
||||
use dom_struct::dom_struct;
|
||||
use ipc_channel::ipc;
|
||||
use js::jsapi::{JSContext, HandleValue};
|
||||
use js::jsapi::JSContext;
|
||||
use js::jsval::{JSVal, UndefinedValue};
|
||||
use js::rust::HandleValue;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use script_traits::ScriptMsg;
|
||||
use servo_url::ImmutableOrigin;
|
||||
|
|
|
@ -15,8 +15,9 @@ use dom::bindings::trace::RootedTraceableBox;
|
|||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom_struct::dom_struct;
|
||||
use js::jsapi::{Heap, HandleValue, JSContext};
|
||||
use js::jsapi::{Heap, JSContext};
|
||||
use js::jsval::JSVal;
|
||||
use js::rust::HandleValue;
|
||||
use servo_atoms::Atom;
|
||||
use std::cell::Cell;
|
||||
|
||||
|
|
|
@ -34,8 +34,9 @@ use dom::virtualmethods::VirtualMethods;
|
|||
use dom::window::Window;
|
||||
use dom_struct::dom_struct;
|
||||
use fnv::FnvHasher;
|
||||
use js::jsapi::{CompileFunction, JS_GetFunctionObject, JSAutoCompartment, JSFunction};
|
||||
use js::jsapi::{JS_GetFunctionObject, JSAutoCompartment, JSFunction};
|
||||
use js::rust::{AutoObjectVectorWrapper, CompileOptionsWrapper};
|
||||
use js::rust::wrappers::CompileFunction;
|
||||
use libc::{c_char, size_t};
|
||||
use servo_atoms::Atom;
|
||||
use servo_url::ServoUrl;
|
||||
|
@ -453,7 +454,7 @@ impl EventTarget {
|
|||
args.as_ptr(),
|
||||
body.as_ptr(),
|
||||
body.len() as size_t,
|
||||
handler.handle_mut())
|
||||
handler.handle_mut().into())
|
||||
};
|
||||
if !rv || handler.get().is_null() {
|
||||
// Step 1.8.2
|
||||
|
|
|
@ -12,7 +12,8 @@ use dom::bindings::str::DOMString;
|
|||
use dom::event::Event;
|
||||
use dom::serviceworkerglobalscope::ServiceWorkerGlobalScope;
|
||||
use dom_struct::dom_struct;
|
||||
use js::jsapi::{HandleValue, JSContext};
|
||||
use js::jsapi::JSContext;
|
||||
use js::rust::HandleValue;
|
||||
use servo_atoms::Atom;
|
||||
|
||||
// https://w3c.github.io/ServiceWorker/#extendable-event
|
||||
|
|
|
@ -16,8 +16,9 @@ use dom::extendableevent::ExtendableEvent;
|
|||
use dom::globalscope::GlobalScope;
|
||||
use dom::serviceworkerglobalscope::ServiceWorkerGlobalScope;
|
||||
use dom_struct::dom_struct;
|
||||
use js::jsapi::{HandleValue, Heap, JSContext};
|
||||
use js::jsapi::{Heap, JSContext};
|
||||
use js::jsval::JSVal;
|
||||
use js::rust::HandleValue;
|
||||
use servo_atoms::Atom;
|
||||
|
||||
#[dom_struct]
|
||||
|
|
|
@ -27,11 +27,13 @@ use ipc_channel::ipc::IpcSender;
|
|||
use js::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL};
|
||||
use js::glue::{IsWrapper, UnwrapObject};
|
||||
use js::jsapi::{CurrentGlobalOrNull, GetGlobalForObjectCrossCompartment};
|
||||
use js::jsapi::{HandleValue, Evaluate2, JSAutoCompartment, JSContext};
|
||||
use js::jsapi::{JSAutoCompartment, JSContext};
|
||||
use js::jsapi::{JSObject, JS_GetContext};
|
||||
use js::jsapi::{JS_GetObjectRuntime, MutableHandleValue};
|
||||
use js::jsapi::JS_GetObjectRuntime;
|
||||
use js::panic::maybe_resume_unwind;
|
||||
use js::rust::{CompileOptionsWrapper, Runtime, get_object_class};
|
||||
use js::rust::{HandleValue, MutableHandleValue};
|
||||
use js::rust::wrappers::Evaluate2;
|
||||
use libc;
|
||||
use microtask::{Microtask, MicrotaskQueue};
|
||||
use msg::constellation_msg::PipelineId;
|
||||
|
|
|
@ -15,8 +15,9 @@ use dom::bindings::structuredclone::StructuredCloneData;
|
|||
use dom::globalscope::GlobalScope;
|
||||
use dom::window::Window;
|
||||
use dom_struct::dom_struct;
|
||||
use js::jsapi::{HandleValue, Heap, JSContext};
|
||||
use js::jsapi::{Heap, JSContext};
|
||||
use js::jsval::{JSVal, NullValue, UndefinedValue};
|
||||
use js::rust::HandleValue;
|
||||
use msg::constellation_msg::TraversalDirection;
|
||||
use profile_traits::ipc::channel;
|
||||
use script_traits::ScriptMsg;
|
||||
|
|
|
@ -33,7 +33,8 @@ use html5ever::{LocalName, Prefix};
|
|||
use image::ColorType;
|
||||
use image::png::PNGEncoder;
|
||||
use js::error::throw_type_error;
|
||||
use js::jsapi::{HandleValue, JSContext};
|
||||
use js::jsapi::JSContext;
|
||||
use js::rust::HandleValue;
|
||||
use offscreen_gl_context::GLContextAttributes;
|
||||
use profile_traits::ipc;
|
||||
use script_layout_interface::{HTMLCanvasData, HTMLCanvasDataSource};
|
||||
|
|
|
@ -15,8 +15,9 @@ use dom::event::Event;
|
|||
use dom::eventtarget::EventTarget;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom_struct::dom_struct;
|
||||
use js::jsapi::{HandleValue, Heap, JSContext};
|
||||
use js::jsapi::{Heap, JSContext};
|
||||
use js::jsval::JSVal;
|
||||
use js::rust::HandleValue;
|
||||
use servo_atoms::Atom;
|
||||
|
||||
#[dom_struct]
|
||||
|
|
|
@ -26,9 +26,6 @@ use dom::workletglobalscope::WorkletTask;
|
|||
use dom_struct::dom_struct;
|
||||
use euclid::TypedScale;
|
||||
use euclid::TypedSize2D;
|
||||
use js::jsapi::Call;
|
||||
use js::jsapi::Construct1;
|
||||
use js::jsapi::HandleValue;
|
||||
use js::jsapi::HandleValueArray;
|
||||
use js::jsapi::Heap;
|
||||
use js::jsapi::IsCallable;
|
||||
|
@ -41,7 +38,10 @@ use js::jsapi::JS_NewArrayObject;
|
|||
use js::jsval::JSVal;
|
||||
use js::jsval::ObjectValue;
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::rust::HandleValue;
|
||||
use js::rust::Runtime;
|
||||
use js::rust::wrappers::Call;
|
||||
use js::rust::wrappers::Construct1;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use net_traits::image::base::PixelFormat;
|
||||
use net_traits::image_cache::ImageCache;
|
||||
|
|
|
@ -14,8 +14,9 @@ use dom::bindings::trace::RootedTraceableBox;
|
|||
use dom::event::Event;
|
||||
use dom::window::Window;
|
||||
use dom_struct::dom_struct;
|
||||
use js::jsapi::{Heap, HandleValue, JSContext};
|
||||
use js::jsapi::{Heap, JSContext};
|
||||
use js::jsval::JSVal;
|
||||
use js::rust::HandleValue;
|
||||
use servo_atoms::Atom;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#the-popstateevent-interface
|
||||
|
|
|
@ -19,14 +19,17 @@ use dom::globalscope::GlobalScope;
|
|||
use dom::promisenativehandler::PromiseNativeHandler;
|
||||
use dom_struct::dom_struct;
|
||||
use js::conversions::ToJSValConvertible;
|
||||
use js::jsapi::{AddPromiseReactions, AddRawValueRoot, CallArgs, CallOriginalPromiseReject};
|
||||
use js::jsapi::{CallOriginalPromiseResolve, GetFunctionNativeReserved, GetPromiseState};
|
||||
use js::jsapi::{HandleObject, HandleValue, Heap, IsPromiseObject, JS_ClearPendingException};
|
||||
use js::jsapi::{AddRawValueRoot, CallArgs, GetFunctionNativeReserved};
|
||||
use js::jsapi::{Heap, JS_ClearPendingException};
|
||||
use js::jsapi::{JSAutoCompartment, JSContext, JSObject, JS_GetContext, JS_GetFunctionObject};
|
||||
use js::jsapi::{JS_GetObjectRuntime, JS_NewFunction, MutableHandleObject};
|
||||
use js::jsapi::{NewFunctionWithReserved, NewPromiseObject, PromiseState, RejectPromise};
|
||||
use js::jsapi::{RemoveRawValueRoot, ResolvePromise, SetFunctionNativeReserved};
|
||||
use js::jsapi::{JS_GetObjectRuntime, JS_NewFunction};
|
||||
use js::jsapi::{NewFunctionWithReserved, PromiseState};
|
||||
use js::jsapi::{RemoveRawValueRoot, SetFunctionNativeReserved};
|
||||
use js::jsval::{JSVal, UndefinedValue, ObjectValue, Int32Value};
|
||||
use js::rust::{HandleObject, HandleValue, MutableHandleObject};
|
||||
use js::rust::wrappers::{AddPromiseReactions, CallOriginalPromiseResolve, CallOriginalPromiseReject};
|
||||
use js::rust::wrappers::{GetPromiseState, IsPromiseObject};
|
||||
use js::rust::wrappers::{NewPromiseObject, ResolvePromise, RejectPromise};
|
||||
use std::ptr;
|
||||
use std::rc::Rc;
|
||||
|
||||
|
@ -106,7 +109,7 @@ impl Promise {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn create_js_promise(cx: *mut JSContext, proto: HandleObject, obj: MutableHandleObject) {
|
||||
unsafe fn create_js_promise(cx: *mut JSContext, proto: HandleObject, mut obj: MutableHandleObject) {
|
||||
let do_nothing_func = JS_NewFunction(cx, Some(do_nothing_promise_executor), /* nargs = */ 2,
|
||||
/* flags = */ 0, ptr::null());
|
||||
assert!(!do_nothing_func.is_null());
|
||||
|
@ -282,4 +285,3 @@ fn create_native_handler_function(cx: *mut JSContext,
|
|||
obj.get()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@ use dom::bindings::root::DomRoot;
|
|||
use dom::bindings::trace::JSTraceable;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom_struct::dom_struct;
|
||||
use js::jsapi::{JSContext, HandleValue};
|
||||
use js::jsapi::JSContext;
|
||||
use js::rust::HandleValue;
|
||||
use malloc_size_of::MallocSizeOf;
|
||||
|
||||
pub trait Callback: JSTraceable + MallocSizeOf {
|
||||
|
|
|
@ -15,7 +15,8 @@ use dom::bindings::structuredclone::StructuredCloneData;
|
|||
use dom::eventtarget::EventTarget;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom_struct::dom_struct;
|
||||
use js::jsapi::{HandleValue, JSContext};
|
||||
use js::jsapi::JSContext;
|
||||
use js::rust::HandleValue;
|
||||
use script_traits::{ScriptMsg, DOMMessage};
|
||||
use servo_url::ServoUrl;
|
||||
use std::cell::Cell;
|
||||
|
|
|
@ -34,9 +34,10 @@ use dom::promise::Promise;
|
|||
use dom::promisenativehandler::{PromiseNativeHandler, Callback};
|
||||
use dom::url::URL;
|
||||
use dom_struct::dom_struct;
|
||||
use js::jsapi::{HandleObject, HandleValue, Heap, JSContext, JSObject};
|
||||
use js::jsapi::{Heap, JSContext, JSObject};
|
||||
use js::jsapi::{JS_NewPlainObject, JS_NewUint8ClampedArray};
|
||||
use js::jsval::{JSVal, NullValue};
|
||||
use js::rust::{HandleObject, HandleValue};
|
||||
use js::rust::CustomAutoRooterGuard;
|
||||
use js::typedarray;
|
||||
use script_traits::MsDuration;
|
||||
|
|
|
@ -52,9 +52,10 @@ use euclid::{Point2D, Vector2D, Rect, Size2D, TypedPoint2D, TypedScale, TypedSiz
|
|||
use fetch;
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use ipc_channel::router::ROUTER;
|
||||
use js::jsapi::{HandleValue, JSAutoCompartment, JSContext};
|
||||
use js::jsapi::{JSAutoCompartment, JSContext};
|
||||
use js::jsapi::{JS_GC, JS_GetRuntime};
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::rust::HandleValue;
|
||||
use layout_image::fetch_image_for_layout;
|
||||
use microtask::MicrotaskQueue;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
|
|
|
@ -18,18 +18,25 @@ use dom::globalscope::GlobalScope;
|
|||
use dom::window::Window;
|
||||
use dom_struct::dom_struct;
|
||||
use js::JSCLASS_IS_GLOBAL;
|
||||
use js::glue::{CreateWrapperProxyHandler, ProxyTraps, NewWindowProxy};
|
||||
use js::glue::{CreateWrapperProxyHandler, ProxyTraps};
|
||||
use js::glue::{GetProxyPrivate, SetProxyExtra, GetProxyExtra};
|
||||
use js::jsapi::{Handle, HandleId, HandleObject, HandleValue};
|
||||
use js::jsapi::{JSAutoCompartment, JSContext, JSErrNum, JSFreeOp, JSObject};
|
||||
use js::jsapi::{JSPROP_READONLY, JSTracer, JS_DefinePropertyById};
|
||||
use js::jsapi::{JS_ForwardGetPropertyTo, JS_ForwardSetPropertyTo};
|
||||
use js::jsapi::{JS_GetOwnPropertyDescriptorById, JS_HasPropertyById, JS_HasOwnPropertyById};
|
||||
use js::jsapi::{JS_IsExceptionPending, JS_TransplantObject, SetWindowProxy};
|
||||
use js::jsapi::{MutableHandle, MutableHandleObject, MutableHandleValue};
|
||||
use js::jsapi::{JS_HasPropertyById, JS_HasOwnPropertyById};
|
||||
use js::jsapi::{JS_IsExceptionPending, JS_GetOwnPropertyDescriptorById};
|
||||
use js::jsapi::{ObjectOpResult, PropertyDescriptor};
|
||||
use js::jsapi::Handle as RawHandle;
|
||||
use js::jsapi::HandleId as RawHandleId;
|
||||
use js::jsapi::HandleObject as RawHandleObject;
|
||||
use js::jsapi::HandleValue as RawHandleValue;
|
||||
use js::jsapi::MutableHandle as RawMutableHandle;
|
||||
use js::jsapi::MutableHandleObject as RawMutableHandleObject;
|
||||
use js::jsapi::MutableHandleValue as RawMutableHandleValue;
|
||||
use js::jsval::{UndefinedValue, PrivateValue};
|
||||
use js::rust::{Handle, MutableHandle};
|
||||
use js::rust::get_object_class;
|
||||
use js::rust::wrappers::{NewWindowProxy, SetWindowProxy, JS_TransplantObject};
|
||||
use msg::constellation_msg::BrowsingContextId;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use msg::constellation_msg::TopLevelBrowsingContextId;
|
||||
|
@ -292,14 +299,16 @@ impl WindowProxy {
|
|||
}
|
||||
}
|
||||
|
||||
// This is only called from extern functions,
|
||||
// there's no use using the lifetimed handles here.
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn GetSubframeWindow(cx: *mut JSContext,
|
||||
proxy: HandleObject,
|
||||
id: HandleId)
|
||||
proxy: RawHandleObject,
|
||||
id: RawHandleId)
|
||||
-> Option<DomRoot<Window>> {
|
||||
let index = get_array_index_from_id(cx, id);
|
||||
let index = get_array_index_from_id(cx, Handle::from_raw(id));
|
||||
if let Some(index) = index {
|
||||
rooted!(in(cx) let target = GetProxyPrivate(*proxy.ptr).to_object());
|
||||
rooted!(in(cx) let target = GetProxyPrivate(*proxy).to_object());
|
||||
let win = root_from_handleobject::<Window>(target.handle()).unwrap();
|
||||
let mut found = false;
|
||||
return win.IndexedGetter(index, &mut found);
|
||||
|
@ -310,21 +319,21 @@ unsafe fn GetSubframeWindow(cx: *mut JSContext,
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe extern "C" fn getOwnPropertyDescriptor(cx: *mut JSContext,
|
||||
proxy: HandleObject,
|
||||
id: HandleId,
|
||||
mut desc: MutableHandle<PropertyDescriptor>)
|
||||
proxy: RawHandleObject,
|
||||
id: RawHandleId,
|
||||
mut desc: RawMutableHandle<PropertyDescriptor>)
|
||||
-> bool {
|
||||
let window = GetSubframeWindow(cx, proxy, id);
|
||||
if let Some(window) = window {
|
||||
rooted!(in(cx) let mut val = UndefinedValue());
|
||||
window.to_jsval(cx, val.handle_mut());
|
||||
desc.value = val.get();
|
||||
fill_property_descriptor(desc, proxy.get(), JSPROP_READONLY);
|
||||
fill_property_descriptor(MutableHandle::from_raw(desc), proxy.get(), JSPROP_READONLY);
|
||||
return true;
|
||||
}
|
||||
|
||||
rooted!(in(cx) let target = GetProxyPrivate(proxy.get()).to_object());
|
||||
if !JS_GetOwnPropertyDescriptorById(cx, target.handle(), id, desc) {
|
||||
if !JS_GetOwnPropertyDescriptorById(cx, target.handle().into(), id, desc) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -339,12 +348,12 @@ unsafe extern "C" fn getOwnPropertyDescriptor(cx: *mut JSContext,
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe extern "C" fn defineProperty(cx: *mut JSContext,
|
||||
proxy: HandleObject,
|
||||
id: HandleId,
|
||||
desc: Handle<PropertyDescriptor>,
|
||||
proxy: RawHandleObject,
|
||||
id: RawHandleId,
|
||||
desc: RawHandle<PropertyDescriptor>,
|
||||
res: *mut ObjectOpResult)
|
||||
-> bool {
|
||||
if get_array_index_from_id(cx, id).is_some() {
|
||||
if get_array_index_from_id(cx, Handle::from_raw(id)).is_some() {
|
||||
// Spec says to Reject whether this is a supported index or not,
|
||||
// since we have no indexed setter or indexed creator. That means
|
||||
// throwing in strict mode (FIXME: Bug 828137), doing nothing in
|
||||
|
@ -354,13 +363,13 @@ unsafe extern "C" fn defineProperty(cx: *mut JSContext,
|
|||
}
|
||||
|
||||
rooted!(in(cx) let target = GetProxyPrivate(*proxy.ptr).to_object());
|
||||
JS_DefinePropertyById(cx, target.handle(), id, desc, res)
|
||||
JS_DefinePropertyById(cx, target.handle().into(), id, desc, res)
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe extern "C" fn has(cx: *mut JSContext,
|
||||
proxy: HandleObject,
|
||||
id: HandleId,
|
||||
proxy: RawHandleObject,
|
||||
id: RawHandleId,
|
||||
bp: *mut bool)
|
||||
-> bool {
|
||||
let window = GetSubframeWindow(cx, proxy, id);
|
||||
|
@ -371,7 +380,7 @@ unsafe extern "C" fn has(cx: *mut JSContext,
|
|||
|
||||
rooted!(in(cx) let target = GetProxyPrivate(*proxy.ptr).to_object());
|
||||
let mut found = false;
|
||||
if !JS_HasPropertyById(cx, target.handle(), id, &mut found) {
|
||||
if !JS_HasPropertyById(cx, target.handle().into(), id, &mut found) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -381,30 +390,30 @@ unsafe extern "C" fn has(cx: *mut JSContext,
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe extern "C" fn get(cx: *mut JSContext,
|
||||
proxy: HandleObject,
|
||||
receiver: HandleValue,
|
||||
id: HandleId,
|
||||
vp: MutableHandleValue)
|
||||
proxy: RawHandleObject,
|
||||
receiver: RawHandleValue,
|
||||
id: RawHandleId,
|
||||
vp: RawMutableHandleValue)
|
||||
-> bool {
|
||||
let window = GetSubframeWindow(cx, proxy, id);
|
||||
if let Some(window) = window {
|
||||
window.to_jsval(cx, vp);
|
||||
window.to_jsval(cx, MutableHandle::from_raw(vp));
|
||||
return true;
|
||||
}
|
||||
|
||||
rooted!(in(cx) let target = GetProxyPrivate(*proxy.ptr).to_object());
|
||||
JS_ForwardGetPropertyTo(cx, target.handle(), id, receiver, vp)
|
||||
JS_ForwardGetPropertyTo(cx, target.handle().into(), id, receiver, vp)
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe extern "C" fn set(cx: *mut JSContext,
|
||||
proxy: HandleObject,
|
||||
id: HandleId,
|
||||
v: HandleValue,
|
||||
receiver: HandleValue,
|
||||
proxy: RawHandleObject,
|
||||
id: RawHandleId,
|
||||
v: RawHandleValue,
|
||||
receiver: RawHandleValue,
|
||||
res: *mut ObjectOpResult)
|
||||
-> bool {
|
||||
if get_array_index_from_id(cx, id).is_some() {
|
||||
if get_array_index_from_id(cx, Handle::from_raw(id)).is_some() {
|
||||
// Reject (which means throw if and only if strict) the set.
|
||||
(*res).code_ = JSErrNum::JSMSG_READ_ONLY as ::libc::uintptr_t;
|
||||
return true;
|
||||
|
@ -412,7 +421,7 @@ unsafe extern "C" fn set(cx: *mut JSContext,
|
|||
|
||||
rooted!(in(cx) let target = GetProxyPrivate(*proxy.ptr).to_object());
|
||||
JS_ForwardSetPropertyTo(cx,
|
||||
target.handle(),
|
||||
target.handle().into(),
|
||||
id,
|
||||
v,
|
||||
receiver,
|
||||
|
@ -421,9 +430,9 @@ unsafe extern "C" fn set(cx: *mut JSContext,
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe extern "C" fn get_prototype_if_ordinary(_: *mut JSContext,
|
||||
_: HandleObject,
|
||||
_: RawHandleObject,
|
||||
is_ordinary: *mut bool,
|
||||
_: MutableHandleObject)
|
||||
_: RawMutableHandleObject)
|
||||
-> bool {
|
||||
// Window's [[GetPrototypeOf]] trap isn't the ordinary definition:
|
||||
//
|
||||
|
@ -495,14 +504,14 @@ unsafe fn throw_security_error(cx: *mut JSContext) -> bool {
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe extern "C" fn has_xorigin(cx: *mut JSContext,
|
||||
proxy: HandleObject,
|
||||
id: HandleId,
|
||||
proxy: RawHandleObject,
|
||||
id: RawHandleId,
|
||||
bp: *mut bool)
|
||||
-> bool
|
||||
{
|
||||
rooted!(in(cx) let target = GetProxyPrivate(*proxy.ptr).to_object());
|
||||
let mut found = false;
|
||||
JS_HasOwnPropertyById(cx, target.handle(), id, &mut found);
|
||||
JS_HasOwnPropertyById(cx, target.handle().into(), id, &mut found);
|
||||
if found {
|
||||
*bp = true;
|
||||
true
|
||||
|
@ -513,10 +522,10 @@ unsafe extern "C" fn has_xorigin(cx: *mut JSContext,
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe extern "C" fn get_xorigin(cx: *mut JSContext,
|
||||
proxy: HandleObject,
|
||||
receiver: HandleValue,
|
||||
id: HandleId,
|
||||
vp: MutableHandleValue)
|
||||
proxy: RawHandleObject,
|
||||
receiver: RawHandleValue,
|
||||
id: RawHandleId,
|
||||
vp: RawMutableHandleValue)
|
||||
-> bool
|
||||
{
|
||||
let mut found = false;
|
||||
|
@ -526,10 +535,10 @@ unsafe extern "C" fn get_xorigin(cx: *mut JSContext,
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe extern "C" fn set_xorigin(cx: *mut JSContext,
|
||||
_: HandleObject,
|
||||
_: HandleId,
|
||||
_: HandleValue,
|
||||
_: HandleValue,
|
||||
_: RawHandleObject,
|
||||
_: RawHandleId,
|
||||
_: RawHandleValue,
|
||||
_: RawHandleValue,
|
||||
_: *mut ObjectOpResult)
|
||||
-> bool
|
||||
{
|
||||
|
@ -538,8 +547,8 @@ unsafe extern "C" fn set_xorigin(cx: *mut JSContext,
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe extern "C" fn delete_xorigin(cx: *mut JSContext,
|
||||
_: HandleObject,
|
||||
_: HandleId,
|
||||
_: RawHandleObject,
|
||||
_: RawHandleId,
|
||||
_: *mut ObjectOpResult)
|
||||
-> bool
|
||||
{
|
||||
|
@ -548,9 +557,9 @@ unsafe extern "C" fn delete_xorigin(cx: *mut JSContext,
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe extern "C" fn getOwnPropertyDescriptor_xorigin(cx: *mut JSContext,
|
||||
proxy: HandleObject,
|
||||
id: HandleId,
|
||||
desc: MutableHandle<PropertyDescriptor>)
|
||||
proxy: RawHandleObject,
|
||||
id: RawHandleId,
|
||||
desc: RawMutableHandle<PropertyDescriptor>)
|
||||
-> bool
|
||||
{
|
||||
let mut found = false;
|
||||
|
@ -560,9 +569,9 @@ unsafe extern "C" fn getOwnPropertyDescriptor_xorigin(cx: *mut JSContext,
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe extern "C" fn defineProperty_xorigin(cx: *mut JSContext,
|
||||
_: HandleObject,
|
||||
_: HandleId,
|
||||
_: Handle<PropertyDescriptor>,
|
||||
_: RawHandleObject,
|
||||
_: RawHandleId,
|
||||
_: RawHandle<PropertyDescriptor>,
|
||||
_: *mut ObjectOpResult)
|
||||
-> bool
|
||||
{
|
||||
|
@ -571,7 +580,7 @@ unsafe extern "C" fn defineProperty_xorigin(cx: *mut JSContext,
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe extern "C" fn preventExtensions_xorigin(cx: *mut JSContext,
|
||||
_: HandleObject,
|
||||
_: RawHandleObject,
|
||||
_: *mut ObjectOpResult)
|
||||
-> bool
|
||||
{
|
||||
|
|
|
@ -21,8 +21,9 @@ use dom::messageevent::MessageEvent;
|
|||
use dom::workerglobalscope::prepare_workerscope_init;
|
||||
use dom_struct::dom_struct;
|
||||
use ipc_channel::ipc;
|
||||
use js::jsapi::{HandleValue, JSAutoCompartment, JSContext};
|
||||
use js::jsapi::{JSAutoCompartment, JSContext};
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::rust::HandleValue;
|
||||
use script_traits::WorkerScriptLoadOrigin;
|
||||
use std::cell::Cell;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
|
|
@ -26,9 +26,10 @@ use dom::workernavigator::WorkerNavigator;
|
|||
use dom_struct::dom_struct;
|
||||
use fetch;
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use js::jsapi::{HandleValue, JSAutoCompartment, JSContext, JSRuntime};
|
||||
use js::jsapi::{JSAutoCompartment, JSContext, JSRuntime};
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::panic::maybe_resume_unwind;
|
||||
use js::rust::HandleValue;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use net_traits::{IpcSend, load_whole_resource};
|
||||
use net_traits::request::{CredentialsMode, Destination, RequestInit as NetRequestInit};
|
||||
|
|
|
@ -48,9 +48,10 @@ use hyper::mime::{self, Attr as MimeAttr, Mime, Value as MimeValue};
|
|||
use hyper_serde::Serde;
|
||||
use ipc_channel::ipc;
|
||||
use ipc_channel::router::ROUTER;
|
||||
use js::jsapi::{Heap, JSContext, JSObject, JS_ParseJSON};
|
||||
use js::jsapi::{Heap, JSContext, JSObject};
|
||||
use js::jsapi::JS_ClearPendingException;
|
||||
use js::jsval::{JSVal, NullValue, UndefinedValue};
|
||||
use js::rust::wrappers::JS_ParseJSON;
|
||||
use js::typedarray::{ArrayBuffer, CreateWith};
|
||||
use net_traits::{FetchChannels, FetchMetadata, FilteredMetadata};
|
||||
use net_traits::{FetchResponseListener, NetworkError, ReferrerPolicy};
|
||||
|
|
|
@ -14,8 +14,9 @@ use dom::testbinding::TestBindingCallback;
|
|||
use dom::xmlhttprequest::XHRTimeoutCallback;
|
||||
use euclid::Length;
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use js::jsapi::{HandleValue, Heap};
|
||||
use js::jsapi::Heap;
|
||||
use js::jsval::{JSVal, UndefinedValue};
|
||||
use js::rust::HandleValue;
|
||||
use script_traits::{MsDuration, precise_time_ms};
|
||||
use script_traits::{TimerEvent, TimerEventId, TimerEventRequest};
|
||||
use script_traits::{TimerSchedulerMsg, TimerSource};
|
||||
|
@ -520,7 +521,7 @@ impl JsTimerTask {
|
|||
// Returning Handles directly from Heap values is inherently unsafe, but here it's
|
||||
// always done via rooted JsTimers, which is safe.
|
||||
#[allow(unsafe_code)]
|
||||
fn collect_heap_args(&self, args: &[Heap<JSVal>]) -> Vec<HandleValue> {
|
||||
fn collect_heap_args<'b>(&self, args: &'b [Heap<JSVal>]) -> Vec<HandleValue<'b>> {
|
||||
args.iter().map(|arg| unsafe { arg.handle() }).collect()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,9 @@ use dom::node::{Node, window_from_node};
|
|||
use euclid::{Point2D, Rect, Size2D};
|
||||
use hyper_serde::Serde;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use js::jsapi::{HandleValue, JSContext};
|
||||
use js::jsapi::JSContext;
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::rust::HandleValue;
|
||||
use msg::constellation_msg::BrowsingContextId;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use net_traits::CookieSource::{HTTP, NonHTTP};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue