2012-01-24 14:13:41 +04: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 21:52:06 +04:00
|
|
|
#include "mozilla/dom/DOMError.h"
|
|
|
|
#include "mozilla/dom/DOMErrorBinding.h"
|
2013-11-20 20:29:03 +04:00
|
|
|
#include "mozilla/dom/DOMException.h"
|
2013-05-18 21:52:06 +04:00
|
|
|
#include "nsPIDOMWindow.h"
|
2012-01-24 14:13:41 +04:00
|
|
|
|
2013-05-18 21:52:06 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2012-01-24 14:13:41 +04:00
|
|
|
|
2014-04-29 12:57:00 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMError, mWindow)
|
2013-05-18 21:52:06 +04: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-20 00:37:58 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(DOMError)
|
2013-05-18 21:52:06 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
2012-01-24 14:13:41 +04:00
|
|
|
|
2013-06-30 16:21:31 +04:00
|
|
|
DOMError::DOMError(nsPIDOMWindow* aWindow)
|
|
|
|
: mWindow(aWindow)
|
|
|
|
{
|
|
|
|
SetIsDOMBinding();
|
|
|
|
}
|
|
|
|
|
2013-05-18 21:52:06 +04:00
|
|
|
DOMError::DOMError(nsPIDOMWindow* aWindow, nsresult aValue)
|
|
|
|
: mWindow(aWindow)
|
2012-01-24 14:13:41 +04:00
|
|
|
{
|
2014-01-20 20:51:41 +04:00
|
|
|
nsCString name, message;
|
|
|
|
NS_GetNameAndMessageForDOMNSResult(aValue, name, message);
|
2013-05-18 21:52:06 +04:00
|
|
|
|
2014-01-20 20:51:41 +04:00
|
|
|
CopyUTF8toUTF16(name, mName);
|
|
|
|
CopyUTF8toUTF16(message, mMessage);
|
2012-01-24 14:13:41 +04:00
|
|
|
|
2013-05-18 21:52:06 +04:00
|
|
|
SetIsDOMBinding();
|
|
|
|
}
|
2012-01-24 14:13:41 +04:00
|
|
|
|
2013-05-18 21:52:06 +04:00
|
|
|
DOMError::DOMError(nsPIDOMWindow* aWindow, const nsAString& aName)
|
|
|
|
: mWindow(aWindow)
|
|
|
|
, mName(aName)
|
2012-04-12 01:55:21 +04:00
|
|
|
{
|
2013-05-18 21:52:06 +04:00
|
|
|
SetIsDOMBinding();
|
2012-04-12 01:55:21 +04:00
|
|
|
}
|
|
|
|
|
2013-05-18 21:52:06 +04:00
|
|
|
DOMError::DOMError(nsPIDOMWindow* aWindow, const nsAString& aName,
|
|
|
|
const nsAString& aMessage)
|
|
|
|
: mWindow(aWindow)
|
|
|
|
, mName(aName)
|
|
|
|
, mMessage(aMessage)
|
|
|
|
{
|
|
|
|
SetIsDOMBinding();
|
|
|
|
}
|
2012-01-24 14:13:41 +04:00
|
|
|
|
2013-05-18 21:52:06 +04:00
|
|
|
DOMError::~DOMError()
|
|
|
|
{
|
|
|
|
}
|
2012-01-24 14:13:41 +04:00
|
|
|
|
2013-05-18 21:52:06 +04:00
|
|
|
JSObject*
|
2014-04-09 02:27:18 +04:00
|
|
|
DOMError::WrapObject(JSContext* aCx)
|
2013-05-18 21:52:06 +04: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-09 02:27:17 +04:00
|
|
|
return DOMErrorBinding::Wrap(aCx, this);
|
2013-05-18 21:52:06 +04:00
|
|
|
}
|
2012-01-24 14:13:41 +04:00
|
|
|
|
2013-05-18 21:52:06 +04:00
|
|
|
/* static */ already_AddRefed<DOMError>
|
2013-08-23 09:17:08 +04:00
|
|
|
DOMError::Constructor(const GlobalObject& aGlobal,
|
|
|
|
const nsAString& aName, const nsAString& aMessage,
|
|
|
|
ErrorResult& aRv)
|
2012-01-24 14:13:41 +04:00
|
|
|
{
|
2013-08-23 09:17:08 +04:00
|
|
|
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
|
2013-05-18 21:52:06 +04:00
|
|
|
|
|
|
|
// Window is null for chrome code.
|
|
|
|
|
|
|
|
nsRefPtr<DOMError> ret = new DOMError(window, aName, aMessage);
|
|
|
|
return ret.forget();
|
2012-01-24 14:13:41 +04:00
|
|
|
}
|
2013-05-18 21:52:06 +04:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|