Bug 1435483 part 3. Remove nsIXPCException. r=qdot

This interface is not usable from JS, because we don't expose initialize() in
the WebIDL bindings for Exception.  And C++ doesn't use it.

MozReview-Commit-ID: LsIm4YA0YZE
This commit is contained in:
Boris Zbarsky 2018-02-05 16:34:04 -05:00
Родитель de9c98ee56
Коммит 0920564cb3
7 изменённых файлов: 26 добавлений и 78 удалений

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

@ -1209,7 +1209,7 @@ nsScriptSecurityManager::CanCreateWrapper(JSContext *cx,
nsISupports *aObj,
nsIClassInfo *aClassInfo)
{
// XXX Special case for nsIXPCException ?
// XXX Special case for Exception ?
uint32_t flags;
if (aClassInfo && NS_SUCCEEDED(aClassInfo->GetFlags(&flags)) &&

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

@ -143,8 +143,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Exception)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(Exception)
NS_INTERFACE_MAP_ENTRY(nsIException)
NS_INTERFACE_MAP_ENTRY(nsIXPCException)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIException)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(Exception)
@ -169,18 +168,27 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Exception)
tmp->mThrownJSVal.setNull();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CI_INTERFACE_GETTER(Exception, nsIXPCException)
Exception::Exception(const nsACString& aMessage,
nsresult aResult,
const nsACString& aName,
nsIStackFrame *aLocation,
nsISupports *aData)
: mResult(NS_OK),
mInitialized(false),
mHoldingJSVal(false)
: mMessage(aMessage)
, mResult(aResult)
, mName(aName)
, mData(aData)
, mInitialized(true)
, mHoldingJSVal(false)
{
Initialize(aMessage, aResult, aName, aLocation, aData);
if (aLocation) {
mLocation = aLocation;
} else {
mLocation = GetCurrentJSStack();
// it is legal for there to be no active JS stack, if C++ code
// is operating on a JS-implemented interface pointer without
// having been called in turn by JS. This happens in the JS
// component loader.
}
}
Exception::~Exception()
@ -364,33 +372,6 @@ Exception::ToString(JSContext* aCx, nsACString& _retval)
return NS_OK;
}
NS_IMETHODIMP
Exception::Initialize(const nsACString& aMessage, nsresult aResult,
const nsACString& aName, nsIStackFrame *aLocation,
nsISupports *aData)
{
NS_ENSURE_FALSE(mInitialized, NS_ERROR_ALREADY_INITIALIZED);
mMessage = aMessage;
mName = aName;
mResult = aResult;
if (aLocation) {
mLocation = aLocation;
} else {
mLocation = GetCurrentJSStack();
// it is legal for there to be no active JS stack, if C++ code
// is operating on a JS-implemented interface pointer without
// having been called in turn by JS. This happens in the JS
// component loader.
}
mData = aData;
mInitialized = true;
return NS_OK;
}
JSObject*
Exception::WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto)
{

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

@ -20,7 +20,7 @@
#include "nsID.h"
#include "nsIDOMDOMException.h"
#include "nsWrapperCache.h"
#include "xpcexception.h"
#include "nsIException.h"
#include "nsString.h"
#include "mozilla/dom/BindingDeclarations.h"
@ -42,7 +42,7 @@ class GlobalObject;
{ 0x55eda557, 0xeba0, 0x4fe3, \
{ 0xae, 0x2e, 0xf3, 0x94, 0x49, 0x23, 0x62, 0xd6 } }
class Exception : public nsIXPCException,
class Exception : public nsIException,
public nsWrapperCache
{
public:
@ -52,7 +52,6 @@ public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_NSIEXCEPTION
NS_DECL_NSIXPCEXCEPTION
// Cruft used by XPConnect for exceptions originating in JS implemented
// components.

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

@ -10,7 +10,6 @@ XPIDL_SOURCES += [
'nsIXPConnect.idl',
'nsIXPCScriptable.idl',
'xpccomponents.idl',
'xpcexception.idl',
'xpcIJSGetFactory.idl',
'xpcIJSModuleLoader.idl',
'xpcIJSWeakReference.idl',

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

@ -1,30 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
#include "nsISupports.idl"
#include "nsIException.idl"
[scriptable, builtinclass, uuid(875e6645-e762-4da6-9ec8-bf19ab0050df)]
interface nsIXPCException : nsIException
{
// inherits methods from nsIException
void initialize(in AUTF8String aMessage,
in nsresult aResult,
in AUTF8String aName,
in nsIStackFrame aLocation,
in nsISupports aData);
};
/* this goes into the C++ header verbatim. */
%{ C++
/********************************************************/
// {5632BF70-51EC-11d3-9896-006008962422}
#define NS_XPCEXCEPTION_CID \
{ 0x5632bf70, 0x51ec, 0x11d3, \
{ 0x98, 0x96, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
%}

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

@ -1254,7 +1254,7 @@ nsXPCComponents_ID::HasInstance(nsIXPConnectWrappedNative* wrapper,
}
/***************************************************************************/
// JavaScript Constructor for nsIXPCException objects (Components.Exception)
// JavaScript Constructor for Exception objects (Components.Exception)
class nsXPCComponents_Exception final :
public nsIXPCComponents_Exception,
@ -1542,14 +1542,14 @@ nsXPCComponents_Exception::CallOrConstruct(nsIXPConnectWrappedNative* wrapper,
if (!parser.parse(args))
return ThrowAndFail(NS_ERROR_XPC_BAD_CONVERT_JS, cx, _retval);
nsCOMPtr<nsIException> e = new Exception(nsCString(parser.eMsg),
parser.eResult,
EmptyCString(),
parser.eStack,
parser.eData);
RefPtr<Exception> e = new Exception(nsCString(parser.eMsg),
parser.eResult,
EmptyCString(),
parser.eStack,
parser.eData);
RootedObject newObj(cx);
if (NS_FAILED(xpc->WrapNative(cx, obj, e, NS_GET_IID(nsIXPCException), newObj.address())) || !newObj) {
if (NS_FAILED(xpc->WrapNative(cx, obj, e, NS_GET_IID(nsIException), newObj.address())) || !newObj) {
return ThrowAndFail(NS_ERROR_XPC_CANT_CREATE_WN, cx, _retval);
}

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

@ -118,7 +118,6 @@
#include "XPCForwards.h"
#include "XPCLog.h"
#include "xpccomponents.h"
#include "xpcexception.h"
#include "xpcjsid.h"
#include "prenv.h"
#include "prcvar.h"