2014-06-07 00:52:15 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* 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/MediaKeyMessageEvent.h"
|
|
|
|
#include "mozilla/dom/MediaKeyMessageEventBinding.h"
|
|
|
|
#include "js/GCAPI.h"
|
|
|
|
#include "jsfriendapi.h"
|
|
|
|
#include "mozilla/dom/Nullable.h"
|
|
|
|
#include "mozilla/dom/PrimitiveConversions.h"
|
|
|
|
#include "mozilla/HoldDropJSObjects.h"
|
|
|
|
#include "mozilla/dom/TypedArray.h"
|
|
|
|
#include "nsContentUtils.h"
|
2014-08-27 12:46:56 +04:00
|
|
|
#include "mozilla/dom/MediaKeys.h"
|
2014-06-07 00:52:15 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(MediaKeyMessageEvent)
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF_INHERITED(MediaKeyMessageEvent, Event)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(MediaKeyMessageEvent, Event)
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(MediaKeyMessageEvent, Event)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(MediaKeyMessageEvent, Event)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mMessage)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(MediaKeyMessageEvent, Event)
|
|
|
|
tmp->mMessage = nullptr;
|
2015-09-11 22:05:00 +03:00
|
|
|
mozilla::DropJSObjects(this);
|
2014-06-07 00:52:15 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(MediaKeyMessageEvent)
|
|
|
|
NS_INTERFACE_MAP_END_INHERITING(Event)
|
|
|
|
|
|
|
|
MediaKeyMessageEvent::MediaKeyMessageEvent(EventTarget* aOwner)
|
|
|
|
: Event(aOwner, nullptr, nullptr)
|
|
|
|
{
|
|
|
|
mozilla::HoldJSObjects(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
MediaKeyMessageEvent::~MediaKeyMessageEvent()
|
|
|
|
{
|
|
|
|
mMessage = nullptr;
|
|
|
|
mozilla::DropJSObjects(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
MediaKeyMessageEvent*
|
|
|
|
MediaKeyMessageEvent::AsMediaKeyMessageEvent()
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
MediaKeyMessageEvent::WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2014-06-07 00:52:15 +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 MediaKeyMessageEventBinding::Wrap(aCx, this, aGivenProto);
|
2014-06-07 00:52:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<MediaKeyMessageEvent>
|
|
|
|
MediaKeyMessageEvent::Constructor(EventTarget* aOwner,
|
2015-01-15 01:25:47 +03:00
|
|
|
MediaKeyMessageType aMessageType,
|
2014-06-07 00:52:15 +04:00
|
|
|
const nsTArray<uint8_t>& aMessage)
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<MediaKeyMessageEvent> e = new MediaKeyMessageEvent(aOwner);
|
2014-06-07 00:52:15 +04:00
|
|
|
e->InitEvent(NS_LITERAL_STRING("message"), false, false);
|
2015-01-15 01:25:47 +03:00
|
|
|
e->mMessageType = aMessageType;
|
2014-06-07 00:52:15 +04:00
|
|
|
e->mRawMessage = aMessage;
|
|
|
|
e->SetTrusted(true);
|
|
|
|
return e.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<MediaKeyMessageEvent>
|
|
|
|
MediaKeyMessageEvent::Constructor(const GlobalObject& aGlobal,
|
|
|
|
const nsAString& aType,
|
|
|
|
const MediaKeyMessageEventInit& aEventInitDict,
|
|
|
|
ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
nsCOMPtr<EventTarget> owner = do_QueryInterface(aGlobal.GetAsSupports());
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<MediaKeyMessageEvent> e = new MediaKeyMessageEvent(owner);
|
2014-06-07 00:52:15 +04:00
|
|
|
bool trusted = e->Init(owner);
|
|
|
|
e->InitEvent(aType, aEventInitDict.mBubbles, aEventInitDict.mCancelable);
|
2016-10-19 10:33:54 +03:00
|
|
|
aEventInitDict.mMessage.ComputeLengthAndData();
|
|
|
|
e->mMessage = ArrayBuffer::Create(aGlobal.Context(),
|
|
|
|
aEventInitDict.mMessage.Length(),
|
|
|
|
aEventInitDict.mMessage.Data());
|
2014-06-07 00:52:15 +04:00
|
|
|
if (!e->mMessage) {
|
|
|
|
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
return nullptr;
|
|
|
|
}
|
2015-01-15 01:25:47 +03:00
|
|
|
e->mMessageType = aEventInitDict.mMessageType;
|
2014-06-07 00:52:15 +04:00
|
|
|
e->SetTrusted(trusted);
|
2016-08-31 06:16:11 +03:00
|
|
|
e->SetComposed(aEventInitDict.mComposed);
|
2014-06-07 00:52:15 +04:00
|
|
|
return e.forget();
|
|
|
|
}
|
|
|
|
|
2014-06-12 00:26:52 +04:00
|
|
|
void
|
|
|
|
MediaKeyMessageEvent::GetMessage(JSContext* cx,
|
|
|
|
JS::MutableHandle<JSObject*> aMessage,
|
|
|
|
ErrorResult& aRv)
|
2014-06-07 00:52:15 +04:00
|
|
|
{
|
|
|
|
if (!mMessage) {
|
2014-08-27 12:46:56 +04:00
|
|
|
mMessage = ArrayBuffer::Create(cx,
|
2015-09-11 22:05:00 +03:00
|
|
|
this,
|
2014-08-27 12:46:56 +04:00
|
|
|
mRawMessage.Length(),
|
|
|
|
mRawMessage.Elements());
|
2014-06-07 00:52:15 +04:00
|
|
|
if (!mMessage) {
|
|
|
|
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
2014-06-12 00:26:52 +04:00
|
|
|
return;
|
2014-06-07 00:52:15 +04:00
|
|
|
}
|
|
|
|
mRawMessage.Clear();
|
|
|
|
}
|
2014-06-12 00:26:52 +04:00
|
|
|
aMessage.set(mMessage);
|
2014-06-07 00:52:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|