Bug 1090636, part 13 - Reimplement the mHasPrototype part of Proxy::set as a call to BaseProxyHandler::set. r=bholley.

--HG--
extra : rebase_source : edc9dd5f8a45e5112af13073b41e6f6879c6f2ce
This commit is contained in:
Jason Orendorff 2014-10-15 11:07:41 -05:00
Родитель 1b77b4caf6
Коммит 6a47357145
1 изменённых файлов: 4 добавлений и 29 удалений

Просмотреть файл

@ -329,36 +329,11 @@ Proxy::set(JSContext *cx, HandleObject proxy, HandleObject receiver, HandleId id
if (!policy.allowed())
return policy.returnValue();
// If the proxy doesn't require that we consult its prototype for the
// non-own cases, we can sink to the |set| trap.
if (!handler->hasPrototype())
// Special case. See the comment on BaseProxyHandler::mHasPrototype.
if (handler->hasPrototype())
return handler->BaseProxyHandler::set(cx, proxy, receiver, id, strict, vp);
return handler->set(cx, proxy, receiver, id, strict, vp);
// If we have an existing (own or non-own) property with a setter, we want
// to invoke that.
Rooted<PropertyDescriptor> desc(cx);
if (!Proxy::getPropertyDescriptor(cx, proxy, id, &desc))
return false;
if (desc.object() && desc.setter()) {
MOZ_ASSERT(desc.setter() != JS_StrictPropertyStub);
return CallSetter(cx, receiver, id, desc.setter(), desc.attributes(), strict, vp);
}
if (desc.isReadonly()) {
return strict ? Throw(cx, id, JSMSG_READ_ONLY) : true;
}
// Ok. Either there was no pre-existing property, or it was a value prop
// that we're going to shadow. Either way, define a new own property.
unsigned attrs =
(desc.object() == proxy)
? JSPROP_IGNORE_ENUMERATE | JSPROP_IGNORE_READONLY | JSPROP_IGNORE_PERMANENT
: JSPROP_ENUMERATE;
const Class *clasp = receiver->getClass();
MOZ_ASSERT(clasp->getProperty != JS_PropertyStub);
MOZ_ASSERT(clasp->setProperty != JS_StrictPropertyStub);
return JSObject::defineGeneric(cx, receiver, id, vp, clasp->getProperty, clasp->setProperty,
attrs);
}
bool