Bug 1632717.
parent
8bd2abb265
commit
853897d5ca
|
@ -5,6 +5,8 @@
|
||||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#include "mozilla/EMEUtils.h"
|
#include "mozilla/EMEUtils.h"
|
||||||
|
|
||||||
|
#include "jsfriendapi.h" // for AutoCheckCannotGC
|
||||||
#include "mozilla/dom/UnionTypes.h"
|
#include "mozilla/dom/UnionTypes.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
@ -23,6 +25,7 @@ ArrayData
|
||||||
GetArrayBufferViewOrArrayBufferData(const dom::ArrayBufferViewOrArrayBuffer& aBufferOrView)
|
GetArrayBufferViewOrArrayBufferData(const dom::ArrayBufferViewOrArrayBuffer& aBufferOrView)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(aBufferOrView.IsArrayBuffer() || aBufferOrView.IsArrayBufferView());
|
MOZ_ASSERT(aBufferOrView.IsArrayBuffer() || aBufferOrView.IsArrayBufferView());
|
||||||
|
JS::AutoCheckCannotGC nogc;
|
||||||
if (aBufferOrView.IsArrayBuffer()) {
|
if (aBufferOrView.IsArrayBuffer()) {
|
||||||
const dom::ArrayBuffer& buffer = aBufferOrView.GetAsArrayBuffer();
|
const dom::ArrayBuffer& buffer = aBufferOrView.GetAsArrayBuffer();
|
||||||
buffer.ComputeLengthAndData();
|
buffer.ComputeLengthAndData();
|
||||||
|
@ -39,6 +42,7 @@ void
|
||||||
CopyArrayBufferViewOrArrayBufferData(const dom::ArrayBufferViewOrArrayBuffer& aBufferOrView,
|
CopyArrayBufferViewOrArrayBufferData(const dom::ArrayBufferViewOrArrayBuffer& aBufferOrView,
|
||||||
nsTArray<uint8_t>& aOutData)
|
nsTArray<uint8_t>& aOutData)
|
||||||
{
|
{
|
||||||
|
JS::AutoCheckCannotGC nogc;
|
||||||
ArrayData data = GetArrayBufferViewOrArrayBufferData(aBufferOrView);
|
ArrayData data = GetArrayBufferViewOrArrayBufferData(aBufferOrView);
|
||||||
aOutData.Clear();
|
aOutData.Clear();
|
||||||
if (!data.IsValid()) {
|
if (!data.IsValid()) {
|
||||||
|
@ -47,6 +51,14 @@ CopyArrayBufferViewOrArrayBufferData(const dom::ArrayBufferViewOrArrayBuffer& aB
|
||||||
aOutData.AppendElements(data.mData, data.mLength);
|
aOutData.AppendElements(data.mData, data.mLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CopyArrayBufferViewOrArrayBufferData(const dom::ArrayBuffer& aBuffer,
|
||||||
|
nsTArray<uint8_t>& aOutData) {
|
||||||
|
JS::AutoCheckCannotGC nogc;
|
||||||
|
aBuffer.ComputeLengthAndData();
|
||||||
|
aOutData.Clear();
|
||||||
|
aOutData.AppendElements(aBuffer.Data(), aBuffer.Length());
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
IsClearkeyKeySystem(const nsAString& aKeySystem)
|
IsClearkeyKeySystem(const nsAString& aKeySystem)
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "mozilla/Logging.h"
|
#include "mozilla/Logging.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
#include "nsTArray.h"
|
#include "nsTArray.h"
|
||||||
|
#include "mozilla/dom/TypedArray.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
|
@ -45,6 +46,10 @@ void
|
||||||
CopyArrayBufferViewOrArrayBufferData(const dom::ArrayBufferViewOrArrayBuffer& aBufferOrView,
|
CopyArrayBufferViewOrArrayBufferData(const dom::ArrayBufferViewOrArrayBuffer& aBufferOrView,
|
||||||
nsTArray<uint8_t>& aOutData);
|
nsTArray<uint8_t>& aOutData);
|
||||||
|
|
||||||
|
// Overload for ArrayBuffer
|
||||||
|
void CopyArrayBufferViewOrArrayBufferData(const dom::ArrayBuffer& aBufferOrView,
|
||||||
|
nsTArray<uint8_t>& aOutData);
|
||||||
|
|
||||||
struct ArrayData {
|
struct ArrayData {
|
||||||
explicit ArrayData(const uint8_t* aData, size_t aLength)
|
explicit ArrayData(const uint8_t* aData, size_t aLength)
|
||||||
: mData(aData)
|
: mData(aData)
|
||||||
|
|
|
@ -87,10 +87,10 @@ MediaEncryptedEvent::Constructor(const GlobalObject& aGlobal,
|
||||||
e->mInitDataType = aEventInitDict.mInitDataType;
|
e->mInitDataType = aEventInitDict.mInitDataType;
|
||||||
if (!aEventInitDict.mInitData.IsNull()) {
|
if (!aEventInitDict.mInitData.IsNull()) {
|
||||||
const auto& a = aEventInitDict.mInitData.Value();
|
const auto& a = aEventInitDict.mInitData.Value();
|
||||||
a.ComputeLengthAndData();
|
nsTArray<uint8_t> initData;
|
||||||
e->mInitData = ArrayBuffer::Create(aGlobal.Context(),
|
CopyArrayBufferViewOrArrayBufferData(a, initData);
|
||||||
a.Length(),
|
e->mInitData = ArrayBuffer::Create(aGlobal.Context(), initData.Length(),
|
||||||
a.Data());
|
initData.Elements());
|
||||||
if (!e->mInitData) {
|
if (!e->mInitData) {
|
||||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -85,10 +85,11 @@ MediaKeyMessageEvent::Constructor(const GlobalObject& aGlobal,
|
||||||
RefPtr<MediaKeyMessageEvent> e = new MediaKeyMessageEvent(owner);
|
RefPtr<MediaKeyMessageEvent> e = new MediaKeyMessageEvent(owner);
|
||||||
bool trusted = e->Init(owner);
|
bool trusted = e->Init(owner);
|
||||||
e->InitEvent(aType, aEventInitDict.mBubbles, aEventInitDict.mCancelable);
|
e->InitEvent(aType, aEventInitDict.mBubbles, aEventInitDict.mCancelable);
|
||||||
aEventInitDict.mMessage.ComputeLengthAndData();
|
nsTArray<uint8_t> initData;
|
||||||
|
CopyArrayBufferViewOrArrayBufferData(aEventInitDict.mMessage, initData);
|
||||||
e->mMessage = ArrayBuffer::Create(aGlobal.Context(),
|
e->mMessage = ArrayBuffer::Create(aGlobal.Context(),
|
||||||
aEventInitDict.mMessage.Length(),
|
initData.Length(),
|
||||||
aEventInitDict.mMessage.Data());
|
initData.Elements());
|
||||||
if (!e->mMessage) {
|
if (!e->mMessage) {
|
||||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
Loading…
Reference in New Issue