From 6b53c4937b67dc71414d37dd3f4ad5cf407b2c2b Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Tue, 9 Feb 2016 16:38:17 +0100 Subject: [PATCH] Introduce a NewWindowProxy API. --- src/glue.rs | 3 +++ src/jsglue.cpp | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/glue.rs b/src/glue.rs index b00959cb5bc97..8796dbe0a27a6 100644 --- a/src/glue.rs +++ b/src/glue.rs @@ -208,6 +208,9 @@ extern "C" { aHandler: *const ::libc::c_void, aClass: *const JSClass, aSingleton: bool) -> *mut JSObject; + pub fn NewWindowProxy(aCx: *mut JSContext, aObj: HandleObject, + aHandler: *const ::libc::c_void) + -> *mut JSObject; pub fn GetProxyExtra(obj: *mut JSObject, slot: u32) -> Value; pub fn GetProxyPrivate(obj: *mut JSObject) -> Value; pub fn SetProxyExtra(obj: *mut JSObject, slot: u32, val: Value); diff --git a/src/jsglue.cpp b/src/jsglue.cpp index 89ad4df6f3b95..2e99789feeb06 100644 --- a/src/jsglue.cpp +++ b/src/jsglue.cpp @@ -529,6 +529,28 @@ WrapperNew(JSContext* aCx, JS::HandleObject aObj, const void* aHandler, return js::Wrapper::New(aCx, aObj, (const js::Wrapper*)aHandler, options); } +void WindowProxyObjectMoved(JSObject*, const JSObject*) +{ + abort(); +} + +const js::Class WindowProxyClass = + PROXY_CLASS_WITH_EXT( + "Proxy", + 0, /* additional class flags */ + PROXY_MAKE_EXT( + nullptr, /* outerObject */ + js::proxy_innerObject, + false, /* isWrappedNative */ + WindowProxyObjectMoved + )); + +JSObject* +NewWindowProxy(JSContext* aCx, JS::HandleObject aObj, const void* aHandler) +{ + return WrapperNew(aCx, aObj, aHandler, Jsvalify(&WindowProxyClass), true); +} + jsval GetProxyExtra(JSObject* obj, uint32_t slot) {