2013-09-09 07:28:50 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_DOMException_h__
|
|
|
|
#define mozilla_dom_DOMException_h__
|
|
|
|
|
2013-09-09 07:29:21 +04:00
|
|
|
// We intentionally shadow non-virtual methods, but gcc gets confused.
|
2013-09-09 07:28:50 +04:00
|
|
|
#ifdef __GNUC__
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Woverloaded-virtual"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "jspubtd.h"
|
|
|
|
#include "js/GCAPI.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsID.h"
|
|
|
|
#include "nsIDOMDOMException.h"
|
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
#include "xpcexception.h"
|
2014-01-20 20:51:41 +04:00
|
|
|
#include "nsString.h"
|
2015-01-03 02:06:58 +03:00
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
2013-09-09 07:28:50 +04:00
|
|
|
|
|
|
|
class nsIStackFrame;
|
|
|
|
class nsString;
|
|
|
|
|
|
|
|
nsresult
|
2014-01-20 20:51:41 +04:00
|
|
|
NS_GetNameAndMessageForDOMNSResult(nsresult aNSResult, nsACString& aName,
|
|
|
|
nsACString& aMessage,
|
2013-09-09 07:28:50 +04:00
|
|
|
uint16_t* aCode = nullptr);
|
|
|
|
|
|
|
|
namespace mozilla {
|
2014-07-04 09:25:16 +04:00
|
|
|
class ErrorResult;
|
|
|
|
|
2013-09-09 07:28:50 +04:00
|
|
|
namespace dom {
|
|
|
|
|
2015-01-03 01:08:33 +03:00
|
|
|
class GlobalObject;
|
|
|
|
|
2013-09-09 07:29:21 +04:00
|
|
|
#define MOZILLA_EXCEPTION_IID \
|
2013-09-09 07:28:50 +04:00
|
|
|
{ 0x55eda557, 0xeba0, 0x4fe3, \
|
|
|
|
{ 0xae, 0x2e, 0xf3, 0x94, 0x49, 0x23, 0x62, 0xd6 } }
|
|
|
|
|
|
|
|
class Exception : public nsIXPCException,
|
|
|
|
public nsWrapperCache
|
|
|
|
{
|
|
|
|
public:
|
2013-09-09 07:29:21 +04:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_EXCEPTION_IID)
|
2013-09-09 07:28:50 +04:00
|
|
|
|
|
|
|
NS_DEFINE_STATIC_CID_ACCESSOR(NS_XPCEXCEPTION_CID)
|
|
|
|
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Exception)
|
|
|
|
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_NSIEXCEPTION
|
|
|
|
NS_DECL_NSIXPCEXCEPTION
|
|
|
|
|
|
|
|
// Cruft used by XPConnect for exceptions originating in JS implemented
|
|
|
|
// components.
|
|
|
|
bool StealJSVal(JS::Value* aVp);
|
|
|
|
void StowJSVal(JS::Value& aVp);
|
|
|
|
|
|
|
|
// WebIDL API
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto)
|
2015-03-21 19:28:04 +03:00
|
|
|
override;
|
2013-09-09 07:28:50 +04:00
|
|
|
|
|
|
|
nsISupports* GetParentObject() const { return nullptr; }
|
|
|
|
|
|
|
|
void GetMessageMoz(nsString& retval);
|
|
|
|
|
|
|
|
uint32_t Result() const;
|
|
|
|
|
|
|
|
void GetName(nsString& retval);
|
|
|
|
|
2014-07-26 09:41:18 +04:00
|
|
|
// The XPCOM GetFilename does the right thing. It might throw, but we want to
|
|
|
|
// return an empty filename in that case anyway, instead of throwing.
|
2013-09-09 07:28:50 +04:00
|
|
|
|
|
|
|
uint32_t LineNumber() const;
|
|
|
|
|
|
|
|
uint32_t ColumnNumber() const;
|
|
|
|
|
|
|
|
already_AddRefed<nsIStackFrame> GetLocation() const;
|
|
|
|
|
|
|
|
already_AddRefed<nsISupports> GetInner() const;
|
|
|
|
|
|
|
|
already_AddRefed<nsISupports> GetData() const;
|
|
|
|
|
2014-07-04 09:25:16 +04:00
|
|
|
void GetStack(nsAString& aStack, ErrorResult& aRv) const;
|
|
|
|
|
2013-09-09 07:28:50 +04:00
|
|
|
void Stringify(nsString& retval);
|
|
|
|
|
|
|
|
// XPCOM factory ctor.
|
|
|
|
Exception();
|
|
|
|
|
2014-01-20 20:51:41 +04:00
|
|
|
Exception(const nsACString& aMessage,
|
2013-09-09 07:28:50 +04:00
|
|
|
nsresult aResult,
|
2014-01-20 20:51:41 +04:00
|
|
|
const nsACString& aName,
|
2013-09-09 07:28:50 +04:00
|
|
|
nsIStackFrame *aLocation,
|
|
|
|
nsISupports *aData);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~Exception();
|
|
|
|
|
2014-01-20 20:51:41 +04:00
|
|
|
nsCString mMessage;
|
2013-09-09 07:28:50 +04:00
|
|
|
nsresult mResult;
|
2014-01-20 20:51:41 +04:00
|
|
|
nsCString mName;
|
2013-09-09 07:28:50 +04:00
|
|
|
nsCOMPtr<nsIStackFrame> mLocation;
|
|
|
|
nsCOMPtr<nsISupports> mData;
|
2014-04-12 06:20:40 +04:00
|
|
|
nsString mFilename;
|
2013-09-09 07:28:50 +04:00
|
|
|
int mLineNumber;
|
|
|
|
nsCOMPtr<nsIException> mInner;
|
|
|
|
bool mInitialized;
|
|
|
|
|
|
|
|
bool mHoldingJSVal;
|
|
|
|
JS::Heap<JS::Value> mThrownJSVal;
|
|
|
|
|
|
|
|
private:
|
|
|
|
static bool sEverMadeOneFromFactory;
|
|
|
|
};
|
|
|
|
|
2013-09-09 07:29:21 +04:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(Exception, MOZILLA_EXCEPTION_IID)
|
2013-09-09 07:28:50 +04:00
|
|
|
|
|
|
|
class DOMException : public Exception,
|
|
|
|
public nsIDOMDOMException
|
|
|
|
{
|
|
|
|
public:
|
2014-01-20 20:51:41 +04:00
|
|
|
DOMException(nsresult aRv, const nsACString& aMessage,
|
|
|
|
const nsACString& aName, uint16_t aCode);
|
2013-09-09 07:28:50 +04:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_NSIDOMDOMEXCEPTION
|
|
|
|
|
|
|
|
// nsIException overrides
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD ToString(nsACString& aReturn) override;
|
2013-09-09 07:28:50 +04:00
|
|
|
|
|
|
|
// nsWrapperCache overrides
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2015-03-21 19:28:04 +03:00
|
|
|
override;
|
2013-09-09 07:28:50 +04:00
|
|
|
|
2015-01-03 01:08:33 +03:00
|
|
|
static already_AddRefed<DOMException>
|
|
|
|
Constructor(GlobalObject& /* unused */,
|
|
|
|
const nsAString& aMessage,
|
|
|
|
const Optional<nsAString>& aName,
|
|
|
|
ErrorResult& aError);
|
|
|
|
|
2013-09-09 07:28:50 +04:00
|
|
|
uint16_t Code() const {
|
|
|
|
return mCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Intentionally shadow the nsXPCException version.
|
|
|
|
void GetMessageMoz(nsString& retval);
|
|
|
|
void GetName(nsString& retval);
|
|
|
|
|
|
|
|
static already_AddRefed<DOMException>
|
|
|
|
Create(nsresult aRv);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual ~DOMException() {}
|
|
|
|
|
2014-01-20 20:51:41 +04:00
|
|
|
nsCString mName;
|
|
|
|
nsCString mMessage;
|
2013-09-09 07:28:50 +04:00
|
|
|
|
|
|
|
uint16_t mCode;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|