зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1633598 - Add a user of |JS::CopyArrayBuffer|. r=peterv
Differential Revision: https://phabricator.services.mozilla.com/D73745
This commit is contained in:
Родитель
75b3b72bb9
Коммит
9542e5adb2
|
@ -51,14 +51,6 @@ void CopyArrayBufferViewOrArrayBufferData(
|
|||
aOutData.AppendElements(data.mData, data.mLength);
|
||||
}
|
||||
|
||||
void CopyArrayBufferViewOrArrayBufferData(const dom::ArrayBuffer& aBuffer,
|
||||
nsTArray<uint8_t>& aOutData) {
|
||||
JS::AutoCheckCannotGC nogc;
|
||||
aBuffer.ComputeState();
|
||||
aOutData.Clear();
|
||||
aOutData.AppendElements(aBuffer.Data(), aBuffer.Length());
|
||||
}
|
||||
|
||||
bool IsClearkeyKeySystem(const nsAString& aKeySystem) {
|
||||
return aKeySystem.EqualsLiteral(EME_KEY_SYSTEM_CLEARKEY);
|
||||
}
|
||||
|
|
|
@ -47,10 +47,6 @@ void CopyArrayBufferViewOrArrayBufferData(
|
|||
const dom::ArrayBufferViewOrArrayBuffer& aBufferOrView,
|
||||
nsTArray<uint8_t>& aOutData);
|
||||
|
||||
// Overload for ArrayBuffer
|
||||
void CopyArrayBufferViewOrArrayBufferData(const dom::ArrayBuffer& aBufferOrView,
|
||||
nsTArray<uint8_t>& aOutData);
|
||||
|
||||
struct ArrayData {
|
||||
explicit ArrayData(const uint8_t* aData, size_t aLength)
|
||||
: mData(aData), mLength(aLength) {}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "MediaEncryptedEvent.h"
|
||||
#include "mozilla/dom/MediaEncryptedEventBinding.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "js/ArrayBuffer.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "nsINode.h"
|
||||
#include "mozilla/dom/MediaKeys.h"
|
||||
|
@ -77,11 +78,9 @@ already_AddRefed<MediaEncryptedEvent> MediaEncryptedEvent::Constructor(
|
|||
e->InitEvent(aType, aEventInitDict.mBubbles, aEventInitDict.mCancelable);
|
||||
e->mInitDataType = aEventInitDict.mInitDataType;
|
||||
if (!aEventInitDict.mInitData.IsNull()) {
|
||||
const auto& a = aEventInitDict.mInitData.Value();
|
||||
nsTArray<uint8_t> initData;
|
||||
CopyArrayBufferViewOrArrayBufferData(a, initData);
|
||||
e->mInitData = ArrayBuffer::Create(aGlobal.Context(), initData.Length(),
|
||||
initData.Elements());
|
||||
JS::Rooted<JSObject*> buffer(aGlobal.Context(),
|
||||
aEventInitDict.mInitData.Value().Obj());
|
||||
e->mInitData = JS::CopyArrayBuffer(aGlobal.Context(), buffer);
|
||||
if (!e->mInitData) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return nullptr;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "mozilla/dom/MediaKeyMessageEvent.h"
|
||||
#include "mozilla/dom/MediaKeyMessageEventBinding.h"
|
||||
#include "js/ArrayBuffer.h"
|
||||
#include "js/RootingAPI.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "mozilla/dom/Nullable.h"
|
||||
|
@ -76,10 +77,9 @@ already_AddRefed<MediaKeyMessageEvent> MediaKeyMessageEvent::Constructor(
|
|||
RefPtr<MediaKeyMessageEvent> e = new MediaKeyMessageEvent(owner);
|
||||
bool trusted = e->Init(owner);
|
||||
e->InitEvent(aType, aEventInitDict.mBubbles, aEventInitDict.mCancelable);
|
||||
nsTArray<uint8_t> initData;
|
||||
CopyArrayBufferViewOrArrayBufferData(aEventInitDict.mMessage, initData);
|
||||
e->mMessage = ArrayBuffer::Create(aGlobal.Context(), initData.Length(),
|
||||
initData.Elements());
|
||||
JS::Rooted<JSObject*> buffer(aGlobal.Context(),
|
||||
aEventInitDict.mMessage.Obj());
|
||||
e->mMessage = JS::CopyArrayBuffer(aGlobal.Context(), buffer);
|
||||
if (!e->mMessage) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return nullptr;
|
||||
|
|
Загрузка…
Ссылка в новой задаче