Bug 886270 - Move SVGAnimatedInteger to WebIDL; r=dzbarsky

This commit is contained in:
Ms2ger 2013-07-01 09:02:56 +02:00
parent fa9bb545c0
commit 5ba35c354d
22 changed files with 156 additions and 137 deletions

View File

@ -0,0 +1,32 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#include "mozilla/dom/SVGAnimatedInteger.h"
#include "mozilla/dom/SVGAnimatedIntegerBinding.h"
namespace mozilla {
namespace dom {
NS_SVG_VAL_IMPL_CYCLE_COLLECTION_WRAPPERCACHED(SVGAnimatedInteger,
mSVGElement)
NS_IMPL_CYCLE_COLLECTING_ADDREF(SVGAnimatedInteger)
NS_IMPL_CYCLE_COLLECTING_RELEASE(SVGAnimatedInteger)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SVGAnimatedInteger)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
JSObject*
SVGAnimatedInteger::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
{
return SVGAnimatedIntegerBinding::Wrap(aCx, aScope, this);
}
} // namespace dom
} // namespace mozilla

View File

@ -0,0 +1,51 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#ifndef mozilla_dom_SVGAnimatedInteger_h
#define mozilla_dom_SVGAnimatedInteger_h
#include "nsIDOMSVGAnimatedEnum.h"
#include "nsWrapperCache.h"
#include "nsSVGElement.h"
namespace mozilla {
namespace dom {
class SVGAnimatedInteger : public nsISupports
, public nsWrapperCache
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(SVGAnimatedInteger)
nsSVGElement* GetParentObject() const
{
return mSVGElement;
}
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
MOZ_OVERRIDE MOZ_FINAL;
virtual int32_t BaseVal() = 0;
virtual void SetBaseVal(int32_t aBaseVal) = 0;
virtual int32_t AnimVal() = 0;
protected:
explicit SVGAnimatedInteger(nsSVGElement* aSVGElement)
: mSVGElement(aSVGElement)
{
SetIsDOMBinding();
}
virtual ~SVGAnimatedInteger() {};
nsRefPtr<nsSVGElement> mSVGElement;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_SVGAnimatedInteger_h

View File

@ -91,13 +91,13 @@ SVGFEConvolveMatrixElement::In1()
return mStringAttributes[IN1].ToDOMAnimatedString(this);
}
already_AddRefed<nsIDOMSVGAnimatedInteger>
already_AddRefed<SVGAnimatedInteger>
SVGFEConvolveMatrixElement::OrderX()
{
return mIntegerPairAttributes[ORDER].ToDOMAnimatedInteger(nsSVGIntegerPair::eFirst, this);
}
already_AddRefed<nsIDOMSVGAnimatedInteger>
already_AddRefed<SVGAnimatedInteger>
SVGFEConvolveMatrixElement::OrderY()
{
return mIntegerPairAttributes[ORDER].ToDOMAnimatedInteger(nsSVGIntegerPair::eSecond, this);
@ -110,13 +110,13 @@ SVGFEConvolveMatrixElement::KernelMatrix()
this, KERNELMATRIX);
}
already_AddRefed<nsIDOMSVGAnimatedInteger>
already_AddRefed<SVGAnimatedInteger>
SVGFEConvolveMatrixElement::TargetX()
{
return mIntegerAttributes[TARGET_X].ToDOMAnimatedInteger(this);
}
already_AddRefed<nsIDOMSVGAnimatedInteger>
already_AddRefed<SVGAnimatedInteger>
SVGFEConvolveMatrixElement::TargetY()
{
return mIntegerAttributes[TARGET_Y].ToDOMAnimatedInteger(this);

View File

@ -59,11 +59,11 @@ public:
// WebIDL
already_AddRefed<SVGAnimatedString> In1();
already_AddRefed<nsIDOMSVGAnimatedInteger> OrderX();
already_AddRefed<nsIDOMSVGAnimatedInteger> OrderY();
already_AddRefed<SVGAnimatedInteger> OrderX();
already_AddRefed<SVGAnimatedInteger> OrderY();
already_AddRefed<DOMSVGAnimatedNumberList> KernelMatrix();
already_AddRefed<nsIDOMSVGAnimatedInteger> TargetX();
already_AddRefed<nsIDOMSVGAnimatedInteger> TargetY();
already_AddRefed<SVGAnimatedInteger> TargetX();
already_AddRefed<SVGAnimatedInteger> TargetY();
already_AddRefed<SVGAnimatedEnumeration> EdgeMode();
already_AddRefed<SVGAnimatedBoolean> PreserveAlpha();
already_AddRefed<nsIDOMSVGAnimatedNumber> Divisor();

View File

@ -98,7 +98,7 @@ SVGFETurbulenceElement::BaseFrequencyY()
return mNumberPairAttributes[BASE_FREQ].ToDOMAnimatedNumber(nsSVGNumberPair::eSecond, this);
}
already_AddRefed<nsIDOMSVGAnimatedInteger>
already_AddRefed<SVGAnimatedInteger>
SVGFETurbulenceElement::NumOctaves()
{
return mIntegerAttributes[OCTAVES].ToDOMAnimatedInteger(this);

View File

@ -50,7 +50,7 @@ public:
// WebIDL
already_AddRefed<nsIDOMSVGAnimatedNumber> BaseFrequencyX();
already_AddRefed<nsIDOMSVGAnimatedNumber> BaseFrequencyY();
already_AddRefed<nsIDOMSVGAnimatedInteger> NumOctaves();
already_AddRefed<SVGAnimatedInteger> NumOctaves();
already_AddRefed<nsIDOMSVGAnimatedNumber> Seed();
already_AddRefed<SVGAnimatedEnumeration> StitchTiles();
already_AddRefed<SVGAnimatedEnumeration> Type();

View File

@ -105,14 +105,14 @@ SVGFilterElement::PrimitiveUnits()
return mEnumAttributes[PRIMITIVEUNITS].ToDOMAnimatedEnum(this);
}
already_AddRefed<nsIDOMSVGAnimatedInteger>
already_AddRefed<SVGAnimatedInteger>
SVGFilterElement::FilterResX()
{
return mIntegerPairAttributes[FILTERRES].ToDOMAnimatedInteger(nsSVGIntegerPair::eFirst,
this);
}
already_AddRefed<nsIDOMSVGAnimatedInteger>
already_AddRefed<SVGAnimatedInteger>
SVGFilterElement::FilterResY()
{
return mIntegerPairAttributes[FILTERRES].ToDOMAnimatedInteger(nsSVGIntegerPair::eSecond,

View File

@ -54,8 +54,8 @@ public:
already_AddRefed<SVGAnimatedLength> Height();
already_AddRefed<SVGAnimatedEnumeration> FilterUnits();
already_AddRefed<SVGAnimatedEnumeration> PrimitiveUnits();
already_AddRefed<nsIDOMSVGAnimatedInteger> FilterResX();
already_AddRefed<nsIDOMSVGAnimatedInteger> FilterResY();
already_AddRefed<SVGAnimatedInteger> FilterResX();
already_AddRefed<SVGAnimatedInteger> FilterResY();
void SetFilterRes(uint32_t filterResX, uint32_t filterResY);
already_AddRefed<SVGAnimatedString> Href();

View File

@ -24,6 +24,7 @@ EXPORTS.mozilla.dom += [
'SVGAnimatedAngle.h',
'SVGAnimatedBoolean.h',
'SVGAnimatedEnumeration.h',
'SVGAnimatedInteger.h',
'SVGAnimatedLength.h',
'SVGAnimatedRect.h',
'SVGAnimatedString.h',
@ -118,6 +119,7 @@ CPP_SOURCES += [
'SVGAnimatedAngle.cpp',
'SVGAnimatedBoolean.cpp',
'SVGAnimatedEnumeration.cpp',
'SVGAnimatedInteger.cpp',
'SVGAnimatedLength.cpp',
'SVGAnimatedLengthList.cpp',
'SVGAnimatedNumberList.cpp',

View File

@ -10,19 +10,7 @@
#include "SMILIntegerType.h"
using namespace mozilla;
NS_SVG_VAL_IMPL_CYCLE_COLLECTION(nsSVGInteger::DOMAnimatedInteger, mSVGElement)
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsSVGInteger::DOMAnimatedInteger)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsSVGInteger::DOMAnimatedInteger)
DOMCI_DATA(SVGAnimatedInteger, nsSVGInteger::DOMAnimatedInteger)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsSVGInteger::DOMAnimatedInteger)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGAnimatedInteger)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAnimatedInteger)
NS_INTERFACE_MAP_END
using namespace mozilla::dom;
/* Implementation */
@ -112,15 +100,7 @@ nsSVGInteger::SetAnimValue(int aValue, nsSVGElement *aSVGElement)
aSVGElement->DidAnimateInteger(mAttrEnum);
}
nsresult
nsSVGInteger::ToDOMAnimatedInteger(nsIDOMSVGAnimatedInteger **aResult,
nsSVGElement *aSVGElement)
{
*aResult = ToDOMAnimatedInteger(aSVGElement).get();
return NS_OK;
}
already_AddRefed<nsIDOMSVGAnimatedInteger>
already_AddRefed<SVGAnimatedInteger>
nsSVGInteger::ToDOMAnimatedInteger(nsSVGElement *aSVGElement)
{
nsRefPtr<DOMAnimatedInteger> domAnimatedInteger =

View File

@ -9,7 +9,7 @@
#include "nsAutoPtr.h"
#include "nsCycleCollectionParticipant.h"
#include "nsError.h"
#include "nsIDOMSVGAnimatedInteger.h"
#include "SVGAnimatedInteger.h"
#include "nsISMILAttr.h"
#include "nsSVGElement.h"
#include "mozilla/Attributes.h"
@ -53,10 +53,8 @@ public:
bool IsExplicitlySet() const
{ return mIsAnimated || mIsBaseSet; }
already_AddRefed<nsIDOMSVGAnimatedInteger>
already_AddRefed<mozilla::dom::SVGAnimatedInteger>
ToDOMAnimatedInteger(nsSVGElement* aSVGElement);
nsresult ToDOMAnimatedInteger(nsIDOMSVGAnimatedInteger **aResult,
nsSVGElement* aSVGElement);
// Returns a new nsISMILAttr object that the caller must delete
nsISMILAttr* ToSMILAttr(nsSVGElement* aSVGElement);
@ -69,30 +67,31 @@ private:
bool mIsBaseSet;
public:
struct DOMAnimatedInteger MOZ_FINAL : public nsIDOMSVGAnimatedInteger
struct DOMAnimatedInteger MOZ_FINAL : public mozilla::dom::SVGAnimatedInteger
{
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(DOMAnimatedInteger)
DOMAnimatedInteger(nsSVGInteger* aVal, nsSVGElement *aSVGElement)
: mVal(aVal), mSVGElement(aSVGElement) {}
DOMAnimatedInteger(nsSVGInteger* aVal, nsSVGElement* aSVGElement)
: mozilla::dom::SVGAnimatedInteger(aSVGElement)
, mVal(aVal)
{}
virtual ~DOMAnimatedInteger();
nsSVGInteger* mVal; // kept alive because it belongs to content
nsRefPtr<nsSVGElement> mSVGElement;
NS_IMETHOD GetBaseVal(int32_t* aResult) MOZ_OVERRIDE
{ *aResult = mVal->GetBaseValue(); return NS_OK; }
NS_IMETHOD SetBaseVal(int32_t aValue) MOZ_OVERRIDE
{ mVal->SetBaseValue(aValue, mSVGElement); return NS_OK; }
virtual int32_t BaseVal() MOZ_OVERRIDE
{
return mVal->GetBaseValue();
}
virtual void SetBaseVal(int32_t aValue) MOZ_OVERRIDE
{
mVal->SetBaseValue(aValue, mSVGElement);
}
// Script may have modified animation parameters or timeline -- DOM getters
// need to flush any resample requests to reflect these modifications.
NS_IMETHOD GetAnimVal(int32_t* aResult) MOZ_OVERRIDE
virtual int32_t AnimVal() MOZ_OVERRIDE
{
mSVGElement->FlushAnimations();
*aResult = mVal->GetAnimValue();
return NS_OK;
return mVal->GetAnimValue();
}
};

View File

@ -13,19 +13,7 @@
#include "SVGIntegerPairSMILType.h"
using namespace mozilla;
NS_SVG_VAL_IMPL_CYCLE_COLLECTION(nsSVGIntegerPair::DOMAnimatedInteger, mSVGElement)
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsSVGIntegerPair::DOMAnimatedInteger)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsSVGIntegerPair::DOMAnimatedInteger)
DOMCI_DATA(SVGAnimatedIntegerPair, nsSVGIntegerPair::DOMAnimatedInteger)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsSVGIntegerPair::DOMAnimatedInteger)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGAnimatedInteger)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAnimatedInteger)
NS_INTERFACE_MAP_END
using namespace mozilla::dom;
static nsSVGAttrTearoffTable<nsSVGIntegerPair, nsSVGIntegerPair::DOMAnimatedInteger>
sSVGFirstAnimatedIntegerTearoffTable;
@ -168,16 +156,7 @@ nsSVGIntegerPair::SetAnimValue(const int32_t aValue[2], nsSVGElement *aSVGElemen
aSVGElement->DidAnimateIntegerPair(mAttrEnum);
}
nsresult
nsSVGIntegerPair::ToDOMAnimatedInteger(nsIDOMSVGAnimatedInteger **aResult,
PairIndex aIndex,
nsSVGElement *aSVGElement)
{
*aResult = ToDOMAnimatedInteger(aIndex, aSVGElement).get();
return NS_OK;
}
already_AddRefed<nsIDOMSVGAnimatedInteger>
already_AddRefed<SVGAnimatedInteger>
nsSVGIntegerPair::ToDOMAnimatedInteger(PairIndex aIndex,
nsSVGElement* aSVGElement)
{

View File

@ -9,10 +9,10 @@
#include "nsAutoPtr.h"
#include "nsCycleCollectionParticipant.h"
#include "nsError.h"
#include "nsIDOMSVGAnimatedInteger.h"
#include "nsISMILAttr.h"
#include "nsSVGElement.h"
#include "mozilla/Attributes.h"
#include "mozilla/dom/SVGAnimatedInteger.h"
class nsSMILValue;
@ -59,10 +59,7 @@ public:
bool IsExplicitlySet() const
{ return mIsAnimated || mIsBaseSet; }
nsresult ToDOMAnimatedInteger(nsIDOMSVGAnimatedInteger **aResult,
PairIndex aIndex,
nsSVGElement* aSVGElement);
already_AddRefed<nsIDOMSVGAnimatedInteger>
already_AddRefed<mozilla::dom::SVGAnimatedInteger>
ToDOMAnimatedInteger(PairIndex aIndex,
nsSVGElement* aSVGElement);
// Returns a new nsISMILAttr object that the caller must delete
@ -77,34 +74,34 @@ private:
bool mIsBaseSet;
public:
struct DOMAnimatedInteger MOZ_FINAL : public nsIDOMSVGAnimatedInteger
struct DOMAnimatedInteger MOZ_FINAL : public mozilla::dom::SVGAnimatedInteger
{
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(DOMAnimatedInteger)
DOMAnimatedInteger(nsSVGIntegerPair* aVal, PairIndex aIndex, nsSVGElement *aSVGElement)
: mVal(aVal), mSVGElement(aSVGElement), mIndex(aIndex) {}
DOMAnimatedInteger(nsSVGIntegerPair* aVal, PairIndex aIndex,
nsSVGElement* aSVGElement)
: mozilla::dom::SVGAnimatedInteger(aSVGElement)
, mVal(aVal)
, mIndex(aIndex)
{}
virtual ~DOMAnimatedInteger();
nsSVGIntegerPair* mVal; // kept alive because it belongs to content
nsRefPtr<nsSVGElement> mSVGElement;
PairIndex mIndex; // are we the first or second integer
NS_IMETHOD GetBaseVal(int32_t* aResult) MOZ_OVERRIDE
{ *aResult = mVal->GetBaseValue(mIndex); return NS_OK; }
NS_IMETHOD SetBaseVal(int32_t aValue) MOZ_OVERRIDE
{
mVal->SetBaseValue(aValue, mIndex, mSVGElement);
return NS_OK;
}
virtual int32_t BaseVal() MOZ_OVERRIDE
{
return mVal->GetBaseValue(mIndex);
}
virtual void SetBaseVal(int32_t aValue) MOZ_OVERRIDE
{
mVal->SetBaseValue(aValue, mIndex, mSVGElement);
}
// Script may have modified animation parameters or timeline -- DOM getters
// need to flush any resample requests to reflect these modifications.
NS_IMETHOD GetAnimVal(int32_t* aResult) MOZ_OVERRIDE
virtual int32_t AnimVal() MOZ_OVERRIDE
{
mSVGElement->FlushAnimations();
*aResult = mVal->GetAnimValue(mIndex);
return NS_OK;
return mVal->GetAnimValue(mIndex);
}
};

View File

@ -183,7 +183,6 @@
#include "nsIDOMXPathResult.h"
#include "nsIDOMMozBrowserFrame.h"
#include "nsIDOMSVGAnimatedInteger.h"
#include "nsIDOMSVGAnimatedNumber.h"
#include "nsIDOMSVGLength.h"
#include "nsIDOMSVGNumber.h"
@ -570,8 +569,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
DOM_DEFAULT_SCRIPTABLE_FLAGS)
// other SVG classes
NS_DEFINE_CLASSINFO_DATA(SVGAnimatedInteger, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGAnimatedNumber, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGLength, nsDOMGenericSH,
@ -1508,10 +1505,6 @@ nsDOMClassInfo::Init()
// The SVG document
// other SVG classes
DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedInteger, nsIDOMSVGAnimatedInteger)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedInteger)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedNumber, nsIDOMSVGAnimatedNumber)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedNumber)
DOM_CLASSINFO_MAP_END

