mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
5625b09b35
From 4ac0853ddabfadb99bfcd037d3831904d8353fbf Mon Sep 17 00:00:00 2001 --- dom/nfc/MozNDEFRecord.cpp | 26 +++++++++++++++++++------- dom/nfc/MozNDEFRecord.h | 36 +++++++++++++++++++++++++----------- dom/webidl/MozNDEFRecord.webidl | 8 ++++---- 3 files changed, 48 insertions(+), 22 deletions(-)
130 lines
3.6 KiB
C++
130 lines
3.6 KiB
C++
/* -*- 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. */
|
|
|
|
#include "MozNDEFRecord.h"
|
|
#include "mozilla/dom/MozNDEFRecordBinding.h"
|
|
#include "mozilla/HoldDropJSObjects.h"
|
|
#include "nsContentUtils.h"
|
|
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(MozNDEFRecord)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(MozNDEFRecord)
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mWindow)
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
|
tmp->DropData();
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(MozNDEFRecord)
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow)
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(MozNDEFRecord)
|
|
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
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(MozNDEFRecord)
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(MozNDEFRecord)
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MozNDEFRecord)
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
NS_INTERFACE_MAP_END
|
|
|
|
void
|
|
MozNDEFRecord::HoldData()
|
|
{
|
|
mozilla::HoldJSObjects(this);
|
|
}
|
|
|
|
void
|
|
MozNDEFRecord::DropData()
|
|
{
|
|
if (mType) {
|
|
mType = nullptr;
|
|
}
|
|
if (mId) {
|
|
mId = nullptr;
|
|
}
|
|
if (mPayload) {
|
|
mPayload = nullptr;
|
|
}
|
|
mozilla::DropJSObjects(this);
|
|
}
|
|
|
|
/* static */
|
|
already_AddRefed<MozNDEFRecord>
|
|
MozNDEFRecord::Constructor(const GlobalObject& aGlobal,
|
|
uint8_t aTnf,
|
|
const Optional<Uint8Array>& aType,
|
|
const Optional<Uint8Array>& aId,
|
|
const Optional<Uint8Array>& aPayload,
|
|
ErrorResult& aRv)
|
|
{
|
|
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aGlobal.GetAsSupports());
|
|
if (!win) {
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
return nullptr;
|
|
}
|
|
|
|
nsRefPtr<MozNDEFRecord> ndefrecord = new MozNDEFRecord(aGlobal.GetContext(),
|
|
win, aTnf, aType, aId,
|
|
aPayload);
|
|
if (!ndefrecord) {
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
return nullptr;
|
|
}
|
|
return ndefrecord.forget();
|
|
}
|
|
|
|
MozNDEFRecord::MozNDEFRecord(JSContext* aCx, nsPIDOMWindow* aWindow,
|
|
uint8_t aTnf,
|
|
const Optional<Uint8Array>& aType,
|
|
const Optional<Uint8Array>& aId,
|
|
const Optional<Uint8Array>& aPayload)
|
|
: mTnf(aTnf)
|
|
{
|
|
mWindow = aWindow; // For GetParentObject()
|
|
|
|
if (aType.WasPassed()) {
|
|
mType = Uint8Array::Create(aCx, this, aType.Value().Length(), aType.Value().Data());
|
|
}
|
|
|
|
if (aId.WasPassed()) {
|
|
mId = Uint8Array::Create(aCx, this, aId.Value().Length(), aId.Value().Data());
|
|
}
|
|
|
|
if (aPayload.WasPassed()) {
|
|
mPayload = Uint8Array::Create(aCx, this, aPayload.Value().Length(), aPayload.Value().Data());
|
|
}
|
|
|
|
SetIsDOMBinding();
|
|
HoldData();
|
|
}
|
|
|
|
MozNDEFRecord::~MozNDEFRecord()
|
|
{
|
|
DropData();
|
|
}
|
|
|
|
JSObject*
|
|
MozNDEFRecord::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
|
{
|
|
return MozNDEFRecordBinding::Wrap(aCx, aScope, this);
|
|
}
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|