Bug 1159347 - Make BaseProxyHandler::getPropertyDescriptor not-pure virtual. r=efaust

This commit is contained in:
Tom Schuster 2015-04-29 10:47:48 +02:00
parent b1aa4dc962
commit 883c729e3a
8 changed files with 24 additions and 64 deletions

View File

@ -158,31 +158,6 @@ DOMProxyHandler::isExtensible(JSContext *cx, JS::Handle<JSObject*> proxy, bool *
return true;
}
bool
BaseDOMProxyHandler::getPropertyDescriptor(JSContext* cx,
JS::Handle<JSObject*> proxy,
JS::Handle<jsid> id,
MutableHandle<JSPropertyDescriptor> desc) const
{
if (!getOwnPropertyDescriptor(cx, proxy, id, desc)) {
return false;
}
if (desc.object()) {
return true;
}
JS::Rooted<JSObject*> proto(cx);
if (!js::GetObjectProto(cx, proxy, &proto)) {
return false;
}
if (!proto) {
desc.object().set(nullptr);
return true;
}
return JS_GetPropertyDescriptorById(cx, proto, id, desc);
}
bool
BaseDOMProxyHandler::getOwnPropertyDescriptor(JSContext* cx,
JS::Handle<JSObject*> proxy,

View File

@ -58,10 +58,6 @@ public:
virtual bool ownPropertyKeys(JSContext* cx, JS::Handle<JSObject*> proxy,
JS::AutoIdVector &props) const override;
bool getPropertyDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy,
JS::Handle<jsid> id,
JS::MutableHandle<JSPropertyDescriptor> desc) const override;
virtual bool enumerate(JSContext *cx, JS::Handle<JSObject*> proxy,
JS::MutableHandle<JSObject*> objp) const override;

View File

@ -315,7 +315,7 @@ class JS_FRIEND_API(BaseProxyHandler)
/* SpiderMonkey extensions. */
virtual bool getPropertyDescriptor(JSContext* cx, HandleObject proxy, HandleId id,
MutableHandle<JSPropertyDescriptor> desc) const = 0;
MutableHandle<JSPropertyDescriptor> desc) const;
virtual bool hasOwn(JSContext* cx, HandleObject proxy, HandleId id, bool* bp) const;
virtual bool getOwnEnumerablePropertyKeys(JSContext* cx, HandleObject proxy,
AutoIdVector& props) const;

View File

@ -31,6 +31,28 @@ BaseProxyHandler::has(JSContext* cx, HandleObject proxy, HandleId id, bool* bp)
return true;
}
bool
BaseProxyHandler::getPropertyDescriptor(JSContext* cx, HandleObject proxy, HandleId id,
MutableHandle<PropertyDescriptor> desc) const
{
assertEnteredPolicy(cx, proxy, id, GET | SET | GET_PROPERTY_DESCRIPTOR);
if (!getOwnPropertyDescriptor(cx, proxy, id, desc))
return false;
if (desc.object())
return true;
RootedObject proto(cx);
if (!GetPrototype(cx, proxy, &proto))
return false;
if (!proto) {
MOZ_ASSERT(!desc.object());
return true;
}
return GetPropertyDescriptor(cx, proto, id, desc);
}
bool
BaseProxyHandler::hasOwn(JSContext* cx, HandleObject proxy, HandleId id, bool* bp) const
{

View File

@ -14,14 +14,6 @@
using namespace js;
using namespace js::gc;
bool
DeadObjectProxy::getPropertyDescriptor(JSContext* cx, HandleObject wrapper, HandleId id,
MutableHandle<PropertyDescriptor> desc) const
{
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT);
return false;
}
bool
DeadObjectProxy::getOwnPropertyDescriptor(JSContext* cx, HandleObject wrapper, HandleId id,
MutableHandle<PropertyDescriptor> desc) const

View File

@ -38,8 +38,7 @@ class DeadObjectProxy : public BaseProxyHandler
virtual bool construct(JSContext* cx, HandleObject proxy, const CallArgs& args) const override;
/* SpiderMonkey extensions. */
virtual bool getPropertyDescriptor(JSContext* cx, HandleObject wrapper, HandleId id,
MutableHandle<JSPropertyDescriptor> desc) const override;
// BaseProxyHandler::getPropertyDescriptor will throw by calling getOwnPropertyDescriptor.
virtual bool nativeCall(JSContext* cx, IsAcceptableThis test, NativeImpl impl,
CallArgs args) const override;
virtual bool hasInstance(JSContext* cx, HandleObject proxy, MutableHandleValue v,

View File

@ -404,28 +404,6 @@ ScriptedDirectProxyHandler::isExtensible(JSContext* cx, HandleObject proxy, bool
return true;
}
// Corresponds to the "standard" property descriptor getOwn/getPrototype dance. It's so explicit
// here because ScriptedDirectProxyHandler allows script visibility for this operation.
bool
ScriptedDirectProxyHandler::getPropertyDescriptor(JSContext* cx, HandleObject proxy, HandleId id,
MutableHandle<PropertyDescriptor> desc) const
{
JS_CHECK_RECURSION(cx, return false);
if (!GetOwnPropertyDescriptor(cx, proxy, id, desc))
return false;
if (desc.object())
return true;
RootedObject proto(cx);
if (!GetPrototype(cx, proxy, &proto))
return false;
if (!proto) {
MOZ_ASSERT(!desc.object());
return true;
}
return GetPropertyDescriptor(cx, proto, id, desc);
}
// ES6 (5 April 2014) 9.5.5 Proxy.[[GetOwnProperty]](P)
bool
ScriptedDirectProxyHandler::getOwnPropertyDescriptor(JSContext* cx, HandleObject proxy, HandleId id,

View File

@ -52,8 +52,6 @@ class ScriptedDirectProxyHandler : public BaseProxyHandler {
virtual bool construct(JSContext* cx, HandleObject proxy, const CallArgs& args) const override;
/* SpiderMonkey extensions. */
virtual bool getPropertyDescriptor(JSContext* cx, HandleObject proxy, HandleId id,
MutableHandle<JSPropertyDescriptor> desc) const override;
virtual bool hasOwn(JSContext* cx, HandleObject proxy, HandleId id, bool* bp) const override {
return BaseProxyHandler::hasOwn(cx, proxy, id, bp);
}