зеркало из https://github.com/mozilla/gecko-dev.git
Bug 754968 - Part c: Make BindingUtils.h not require private xpconnect headers; r=bholley
This commit is contained in:
Родитель
dff3118490
Коммит
ba51dd062a
|
@ -44,6 +44,7 @@
|
|||
#include "mozilla/Util.h"
|
||||
|
||||
#include "xpcprivate.h"
|
||||
#include "XPCWrapper.h"
|
||||
#include "nsScriptSecurityManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIScriptObjectPrincipal.h"
|
||||
|
|
|
@ -109,7 +109,6 @@ INCLUDES += \
|
|||
-I$(srcdir)/../../../layout/generic \
|
||||
-I$(srcdir)/../../base/src \
|
||||
-I$(srcdir)/../../html/content/src \
|
||||
-I$(srcdir)/../../../js/xpconnect/src \
|
||||
-I$(srcdir)/../../../dom/base \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -149,7 +149,6 @@ INCLUDES += \
|
|||
-I$(srcdir)/../../../../editor/libeditor/base \
|
||||
-I$(srcdir)/../../../../editor/libeditor/text \
|
||||
-I$(srcdir) \
|
||||
-I$(topsrcdir)/js/xpconnect/src \
|
||||
-I$(topsrcdir)/xpcom/ds \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -89,7 +89,6 @@ LOCAL_INCLUDES = \
|
|||
-I$(srcdir)/../../../layout/style \
|
||||
-I$(srcdir)/../../../dom/base \
|
||||
-I$(topsrcdir)/xpcom/ds \
|
||||
-I$(topsrcdir)/js/xpconnect/src \
|
||||
$(NULL)
|
||||
|
||||
DEFINES += -D_IMPL_NS_LAYOUT
|
||||
|
|
|
@ -76,7 +76,6 @@ LOCAL_INCLUDES = -I$(srcdir)/../../../base/src \
|
|||
-I$(srcdir)/../../../xbl/src \
|
||||
-I$(srcdir)/../../../events/src \
|
||||
-I$(topsrcdir)/xpcom/ds \
|
||||
-I$(topsrcdir)/js/xpconnect/src \
|
||||
-I$(topsrcdir)/dom/base \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
|
||||
#include "BindingUtils.h"
|
||||
|
||||
#include "xpcprivate.h"
|
||||
#include "XPCQuickStubs.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
|
|
|
@ -13,9 +13,11 @@
|
|||
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "jswrapper.h"
|
||||
|
||||
#include "XPCQuickStubs.h"
|
||||
#include "XPCWrapper.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "qsObjectHelper.h"
|
||||
#include "xpcpublic.h"
|
||||
#include "nsTraceRefcnt.h"
|
||||
#include "nsWrapperCacheInlines.h"
|
||||
|
||||
|
@ -34,7 +36,7 @@ Throw(JSContext* cx, nsresult rv)
|
|||
|
||||
// XXX Introduce exception machinery.
|
||||
if (mainThread) {
|
||||
XPCThrower::Throw(rv, cx);
|
||||
xpc::Throw(cx, rv);
|
||||
} else {
|
||||
if (!JS_IsExceptionPending(cx)) {
|
||||
ThrowDOMExceptionForNSResult(cx, rv);
|
||||
|
@ -106,7 +108,7 @@ UnwrapObject(JSContext* cx, JSObject* obj, T** value)
|
|||
return NS_ERROR_XPC_BAD_CONVERT_JS;
|
||||
}
|
||||
|
||||
obj = XPCWrapper::Unwrap(cx, obj, false);
|
||||
obj = xpc::Unwrap(cx, obj, false);
|
||||
if (!obj) {
|
||||
return NS_ERROR_XPC_SECURITY_MANAGER_VETO;
|
||||
}
|
||||
|
@ -143,7 +145,7 @@ IsArrayLike(JSContext* cx, JSObject* obj)
|
|||
// the underlying object after unwrapping.
|
||||
JSAutoEnterCompartment ac;
|
||||
if (js::IsWrapper(obj)) {
|
||||
obj = XPCWrapper::Unwrap(cx, obj, false);
|
||||
obj = xpc::Unwrap(cx, obj, false);
|
||||
if (!obj) {
|
||||
// Let's say it's not
|
||||
return false;
|
||||
|
@ -175,7 +177,7 @@ IsPlatformObject(JSContext* cx, JSObject* obj)
|
|||
}
|
||||
// Now for simplicity check for security wrappers before anything else
|
||||
if (js::IsWrapper(obj)) {
|
||||
obj = XPCWrapper::Unwrap(cx, obj, false);
|
||||
obj = xpc::Unwrap(cx, obj, false);
|
||||
if (!obj) {
|
||||
// Let's say it's not
|
||||
return false;
|
||||
|
|
|
@ -67,13 +67,10 @@ CPPSRCS = \
|
|||
$(NULL)
|
||||
|
||||
# We fire the nsDOMDeviceAcceleration
|
||||
LOCAL_INCLUDES += -I$(topsrcdir)/content/events/src
|
||||
|
||||
LOCAL_INCLUDES += \
|
||||
-I$(topsrcdir)/content/events/src \
|
||||
-I$(topsrcdir)/dom/base \
|
||||
-I$(topsrcdir)/dom/bindings \
|
||||
-I$(topsrcdir)/js/xpconnect/src \
|
||||
-I$(topsrcdir)/js/xpconnect/wrappers \
|
||||
$(NULL)
|
||||
|
||||
# On Systems that have build in geolocation providers,
|
||||
|
|
|
@ -63,7 +63,6 @@ LOCAL_INCLUDES = \
|
|||
-I$(topsrcdir)/dom/base \
|
||||
-I$(topsrcdir)/dom/system \
|
||||
-I$(topsrcdir)/xpcom/build \
|
||||
-I$(topsrcdir)/js/xpconnect/src \
|
||||
$(NULL)
|
||||
|
||||
TEST_DIRS += test
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "mozilla/unused.h"
|
||||
|
||||
#include "xpcprivate.h"
|
||||
#include "XPCQuickStubs.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "xpcIJSModuleLoader.h"
|
||||
#include "nsIScriptObjectPrincipal.h"
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
/* Code for throwing errors into JavaScript. */
|
||||
|
||||
#include "xpcprivate.h"
|
||||
#include "xpcpublic.h"
|
||||
#include "XPCWrapper.h"
|
||||
|
||||
JSBool XPCThrower::sVerbose = true;
|
||||
|
@ -57,6 +58,17 @@ XPCThrower::Throw(nsresult rv, JSContext* cx)
|
|||
BuildAndThrowException(cx, rv, format);
|
||||
}
|
||||
|
||||
namespace xpc {
|
||||
|
||||
bool
|
||||
Throw(JSContext *cx, nsresult rv)
|
||||
{
|
||||
XPCThrower::Throw(rv, cx);
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace xpc
|
||||
|
||||
/*
|
||||
* If there has already been an exception thrown, see if we're throwing the
|
||||
* same sort of exception, and if we are, don't clobber the old one. ccx
|
||||
|
|
|
@ -118,9 +118,10 @@ AttachNewConstructorObject(XPCCallContext &ccx, JSObject *aGlobalObject)
|
|||
return JS_DefineFunction(ccx, JS_GetFunctionObject(xpcnativewrapper), "unwrap", UnwrapNW, 1,
|
||||
JSPROP_READONLY | JSPROP_PERMANENT) != nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
namespace XPCWrapper {
|
||||
} // namespace XPCNativeWrapper
|
||||
|
||||
namespace xpc {
|
||||
|
||||
JSObject *
|
||||
Unwrap(JSContext *cx, JSObject *wrapper, bool stopAtOuter)
|
||||
|
@ -134,6 +135,10 @@ Unwrap(JSContext *cx, JSObject *wrapper, bool stopAtOuter)
|
|||
return nsnull;
|
||||
}
|
||||
|
||||
} // namespace xpc
|
||||
|
||||
namespace XPCWrapper {
|
||||
|
||||
JSObject *
|
||||
UnsafeUnwrapSecurityWrapper(JSObject *obj)
|
||||
{
|
||||
|
@ -144,4 +149,4 @@ UnsafeUnwrapSecurityWrapper(JSObject *obj)
|
|||
return obj;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace XPCWrapper
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#define XPC_WRAPPER_H 1
|
||||
|
||||
#include "xpcprivate.h"
|
||||
#include "xpcpublic.h"
|
||||
|
||||
namespace XPCNativeWrapper {
|
||||
|
||||
|
@ -82,18 +83,11 @@ IsSecurityWrapper(JSObject *wrapper)
|
|||
return js::IsWrapper(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an arbitrary object, Unwrap will return the wrapped object if the
|
||||
* passed-in object is a wrapper that Unwrap knows about *and* the
|
||||
* currently running code has permission to access both the wrapper and
|
||||
* wrapped object.
|
||||
*
|
||||
* Since this is meant to be called from functions like
|
||||
* XPCWrappedNative::GetWrappedNativeOfJSObject, it does not set an
|
||||
* exception on |cx|.
|
||||
*/
|
||||
JSObject *
|
||||
Unwrap(JSContext *cx, JSObject *wrapper, bool stopAtOuter = true);
|
||||
inline JSObject *
|
||||
Unwrap(JSContext *cx, JSObject *wrapper, bool stopAtOuter = true)
|
||||
{
|
||||
return xpc::Unwrap(cx, wrapper, stopAtOuter);
|
||||
}
|
||||
|
||||
JSObject *
|
||||
UnsafeUnwrapSecurityWrapper(JSObject *obj);
|
||||
|
|
|
@ -330,6 +330,25 @@ ValueToUint64(JSContext *cx, JS::Value v, uint64_t *result)
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an arbitrary object, Unwrap will return the wrapped object if the
|
||||
* passed-in object is a wrapper that Unwrap knows about *and* the
|
||||
* currently running code has permission to access both the wrapper and
|
||||
* wrapped object.
|
||||
*
|
||||
* Since this is meant to be called from functions like
|
||||
* XPCWrappedNative::GetWrappedNativeOfJSObject, it does not set an
|
||||
* exception on |cx|.
|
||||
*/
|
||||
JSObject *
|
||||
Unwrap(JSContext *cx, JSObject *wrapper, bool stopAtOuter = true);
|
||||
|
||||
/**
|
||||
* Throws an exception on cx and returns false.
|
||||
*/
|
||||
bool
|
||||
Throw(JSContext *cx, nsresult rv);
|
||||
|
||||
} // namespace xpc
|
||||
|
||||
namespace mozilla {
|
||||
|
|
Загрузка…
Ссылка в новой задаче