2015-05-03 22:32:37 +03: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-17 05:35:24 +04: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-12 02:05:58 +04:00
|
|
|
#include "nsISVGPoint.h"
|
2013-01-17 05:35:24 +04:00
|
|
|
#include "DOMSVGPointList.h"
|
|
|
|
#include "SVGPoint.h"
|
2018-12-21 11:58:14 +03:00
|
|
|
#include "SVGElement.h"
|
2013-01-17 05:35:24 +04:00
|
|
|
#include "nsError.h"
|
|
|
|
#include "mozilla/dom/SVGPointBinding.h"
|
|
|
|
|
|
|
|
// See the architecture comment in DOMSVGPointList.h.
|
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
|
2014-04-25 20:49:00 +04:00
|
|
|
// We could use NS_IMPL_CYCLE_COLLECTION(, except that in Unlink() we need to
|
2013-01-17 05:35:24 +04: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-02 05:29:05 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(nsISVGPoint)
|
|
|
|
|
2013-01-17 05:35:24 +04: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_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-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!HasOwner(), "Inserting item that already has an owner");
|
2013-01-17 05:35:24 +04:00
|
|
|
|
|
|
|
mList = aList;
|
|
|
|
mListIndex = aListIndex;
|
|
|
|
mIsReadonly = false;
|
|
|
|
mIsAnimValItem = aIsAnimValItem;
|
|
|
|
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(IndexIsValid(), "Bad index for DOMSVGPoint!");
|
2013-01-17 05:35:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsISVGPoint::RemovingFromList() {
|
|
|
|
mPt = InternalItem();
|
|
|
|
mList = nullptr;
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!mIsReadonly, "mIsReadonly set for list");
|
2013-01-17 05:35:24 +04:00
|
|
|
mIsAnimValItem = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
SVGPoint& nsISVGPoint::InternalItem() {
|
|
|
|
return mList->InternalList().mItems[mListIndex];
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
bool nsISVGPoint::IndexIsValid() {
|
|
|
|
return mListIndex < mList->InternalList().Length();
|
|
|
|
}
|
|
|
|
#endif
|