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/. */
7 #include "mozilla/dom/DOMError.h"
8 #include "mozilla/dom/DOMErrorBinding.h"
9 #include "mozilla/dom/DOMException.h"
10 #include "nsPIDOMWindow.h"
15 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMError
, mWindow
)
16 NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMError
)
17 NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMError
)
18 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMError
)
19 NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
20 NS_INTERFACE_MAP_ENTRY(DOMError
)
21 NS_INTERFACE_MAP_ENTRY(nsISupports
)
24 DOMError::DOMError(nsPIDOMWindow
* aWindow
)
30 DOMError::DOMError(nsPIDOMWindow
* aWindow
, nsresult aValue
)
33 nsCString name
, message
;
34 NS_GetNameAndMessageForDOMNSResult(aValue
, name
, message
);
36 CopyUTF8toUTF16(name
, mName
);
37 CopyUTF8toUTF16(message
, mMessage
);
42 DOMError::DOMError(nsPIDOMWindow
* aWindow
, const nsAString
& aName
)
49 DOMError::DOMError(nsPIDOMWindow
* aWindow
, const nsAString
& aName
,
50 const nsAString
& aMessage
)
63 DOMError::WrapObject(JSContext
* aCx
)
65 return DOMErrorBinding::Wrap(aCx
, this);
68 /* static */ already_AddRefed
<DOMError
>
69 DOMError::Constructor(const GlobalObject
& aGlobal
,
70 const nsAString
& aName
, const nsAString
& aMessage
,
73 nsCOMPtr
<nsPIDOMWindow
> window
= do_QueryInterface(aGlobal
.GetAsSupports());
75 // Window is null for chrome code.
77 nsRefPtr
<DOMError
> ret
= new DOMError(window
, aName
, aMessage
);
82 } // namespace mozilla