2015-05-03 12:32:37 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-01-16 17:35:24 -08:00
|
|
|
/* 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/. */
|
|
|
|
|
2013-03-11 15:05:58 -07:00
|
|
|
#include "nsISVGPoint.h"
|
2013-01-16 17:35:24 -08:00
|
|
|
#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;
|
|
|
|
|
2014-04-25 09:49:00 -07:00
|
|
|
// We could use NS_IMPL_CYCLE_COLLECTION(, except that in Unlink() we need to
|
2013-01-16 17:35:24 -08:00
|
|
|
// 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.)
|
2013-08-01 18:29:05 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(nsISVGPoint)
|
|
|
|
|
2013-01-16 17:35:24 -08:00
|
|
|
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)
|
|
|
|
{
|
2015-02-09 14:34:50 -08:00
|
|
|
MOZ_ASSERT(!HasOwner(), "Inserting item that already has an owner");
|
2013-01-16 17:35:24 -08:00
|
|
|
|
|
|
|
mList = aList;
|
|
|
|
mListIndex = aListIndex;
|
|
|
|
mIsReadonly = false;
|
|
|
|
mIsAnimValItem = aIsAnimValItem;
|
|
|
|
|
2015-02-09 14:34:50 -08:00
|
|
|
MOZ_ASSERT(IndexIsValid(), "Bad index for DOMSVGPoint!");
|
2013-01-16 17:35:24 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsISVGPoint::RemovingFromList()
|
|
|
|
{
|
|
|
|
mPt = InternalItem();
|
|
|
|
mList = nullptr;
|
2015-02-09 14:34:50 -08:00
|
|
|
MOZ_ASSERT(!mIsReadonly, "mIsReadonly set for list");
|
2013-01-16 17:35:24 -08:00
|
|
|
mIsAnimValItem = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
SVGPoint&
|
|
|
|
nsISVGPoint::InternalItem()
|
|
|
|
{
|
|
|
|
return mList->InternalList().mItems[mListIndex];
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
bool
|
|
|
|
nsISVGPoint::IndexIsValid()
|
|
|
|
{
|
|
|
|
return mListIndex < mList->InternalList().Length();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|