зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1053271 - Remove XrayTraits' HasPrototype. r=bz.
XPCWN Xrays were the only Xrays that set HasPrototype to 0. --HG-- extra : rebase_source : c10654e4eb6eb39b3cfe8884009cd1a47dcad807
This commit is contained in:
Родитель
c02d68395d
Коммит
a47cb53336
|
@ -1786,9 +1786,7 @@ XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext* cx, HandleObject wra
|
|||
JS::MutableHandle<PropertyDescriptor> desc)
|
||||
const
|
||||
{
|
||||
// We can't assert !Traits::HasPrototypes here, because
|
||||
// CrossOriginXrayWrapper::getOwnPropertyDescriptor calls us, but it uses
|
||||
// DOMXrayTraits, which have HasPrototype.
|
||||
// CrossOriginXrayWrapper::getOwnPropertyDescriptor calls this.
|
||||
|
||||
assertEnteredPolicy(cx, wrapper, id, BaseProxyHandler::GET | BaseProxyHandler::SET |
|
||||
BaseProxyHandler::GET_PROPERTY_DESCRIPTOR);
|
||||
|
@ -2058,13 +2056,6 @@ XrayWrapper<Base, Traits>::get(JSContext* cx, HandleObject wrapper,
|
|||
MutableHandleValue vp) const
|
||||
{
|
||||
// Skip our Base if it isn't already ProxyHandler.
|
||||
// NB: None of the functions we call are prepared for the receiver not
|
||||
// being the wrapper, so ignore the receiver here.
|
||||
RootedValue thisv(cx);
|
||||
if (Traits::HasPrototype)
|
||||
thisv = receiver;
|
||||
else
|
||||
thisv.setObject(*wrapper);
|
||||
|
||||
// This uses getPropertyDescriptor for backward compatibility with
|
||||
// the old BaseProxyHandler::get implementation.
|
||||
|
@ -2092,7 +2083,7 @@ XrayWrapper<Base, Traits>::get(JSContext* cx, HandleObject wrapper,
|
|||
return true;
|
||||
}
|
||||
|
||||
return Call(cx, thisv, getter, HandleValueArray::empty(), vp);
|
||||
return Call(cx, receiver, getter, HandleValueArray::empty(), vp);
|
||||
}
|
||||
|
||||
template <typename Base, typename Traits>
|
||||
|
@ -2100,12 +2091,8 @@ bool
|
|||
XrayWrapper<Base, Traits>::set(JSContext* cx, HandleObject wrapper, HandleId id, HandleValue v,
|
||||
HandleValue receiver, ObjectOpResult& result) const
|
||||
{
|
||||
MOZ_ASSERT(!Traits::HasPrototype);
|
||||
// Skip our Base if it isn't already BaseProxyHandler.
|
||||
// NB: None of the functions we call are prepared for the receiver not
|
||||
// being the wrapper, so ignore the receiver here.
|
||||
RootedValue wrapperValue(cx, ObjectValue(*wrapper));
|
||||
return js::BaseProxyHandler::set(cx, wrapper, id, v, wrapperValue, result);
|
||||
MOZ_CRASH("Shouldn't be called");
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename Base, typename Traits>
|
||||
|
@ -2146,9 +2133,8 @@ template <typename Base, typename Traits>
|
|||
JSObject*
|
||||
XrayWrapper<Base, Traits>::enumerate(JSContext* cx, HandleObject wrapper) const
|
||||
{
|
||||
MOZ_ASSERT(!Traits::HasPrototype, "Why did we get called?");
|
||||
// Skip our Base if it isn't already ProxyHandler.
|
||||
return js::BaseProxyHandler::enumerate(cx, wrapper);
|
||||
MOZ_CRASH("Shouldn't be called");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <typename Base, typename Traits>
|
||||
|
@ -2224,7 +2210,7 @@ XrayWrapper<Base, Traits>::getPrototype(JSContext* cx, JS::HandleObject wrapper,
|
|||
Value cached = js::GetReservedSlot(holder,
|
||||
Traits::HOLDER_SLOT_CACHED_PROTO);
|
||||
if (cached.isUndefined()) {
|
||||
if (!getPrototypeHelper(cx, wrapper, target, protop))
|
||||
if (!Traits::singleton.getPrototype(cx, wrapper, target, protop))
|
||||
return false;
|
||||
|
||||
js::SetReservedSlot(holder, Traits::HOLDER_SLOT_CACHED_PROTO,
|
||||
|
|
|
@ -146,10 +146,6 @@ class DOMXrayTraits : public XrayTraits
|
|||
public:
|
||||
constexpr DOMXrayTraits() = default;
|
||||
|
||||
enum {
|
||||
HasPrototype = 1
|
||||
};
|
||||
|
||||
static const XrayType Type = XrayForDOMObject;
|
||||
|
||||
virtual bool resolveNativeProperty(JSContext* cx, JS::HandleObject wrapper,
|
||||
|
@ -202,9 +198,6 @@ protected:
|
|||
class JSXrayTraits : public XrayTraits
|
||||
{
|
||||
public:
|
||||
enum {
|
||||
HasPrototype = 1
|
||||
};
|
||||
static const XrayType Type = XrayForJSObject;
|
||||
|
||||
virtual bool resolveNativeProperty(JSContext* cx, JS::HandleObject wrapper,
|
||||
|
@ -319,9 +312,6 @@ public:
|
|||
class OpaqueXrayTraits : public XrayTraits
|
||||
{
|
||||
public:
|
||||
enum {
|
||||
HasPrototype = 1
|
||||
};
|
||||
static const XrayType Type = XrayForOpaqueObject;
|
||||
|
||||
virtual bool resolveNativeProperty(JSContext* cx, JS::HandleObject wrapper,
|
||||
|
@ -404,12 +394,13 @@ public:
|
|||
XrayType GetXrayType(JSObject* obj);
|
||||
XrayTraits* GetXrayTraits(JSObject* obj);
|
||||
|
||||
// NB: Base *must* derive from JSProxyHandler
|
||||
template <typename Base, typename Traits>
|
||||
class XrayWrapper : public Base {
|
||||
static_assert(mozilla::IsBaseOf<js::BaseProxyHandler, Base>::value,
|
||||
"Base *must* derive from js::BaseProxyHandler");
|
||||
public:
|
||||
constexpr explicit XrayWrapper(unsigned flags)
|
||||
: Base(flags | WrapperFactory::IS_XRAY_WRAPPER_FLAG, Traits::HasPrototype)
|
||||
: Base(flags | WrapperFactory::IS_XRAY_WRAPPER_FLAG, /* aHasPrototype = */ true)
|
||||
{ };
|
||||
|
||||
/* Standard internal methods. */
|
||||
|
@ -459,28 +450,6 @@ class XrayWrapper : public Base {
|
|||
|
||||
static const XrayWrapper singleton;
|
||||
|
||||
private:
|
||||
template <bool HasPrototype>
|
||||
typename mozilla::EnableIf<HasPrototype, bool>::Type
|
||||
getPrototypeHelper(JSContext* cx, JS::HandleObject wrapper,
|
||||
JS::HandleObject target, JS::MutableHandleObject protop) const
|
||||
{
|
||||
return Traits::singleton.getPrototype(cx, wrapper, target, protop);
|
||||
}
|
||||
template <bool HasPrototype>
|
||||
typename mozilla::EnableIf<!HasPrototype, bool>::Type
|
||||
getPrototypeHelper(JSContext* cx, JS::HandleObject wrapper,
|
||||
JS::HandleObject target, JS::MutableHandleObject protop) const
|
||||
{
|
||||
return Base::getPrototype(cx, wrapper, protop);
|
||||
}
|
||||
bool getPrototypeHelper(JSContext* cx, JS::HandleObject wrapper,
|
||||
JS::HandleObject target, JS::MutableHandleObject protop) const
|
||||
{
|
||||
return getPrototypeHelper<Traits::HasPrototype>(cx, wrapper, target,
|
||||
protop);
|
||||
}
|
||||
|
||||
protected:
|
||||
bool getPropertyKeys(JSContext* cx, JS::Handle<JSObject*> wrapper, unsigned flags,
|
||||
JS::AutoIdVector& props) const;
|
||||
|
|
Загрузка…
Ссылка в новой задаче