View File

@ -74,7 +74,6 @@ DOMCI_CLASS(CSSMozDocumentRule)
DOMCI_CLASS(CSSSupportsRule)
// other SVG classes
DOMCI_CLASS(SVGAnimatedInteger)
DOMCI_CLASS(SVGAnimatedNumber)
DOMCI_CLASS(SVGLength)
DOMCI_CLASS(SVGNumber)

View File

@ -1663,7 +1663,6 @@ addExternalIface('PrintCallback', nativeType='nsIPrintCallback',
headerFile='nsIDOMHTMLCanvasElement.h')
addExternalIface('Selection', nativeType='nsISelection')
addExternalIface('StyleSheetList')
addExternalIface('SVGAnimatedNumber')
addExternalIface('SVGLength')
addExternalIface('SVGNumber')
addExternalIface('TouchList', headerFile='nsIDOMTouchEvent.h')

View File

@ -6,7 +6,6 @@
XPIDL_SOURCES += [
'nsIDOMSVGAnimatedEnum.idl',
'nsIDOMSVGAnimatedInteger.idl',
'nsIDOMSVGAnimatedNumber.idl',
'nsIDOMSVGElement.idl',
'nsIDOMSVGLength.idl',

View File

@ -1,25 +0,0 @@
/* -*- 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/. */
#include "domstubs.idl"
/**
* The nsIDOMSVGAnimatedNumber interface is the interface to an SVG
* Animated Integer.
*
* For more information on this interface please see
* http://www.w3.org/TR/SVG11/types.html
*
*/
[scriptable, uuid(7b196db6-955e-4a9f-8f42-645ebc2ce938)]
interface nsIDOMSVGAnimatedInteger : nsISupports
{
attribute long baseVal;
// raises DOMException on setting
readonly attribute long animVal;
};

View File

@ -0,0 +1,16 @@
/* -*- 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
* https://svgwg.org/svg2-draft/types.html#InterfaceSVGAnimatedInteger
*
* Copyright © 2013 W3C® (MIT, ERCIM, Keio, Beihang), All Rights Reserved.
* W3C liability, trademark and document use rules apply.
*/
interface SVGAnimatedInteger {
attribute long baseVal;
readonly attribute long animVal;
};

View File

@ -10,7 +10,6 @@
* liability, trademark and document use rules apply.
*/
interface SVGAnimatedInteger;
interface SVGAnimatedNumber;
interface SVGFETurbulenceElement : SVGElement {

View File

@ -10,8 +10,6 @@
* liability, trademark and document use rules apply.
*/
interface SVGAnimatedInteger;
interface SVGFilterElement : SVGElement {
readonly attribute SVGAnimatedEnumeration filterUnits;
readonly attribute SVGAnimatedEnumeration primitiveUnits;

View File

@ -229,6 +229,7 @@ webidl_files = \
SVGAnimatedAngle.webidl \
SVGAnimatedBoolean.webidl \
SVGAnimatedEnumeration.webidl \
SVGAnimatedInteger.webidl \
SVGAnimatedLength.webidl \
SVGAnimatedLengthList.webidl \
SVGAnimatedNumberList.webidl \