2010-06-23 23:46:08 +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-05-21 15:12:37 +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/. */
|
2010-06-23 23:46:08 +04:00
|
|
|
|
|
|
|
#include "IDBEvents.h"
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
#include "mozilla/ErrorResult.h"
|
|
|
|
#include "mozilla/dom/EventTarget.h"
|
|
|
|
#include "mozilla/dom/IDBVersionChangeEventBinding.h"
|
|
|
|
#include "nsString.h"
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
using namespace mozilla;
|
2013-04-20 02:18:32 +04:00
|
|
|
using namespace mozilla::dom;
|
2014-09-27 03:21:57 +04:00
|
|
|
using namespace mozilla::dom::indexedDB;
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
namespace indexedDB {
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2016-07-21 08:03:25 +03:00
|
|
|
const char16_t* kAbortEventType = u"abort";
|
|
|
|
const char16_t* kBlockedEventType = u"blocked";
|
|
|
|
const char16_t* kCompleteEventType = u"complete";
|
|
|
|
const char16_t* kErrorEventType = u"error";
|
|
|
|
const char16_t* kSuccessEventType = u"success";
|
|
|
|
const char16_t* kUpgradeNeededEventType = u"upgradeneeded";
|
|
|
|
const char16_t* kVersionChangeEventType = u"versionchange";
|
|
|
|
const char16_t* kCloseEventType = u"close";
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2018-04-05 20:42:41 +03:00
|
|
|
already_AddRefed<Event>
|
2014-09-27 03:21:57 +04:00
|
|
|
CreateGenericEvent(EventTarget* aOwner,
|
|
|
|
const nsDependentString& aType,
|
|
|
|
Bubbles aBubbles,
|
|
|
|
Cancelable aCancelable)
|
2010-06-23 23:46:08 +04:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Event> event = new Event(aOwner, nullptr, nullptr);
|
2014-09-27 03:21:57 +04:00
|
|
|
|
2015-11-13 03:09:42 +03:00
|
|
|
event->InitEvent(aType,
|
|
|
|
aBubbles == eDoesBubble ? true : false,
|
|
|
|
aCancelable == eCancelable ? true : false);
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2012-12-22 12:18:08 +04:00
|
|
|
event->SetTrusted(true);
|
2010-06-23 23:46:08 +04:00
|
|
|
|
2011-01-07 09:21:36 +03:00
|
|
|
return event.forget();
|
2010-06-23 23:46:08 +04:00
|
|
|
}
|
|
|
|
|
2016-02-17 00:46:08 +03:00
|
|
|
} // namespace indexedDB
|
|
|
|
|
2010-10-19 21:58:52 +04:00
|
|
|
// static
|
2013-07-05 21:57:28 +04:00
|
|
|
already_AddRefed<IDBVersionChangeEvent>
|
2014-09-27 03:21:57 +04:00
|
|
|
IDBVersionChangeEvent::CreateInternal(EventTarget* aOwner,
|
2013-03-09 15:34:29 +04:00
|
|
|
const nsAString& aType,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t aOldVersion,
|
2017-02-13 20:07:40 +03:00
|
|
|
const Nullable<uint64_t>& aNewVersion)
|
2010-10-19 21:58:52 +04:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<IDBVersionChangeEvent> event =
|
2014-09-27 03:21:57 +04:00
|
|
|
new IDBVersionChangeEvent(aOwner, aOldVersion);
|
|
|
|
if (!aNewVersion.IsNull()) {
|
|
|
|
event->mNewVersion.SetValue(aNewVersion.Value());
|
|
|
|
}
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2015-11-13 03:09:42 +03:00
|
|
|
event->InitEvent(aType, false, false);
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2012-12-22 12:18:08 +04:00
|
|
|
event->SetTrusted(true);
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2012-12-22 12:18:08 +04:00
|
|
|
return event.forget();
|
2010-10-19 21:58:52 +04:00
|
|
|
}
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
already_AddRefed<IDBVersionChangeEvent>
|
|
|
|
IDBVersionChangeEvent::Constructor(const GlobalObject& aGlobal,
|
|
|
|
const nsAString& aType,
|
|
|
|
const IDBVersionChangeEventInit& aOptions,
|
|
|
|
ErrorResult& aRv)
|
2010-10-19 21:58:52 +04:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
nsCOMPtr<EventTarget> target = do_QueryInterface(aGlobal.GetAsSupports());
|
2010-10-19 21:58:52 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
return CreateInternal(target,
|
|
|
|
aType,
|
|
|
|
aOptions.mOldVersion,
|
|
|
|
aOptions.mNewVersion);
|
2010-10-19 21:58:52 +04:00
|
|
|
}
|
|
|
|
|
2014-03-05 04:37:43 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(IDBVersionChangeEvent, Event)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(IDBVersionChangeEvent, Event)
|
2010-10-19 21:58:52 +04:00
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN(IDBVersionChangeEvent)
|
2013-07-11 21:36:42 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(IDBVersionChangeEvent)
|
2014-03-05 04:37:43 +04:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(Event)
|
2014-09-27 03:21:57 +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
|
|
|
IDBVersionChangeEvent::WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2014-09-27 03:21:57 +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 IDBVersionChangeEventBinding::Wrap(aCx, this, aGivenProto);
|
2014-09-27 03:21:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|