2013-03-19 20:20:38 -07:00
|
|
|
/* -*- 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/. */
|
|
|
|
|
2013-04-14 15:56:34 -07:00
|
|
|
#include "mozilla/dom/SVGAnimatedTransformList.h"
|
2013-03-19 20:20:38 -07:00
|
|
|
#include "DOMSVGTransformList.h"
|
2013-04-14 15:56:34 -07:00
|
|
|
#include "nsSVGAnimatedTransformList.h"
|
2013-03-19 20:20:38 -07:00
|
|
|
#include "nsSVGAttrTearoffTable.h"
|
|
|
|
#include "mozilla/dom/SVGAnimatedTransformListBinding.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
2013-04-14 15:56:34 -07:00
|
|
|
namespace dom {
|
2013-03-19 20:20:38 -07:00
|
|
|
|
|
|
|
static
|
2013-04-14 15:56:34 -07:00
|
|
|
nsSVGAttrTearoffTable<nsSVGAnimatedTransformList, SVGAnimatedTransformList>
|
2013-03-19 20:20:38 -07:00
|
|
|
sSVGAnimatedTransformListTearoffTable;
|
|
|
|
|
2013-04-14 15:56:34 -07:00
|
|
|
NS_SVG_VAL_IMPL_CYCLE_COLLECTION_WRAPPERCACHED(SVGAnimatedTransformList, mElement)
|
2013-03-19 20:20:38 -07:00
|
|
|
|
2013-04-14 15:56:34 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(SVGAnimatedTransformList, AddRef)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(SVGAnimatedTransformList, Release)
|
2013-03-19 20:20:38 -07:00
|
|
|
|
|
|
|
JSObject*
|
2014-04-08 15:27:18 -07:00
|
|
|
SVGAnimatedTransformList::WrapObject(JSContext* aCx)
|
2013-03-19 20:20:38 -07:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-08 15:27:17 -07:00
|
|
|
return SVGAnimatedTransformListBinding::Wrap(aCx, this);
|
2013-03-19 20:20:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
already_AddRefed<DOMSVGTransformList>
|
2013-04-14 15:56:34 -07:00
|
|
|
SVGAnimatedTransformList::BaseVal()
|
2013-03-19 20:20:38 -07:00
|
|
|
{
|
|
|
|
if (!mBaseVal) {
|
|
|
|
mBaseVal = new DOMSVGTransformList(this, InternalAList().GetBaseValue());
|
|
|
|
}
|
|
|
|
nsRefPtr<DOMSVGTransformList> baseVal = mBaseVal;
|
|
|
|
return baseVal.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<DOMSVGTransformList>
|
2013-04-14 15:56:34 -07:00
|
|
|
SVGAnimatedTransformList::AnimVal()
|
2013-03-19 20:20:38 -07:00
|
|
|
{
|
|
|
|
if (!mAnimVal) {
|
|
|
|
mAnimVal = new DOMSVGTransformList(this, InternalAList().GetAnimValue());
|
|
|
|
}
|
|
|
|
nsRefPtr<DOMSVGTransformList> animVal = mAnimVal;
|
|
|
|
return animVal.forget();
|
|
|
|
}
|
|
|
|
|
2013-04-14 15:56:34 -07:00
|
|
|
/* static */ already_AddRefed<SVGAnimatedTransformList>
|
|
|
|
SVGAnimatedTransformList::GetDOMWrapper(nsSVGAnimatedTransformList *aList,
|
|
|
|
nsSVGElement *aElement)
|
2013-03-19 20:20:38 -07:00
|
|
|
{
|
2013-04-14 15:56:34 -07:00
|
|
|
nsRefPtr<SVGAnimatedTransformList> wrapper =
|
2013-03-19 20:20:38 -07:00
|
|
|
sSVGAnimatedTransformListTearoffTable.GetTearoff(aList);
|
|
|
|
if (!wrapper) {
|
2013-04-14 15:56:34 -07:00
|
|
|
wrapper = new SVGAnimatedTransformList(aElement);
|
2013-03-19 20:20:38 -07:00
|
|
|
sSVGAnimatedTransformListTearoffTable.AddTearoff(aList, wrapper);
|
|
|
|
}
|
|
|
|
return wrapper.forget();
|
|
|
|
}
|
|
|
|
|
2013-04-14 15:56:34 -07:00
|
|
|
/* static */ SVGAnimatedTransformList*
|
|
|
|
SVGAnimatedTransformList::GetDOMWrapperIfExists(
|
|
|
|
nsSVGAnimatedTransformList *aList)
|
2013-03-19 20:20:38 -07:00
|
|
|
{
|
|
|
|
return sSVGAnimatedTransformListTearoffTable.GetTearoff(aList);
|
|
|
|
}
|
|
|
|
|
2013-04-14 15:56:34 -07:00
|
|
|
SVGAnimatedTransformList::~SVGAnimatedTransformList()
|
2013-03-19 20:20:38 -07:00
|
|
|
{
|
|
|
|
// Script no longer has any references to us, to our base/animVal objects, or
|
|
|
|
// to any of their list items.
|
|
|
|
sSVGAnimatedTransformListTearoffTable.RemoveTearoff(&InternalAList());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-04-14 15:56:34 -07:00
|
|
|
SVGAnimatedTransformList::InternalBaseValListWillChangeLengthTo(
|
2013-03-19 20:20:38 -07:00
|
|
|
uint32_t aNewLength)
|
|
|
|
{
|
|
|
|
// When the number of items in our internal counterpart's baseVal changes,
|
|
|
|
// we MUST keep our baseVal in sync. If we don't, script will either see a
|
|
|
|
// list that is too short and be unable to access indexes that should be
|
|
|
|
// valid, or else, MUCH WORSE, script will see a list that is too long and be
|
|
|
|
// able to access "items" at indexes that are out of bounds (read/write to
|
|
|
|
// bad memory)!!
|
|
|
|
|
2013-04-14 15:56:34 -07:00
|
|
|
nsRefPtr<SVGAnimatedTransformList> kungFuDeathGrip;
|
2013-03-19 20:20:38 -07:00
|
|
|
if (mBaseVal) {
|
|
|
|
if (aNewLength < mBaseVal->LengthNoFlush()) {
|
|
|
|
// InternalListLengthWillChange might clear last reference to |this|.
|
|
|
|
// Retain a temporary reference to keep from dying before returning.
|
|
|
|
kungFuDeathGrip = this;
|
|
|
|
}
|
|
|
|
mBaseVal->InternalListLengthWillChange(aNewLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
// If our attribute is not animating, then our animVal mirrors our baseVal
|
|
|
|
// and we must sync its length too. (If our attribute is animating, then the
|
|
|
|
// SMIL engine takes care of calling InternalAnimValListWillChangeLengthTo()
|
|
|
|
// if necessary.)
|
|
|
|
|
|
|
|
if (!IsAnimating()) {
|
|
|
|
InternalAnimValListWillChangeLengthTo(aNewLength);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-04-14 15:56:34 -07:00
|
|
|
SVGAnimatedTransformList::InternalAnimValListWillChangeLengthTo(
|
2013-03-19 20:20:38 -07:00
|
|
|
uint32_t aNewLength)
|
|
|
|
{
|
|
|
|
if (mAnimVal) {
|
|
|
|
mAnimVal->InternalListLengthWillChange(aNewLength);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-04-14 15:56:34 -07:00
|
|
|
SVGAnimatedTransformList::IsAnimating() const
|
2013-03-19 20:20:38 -07:00
|
|
|
{
|
|
|
|
return InternalAList().IsAnimating();
|
|
|
|
}
|
|
|
|
|
2013-04-14 15:56:34 -07:00
|
|
|
nsSVGAnimatedTransformList&
|
|
|
|
SVGAnimatedTransformList::InternalAList()
|
2013-03-19 20:20:38 -07:00
|
|
|
{
|
|
|
|
return *mElement->GetAnimatedTransformList();
|
|
|
|
}
|
|
|
|
|
2013-04-14 15:56:34 -07:00
|
|
|
const nsSVGAnimatedTransformList&
|
|
|
|
SVGAnimatedTransformList::InternalAList() const
|
2013-03-19 20:20:38 -07:00
|
|
|
{
|
|
|
|
return *mElement->GetAnimatedTransformList();
|
|
|
|
}
|
|
|
|
|
2013-04-14 15:56:34 -07:00
|
|
|
} // namespace dom
|
2013-03-19 20:20:38 -07:00
|
|
|
} // namespace mozilla
|