Bug 816778 Part 13: Convert SVGAnimatedLengthList to WebIDL r=bz

This commit is contained in:
David Zbarsky 2012-12-22 23:54:25 -05:00
parent 874d9d8054
commit da78a6c3e5
5 changed files with 68 additions and 11 deletions

View File

@ -9,6 +9,7 @@
#include "nsSVGElement.h"
#include "nsCOMPtr.h"
#include "nsSVGAttrTearoffTable.h"
#include "mozilla/dom/SVGAnimatedLengthListBinding.h"
// See the architecture comment in this file's header.
@ -17,7 +18,7 @@ namespace mozilla {
static nsSVGAttrTearoffTable<SVGAnimatedLengthList, DOMSVGAnimatedLengthList>
sSVGAnimatedLengthListTearoffTable;
NS_SVG_VAL_IMPL_CYCLE_COLLECTION(DOMSVGAnimatedLengthList, mElement)
NS_SVG_VAL_IMPL_CYCLE_COLLECTION_WRAPPERCACHED(DOMSVGAnimatedLengthList, mElement)
NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMSVGAnimatedLengthList)
NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMSVGAnimatedLengthList)
@ -27,28 +28,49 @@ DOMCI_DATA(SVGAnimatedLengthList, mozilla::DOMSVGAnimatedLengthList)
namespace mozilla {
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMSVGAnimatedLengthList)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGAnimatedLengthList)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAnimatedLengthList)
NS_INTERFACE_MAP_END
NS_IMETHODIMP
DOMSVGAnimatedLengthList::GetBaseVal(nsIDOMSVGLengthList **_retval)
JSObject*
DOMSVGAnimatedLengthList::WrapObject(JSContext* aCx, JSObject* aScope, bool* aTriedToWrap)
{
return dom::SVGAnimatedLengthListBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
already_AddRefed<DOMSVGLengthList>
DOMSVGAnimatedLengthList::BaseVal()
{
if (!mBaseVal) {
mBaseVal = new DOMSVGLengthList(this, InternalAList().GetBaseValue());
}
NS_ADDREF(*_retval = mBaseVal);
nsRefPtr<DOMSVGLengthList> baseVal = mBaseVal;
return baseVal.forget();
}
already_AddRefed<DOMSVGLengthList>
DOMSVGAnimatedLengthList::AnimVal()
{
if (!mAnimVal) {
mAnimVal = new DOMSVGLengthList(this, InternalAList().GetAnimValue());
}
nsRefPtr<DOMSVGLengthList> animVal = mAnimVal;
return animVal.forget();
}
NS_IMETHODIMP
DOMSVGAnimatedLengthList::GetBaseVal(nsIDOMSVGLengthList **_retval)
{
*_retval = BaseVal().get();
return NS_OK;
}
NS_IMETHODIMP
DOMSVGAnimatedLengthList::GetAnimVal(nsIDOMSVGLengthList **_retval)
{
if (!mAnimVal) {
mAnimVal = new DOMSVGLengthList(this, InternalAList().GetAnimValue());
}
NS_ADDREF(*_retval = mAnimVal);
*_retval = AnimVal().get();
return NS_OK;
}

View File

@ -104,13 +104,14 @@ class DOMSVGLengthList;
* One drawback of this design is that objects must look up their parent
* chain to find their element, but that overhead is relatively small.
*/
class DOMSVGAnimatedLengthList MOZ_FINAL : public nsIDOMSVGAnimatedLengthList
class DOMSVGAnimatedLengthList MOZ_FINAL : public nsIDOMSVGAnimatedLengthList,
public nsWrapperCache
{
friend class DOMSVGLengthList;
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(DOMSVGAnimatedLengthList)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMSVGAnimatedLengthList)
NS_DECL_NSIDOMSVGANIMATEDLENGTHLIST
/**
@ -159,6 +160,13 @@ public:
*/
bool IsAnimating() const;
// WebIDL
nsSVGElement* GetParentObject() const { return mElement; }
virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope, bool* aTriedToWrap);
// These aren't weak refs because mBaseVal and mAnimVal are weak
already_AddRefed<DOMSVGLengthList> BaseVal();
already_AddRefed<DOMSVGLengthList> AnimVal();
private:
/**
@ -171,7 +179,9 @@ private:
, mElement(aElement)
, mAttrEnum(aAttrEnum)
, mAxis(aAxis)
{}
{
SetIsDOMBinding();
}
~DOMSVGAnimatedLengthList();

View File

@ -441,6 +441,11 @@ DOMInterfaces = {
'prefable': True,
},
'SVGAnimatedLengthList': {
'nativeType': 'mozilla::DOMSVGAnimatedLengthList',
'headerFile': 'DOMSVGAnimatedLengthList.h'
},
'SVGAnimatedNumberList': {
'nativeType': 'mozilla::DOMSVGAnimatedNumberList',
'headerFile': 'DOMSVGAnimatedNumberList.h'

View File

@ -0,0 +1,19 @@
/* -*- Mode: IDL; 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/.
*
* The origin of this IDL file is
* http://www.w3.org/TR/SVG2/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
interface SVGAnimatedLengthList {
[Constant]
readonly attribute SVGLengthList baseVal;
[Constant]
readonly attribute SVGLengthList animVal;
};

View File

@ -71,6 +71,7 @@ webidl_files = \
SVGAngle.webidl \
SVGAnimatedAngle.webidl \
SVGAnimatedBoolean.webidl \
SVGAnimatedLengthList.webidl \
SVGAnimatedNumberList.webidl \
SVGAnimatedPreserveAspectRatio.webidl \
SVGAnimatedTransformList.webidl \