2014-04-03 15:58:00 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim: set ts=8 sts=4 et sw=4 tw=99: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2012-05-21 15:12:37 +04:00
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-07-03 01:09:48 +04:00
|
|
|
|
2012-07-16 21:22:51 +04:00
|
|
|
#include "WaiveXrayWrapper.h"
|
2010-10-11 02:48:29 +04:00
|
|
|
#include "WrapperFactory.h"
|
2013-09-10 01:14:10 +04:00
|
|
|
#include "jsapi.h"
|
2010-10-11 02:48:29 +04:00
|
|
|
|
2013-04-20 13:41:47 +04:00
|
|
|
using namespace JS;
|
|
|
|
|
2010-07-03 01:09:48 +04:00
|
|
|
namespace xpc {
|
|
|
|
|
2013-04-03 22:41:22 +04:00
|
|
|
static bool
|
2013-07-26 09:52:59 +04:00
|
|
|
WaiveAccessors(JSContext *cx, JS::MutableHandle<JSPropertyDescriptor> desc)
|
2013-04-03 22:41:22 +04:00
|
|
|
{
|
2013-04-30 21:29:40 +04:00
|
|
|
if (desc.hasGetterObject() && desc.getterObject()) {
|
|
|
|
RootedValue v(cx, JS::ObjectValue(*desc.getterObject()));
|
2013-10-26 20:19:05 +04:00
|
|
|
if (!WrapperFactory::WaiveXrayAndWrap(cx, &v))
|
2013-04-03 22:41:22 +04:00
|
|
|
return false;
|
2013-04-30 21:29:40 +04:00
|
|
|
desc.setGetterObject(&v.toObject());
|
2013-04-03 22:41:22 +04:00
|
|
|
}
|
|
|
|
|
2013-04-30 21:29:40 +04:00
|
|
|
if (desc.hasSetterObject() && desc.setterObject()) {
|
|
|
|
RootedValue v(cx, JS::ObjectValue(*desc.setterObject()));
|
2013-10-26 20:19:05 +04:00
|
|
|
if (!WrapperFactory::WaiveXrayAndWrap(cx, &v))
|
2013-04-03 22:41:22 +04:00
|
|
|
return false;
|
2013-04-30 21:29:40 +04:00
|
|
|
desc.setSetterObject(&v.toObject());
|
2013-04-03 22:41:22 +04:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-10-11 02:48:29 +04:00
|
|
|
bool
|
2013-04-20 13:41:47 +04:00
|
|
|
WaiveXrayWrapper::getPropertyDescriptor(JSContext *cx, HandleObject wrapper,
|
2014-04-26 01:11:01 +04:00
|
|
|
HandleId id, JS::MutableHandle<JSPropertyDescriptor> desc)
|
2014-06-27 15:44:06 +04:00
|
|
|
const
|
2010-10-11 02:48:29 +04:00
|
|
|
{
|
2014-04-26 01:11:01 +04:00
|
|
|
return CrossCompartmentWrapper::getPropertyDescriptor(cx, wrapper, id, desc) &&
|
2013-10-26 20:19:05 +04:00
|
|
|
WrapperFactory::WaiveXrayAndWrap(cx, desc.value()) && WaiveAccessors(cx, desc);
|
2010-10-11 02:48:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-04-20 13:41:47 +04:00
|
|
|
WaiveXrayWrapper::getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper,
|
2014-04-26 01:11:01 +04:00
|
|
|
HandleId id, JS::MutableHandle<JSPropertyDescriptor> desc)
|
2014-06-27 15:44:06 +04:00
|
|
|
const
|
2010-10-11 02:48:29 +04:00
|
|
|
{
|
2014-04-26 01:11:01 +04:00
|
|
|
return CrossCompartmentWrapper::getOwnPropertyDescriptor(cx, wrapper, id, desc) &&
|
2013-10-26 20:19:05 +04:00
|
|
|
WrapperFactory::WaiveXrayAndWrap(cx, desc.value()) && WaiveAccessors(cx, desc);
|
2010-10-11 02:48:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-04-20 13:41:47 +04:00
|
|
|
WaiveXrayWrapper::get(JSContext *cx, HandleObject wrapper,
|
|
|
|
HandleObject receiver, HandleId id,
|
2014-06-27 15:44:06 +04:00
|
|
|
MutableHandleValue vp) const
|
2010-10-11 02:48:29 +04:00
|
|
|
{
|
2011-09-09 07:29:15 +04:00
|
|
|
return CrossCompartmentWrapper::get(cx, wrapper, receiver, id, vp) &&
|
2013-10-26 20:19:05 +04:00
|
|
|
WrapperFactory::WaiveXrayAndWrap(cx, vp);
|
2010-10-11 02:48:29 +04:00
|
|
|
}
|
|
|
|
|
2014-07-24 02:20:05 +04:00
|
|
|
bool
|
|
|
|
WaiveXrayWrapper::iterate(JSContext *cx, HandleObject proxy, unsigned flags,
|
2014-11-19 03:44:03 +03:00
|
|
|
MutableHandleObject objp) const
|
2014-07-24 02:20:05 +04:00
|
|
|
{
|
2014-11-19 03:44:03 +03:00
|
|
|
return CrossCompartmentWrapper::iterate(cx, proxy, flags, objp) &&
|
|
|
|
(!objp || WrapperFactory::WaiveXrayAndWrap(cx, objp));
|
2014-07-24 02:20:05 +04:00
|
|
|
}
|
|
|
|
|
2010-12-04 06:00:23 +03:00
|
|
|
bool
|
2014-06-27 15:44:06 +04:00
|
|
|
WaiveXrayWrapper::call(JSContext *cx, HandleObject wrapper, const JS::CallArgs &args) const
|
2010-12-04 06:00:23 +03:00
|
|
|
{
|
2013-04-04 11:02:24 +04:00
|
|
|
return CrossCompartmentWrapper::call(cx, wrapper, args) &&
|
2013-10-26 20:19:05 +04:00
|
|
|
WrapperFactory::WaiveXrayAndWrap(cx, args.rval());
|
2010-12-04 06:00:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2014-06-27 15:44:06 +04:00
|
|
|
WaiveXrayWrapper::construct(JSContext *cx, HandleObject wrapper, const JS::CallArgs &args) const
|
2010-12-04 06:00:23 +03:00
|
|
|
{
|
2013-04-04 11:02:24 +04:00
|
|
|
return CrossCompartmentWrapper::construct(cx, wrapper, args) &&
|
2013-10-26 20:19:05 +04:00
|
|
|
WrapperFactory::WaiveXrayAndWrap(cx, args.rval());
|
2010-12-04 06:00:23 +03:00
|
|
|
}
|
|
|
|
|
2013-04-03 22:41:23 +04:00
|
|
|
// NB: This is important as the other side of a handshake with FieldGetter. See
|
|
|
|
// nsXBLProtoImplField.cpp.
|
|
|
|
bool
|
|
|
|
WaiveXrayWrapper::nativeCall(JSContext *cx, JS::IsAcceptableThis test,
|
2014-06-27 15:44:06 +04:00
|
|
|
JS::NativeImpl impl, JS::CallArgs args) const
|
2013-04-03 22:41:23 +04:00
|
|
|
{
|
|
|
|
return CrossCompartmentWrapper::nativeCall(cx, test, impl, args) &&
|
2013-10-26 20:19:05 +04:00
|
|
|
WrapperFactory::WaiveXrayAndWrap(cx, args.rval());
|
2013-04-03 22:41:23 +04:00
|
|
|
}
|
|
|
|
|
2013-12-14 00:01:30 +04:00
|
|
|
bool
|
2014-06-27 15:44:06 +04:00
|
|
|
WaiveXrayWrapper::getPrototypeOf(JSContext *cx, HandleObject wrapper, MutableHandleObject protop) const
|
2013-12-14 00:01:30 +04:00
|
|
|
{
|
|
|
|
return CrossCompartmentWrapper::getPrototypeOf(cx, wrapper, protop) &&
|
|
|
|
(!protop || WrapperFactory::WaiveXrayAndWrap(cx, protop));
|
|
|
|
}
|
|
|
|
|
2010-07-03 01:09:48 +04:00
|
|
|
}
|