|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* vim: set ts=2 et sw=2 tw=80: */ |
|
3 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
|
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef mozilla_dom_domerror_h__ |
|
8 #define mozilla_dom_domerror_h__ |
|
9 |
|
10 #include "mozilla/Attributes.h" |
|
11 #include "nsWrapperCache.h" |
|
12 #include "nsCOMPtr.h" |
|
13 #include "nsString.h" |
|
14 #include "nsPIDOMWindow.h" |
|
15 |
|
16 namespace mozilla { |
|
17 |
|
18 class ErrorResult; |
|
19 |
|
20 namespace dom { |
|
21 |
|
22 class GlobalObject; |
|
23 |
|
24 class DOMError : public nsISupports, |
|
25 public nsWrapperCache |
|
26 { |
|
27 nsCOMPtr<nsPIDOMWindow> mWindow; |
|
28 nsString mName; |
|
29 nsString mMessage; |
|
30 |
|
31 public: |
|
32 NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
|
33 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMError) |
|
34 |
|
35 // aWindow can be null if this DOMError is not associated with a particular |
|
36 // window. |
|
37 |
|
38 DOMError(nsPIDOMWindow* aWindow); |
|
39 |
|
40 DOMError(nsPIDOMWindow* aWindow, nsresult aValue); |
|
41 |
|
42 DOMError(nsPIDOMWindow* aWindow, const nsAString& aName); |
|
43 |
|
44 DOMError(nsPIDOMWindow* aWindow, const nsAString& aName, |
|
45 const nsAString& aMessage); |
|
46 |
|
47 virtual ~DOMError(); |
|
48 |
|
49 nsPIDOMWindow* GetParentObject() const |
|
50 { |
|
51 return mWindow; |
|
52 } |
|
53 |
|
54 virtual JSObject* |
|
55 WrapObject(JSContext* aCx) MOZ_OVERRIDE; |
|
56 |
|
57 static already_AddRefed<DOMError> |
|
58 Constructor(const GlobalObject& global, const nsAString& name, |
|
59 const nsAString& message, ErrorResult& aRv); |
|
60 |
|
61 void GetName(nsString& aRetval) const |
|
62 { |
|
63 aRetval = mName; |
|
64 } |
|
65 |
|
66 void GetMessage(nsString& aRetval) const |
|
67 { |
|
68 aRetval = mMessage; |
|
69 } |
|
70 |
|
71 void Init(const nsAString& aName, const nsAString& aMessage) |
|
72 { |
|
73 mName = aName; |
|
74 mMessage = aMessage; |
|
75 } |
|
76 }; |
|
77 |
|
78 } // namespace dom |
|
79 } // namespace mozilla |
|
80 |
|
81 #endif // mozilla_dom_domerror_h__ |