mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
e4e2da55c9
The bulk of this commit was generated with a script, executed at the top level of a typical source code checkout. The only non-machine-generated part was modifying MFBT's moz.build to reflect the new naming. CLOSED TREE makes big refactorings like this a piece of cake. # The main substitution. find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \ xargs perl -p -i -e ' s/nsRefPtr\.h/RefPtr\.h/g; # handle includes s/nsRefPtr ?</RefPtr</g; # handle declarations and variables ' # Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h. perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h # Handle nsRefPtr.h itself, a couple places that define constructors # from nsRefPtr, and code generators specially. We do this here, rather # than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename # things like nsRefPtrHashtable. perl -p -i -e 's/nsRefPtr/RefPtr/g' \ mfbt/nsRefPtr.h \ xpcom/glue/nsCOMPtr.h \ xpcom/base/OwningNonNull.h \ ipc/ipdl/ipdl/lower.py \ ipc/ipdl/ipdl/builtin.py \ dom/bindings/Codegen.py \ python/lldbutils/lldbutils/utils.py # In our indiscriminate substitution above, we renamed # nsRefPtrGetterAddRefs, the class behind getter_AddRefs. Fix that up. find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \ xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g' if [ -d .git ]; then git mv mfbt/nsRefPtr.h mfbt/RefPtr.h else hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h fi
188 lines
5.5 KiB
C++
188 lines
5.5 KiB
C++
/* vim: set ts=8 sts=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/. */
|
|
|
|
#include "mozilla/dom/ServiceWorkerMessageEvent.h"
|
|
#include "mozilla/dom/ServiceWorkerMessageEventBinding.h"
|
|
#include "mozilla/dom/MessagePort.h"
|
|
#include "mozilla/dom/MessagePortBinding.h"
|
|
#include "mozilla/dom/MessagePortList.h"
|
|
|
|
#include "mozilla/HoldDropJSObjects.h"
|
|
#include "jsapi.h"
|
|
|
|
#include "ServiceWorker.h"
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(ServiceWorkerMessageEvent)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(ServiceWorkerMessageEvent, Event)
|
|
tmp->mData.setUndefined();
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mServiceWorker)
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mMessagePort)
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mPorts)
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(ServiceWorkerMessageEvent, Event)
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mServiceWorker)
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMessagePort)
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPorts)
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(ServiceWorkerMessageEvent, Event)
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_JSVAL_MEMBER_CALLBACK(mData)
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ServiceWorkerMessageEvent)
|
|
NS_INTERFACE_MAP_END_INHERITING(Event)
|
|
|
|
NS_IMPL_ADDREF_INHERITED(ServiceWorkerMessageEvent, Event)
|
|
NS_IMPL_RELEASE_INHERITED(ServiceWorkerMessageEvent, Event)
|
|
|
|
ServiceWorkerMessageEvent::ServiceWorkerMessageEvent(EventTarget* aOwner,
|
|
nsPresContext* aPresContext,
|
|
WidgetEvent* aEvent)
|
|
: Event(aOwner, aPresContext, aEvent)
|
|
, mData(JS::UndefinedValue())
|
|
{
|
|
mozilla::HoldJSObjects(this);
|
|
}
|
|
|
|
ServiceWorkerMessageEvent::~ServiceWorkerMessageEvent()
|
|
{
|
|
mData.setUndefined();
|
|
DropJSObjects(this);
|
|
}
|
|
|
|
JSObject*
|
|
ServiceWorkerMessageEvent::WrapObjectInternal(JSContext* aCx,
|
|
JS::Handle<JSObject*> aGivenProto)
|
|
{
|
|
return mozilla::dom::ServiceWorkerMessageEventBinding::Wrap(aCx, this, aGivenProto);
|
|
}
|
|
|
|
|
|
void
|
|
ServiceWorkerMessageEvent::GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData,
|
|
ErrorResult& aRv) const
|
|
{
|
|
JS::ExposeValueToActiveJS(mData);
|
|
aData.set(mData);
|
|
if (!JS_WrapValue(aCx, aData)) {
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
}
|
|
}
|
|
|
|
void
|
|
ServiceWorkerMessageEvent::GetOrigin(nsAString& aOrigin) const
|
|
{
|
|
aOrigin = mOrigin;
|
|
}
|
|
|
|
void
|
|
ServiceWorkerMessageEvent::GetLastEventId(nsAString& aLastEventId) const
|
|
{
|
|
aLastEventId = mLastEventId;
|
|
}
|
|
|
|
void
|
|
ServiceWorkerMessageEvent::GetSource(Nullable<OwningServiceWorkerOrMessagePort>& aValue) const
|
|
{
|
|
if (mServiceWorker) {
|
|
aValue.SetValue().SetAsServiceWorker() = mServiceWorker;
|
|
} else if (mMessagePort) {
|
|
aValue.SetValue().SetAsMessagePort() = mMessagePort;
|
|
}
|
|
}
|
|
|
|
void
|
|
ServiceWorkerMessageEvent::SetSource(mozilla::dom::MessagePort* aPort)
|
|
{
|
|
mMessagePort = aPort;
|
|
}
|
|
|
|
void
|
|
ServiceWorkerMessageEvent::SetSource(workers::ServiceWorker* aServiceWorker)
|
|
{
|
|
mServiceWorker = aServiceWorker;
|
|
}
|
|
|
|
void
|
|
ServiceWorkerMessageEvent::SetPorts(MessagePortList* aPorts)
|
|
{
|
|
MOZ_ASSERT(!mPorts && aPorts);
|
|
mPorts = aPorts;
|
|
}
|
|
|
|
MessagePortList*
|
|
ServiceWorkerMessageEvent::GetPorts() const
|
|
{
|
|
return mPorts;
|
|
}
|
|
|
|
/* static */ already_AddRefed<ServiceWorkerMessageEvent>
|
|
ServiceWorkerMessageEvent::Constructor(const GlobalObject& aGlobal,
|
|
const nsAString& aType,
|
|
const ServiceWorkerMessageEventInit& aParam,
|
|
ErrorResult& aRv)
|
|
{
|
|
nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
|
|
return Constructor(t, aType, aParam, aRv);
|
|
}
|
|
|
|
/* static */ already_AddRefed<ServiceWorkerMessageEvent>
|
|
ServiceWorkerMessageEvent::Constructor(EventTarget* aEventTarget,
|
|
const nsAString& aType,
|
|
const ServiceWorkerMessageEventInit& aParam,
|
|
ErrorResult& aRv)
|
|
{
|
|
RefPtr<ServiceWorkerMessageEvent> event =
|
|
new ServiceWorkerMessageEvent(aEventTarget, nullptr, nullptr);
|
|
|
|
aRv = event->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
|
|
if (NS_WARN_IF(aRv.Failed())) {
|
|
return nullptr;
|
|
}
|
|
|
|
bool trusted = event->Init(aEventTarget);
|
|
event->SetTrusted(trusted);
|
|
|
|
event->mData = aParam.mData;
|
|
|
|
if (aParam.mOrigin.WasPassed()) {
|
|
event->mOrigin = aParam.mOrigin.Value();
|
|
}
|
|
|
|
if (aParam.mLastEventId.WasPassed()) {
|
|
event->mLastEventId = aParam.mLastEventId.Value();
|
|
}
|
|
|
|
if (aParam.mSource.WasPassed() && !aParam.mSource.Value().IsNull()) {
|
|
|
|
if (aParam.mSource.Value().Value().IsServiceWorker()) {
|
|
event->mServiceWorker = aParam.mSource.Value().Value().GetAsServiceWorker();
|
|
} else {
|
|
event->mMessagePort = aParam.mSource.Value().Value().GetAsMessagePort();
|
|
}
|
|
|
|
MOZ_ASSERT(event->mServiceWorker || event->mMessagePort);
|
|
}
|
|
|
|
if (aParam.mPorts.WasPassed() && !aParam.mPorts.Value().IsNull()) {
|
|
nsTArray<RefPtr<MessagePort>> ports;
|
|
for (uint32_t i = 0, len = aParam.mPorts.Value().Value().Length(); i < len; ++i) {
|
|
ports.AppendElement(aParam.mPorts.Value().Value()[i].get());
|
|
}
|
|
|
|
event->mPorts = new MessagePortList(static_cast<EventBase*>(event), ports);
|
|
}
|
|
|
|
return event.forget();
|
|
}
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|