2012-01-24 14:13:41 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2015-05-03 22:32:37 +03:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-01-24 14:13:41 +04: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 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"
|
2017-08-08 17:43:32 +03:00
|
|
|
#include "mozilla/UseCounter.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
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
DOMError::DOMError(nsPIDOMWindowInner* aWindow)
|
2013-06-30 16:21:31 +04:00
|
|
|
: mWindow(aWindow)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
DOMError::DOMError(nsPIDOMWindowInner* aWindow, nsresult aValue)
|
2013-05-18 21:52:06 +04:00
|
|
|
: 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);
|
2013-05-18 21:52:06 +04:00
|
|
|
}
|
2012-01-24 14:13:41 +04:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
DOMError::DOMError(nsPIDOMWindowInner* aWindow, const nsAString& aName)
|
2013-05-18 21:52:06 +04:00
|
|
|
: mWindow(aWindow)
|
|
|
|
, mName(aName)
|
2012-04-12 01:55:21 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
DOMError::DOMError(nsPIDOMWindowInner* aWindow, const nsAString& aName,
|
2013-05-18 21:52:06 +04:00
|
|
|
const nsAString& aMessage)
|
|
|
|
: mWindow(aWindow)
|
|
|
|
, mName(aName)
|
|
|
|
, mMessage(aMessage)
|
|
|
|
{
|
|
|
|
}
|
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*
|
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 17:13:33 +03:00
|
|
|
DOMError::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-05-18 21:52:06 +04: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 17:13:33 +03:00
|
|
|
return DOMErrorBinding::Wrap(aCx, this, aGivenProto);
|
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
|
|
|
{
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal.GetAsSupports());
|
2013-05-18 21:52:06 +04:00
|
|
|
|
2017-08-08 17:43:32 +03:00
|
|
|
if (window) {
|
|
|
|
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
|
|
|
|
if (doc) {
|
|
|
|
doc->SetDocumentAndPageUseCounter(eUseCounter_custom_DOMErrorConstructor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-18 21:52:06 +04:00
|
|
|
// Window is null for chrome code.
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DOMError> ret = new DOMError(window, aName, aMessage);
|
2013-05-18 21:52:06 +04:00
|
|
|
return ret.forget();
|
2012-01-24 14:13:41 +04:00
|
|
|
}
|
2013-05-18 21:52:06 +04:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|