2013-11-06 09:53:19 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
/* Copyright © 2013 Deutsche Telekom, Inc. */
|
|
|
|
|
2014-01-28 16:20:17 -08:00
|
|
|
#include "MozNDEFRecord.h"
|
2015-01-29 23:36:42 -08:00
|
|
|
#include "js/StructuredClone.h"
|
2014-01-28 16:20:17 -08:00
|
|
|
#include "mozilla/dom/MozNDEFRecordBinding.h"
|
2013-11-08 15:10:23 -08:00
|
|
|
#include "mozilla/HoldDropJSObjects.h"
|
2013-11-06 09:53:19 -08:00
|
|
|
#include "nsContentUtils.h"
|
2015-01-29 23:36:42 -08:00
|
|
|
#include "nsIGlobalObject.h"
|
2015-01-29 02:16:26 -08:00
|
|
|
#include "nsString.h"
|
2013-11-08 15:10:23 -08:00
|
|
|
|
2013-11-06 09:53:19 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2014-01-28 16:20:17 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(MozNDEFRecord)
|
2013-11-08 15:10:23 -08:00
|
|
|
|
2014-01-28 16:20:17 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(MozNDEFRecord)
|
2015-01-29 23:36:42 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mParent)
|
2013-11-08 15:10:23 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
2014-02-12 01:21:09 -08:00
|
|
|
tmp->DropData();
|
2013-11-08 15:10:23 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
2014-01-28 16:20:17 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(MozNDEFRecord)
|
2015-01-29 23:36:42 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParent)
|
2013-11-08 15:10:23 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
2014-01-28 16:20:17 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(MozNDEFRecord)
|
2013-11-08 15:10:23 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mType)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mId)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mPayload)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
|
|
|
|
2014-01-28 16:20:17 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(MozNDEFRecord)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(MozNDEFRecord)
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MozNDEFRecord)
|
2013-11-06 09:53:19 -08:00
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2013-11-08 15:10:23 -08:00
|
|
|
void
|
2014-01-28 16:20:17 -08:00
|
|
|
MozNDEFRecord::HoldData()
|
2013-11-08 15:10:23 -08:00
|
|
|
{
|
|
|
|
mozilla::HoldJSObjects(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-01-28 16:20:17 -08:00
|
|
|
MozNDEFRecord::DropData()
|
2013-11-08 15:10:23 -08:00
|
|
|
{
|
|
|
|
if (mType) {
|
|
|
|
mType = nullptr;
|
|
|
|
}
|
|
|
|
if (mId) {
|
|
|
|
mId = nullptr;
|
|
|
|
}
|
|
|
|
if (mPayload) {
|
|
|
|
mPayload = nullptr;
|
|
|
|
}
|
|
|
|
mozilla::DropJSObjects(this);
|
|
|
|
}
|
|
|
|
|
2014-08-28 01:44:48 -07:00
|
|
|
/**
|
|
|
|
* Validate TNF.
|
|
|
|
* See section 3.3 THE NDEF Specification Test Requirements,
|
|
|
|
* NDEF specification 1.0
|
|
|
|
*/
|
2015-01-07 02:08:21 -08:00
|
|
|
/* static */ bool
|
2014-08-28 01:44:48 -07:00
|
|
|
MozNDEFRecord::ValidateTNF(const MozNDEFRecordOptions& aOptions,
|
|
|
|
ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
// * The TNF field MUST have a value between 0x00 and 0x06.
|
|
|
|
// * The TNF value MUST NOT be 0x07.
|
|
|
|
// These two requirements are already handled by WebIDL bindings.
|
|
|
|
|
|
|
|
// If the TNF value is 0x00 (Empty), the TYPE, ID, and PAYLOAD fields MUST be
|
|
|
|
// omitted from the record.
|
|
|
|
if ((aOptions.mTnf == TNF::Empty) &&
|
|
|
|
(aOptions.mType.WasPassed() || aOptions.mId.WasPassed() ||
|
|
|
|
aOptions.mPayload.WasPassed())) {
|
|
|
|
NS_WARNING("tnf is empty but type/id/payload is not null.");
|
|
|
|
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the TNF value is 0x05 (Unknown) or 0x06(Unchanged), the TYPE field MUST
|
|
|
|
// be omitted from the NDEF record.
|
|
|
|
if ((aOptions.mTnf == TNF::Unknown || aOptions.mTnf == TNF::Unchanged) &&
|
|
|
|
aOptions.mType.WasPassed()) {
|
|
|
|
NS_WARNING("tnf is unknown/unchanged but type is not null.");
|
|
|
|
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-01-07 02:08:21 -08:00
|
|
|
/* static */ already_AddRefed<MozNDEFRecord>
|
2014-01-28 16:20:17 -08:00
|
|
|
MozNDEFRecord::Constructor(const GlobalObject& aGlobal,
|
2014-08-17 23:56:12 -07:00
|
|
|
const MozNDEFRecordOptions& aOptions,
|
2013-11-06 09:53:19 -08:00
|
|
|
ErrorResult& aRv)
|
|
|
|
{
|
2014-08-28 01:44:48 -07:00
|
|
|
if (!ValidateTNF(aOptions, aRv)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-01-29 23:36:42 -08:00
|
|
|
nsCOMPtr<nsISupports> parent = do_QueryInterface(aGlobal.GetAsSupports());
|
|
|
|
if (!parent) {
|
2013-11-08 15:10:23 -08:00
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return nullptr;
|
|
|
|
}
|
2015-01-07 02:08:21 -08:00
|
|
|
|
|
|
|
JSContext* context = aGlobal.Context();
|
2015-01-29 23:36:42 -08:00
|
|
|
nsRefPtr<MozNDEFRecord> ndefRecord = new MozNDEFRecord(parent, aOptions.mTnf);
|
2015-01-07 02:08:21 -08:00
|
|
|
ndefRecord->InitType(context, aOptions.mType);
|
|
|
|
ndefRecord->InitId(context, aOptions.mId);
|
|
|
|
ndefRecord->InitPayload(context, aOptions.mPayload);
|
|
|
|
|
|
|
|
return ndefRecord.forget();
|
|
|
|
}
|
|
|
|
|
2015-01-29 02:16:26 -08:00
|
|
|
/* static */ already_AddRefed<MozNDEFRecord>
|
|
|
|
MozNDEFRecord::Constructor(const GlobalObject& aGlobal,
|
|
|
|
const nsAString& aUri,
|
|
|
|
ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
if (aUri.IsVoid()) {
|
|
|
|
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-01-29 23:36:42 -08:00
|
|
|
nsCOMPtr<nsISupports> parent = do_QueryInterface(aGlobal.GetAsSupports());
|
|
|
|
if (!parent) {
|
2015-01-29 02:16:26 -08:00
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-01-29 23:36:42 -08:00
|
|
|
nsRefPtr<MozNDEFRecord> ndefRecord = new MozNDEFRecord(parent, TNF::Well_known);
|
2015-01-29 02:16:26 -08:00
|
|
|
ndefRecord->InitType(aGlobal.Context(), RTD::U);
|
|
|
|
ndefRecord->InitPayload(aGlobal.Context(), aUri);
|
|
|
|
return ndefRecord.forget();
|
|
|
|
}
|
|
|
|
|
2015-01-29 23:36:42 -08:00
|
|
|
MozNDEFRecord::MozNDEFRecord(nsISupports* aParent, TNF aTnf)
|
|
|
|
: mParent(aParent) // For GetParentObject()
|
2015-01-07 02:08:21 -08:00
|
|
|
, mTnf(aTnf)
|
|
|
|
, mSize(3) // 1(flags) + 1(type_length) + 1(payload_length)
|
|
|
|
{
|
|
|
|
HoldData();
|
2013-11-06 09:53:19 -08:00
|
|
|
}
|
|
|
|
|
2015-01-21 01:37:45 -08:00
|
|
|
void
|
|
|
|
MozNDEFRecord::GetAsURI(nsAString& aRetVal)
|
|
|
|
{
|
|
|
|
aRetVal.SetIsVoid(true);
|
|
|
|
if (mTnf != TNF::Well_known) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
JS::AutoCheckCannotGC nogc;
|
|
|
|
uint8_t* typeData = JS_GetUint8ArrayData(mType, nogc);
|
|
|
|
const char* uVal = RTDValues::strings[static_cast<uint32_t>(RTD::U)].value;
|
|
|
|
if (typeData[0] != uVal[0]) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t payloadLen;
|
|
|
|
uint8_t* payloadData;
|
|
|
|
js::GetUint8ArrayLengthAndData(mPayload, &payloadLen, &payloadData);
|
|
|
|
uint8_t id = payloadData[0];
|
|
|
|
if (id >= static_cast<uint8_t>(WellKnownURIPrefix::EndGuard_)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
using namespace mozilla::dom::WellKnownURIPrefixValues;
|
|
|
|
aRetVal.AssignASCII(strings[id].value);
|
|
|
|
aRetVal.Append(NS_ConvertUTF8toUTF16(
|
|
|
|
nsDependentCSubstring(reinterpret_cast<char*>(&payloadData[1]), payloadLen - 1)));
|
|
|
|
}
|
|
|
|
|
2015-01-29 23:36:42 -08:00
|
|
|
bool
|
|
|
|
MozNDEFRecord::WriteStructuredClone(JSContext* aCx, JSStructuredCloneWriter* aWriter) const
|
|
|
|
{
|
|
|
|
uint8_t* dummy;
|
|
|
|
uint32_t typeLen = 0, idLen = 0, payloadLen = 0;
|
|
|
|
if (mType) {
|
|
|
|
js::GetUint8ArrayLengthAndData(mType, &typeLen, &dummy);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mId) {
|
|
|
|
js::GetUint8ArrayLengthAndData(mId, &idLen, &dummy);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mPayload) {
|
|
|
|
js::GetUint8ArrayLengthAndData(mPayload, &payloadLen, &dummy);
|
|
|
|
}
|
|
|
|
|
|
|
|
return JS_WriteUint32Pair(aWriter, static_cast<uint32_t>(mTnf), typeLen) &&
|
|
|
|
JS_WriteUint32Pair(aWriter, idLen, payloadLen) &&
|
|
|
|
WriteUint8Array(aCx, aWriter, mType, typeLen) &&
|
|
|
|
WriteUint8Array(aCx, aWriter, mId, idLen) &&
|
|
|
|
WriteUint8Array(aCx, aWriter, mPayload, payloadLen);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MozNDEFRecord::ReadStructuredClone(JSContext* aCx, JSStructuredCloneReader* aReader)
|
|
|
|
{
|
|
|
|
uint32_t tnf, typeLen, idLen, payloadLen;
|
|
|
|
|
|
|
|
if (!JS_ReadUint32Pair(aReader, &tnf, &typeLen) ||
|
|
|
|
!JS_ReadUint32Pair(aReader, &idLen, &payloadLen)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
mTnf = static_cast<TNF>(tnf);
|
|
|
|
|
|
|
|
if (typeLen) {
|
|
|
|
JS::Rooted<JS::Value> value(aCx);
|
|
|
|
if (!JS_ReadTypedArray(aReader, &value)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(value.isObject());
|
|
|
|
InitType(aCx, value.toObject(), typeLen);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (idLen) {
|
|
|
|
JS::Rooted<JS::Value> value(aCx);
|
|
|
|
if (!JS_ReadTypedArray(aReader, &value)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(value.isObject());
|
|
|
|
InitId(aCx, value.toObject(), idLen);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (payloadLen) {
|
|
|
|
JS::Rooted<JS::Value> value(aCx);
|
|
|
|
if (!JS_ReadTypedArray(aReader, &value)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(value.isObject());
|
|
|
|
InitPayload(aCx, value.toObject(), payloadLen);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-01-07 02:08:21 -08:00
|
|
|
void
|
2015-03-06 00:23:21 -08:00
|
|
|
MozNDEFRecord::InitType(JSContext* aCx, const Optional<Nullable<Uint8Array>>& aType)
|
2013-11-06 09:53:19 -08:00
|
|
|
{
|
2015-03-06 00:23:21 -08:00
|
|
|
if (!aType.WasPassed() || aType.Value().IsNull()) {
|
2015-01-07 02:08:21 -08:00
|
|
|
return;
|
|
|
|
}
|
2013-11-08 15:10:23 -08:00
|
|
|
|
2015-03-06 00:23:21 -08:00
|
|
|
const Uint8Array& type = aType.Value().Value();
|
2015-01-07 02:08:21 -08:00
|
|
|
type.ComputeLengthAndData();
|
|
|
|
mType = Uint8Array::Create(aCx, this, type.Length(), type.Data());
|
|
|
|
IncSize(type.Length());
|
|
|
|
}
|
2014-08-17 23:56:12 -07:00
|
|
|
|
2015-01-29 02:16:26 -08:00
|
|
|
void
|
|
|
|
MozNDEFRecord::InitType(JSContext* aCx, RTD rtd)
|
|
|
|
{
|
|
|
|
EnumEntry rtdType = RTDValues::strings[static_cast<uint32_t>(rtd)];
|
|
|
|
mType = Uint8Array::Create(aCx, rtdType.length,
|
|
|
|
reinterpret_cast<const uint8_t*>(rtdType.value));
|
|
|
|
IncSize(rtdType.length);
|
|
|
|
}
|
|
|
|
|
2015-01-29 23:36:42 -08:00
|
|
|
void
|
|
|
|
MozNDEFRecord::InitType(JSContext* aCx, JSObject& aType, uint32_t aLen)
|
|
|
|
{
|
|
|
|
mType = &aType;
|
|
|
|
IncSize(aLen);
|
|
|
|
}
|
|
|
|
|
2015-01-07 02:08:21 -08:00
|
|
|
void
|
2015-03-06 00:23:21 -08:00
|
|
|
MozNDEFRecord::InitId(JSContext* aCx, const Optional<Nullable<Uint8Array>>& aId)
|
2015-01-07 02:08:21 -08:00
|
|
|
{
|
2015-03-06 00:23:21 -08:00
|
|
|
if (!aId.WasPassed() || aId.Value().IsNull()) {
|
2015-01-07 02:08:21 -08:00
|
|
|
return;
|
2014-02-19 23:08:46 -08:00
|
|
|
}
|
|
|
|
|
2015-03-06 00:23:21 -08:00
|
|
|
const Uint8Array& id = aId.Value().Value();
|
2015-01-07 02:08:21 -08:00
|
|
|
id.ComputeLengthAndData();
|
|
|
|
mId = Uint8Array::Create(aCx, this, id.Length(), id.Data());
|
|
|
|
IncSize(1 /* id_length */ + id.Length());
|
|
|
|
}
|
|
|
|
|
2015-01-29 23:36:42 -08:00
|
|
|
void
|
|
|
|
MozNDEFRecord::InitId(JSContext* aCx, JSObject& aId, uint32_t aLen)
|
|
|
|
{
|
|
|
|
mId = &aId;
|
|
|
|
IncSize(1 /* id_length */ + aLen);
|
|
|
|
}
|
|
|
|
|
2015-01-07 02:08:21 -08:00
|
|
|
void
|
2015-03-06 00:23:21 -08:00
|
|
|
MozNDEFRecord::InitPayload(JSContext* aCx, const Optional<Nullable<Uint8Array>>& aPayload)
|
2015-01-07 02:08:21 -08:00
|
|
|
{
|
2015-03-06 00:23:21 -08:00
|
|
|
if (!aPayload.WasPassed() || aPayload.Value().IsNull()) {
|
2015-01-07 02:08:21 -08:00
|
|
|
return;
|
2014-02-19 23:08:46 -08:00
|
|
|
}
|
|
|
|
|
2015-03-06 00:23:21 -08:00
|
|
|
const Uint8Array& payload = aPayload.Value().Value();
|
2015-01-07 02:08:21 -08:00
|
|
|
payload.ComputeLengthAndData();
|
|
|
|
mPayload = Uint8Array::Create(aCx, this, payload.Length(), payload.Data());
|
|
|
|
IncSizeForPayload(payload.Length());
|
|
|
|
}
|
|
|
|
|
2015-01-29 02:16:26 -08:00
|
|
|
void
|
|
|
|
MozNDEFRecord::InitPayload(JSContext* aCx, const nsAString& aUri)
|
|
|
|
{
|
|
|
|
using namespace mozilla::dom::WellKnownURIPrefixValues;
|
|
|
|
|
|
|
|
nsCString uri = NS_ConvertUTF16toUTF8(aUri);
|
|
|
|
uint8_t id = GetURIIdentifier(uri);
|
|
|
|
uri = Substring(uri, strings[id].length);
|
|
|
|
mPayload = Uint8Array::Create(aCx, this, uri.Length() + 1);
|
|
|
|
|
|
|
|
JS::AutoCheckCannotGC nogc;
|
|
|
|
uint8_t* data = JS_GetUint8ArrayData(mPayload, nogc);
|
|
|
|
data[0] = id;
|
|
|
|
memcpy(&data[1], reinterpret_cast<const uint8_t*>(uri.Data()), uri.Length());
|
|
|
|
IncSizeForPayload(uri.Length() + 1);
|
|
|
|
}
|
|
|
|
|
2015-01-29 23:36:42 -08:00
|
|
|
void
|
|
|
|
MozNDEFRecord::InitPayload(JSContext* aCx, JSObject& aPayload, uint32_t aLen)
|
|
|
|
{
|
|
|
|
mPayload = &aPayload;
|
|
|
|
IncSizeForPayload(aLen);
|
|
|
|
}
|
|
|
|
|
2015-01-07 02:08:21 -08:00
|
|
|
void
|
|
|
|
MozNDEFRecord::IncSize(uint32_t aCount)
|
|
|
|
{
|
|
|
|
mSize += aCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MozNDEFRecord::IncSizeForPayload(uint32_t aLen)
|
|
|
|
{
|
|
|
|
if (aLen > 0xff) {
|
|
|
|
IncSize(3);
|
2014-02-19 23:08:46 -08:00
|
|
|
}
|
2013-11-08 15:10:23 -08:00
|
|
|
|
2015-01-07 02:08:21 -08:00
|
|
|
IncSize(aLen);
|
2013-11-06 09:53:19 -08:00
|
|
|
}
|
|
|
|
|
2015-01-29 23:36:42 -08:00
|
|
|
bool
|
|
|
|
MozNDEFRecord::WriteUint8Array(JSContext* aCx, JSStructuredCloneWriter* aWriter, JSObject* aObj, uint32_t aLen) const
|
|
|
|
{
|
|
|
|
if (!aLen) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
JS::Rooted<JSObject*> obj(aCx, aObj);
|
|
|
|
JSAutoCompartment ac(aCx, obj);
|
|
|
|
JS::Rooted<JS::Value> value(aCx, JS::ObjectValue(*obj));
|
|
|
|
return JS_WriteTypedArray(aWriter, value);
|
|
|
|
}
|
|
|
|
|
2015-01-29 02:16:26 -08:00
|
|
|
/* static */ uint32_t
|
|
|
|
MozNDEFRecord::GetURIIdentifier(const nsCString& aUri)
|
|
|
|
{
|
|
|
|
using namespace mozilla::dom::WellKnownURIPrefixValues;
|
|
|
|
|
|
|
|
// strings[0] is "", so we start from 1.
|
|
|
|
for (uint32_t i = 1; i < static_cast<uint32_t>(WellKnownURIPrefix::EndGuard_); i++) {
|
|
|
|
if (StringBeginsWith(aUri, nsDependentCString(strings[i].value))) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-01-28 16:20:17 -08:00
|
|
|
MozNDEFRecord::~MozNDEFRecord()
|
2013-11-06 09:53:19 -08:00
|
|
|
{
|
2013-11-08 15:10:23 -08:00
|
|
|
DropData();
|
2013-11-06 09:53:19 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
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 07:13:33 -07:00
|
|
|
MozNDEFRecord::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-11-06 09:53:19 -08: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 07:13:33 -07:00
|
|
|
return MozNDEFRecordBinding::Wrap(aCx, this, aGivenProto);
|
2013-11-06 09:53:19 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|