Bug 1057173 - Rename MediaKeyNeededEvent to MediaEncryptedEvent. r=bz

--HG--
rename : content/media/eme/MediaKeyNeededEvent.cpp => content/media/eme/MediaEncryptedEvent.cpp
rename : content/media/eme/MediaKeyNeededEvent.h => content/media/eme/MediaEncryptedEvent.h
rename : dom/webidl/MediaKeyNeededEvent.webidl => dom/webidl/MediaEncryptedEvent.webidl
This commit is contained in:
Chris Pearce 2014-08-27 20:46:56 +12:00
parent 300def5932
commit 708e5b48b9
12 changed files with 58 additions and 59 deletions

View File

@ -1966,8 +1966,8 @@ GK_ATOM(oncontrollerchange, "oncontrollerchange")
GK_ATOM(oncuechange, "oncuechange")
GK_ATOM(onenter, "onenter")
GK_ATOM(onexit, "onexit")
GK_ATOM(onneedkey, "onneedkey")
GK_ATOM(needkey, "needkey")
GK_ATOM(onencrypted, "onencrypted")
GK_ATOM(encrypted, "encrypted")
GK_ATOM(onremovetrack, "onremovetrack")
GK_ATOM(loadstart, "loadstart")
GK_ATOM(suspend, "suspend")

View File

@ -537,11 +537,11 @@ public:
MediaWaitingFor WaitingFor() const;
mozilla::dom::EventHandlerNonNull* GetOnneedkey();
void SetOnneedkey(mozilla::dom::EventHandlerNonNull* listener);
mozilla::dom::EventHandlerNonNull* GetOnencrypted();
void SetOnencrypted(mozilla::dom::EventHandlerNonNull* listener);
void DispatchNeedKey(const nsTArray<uint8_t>& aInitData,
const nsAString& aInitDataType);
void DispatchEncrypted(const nsTArray<uint8_t>& aInitData,
const nsAString& aInitDataType);
bool IsEventAttributeName(nsIAtom* aName) MOZ_OVERRIDE;

View File

