2010-12-03 19:40:23 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +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/. */
|
2010-12-03 19:40:23 +03:00
|
|
|
|
|
|
|
#include "DOMSVGAnimatedNumberList.h"
|
|
|
|
#include "DOMSVGNumberList.h"
|
|
|
|
#include "SVGAnimatedNumberList.h"
|
|
|
|
#include "nsSVGElement.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsSVGAttrTearoffTable.h"
|
2012-12-23 08:54:21 +04:00
|
|
|
#include "mozilla/dom/SVGAnimatedNumberListBinding.h"
|
2010-12-03 19:40:23 +03:00
|
|
|
|
|
|
|
// See the architecture comment in this file's header.
|
|
|
|
|
2011-02-16 10:53:43 +03:00
|
|
|
namespace mozilla {
|
2010-12-03 19:40:23 +03:00
|
|
|
|
2013-05-31 02:34:53 +04:00
|
|
|
static inline
|
|
|
|
nsSVGAttrTearoffTable<SVGAnimatedNumberList, DOMSVGAnimatedNumberList>&
|
|
|
|
SVGAnimatedNumberListTearoffTable()
|
|
|
|
{
|
|
|
|
static nsSVGAttrTearoffTable<SVGAnimatedNumberList, DOMSVGAnimatedNumberList>
|
|
|
|
sSVGAnimatedNumberListTearoffTable;
|
|
|
|
return sSVGAnimatedNumberListTearoffTable;
|
|
|
|
}
|
2010-12-03 19:40:23 +03:00
|
|
|
|
2012-12-23 08:54:22 +04:00
|
|
|
NS_SVG_VAL_IMPL_CYCLE_COLLECTION_WRAPPERCACHED(DOMSVGAnimatedNumberList, mElement)
|
2010-12-03 19:40:23 +03:00
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMSVGAnimatedNumberList)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMSVGAnimatedNumberList)
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMSVGAnimatedNumberList)
|
2012-12-23 08:54:21 +04:00
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
2010-12-03 19:40:23 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2012-12-23 08:54:21 +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
|
|
|
DOMSVGAnimatedNumberList::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2012-12-23 08:54:21 +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 mozilla::dom::SVGAnimatedNumberListBinding::Wrap(aCx, this, aGivenProto);
|
2012-12-23 08:54:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<DOMSVGNumberList>
|
|
|
|
DOMSVGAnimatedNumberList::BaseVal()
|
2010-12-03 19:40:23 +03:00
|
|
|
{
|
|
|
|
if (!mBaseVal) {
|
|
|
|
mBaseVal = new DOMSVGNumberList(this, InternalAList().GetBaseValue());
|
|
|
|
}
|
2012-12-23 08:54:21 +04:00
|
|
|
nsRefPtr<DOMSVGNumberList> baseVal = mBaseVal;
|
|
|
|
return baseVal.forget();
|
2010-12-03 19:40:23 +03:00
|
|
|
}
|
|
|
|
|
2012-12-23 08:54:21 +04:00
|
|
|
already_AddRefed<DOMSVGNumberList>
|
|
|
|
DOMSVGAnimatedNumberList::AnimVal()
|
2010-12-03 19:40:23 +03:00
|
|
|
{
|
|
|
|
if (!mAnimVal) {
|
|
|
|
mAnimVal = new DOMSVGNumberList(this, InternalAList().GetAnimValue());
|
|
|
|
}
|
2012-12-23 08:54:21 +04:00
|
|
|
nsRefPtr<DOMSVGNumberList> animVal = mAnimVal;
|
|
|
|
return animVal.forget();
|
|
|
|
}
|
|
|
|
|
2010-12-03 19:40:23 +03:00
|
|
|
/* static */ already_AddRefed<DOMSVGAnimatedNumberList>
|
|
|
|
DOMSVGAnimatedNumberList::GetDOMWrapper(SVGAnimatedNumberList *aList,
|
|
|
|
nsSVGElement *aElement,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t aAttrEnum)
|
2010-12-03 19:40:23 +03:00
|
|
|
{
|
2012-08-23 10:24:41 +04:00
|
|
|
nsRefPtr<DOMSVGAnimatedNumberList> wrapper =
|
2013-05-31 02:34:53 +04:00
|
|
|
SVGAnimatedNumberListTearoffTable().GetTearoff(aList);
|
2010-12-03 19:40:23 +03:00
|
|
|
if (!wrapper) {
|
|
|
|
wrapper = new DOMSVGAnimatedNumberList(aElement, aAttrEnum);
|
2013-05-31 02:34:53 +04:00
|
|
|
SVGAnimatedNumberListTearoffTable().AddTearoff(aList, wrapper);
|
2010-12-03 19:40:23 +03:00
|
|
|
}
|
2012-08-23 10:24:41 +04:00
|
|
|
return wrapper.forget();
|
2010-12-03 19:40:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ DOMSVGAnimatedNumberList*
|
|
|
|
DOMSVGAnimatedNumberList::GetDOMWrapperIfExists(SVGAnimatedNumberList *aList)
|
|
|
|
{
|
2013-05-31 02:34:53 +04:00
|
|
|
return SVGAnimatedNumberListTearoffTable().GetTearoff(aList);
|
2010-12-03 19:40:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
DOMSVGAnimatedNumberList::~DOMSVGAnimatedNumberList()
|
|
|
|
{
|
|
|
|
// Script no longer has any references to us, to our base/animVal objects, or
|
|
|
|
// to any of their list items.
|
2013-05-31 02:34:53 +04:00
|
|
|
SVGAnimatedNumberListTearoffTable().RemoveTearoff(&InternalAList());
|
2010-12-03 19:40:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DOMSVGAnimatedNumberList::InternalBaseValListWillChangeTo(const SVGNumberList& aNewValue)
|
|
|
|
{
|
|
|
|
// 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)!!
|
|
|
|
|
2011-03-29 19:47:53 +04:00
|
|
|
nsRefPtr<DOMSVGAnimatedNumberList> kungFuDeathGrip;
|
2010-12-03 19:40:23 +03:00
|
|
|
if (mBaseVal) {
|
2012-09-05 18:52:57 +04:00
|
|
|
if (aNewValue.Length() < mBaseVal->LengthNoFlush()) {
|
2011-03-29 19:47:53 +04:00
|
|
|
// InternalListLengthWillChange might clear last reference to |this|.
|
|
|
|
// Retain a temporary reference to keep from dying before returning.
|
|
|
|
kungFuDeathGrip = this;
|
|
|
|
}
|
2010-12-03 19:40:23 +03:00
|
|
|
mBaseVal->InternalListLengthWillChange(aNewValue.Length());
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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 InternalAnimValListWillChangeTo() if
|
|
|
|
// necessary.)
|
|
|
|
|
|
|
|
if (!IsAnimating()) {
|
|
|
|
InternalAnimValListWillChangeTo(aNewValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DOMSVGAnimatedNumberList::InternalAnimValListWillChangeTo(const SVGNumberList& aNewValue)
|
|
|
|
{
|
|
|
|
if (mAnimVal) {
|
|
|
|
mAnimVal->InternalListLengthWillChange(aNewValue.Length());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2010-12-03 19:40:23 +03:00
|
|
|
DOMSVGAnimatedNumberList::IsAnimating() const
|
|
|
|
{
|
|
|
|
return InternalAList().IsAnimating();
|
|
|
|
}
|
|
|
|
|
|
|
|
SVGAnimatedNumberList&
|
|
|
|
DOMSVGAnimatedNumberList::InternalAList()
|
|
|
|
{
|
|
|
|
return *mElement->GetAnimatedNumberList(mAttrEnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
const SVGAnimatedNumberList&
|
|
|
|
DOMSVGAnimatedNumberList::InternalAList() const
|
|
|
|
{
|
|
|
|
return *mElement->GetAnimatedNumberList(mAttrEnum);
|
|
|
|
}
|
2011-02-16 10:53:43 +03:00
|
|
|
|
|
|
|
} // namespace mozilla
|