2012-01-24 02:13:41 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
|
|
|
/* 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/. */
|
|
|
|
|
2013-05-18 10:52:06 -07:00
|
|
|
#include "mozilla/dom/DOMError.h"
|
|
|
|
#include "mozilla/dom/DOMErrorBinding.h"
|
2013-11-20 08:29:03 -08:00
|
|
|
#include "mozilla/dom/DOMException.h"
|
2013-05-18 10:52:06 -07:00
|
|
|
#include "nsPIDOMWindow.h"
|
2012-01-24 02:13:41 -08:00
|
|
|
|
2013-05-18 10:52:06 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2012-01-24 02:13:41 -08:00
|
|
|
|
2014-04-29 01:57:00 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMError, mWindow)
|
2013-05-18 10:52:06 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMError)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMError)
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMError)
|
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
2014-05-19 13:37:58 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY(DOMError)
|
2013-05-18 10:52:06 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
2012-01-24 02:13:41 -08:00
|
|
|
|
2013-06-30 05:21:31 -07:00
|
|
|
DOMError::DOMError(nsPIDOMWindow* aWindow)
|
|
|
|
: mWindow(aWindow)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-18 10:52:06 -07:00
|
|
|
DOMError::DOMError(nsPIDOMWindow* aWindow, nsresult aValue)
|
|
|
|
: mWindow(aWindow)
|
2012-01-24 02:13:41 -08:00
|
|
|
{
|
2014-01-20 08:51:41 -08:00
|
|
|
nsCString name, message;
|
|
|
|
NS_GetNameAndMessageForDOMNSResult(aValue, name, message);
|
2013-05-18 10:52:06 -07:00
|
|
|
|
2014-01-20 08:51:41 -08:00
|
|
|
CopyUTF8toUTF16(name, mName);
|
|
|
|
CopyUTF8toUTF16(message, mMessage);
|
2013-05-18 10:52:06 -07:00
|
|
|
}
|
2012-01-24 02:13:41 -08:00
|
|
|
|
2013-05-18 10:52:06 -07:00
|
|
|
DOMError::DOMError(nsPIDOMWindow* aWindow, const nsAString& aName)
|
|
|
|
: mWindow(aWindow)
|
|
|
|
, mName(aName)
|
2012-04-11 14:55:21 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-18 10:52:06 -07:00
|
|
|
DOMError::DOMError(nsPIDOMWindow* aWindow, const nsAString& aName,
|
|
|
|
const nsAString& aMessage)
|
|
|
|
: mWindow(aWindow)
|
|
|
|
, mName(aName)
|
|
|
|
, mMessage(aMessage)
|
|
|
|
{
|
|
|
|
}
|
2012-01-24 02:13:41 -08:00
|
|
|
|
2013-05-18 10:52:06 -07:00
|
|
|
DOMError::~DOMError()
|
|
|
|
{
|
|
|
|
}
|
2012-01-24 02:13:41 -08:00
|
|
|
|
2013-05-18 10:52:06 -07:00
|
|
|
JSObject*
|
2014-04-08 15:27:18 -07:00
|
|
|
DOMError::WrapObject(JSContext* aCx)
|
2013-05-18 10:52:06 -07:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-08 15:27:17 -07:00
|
|
|
return DOMErrorBinding::Wrap(aCx, this);
|
2013-05-18 10:52:06 -07:00
|
|
|
}
|
2012-01-24 02:13:41 -08:00
|
|
|
|
2013-05-18 10:52:06 -07:00
|
|
|
/* static */ already_AddRefed<DOMError>
|
2013-08-22 22:17:08 -07:00
|
|
|
DOMError::Constructor(const GlobalObject& aGlobal,
|
|
|
|
const nsAString& aName, const nsAString& aMessage,
|
|
|
|
ErrorResult& aRv)
|
2012-01-24 02:13:41 -08:00
|
|
|
{
|
2013-08-22 22:17:08 -07:00
|
|
|
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
|
2013-05-18 10:52:06 -07:00
|
|
|
|
|
|
|
// Window is null for chrome code.
|
|
|
|
|
|
|
|
nsRefPtr<DOMError> ret = new DOMError(window, aName, aMessage);
|
|
|
|
return ret.forget();
|
2012-01-24 02:13:41 -08:00
|
|
|
}
|
2013-05-18 10:52:06 -07:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|