gecko-dev/dom/svg/nsISVGPoint.cpp
Nicholas Nethercote 242708cf72 Bug 1127201 (attempt 2, part 1) - Replace most NS_ABORT_IF_FALSE calls with MOZ_ASSERT. r=Waldo.
--HG--
extra : rebase_source : 488e401ff87e31a2074c4108c4df0572d9536667
2015-02-09 14:34:50 -08:00

88 lines
2.5 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#include "nsISVGPoint.h"
#include "DOMSVGPointList.h"
#include "SVGPoint.h"
#include "nsSVGElement.h"
#include "nsError.h"
#include "mozilla/dom/SVGPointBinding.h"
// See the architecture comment in DOMSVGPointList.h.
using namespace mozilla;
// We could use NS_IMPL_CYCLE_COLLECTION(, except that in Unlink() we need to
// clear our list's weak ref to us to be safe. (The other option would be to
// not unlink and rely on the breaking of the other edges in the cycle, as
// NS_SVG_VAL_IMPL_CYCLE_COLLECTION does.)
NS_IMPL_CYCLE_COLLECTION_CLASS(nsISVGPoint)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsISVGPoint)
// We may not belong to a list, so we must null check tmp->mList.
if (tmp->mList) {
tmp->mList->mItems[tmp->mListIndex] = nullptr;
}
NS_IMPL_CYCLE_COLLECTION_UNLINK(mList)
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsISVGPoint)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mList)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsISVGPoint)
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsISVGPoint)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsISVGPoint)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsISVGPoint)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISVGPoint)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
void
nsISVGPoint::InsertingIntoList(DOMSVGPointList *aList,
uint32_t aListIndex,
bool aIsAnimValItem)
{
MOZ_ASSERT(!HasOwner(), "Inserting item that already has an owner");
mList = aList;
mListIndex = aListIndex;
mIsReadonly = false;
mIsAnimValItem = aIsAnimValItem;
MOZ_ASSERT(IndexIsValid(), "Bad index for DOMSVGPoint!");
}
void
nsISVGPoint::RemovingFromList()
{
mPt = InternalItem();
mList = nullptr;
MOZ_ASSERT(!mIsReadonly, "mIsReadonly set for list");
mIsAnimValItem = false;
}
SVGPoint&
nsISVGPoint::InternalItem()
{
return mList->InternalList().mItems[mListIndex];
}
#ifdef DEBUG
bool
nsISVGPoint::IndexIsValid()
{
return mListIndex < mList->InternalList().Length();
}
#endif