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-03-20 07:20:38 +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-04-15 02:56:34 +04:00
|
|
|
#include "mozilla/dom/SVGAnimatedTransformList.h"
|
2013-03-20 07:20:38 +04:00
|
|
|
#include "DOMSVGTransformList.h"
|
2013-04-15 02:56:34 +04:00
|
|
|
#include "nsSVGAnimatedTransformList.h"
|
2013-03-20 07:20:38 +04:00
|
|
|
#include "nsSVGAttrTearoffTable.h"
|
|
|
|
#include "mozilla/dom/SVGAnimatedTransformListBinding.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
2013-04-15 02:56:34 +04:00
|
|
|
namespace dom {
|
2013-03-20 07:20:38 +04:00
|
|
|
|
|
|
|
static
|
2013-04-15 02:56:34 +04:00
|
|
|
nsSVGAttrTearoffTable<nsSVGAnimatedTransformList, SVGAnimatedTransformList>
|
2013-03-20 07:20:38 +04:00
|
|
|
sSVGAnimatedTransformListTearoffTable;
|
|
|
|
|
2013-04-15 02:56:34 +04:00
|
|
|
NS_SVG_VAL_IMPL_CYCLE_COLLECTION_WRAPPERCACHED(SVGAnimatedTransformList, mElement)
|
2013-03-20 07:20:38 +04:00
|
|
|
|
2013-04-15 02:56:34 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(SVGAnimatedTransformList, AddRef)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(SVGAnimatedTransformList, Release)
|
2013-03-20 07:20:38 +04:00
|
|
|
|
|
|
|
JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
SVGAnimatedTransformList::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-03-20 07:20:38 +04:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
return SVGAnimatedTransformListBinding::Wrap(aCx, this, aGivenProto);
|
2013-03-20 07:20:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
already_AddRefed<DOMSVGTransformList>
|
2013-04-15 02:56:34 +04:00
|
|
|
SVGAnimatedTransformList::BaseVal()
|
2013-03-20 07:20:38 +04:00
|
|
|
{
|
|
|
|
if (!mBaseVal) {
|
|
|
|
mBaseVal = new DOMSVGTransformList(this, InternalAList().GetBaseValue());
|
|
|
|
}
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DOMSVGTransformList> baseVal = mBaseVal;
|
2013-03-20 07:20:38 +04:00
|
|
|
return baseVal.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<DOMSVGTransformList>
|
2013-04-15 02:56:34 +04:00
|
|
|
SVGAnimatedTransformList::AnimVal()
|
2013-03-20 07:20:38 +04:00
|
|
|
{
|
|
|
|
if (!mAnimVal) {
|
|
|
|
mAnimVal = new DOMSVGTransformList(this, InternalAList().GetAnimValue());
|
|
|
|
}
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DOMSVGTransformList> animVal = mAnimVal;
|
2013-03-20 07:20:38 +04:00
|
|
|
return animVal.forget();
|
|
|
|
}
|
|
|
|
|
2013-04-15 02:56:34 +04:00
|
|
|
/* static */ already_AddRefed<SVGAnimatedTransformList>
|
|
|
|
SVGAnimatedTransformList::GetDOMWrapper(nsSVGAnimatedTransformList *aList,
|
|
|
|
nsSVGElement *aElement)
|
2013-03-20 07:20:38 +04:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<SVGAnimatedTransformList> wrapper =
|
2013-03-20 07:20:38 +04:00
|
|
|
sSVGAnimatedTransformListTearoffTable.GetTearoff(aList);
|
|
|
|
if (!wrapper) {
|
2013-04-15 02:56:34 +04:00
|
|
|
wrapper = new SVGAnimatedTransformList(aElement);
|
2013-03-20 07:20:38 +04:00
|
|
|
sSVGAnimatedTransformListTearoffTable.AddTearoff(aList, wrapper);
|
|
|
|
}
|
|
|
|
return wrapper.forget();
|
|
|
|
}
|
|
|
|
|
2013-04-15 02:56:34 +04:00
|
|
|
/* static */ SVGAnimatedTransformList*
|
|
|
|
SVGAnimatedTransformList::GetDOMWrapperIfExists(
|
|
|
|
nsSVGAnimatedTransformList *aList)
|
2013-03-20 07:20:38 +04:00
|
|
|
{
|
|
|
|
return sSVGAnimatedTransformListTearoffTable.GetTearoff(aList);
|
|
|
|
}
|
|
|
|
|
2013-04-15 02:56:34 +04:00
|
|
|
SVGAnimatedTransformList::~SVGAnimatedTransformList()
|
2013-03-20 07:20:38 +04: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-15 02:56:34 +04:00
|
|
|
SVGAnimatedTransformList::InternalBaseValListWillChangeLengthTo(
|
2013-03-20 07:20:38 +04: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)!!
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<SVGAnimatedTransformList> kungFuDeathGrip;
|
2013-03-20 07:20:38 +04: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-15 02:56:34 +04:00
|
|
|
SVGAnimatedTransformList::InternalAnimValListWillChangeLengthTo(
|
2013-03-20 07:20:38 +04:00
|
|
|
uint32_t aNewLength)
|
|
|
|
{
|
|
|
|
if (mAnimVal) {
|
|
|
|
mAnimVal->InternalListLengthWillChange(aNewLength);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-04-15 02:56:34 +04:00
|
|
|
SVGAnimatedTransformList::IsAnimating() const
|
2013-03-20 07:20:38 +04:00
|
|
|
{
|
|
|
|
return InternalAList().IsAnimating();
|
|
|
|
}
|
|
|
|
|
2013-04-15 02:56:34 +04:00
|
|
|
nsSVGAnimatedTransformList&
|
|
|
|
SVGAnimatedTransformList::InternalAList()
|
2013-03-20 07:20:38 +04:00
|
|
|
{
|
|
|
|
return *mElement->GetAnimatedTransformList();
|
|
|
|
}
|
|
|
|
|
2013-04-15 02:56:34 +04:00
|
|
|
const nsSVGAnimatedTransformList&
|
|
|
|
SVGAnimatedTransformList::InternalAList() const
|
2013-03-20 07:20:38 +04:00
|
|
|
{
|
|
|
|
return *mElement->GetAnimatedTransformList();
|
|
|
|
}
|
|
|
|
|
2013-04-15 02:56:34 +04:00
|
|
|
} // namespace dom
|
2013-03-20 07:20:38 +04:00
|
|
|
} // namespace mozilla
|