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: */
|
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"
|
2018-12-21 11:58:14 +03:00
|
|
|
#include "SVGElement.h"
|
2010-12-03 19:40:23 +03:00
|
|
|
#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 {
|
2018-12-28 16:42:46 +03:00
|
|
|
namespace dom {
|
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
|
|
|
|
|
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
|
|
|
JSObject* DOMSVGAnimatedNumberList::WrapObject(
|
|
|
|
JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return mozilla::dom::SVGAnimatedNumberList_Binding::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());
|
|
|
|
}
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DOMSVGNumberList> baseVal = mBaseVal;
|
2012-12-23 08:54:21 +04:00
|
|
|
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());
|
|
|
|
}
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DOMSVGNumberList> animVal = mAnimVal;
|
2012-12-23 08:54:21 +04:00
|
|
|
return animVal.forget();
|
|
|
|
}
|
|
|
|
|
2010-12-03 19:40:23 +03:00
|
|
|
/* static */ already_AddRefed<DOMSVGAnimatedNumberList>
|
|
|
|
DOMSVGAnimatedNumberList::GetDOMWrapper(SVGAnimatedNumberList* aList,
|
2018-12-21 11:58:14 +03:00
|
|
|
dom::SVGElement* aElement,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t aAttrEnum) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<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)!!
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<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());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool 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
|
|
|
|
2018-12-28 16:42:46 +03:00
|
|
|
} // namespace dom
|
2011-02-16 10:53:43 +03:00
|
|
|
} // namespace mozilla
|