@ -12,7 +12,7 @@
#include "mozilla/MathAlgorithms.h"
#include "mozilla/AsyncEventDispatcher.h"
#ifdef MOZ_EME
#include "mozilla/dom/MediaKeyNeededEvent.h"
#include "mozilla/dom/MediaEncryptedEvent.h"
#endif
#include "base/basictypes.h"
@ -4018,28 +4018,28 @@ HTMLMediaElement::WaitingFor() const
}
EventHandlerNonNull*
HTMLMediaElement::GetOnneedkey()
HTMLMediaElement::GetOnencrypted()
{
EventListenerManager *elm = GetExistingListenerManager();
return elm ? elm->GetEventHandler(nsGkAtoms::onneedkey, EmptyString())
return elm ? elm->GetEventHandler(nsGkAtoms::onencrypted, EmptyString())
: nullptr;
}
void
HTMLMediaElement::SetOnneedkey(EventHandlerNonNull* handler)
HTMLMediaElement::SetOnencrypted(EventHandlerNonNull* handler)
{
EventListenerManager *elm = GetOrCreateListenerManager();
if (elm) {
elm->SetEventHandler(nsGkAtoms::onneedkey, EmptyString(), handler);
elm->SetEventHandler(nsGkAtoms::onencrypted, EmptyString(), handler);
}
}
void
HTMLMediaElement::DispatchNeedKey(const nsTArray<uint8_t>& aInitData,
const nsAString& aInitDataType)
HTMLMediaElement::DispatchEncrypted(const nsTArray<uint8_t>& aInitData,
const nsAString& aInitDataType)
{
nsRefPtr<MediaKeyNeededEvent> event(
MediaKeyNeededEvent::Constructor(this, aInitDataType, aInitData));
nsRefPtr<MediaEncryptedEvent> event(
MediaEncryptedEvent::Constructor(this, aInitDataType, aInitData));
nsRefPtr<AsyncEventDispatcher> asyncDispatcher =
new AsyncEventDispatcher(this, event);
asyncDispatcher->PostDOMEvent();
@ -4048,7 +4048,7 @@ HTMLMediaElement::DispatchNeedKey(const nsTArray<uint8_t>& aInitData,
bool
HTMLMediaElement::IsEventAttributeName(nsIAtom* aName)
{
return aName == nsGkAtoms::onneedkey ||
return aName == nsGkAtoms::onencrypted ||
nsGenericHTMLElement::IsEventAttributeName(aName);
}
#endif // MOZ_EME

View File

@ -139,11 +139,11 @@ public:
virtual void ResetConnectionState() = 0;
#ifdef MOZ_EME
// Dispatches a "needkey" event to the HTMLMediaElement, with the
// Dispatches a "encrypted" event to the HTMLMediaElement, with the
// provided init data.
// Main thread only.
virtual void DispatchNeedKey(const nsTArray<uint8_t>& aInitData,
const nsAString& aInitDataType) = 0;
virtual void DispatchEncrypted(const nsTArray<uint8_t>& aInitData,
const nsAString& aInitDataType) = 0;
#endif
};

View File

@ -4,8 +4,8 @@
* 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 "MediaKeyNeededEvent.h"
#include "mozilla/dom/MediaKeyNeededEventBinding.h"
#include "MediaEncryptedEvent.h"
#include "mozilla/dom/MediaEncryptedEventBinding.h"
#include "nsContentUtils.h"
#include "jsfriendapi.h"
#include "nsINode.h"
@ -13,70 +13,69 @@
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION_CLASS(MediaKeyNeededEvent)
NS_IMPL_CYCLE_COLLECTION_CLASS(MediaEncryptedEvent)
NS_IMPL_ADDREF_INHERITED(MediaKeyNeededEvent, Event)
NS_IMPL_RELEASE_INHERITED(MediaKeyNeededEvent, Event)
NS_IMPL_ADDREF_INHERITED(MediaEncryptedEvent, Event)
NS_IMPL_RELEASE_INHERITED(MediaEncryptedEvent, Event)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(MediaKeyNeededEvent, Event)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(MediaEncryptedEvent, Event)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(MediaKeyNeededEvent, Event)
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(MediaEncryptedEvent, Event)
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mInitData)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(MediaKeyNeededEvent, Event)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(MediaEncryptedEvent, Event)
tmp->mInitData = nullptr;
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(MediaKeyNeededEvent)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(MediaEncryptedEvent)
NS_INTERFACE_MAP_END_INHERITING(Event)
MediaKeyNeededEvent::MediaKeyNeededEvent(EventTarget* aOwner)
MediaEncryptedEvent::MediaEncryptedEvent(EventTarget* aOwner)
: Event(aOwner, nullptr, nullptr)
{
mozilla::HoldJSObjects(this);
}
MediaKeyNeededEvent::~MediaKeyNeededEvent()
MediaEncryptedEvent::~MediaEncryptedEvent()
{
mInitData = nullptr;
mozilla::DropJSObjects(this);
}
JSObject*
MediaKeyNeededEvent::WrapObject(JSContext* aCx)
MediaEncryptedEvent::WrapObject(JSContext* aCx)
{
return MediaKeyNeededEventBinding::Wrap(aCx, this);
return MediaEncryptedEventBinding::Wrap(aCx, this);
}
already_AddRefed<MediaKeyNeededEvent>
MediaKeyNeededEvent::Constructor(EventTarget* aOwner,
already_AddRefed<MediaEncryptedEvent>
MediaEncryptedEvent::Constructor(EventTarget* aOwner,
const nsAString& aInitDataType,
const nsTArray<uint8_t>& aInitData)
{
nsRefPtr<MediaKeyNeededEvent> e = new MediaKeyNeededEvent(aOwner);
e->InitEvent(NS_LITERAL_STRING("needkey"), false, false);
nsRefPtr<MediaEncryptedEvent> e = new MediaEncryptedEvent(aOwner);
e->InitEvent(NS_LITERAL_STRING("encrypted"), false, false);
e->mInitDataType = aInitDataType;
e->mRawInitData = aInitData;
e->SetTrusted(true);
return e.forget();
}
already_AddRefed<MediaKeyNeededEvent>
MediaKeyNeededEvent::Constructor(const GlobalObject& aGlobal,
already_AddRefed<MediaEncryptedEvent>
MediaEncryptedEvent::Constructor(const GlobalObject& aGlobal,
const nsAString& aType,
const MediaKeyNeededEventInit& aEventInitDict,
ErrorResult& aRv)
{
nsCOMPtr<EventTarget> owner = do_QueryInterface(aGlobal.GetAsSupports());
nsRefPtr<MediaKeyNeededEvent> e = new MediaKeyNeededEvent(owner);
nsRefPtr<MediaEncryptedEvent> e = new MediaEncryptedEvent(owner);
bool trusted = e->Init(owner);
e->InitEvent(aType, aEventInitDict.mBubbles, aEventInitDict.mCancelable);
e->mInitDataType = aEventInitDict.mInitDataType;
if (aEventInitDict.mInitData.WasPassed() &&
!aEventInitDict.mInitData.Value().IsNull()) {
const auto& a = aEventInitDict.mInitData.Value().Value();
if (!aEventInitDict.mInitData.IsNull()) {
const auto& a = aEventInitDict.mInitData.Value();
a.ComputeLengthAndData();
e->mInitData = Uint8Array::Create(aGlobal.Context(), owner, a.Length(), a.Data());
if (!e->mInitData) {
@ -89,13 +88,13 @@ MediaKeyNeededEvent::Constructor(const GlobalObject& aGlobal,
}
void
MediaKeyNeededEvent::GetInitDataType(nsString& aRetVal) const
MediaEncryptedEvent::GetInitDataType(nsString& aRetVal) const
{
aRetVal = mInitDataType;
}
void
MediaKeyNeededEvent::GetInitData(JSContext* cx,
MediaEncryptedEvent::GetInitData(JSContext* cx,
JS::MutableHandle<JSObject*> aData,
ErrorResult& aRv)
{

View File

@ -7,7 +7,7 @@
#ifndef mozilla_dom_MediaKeyNeededEvent_h__
#define mozilla_dom_MediaKeyNeededEvent_h__
#include "mozilla/dom/MediaKeyNeededEventBinding.h"
#include "mozilla/dom/MediaEncryptedEventBinding.h"
#include "mozilla/Attributes.h"
#include "mozilla/ErrorResult.h"
#include "nsCycleCollectionParticipant.h"
@ -22,14 +22,14 @@
namespace mozilla {
namespace dom {
class MediaKeyNeededEvent MOZ_FINAL : public Event
class MediaEncryptedEvent MOZ_FINAL : public Event
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(MediaKeyNeededEvent, Event)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(MediaEncryptedEvent, Event)
protected:
virtual ~MediaKeyNeededEvent();
MediaKeyNeededEvent(EventTarget* aOwner);
virtual ~MediaEncryptedEvent();
MediaEncryptedEvent(EventTarget* aOwner);
nsString mInitDataType;
JS::Heap<JSObject*> mInitData;
@ -38,12 +38,12 @@ public:
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
static already_AddRefed<MediaKeyNeededEvent>
static already_AddRefed<MediaEncryptedEvent>
Constructor(EventTarget* aOwner,
const nsAString& aInitDataType,
const nsTArray<uint8_t>& aInitData);
static already_AddRefed<MediaKeyNeededEvent>
static already_AddRefed<MediaEncryptedEvent>
Constructor(const GlobalObject& aGlobal,
const nsAString& aType,
const MediaKeyNeededEventInit& aEventInitDict,

View File

@ -8,7 +8,7 @@
#include "mozilla/dom/MediaKeySession.h"
#include "mozilla/dom/MediaKeyError.h"
#include "mozilla/dom/MediaKeyMessageEvent.h"
#include "mozilla/dom/MediaKeyNeededEvent.h"
#include "mozilla/dom/MediaEncryptedEvent.h"
#include "nsCycleCollectionParticipant.h"
#include "mozilla/CDMProxy.h"
#include "mozilla/AsyncEventDispatcher.h"

View File

@ -5,9 +5,9 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXPORTS.mozilla.dom += [
'MediaEncryptedEvent.h',
'MediaKeyError.h',
'MediaKeyMessageEvent.h',
'MediaKeyNeededEvent.h',
'MediaKeys.h',
'MediaKeySession.h',
]
@ -24,9 +24,9 @@ UNIFIED_SOURCES += [
'CDMCaps.cpp',
'CDMProxy.cpp',
'EMELog.cpp',
'MediaEncryptedEvent.cpp',
'MediaKeyError.cpp',
'MediaKeyMessageEvent.cpp',
'MediaKeyNeededEvent.cpp',
'MediaKeys.cpp',
'MediaKeySession.cpp',
]

View File

@ -225,7 +225,7 @@ public:
// since this event was dispatched.
MediaDecoderOwner* owner = mDecoder->GetOwner();
if (owner) {
owner->DispatchNeedKey(mInitData, mInitDataType);
owner->DispatchEncrypted(mInitData, mInitDataType);
}
mDecoder = nullptr;
return NS_OK;

View File

@ -155,7 +155,7 @@ partial interface HTMLMediaElement {
Promise<void> setMediaKeys(MediaKeys? mediaKeys);
[Pref="media.eme.enabled"]
attribute EventHandler onneedkey;
attribute EventHandler onencrypted;
[Pref="media.eme.enabled"]
readonly attribute MediaWaitingFor waitingFor;

View File

@ -11,7 +11,7 @@
*/
[Pref="media.eme.enabled", Constructor(DOMString type, optional MediaKeyNeededEventInit eventInitDict)]
interface MediaKeyNeededEvent : Event {
interface MediaEncryptedEvent : Event {
readonly attribute DOMString initDataType;
[Throws]
readonly attribute Uint8Array? initData;
@ -19,5 +19,5 @@ interface MediaKeyNeededEvent : Event {
dictionary MediaKeyNeededEventInit : EventInit {
DOMString initDataType = "";
Uint8Array? initData;
Uint8Array? initData = null;
};

View File

@ -745,9 +745,9 @@ if CONFIG['MOZ_BUILD_APP'] in ['browser', 'mobile/android', 'xulrunner']:
if CONFIG['MOZ_EME']:
WEBIDL_FILES += [
'MediaEncryptedEvent.webidl',
'MediaKeyError.webidl',
'MediaKeyMessageEvent.webidl',
'MediaKeyNeededEvent.webidl',
'MediaKeys.webidl',
'MediaKeySession.webidl',
]