2012-01-24 02:13:41 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2015-05-03 12:32:37 -07:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-01-24 02:13:41 -08:00
|
|
|
/* 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*
|
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 07:13:33 -07:00
|
|
|
DOMError::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-05-18 10:52:06 -07:00
|
|
|
{
|
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 07:13:33 -07:00
|
|
|
return DOMErrorBinding::Wrap(aCx, this, aGivenProto);
|
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
|