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/. */
|
|
|
|
|
2018-12-23 14:08:14 +03:00
|
|
|
#include "DOMSVGAnimatedTransformList.h"
|
2019-01-24 00:48:00 +03:00
|
|
|
|
2013-03-20 07:20:38 +04:00
|
|
|
#include "DOMSVGTransformList.h"
|
2018-12-27 02:46:38 +03:00
|
|
|
#include "SVGAnimatedTransformList.h"
|
2019-01-24 00:48:00 +03:00
|
|
|
#include "SVGAttrTearoffTable.h"
|
2013-03-20 07:20:38 +04:00
|
|
|
#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
|
|
|
|
2019-01-24 00:48:00 +03:00
|
|
|
static SVGAttrTearoffTable<SVGAnimatedTransformList,
|
|
|
|
DOMSVGAnimatedTransformList>
|
2013-03-20 07:20:38 +04:00
|
|
|
sSVGAnimatedTransformListTearoffTable;
|
|
|
|
|
2018-12-23 14:08:14 +03:00
|
|
|
NS_SVG_VAL_IMPL_CYCLE_COLLECTION_WRAPPERCACHED(DOMSVGAnimatedTransformList,
|
2013-04-15 02:56:34 +04:00
|
|
|
mElement)
|
2013-03-20 07:20:38 +04:00
|
|
|
|
2018-12-23 14:08:14 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DOMSVGAnimatedTransformList, AddRef)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DOMSVGAnimatedTransformList, Release)
|
2013-03-20 07:20:38 +04:00
|
|
|
|
2018-12-23 14:08:14 +03:00
|
|
|
JSObject* DOMSVGAnimatedTransformList::WrapObject(
|
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
|
|
|
JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return SVGAnimatedTransformList_Binding::Wrap(aCx, this, aGivenProto);
|
2013-03-20 07:20:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-12-23 14:08:14 +03:00
|
|
|
already_AddRefed<DOMSVGTransformList> DOMSVGAnimatedTransformList::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();
|
|
|
|
}
|
|
|
|
|
2018-12-23 14:08:14 +03:00
|
|
|
already_AddRefed<DOMSVGTransformList> DOMSVGAnimatedTransformList::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();
|
|
|
|
}
|
|
|
|
|
2019-02-26 01:05:29 +03:00
|
|
|
/* static */
|
|
|
|
already_AddRefed<DOMSVGAnimatedTransformList>
|
2018-12-27 02:46:38 +03:00
|
|
|
DOMSVGAnimatedTransformList::GetDOMWrapper(SVGAnimatedTransformList* aList,
|
2018-12-23 14:08:14 +03:00
|
|
|
SVGElement* aElement) {
|
|
|
|
RefPtr<DOMSVGAnimatedTransformList> wrapper =
|
2013-03-20 07:20:38 +04:00
|
|
|
sSVGAnimatedTransformListTearoffTable.GetTearoff(aList);
|
|
|
|
if (!wrapper) {
|
2018-12-23 14:08:14 +03:00
|
|
|
wrapper = new DOMSVGAnimatedTransformList(aElement);
|
2013-03-20 07:20:38 +04:00
|
|
|
sSVGAnimatedTransformListTearoffTable.AddTearoff(aList, wrapper);
|
|
|
|
}
|
|
|
|
return wrapper.forget();
|
|
|
|
}
|
|
|
|
|
2019-02-26 01:05:29 +03:00
|
|
|
/* static */
|
|
|
|
DOMSVGAnimatedTransformList* DOMSVGAnimatedTransformList::GetDOMWrapperIfExists(
|
2018-12-27 02:46:38 +03:00
|
|
|
SVGAnimatedTransformList* aList) {
|
2013-03-20 07:20:38 +04:00
|
|
|
return sSVGAnimatedTransformListTearoffTable.GetTearoff(aList);
|
|
|
|
}
|
|
|
|
|
2018-12-23 14:08:14 +03:00
|
|
|
DOMSVGAnimatedTransformList::~DOMSVGAnimatedTransformList() {
|
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());
|
|
|
|
}
|
|
|
|
|
2018-12-23 14:08:14 +03:00
|
|
|
void DOMSVGAnimatedTransformList::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)!!
|
|
|
|
|
2018-12-23 14:08:14 +03:00
|
|
|
RefPtr<DOMSVGAnimatedTransformList> 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-23 14:08:14 +03:00
|
|
|
void DOMSVGAnimatedTransformList::InternalAnimValListWillChangeLengthTo(
|
2013-03-20 07:20:38 +04:00
|
|
|
uint32_t aNewLength) {
|
|
|
|
if (mAnimVal) {
|
|
|
|
mAnimVal->InternalListLengthWillChange(aNewLength);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-23 14:08:14 +03:00
|
|
|
bool DOMSVGAnimatedTransformList::IsAnimating() const {
|
2013-03-20 07:20:38 +04:00
|
|
|
return InternalAList().IsAnimating();
|
|
|
|
}
|
|
|
|
|
2018-12-27 02:46:38 +03:00
|
|
|
SVGAnimatedTransformList& DOMSVGAnimatedTransformList::InternalAList() {
|
2013-03-20 07:20:38 +04:00
|
|
|
return *mElement->GetAnimatedTransformList();
|
|
|
|
}
|
|
|
|
|
2018-12-27 02:46:38 +03:00
|
|
|
const SVGAnimatedTransformList& DOMSVGAnimatedTransformList::InternalAList()
|
2013-03-20 07:20:38 +04:00
|
|
|
const {
|
|
|
|
return *mElement->GetAnimatedTransformList();
|
|
|
|
}
|
|
|
|
|
2013-04-15 02:56:34 +04:00
|
|
|
} // namespace dom
|
2013-03-20 07:20:38 +04:00
|
|
|
} // namespace mozilla
|