зеркало из https://github.com/mozilla/gecko-dev.git
Bug 862115 - Use Rooted<JSPropertyDescriptor> in favor of JSPropertyDescriptor::AutoRooter r=terrence r=smaug r=bholley
This commit is contained in:
Родитель
afbb0ff592
Коммит
09de524f1a
|
@ -575,17 +575,17 @@ public:
|
|||
virtual bool getPropertyDescriptor(JSContext* cx,
|
||||
JS::Handle<JSObject*> proxy,
|
||||
JS::Handle<jsid> id,
|
||||
JSPropertyDescriptor* desc,
|
||||
JS::MutableHandle<JSPropertyDescriptor> desc,
|
||||
unsigned flags) MOZ_OVERRIDE;
|
||||
virtual bool getOwnPropertyDescriptor(JSContext* cx,
|
||||
JS::Handle<JSObject*> proxy,
|
||||
JS::Handle<jsid> id,
|
||||
JSPropertyDescriptor* desc,
|
||||
JS::MutableHandle<JSPropertyDescriptor> desc,
|
||||
unsigned flags) MOZ_OVERRIDE;
|
||||
virtual bool defineProperty(JSContext* cx,
|
||||
JS::Handle<JSObject*> proxy,
|
||||
JS::Handle<jsid> id,
|
||||
JSPropertyDescriptor* desc) MOZ_OVERRIDE;
|
||||
JS::MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||
virtual bool getOwnPropertyNames(JSContext *cx,
|
||||
JS::Handle<JSObject*> proxy,
|
||||
JS::AutoIdVector &props) MOZ_OVERRIDE;
|
||||
|
@ -688,18 +688,18 @@ bool
|
|||
nsOuterWindowProxy::getPropertyDescriptor(JSContext* cx,
|
||||
JS::Handle<JSObject*> proxy,
|
||||
JS::Handle<jsid> id,
|
||||
JSPropertyDescriptor* desc,
|
||||
JS::MutableHandle<JSPropertyDescriptor> desc,
|
||||
unsigned flags)
|
||||
{
|
||||
// The only thing we can do differently from js::Wrapper is shadow stuff with
|
||||
// our indexed properties, so we can just try getOwnPropertyDescriptor and if
|
||||
// that gives us nothing call on through to js::Wrapper.
|
||||
desc->obj = nullptr;
|
||||
desc.object().set(nullptr);
|
||||
if (!getOwnPropertyDescriptor(cx, proxy, id, desc, flags)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (desc->obj) {
|
||||
if (desc.object()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -710,11 +710,11 @@ bool
|
|||
nsOuterWindowProxy::getOwnPropertyDescriptor(JSContext* cx,
|
||||
JS::Handle<JSObject*> proxy,
|
||||
JS::Handle<jsid> id,
|
||||
JSPropertyDescriptor* desc,
|
||||
JS::MutableHandle<JSPropertyDescriptor> desc,
|
||||
unsigned flags)
|
||||
{
|
||||
bool found;
|
||||
if (!GetSubframeWindow(cx, proxy, id, &desc->value, found)) {
|
||||
if (!GetSubframeWindow(cx, proxy, id, desc.value().address(), found)) {
|
||||
return false;
|
||||
}
|
||||
if (found) {
|
||||
|
@ -730,7 +730,7 @@ bool
|
|||
nsOuterWindowProxy::defineProperty(JSContext* cx,
|
||||
JS::Handle<JSObject*> proxy,
|
||||
JS::Handle<jsid> id,
|
||||
JSPropertyDescriptor* desc)
|
||||
JS::MutableHandle<JSPropertyDescriptor> desc)
|
||||
{
|
||||
int32_t index = GetArrayIndexFromId(cx, id);
|
||||
if (IsArrayIndex(index)) {
|
||||
|
|
|
@ -815,15 +815,14 @@ GetNativePropertyHooks(JSContext *cx, JS::Handle<JSObject*> obj,
|
|||
bool
|
||||
XrayResolveOwnProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
|
||||
JS::Handle<JSObject*> obj, JS::Handle<jsid> id,
|
||||
JSPropertyDescriptor* desc, unsigned flags)
|
||||
JS::MutableHandle<JSPropertyDescriptor> desc, unsigned flags)
|
||||
{
|
||||
DOMObjectType type;
|
||||
const NativePropertyHooks *nativePropertyHooks =
|
||||
GetNativePropertyHooks(cx, obj, type);
|
||||
|
||||
return type != eInstance || !nativePropertyHooks->mResolveOwnProperty ||
|
||||
nativePropertyHooks->mResolveOwnProperty(cx, wrapper, obj, id, desc,
|
||||
flags);
|
||||
nativePropertyHooks->mResolveOwnProperty(cx, wrapper, obj, id, desc, flags);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -1088,7 +1087,7 @@ XrayResolveNativeProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
|
|||
bool
|
||||
XrayDefineProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
|
||||
JS::Handle<JSObject*> obj, JS::Handle<jsid> id,
|
||||
JSPropertyDescriptor* desc, bool* defined)
|
||||
JS::MutableHandle<JSPropertyDescriptor> desc, bool* defined)
|
||||
{
|
||||
if (!js::IsProxy(obj))
|
||||
return true;
|
||||
|
|
|
@ -1901,7 +1901,7 @@ bool
|
|||
XrayResolveOwnProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
|
||||
JS::Handle<JSObject*> obj,
|
||||
JS::Handle<jsid> id,
|
||||
JSPropertyDescriptor* desc, unsigned flags);
|
||||
JS::MutableHandle<JSPropertyDescriptor> desc, unsigned flags);
|
||||
|
||||
/**
|
||||
* This resolves operations, attributes and constants of the interfaces for obj.
|
||||
|
@ -1924,9 +1924,9 @@ XrayResolveNativeProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
|
|||
* defined will be set to true if a property was set as a result of this call.
|
||||
*/
|
||||
bool
|
||||
XrayDefineProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
|
||||
XrayDefineProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
|
||||
JS::Handle<JSObject*> obj, JS::Handle<jsid> id,
|
||||
JSPropertyDescriptor* desc, bool* defined);
|
||||
JS::MutableHandle<JSPropertyDescriptor> desc, bool* defined);
|
||||
|
||||
/**
|
||||
* This enumerates indexed or named properties of obj and operations, attributes
|
||||
|
|
|
@ -6930,7 +6930,8 @@ class CGResolveOwnProperty(CGAbstractStaticMethod):
|
|||
Argument('JS::Handle<JSObject*>', 'wrapper'),
|
||||
Argument('JS::Handle<JSObject*>', 'obj'),
|
||||
Argument('JS::Handle<jsid>', 'id'),
|
||||
Argument('JSPropertyDescriptor*', 'desc'), Argument('unsigned', 'flags'),
|
||||
Argument('JS::MutableHandle<JSPropertyDescriptor>', 'desc'),
|
||||
Argument('unsigned', 'flags'),
|
||||
]
|
||||
CGAbstractStaticMethod.__init__(self, descriptor, "ResolveOwnProperty",
|
||||
"bool", args)
|
||||
|
@ -6948,7 +6949,8 @@ class CGResolveOwnPropertyViaNewresolve(CGAbstractBindingMethod):
|
|||
Argument('JS::Handle<JSObject*>', 'wrapper'),
|
||||
Argument('JS::Handle<JSObject*>', 'obj'),
|
||||
Argument('JS::Handle<jsid>', 'id'),
|
||||
Argument('JSPropertyDescriptor*', 'desc'), Argument('unsigned', 'flags'),
|
||||
Argument('JS::MutableHandle<JSPropertyDescriptor>', 'desc'),
|
||||
Argument('unsigned', 'flags'),
|
||||
]
|
||||
CGAbstractBindingMethod.__init__(self, descriptor,
|
||||
"ResolveOwnPropertyViaNewresolve",
|
||||
|
@ -7076,8 +7078,8 @@ class CGProxySpecialOperation(CGPerSignatureCall):
|
|||
templateValues = {
|
||||
"declName": argument.identifier.name,
|
||||
"holderName": argument.identifier.name + "_holder",
|
||||
"val" : "JS::Handle<JS::Value>::fromMarkedLocation(&desc->value)",
|
||||
"mutableVal" : "JS::MutableHandle<JS::Value>::fromMarkedLocation(&desc->value)",
|
||||
"val": "desc.value()",
|
||||
"mutableVal" : "desc.value()",
|
||||
"obj": "obj"
|
||||
}
|
||||
self.cgRoot.prepend(instantiateJSToNativeConversion(info, templateValues))
|
||||
|
@ -7282,7 +7284,8 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(ClassMethod):
|
|||
def __init__(self, descriptor):
|
||||
args = [Argument('JSContext*', 'cx'), Argument('JS::Handle<JSObject*>', 'proxy'),
|
||||
Argument('JS::Handle<jsid>', 'id'),
|
||||
Argument('JSPropertyDescriptor*', 'desc'), Argument('unsigned', 'flags')]
|
||||
Argument('JS::MutableHandle<JSPropertyDescriptor>', 'desc'),
|
||||
Argument('unsigned', 'flags')]
|
||||
ClassMethod.__init__(self, "getOwnPropertyDescriptor", "bool", args)
|
||||
self.descriptor = descriptor
|
||||
def getBody(self):
|
||||
|
@ -7294,23 +7297,22 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(ClassMethod):
|
|||
setOrIndexedGet += "int32_t index = GetArrayIndexFromId(cx, id);\n"
|
||||
readonly = toStringBool(indexedSetter is None)
|
||||
fillDescriptor = "FillPropertyDescriptor(desc, proxy, %s);\nreturn true;" % readonly
|
||||
templateValues = {'jsvalRef': 'JS::MutableHandle<JS::Value>::fromMarkedLocation(&desc->value)',
|
||||
'jsvalHandle': 'JS::MutableHandle<JS::Value>::fromMarkedLocation(&desc->value)',
|
||||
templateValues = {'jsvalRef': 'desc.value()', 'jsvalHandle': 'desc.value()',
|
||||
'obj': 'proxy', 'successCode': fillDescriptor}
|
||||
get = ("if (IsArrayIndex(index)) {\n" +
|
||||
CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define() + "\n" +
|
||||
"}\n") % (self.descriptor.nativeType)
|
||||
|
||||
if UseHolderForUnforgeable(self.descriptor):
|
||||
getUnforgeable = """if (!JS_GetPropertyDescriptorById(cx, ${holder}, id, flags, desc)) {
|
||||
getUnforgeable = """if (!JS_GetPropertyDescriptorById(cx, ${holder}, id, flags, desc.address())) {
|
||||
return false;
|
||||
}
|
||||
MOZ_ASSERT_IF(desc->obj, desc->obj == ${holder});"""
|
||||
MOZ_ASSERT_IF(desc.object(), desc.object() == ${holder});"""
|
||||
getUnforgeable = CallOnUnforgeableHolder(self.descriptor,
|
||||
getUnforgeable, "isXray")
|
||||
getUnforgeable += """if (desc->obj) {
|
||||
desc->obj = proxy;
|
||||
return !isXray || JS_WrapPropertyDescriptor(cx, desc);
|
||||
getUnforgeable += """if (desc.object()) {
|
||||
desc.object().set(proxy);
|
||||
return !isXray || JS_WrapPropertyDescriptor(cx, desc.address());
|
||||
}
|
||||
|
||||
"""
|
||||
|
@ -7362,8 +7364,7 @@ MOZ_ASSERT_IF(desc->obj, desc->obj == ${holder});"""
|
|||
if self.descriptor.supportsNamedProperties():
|
||||
readonly = toStringBool(self.descriptor.operations['NamedSetter'] is None)
|
||||
fillDescriptor = "FillPropertyDescriptor(desc, proxy, %s);\nreturn true;" % readonly
|
||||
templateValues = {'jsvalRef': 'JS::MutableHandle<JS::Value>::fromMarkedLocation(&desc->value)',
|
||||
'jsvalHandle': 'JS::MutableHandle<JS::Value>::fromMarkedLocation(&desc->value)',
|
||||
templateValues = {'jsvalRef': 'desc.value()', 'jsvalHandle': 'desc.value()',
|
||||
'obj': 'proxy', 'successCode': fillDescriptor}
|
||||
condition = "!HasPropertyOnPrototype(cx, proxy, this, id)"
|
||||
if self.descriptor.interface.getExtendedAttribute('OverrideBuiltins'):
|
||||
|
@ -7380,24 +7381,25 @@ MOZ_ASSERT_IF(desc->obj, desc->obj == ${holder});"""
|
|||
|
||||
return setOrIndexedGet + """JS::Rooted<JSObject*> expando(cx);
|
||||
if (!isXray && (expando = GetExpandoObject(proxy))) {
|
||||
if (!JS_GetPropertyDescriptorById(cx, expando, id, flags, desc)) {
|
||||
if (!JS_GetPropertyDescriptorById(cx, expando, id, flags, desc.address())) {
|
||||
return false;
|
||||
}
|
||||
if (desc->obj) {
|
||||
if (desc.object()) {
|
||||
// Pretend the property lives on the wrapper.
|
||||
desc->obj = proxy;
|
||||
desc.object().set(proxy);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
""" + namedGet + """
|
||||
desc->obj = nullptr;
|
||||
desc.object().set(nullptr);
|
||||
return true;"""
|
||||
|
||||
class CGDOMJSProxyHandler_defineProperty(ClassMethod):
|
||||
def __init__(self, descriptor):
|
||||
args = [Argument('JSContext*', 'cx'), Argument('JS::Handle<JSObject*>', 'proxy'),
|
||||
Argument('JS::Handle<jsid>', 'id'),
|
||||
Argument('JSPropertyDescriptor*', 'desc'), Argument('bool*', 'defined')]
|
||||
Argument('JS::MutableHandle<JSPropertyDescriptor>', 'desc'),
|
||||
Argument('bool*', 'defined')]
|
||||
ClassMethod.__init__(self, "defineProperty", "bool", args, virtual=True, override=True)
|
||||
self.descriptor = descriptor
|
||||
def getBody(self):
|
||||
|
@ -7429,7 +7431,7 @@ class CGDOMJSProxyHandler_defineProperty(ClassMethod):
|
|||
"if (hasUnforgeable) {\n"
|
||||
" *defined = true;" +
|
||||
" bool unused;\n"
|
||||
" return js_DefineOwnProperty(cx, ${holder}, id, *desc, &unused);\n"
|
||||
" return js_DefineOwnProperty(cx, ${holder}, id, desc, &unused);\n"
|
||||
"}\n")
|
||||
set += CallOnUnforgeableHolder(self.descriptor,
|
||||
defineOnUnforgeable,
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace dom {
|
|||
typedef bool
|
||||
(* ResolveOwnProperty)(JSContext* cx, JS::Handle<JSObject*> wrapper,
|
||||
JS::Handle<JSObject*> obj, JS::Handle<jsid> id,
|
||||
JSPropertyDescriptor* desc, unsigned flags);
|
||||
JS::MutableHandle<JSPropertyDescriptor> desc, unsigned flags);
|
||||
|
||||
typedef bool
|
||||
(* EnumerateOwnProperties)(JSContext* cx, JS::Handle<JSObject*> wrapper,
|
||||
|
|
|
@ -161,12 +161,12 @@ DOMProxyHandler::preventExtensions(JSContext *cx, JS::Handle<JSObject*> proxy)
|
|||
|
||||
bool
|
||||
DOMProxyHandler::getPropertyDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id,
|
||||
JSPropertyDescriptor* desc, unsigned flags)
|
||||
MutableHandle<JSPropertyDescriptor> desc, unsigned flags)
|
||||
{
|
||||
if (!getOwnPropertyDescriptor(cx, proxy, id, desc, flags)) {
|
||||
return false;
|
||||
}
|
||||
if (desc->obj) {
|
||||
if (desc.object()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -175,18 +175,18 @@ DOMProxyHandler::getPropertyDescriptor(JSContext* cx, JS::Handle<JSObject*> prox
|
|||
return false;
|
||||
}
|
||||
if (!proto) {
|
||||
desc->obj = NULL;
|
||||
desc.object().set(nullptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
return JS_GetPropertyDescriptorById(cx, proto, id, 0, desc);
|
||||
return JS_GetPropertyDescriptorById(cx, proto, id, 0, desc.address());
|
||||
}
|
||||
|
||||
bool
|
||||
DOMProxyHandler::defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id,
|
||||
JSPropertyDescriptor* desc, bool* defined)
|
||||
MutableHandle<JSPropertyDescriptor> desc, bool* defined)
|
||||
{
|
||||
if ((desc->attrs & JSPROP_GETTER) && desc->setter == JS_StrictPropertyStub) {
|
||||
if (desc.hasGetterObject() && desc.setter() == JS_StrictPropertyStub) {
|
||||
return JS_ReportErrorFlagsAndNumber(cx,
|
||||
JSREPORT_WARNING | JSREPORT_STRICT |
|
||||
JSREPORT_STRICT_MODE_ERROR,
|
||||
|
@ -204,7 +204,7 @@ DOMProxyHandler::defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::
|
|||
}
|
||||
|
||||
bool dummy;
|
||||
return js_DefineOwnProperty(cx, expando, id, *desc, &dummy);
|
||||
return js_DefineOwnProperty(cx, expando, id, desc, &dummy);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -38,15 +38,15 @@ public:
|
|||
|
||||
bool preventExtensions(JSContext *cx, JS::Handle<JSObject*> proxy) MOZ_OVERRIDE;
|
||||
bool getPropertyDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id,
|
||||
JSPropertyDescriptor* desc, unsigned flags) MOZ_OVERRIDE;
|
||||
JS::MutableHandle<JSPropertyDescriptor> desc, unsigned flags) MOZ_OVERRIDE;
|
||||
bool defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id,
|
||||
JSPropertyDescriptor* desc) MOZ_OVERRIDE
|
||||
JS::MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE
|
||||
{
|
||||
bool unused;
|
||||
return defineProperty(cx, proxy, id, desc, &unused);
|
||||
}
|
||||
virtual bool defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id,
|
||||
JSPropertyDescriptor* desc, bool* defined);
|
||||
JS::MutableHandle<JSPropertyDescriptor> desc, bool* defined);
|
||||
bool delete_(JSContext* cx, JS::Handle<JSObject*> proxy,
|
||||
JS::Handle<jsid> id, bool* bp) MOZ_OVERRIDE;
|
||||
bool enumerate(JSContext* cx, JS::Handle<JSObject*> proxy, JS::AutoIdVector& props) MOZ_OVERRIDE;
|
||||
|
@ -123,19 +123,20 @@ IsArrayIndex(int32_t index)
|
|||
}
|
||||
|
||||
inline void
|
||||
FillPropertyDescriptor(JSPropertyDescriptor* desc, JSObject* obj, bool readonly)
|
||||
FillPropertyDescriptor(JS::MutableHandle<JSPropertyDescriptor> desc, JSObject* obj, bool readonly)
|
||||
{
|
||||
desc->obj = obj;
|
||||
desc->attrs = (readonly ? JSPROP_READONLY : 0) | JSPROP_ENUMERATE;
|
||||
desc->getter = NULL;
|
||||
desc->setter = NULL;
|
||||
desc->shortid = 0;
|
||||
desc.object().set(obj);
|
||||
desc.setAttributes((readonly ? JSPROP_READONLY : 0) | JSPROP_ENUMERATE);
|
||||
desc.setGetter(nullptr);
|
||||
desc.setSetter(nullptr);
|
||||
desc.setShortId(0);
|
||||
}
|
||||
|
||||
inline void
|
||||
FillPropertyDescriptor(JSPropertyDescriptor* desc, JSObject* obj, JS::Value v, bool readonly)
|
||||
FillPropertyDescriptor(JS::MutableHandle<JSPropertyDescriptor> desc, JSObject* obj, JS::Value v,
|
||||
bool readonly)
|
||||
{
|
||||
desc->value = v;
|
||||
desc.value().set(v);
|
||||
FillPropertyDescriptor(desc, obj, readonly);
|
||||
}
|
||||
|
||||
|
|
|
@ -188,11 +188,11 @@ JavaScriptChild::AnswerGetPropertyDescriptor(const ObjectId &objId, const nsStri
|
|||
if (!convertGeckoStringToId(cx, id, &internedId))
|
||||
return fail(cx, rs);
|
||||
|
||||
JSPropertyDescriptor desc;
|
||||
if (!JS_GetPropertyDescriptorById(cx, obj, internedId, flags, &desc))
|
||||
Rooted<JSPropertyDescriptor> desc(cx);
|
||||
if (!JS_GetPropertyDescriptorById(cx, obj, internedId, flags, desc.address()))
|
||||
return fail(cx, rs);
|
||||
|
||||
if (!desc.obj)
|
||||
if (!desc.object())
|
||||
return ok(rs);
|
||||
|
||||
if (!fromDescriptor(cx, desc, out))
|
||||
|
@ -221,11 +221,11 @@ JavaScriptChild::AnswerGetOwnPropertyDescriptor(const ObjectId &objId, const nsS
|
|||
if (!convertGeckoStringToId(cx, id, &internedId))
|
||||
return fail(cx, rs);
|
||||
|
||||
JSPropertyDescriptor desc;
|
||||
if (!JS_GetPropertyDescriptorById(cx, obj, internedId, flags, &desc))
|
||||
Rooted<JSPropertyDescriptor> desc(cx);
|
||||
if (!JS_GetPropertyDescriptorById(cx, obj, internedId, flags, desc.address()))
|
||||
return fail(cx, rs);
|
||||
|
||||
if (desc.obj != obj)
|
||||
if (desc.object() != obj)
|
||||
return ok(rs);
|
||||
|
||||
if (!fromDescriptor(cx, desc, out))
|
||||
|
@ -252,7 +252,7 @@ JavaScriptChild::AnswerDefineProperty(const ObjectId &objId, const nsString &id,
|
|||
return fail(cx, rs);
|
||||
|
||||
Rooted<JSPropertyDescriptor> desc(cx);
|
||||
if (!toDescriptor(cx, descriptor, desc.address()))
|
||||
if (!toDescriptor(cx, descriptor, &desc))
|
||||
return false;
|
||||
|
||||
if (!js::CheckDefineProperty(cx, obj, internedId, desc.value(), desc.getter(),
|
||||
|
|
|
@ -62,11 +62,13 @@ class CPOWProxyHandler : public BaseProxyHandler
|
|||
|
||||
virtual bool preventExtensions(JSContext *cx, HandleObject proxy) MOZ_OVERRIDE;
|
||||
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
|
||||
MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags) MOZ_OVERRIDE;
|
||||
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy,
|
||||
HandleId id, PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
|
||||
HandleId id, MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags) MOZ_OVERRIDE;
|
||||
virtual bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc) MOZ_OVERRIDE;
|
||||
MutableHandle<PropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject proxy,
|
||||
AutoIdVector &props) MOZ_OVERRIDE;
|
||||
virtual bool delete_(JSContext *cx, HandleObject proxy, HandleId id, bool *bp) MOZ_OVERRIDE;
|
||||
|
@ -111,14 +113,14 @@ JavaScriptParent::preventExtensions(JSContext *cx, HandleObject proxy)
|
|||
|
||||
bool
|
||||
CPOWProxyHandler::getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags)
|
||||
MutableHandle<PropertyDescriptor> desc, unsigned flags)
|
||||
{
|
||||
return ParentOf(proxy)->getPropertyDescriptor(cx, proxy, id, desc, flags);
|
||||
}
|
||||
|
||||
bool
|
||||
JavaScriptParent::getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags)
|
||||
MutableHandle<PropertyDescriptor> desc, unsigned flags)
|
||||
{
|
||||
ObjectId objId = idOf(proxy);
|
||||
|
||||
|
@ -138,14 +140,15 @@ JavaScriptParent::getPropertyDescriptor(JSContext *cx, HandleObject proxy, Handl
|
|||
|
||||
bool
|
||||
CPOWProxyHandler::getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy,
|
||||
HandleId id, PropertyDescriptor *desc, unsigned flags)
|
||||
HandleId id, MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags)
|
||||
{
|
||||
return ParentOf(proxy)->getOwnPropertyDescriptor(cx, proxy, id, desc, flags);
|
||||
}
|
||||
|
||||
bool
|
||||
JavaScriptParent::getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags)
|
||||
MutableHandle<PropertyDescriptor> desc, unsigned flags)
|
||||
{
|
||||
ObjectId objId = idOf(proxy);
|
||||
|
||||
|
@ -165,14 +168,14 @@ JavaScriptParent::getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, Ha
|
|||
|
||||
bool
|
||||
CPOWProxyHandler::defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc)
|
||||
MutableHandle<PropertyDescriptor> desc)
|
||||
{
|
||||
return ParentOf(proxy)->defineProperty(cx, proxy, id, desc);
|
||||
}
|
||||
|
||||
bool
|
||||
JavaScriptParent::defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc)
|
||||
MutableHandle<PropertyDescriptor> desc)
|
||||
{
|
||||
ObjectId objId = idOf(proxy);
|
||||
|
||||
|
@ -181,7 +184,7 @@ JavaScriptParent::defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
|
|||
return false;
|
||||
|
||||
PPropertyDescriptor descriptor;
|
||||
if (!fromDescriptor(cx, *desc, &descriptor))
|
||||
if (!fromDescriptor(cx, desc, &descriptor))
|
||||
return false;
|
||||
|
||||
ReturnStatus status;
|
||||
|
|
|
@ -34,11 +34,11 @@ class JavaScriptParent
|
|||
// (The traps should be in the same order like js/src/jsproxy.h)
|
||||
bool preventExtensions(JSContext *cx, JS::HandleObject proxy);
|
||||
bool getPropertyDescriptor(JSContext *cx, JS::HandleObject proxy, JS::HandleId id,
|
||||
JSPropertyDescriptor *desc, unsigned flags);
|
||||
JS::MutableHandle<JSPropertyDescriptor> desc, unsigned flags);
|
||||
bool getOwnPropertyDescriptor(JSContext *cx, JS::HandleObject proxy, JS::HandleId id,
|
||||
JSPropertyDescriptor *desc, unsigned flags);
|
||||
JS::MutableHandle<JSPropertyDescriptor> desc, unsigned flags);
|
||||
bool defineProperty(JSContext *cx, JS::HandleObject proxy, JS::HandleId id,
|
||||
JSPropertyDescriptor *desc);
|
||||
JS::MutableHandle<JSPropertyDescriptor> desc);
|
||||
bool getOwnPropertyNames(JSContext *cx, JS::HandleObject proxy, js::AutoIdVector &props);
|
||||
bool delete_(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, bool *bp);
|
||||
bool enumerate(JSContext *cx, JS::HandleObject proxy, js::AutoIdVector &props);
|
||||
|
|
|
@ -313,39 +313,40 @@ static const uint32_t GetterOnlyPropertyStub = 2;
|
|||
static const uint32_t UnknownPropertyOp = 3;
|
||||
|
||||
bool
|
||||
JavaScriptShared::fromDescriptor(JSContext *cx, const JSPropertyDescriptor &desc, PPropertyDescriptor *out)
|
||||
JavaScriptShared::fromDescriptor(JSContext *cx, Handle<JSPropertyDescriptor> desc,
|
||||
PPropertyDescriptor *out)
|
||||
{
|
||||
out->attrs() = desc.attrs;
|
||||
out->shortid() = desc.shortid;
|
||||
if (!toVariant(cx, desc.value, &out->value()))
|
||||
out->attrs() = desc.attributes();
|
||||
out->shortid() = desc.shortid();
|
||||
if (!toVariant(cx, desc.value(), &out->value()))
|
||||
return false;
|
||||
|
||||
if (!makeId(cx, desc.obj, &out->objId()))
|
||||
if (!makeId(cx, desc.object(), &out->objId()))
|
||||
return false;
|
||||
|
||||
if (!desc.getter) {
|
||||
if (!desc.getter()) {
|
||||
out->getter() = 0;
|
||||
} else if (desc.attrs & JSPROP_GETTER) {
|
||||
JSObject *getter = JS_FUNC_TO_DATA_PTR(JSObject *, desc.getter);
|
||||
} else if (desc.hasGetterObject()) {
|
||||
JSObject *getter = desc.getterObject();
|
||||
if (!makeId(cx, getter, &out->getter()))
|
||||
return false;
|
||||
} else {
|
||||
if (desc.getter == JS_PropertyStub)
|
||||
if (desc.getter() == JS_PropertyStub)
|
||||
out->getter() = DefaultPropertyOp;
|
||||
else
|
||||
out->getter() = UnknownPropertyOp;
|
||||
}
|
||||
|
||||
if (!desc.setter) {
|
||||
if (!desc.setter()) {
|
||||
out->setter() = 0;
|
||||
} else if (desc.attrs & JSPROP_SETTER) {
|
||||
JSObject *setter = JS_FUNC_TO_DATA_PTR(JSObject *, desc.setter);
|
||||
} else if (desc.hasSetterObject()) {
|
||||
JSObject *setter = desc.setterObject();
|
||||
if (!makeId(cx, setter, &out->setter()))
|
||||
return false;
|
||||
} else {
|
||||
if (desc.setter == JS_StrictPropertyStub)
|
||||
if (desc.setter() == JS_StrictPropertyStub)
|
||||
out->setter() = DefaultPropertyOp;
|
||||
else if (desc.setter == js_GetterOnlyPropertyStub)
|
||||
else if (desc.setter() == js_GetterOnlyPropertyStub)
|
||||
out->setter() = GetterOnlyPropertyStub;
|
||||
else
|
||||
out->setter() = UnknownPropertyOp;
|
||||
|
@ -369,45 +370,46 @@ UnknownStrictPropertyStub(JSContext *cx, HandleObject obj, HandleId id, bool str
|
|||
}
|
||||
|
||||
bool
|
||||
JavaScriptShared::toDescriptor(JSContext *cx, const PPropertyDescriptor &in, JSPropertyDescriptor *out)
|
||||
JavaScriptShared::toDescriptor(JSContext *cx, const PPropertyDescriptor &in,
|
||||
MutableHandle<JSPropertyDescriptor> out)
|
||||
{
|
||||
out->attrs = in.attrs();
|
||||
out->shortid = in.shortid();
|
||||
if (!toValue(cx, in.value(), &out->value))
|
||||
out.setAttributes(in.attrs());
|
||||
out.setShortId(in.shortid());
|
||||
if (!toValue(cx, in.value(), out.value()))
|
||||
return false;
|
||||
Rooted<JSObject*> obj(cx);
|
||||
if (!unwrap(cx, in.objId(), &obj))
|
||||
return false;
|
||||
out->obj = obj;
|
||||
out.object().set(obj);
|
||||
|
||||
if (!in.getter()) {
|
||||
out->getter = NULL;
|
||||
out.setGetter(nullptr);
|
||||
} else if (in.attrs() & JSPROP_GETTER) {
|
||||
Rooted<JSObject*> getter(cx);
|
||||
if (!unwrap(cx, in.getter(), &getter))
|
||||
return false;
|
||||
out->getter = JS_DATA_TO_FUNC_PTR(JSPropertyOp, getter.get());
|
||||
out.setGetter(JS_DATA_TO_FUNC_PTR(JSPropertyOp, getter.get()));
|
||||
} else {
|
||||
if (in.getter() == DefaultPropertyOp)
|
||||
out->getter = JS_PropertyStub;
|
||||
out.setGetter(JS_PropertyStub);
|
||||
else
|
||||
out->getter = UnknownPropertyStub;
|
||||
out.setGetter(UnknownPropertyStub);
|
||||
}
|
||||
|
||||
if (!in.setter()) {
|
||||
out->setter = NULL;
|
||||
out.setSetter(nullptr);
|
||||
} else if (in.attrs() & JSPROP_SETTER) {
|
||||
Rooted<JSObject*> setter(cx);
|
||||
if (!unwrap(cx, in.setter(), &setter))
|
||||
return false;
|
||||
out->setter = JS_DATA_TO_FUNC_PTR(JSStrictPropertyOp, setter.get());
|
||||
out.setSetter(JS_DATA_TO_FUNC_PTR(JSStrictPropertyOp, setter.get()));
|
||||
} else {
|
||||
if (in.setter() == DefaultPropertyOp)
|
||||
out->setter = JS_StrictPropertyStub;
|
||||
out.setSetter(JS_StrictPropertyStub);
|
||||
else if (in.setter() == GetterOnlyPropertyStub)
|
||||
out->setter = js_GetterOnlyPropertyStub;
|
||||
out.setSetter(js_GetterOnlyPropertyStub);
|
||||
else
|
||||
out->setter = UnknownStrictPropertyStub;
|
||||
out.setSetter(UnknownStrictPropertyStub);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -96,8 +96,9 @@ class JavaScriptShared
|
|||
protected:
|
||||
bool toVariant(JSContext *cx, jsval from, JSVariant *to);
|
||||
bool toValue(JSContext *cx, const JSVariant &from, JS::MutableHandleValue to);
|
||||
bool fromDescriptor(JSContext *cx, const JSPropertyDescriptor &desc, PPropertyDescriptor *out);
|
||||
bool toDescriptor(JSContext *cx, const PPropertyDescriptor &in, JSPropertyDescriptor *out);
|
||||
bool fromDescriptor(JSContext *cx, JS::Handle<JSPropertyDescriptor> desc, PPropertyDescriptor *out);
|
||||
bool toDescriptor(JSContext *cx, const PPropertyDescriptor &in,
|
||||
JS::MutableHandle<JSPropertyDescriptor> out);
|
||||
bool convertIdToGeckoString(JSContext *cx, JS::HandleId id, nsString *to);
|
||||
bool convertGeckoStringToId(JSContext *cx, const nsString &from, JS::MutableHandleId id);
|
||||
|
||||
|
|
|
@ -424,11 +424,11 @@ obj_lookupGetter(JSContext *cx, unsigned argc, Value *vp)
|
|||
// The vanilla getter lookup code below requires that the object is
|
||||
// native. Handle proxies separately.
|
||||
args.rval().setUndefined();
|
||||
AutoPropertyDescriptorRooter desc(cx);
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
if (!Proxy::getPropertyDescriptor(cx, obj, id, &desc, 0))
|
||||
return false;
|
||||
if (desc.obj && (desc.attrs & JSPROP_GETTER) && desc.getter)
|
||||
args.rval().set(CastAsObjectJsval(desc.getter));
|
||||
if (desc.object() && desc.hasGetterObject() && desc.getterObject())
|
||||
args.rval().setObject(*desc.getterObject());
|
||||
return true;
|
||||
}
|
||||
RootedObject pobj(cx);
|
||||
|
@ -460,11 +460,11 @@ obj_lookupSetter(JSContext *cx, unsigned argc, Value *vp)
|
|||
// The vanilla setter lookup code below requires that the object is
|
||||
// native. Handle proxies separately.
|
||||
args.rval().setUndefined();
|
||||
AutoPropertyDescriptorRooter desc(cx);
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
if (!Proxy::getPropertyDescriptor(cx, obj, id, &desc, 0))
|
||||
return false;
|
||||
if (desc.obj && (desc.attrs & JSPROP_SETTER) && desc.setter)
|
||||
args.rval().set(CastAsObjectJsval(desc.setter));
|
||||
if (desc.object() && desc.hasSetterObject() && desc.setterObject())
|
||||
args.rval().setObject(*desc.setterObject());
|
||||
return true;
|
||||
}
|
||||
RootedObject pobj(cx);
|
||||
|
|
|
@ -3117,11 +3117,11 @@ LookupResult(JSContext *cx, HandleObject obj, HandleObject obj2, HandleId id,
|
|||
|
||||
if (!obj2->isNative()) {
|
||||
if (obj2->is<ProxyObject>()) {
|
||||
AutoPropertyDescriptorRooter desc(cx);
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
if (!Proxy::getPropertyDescriptor(cx, obj2, id, &desc, 0))
|
||||
return false;
|
||||
if (!(desc.attrs & JSPROP_SHARED)) {
|
||||
vp.set(desc.value);
|
||||
if (!desc.isShared()) {
|
||||
vp.set(desc.value());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -3595,7 +3595,7 @@ JS_DefineProperties(JSContext *cx, JSObject *objArg, const JSPropertySpec *ps)
|
|||
|
||||
static bool
|
||||
GetPropertyDescriptorById(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
|
||||
bool own, PropertyDescriptor *desc)
|
||||
bool own, MutableHandle<PropertyDescriptor> desc)
|
||||
{
|
||||
RootedObject obj2(cx);
|
||||
RootedShape shape(cx);
|
||||
|
@ -3603,30 +3603,22 @@ GetPropertyDescriptorById(JSContext *cx, HandleObject obj, HandleId id, unsigned
|
|||
if (!LookupPropertyById(cx, obj, id, flags, &obj2, &shape))
|
||||
return false;
|
||||
|
||||
if (!shape || (own && obj != obj2)) {
|
||||
desc->obj = NULL;
|
||||
desc->attrs = 0;
|
||||
desc->getter = NULL;
|
||||
desc->setter = NULL;
|
||||
desc->value.setUndefined();
|
||||
JS_ASSERT(desc.isClear());
|
||||
if (!shape || (own && obj != obj2))
|
||||
return true;
|
||||
}
|
||||
|
||||
desc->obj = obj2;
|
||||
desc.object().set(obj2);
|
||||
if (obj2->isNative()) {
|
||||
if (IsImplicitDenseElement(shape)) {
|
||||
desc->attrs = JSPROP_ENUMERATE;
|
||||
desc->getter = NULL;
|
||||
desc->setter = NULL;
|
||||
desc->value = obj2->getDenseElement(JSID_TO_INT(id));
|
||||
desc.setEnumerable();
|
||||
desc.value().set(obj2->getDenseElement(JSID_TO_INT(id)));
|
||||
} else {
|
||||
desc->attrs = shape->attributes();
|
||||
desc->getter = shape->getter();
|
||||
desc->setter = shape->setter();
|
||||
desc.setAttributes(shape->attributes());
|
||||
desc.setGetter(shape->getter());
|
||||
desc.setSetter(shape->setter());
|
||||
JS_ASSERT(desc.value().isUndefined());
|
||||
if (shape->hasSlot())
|
||||
desc->value = obj2->nativeGetSlot(shape->slot());
|
||||
else
|
||||
desc->value.setUndefined();
|
||||
desc.value().set(obj2->nativeGetSlot(shape->slot()));
|
||||
}
|
||||
} else {
|
||||
if (obj2->is<ProxyObject>()) {
|
||||
|
@ -3635,11 +3627,11 @@ GetPropertyDescriptorById(JSContext *cx, HandleObject obj, HandleId id, unsigned
|
|||
? Proxy::getOwnPropertyDescriptor(cx, obj2, id, desc, 0)
|
||||
: Proxy::getPropertyDescriptor(cx, obj2, id, desc, 0);
|
||||
}
|
||||
if (!JSObject::getGenericAttributes(cx, obj2, id, &desc->attrs))
|
||||
if (!JSObject::getGenericAttributes(cx, obj2, id, &desc.attributesRef()))
|
||||
return false;
|
||||
desc->getter = NULL;
|
||||
desc->setter = NULL;
|
||||
desc->value.setUndefined();
|
||||
JS_ASSERT(desc.getter() == NULL);
|
||||
JS_ASSERT(desc.setter() == NULL);
|
||||
JS_ASSERT(desc.value().isUndefined());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -3650,7 +3642,7 @@ JS_GetPropertyDescriptorById(JSContext *cx, JSObject *objArg, jsid idArg, unsign
|
|||
{
|
||||
RootedObject obj(cx, objArg);
|
||||
RootedId id(cx, idArg);
|
||||
AutoPropertyDescriptorRooter desc(cx);
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
if (!GetPropertyDescriptorById(cx, obj, id, flags, false, &desc))
|
||||
return false;
|
||||
*desc_ = desc;
|
||||
|
@ -3664,16 +3656,16 @@ JS_GetPropertyAttrsGetterAndSetterById(JSContext *cx, JSObject *objArg, jsid idA
|
|||
{
|
||||
RootedObject obj(cx, objArg);
|
||||
RootedId id(cx, idArg);
|
||||
AutoPropertyDescriptorRooter desc(cx);
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
if (!GetPropertyDescriptorById(cx, obj, id, 0, false, &desc))
|
||||
return false;
|
||||
|
||||
*attrsp = desc.attrs;
|
||||
*foundp = (desc.obj != NULL);
|
||||
*attrsp = desc.attributes();
|
||||
*foundp = !!desc.object();
|
||||
if (getterp)
|
||||
*getterp = desc.getter;
|
||||
*getterp = desc.getter();
|
||||
if (setterp)
|
||||
*setterp = desc.setter;
|
||||
*setterp = desc.setter();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -3430,7 +3430,6 @@ template <typename Outer>
|
|||
class PropertyDescriptorOperations
|
||||
{
|
||||
const JSPropertyDescriptor * desc() const { return static_cast<const Outer*>(this)->extract(); }
|
||||
JSPropertyDescriptor * desc() { return static_cast<Outer*>(this)->extract(); }
|
||||
|
||||
public:
|
||||
bool isEnumerable() const { return desc()->attrs & JSPROP_ENUMERATE; }
|
||||
|
@ -3439,19 +3438,17 @@ class PropertyDescriptorOperations
|
|||
bool hasNativeAccessors() const { return desc()->attrs & JSPROP_NATIVE_ACCESSORS; }
|
||||
bool hasGetterObject() const { return desc()->attrs & JSPROP_GETTER; }
|
||||
bool hasSetterObject() const { return desc()->attrs & JSPROP_SETTER; }
|
||||
bool hasGetterOrSetterObject() const { return desc()->attrs & (JSPROP_GETTER | JSPROP_SETTER); }
|
||||
bool isShared() const { return desc()->attrs & JSPROP_SHARED; }
|
||||
bool isIndex() const { return desc()->attrs & JSPROP_INDEX; }
|
||||
bool hasShortId() const { return desc()->attrs & JSPROP_SHORTID; }
|
||||
bool hasAttributes(unsigned attrs) const { return desc()->attrs & attrs; }
|
||||
|
||||
JS::MutableHandle<JSObject*> object() {
|
||||
return JS::MutableHandle<JSObject*>::fromMarkedLocation(&desc()->obj);
|
||||
JS::Handle<JSObject*> object() const {
|
||||
return JS::Handle<JSObject*>::fromMarkedLocation(&desc()->obj);
|
||||
}
|
||||
unsigned attributes() const { return desc()->attrs; }
|
||||
unsigned shortid() const {
|
||||
MOZ_ASSERT(hasShortId());
|
||||
return desc()->shortid;
|
||||
}
|
||||
unsigned shortid() const { return desc()->shortid; }
|
||||
JSPropertyOp getter() const { return desc()->getter; }
|
||||
JSStrictPropertyOp setter() const { return desc()->setter; }
|
||||
JS::Handle<JSObject*> getterObject() const {
|
||||
|
@ -3464,11 +3461,35 @@ class PropertyDescriptorOperations
|
|||
return JS::Handle<JSObject*>::fromMarkedLocation(
|
||||
reinterpret_cast<JSObject *const *>(&desc()->setter));
|
||||
}
|
||||
JS::Handle<Value> value() const {
|
||||
return JS::Handle<Value>::fromMarkedLocation(&desc()->value);
|
||||
}
|
||||
|
||||
bool isClear() const {
|
||||
return desc()->obj == NULL && desc()->attrs == 0 && desc()->getter == NULL &&
|
||||
desc()->setter == NULL && desc()->value.isUndefined();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Outer>
|
||||
class MutablePropertyDescriptorOperations : public PropertyDescriptorOperations<Outer>
|
||||
{
|
||||
JSPropertyDescriptor * desc() { return static_cast<Outer*>(this)->extractMutable(); }
|
||||
|
||||
public:
|
||||
JS::MutableHandle<JSObject*> object() {
|
||||
return JS::MutableHandle<JSObject*>::fromMarkedLocation(&desc()->obj);
|
||||
}
|
||||
unsigned &attributesRef() { return desc()->attrs; }
|
||||
JSPropertyOp &getter() { return desc()->getter; }
|
||||
JSStrictPropertyOp &setter() { return desc()->setter; }
|
||||
JS::MutableHandle<Value> value() {
|
||||
return JS::MutableHandle<Value>::fromMarkedLocation(&desc()->value);
|
||||
}
|
||||
|
||||
void setEnumerable() { desc()->attrs |= JSPROP_ENUMERATE; }
|
||||
void setAttributes(unsigned attrs) { desc()->attrs = attrs; }
|
||||
|
||||
void setShortId(unsigned id) { desc()->shortid = id; }
|
||||
void setGetter(JSPropertyOp op) { desc()->getter = op; }
|
||||
void setSetter(JSStrictPropertyOp op) { desc()->setter = op; }
|
||||
|
@ -3494,13 +3515,14 @@ struct GCMethods<JSPropertyDescriptor> {
|
|||
|
||||
template <>
|
||||
class RootedBase<JSPropertyDescriptor>
|
||||
: public JS::PropertyDescriptorOperations<JS::Rooted<JSPropertyDescriptor> >
|
||||
: public JS::MutablePropertyDescriptorOperations<JS::Rooted<JSPropertyDescriptor> >
|
||||
{
|
||||
friend class JS::PropertyDescriptorOperations<JS::Rooted<JSPropertyDescriptor> >;
|
||||
friend class JS::MutablePropertyDescriptorOperations<JS::Rooted<JSPropertyDescriptor> >;
|
||||
const JSPropertyDescriptor *extract() const {
|
||||
return static_cast<const JS::Rooted<JSPropertyDescriptor>*>(this)->address();
|
||||
}
|
||||
JSPropertyDescriptor *extract() {
|
||||
JSPropertyDescriptor *extractMutable() {
|
||||
return static_cast<JS::Rooted<JSPropertyDescriptor>*>(this)->address();
|
||||
}
|
||||
};
|
||||
|
@ -3513,24 +3535,18 @@ class HandleBase<JSPropertyDescriptor>
|
|||
const JSPropertyDescriptor *extract() const {
|
||||
return static_cast<const JS::Handle<JSPropertyDescriptor>*>(this)->address();
|
||||
}
|
||||
public:
|
||||
JS::Handle<JS::Value> value() const {
|
||||
return JS::Handle<JS::Value>::fromMarkedLocation(&extract()->value);
|
||||
}
|
||||
JS::Handle<JSObject*> obj() const {
|
||||
return JS::Handle<JSObject*>::fromMarkedLocation(&extract()->obj);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
class MutableHandleBase<JSPropertyDescriptor>
|
||||
: public JS::PropertyDescriptorOperations<JS::MutableHandle<JSPropertyDescriptor> >
|
||||
: public JS::MutablePropertyDescriptorOperations<JS::MutableHandle<JSPropertyDescriptor> >
|
||||
{
|
||||
friend class JS::PropertyDescriptorOperations<JS::MutableHandle<JSPropertyDescriptor> >;
|
||||
friend class JS::MutablePropertyDescriptorOperations<JS::MutableHandle<JSPropertyDescriptor> >;
|
||||
const JSPropertyDescriptor *extract() const {
|
||||
return static_cast<const JS::MutableHandle<JSPropertyDescriptor>*>(this)->address();
|
||||
}
|
||||
JSPropertyDescriptor *extract() {
|
||||
JSPropertyDescriptor *extractMutable() {
|
||||
return static_cast<JS::MutableHandle<JSPropertyDescriptor>*>(this)->address();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -418,25 +418,21 @@ JSCompartment::wrap(JSContext *cx, StrictPropertyOp *propp)
|
|||
}
|
||||
|
||||
bool
|
||||
JSCompartment::wrap(JSContext *cx, PropertyDescriptor *desc)
|
||||
JSCompartment::wrap(JSContext *cx, MutableHandle<PropertyDescriptor> desc)
|
||||
{
|
||||
if (!wrap(cx, &desc->obj))
|
||||
if (!wrap(cx, desc.object().address()))
|
||||
return false;
|
||||
|
||||
if (desc->attrs & JSPROP_GETTER) {
|
||||
if (!wrap(cx, &desc->getter))
|
||||
if (desc.hasGetterObject()) {
|
||||
if (!wrap(cx, &desc.getter()))
|
||||
return false;
|
||||
}
|
||||
if (desc->attrs & JSPROP_SETTER) {
|
||||
if (!wrap(cx, &desc->setter))
|
||||
if (desc.hasSetterObject()) {
|
||||
if (!wrap(cx, &desc.setter()))
|
||||
return false;
|
||||
}
|
||||
|
||||
RootedValue value(cx, desc->value);
|
||||
if (!wrap(cx, &value))
|
||||
return false;
|
||||
desc->value = value.get();
|
||||
return true;
|
||||
return wrap(cx, desc.value());
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -295,7 +295,7 @@ struct JSCompartment
|
|||
bool wrapId(JSContext *cx, jsid *idp);
|
||||
bool wrap(JSContext *cx, js::PropertyOp *op);
|
||||
bool wrap(JSContext *cx, js::StrictPropertyOp *op);
|
||||
bool wrap(JSContext *cx, js::PropertyDescriptor *desc);
|
||||
bool wrap(JSContext *cx, JS::MutableHandle<js::PropertyDescriptor> desc);
|
||||
bool wrap(JSContext *cx, js::AutoIdVector &props);
|
||||
|
||||
bool putWrapper(const js::CrossCompartmentKey& wrapped, const js::Value& wrapper);
|
||||
|
|
|
@ -243,9 +243,12 @@ JS_SetCompartmentPrincipals(JSCompartment *compartment, JSPrincipals *principals
|
|||
}
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
JS_WrapPropertyDescriptor(JSContext *cx, js::PropertyDescriptor *desc)
|
||||
JS_WrapPropertyDescriptor(JSContext *cx, js::PropertyDescriptor *descArg)
|
||||
{
|
||||
return cx->compartment()->wrap(cx, desc);
|
||||
Rooted<PropertyDescriptor> desc(cx, *descArg);
|
||||
bool status = cx->compartment()->wrap(cx, &desc);
|
||||
*descArg = desc;
|
||||
return status;
|
||||
}
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
|
@ -1104,17 +1107,18 @@ js::GetObjectMetadata(JSObject *obj)
|
|||
|
||||
JS_FRIEND_API(bool)
|
||||
js_DefineOwnProperty(JSContext *cx, JSObject *objArg, jsid idArg,
|
||||
const js::PropertyDescriptor& descriptor, bool *bp)
|
||||
const js::PropertyDescriptor& descriptorArg, bool *bp)
|
||||
{
|
||||
RootedObject obj(cx, objArg);
|
||||
RootedId id(cx, idArg);
|
||||
Rooted<PropertyDescriptor> descriptor(cx, descriptorArg);
|
||||
JS_ASSERT(cx->runtime()->heapState == js::Idle);
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, id, descriptor.value);
|
||||
if (descriptor.attrs & JSPROP_GETTER)
|
||||
assertSameCompartment(cx, CastAsObjectJsval(descriptor.getter));
|
||||
if (descriptor.attrs & JSPROP_SETTER)
|
||||
assertSameCompartment(cx, CastAsObjectJsval(descriptor.setter));
|
||||
assertSameCompartment(cx, obj, id, descriptor.value());
|
||||
if (descriptor.hasGetterObject())
|
||||
assertSameCompartment(cx, descriptor.getterObject());
|
||||
if (descriptor.hasSetterObject())
|
||||
assertSameCompartment(cx, descriptor.setterObject());
|
||||
|
||||
return DefineOwnProperty(cx, HandleObject(obj), id, descriptor, bp);
|
||||
}
|
||||
|
|
|
@ -185,10 +185,10 @@ js::HasOwnProperty<NoGC>(JSContext *cx, LookupGenericOp lookup,
|
|||
FakeMutableHandle<JSObject*> objp, FakeMutableHandle<Shape*> propp);
|
||||
|
||||
bool
|
||||
js::NewPropertyDescriptorObject(JSContext *cx, const PropertyDescriptor *desc,
|
||||
js::NewPropertyDescriptorObject(JSContext *cx, Handle<PropertyDescriptor> desc,
|
||||
MutableHandleValue vp)
|
||||
{
|
||||
if (!desc->obj) {
|
||||
if (!desc.object()) {
|
||||
vp.setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ js::NewPropertyDescriptorObject(JSContext *cx, const PropertyDescriptor *desc,
|
|||
/* We have our own property, so start creating the descriptor. */
|
||||
AutoPropDescRooter d(cx);
|
||||
|
||||
d.initFromPropertyDescriptor(*desc);
|
||||
d.initFromPropertyDescriptor(desc);
|
||||
if (!d.makeObject(cx))
|
||||
return false;
|
||||
vp.set(d.pd());
|
||||
|
@ -204,20 +204,20 @@ js::NewPropertyDescriptorObject(JSContext *cx, const PropertyDescriptor *desc,
|
|||
}
|
||||
|
||||
void
|
||||
PropDesc::initFromPropertyDescriptor(const PropertyDescriptor &desc)
|
||||
PropDesc::initFromPropertyDescriptor(Handle<PropertyDescriptor> desc)
|
||||
{
|
||||
isUndefined_ = false;
|
||||
pd_.setUndefined();
|
||||
attrs = uint8_t(desc.attrs);
|
||||
attrs = uint8_t(desc.attributes());
|
||||
JS_ASSERT_IF(attrs & JSPROP_READONLY, !(attrs & (JSPROP_GETTER | JSPROP_SETTER)));
|
||||
if (desc.attrs & (JSPROP_GETTER | JSPROP_SETTER)) {
|
||||
if (desc.hasGetterOrSetterObject()) {
|
||||
hasGet_ = true;
|
||||
get_ = ((desc.attrs & JSPROP_GETTER) && desc.getter)
|
||||
? CastAsObjectJsval(desc.getter)
|
||||
get_ = desc.hasGetterObject() && desc.getterObject()
|
||||
? ObjectValue(*desc.getterObject())
|
||||
: UndefinedValue();
|
||||
hasSet_ = true;
|
||||
set_ = ((desc.attrs & JSPROP_SETTER) && desc.setter)
|
||||
? CastAsObjectJsval(desc.setter)
|
||||
set_ = desc.hasSetterObject() && desc.setterObject()
|
||||
? ObjectValue(*desc.setterObject())
|
||||
: UndefinedValue();
|
||||
hasValue_ = false;
|
||||
value_.setUndefined();
|
||||
|
@ -228,7 +228,7 @@ PropDesc::initFromPropertyDescriptor(const PropertyDescriptor &desc)
|
|||
hasSet_ = false;
|
||||
set_.setUndefined();
|
||||
hasValue_ = true;
|
||||
value_ = desc.value;
|
||||
value_ = desc.value();
|
||||
hasWritable_ = true;
|
||||
}
|
||||
hasEnumerable_ = true;
|
||||
|
@ -270,7 +270,7 @@ PropDesc::makeObject(JSContext *cx)
|
|||
|
||||
bool
|
||||
js::GetOwnPropertyDescriptor(JSContext *cx, HandleObject obj, HandleId id,
|
||||
PropertyDescriptor *desc)
|
||||
MutableHandle<PropertyDescriptor> desc)
|
||||
{
|
||||
// FIXME: Call TrapGetOwnProperty directly once ScriptedIndirectProxies is removed
|
||||
if (obj->is<ProxyObject>())
|
||||
|
@ -281,22 +281,22 @@ js::GetOwnPropertyDescriptor(JSContext *cx, HandleObject obj, HandleId id,
|
|||
if (!HasOwnProperty<CanGC>(cx, obj->getOps()->lookupGeneric, obj, id, &pobj, &shape))
|
||||
return false;
|
||||
if (!shape) {
|
||||
desc->obj = NULL;
|
||||
desc.object().set(NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool doGet = true;
|
||||
if (pobj->isNative()) {
|
||||
desc->attrs = GetShapeAttributes(shape);
|
||||
if (desc->attrs & (JSPROP_GETTER | JSPROP_SETTER)) {
|
||||
desc.setAttributes(GetShapeAttributes(shape));
|
||||
if (desc.hasGetterOrSetterObject()) {
|
||||
doGet = false;
|
||||
if (desc->attrs & JSPROP_GETTER)
|
||||
desc->getter = CastAsPropertyOp(shape->getterObject());
|
||||
if (desc->attrs & JSPROP_SETTER)
|
||||
desc->setter = CastAsStrictPropertyOp(shape->setterObject());
|
||||
if (desc.hasGetterObject())
|
||||
desc.setGetterObject(shape->getterObject());
|
||||
if (desc.hasSetterObject())
|
||||
desc.setSetterObject(shape->setterObject());
|
||||
}
|
||||
} else {
|
||||
if (!JSObject::getGenericAttributes(cx, pobj, id, &desc->attrs))
|
||||
if (!JSObject::getGenericAttributes(cx, pobj, id, &desc.attributesRef()))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -304,17 +304,17 @@ js::GetOwnPropertyDescriptor(JSContext *cx, HandleObject obj, HandleId id,
|
|||
if (doGet && !JSObject::getGeneric(cx, obj, obj, id, &value))
|
||||
return false;
|
||||
|
||||
desc->value = value;
|
||||
desc->obj = obj;
|
||||
desc.value().set(value);
|
||||
desc.object().set(obj);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
js::GetOwnPropertyDescriptor(JSContext *cx, HandleObject obj, HandleId id, MutableHandleValue vp)
|
||||
{
|
||||
AutoPropertyDescriptorRooter desc(cx);
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
return GetOwnPropertyDescriptor(cx, obj, id, &desc) &&
|
||||
NewPropertyDescriptorObject(cx, &desc, vp);
|
||||
NewPropertyDescriptorObject(cx, desc, vp);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -568,29 +568,29 @@ js::CheckDefineProperty(JSContext *cx, HandleObject obj, HandleId id, HandleValu
|
|||
|
||||
// ES5 8.12.9 Step 1. Even though we know obj is native, we use generic
|
||||
// APIs for shorter, more readable code.
|
||||
AutoPropertyDescriptorRooter desc(cx);
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
if (!GetOwnPropertyDescriptor(cx, obj, id, &desc))
|
||||
return false;
|
||||
|
||||
// This does not have to check obj's extensibility when !desc.obj (steps
|
||||
// 2-3) because the low-level methods JSObject::{add,put}Property check
|
||||
// for that.
|
||||
if (desc.obj && (desc.attrs & JSPROP_PERMANENT)) {
|
||||
if (desc.object() && desc.isPermanent()) {
|
||||
// Steps 6-11, skipping step 10.a.ii. Prohibit redefining a permanent
|
||||
// property with different metadata, except to make a writable property
|
||||
// non-writable.
|
||||
if (getter != desc.getter ||
|
||||
setter != desc.setter ||
|
||||
(attrs != desc.attrs && attrs != (desc.attrs | JSPROP_READONLY)))
|
||||
if (getter != desc.getter() ||
|
||||
setter != desc.setter() ||
|
||||
(attrs != desc.attributes() && attrs != (desc.attributes() | JSPROP_READONLY)))
|
||||
{
|
||||
return Throw(cx, id, JSMSG_CANT_REDEFINE_PROP);
|
||||
}
|
||||
|
||||
// Step 10.a.ii. Prohibit changing the value of a non-configurable,
|
||||
// non-writable data property.
|
||||
if ((desc.attrs & (JSPROP_GETTER | JSPROP_SETTER | JSPROP_READONLY)) == JSPROP_READONLY) {
|
||||
if ((desc.attributes() & (JSPROP_GETTER | JSPROP_SETTER | JSPROP_READONLY)) == JSPROP_READONLY) {
|
||||
bool same;
|
||||
if (!SameValue(cx, value, desc.value, &same))
|
||||
if (!SameValue(cx, value, desc.value(), &same))
|
||||
return false;
|
||||
if (!same)
|
||||
return JSObject::reportReadOnly(cx, id);
|
||||
|
@ -1024,7 +1024,7 @@ js::DefineOwnProperty(JSContext *cx, HandleObject obj, HandleId id, HandleValue
|
|||
|
||||
bool
|
||||
js::DefineOwnProperty(JSContext *cx, HandleObject obj, HandleId id,
|
||||
const PropertyDescriptor &descriptor, bool *bp)
|
||||
Handle<PropertyDescriptor> descriptor, bool *bp)
|
||||
{
|
||||
AutoPropDescArrayRooter descs(cx);
|
||||
PropDesc *desc = descs.append();
|
||||
|
@ -4548,17 +4548,17 @@ baseops::SetPropertyHelper(JSContext *cx, HandleObject obj, HandleObject receive
|
|||
if (shape) {
|
||||
if (!pobj->isNative()) {
|
||||
if (pobj->is<ProxyObject>()) {
|
||||
AutoPropertyDescriptorRooter pd(cx);
|
||||
Rooted<PropertyDescriptor> pd(cx);
|
||||
if (!Proxy::getPropertyDescriptor(cx, pobj, id, &pd, JSRESOLVE_ASSIGNING))
|
||||
return false;
|
||||
|
||||
if ((pd.attrs & (JSPROP_SHARED | JSPROP_SHADOWABLE)) == JSPROP_SHARED) {
|
||||
return !pd.setter ||
|
||||
CallSetter(cx, receiver, id, pd.setter, pd.attrs, pd.shortid, strict,
|
||||
vp);
|
||||
if ((pd.attributes() & (JSPROP_SHARED | JSPROP_SHADOWABLE)) == JSPROP_SHARED) {
|
||||
return !pd.setter() ||
|
||||
CallSetter(cx, receiver, id, pd.setter(), pd.attributes(),
|
||||
pd.shortid(), strict, vp);
|
||||
}
|
||||
|
||||
if (pd.attrs & JSPROP_READONLY) {
|
||||
if (pd.isReadonly()) {
|
||||
if (strict)
|
||||
return JSObject::reportReadOnly(cx, id, JSREPORT_ERROR);
|
||||
if (cx->hasExtraWarningsOption())
|
||||
|
|
|
@ -1168,7 +1168,7 @@ DefineOwnProperty(JSContext *cx, JS::HandleObject obj, JS::HandleId id,
|
|||
|
||||
extern bool
|
||||
DefineOwnProperty(JSContext *cx, JS::HandleObject obj, JS::HandleId id,
|
||||
const js::PropertyDescriptor &descriptor, bool *bp);
|
||||
JS::Handle<js::PropertyDescriptor> descriptor, bool *bp);
|
||||
|
||||
/*
|
||||
* The NewObjectKind allows an allocation site to specify the type properties
|
||||
|
@ -1343,13 +1343,14 @@ GetPropertyPure(ThreadSafeContext *cx, JSObject *obj, PropertyName *name, Value
|
|||
}
|
||||
|
||||
bool
|
||||
GetOwnPropertyDescriptor(JSContext *cx, HandleObject obj, HandleId id, PropertyDescriptor *desc);
|
||||
GetOwnPropertyDescriptor(JSContext *cx, HandleObject obj, HandleId id,
|
||||
MutableHandle<PropertyDescriptor> desc);
|
||||
|
||||
bool
|
||||
GetOwnPropertyDescriptor(JSContext *cx, HandleObject obj, HandleId id, MutableHandleValue vp);
|
||||
|
||||
bool
|
||||
NewPropertyDescriptorObject(JSContext *cx, const PropertyDescriptor *desc, MutableHandleValue vp);
|
||||
NewPropertyDescriptorObject(JSContext *cx, Handle<PropertyDescriptor> desc, MutableHandleValue vp);
|
||||
|
||||
/*
|
||||
* If obj has an already-resolved data property for id, return true and
|
||||
|
|
|
@ -95,10 +95,10 @@ bool
|
|||
BaseProxyHandler::has(JSContext *cx, HandleObject proxy, HandleId id, bool *bp)
|
||||
{
|
||||
assertEnteredPolicy(cx, proxy, id);
|
||||
AutoPropertyDescriptorRooter desc(cx);
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
if (!getPropertyDescriptor(cx, proxy, id, &desc, 0))
|
||||
return false;
|
||||
*bp = !!desc.obj;
|
||||
*bp = !!desc.object();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -106,10 +106,10 @@ bool
|
|||
BaseProxyHandler::hasOwn(JSContext *cx, HandleObject proxy, HandleId id, bool *bp)
|
||||
{
|
||||
assertEnteredPolicy(cx, proxy, id);
|
||||
AutoPropertyDescriptorRooter desc(cx);
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
if (!getOwnPropertyDescriptor(cx, proxy, id, &desc, 0))
|
||||
return false;
|
||||
*bp = !!desc.obj;
|
||||
*bp = !!desc.object();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -119,30 +119,31 @@ BaseProxyHandler::get(JSContext *cx, HandleObject proxy, HandleObject receiver,
|
|||
{
|
||||
assertEnteredPolicy(cx, proxy, id);
|
||||
|
||||
AutoPropertyDescriptorRooter desc(cx);
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
if (!getPropertyDescriptor(cx, proxy, id, &desc, 0))
|
||||
return false;
|
||||
if (!desc.obj) {
|
||||
if (!desc.object()) {
|
||||
vp.setUndefined();
|
||||
return true;
|
||||
}
|
||||
if (!desc.getter ||
|
||||
(!(desc.attrs & JSPROP_GETTER) && desc.getter == JS_PropertyStub)) {
|
||||
vp.set(desc.value);
|
||||
if (!desc.getter() ||
|
||||
(!desc.hasGetterObject() && desc.getter() == JS_PropertyStub))
|
||||
{
|
||||
vp.set(desc.value());
|
||||
return true;
|
||||
}
|
||||
if (desc.attrs & JSPROP_GETTER)
|
||||
return InvokeGetterOrSetter(cx, receiver, CastAsObjectJsval(desc.getter), 0, NULL, vp);
|
||||
if (!(desc.attrs & JSPROP_SHARED))
|
||||
vp.set(desc.value);
|
||||
if (desc.hasGetterObject())
|
||||
return InvokeGetterOrSetter(cx, receiver, ObjectValue(*desc.getterObject()), 0, NULL, vp);
|
||||
if (!desc.isShared())
|
||||
vp.set(desc.value());
|
||||
else
|
||||
vp.setUndefined();
|
||||
|
||||
if (desc.attrs & JSPROP_SHORTID) {
|
||||
RootedId id(cx, INT_TO_JSID(desc.shortid));
|
||||
return CallJSPropertyOp(cx, desc.getter, receiver, id, vp);
|
||||
if (desc.hasShortId()) {
|
||||
RootedId id(cx, INT_TO_JSID(desc.shortid()));
|
||||
return CallJSPropertyOp(cx, desc.getter(), receiver, id, vp);
|
||||
}
|
||||
return CallJSPropertyOp(cx, desc.getter, receiver, id, vp);
|
||||
return CallJSPropertyOp(cx, desc.getter(), receiver, id, vp);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -172,69 +173,69 @@ BaseProxyHandler::set(JSContext *cx, HandleObject proxy, HandleObject receiver,
|
|||
{
|
||||
assertEnteredPolicy(cx, proxy, id);
|
||||
|
||||
AutoPropertyDescriptorRooter desc(cx);
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
if (!getOwnPropertyDescriptor(cx, proxy, id, &desc, JSRESOLVE_ASSIGNING))
|
||||
return false;
|
||||
/* The control-flow here differs from ::get() because of the fall-through case below. */
|
||||
if (desc.obj) {
|
||||
if (desc.object()) {
|
||||
// Check for read-only properties.
|
||||
if (desc.attrs & JSPROP_READONLY)
|
||||
if (desc.isReadonly())
|
||||
return strict ? Throw(cx, id, JSMSG_CANT_REDEFINE_PROP) : true;
|
||||
if (!desc.setter) {
|
||||
if (!desc.setter()) {
|
||||
// Be wary of the odd explicit undefined setter case possible through
|
||||
// Object.defineProperty.
|
||||
if (!(desc.attrs & JSPROP_SETTER))
|
||||
desc.setter = JS_StrictPropertyStub;
|
||||
} else if ((desc.attrs & JSPROP_SETTER) || desc.setter != JS_StrictPropertyStub) {
|
||||
if (!CallSetter(cx, receiver, id, desc.setter, desc.attrs, desc.shortid, strict, vp))
|
||||
if (!desc.hasSetterObject())
|
||||
desc.setSetter(JS_StrictPropertyStub);
|
||||
} else if (desc.hasSetterObject() || desc.setter() != JS_StrictPropertyStub) {
|
||||
if (!CallSetter(cx, receiver, id, desc.setter(), desc.attributes(), desc.shortid(), strict, vp))
|
||||
return false;
|
||||
if (!proxy->is<ProxyObject>() || proxy->as<ProxyObject>().handler() != this)
|
||||
return true;
|
||||
if (desc.attrs & JSPROP_SHARED)
|
||||
if (desc.isShared())
|
||||
return true;
|
||||
}
|
||||
if (!desc.getter) {
|
||||
if (!desc.getter()) {
|
||||
// Same as above for the null setter case.
|
||||
if (!(desc.attrs & JSPROP_GETTER))
|
||||
desc.getter = JS_PropertyStub;
|
||||
if (!desc.hasGetterObject())
|
||||
desc.setGetter(JS_PropertyStub);
|
||||
}
|
||||
desc.value = vp.get();
|
||||
desc.value().set(vp.get());
|
||||
return defineProperty(cx, receiver, id, &desc);
|
||||
}
|
||||
if (!getPropertyDescriptor(cx, proxy, id, &desc, JSRESOLVE_ASSIGNING))
|
||||
return false;
|
||||
if (desc.obj) {
|
||||
if (desc.object()) {
|
||||
// Check for read-only properties.
|
||||
if (desc.attrs & JSPROP_READONLY)
|
||||
if (desc.isReadonly())
|
||||
return strict ? Throw(cx, id, JSMSG_CANT_REDEFINE_PROP) : true;
|
||||
if (!desc.setter) {
|
||||
if (!desc.setter()) {
|
||||
// Be wary of the odd explicit undefined setter case possible through
|
||||
// Object.defineProperty.
|
||||
if (!(desc.attrs & JSPROP_SETTER))
|
||||
desc.setter = JS_StrictPropertyStub;
|
||||
} else if ((desc.attrs & JSPROP_SETTER) || desc.setter != JS_StrictPropertyStub) {
|
||||
if (!CallSetter(cx, receiver, id, desc.setter, desc.attrs, desc.shortid, strict, vp))
|
||||
if (!desc.hasSetterObject())
|
||||
desc.setSetter(JS_StrictPropertyStub);
|
||||
} else if (desc.hasSetterObject() || desc.setter() != JS_StrictPropertyStub) {
|
||||
if (!CallSetter(cx, receiver, id, desc.setter(), desc.attributes(), desc.shortid(), strict, vp))
|
||||
return false;
|
||||
if (!proxy->is<ProxyObject>() || proxy->as<ProxyObject>().handler() != this)
|
||||
return true;
|
||||
if (desc.attrs & JSPROP_SHARED)
|
||||
if (desc.isShared())
|
||||
return true;
|
||||
}
|
||||
if (!desc.getter) {
|
||||
if (!desc.getter()) {
|
||||
// Same as above for the null setter case.
|
||||
if (!(desc.attrs & JSPROP_GETTER))
|
||||
desc.getter = JS_PropertyStub;
|
||||
if (!desc.hasGetterObject())
|
||||
desc.setGetter(JS_PropertyStub);
|
||||
}
|
||||
desc.value = vp.get();
|
||||
desc.value().set(vp.get());
|
||||
return defineProperty(cx, receiver, id, &desc);
|
||||
}
|
||||
|
||||
desc.obj = receiver;
|
||||
desc.value = vp.get();
|
||||
desc.attrs = JSPROP_ENUMERATE;
|
||||
desc.shortid = 0;
|
||||
desc.getter = NULL;
|
||||
desc.setter = NULL; // Pick up the class getter/setter.
|
||||
desc.object().set(receiver);
|
||||
desc.value().set(vp.get());
|
||||
desc.setAttributes(JSPROP_ENUMERATE);
|
||||
desc.setShortId(0);
|
||||
desc.setGetter(NULL);
|
||||
desc.setSetter(NULL); // Pick up the class getter/setter.
|
||||
return defineProperty(cx, receiver, id, &desc);
|
||||
}
|
||||
|
||||
|
@ -248,7 +249,7 @@ BaseProxyHandler::keys(JSContext *cx, HandleObject proxy, AutoIdVector &props)
|
|||
return false;
|
||||
|
||||
/* Select only the enumerable properties through in-place iteration. */
|
||||
AutoPropertyDescriptorRooter desc(cx);
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
RootedId id(cx);
|
||||
size_t i = 0;
|
||||
for (size_t j = 0, len = props.length(); j < len; j++) {
|
||||
|
@ -257,7 +258,7 @@ BaseProxyHandler::keys(JSContext *cx, HandleObject proxy, AutoIdVector &props)
|
|||
AutoWaivePolicy policy(cx, proxy, id);
|
||||
if (!getOwnPropertyDescriptor(cx, proxy, id, &desc, 0))
|
||||
return false;
|
||||
if (desc.obj && (desc.attrs & JSPROP_ENUMERATE))
|
||||
if (desc.object() && desc.isEnumerable())
|
||||
props[i++] = id;
|
||||
}
|
||||
|
||||
|
@ -365,33 +366,34 @@ BaseProxyHandler::getPrototypeOf(JSContext *cx, HandleObject proxy, MutableHandl
|
|||
|
||||
bool
|
||||
DirectProxyHandler::getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags)
|
||||
MutableHandle<PropertyDescriptor> desc, unsigned flags)
|
||||
{
|
||||
assertEnteredPolicy(cx, proxy, id);
|
||||
JS_ASSERT(!hasPrototype()); // Should never be called if there's a prototype.
|
||||
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
||||
return JS_GetPropertyDescriptorById(cx, target, id, 0, desc);
|
||||
return JS_GetPropertyDescriptorById(cx, target, id, 0, desc.address());
|
||||
}
|
||||
|
||||
static bool
|
||||
GetOwnPropertyDescriptor(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
|
||||
JSPropertyDescriptor *desc)
|
||||
MutableHandle<PropertyDescriptor> desc)
|
||||
{
|
||||
// If obj is a proxy, we can do better than just guessing. This is
|
||||
// important for certain types of wrappers that wrap other wrappers.
|
||||
if (obj->is<ProxyObject>())
|
||||
return Proxy::getOwnPropertyDescriptor(cx, obj, id, desc, flags);
|
||||
|
||||
if (!JS_GetPropertyDescriptorById(cx, obj, id, flags, desc))
|
||||
if (!JS_GetPropertyDescriptorById(cx, obj, id, flags, desc.address()))
|
||||
return false;
|
||||
if (desc->obj != obj)
|
||||
desc->obj = NULL;
|
||||
if (desc.object() != obj)
|
||||
desc.object().set(NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
DirectProxyHandler::getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy,
|
||||
HandleId id, PropertyDescriptor *desc, unsigned flags)
|
||||
HandleId id, MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags)
|
||||
{
|
||||
assertEnteredPolicy(cx, proxy, id);
|
||||
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
||||
|
@ -400,13 +402,13 @@ DirectProxyHandler::getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy,
|
|||
|
||||
bool
|
||||
DirectProxyHandler::defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc)
|
||||
MutableHandle<PropertyDescriptor> desc)
|
||||
{
|
||||
assertEnteredPolicy(cx, proxy, id);
|
||||
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
||||
RootedValue v(cx, desc->value);
|
||||
return CheckDefineProperty(cx, target, id, v, desc->getter, desc->setter, desc->attrs) &&
|
||||
JS_DefinePropertyById(cx, target, id, v, desc->getter, desc->setter, desc->attrs);
|
||||
RootedValue v(cx, desc.value());
|
||||
return CheckDefineProperty(cx, target, id, v, desc.getter(), desc.setter(), desc.attributes()) &&
|
||||
JS_DefinePropertyById(cx, target, id, v, desc.getter(), desc.setter(), desc.attributes());
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -551,10 +553,10 @@ DirectProxyHandler::hasOwn(JSContext *cx, HandleObject proxy, HandleId id, bool
|
|||
{
|
||||
assertEnteredPolicy(cx, proxy, id);
|
||||
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
||||
AutoPropertyDescriptorRooter desc(cx);
|
||||
if (!JS_GetPropertyDescriptorById(cx, target, id, 0, &desc))
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
if (!JS_GetPropertyDescriptorById(cx, target, id, 0, desc.address()))
|
||||
return false;
|
||||
*bp = (desc.obj == target);
|
||||
*bp = (desc.object() == target);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -666,7 +668,7 @@ Trap2(JSContext *cx, HandleObject handler, HandleValue fval, HandleId id, Value
|
|||
|
||||
static bool
|
||||
ParsePropertyDescriptorObject(JSContext *cx, HandleObject obj, const Value &v,
|
||||
PropertyDescriptor *desc, bool complete = false)
|
||||
MutableHandle<PropertyDescriptor> desc, bool complete = false)
|
||||
{
|
||||
AutoPropDescArrayRooter descs(cx);
|
||||
PropDesc *d = descs.append();
|
||||
|
@ -674,20 +676,20 @@ ParsePropertyDescriptorObject(JSContext *cx, HandleObject obj, const Value &v,
|
|||
return false;
|
||||
if (complete)
|
||||
d->complete();
|
||||
desc->obj = obj;
|
||||
desc->value = d->hasValue() ? d->value() : UndefinedValue();
|
||||
desc.object().set(obj);
|
||||
desc.value().set(d->hasValue() ? d->value() : UndefinedValue());
|
||||
JS_ASSERT(!(d->attributes() & JSPROP_SHORTID));
|
||||
desc->attrs = d->attributes();
|
||||
desc->getter = d->getter();
|
||||
desc->setter = d->setter();
|
||||
desc->shortid = 0;
|
||||
desc.setAttributes(d->attributes());
|
||||
desc.setGetter(d->getter());
|
||||
desc.setSetter(d->setter());
|
||||
desc.setShortId(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
IndicatePropertyNotFound(PropertyDescriptor *desc)
|
||||
IndicatePropertyNotFound(MutableHandle<PropertyDescriptor> desc)
|
||||
{
|
||||
desc->obj = NULL;
|
||||
desc.object().set(NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -752,11 +754,13 @@ class ScriptedIndirectProxyHandler : public BaseProxyHandler
|
|||
/* ES5 Harmony fundamental proxy traps. */
|
||||
virtual bool preventExtensions(JSContext *cx, HandleObject proxy) MOZ_OVERRIDE;
|
||||
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
|
||||
MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags) MOZ_OVERRIDE;
|
||||
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
|
||||
MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags) MOZ_OVERRIDE;
|
||||
virtual bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc) MOZ_OVERRIDE;
|
||||
MutableHandle<PropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject proxy, AutoIdVector &props);
|
||||
virtual bool delete_(JSContext *cx, HandleObject proxy, HandleId id, bool *bp) MOZ_OVERRIDE;
|
||||
virtual bool enumerate(JSContext *cx, HandleObject proxy, AutoIdVector &props) MOZ_OVERRIDE;
|
||||
|
@ -835,7 +839,8 @@ GetIndirectProxyHandlerObject(JSObject *proxy)
|
|||
|
||||
bool
|
||||
ScriptedIndirectProxyHandler::getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags)
|
||||
MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags)
|
||||
{
|
||||
RootedObject handler(cx, GetIndirectProxyHandlerObject(proxy));
|
||||
RootedValue fval(cx), value(cx);
|
||||
|
@ -848,7 +853,8 @@ ScriptedIndirectProxyHandler::getPropertyDescriptor(JSContext *cx, HandleObject
|
|||
|
||||
bool
|
||||
ScriptedIndirectProxyHandler::getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags)
|
||||
MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags)
|
||||
{
|
||||
RootedObject handler(cx, GetIndirectProxyHandlerObject(proxy));
|
||||
RootedValue fval(cx), value(cx);
|
||||
|
@ -861,7 +867,7 @@ ScriptedIndirectProxyHandler::getOwnPropertyDescriptor(JSContext *cx, HandleObje
|
|||
|
||||
bool
|
||||
ScriptedIndirectProxyHandler::defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc)
|
||||
MutableHandle<PropertyDescriptor> desc)
|
||||
{
|
||||
RootedObject handler(cx, GetIndirectProxyHandlerObject(proxy));
|
||||
RootedValue fval(cx), value(cx);
|
||||
|
@ -1063,11 +1069,13 @@ class ScriptedDirectProxyHandler : public DirectProxyHandler {
|
|||
/* ES5 Harmony fundamental proxy traps. */
|
||||
virtual bool preventExtensions(JSContext *cx, HandleObject proxy) MOZ_OVERRIDE;
|
||||
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
|
||||
MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags) MOZ_OVERRIDE;
|
||||
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
|
||||
MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags) MOZ_OVERRIDE;
|
||||
virtual bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc) MOZ_OVERRIDE;
|
||||
MutableHandle<PropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject proxy, AutoIdVector &props);
|
||||
virtual bool delete_(JSContext *cx, HandleObject proxy, HandleId id, bool *bp) MOZ_OVERRIDE;
|
||||
virtual bool enumerate(JSContext *cx, HandleObject proxy, AutoIdVector &props) MOZ_OVERRIDE;
|
||||
|
@ -1198,7 +1206,7 @@ static bool
|
|||
ValidateProperty(JSContext *cx, HandleObject obj, HandleId id, PropDesc *desc, bool *bp)
|
||||
{
|
||||
// step 1
|
||||
AutoPropertyDescriptorRooter current(cx);
|
||||
Rooted<PropertyDescriptor> current(cx);
|
||||
if (!GetOwnPropertyDescriptor(cx, obj, id, 0, ¤t))
|
||||
return false;
|
||||
|
||||
|
@ -1206,7 +1214,7 @@ ValidateProperty(JSContext *cx, HandleObject obj, HandleId id, PropDesc *desc, b
|
|||
* steps 2-4 are redundant since ValidateProperty is never called unless
|
||||
* target.[[HasOwn]](P) is true
|
||||
*/
|
||||
JS_ASSERT(current.obj);
|
||||
JS_ASSERT(current.object());
|
||||
|
||||
// step 5
|
||||
if (!desc->hasValue() && !desc->hasWritable() && !desc->hasGet() && !desc->hasSet() &&
|
||||
|
@ -1217,18 +1225,18 @@ ValidateProperty(JSContext *cx, HandleObject obj, HandleId id, PropDesc *desc, b
|
|||
}
|
||||
|
||||
// step 6
|
||||
if ((!desc->hasWritable() || desc->writable() == !(current.attrs & JSPROP_READONLY)) &&
|
||||
(!desc->hasGet() || desc->getter() == current.getter) &&
|
||||
(!desc->hasSet() || desc->setter() == current.setter) &&
|
||||
(!desc->hasEnumerable() || desc->enumerable() == bool(current.attrs & JSPROP_ENUMERATE)) &&
|
||||
(!desc->hasConfigurable() || desc->configurable() == !(current.attrs & JSPROP_PERMANENT)))
|
||||
if ((!desc->hasWritable() || desc->writable() == !current.isReadonly()) &&
|
||||
(!desc->hasGet() || desc->getter() == current.getter()) &&
|
||||
(!desc->hasSet() || desc->setter() == current.setter()) &&
|
||||
(!desc->hasEnumerable() || desc->enumerable() == current.isEnumerable()) &&
|
||||
(!desc->hasConfigurable() || desc->configurable() == !current.isPermanent()))
|
||||
{
|
||||
if (!desc->hasValue()) {
|
||||
*bp = true;
|
||||
return true;
|
||||
}
|
||||
bool same = false;
|
||||
if (!SameValue(cx, desc->value(), current.value, &same))
|
||||
if (!SameValue(cx, desc->value(), current.value(), &same))
|
||||
return false;
|
||||
if (same) {
|
||||
*bp = true;
|
||||
|
@ -1237,14 +1245,14 @@ ValidateProperty(JSContext *cx, HandleObject obj, HandleId id, PropDesc *desc, b
|
|||
}
|
||||
|
||||
// step 7
|
||||
if (current.attrs & JSPROP_PERMANENT) {
|
||||
if (current.isPermanent()) {
|
||||
if (desc->hasConfigurable() && desc->configurable()) {
|
||||
*bp = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (desc->hasEnumerable() &&
|
||||
desc->enumerable() != bool(current.attrs & JSPROP_ENUMERATE))
|
||||
desc->enumerable() != current.isEnumerable())
|
||||
{
|
||||
*bp = false;
|
||||
return true;
|
||||
|
@ -1259,14 +1267,14 @@ ValidateProperty(JSContext *cx, HandleObject obj, HandleId id, PropDesc *desc, b
|
|||
|
||||
// step 9
|
||||
if (IsDataDescriptor(current) != desc->isDataDescriptor()) {
|
||||
*bp = !(current.attrs & JSPROP_PERMANENT);
|
||||
*bp = !current.isPermanent();
|
||||
return true;
|
||||
}
|
||||
|
||||
// step 10
|
||||
if (IsDataDescriptor(current)) {
|
||||
JS_ASSERT(desc->isDataDescriptor()); // by step 9
|
||||
if ((current.attrs & JSPROP_PERMANENT) && (current.attrs & JSPROP_READONLY)) {
|
||||
if (current.isPermanent() && current.isReadonly()) {
|
||||
if (desc->hasWritable() && desc->writable()) {
|
||||
*bp = false;
|
||||
return true;
|
||||
|
@ -1274,7 +1282,7 @@ ValidateProperty(JSContext *cx, HandleObject obj, HandleId id, PropDesc *desc, b
|
|||
|
||||
if (desc->hasValue()) {
|
||||
bool same;
|
||||
if (!SameValue(cx, desc->value(), current.value, &same))
|
||||
if (!SameValue(cx, desc->value(), current.value(), &same))
|
||||
return false;
|
||||
if (!same) {
|
||||
*bp = false;
|
||||
|
@ -1290,9 +1298,9 @@ ValidateProperty(JSContext *cx, HandleObject obj, HandleId id, PropDesc *desc, b
|
|||
// steps 11-12
|
||||
JS_ASSERT(IsAccessorDescriptor(current)); // by step 10
|
||||
JS_ASSERT(desc->isAccessorDescriptor()); // by step 9
|
||||
*bp = (!(current.attrs & JSPROP_PERMANENT) ||
|
||||
((!desc->hasSet() || desc->setter() == current.setter) &&
|
||||
(!desc->hasGet() || desc->getter() == current.getter)));
|
||||
*bp = (!current.isPermanent() ||
|
||||
((!desc->hasSet() || desc->setter() == current.setter()) &&
|
||||
(!desc->hasGet() || desc->getter() == current.getter())));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1301,22 +1309,22 @@ static bool
|
|||
IsSealed(JSContext* cx, HandleObject obj, HandleId id, bool *bp)
|
||||
{
|
||||
// step 1
|
||||
AutoPropertyDescriptorRooter desc(cx);
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
if (!GetOwnPropertyDescriptor(cx, obj, id, 0, &desc))
|
||||
return false;
|
||||
|
||||
// steps 2-3
|
||||
*bp = desc.obj && (desc.attrs & JSPROP_PERMANENT);
|
||||
*bp = desc.object() && desc.isPermanent();
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
HasOwn(JSContext *cx, HandleObject obj, HandleId id, bool *bp)
|
||||
{
|
||||
AutoPropertyDescriptorRooter desc(cx);
|
||||
if (!JS_GetPropertyDescriptorById(cx, obj, id, 0, &desc))
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
if (!JS_GetPropertyDescriptorById(cx, obj, id, 0, desc.address()))
|
||||
return false;
|
||||
*bp = (desc.obj == obj);
|
||||
*bp = (desc.object() == obj);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1348,10 +1356,10 @@ TrapGetOwnProperty(JSContext *cx, HandleObject proxy, HandleId id, MutableHandle
|
|||
|
||||
// step 4
|
||||
if (trap.isUndefined()) {
|
||||
AutoPropertyDescriptorRooter desc(cx);
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
if (!GetOwnPropertyDescriptor(cx, target, id, &desc))
|
||||
return false;
|
||||
return NewPropertyDescriptorObject(cx, &desc, rval);
|
||||
return NewPropertyDescriptorObject(cx, desc, rval);
|
||||
}
|
||||
|
||||
// step 5
|
||||
|
@ -1456,11 +1464,11 @@ TrapDefineOwnProperty(JSContext *cx, HandleObject proxy, HandleId id, MutableHan
|
|||
|
||||
// step 4
|
||||
if (trap.isUndefined()) {
|
||||
AutoPropertyDescriptorRooter desc(cx);
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
if (!ParsePropertyDescriptorObject(cx, proxy, vp, &desc))
|
||||
return false;
|
||||
return JS_DefinePropertyById(cx, target, id, desc.value, desc.getter, desc.setter,
|
||||
desc.attrs);
|
||||
return JS_DefinePropertyById(cx, target, id, desc.value(), desc.getter(), desc.setter(),
|
||||
desc.attributes());
|
||||
}
|
||||
|
||||
// step 5
|
||||
|
@ -1693,27 +1701,29 @@ ScriptedDirectProxyHandler::preventExtensions(JSContext *cx, HandleObject proxy)
|
|||
// FIXME: Move to Proxy::getPropertyDescriptor once ScriptedIndirectProxy is removed
|
||||
bool
|
||||
ScriptedDirectProxyHandler::getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags)
|
||||
MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags)
|
||||
{
|
||||
JS_CHECK_RECURSION(cx, return false);
|
||||
|
||||
if (!GetOwnPropertyDescriptor(cx, proxy, id, desc))
|
||||
return false;
|
||||
if (desc->obj)
|
||||
if (desc.object())
|
||||
return true;
|
||||
RootedObject proto(cx);
|
||||
if (!JSObject::getProto(cx, proxy, &proto))
|
||||
return false;
|
||||
if (!proto) {
|
||||
JS_ASSERT(!desc->obj);
|
||||
JS_ASSERT(!desc.object());
|
||||
return true;
|
||||
}
|
||||
return JS_GetPropertyDescriptorById(cx, proto, id, 0, desc);
|
||||
return JS_GetPropertyDescriptorById(cx, proto, id, 0, desc.address());
|
||||
}
|
||||
|
||||
bool
|
||||
ScriptedDirectProxyHandler::getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags)
|
||||
MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags)
|
||||
{
|
||||
// step 1
|
||||
RootedValue v(cx);
|
||||
|
@ -1722,7 +1732,7 @@ ScriptedDirectProxyHandler::getOwnPropertyDescriptor(JSContext *cx, HandleObject
|
|||
|
||||
// step 2
|
||||
if (v.isUndefined()) {
|
||||
desc->obj = NULL;
|
||||
desc.object().set(NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1732,12 +1742,12 @@ ScriptedDirectProxyHandler::getOwnPropertyDescriptor(JSContext *cx, HandleObject
|
|||
|
||||
bool
|
||||
ScriptedDirectProxyHandler::defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc)
|
||||
MutableHandle<PropertyDescriptor> desc)
|
||||
{
|
||||
// step 1
|
||||
AutoPropDescArrayRooter descs(cx);
|
||||
PropDesc *d = descs.append();
|
||||
d->initFromPropertyDescriptor(*desc);
|
||||
d->initFromPropertyDescriptor(desc);
|
||||
RootedValue v(cx);
|
||||
if (!FromGenericPropertyDescriptor(cx, d, &v))
|
||||
return false;
|
||||
|
@ -2052,18 +2062,15 @@ ScriptedDirectProxyHandler::get(JSContext *cx, HandleObject proxy, HandleObject
|
|||
return false;
|
||||
|
||||
// step 6
|
||||
AutoPropertyDescriptorRooter desc(cx);
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
if (!GetOwnPropertyDescriptor(cx, target, id, &desc))
|
||||
return false;
|
||||
|
||||
// step 7
|
||||
if (desc.obj) {
|
||||
if (IsDataDescriptor(desc) &&
|
||||
(desc.attrs & JSPROP_PERMANENT) &&
|
||||
(desc.attrs & JSPROP_READONLY))
|
||||
{
|
||||
if (desc.object()) {
|
||||
if (IsDataDescriptor(desc) && desc.isPermanent() && desc.isReadonly()) {
|
||||
bool same;
|
||||
if (!SameValue(cx, vp, desc.value, &same))
|
||||
if (!SameValue(cx, vp, desc.value(), &same))
|
||||
return false;
|
||||
if (!same) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_MUST_REPORT_SAME_VALUE);
|
||||
|
@ -2071,10 +2078,7 @@ ScriptedDirectProxyHandler::get(JSContext *cx, HandleObject proxy, HandleObject
|
|||
}
|
||||
}
|
||||
|
||||
if (IsAccessorDescriptor(desc) &&
|
||||
(desc.attrs & JSPROP_PERMANENT) &&
|
||||
!(desc.attrs & JSPROP_GETTER))
|
||||
{
|
||||
if (IsAccessorDescriptor(desc) && desc.isPermanent() && !desc.hasGetterObject()) {
|
||||
if (!trapResult.isUndefined()) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_MUST_REPORT_UNDEFINED);
|
||||
return false;
|
||||
|
@ -2126,15 +2130,14 @@ ScriptedDirectProxyHandler::set(JSContext *cx, HandleObject proxy, HandleObject
|
|||
|
||||
// step 7
|
||||
if (success) {
|
||||
AutoPropertyDescriptorRooter desc(cx);
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
if (!GetOwnPropertyDescriptor(cx, target, id, &desc))
|
||||
return false;
|
||||
|
||||
if (desc.obj) {
|
||||
if (IsDataDescriptor(desc) && (desc.attrs & JSPROP_PERMANENT) &&
|
||||
(desc.attrs & JSPROP_READONLY)) {
|
||||
if (desc.object()) {
|
||||
if (IsDataDescriptor(desc) && desc.isPermanent() && desc.isReadonly()) {
|
||||
bool same;
|
||||
if (!SameValue(cx, vp, desc.value, &same))
|
||||
if (!SameValue(cx, vp, desc.value(), &same))
|
||||
return false;
|
||||
if (!same) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_SET_NW_NC);
|
||||
|
@ -2142,11 +2145,9 @@ ScriptedDirectProxyHandler::set(JSContext *cx, HandleObject proxy, HandleObject
|
|||
}
|
||||
}
|
||||
|
||||
if (IsAccessorDescriptor(desc) && (desc.attrs & JSPROP_PERMANENT)) {
|
||||
if (!(desc.attrs & JSPROP_SETTER)) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_SET_WO_SETTER);
|
||||
return false;
|
||||
}
|
||||
if (IsAccessorDescriptor(desc) && desc.isPermanent() && !desc.hasSetterObject()) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_SET_WO_SETTER);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2296,11 +2297,11 @@ ScriptedDirectProxyHandler ScriptedDirectProxyHandler::singleton;
|
|||
|
||||
bool
|
||||
Proxy::getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags)
|
||||
MutableHandle<PropertyDescriptor> desc, unsigned flags)
|
||||
{
|
||||
JS_CHECK_RECURSION(cx, return false);
|
||||
BaseProxyHandler *handler = proxy->as<ProxyObject>().handler();
|
||||
desc->obj = NULL; // default result if we refuse to perform this action
|
||||
desc.object().set(NULL); // default result if we refuse to perform this action
|
||||
AutoEnterPolicy policy(cx, handler, proxy, id, BaseProxyHandler::GET, true);
|
||||
if (!policy.allowed())
|
||||
return policy.returnValue();
|
||||
|
@ -2308,10 +2309,10 @@ Proxy::getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
|||
return handler->getPropertyDescriptor(cx, proxy, id, desc, flags);
|
||||
if (!handler->getOwnPropertyDescriptor(cx, proxy, id, desc, flags))
|
||||
return false;
|
||||
if (desc->obj)
|
||||
if (desc.object())
|
||||
return true;
|
||||
INVOKE_ON_PROTOTYPE(cx, handler, proxy,
|
||||
JS_GetPropertyDescriptorById(cx, proto, id, 0, desc));
|
||||
JS_GetPropertyDescriptorById(cx, proto, id, 0, desc.address()));
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -2320,20 +2321,20 @@ Proxy::getPropertyDescriptor(JSContext *cx, HandleObject proxy, unsigned flags,
|
|||
{
|
||||
JS_CHECK_RECURSION(cx, return false);
|
||||
|
||||
AutoPropertyDescriptorRooter desc(cx);
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
if (!Proxy::getPropertyDescriptor(cx, proxy, id, &desc, flags))
|
||||
return false;
|
||||
return NewPropertyDescriptorObject(cx, &desc, vp);
|
||||
return NewPropertyDescriptorObject(cx, desc, vp);
|
||||
}
|
||||
|
||||
bool
|
||||
Proxy::getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags)
|
||||
MutableHandle<PropertyDescriptor> desc, unsigned flags)
|
||||
{
|
||||
JS_CHECK_RECURSION(cx, return false);
|
||||
|
||||
BaseProxyHandler *handler = proxy->as<ProxyObject>().handler();
|
||||
desc->obj = NULL; // default result if we refuse to perform this action
|
||||
desc.object().set(NULL); // default result if we refuse to perform this action
|
||||
AutoEnterPolicy policy(cx, handler, proxy, id, BaseProxyHandler::GET, true);
|
||||
if (!policy.allowed())
|
||||
return policy.returnValue();
|
||||
|
@ -2346,14 +2347,15 @@ Proxy::getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, unsigned flag
|
|||
{
|
||||
JS_CHECK_RECURSION(cx, return false);
|
||||
|
||||
AutoPropertyDescriptorRooter desc(cx);
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
if (!Proxy::getOwnPropertyDescriptor(cx, proxy, id, &desc, flags))
|
||||
return false;
|
||||
return NewPropertyDescriptorObject(cx, &desc, vp);
|
||||
return NewPropertyDescriptorObject(cx, desc, vp);
|
||||
}
|
||||
|
||||
bool
|
||||
Proxy::defineProperty(JSContext *cx, HandleObject proxy, HandleId id, PropertyDescriptor *desc)
|
||||
Proxy::defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
MutableHandle<PropertyDescriptor> desc)
|
||||
{
|
||||
JS_CHECK_RECURSION(cx, return false);
|
||||
BaseProxyHandler *handler = proxy->as<ProxyObject>().handler();
|
||||
|
@ -2367,7 +2369,7 @@ bool
|
|||
Proxy::defineProperty(JSContext *cx, HandleObject proxy, HandleId id, HandleValue v)
|
||||
{
|
||||
JS_CHECK_RECURSION(cx, return false);
|
||||
AutoPropertyDescriptorRooter desc(cx);
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
return ParsePropertyDescriptorObject(cx, proxy, v, &desc) &&
|
||||
Proxy::defineProperty(cx, proxy, id, &desc);
|
||||
}
|
||||
|
@ -2542,10 +2544,10 @@ Proxy::set(JSContext *cx, HandleObject proxy, HandleObject receiver, HandleId id
|
|||
if (!handler->getPrototypeOf(cx, proxy, &proto))
|
||||
return false;
|
||||
if (proto) {
|
||||
AutoPropertyDescriptorRooter desc(cx);
|
||||
if (!JS_GetPropertyDescriptorById(cx, proto, id, 0, &desc))
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
if (!JS_GetPropertyDescriptorById(cx, proto, id, 0, desc.address()))
|
||||
return false;
|
||||
if (desc.obj && desc.setter)
|
||||
if (desc.object() && desc.setter())
|
||||
return JSObject::setGeneric(cx, proto, receiver, id, vp, strict);
|
||||
}
|
||||
}
|
||||
|
@ -2788,13 +2790,13 @@ static bool
|
|||
proxy_DefineGeneric(JSContext *cx, HandleObject obj, HandleId id, HandleValue value,
|
||||
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
|
||||
{
|
||||
AutoPropertyDescriptorRooter desc(cx);
|
||||
desc.obj = obj;
|
||||
desc.value = value;
|
||||
desc.attrs = (attrs & (~JSPROP_SHORTID));
|
||||
desc.getter = getter;
|
||||
desc.setter = setter;
|
||||
desc.shortid = 0;
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
desc.object().set(obj);
|
||||
desc.value().set(value);
|
||||
desc.setAttributes(attrs & (~JSPROP_SHORTID));
|
||||
desc.setGetter(getter);
|
||||
desc.setSetter(setter);
|
||||
desc.setShortId(0);
|
||||
return Proxy::defineProperty(cx, obj, id, &desc);
|
||||
}
|
||||
|
||||
|
@ -2900,10 +2902,10 @@ proxy_SetSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid,
|
|||
static bool
|
||||
proxy_GetGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp)
|
||||
{
|
||||
AutoPropertyDescriptorRooter desc(cx);
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
if (!Proxy::getOwnPropertyDescriptor(cx, obj, id, &desc, 0))
|
||||
return false;
|
||||
*attrsp = desc.attrs;
|
||||
*attrsp = desc.attributes();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2934,10 +2936,10 @@ static bool
|
|||
proxy_SetGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp)
|
||||
{
|
||||
/* Lookup the current property descriptor so we have setter/getter/value. */
|
||||
AutoPropertyDescriptorRooter desc(cx);
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
if (!Proxy::getOwnPropertyDescriptor(cx, obj, id, &desc, JSRESOLVE_ASSIGNING))
|
||||
return false;
|
||||
desc.attrs = (*attrsp & (~JSPROP_SHORTID));
|
||||
desc.setAttributes(*attrsp & (~JSPROP_SHORTID));
|
||||
return Proxy::defineProperty(cx, obj, id, &desc);
|
||||
}
|
||||
|
||||
|
|
|
@ -106,12 +106,13 @@ class JS_FRIEND_API(BaseProxyHandler)
|
|||
/* ES5 Harmony fundamental proxy traps. */
|
||||
virtual bool preventExtensions(JSContext *cx, HandleObject proxy) = 0;
|
||||
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags) = 0;
|
||||
MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags) = 0;
|
||||
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy,
|
||||
HandleId id, PropertyDescriptor *desc,
|
||||
HandleId id, MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags) = 0;
|
||||
virtual bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc) = 0;
|
||||
MutableHandle<PropertyDescriptor> desc) = 0;
|
||||
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject proxy,
|
||||
AutoIdVector &props) = 0;
|
||||
virtual bool delete_(JSContext *cx, HandleObject proxy, HandleId id, bool *bp) = 0;
|
||||
|
@ -162,12 +163,12 @@ class JS_PUBLIC_API(DirectProxyHandler) : public BaseProxyHandler
|
|||
/* ES5 Harmony fundamental proxy traps. */
|
||||
virtual bool preventExtensions(JSContext *cx, HandleObject proxy) MOZ_OVERRIDE;
|
||||
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
|
||||
MutableHandle<PropertyDescriptor> desc, unsigned flags) MOZ_OVERRIDE;
|
||||
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy,
|
||||
HandleId id, PropertyDescriptor *desc,
|
||||
HandleId id, MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags) MOZ_OVERRIDE;
|
||||
virtual bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc) MOZ_OVERRIDE;
|
||||
MutableHandle<PropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject proxy,
|
||||
AutoIdVector &props) MOZ_OVERRIDE;
|
||||
virtual bool delete_(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
|
@ -216,14 +217,15 @@ class Proxy
|
|||
/* ES5 Harmony fundamental proxy traps. */
|
||||
static bool preventExtensions(JSContext *cx, HandleObject proxy);
|
||||
static bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags);
|
||||
MutableHandle<PropertyDescriptor> desc, unsigned flags);
|
||||
static bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, unsigned flags, HandleId id,
|
||||
MutableHandleValue vp);
|
||||
static bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags);
|
||||
MutableHandle<PropertyDescriptor> desc, unsigned flags);
|
||||
static bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, unsigned flags, HandleId id,
|
||||
MutableHandleValue vp);
|
||||
static bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id, PropertyDescriptor *desc);
|
||||
static bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
MutableHandle<PropertyDescriptor> desc);
|
||||
static bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id, HandleValue v);
|
||||
static bool getOwnPropertyNames(JSContext *cx, HandleObject proxy, AutoIdVector &props);
|
||||
static bool delete_(JSContext *cx, HandleObject proxy, HandleId id, bool *bp);
|
||||
|
|
|
@ -203,7 +203,7 @@ CrossCompartmentWrapper::preventExtensions(JSContext *cx, HandleObject wrapper)
|
|||
|
||||
bool
|
||||
CrossCompartmentWrapper::getPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags)
|
||||
MutableHandle<PropertyDescriptor> desc, unsigned flags)
|
||||
{
|
||||
RootedId idCopy(cx, id);
|
||||
PIERCE(cx, wrapper,
|
||||
|
@ -214,7 +214,7 @@ CrossCompartmentWrapper::getPropertyDescriptor(JSContext *cx, HandleObject wrapp
|
|||
|
||||
bool
|
||||
CrossCompartmentWrapper::getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper,
|
||||
HandleId id, PropertyDescriptor *desc,
|
||||
HandleId id, MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags)
|
||||
{
|
||||
RootedId idCopy(cx, id);
|
||||
|
@ -226,10 +226,10 @@ CrossCompartmentWrapper::getOwnPropertyDescriptor(JSContext *cx, HandleObject wr
|
|||
|
||||
bool
|
||||
CrossCompartmentWrapper::defineProperty(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||
PropertyDescriptor *desc)
|
||||
MutableHandle<PropertyDescriptor> desc)
|
||||
{
|
||||
RootedId idCopy(cx, id);
|
||||
AutoPropertyDescriptorRooter desc2(cx, desc);
|
||||
Rooted<PropertyDescriptor> desc2(cx, desc);
|
||||
PIERCE(cx, wrapper,
|
||||
cx->compartment()->wrapId(cx, idCopy.address()) && cx->compartment()->wrap(cx, &desc2),
|
||||
Wrapper::defineProperty(cx, wrapper, idCopy, &desc2),
|
||||
|
@ -657,9 +657,9 @@ SecurityWrapper<Base>::regexp_toShared(JSContext *cx, HandleObject obj, RegExpGu
|
|||
template <class Base>
|
||||
bool
|
||||
SecurityWrapper<Base>::defineProperty(JSContext *cx, HandleObject wrapper,
|
||||
HandleId id, PropertyDescriptor *desc)
|
||||
HandleId id, MutableHandle<PropertyDescriptor> desc)
|
||||
{
|
||||
if (desc->getter || desc->setter) {
|
||||
if (desc.getter() || desc.setter()) {
|
||||
JSString *str = IdToString(cx, id);
|
||||
const jschar *prop = str ? str->getCharsZ(cx) : NULL;
|
||||
JS_ReportErrorNumberUC(cx, js_GetErrorMessage, NULL,
|
||||
|
@ -696,7 +696,7 @@ DeadObjectProxy::preventExtensions(JSContext *cx, HandleObject proxy)
|
|||
|
||||
bool
|
||||
DeadObjectProxy::getPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags)
|
||||
MutableHandle<PropertyDescriptor> desc, unsigned flags)
|
||||
{
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_DEAD_OBJECT);
|
||||
return false;
|
||||
|
@ -704,7 +704,7 @@ DeadObjectProxy::getPropertyDescriptor(JSContext *cx, HandleObject wrapper, Hand
|
|||
|
||||
bool
|
||||
DeadObjectProxy::getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags)
|
||||
MutableHandle<PropertyDescriptor> desc, unsigned flags)
|
||||
{
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_DEAD_OBJECT);
|
||||
return false;
|
||||
|
@ -712,7 +712,7 @@ DeadObjectProxy::getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper, H
|
|||
|
||||
bool
|
||||
DeadObjectProxy::defineProperty(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||
PropertyDescriptor *desc)
|
||||
MutableHandle<PropertyDescriptor> desc)
|
||||
{
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_DEAD_OBJECT);
|
||||
return false;
|
||||
|
|
|
@ -81,11 +81,13 @@ class JS_FRIEND_API(CrossCompartmentWrapper) : public Wrapper
|
|||
/* ES5 Harmony fundamental wrapper traps. */
|
||||
virtual bool preventExtensions(JSContext *cx, HandleObject wrapper) MOZ_OVERRIDE;
|
||||
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
|
||||
MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags) MOZ_OVERRIDE;
|
||||
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
|
||||
MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags) MOZ_OVERRIDE;
|
||||
virtual bool defineProperty(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||
PropertyDescriptor *desc) MOZ_OVERRIDE;
|
||||
MutableHandle<PropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject wrapper,
|
||||
AutoIdVector &props) MOZ_OVERRIDE;
|
||||
virtual bool delete_(JSContext *cx, HandleObject wrapper, HandleId id, bool *bp) MOZ_OVERRIDE;
|
||||
|
@ -149,7 +151,7 @@ class JS_FRIEND_API(SecurityWrapper) : public Base
|
|||
JSContext *cx) MOZ_OVERRIDE;
|
||||
virtual bool regexp_toShared(JSContext *cx, HandleObject proxy, RegExpGuard *g) MOZ_OVERRIDE;
|
||||
virtual bool defineProperty(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||
PropertyDescriptor *desc) MOZ_OVERRIDE;
|
||||
MutableHandle<PropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||
|
||||
/*
|
||||
* Allow our subclasses to select the superclass behavior they want without
|
||||
|
@ -172,11 +174,13 @@ class JS_FRIEND_API(DeadObjectProxy) : public BaseProxyHandler
|
|||
/* ES5 Harmony fundamental wrapper traps. */
|
||||
virtual bool preventExtensions(JSContext *cx, HandleObject proxy) MOZ_OVERRIDE;
|
||||
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
|
||||
MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags) MOZ_OVERRIDE;
|
||||
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
|
||||
MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags) MOZ_OVERRIDE;
|
||||
virtual bool defineProperty(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||
PropertyDescriptor *desc) MOZ_OVERRIDE;
|
||||
MutableHandle<PropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject wrapper,
|
||||
AutoIdVector &props) MOZ_OVERRIDE;
|
||||
virtual bool delete_(JSContext *cx, HandleObject wrapper, HandleId id, bool *bp) MOZ_OVERRIDE;
|
||||
|
|
|
@ -2679,7 +2679,7 @@ CopyProperty(JSContext *cx, HandleObject obj, HandleObject referent, HandleId id
|
|||
unsigned lookupFlags, MutableHandleObject objp)
|
||||
{
|
||||
RootedShape shape(cx);
|
||||
AutoPropertyDescriptorRooter desc(cx);
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
unsigned propFlags = 0;
|
||||
RootedObject obj2(cx);
|
||||
|
||||
|
@ -2691,24 +2691,24 @@ CopyProperty(JSContext *cx, HandleObject obj, HandleObject referent, HandleId id
|
|||
return true;
|
||||
|
||||
if (shape->hasSlot()) {
|
||||
desc.value = referent->nativeGetSlot(shape->slot());
|
||||
desc.value().set(referent->nativeGetSlot(shape->slot()));
|
||||
} else {
|
||||
desc.value.setUndefined();
|
||||
desc.value().setUndefined();
|
||||
}
|
||||
|
||||
desc.attrs = shape->attributes();
|
||||
desc.getter = shape->getter();
|
||||
if (!desc.getter && !(desc.attrs & JSPROP_GETTER))
|
||||
desc.getter = JS_PropertyStub;
|
||||
desc.setter = shape->setter();
|
||||
if (!desc.setter && !(desc.attrs & JSPROP_SETTER))
|
||||
desc.setter = JS_StrictPropertyStub;
|
||||
desc.shortid = shape->shortid();
|
||||
desc.setAttributes(shape->attributes());
|
||||
desc.setGetter(shape->getter());
|
||||
if (!desc.getter() && !desc.hasGetterObject())
|
||||
desc.setGetter(JS_PropertyStub);
|
||||
desc.setSetter(shape->setter());
|
||||
if (!desc.setter() && !desc.hasSetterObject())
|
||||
desc.setSetter(JS_StrictPropertyStub);
|
||||
desc.setShortId(shape->shortid());
|
||||
propFlags = shape->getFlags();
|
||||
} else if (referent->is<ProxyObject>()) {
|
||||
if (!Proxy::getOwnPropertyDescriptor(cx, referent, id, &desc, 0))
|
||||
return false;
|
||||
if (!desc.obj)
|
||||
if (!desc.object())
|
||||
return true;
|
||||
} else {
|
||||
if (!JSObject::lookupGeneric(cx, referent, id, objp, &shape))
|
||||
|
@ -2717,21 +2717,20 @@ CopyProperty(JSContext *cx, HandleObject obj, HandleObject referent, HandleId id
|
|||
return true;
|
||||
RootedValue value(cx);
|
||||
if (!JSObject::getGeneric(cx, referent, referent, id, &value) ||
|
||||
!JSObject::getGenericAttributes(cx, referent, id, &desc.attrs))
|
||||
!JSObject::getGenericAttributes(cx, referent, id, &desc.attributesRef()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
desc.value = value;
|
||||
desc.attrs &= JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT;
|
||||
desc.getter = JS_PropertyStub;
|
||||
desc.setter = JS_StrictPropertyStub;
|
||||
desc.shortid = 0;
|
||||
desc.value().set(value);
|
||||
desc.attributesRef() &= JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT;
|
||||
desc.setGetter(JS_PropertyStub);
|
||||
desc.setSetter(JS_StrictPropertyStub);
|
||||
desc.setShortId(0);
|
||||
}
|
||||
|
||||
RootedValue value(cx, desc.value);
|
||||
objp.set(obj);
|
||||
return DefineNativeProperty(cx, obj, id, value, desc.getter, desc.setter,
|
||||
desc.attrs, propFlags, desc.shortid);
|
||||
return DefineNativeProperty(cx, obj, id, desc.value(), desc.getter(), desc.setter(),
|
||||
desc.attributes(), propFlags, desc.shortid());
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
|
@ -4631,7 +4631,7 @@ DebuggerObject_getOwnPropertyDescriptor(JSContext *cx, unsigned argc, Value *vp)
|
|||
return false;
|
||||
|
||||
/* Bug: This can cause the debuggee to run! */
|
||||
AutoPropertyDescriptorRooter desc(cx);
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
{
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, obj);
|
||||
|
@ -4643,28 +4643,26 @@ DebuggerObject_getOwnPropertyDescriptor(JSContext *cx, unsigned argc, Value *vp)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (desc.obj) {
|
||||
if (desc.object()) {
|
||||
/* Rewrap the debuggee values in desc for the debugger. */
|
||||
RootedValue value(cx, desc.value);
|
||||
if (!dbg->wrapDebuggeeValue(cx, &value))
|
||||
if (!dbg->wrapDebuggeeValue(cx, desc.value()))
|
||||
return false;
|
||||
desc.value = value;
|
||||
|
||||
if (desc.attrs & JSPROP_GETTER) {
|
||||
RootedValue get(cx, ObjectOrNullValue(CastAsObject(desc.getter)));
|
||||
if (desc.hasGetterObject()) {
|
||||
RootedValue get(cx, ObjectOrNullValue(desc.getterObject()));
|
||||
if (!dbg->wrapDebuggeeValue(cx, &get))
|
||||
return false;
|
||||
desc.getter = CastAsPropertyOp(get.toObjectOrNull());
|
||||
desc.setGetterObject(get.toObjectOrNull());
|
||||
}
|
||||
if (desc.attrs & JSPROP_SETTER) {
|
||||
RootedValue set(cx, ObjectOrNullValue(CastAsObject(desc.setter)));
|
||||
if (desc.hasSetterObject()) {
|
||||
RootedValue set(cx, ObjectOrNullValue(desc.setterObject()));
|
||||
if (!dbg->wrapDebuggeeValue(cx, &set))
|
||||
return false;
|
||||
desc.setter = CastAsStrictPropertyOp(set.toObjectOrNull());
|
||||
desc.setSetterObject(set.toObjectOrNull());
|
||||
}
|
||||
}
|
||||
|
||||
return NewPropertyDescriptorObject(cx, &desc, args.rval());
|
||||
return NewPropertyDescriptorObject(cx, desc, args.rval());
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
|
@ -238,7 +238,7 @@ struct PropDesc {
|
|||
* makeObject populates pd based on the other fields of *this, creating a
|
||||
* new property descriptor JSObject and defining properties on it.
|
||||
*/
|
||||
void initFromPropertyDescriptor(const PropertyDescriptor &desc);
|
||||
void initFromPropertyDescriptor(Handle<PropertyDescriptor> desc);
|
||||
bool makeObject(JSContext *cx);
|
||||
|
||||
void setUndefined() { isUndefined_ = true; }
|
||||
|
@ -355,7 +355,7 @@ class AutoPropDescRooter : private JS::CustomAutoRooter
|
|||
|
||||
PropDesc& getPropDesc() { return propDesc; }
|
||||
|
||||
void initFromPropertyDescriptor(const PropertyDescriptor &desc) {
|
||||
void initFromPropertyDescriptor(Handle<PropertyDescriptor> desc) {
|
||||
propDesc.initFromPropertyDescriptor(desc);
|
||||
}
|
||||
|
||||
|
|
|
@ -1374,14 +1374,16 @@ class DebugScopeProxy : public BaseProxyHandler
|
|||
return false;
|
||||
}
|
||||
|
||||
bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id, PropertyDescriptor *desc,
|
||||
bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags) MOZ_OVERRIDE
|
||||
{
|
||||
return getOwnPropertyDescriptor(cx, proxy, id, desc, flags);
|
||||
}
|
||||
|
||||
bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE
|
||||
MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags) MOZ_OVERRIDE
|
||||
{
|
||||
Rooted<DebugScopeObject*> debugScope(cx, &proxy->as<DebugScopeObject>());
|
||||
Rooted<ScopeObject*> scope(cx, &debugScope->scope());
|
||||
|
@ -1391,23 +1393,27 @@ class DebugScopeProxy : public BaseProxyHandler
|
|||
return false;
|
||||
|
||||
if (maybeArgsObj) {
|
||||
PodZero(desc);
|
||||
desc->obj = debugScope;
|
||||
desc->attrs = JSPROP_READONLY | JSPROP_ENUMERATE | JSPROP_PERMANENT;
|
||||
desc->value = ObjectValue(*maybeArgsObj);
|
||||
desc.object().set(debugScope);
|
||||
desc.setAttributes(JSPROP_READONLY | JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||
desc.value().setObject(*maybeArgsObj);
|
||||
desc.setShortId(0);
|
||||
desc.setGetter(NULL);
|
||||
desc.setSetter(NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
RootedValue v(cx);
|
||||
if (handleUnaliasedAccess(cx, debugScope, scope, id, GET, &v)) {
|
||||
PodZero(desc);
|
||||
desc->obj = debugScope;
|
||||
desc->attrs = JSPROP_READONLY | JSPROP_ENUMERATE | JSPROP_PERMANENT;
|
||||
desc->value = v;
|
||||
desc.object().set(debugScope);
|
||||
desc.setAttributes(JSPROP_READONLY | JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||
desc.value().set(v);
|
||||
desc.setShortId(0);
|
||||
desc.setGetter(NULL);
|
||||
desc.setSetter(NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
return JS_GetPropertyDescriptorById(cx, scope, id, 0, desc);
|
||||
return JS_GetPropertyDescriptorById(cx, scope, id, 0, desc.address());
|
||||
}
|
||||
|
||||
bool get(JSContext *cx, HandleObject proxy, HandleObject receiver, HandleId id,
|
||||
|
@ -1442,7 +1448,7 @@ class DebugScopeProxy : public BaseProxyHandler
|
|||
}
|
||||
|
||||
bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
PropertyDescriptor *desc) MOZ_OVERRIDE
|
||||
MutableHandle<PropertyDescriptor> desc) MOZ_OVERRIDE
|
||||
{
|
||||
Rooted<ScopeObject*> scope(cx, &proxy->as<DebugScopeObject>().scope());
|
||||
|
||||
|
@ -1452,8 +1458,8 @@ class DebugScopeProxy : public BaseProxyHandler
|
|||
if (found)
|
||||
return Throw(cx, id, JSMSG_CANT_REDEFINE_PROP);
|
||||
|
||||
return JS_DefinePropertyById(cx, scope, id, desc->value, desc->getter, desc->setter,
|
||||
desc->attrs);
|
||||
return JS_DefinePropertyById(cx, scope, id, desc.value(), desc.getter(), desc.setter(),
|
||||
desc.attributes());
|
||||
}
|
||||
|
||||
bool getScopePropertyNames(JSContext *cx, HandleObject proxy, AutoIdVector &props,
|
||||
|
|
|
@ -3134,17 +3134,17 @@ bool
|
|||
xpc::SandboxProxyHandler::getPropertyDescriptor(JSContext *cx,
|
||||
JS::Handle<JSObject*> proxy,
|
||||
JS::Handle<jsid> id,
|
||||
PropertyDescriptor *desc,
|
||||
JS::MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags)
|
||||
{
|
||||
JS::RootedObject obj(cx, wrappedObject(proxy));
|
||||
|
||||
MOZ_ASSERT(js::GetObjectCompartment(obj) == js::GetObjectCompartment(proxy));
|
||||
if (!JS_GetPropertyDescriptorById(cx, obj, id,
|
||||
flags, desc))
|
||||
flags, desc.address()))
|
||||
return false;
|
||||
|
||||
if (!desc->obj)
|
||||
if (!desc.object())
|
||||
return true; // No property, nothing to do
|
||||
|
||||
// Now fix up the getter/setter/value as needed to be bound to desc->obj
|
||||
|
@ -3157,21 +3157,21 @@ xpc::SandboxProxyHandler::getPropertyDescriptor(JSContext *cx,
|
|||
// Similarly, don't mess with XPC_WN_Helper_GetProperty and
|
||||
// XPC_WN_Helper_SetProperty, for the same reasons: that could confuse our
|
||||
// access to expandos when we're not doing Xrays.
|
||||
if (desc->getter != xpc::holder_get &&
|
||||
desc->getter != XPC_WN_Helper_GetProperty &&
|
||||
!BindPropertyOp(cx, desc->getter, desc, id, JSPROP_GETTER, proxy))
|
||||
if (desc.getter() != xpc::holder_get &&
|
||||
desc.getter() != XPC_WN_Helper_GetProperty &&
|
||||
!BindPropertyOp(cx, desc.getter(), desc.address(), id, JSPROP_GETTER, proxy))
|
||||
return false;
|
||||
if (desc->setter != xpc::holder_set &&
|
||||
desc->setter != XPC_WN_Helper_SetProperty &&
|
||||
!BindPropertyOp(cx, desc->setter, desc, id, JSPROP_SETTER, proxy))
|
||||
if (desc.setter() != xpc::holder_set &&
|
||||
desc.setter() != XPC_WN_Helper_SetProperty &&
|
||||
!BindPropertyOp(cx, desc.setter(), desc.address(), id, JSPROP_SETTER, proxy))
|
||||
return false;
|
||||
if (desc->value.isObject()) {
|
||||
JSObject* val = &desc->value.toObject();
|
||||
if (desc.value().isObject()) {
|
||||
JSObject* val = &desc.value().toObject();
|
||||
if (JS_ObjectIsCallable(cx, val)) {
|
||||
val = WrapCallable(cx, val, proxy);
|
||||
if (!val)
|
||||
return false;
|
||||
desc->value = ObjectValue(*val);
|
||||
desc.value().setObject(*val);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3182,14 +3182,14 @@ bool
|
|||
xpc::SandboxProxyHandler::getOwnPropertyDescriptor(JSContext *cx,
|
||||
JS::Handle<JSObject*> proxy,
|
||||
JS::Handle<jsid> id,
|
||||
PropertyDescriptor *desc,
|
||||
JS::MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags)
|
||||
{
|
||||
if (!getPropertyDescriptor(cx, proxy, id, desc, flags))
|
||||
return false;
|
||||
|
||||
if (desc->obj != wrappedObject(proxy))
|
||||
desc->obj = nullptr;
|
||||
if (desc.object() != wrappedObject(proxy))
|
||||
desc.object().set(nullptr);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -30,10 +30,10 @@ AllowedByBase(JSContext *cx, HandleObject wrapper, HandleId id,
|
|||
}
|
||||
|
||||
static bool
|
||||
PropIsFromStandardPrototype(JSContext *cx, JSPropertyDescriptor *desc)
|
||||
PropIsFromStandardPrototype(JSContext *cx, JS::MutableHandle<js::PropertyDescriptor> desc)
|
||||
{
|
||||
MOZ_ASSERT(desc->obj);
|
||||
RootedObject unwrapped(cx, js::UncheckedUnwrap(desc->obj));
|
||||
MOZ_ASSERT(desc.object());
|
||||
RootedObject unwrapped(cx, js::UncheckedUnwrap(desc.object()));
|
||||
JSAutoCompartment ac(cx, unwrapped);
|
||||
return JS_IdentifyClassPrototype(cx, unwrapped) != JSProto_Null;
|
||||
}
|
||||
|
@ -51,24 +51,24 @@ PropIsFromStandardPrototype(JSContext *cx, HandleObject wrapper,
|
|||
Rooted<JSPropertyDescriptor> desc(cx);
|
||||
ChromeObjectWrapper *handler = &ChromeObjectWrapper::singleton;
|
||||
if (!handler->ChromeObjectWrapperBase::getPropertyDescriptor(cx, wrapper, id,
|
||||
desc.address(), 0) ||
|
||||
&desc, 0) ||
|
||||
!desc.object())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return PropIsFromStandardPrototype(cx, desc.address());
|
||||
return PropIsFromStandardPrototype(cx, &desc);
|
||||
}
|
||||
|
||||
bool
|
||||
ChromeObjectWrapper::getPropertyDescriptor(JSContext *cx,
|
||||
HandleObject wrapper,
|
||||
HandleId id,
|
||||
js::PropertyDescriptor *desc,
|
||||
JS::MutableHandle<js::PropertyDescriptor> desc,
|
||||
unsigned flags)
|
||||
{
|
||||
assertEnteredPolicy(cx, wrapper, id);
|
||||
// First, try a lookup on the base wrapper if permitted.
|
||||
desc->obj = NULL;
|
||||
desc.object().set(NULL);
|
||||
if (AllowedByBase(cx, wrapper, id, Wrapper::GET) &&
|
||||
!ChromeObjectWrapperBase::getPropertyDescriptor(cx, wrapper, id,
|
||||
desc, flags)) {
|
||||
|
@ -78,19 +78,19 @@ ChromeObjectWrapper::getPropertyDescriptor(JSContext *cx,
|
|||
// If the property is something that can be found on a standard prototype,
|
||||
// prefer the one we'll get via the prototype chain in the content
|
||||
// compartment.
|
||||
if (desc->obj && PropIsFromStandardPrototype(cx, desc))
|
||||
desc->obj = NULL;
|
||||
if (desc.object() && PropIsFromStandardPrototype(cx, desc))
|
||||
desc.object().set(NULL);
|
||||
|
||||
// If we found something or have no proto, we're done.
|
||||
RootedObject wrapperProto(cx);
|
||||
if (!JS_GetPrototype(cx, wrapper, &wrapperProto))
|
||||
return false;
|
||||
if (desc->obj || !wrapperProto)
|
||||
if (desc.object() || !wrapperProto)
|
||||
return true;
|
||||
|
||||
// If not, try doing the lookup on the prototype.
|
||||
MOZ_ASSERT(js::IsObjectInContextCompartment(wrapper, cx));
|
||||
return JS_GetPropertyDescriptorById(cx, wrapperProto, id, 0, desc);
|
||||
return JS_GetPropertyDescriptorById(cx, wrapperProto, id, 0, desc.address());
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -128,7 +128,6 @@ ChromeObjectWrapper::get(JSContext *cx, HandleObject wrapper,
|
|||
{
|
||||
assertEnteredPolicy(cx, wrapper, id);
|
||||
vp.setUndefined();
|
||||
JSPropertyDescriptor desc;
|
||||
// Only call through to the get trap on the underlying object if we're
|
||||
// allowed to see the property, and if what we'll find is not on a standard
|
||||
// prototype.
|
||||
|
|
|
@ -30,7 +30,8 @@ class ChromeObjectWrapper : public ChromeObjectWrapperBase
|
|||
|
||||
/* Custom traps. */
|
||||
virtual bool getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
||||
JS::Handle<jsid> id, js::PropertyDescriptor *desc,
|
||||
JS::Handle<jsid> id,
|
||||
JS::MutableHandle<js::PropertyDescriptor> desc,
|
||||
unsigned flags) MOZ_OVERRIDE;
|
||||
virtual bool has(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
||||
JS::Handle<jsid> id, bool *bp) MOZ_OVERRIDE;
|
||||
|
|
|
@ -48,13 +48,13 @@ Filter(JSContext *cx, HandleObject wrapper, AutoIdVector &props)
|
|||
|
||||
template <typename Policy>
|
||||
static bool
|
||||
FilterSetter(JSContext *cx, JSObject *wrapper, jsid id, js::PropertyDescriptor *desc)
|
||||
FilterSetter(JSContext *cx, JSObject *wrapper, jsid id, JS::MutableHandle<js::PropertyDescriptor> desc)
|
||||
{
|
||||
bool setAllowed = Policy::check(cx, wrapper, id, Wrapper::SET);
|
||||
if (!setAllowed) {
|
||||
if (JS_IsExceptionPending(cx))
|
||||
return false;
|
||||
desc->setter = nullptr;
|
||||
desc.setSetter(nullptr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -63,7 +63,8 @@ template <typename Base, typename Policy>
|
|||
bool
|
||||
FilteringWrapper<Base, Policy>::getPropertyDescriptor(JSContext *cx, HandleObject wrapper,
|
||||
HandleId id,
|
||||
js::PropertyDescriptor *desc, unsigned flags)
|
||||
JS::MutableHandle<js::PropertyDescriptor> desc,
|
||||
unsigned flags)
|
||||
{
|
||||
assertEnteredPolicy(cx, wrapper, id);
|
||||
if (!Base::getPropertyDescriptor(cx, wrapper, id, desc, flags))
|
||||
|
@ -75,7 +76,7 @@ template <typename Base, typename Policy>
|
|||
bool
|
||||
FilteringWrapper<Base, Policy>::getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper,
|
||||
HandleId id,
|
||||
js::PropertyDescriptor *desc,
|
||||
JS::MutableHandle<js::PropertyDescriptor> desc,
|
||||
unsigned flags)
|
||||
{
|
||||
assertEnteredPolicy(cx, wrapper, id);
|
||||
|
|
|
@ -20,10 +20,12 @@ class FilteringWrapper : public Base {
|
|||
virtual ~FilteringWrapper();
|
||||
|
||||
virtual bool getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
||||
JS::Handle<jsid> id, js::PropertyDescriptor *desc,
|
||||
JS::Handle<jsid> id,
|
||||
JS::MutableHandle<js::PropertyDescriptor> desc,
|
||||
unsigned flags) MOZ_OVERRIDE;
|
||||
virtual bool getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
||||
JS::Handle<jsid> id, js::PropertyDescriptor *desc,
|
||||
JS::Handle<jsid> id,
|
||||
JS::MutableHandle<js::PropertyDescriptor> desc,
|
||||
unsigned flags) MOZ_OVERRIDE;
|
||||
virtual bool getOwnPropertyNames(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
||||
js::AutoIdVector &props) MOZ_OVERRIDE;
|
||||
|
|
|
@ -18,20 +18,20 @@ using namespace JS;
|
|||
namespace xpc {
|
||||
|
||||
static bool
|
||||
WaiveAccessors(JSContext *cx, js::PropertyDescriptor *desc)
|
||||
WaiveAccessors(JSContext *cx, JS::MutableHandle<js::PropertyDescriptor> desc)
|
||||
{
|
||||
if ((desc->attrs & JSPROP_GETTER) && desc->getter) {
|
||||
RootedValue v(cx, JS::ObjectValue(*JS_FUNC_TO_DATA_PTR(JSObject *, desc->getter)));
|
||||
if (desc.hasGetterObject() && desc.getterObject()) {
|
||||
RootedValue v(cx, JS::ObjectValue(*desc.getterObject()));
|
||||
if (!WrapperFactory::WaiveXrayAndWrap(cx, v.address()))
|
||||
return false;
|
||||
desc->getter = js::CastAsJSPropertyOp(&v.toObject());
|
||||
desc.setGetterObject(&v.toObject());
|
||||
}
|
||||
|
||||
if ((desc->attrs & JSPROP_SETTER) && desc->setter) {
|
||||
RootedValue v(cx, JS::ObjectValue(*JS_FUNC_TO_DATA_PTR(JSObject *, desc->setter)));
|
||||
if (desc.hasSetterObject() && desc.setterObject()) {
|
||||
RootedValue v(cx, JS::ObjectValue(*desc.setterObject()));
|
||||
if (!WrapperFactory::WaiveXrayAndWrap(cx, v.address()))
|
||||
return false;
|
||||
desc->setter = js::CastAsJSStrictPropertyOp(&v.toObject());
|
||||
desc.setSetterObject(&v.toObject());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -46,20 +46,20 @@ WaiveXrayWrapper::~WaiveXrayWrapper()
|
|||
|
||||
bool
|
||||
WaiveXrayWrapper::getPropertyDescriptor(JSContext *cx, HandleObject wrapper,
|
||||
HandleId id, js::PropertyDescriptor *desc,
|
||||
HandleId id, JS::MutableHandle<js::PropertyDescriptor> desc,
|
||||
unsigned flags)
|
||||
{
|
||||
return CrossCompartmentWrapper::getPropertyDescriptor(cx, wrapper, id, desc, flags) &&
|
||||
WrapperFactory::WaiveXrayAndWrap(cx, &desc->value) && WaiveAccessors(cx, desc);
|
||||
WrapperFactory::WaiveXrayAndWrap(cx, desc.value().address()) && WaiveAccessors(cx, desc);
|
||||
}
|
||||
|
||||
bool
|
||||
WaiveXrayWrapper::getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper,
|
||||
HandleId id, js::PropertyDescriptor *desc,
|
||||
HandleId id, JS::MutableHandle<js::PropertyDescriptor> desc,
|
||||
unsigned flags)
|
||||
{
|
||||
return CrossCompartmentWrapper::getOwnPropertyDescriptor(cx, wrapper, id, desc, flags) &&
|
||||
WrapperFactory::WaiveXrayAndWrap(cx, &desc->value) && WaiveAccessors(cx, desc);
|
||||
WrapperFactory::WaiveXrayAndWrap(cx, desc.value().address()) && WaiveAccessors(cx, desc);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -21,11 +21,12 @@ class WaiveXrayWrapper : public js::CrossCompartmentWrapper {
|
|||
virtual ~WaiveXrayWrapper();
|
||||
|
||||
virtual bool getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
||||
JS::Handle<jsid> id, js::PropertyDescriptor *desc,
|
||||
JS::Handle<jsid> id,
|
||||
JS::MutableHandle<js::PropertyDescriptor> desc,
|
||||
unsigned flags) MOZ_OVERRIDE;
|
||||
virtual bool getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
||||
JS::Handle<jsid> id,
|
||||
js::PropertyDescriptor *desc,
|
||||
JS::MutableHandle<js::PropertyDescriptor> desc,
|
||||
unsigned flags) MOZ_OVERRIDE;
|
||||
virtual bool get(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> receiver,
|
||||
JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) MOZ_OVERRIDE;
|
||||
|
|
|
@ -134,14 +134,16 @@ public:
|
|||
|
||||
virtual bool resolveNativeProperty(JSContext *cx, HandleObject wrapper,
|
||||
HandleObject holder, HandleId id,
|
||||
JSPropertyDescriptor *desc, unsigned flags) = 0;
|
||||
MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags) = 0;
|
||||
// NB: resolveOwnProperty may decide whether or not to cache what it finds
|
||||
// on the holder. If the result is not cached, the lookup will happen afresh
|
||||
// for each access, which is the right thing for things like dynamic NodeList
|
||||
// properties.
|
||||
virtual bool resolveOwnProperty(JSContext *cx, Wrapper &jsWrapper,
|
||||
HandleObject wrapper, HandleObject holder,
|
||||
HandleId id, JSPropertyDescriptor *desc, unsigned flags);
|
||||
HandleId id, MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags);
|
||||
|
||||
static bool call(JSContext *cx, HandleObject wrapper,
|
||||
const JS::CallArgs &args, js::Wrapper& baseInstance)
|
||||
|
@ -188,12 +190,12 @@ public:
|
|||
|
||||
virtual bool resolveNativeProperty(JSContext *cx, HandleObject wrapper,
|
||||
HandleObject holder, HandleId id,
|
||||
JSPropertyDescriptor *desc, unsigned flags);
|
||||
MutableHandle<JSPropertyDescriptor> desc, unsigned flags);
|
||||
virtual bool resolveOwnProperty(JSContext *cx, Wrapper &jsWrapper, HandleObject wrapper,
|
||||
HandleObject holder, HandleId id,
|
||||
JSPropertyDescriptor *desc, unsigned flags);
|
||||
MutableHandle<PropertyDescriptor> desc, unsigned flags);
|
||||
static bool defineProperty(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||
PropertyDescriptor *desc,
|
||||
MutableHandle<PropertyDescriptor> desc,
|
||||
Handle<PropertyDescriptor> existingDesc, bool *defined);
|
||||
static bool enumerateNames(JSContext *cx, HandleObject wrapper, unsigned flags,
|
||||
AutoIdVector &props);
|
||||
|
@ -234,12 +236,12 @@ public:
|
|||
|
||||
virtual bool resolveNativeProperty(JSContext *cx, HandleObject wrapper,
|
||||
HandleObject holder, HandleId id,
|
||||
JSPropertyDescriptor *desc, unsigned flags);
|
||||
MutableHandle<PropertyDescriptor> desc, unsigned flags);
|
||||
virtual bool resolveOwnProperty(JSContext *cx, Wrapper &jsWrapper, HandleObject wrapper,
|
||||
HandleObject holder, HandleId id,
|
||||
JSPropertyDescriptor *desc, unsigned flags);
|
||||
MutableHandle<PropertyDescriptor> desc, unsigned flags);
|
||||
static bool defineProperty(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||
PropertyDescriptor *desc,
|
||||
MutableHandle<PropertyDescriptor> desc,
|
||||
Handle<PropertyDescriptor> existingDesc, bool *defined);
|
||||
static bool enumerateNames(JSContext *cx, HandleObject wrapper, unsigned flags,
|
||||
AutoIdVector &props);
|
||||
|
@ -692,11 +694,11 @@ XPCWrappedNativeXrayTraits::preserveWrapper(JSObject *target)
|
|||
bool
|
||||
XPCWrappedNativeXrayTraits::resolveNativeProperty(JSContext *cx, HandleObject wrapper,
|
||||
HandleObject holder, HandleId id,
|
||||
JSPropertyDescriptor *desc, unsigned flags)
|
||||
MutableHandle<PropertyDescriptor> desc, unsigned flags)
|
||||
{
|
||||
MOZ_ASSERT(js::GetObjectJSClass(holder) == &HolderClass);
|
||||
|
||||
desc->obj = NULL;
|
||||
desc.object().set(NULL);
|
||||
|
||||
// This will do verification and the method lookup for us.
|
||||
RootedObject target(cx, getTargetObject(wrapper));
|
||||
|
@ -708,7 +710,7 @@ XPCWrappedNativeXrayTraits::resolveNativeProperty(JSContext *cx, HandleObject wr
|
|||
// check for those.
|
||||
if (!JSID_IS_STRING(id)) {
|
||||
/* Not found */
|
||||
return resolveDOMCollectionProperty(cx, wrapper, holder, id, desc, flags);
|
||||
return resolveDOMCollectionProperty(cx, wrapper, holder, id, desc.address(), flags);
|
||||
}
|
||||
|
||||
XPCNativeInterface *iface;
|
||||
|
@ -722,19 +724,19 @@ XPCWrappedNativeXrayTraits::resolveNativeProperty(JSContext *cx, HandleObject wr
|
|||
} else if (!(iface = ccx.GetInterface()) ||
|
||||
!(member = ccx.GetMember())) {
|
||||
/* Not found */
|
||||
return resolveDOMCollectionProperty(cx, wrapper, holder, id, desc, flags);
|
||||
return resolveDOMCollectionProperty(cx, wrapper, holder, id, desc.address(), flags);
|
||||
}
|
||||
|
||||
desc->obj = holder;
|
||||
desc->attrs = JSPROP_ENUMERATE;
|
||||
desc->getter = NULL;
|
||||
desc->setter = NULL;
|
||||
desc->shortid = 0;
|
||||
desc->value = JSVAL_VOID;
|
||||
desc.object().set(holder);
|
||||
desc.setAttributes(JSPROP_ENUMERATE);
|
||||
desc.setGetter(NULL);
|
||||
desc.setSetter(NULL);
|
||||
desc.setShortId(0);
|
||||
desc.value().set(JSVAL_VOID);
|
||||
|
||||
RootedValue fval(cx, JSVAL_VOID);
|
||||
if (member->IsConstant()) {
|
||||
if (!member->GetConstantValue(ccx, iface, &desc->value)) {
|
||||
if (!member->GetConstantValue(ccx, iface, desc.value().address())) {
|
||||
JS_ReportError(cx, "Failed to convert constant native property to JS value");
|
||||
return false;
|
||||
}
|
||||
|
@ -745,16 +747,18 @@ XPCWrappedNativeXrayTraits::resolveNativeProperty(JSContext *cx, HandleObject wr
|
|||
return false;
|
||||
}
|
||||
|
||||
desc->attrs |= JSPROP_GETTER;
|
||||
unsigned attrs = desc.attributes();
|
||||
attrs |= JSPROP_GETTER;
|
||||
if (member->IsWritableAttribute())
|
||||
desc->attrs |= JSPROP_SETTER;
|
||||
attrs |= JSPROP_SETTER;
|
||||
|
||||
// Make the property shared on the holder so no slot is allocated
|
||||
// for it. This avoids keeping garbage alive through that slot.
|
||||
desc->attrs |= JSPROP_SHARED;
|
||||
attrs |= JSPROP_SHARED;
|
||||
desc.setAttributes(attrs);
|
||||
} else {
|
||||
// This is a method. Clone a function for it.
|
||||
if (!member->NewFunctionObject(ccx, iface, wrapper, &desc->value)) {
|
||||
if (!member->NewFunctionObject(ccx, iface, wrapper, desc.value().address())) {
|
||||
JS_ReportError(cx, "Failed to clone function object for native function");
|
||||
return false;
|
||||
}
|
||||
|
@ -763,21 +767,21 @@ XPCWrappedNativeXrayTraits::resolveNativeProperty(JSContext *cx, HandleObject wr
|
|||
// don't have one, we have to avoid calling the scriptable helper's
|
||||
// GetProperty method for this property, so stub out the getter and
|
||||
// setter here explicitly.
|
||||
desc->getter = JS_PropertyStub;
|
||||
desc->setter = JS_StrictPropertyStub;
|
||||
desc.setGetter(JS_PropertyStub);
|
||||
desc.setSetter(JS_StrictPropertyStub);
|
||||
}
|
||||
|
||||
if (!JS_WrapValue(cx, &desc->value) || !JS_WrapValue(cx, fval.address()))
|
||||
if (!JS_WrapValue(cx, desc.value().address()) || !JS_WrapValue(cx, fval.address()))
|
||||
return false;
|
||||
|
||||
if (desc->attrs & JSPROP_GETTER)
|
||||
desc->getter = js::CastAsJSPropertyOp(JSVAL_TO_OBJECT(fval));
|
||||
if (desc->attrs & JSPROP_SETTER)
|
||||
desc->setter = js::CastAsJSStrictPropertyOp(JSVAL_TO_OBJECT(fval));
|
||||
if (desc.hasGetterObject())
|
||||
desc.setGetterObject(&fval.toObject());
|
||||
if (desc.hasSetterObject())
|
||||
desc.setSetterObject(&fval.toObject());
|
||||
|
||||
// Define the property.
|
||||
return JS_DefinePropertyById(cx, holder, id, desc->value,
|
||||
desc->getter, desc->setter, desc->attrs);
|
||||
return JS_DefinePropertyById(cx, holder, id, desc.value(),
|
||||
desc.getter(), desc.setter(), desc.attributes());
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -796,9 +800,9 @@ wrappedJSObject_getter(JSContext *cx, HandleObject wrapper, HandleId id, Mutable
|
|||
bool
|
||||
XrayTraits::resolveOwnProperty(JSContext *cx, Wrapper &jsWrapper,
|
||||
HandleObject wrapper, HandleObject holder, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags)
|
||||
MutableHandle<PropertyDescriptor> desc, unsigned flags)
|
||||
{
|
||||
desc->obj = NULL;
|
||||
desc.object().set(NULL);
|
||||
RootedObject target(cx, getTargetObject(wrapper));
|
||||
RootedObject expando(cx, getExpandoObject(cx, target, wrapper));
|
||||
|
||||
|
@ -806,14 +810,14 @@ XrayTraits::resolveOwnProperty(JSContext *cx, Wrapper &jsWrapper,
|
|||
// in the target compartment.
|
||||
if (expando) {
|
||||
JSAutoCompartment ac(cx, expando);
|
||||
if (!JS_GetPropertyDescriptorById(cx, expando, id, 0, desc))
|
||||
if (!JS_GetPropertyDescriptorById(cx, expando, id, 0, desc.address()))
|
||||
return false;
|
||||
}
|
||||
if (desc->obj) {
|
||||
if (!JS_WrapPropertyDescriptor(cx, desc))
|
||||
if (desc.object()) {
|
||||
if (!JS_WrapPropertyDescriptor(cx, desc.address()))
|
||||
return false;
|
||||
// Pretend the property lives on the wrapper.
|
||||
desc->obj = wrapper;
|
||||
desc.object().set(wrapper);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
|
@ -822,12 +826,13 @@ XrayTraits::resolveOwnProperty(JSContext *cx, Wrapper &jsWrapper,
|
|||
bool
|
||||
XPCWrappedNativeXrayTraits::resolveOwnProperty(JSContext *cx, Wrapper &jsWrapper,
|
||||
HandleObject wrapper, HandleObject holder,
|
||||
HandleId id, PropertyDescriptor *desc, unsigned flags)
|
||||
HandleId id, MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags)
|
||||
{
|
||||
// Call the common code.
|
||||
bool ok = XrayTraits::resolveOwnProperty(cx, jsWrapper, wrapper, holder,
|
||||
id, desc, flags);
|
||||
if (!ok || desc->obj)
|
||||
if (!ok || desc.object())
|
||||
return ok;
|
||||
|
||||
// Check for indexed access on a window.
|
||||
|
@ -847,9 +852,9 @@ XPCWrappedNativeXrayTraits::resolveOwnProperty(JSContext *cx, Wrapper &jsWrapper
|
|||
// It's gone?
|
||||
return xpc::Throw(cx, NS_ERROR_FAILURE);
|
||||
}
|
||||
desc->value = ObjectValue(*obj);
|
||||
desc.value().setObject(*obj);
|
||||
mozilla::dom::FillPropertyDescriptor(desc, wrapper, true);
|
||||
return JS_WrapPropertyDescriptor(cx, desc);
|
||||
return JS_WrapPropertyDescriptor(cx, desc.address());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -897,27 +902,27 @@ XPCWrappedNativeXrayTraits::resolveOwnProperty(JSContext *cx, Wrapper &jsWrapper
|
|||
// return non-|own| properties from Object.getOwnPropertyDescriptor if
|
||||
// lookups are performed in a certain order, but we can probably live with
|
||||
// that until XPCWN Xrays go away with the new DOM bindings.
|
||||
return JS_GetPropertyDescriptorById(cx, holder, id, 0, desc);
|
||||
return JS_GetPropertyDescriptorById(cx, holder, id, 0, desc.address());
|
||||
}
|
||||
|
||||
bool
|
||||
XPCWrappedNativeXrayTraits::defineProperty(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||
PropertyDescriptor *desc,
|
||||
MutableHandle<PropertyDescriptor> desc,
|
||||
Handle<PropertyDescriptor> existingDesc, bool *defined)
|
||||
{
|
||||
*defined = false;
|
||||
JSObject *holder = singleton.ensureHolder(cx, wrapper);
|
||||
if (isResolving(cx, holder, id)) {
|
||||
if (!(desc->attrs & (JSPROP_GETTER | JSPROP_SETTER))) {
|
||||
if (!desc->getter)
|
||||
desc->getter = holder_get;
|
||||
if (!desc->setter)
|
||||
desc->setter = holder_set;
|
||||
if (!desc.hasAttributes(JSPROP_GETTER | JSPROP_SETTER)) {
|
||||
if (!desc.getter())
|
||||
desc.setGetter(holder_get);
|
||||
if (!desc.setter())
|
||||
desc.setSetter(holder_set);
|
||||
}
|
||||
|
||||
*defined = true;
|
||||
return JS_DefinePropertyById(cx, holder, id, desc->value, desc->getter, desc->setter,
|
||||
desc->attrs);
|
||||
return JS_DefinePropertyById(cx, holder, id, desc.value(), desc.getter(), desc.setter(),
|
||||
desc.attributes());
|
||||
}
|
||||
|
||||
// Check for an indexed property on a Window. If that's happening, do
|
||||
|
@ -1024,13 +1029,13 @@ XPCWrappedNativeXrayTraits::construct(JSContext *cx, HandleObject wrapper,
|
|||
bool
|
||||
DOMXrayTraits::resolveNativeProperty(JSContext *cx, HandleObject wrapper,
|
||||
HandleObject holder, HandleId id,
|
||||
JSPropertyDescriptor *desc, unsigned flags)
|
||||
MutableHandle<PropertyDescriptor> desc, unsigned flags)
|
||||
{
|
||||
RootedObject obj(cx, getTargetObject(wrapper));
|
||||
if (!XrayResolveNativeProperty(cx, wrapper, obj, id, desc))
|
||||
if (!XrayResolveNativeProperty(cx, wrapper, obj, id, desc.address()))
|
||||
return false;
|
||||
|
||||
NS_ASSERTION(!desc->obj || desc->obj == wrapper,
|
||||
NS_ASSERTION(!desc.object() || desc.object() == wrapper,
|
||||
"What did we resolve this on?");
|
||||
|
||||
return true;
|
||||
|
@ -1039,19 +1044,19 @@ DOMXrayTraits::resolveNativeProperty(JSContext *cx, HandleObject wrapper,
|
|||
bool
|
||||
DOMXrayTraits::resolveOwnProperty(JSContext *cx, Wrapper &jsWrapper, HandleObject wrapper,
|
||||
HandleObject holder, HandleId id,
|
||||
JSPropertyDescriptor *desc, unsigned flags)
|
||||
MutableHandle<PropertyDescriptor> desc, unsigned flags)
|
||||
{
|
||||
// Call the common code.
|
||||
bool ok = XrayTraits::resolveOwnProperty(cx, jsWrapper, wrapper, holder,
|
||||
id, desc, flags);
|
||||
if (!ok || desc->obj)
|
||||
if (!ok || desc.object())
|
||||
return ok;
|
||||
|
||||
RootedObject obj(cx, getTargetObject(wrapper));
|
||||
if (!XrayResolveOwnProperty(cx, wrapper, obj, id, desc, flags))
|
||||
return false;
|
||||
|
||||
NS_ASSERTION(!desc->obj || desc->obj == wrapper,
|
||||
NS_ASSERTION(!desc.object() || desc.object() == wrapper,
|
||||
"What did we resolve this on?");
|
||||
|
||||
return true;
|
||||
|
@ -1059,10 +1064,10 @@ DOMXrayTraits::resolveOwnProperty(JSContext *cx, Wrapper &jsWrapper, HandleObjec
|
|||
|
||||
bool
|
||||
DOMXrayTraits::defineProperty(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||
PropertyDescriptor *desc,
|
||||
MutableHandle<PropertyDescriptor> desc,
|
||||
Handle<PropertyDescriptor> existingDesc, bool *defined)
|
||||
{
|
||||
if (!existingDesc.obj())
|
||||
if (!existingDesc.object())
|
||||
return true;
|
||||
|
||||
JS::Rooted<JSObject*> obj(cx, getTargetObject(wrapper));
|
||||
|
@ -1202,7 +1207,7 @@ HasNativeProperty(JSContext *cx, HandleObject wrapper, HandleId id, bool *hasPro
|
|||
Maybe<ResolvingId> resolvingId;
|
||||
if (traits == &XPCWrappedNativeXrayTraits::singleton)
|
||||
resolvingId.construct(cx, wrapper, id);
|
||||
if (!traits->resolveOwnProperty(cx, *handler, wrapper, holder, id, desc.address(), 0))
|
||||
if (!traits->resolveOwnProperty(cx, *handler, wrapper, holder, id, &desc, 0))
|
||||
return false;
|
||||
if (desc.object()) {
|
||||
*hasProp = true;
|
||||
|
@ -1219,7 +1224,7 @@ HasNativeProperty(JSContext *cx, HandleObject wrapper, HandleId id, bool *hasPro
|
|||
}
|
||||
|
||||
// Try resolveNativeProperty.
|
||||
if (!traits->resolveNativeProperty(cx, wrapper, holder, id, desc.address(), 0))
|
||||
if (!traits->resolveNativeProperty(cx, wrapper, holder, id, &desc, 0))
|
||||
return false;
|
||||
*hasProp = !!desc.object();
|
||||
return true;
|
||||
|
@ -1335,12 +1340,13 @@ XrayWrapper<Base, Traits>::preventExtensions(JSContext *cx, HandleObject wrapper
|
|||
template <typename Base, typename Traits>
|
||||
bool
|
||||
XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags)
|
||||
JS::MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags)
|
||||
{
|
||||
assertEnteredPolicy(cx, wrapper, id);
|
||||
RootedObject holder(cx, Traits::singleton.ensureHolder(cx, wrapper));
|
||||
if (Traits::isResolving(cx, holder, id)) {
|
||||
desc->obj = NULL;
|
||||
desc.object().set(NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1355,12 +1361,12 @@ XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, HandleObject wra
|
|||
XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
|
||||
if (AccessCheck::wrapperSubsumes(wrapper) &&
|
||||
id == rt->GetStringID(XPCJSRuntime::IDX_WRAPPED_JSOBJECT)) {
|
||||
desc->obj = wrapper;
|
||||
desc->attrs = JSPROP_ENUMERATE|JSPROP_SHARED;
|
||||
desc->getter = wrappedJSObject_getter;
|
||||
desc->setter = NULL;
|
||||
desc->shortid = 0;
|
||||
desc->value = JSVAL_VOID;
|
||||
desc.object().set(wrapper);
|
||||
desc.setAttributes(JSPROP_ENUMERATE|JSPROP_SHARED);
|
||||
desc.setGetter(wrappedJSObject_getter);
|
||||
desc.setSetter(NULL);
|
||||
desc.setShortId(0);
|
||||
desc.value().set(JSVAL_VOID);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1388,10 +1394,10 @@ XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, HandleObject wra
|
|||
return false;
|
||||
|
||||
// Check the holder.
|
||||
if (!desc->obj && !JS_GetPropertyDescriptorById(cx, holder, id, 0, desc))
|
||||
if (!desc.object() && !JS_GetPropertyDescriptorById(cx, holder, id, 0, desc.address()))
|
||||
return false;
|
||||
if (desc->obj) {
|
||||
desc->obj = wrapper;
|
||||
if (desc.object()) {
|
||||
desc.object().set(wrapper);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1406,7 +1412,7 @@ XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, HandleObject wra
|
|||
// resolveNativeProperty, which we don't want for something dynamic like
|
||||
// named access. So we just handle it separately here.
|
||||
nsGlobalWindow *win;
|
||||
if (!desc->obj && Traits::Type == XrayForWrappedNative && JSID_IS_STRING(id) &&
|
||||
if (!desc.object() && Traits::Type == XrayForWrappedNative && JSID_IS_STRING(id) &&
|
||||
(win = static_cast<nsGlobalWindow*>(As<nsPIDOMWindow>(wrapper))))
|
||||
{
|
||||
nsDependentJSString name(id);
|
||||
|
@ -1419,11 +1425,11 @@ XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, HandleObject wra
|
|||
mozilla::dom::FillPropertyDescriptor(desc, wrapper,
|
||||
ObjectValue(*childObj),
|
||||
/* readOnly = */ true);
|
||||
return JS_WrapPropertyDescriptor(cx, desc);
|
||||
return JS_WrapPropertyDescriptor(cx, desc.address());
|
||||
}
|
||||
}
|
||||
|
||||
if (!desc->obj &&
|
||||
if (!desc.object() &&
|
||||
id == nsXPConnect::GetRuntimeInstance()->GetStringID(XPCJSRuntime::IDX_TO_STRING))
|
||||
{
|
||||
|
||||
|
@ -1431,12 +1437,12 @@ XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, HandleObject wra
|
|||
if (!toString)
|
||||
return false;
|
||||
|
||||
desc->obj = wrapper;
|
||||
desc->attrs = 0;
|
||||
desc->getter = NULL;
|
||||
desc->setter = NULL;
|
||||
desc->shortid = 0;
|
||||
desc->value.setObject(*JS_GetFunctionObject(toString));
|
||||
desc.object().set(wrapper);
|
||||
desc.setAttributes(0);
|
||||
desc.setGetter(NULL);
|
||||
desc.setSetter(NULL);
|
||||
desc.setShortId(0);
|
||||
desc.value().setObject(*JS_GetFunctionObject(toString));
|
||||
}
|
||||
|
||||
// If we're a special scope for in-content XBL, our script expects to see
|
||||
|
@ -1454,39 +1460,40 @@ XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, HandleObject wra
|
|||
//
|
||||
// Make sure to assert this.
|
||||
nsCOMPtr<nsIContent> content;
|
||||
if (!desc->obj &&
|
||||
if (!desc.object() &&
|
||||
EnsureCompartmentPrivate(wrapper)->scope->IsXBLScope() &&
|
||||
(content = do_QueryInterfaceNative(cx, wrapper)))
|
||||
{
|
||||
if (!nsContentUtils::LookupBindingMember(cx, content, id, desc))
|
||||
if (!nsContentUtils::LookupBindingMember(cx, content, id, desc.address()))
|
||||
return false;
|
||||
DEBUG_CheckXBLLookup(cx, desc);
|
||||
DEBUG_CheckXBLLookup(cx, desc.address());
|
||||
}
|
||||
|
||||
// If we still have nothing, we're done.
|
||||
if (!desc->obj)
|
||||
if (!desc.object())
|
||||
return true;
|
||||
|
||||
if (!JS_DefinePropertyById(cx, holder, id, desc->value, desc->getter,
|
||||
desc->setter, desc->attrs) ||
|
||||
!JS_GetPropertyDescriptorById(cx, holder, id, flags, desc))
|
||||
if (!JS_DefinePropertyById(cx, holder, id, desc.value(), desc.getter(),
|
||||
desc.setter(), desc.attributes()) ||
|
||||
!JS_GetPropertyDescriptorById(cx, holder, id, flags, desc.address()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
MOZ_ASSERT(desc->obj);
|
||||
desc->obj = wrapper;
|
||||
MOZ_ASSERT(desc.object());
|
||||
desc.object().set(wrapper);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Base, typename Traits>
|
||||
bool
|
||||
XrayWrapper<Base, Traits>::getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||
PropertyDescriptor *desc, unsigned flags)
|
||||
JS::MutableHandle<PropertyDescriptor> desc,
|
||||
unsigned flags)
|
||||
{
|
||||
assertEnteredPolicy(cx, wrapper, id);
|
||||
RootedObject holder(cx, Traits::singleton.ensureHolder(cx, wrapper));
|
||||
if (Traits::isResolving(cx, holder, id)) {
|
||||
desc->obj = NULL;
|
||||
desc.object().set(NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1497,8 +1504,8 @@ XrayWrapper<Base, Traits>::getOwnPropertyDescriptor(JSContext *cx, HandleObject
|
|||
|
||||
if (!Traits::singleton.resolveOwnProperty(cx, *this, wrapper, holder, id, desc, flags))
|
||||
return false;
|
||||
if (desc->obj)
|
||||
desc->obj = wrapper;
|
||||
if (desc.object())
|
||||
desc.object().set(wrapper);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1562,14 +1569,14 @@ RecreateLostWaivers(JSContext *cx, PropertyDescriptor *orig,
|
|||
template <typename Base, typename Traits>
|
||||
bool
|
||||
XrayWrapper<Base, Traits>::defineProperty(JSContext *cx, HandleObject wrapper,
|
||||
HandleId id, PropertyDescriptor *desc)
|
||||
HandleId id, MutableHandle<PropertyDescriptor> desc)
|
||||
{
|
||||
assertEnteredPolicy(cx, wrapper, id);
|
||||
|
||||
// NB: We still need JSRESOLVE_ASSIGNING here for the time being, because it
|
||||
// tells things like nodelists whether they should create the property or not.
|
||||
Rooted<PropertyDescriptor> existing_desc(cx);
|
||||
if (!getOwnPropertyDescriptor(cx, wrapper, id, existing_desc.address(), JSRESOLVE_ASSIGNING))
|
||||
if (!getOwnPropertyDescriptor(cx, wrapper, id, &existing_desc, JSRESOLVE_ASSIGNING))
|
||||
return false;
|
||||
|
||||
if (existing_desc.object() && existing_desc.isPermanent())
|
||||
|
@ -1593,12 +1600,12 @@ XrayWrapper<Base, Traits>::defineProperty(JSContext *cx, HandleObject wrapper,
|
|||
return false;
|
||||
|
||||
// Wrap the property descriptor for the target compartment.
|
||||
Rooted<PropertyDescriptor> wrappedDesc(cx, *desc);
|
||||
Rooted<PropertyDescriptor> wrappedDesc(cx, desc);
|
||||
if (!JS_WrapPropertyDescriptor(cx, wrappedDesc.address()))
|
||||
return false;
|
||||
|
||||
// Fix up Xray waivers.
|
||||
if (!RecreateLostWaivers(cx, desc, &wrappedDesc))
|
||||
if (!RecreateLostWaivers(cx, desc.address(), &wrappedDesc))
|
||||
return false;
|
||||
|
||||
return JS_DefinePropertyById(cx, expandoObject, id, wrappedDesc.value(),
|
||||
|
|
|
@ -73,12 +73,12 @@ class XrayWrapper : public Base {
|
|||
virtual bool isExtensible(JSContext *cx, JS::Handle<JSObject*> wrapper, bool *extensible) MOZ_OVERRIDE;
|
||||
virtual bool preventExtensions(JSContext *cx, JS::Handle<JSObject*> wrapper) MOZ_OVERRIDE;
|
||||
virtual bool getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<jsid> id,
|
||||
js::PropertyDescriptor *desc, unsigned flags);
|
||||
JS::MutableHandle<js::PropertyDescriptor> desc, unsigned flags);
|
||||
virtual bool getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<jsid> id,
|
||||
js::PropertyDescriptor *desc,
|
||||
JS::MutableHandle<js::PropertyDescriptor> desc,
|
||||
unsigned flags);
|
||||
virtual bool defineProperty(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<jsid> id,
|
||||
js::PropertyDescriptor *desc);
|
||||
JS::MutableHandle<js::PropertyDescriptor> desc);
|
||||
virtual bool getOwnPropertyNames(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
||||
js::AutoIdVector &props);
|
||||
virtual bool delete_(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
||||
|
@ -130,10 +130,12 @@ public:
|
|||
}
|
||||
|
||||
virtual bool getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> proxy,
|
||||
JS::Handle<jsid> id, js::PropertyDescriptor *desc,
|
||||
JS::Handle<jsid> id,
|
||||
JS::MutableHandle<js::PropertyDescriptor> desc,
|
||||
unsigned flags) MOZ_OVERRIDE;
|
||||
virtual bool getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> proxy,
|
||||
JS::Handle<jsid> id, js::PropertyDescriptor *desc,
|
||||
JS::Handle<jsid> id,
|
||||
JS::MutableHandle<js::PropertyDescriptor> desc,
|
||||
unsigned flags) MOZ_OVERRIDE;
|
||||
|
||||
// We just forward the derived traps to the BaseProxyHandler versions which
|
||||
|
|
Загрузка…
Ссылка в новой задаче