Bug 619516 Patch 1: Rename nsSVGPreserveAspectRatio and its inner class to SVGAnimatedPreserveAspectRatio / SVGPreserveAspectRatio. r=jwatt a=roc

This commit is contained in:
Daniel Holbert 2010-12-19 16:45:29 -08:00
Родитель eb5e67344d
Коммит 4fc44248a5
5 изменённых файлов: 138 добавлений и 102 удалений

Просмотреть файл

@ -68,7 +68,6 @@ class nsSVGBoolean;
class nsSVGEnum;
struct nsSVGEnumMapping;
class nsSVGViewBox;
class nsSVGPreserveAspectRatio;
class nsSVGString;
struct gfxMatrix;
namespace mozilla {
@ -78,7 +77,10 @@ class SVGAnimatedLengthList;
class SVGUserUnitList;
class SVGAnimatedPointList;
class SVGAnimatedPathSegList;
class SVGAnimatedPreserveAspectRatio;
}
// XXXdholbert TEMPORARY TYPEDEF
typedef mozilla::SVGAnimatedPreserveAspectRatio nsSVGPreserveAspectRatio;
typedef nsStyledElement nsSVGElementBase;

Просмотреть файл

@ -46,41 +46,46 @@
using namespace mozilla;
////////////////////////////////////////////////////////////////////////
// nsSVGPreserveAspectRatio class
// SVGAnimatedPreserveAspectRatio class
NS_SVG_VAL_IMPL_CYCLE_COLLECTION(
nsSVGPreserveAspectRatio::DOMBaseVal, mSVGElement)
SVGAnimatedPreserveAspectRatio::DOMBaseVal, mSVGElement)
NS_SVG_VAL_IMPL_CYCLE_COLLECTION(
nsSVGPreserveAspectRatio::DOMAnimVal, mSVGElement)
SVGAnimatedPreserveAspectRatio::DOMAnimVal, mSVGElement)
NS_SVG_VAL_IMPL_CYCLE_COLLECTION(
nsSVGPreserveAspectRatio::DOMAnimPAspectRatio, mSVGElement)
SVGAnimatedPreserveAspectRatio::DOMAnimPAspectRatio, mSVGElement)
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsSVGPreserveAspectRatio::DOMBaseVal)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsSVGPreserveAspectRatio::DOMBaseVal)
NS_IMPL_CYCLE_COLLECTING_ADDREF(SVGAnimatedPreserveAspectRatio::DOMBaseVal)
NS_IMPL_CYCLE_COLLECTING_RELEASE(SVGAnimatedPreserveAspectRatio::DOMBaseVal)
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsSVGPreserveAspectRatio::DOMAnimVal)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsSVGPreserveAspectRatio::DOMAnimVal)
NS_IMPL_CYCLE_COLLECTING_ADDREF(SVGAnimatedPreserveAspectRatio::DOMAnimVal)
NS_IMPL_CYCLE_COLLECTING_RELEASE(SVGAnimatedPreserveAspectRatio::DOMAnimVal)
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsSVGPreserveAspectRatio::DOMAnimPAspectRatio)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsSVGPreserveAspectRatio::DOMAnimPAspectRatio)
NS_IMPL_CYCLE_COLLECTING_ADDREF(
SVGAnimatedPreserveAspectRatio::DOMAnimPAspectRatio)
NS_IMPL_CYCLE_COLLECTING_RELEASE(
SVGAnimatedPreserveAspectRatio::DOMAnimPAspectRatio)
DOMCI_DATA(SVGPreserveAspectRatio, nsSVGPreserveAspectRatio::DOMBaseVal)
DOMCI_DATA(SVGPreserveAspectRatio, SVGAnimatedPreserveAspectRatio::DOMBaseVal)
DOMCI_DATA(SVGAnimatedPreserveAspectRatio,
nsSVGPreserveAspectRatio::DOMAnimPAspectRatio)
SVGAnimatedPreserveAspectRatio::DOMAnimPAspectRatio)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsSVGPreserveAspectRatio::DOMBaseVal)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
SVGAnimatedPreserveAspectRatio::DOMBaseVal)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGPreserveAspectRatio)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGPreserveAspectRatio)
NS_INTERFACE_MAP_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsSVGPreserveAspectRatio::DOMAnimVal)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
SVGAnimatedPreserveAspectRatio::DOMAnimVal)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGPreserveAspectRatio)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGPreserveAspectRatio)
NS_INTERFACE_MAP_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsSVGPreserveAspectRatio::DOMAnimPAspectRatio)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
SVGAnimatedPreserveAspectRatio::DOMAnimPAspectRatio)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGAnimatedPreserveAspectRatio)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAnimatedPreserveAspectRatio)
@ -145,8 +150,9 @@ GetMeetOrSliceString(nsAString& aMeetOrSliceString, PRUint16 aMeetOrSlice)
}
nsresult
nsSVGPreserveAspectRatio::ToDOMBaseVal(nsIDOMSVGPreserveAspectRatio **aResult,
nsSVGElement *aSVGElement)
SVGAnimatedPreserveAspectRatio::ToDOMBaseVal(
nsIDOMSVGPreserveAspectRatio **aResult,
nsSVGElement *aSVGElement)
{
*aResult = new DOMBaseVal(this, aSVGElement);
if (!*aResult)
@ -157,8 +163,9 @@ nsSVGPreserveAspectRatio::ToDOMBaseVal(nsIDOMSVGPreserveAspectRatio **aResult,
}
nsresult
nsSVGPreserveAspectRatio::ToDOMAnimVal(nsIDOMSVGPreserveAspectRatio **aResult,
nsSVGElement *aSVGElement)
SVGAnimatedPreserveAspectRatio::ToDOMAnimVal(
nsIDOMSVGPreserveAspectRatio **aResult,
nsSVGElement *aSVGElement)
{
*aResult = new DOMAnimVal(this, aSVGElement);
if (!*aResult)
@ -170,7 +177,7 @@ nsSVGPreserveAspectRatio::ToDOMAnimVal(nsIDOMSVGPreserveAspectRatio **aResult,
static nsresult
ToPreserveAspectRatio(const nsAString &aString,
nsSVGPreserveAspectRatio::PreserveAspectRatio *aValue)
SVGPreserveAspectRatio *aValue)
{
if (aString.IsEmpty() || NS_IsAsciiWhitespace(aString[0])) {
return NS_ERROR_DOM_SYNTAX_ERR;
@ -183,7 +190,7 @@ ToPreserveAspectRatio(const nsAString &aString,
const nsAString &token = tokenizer.nextToken();
nsresult rv;
nsSVGPreserveAspectRatio::PreserveAspectRatio val;
SVGPreserveAspectRatio val;
val.SetDefer(token.EqualsLiteral("defer"));
@ -218,11 +225,12 @@ ToPreserveAspectRatio(const nsAString &aString,
}
nsresult
nsSVGPreserveAspectRatio::SetBaseValueString(const nsAString &aValueAsString,
nsSVGElement *aSVGElement,
PRBool aDoSetAttr)
SVGAnimatedPreserveAspectRatio::SetBaseValueString(
const nsAString &aValueAsString,
nsSVGElement *aSVGElement,
PRBool aDoSetAttr)
{
PreserveAspectRatio val;
SVGPreserveAspectRatio val;
nsresult res = ToPreserveAspectRatio(aValueAsString, &val);
if (NS_FAILED(res)) {
return res;
@ -245,7 +253,7 @@ nsSVGPreserveAspectRatio::SetBaseValueString(const nsAString &aValueAsString,
}
void
nsSVGPreserveAspectRatio::GetBaseValueString(nsAString & aValueAsString)
SVGAnimatedPreserveAspectRatio::GetBaseValueString(nsAString & aValueAsString)
{
nsAutoString tmpString;
@ -268,8 +276,8 @@ nsSVGPreserveAspectRatio::GetBaseValueString(nsAString & aValueAsString)
}
nsresult
nsSVGPreserveAspectRatio::SetBaseAlign(PRUint16 aAlign,
nsSVGElement *aSVGElement)
SVGAnimatedPreserveAspectRatio::SetBaseAlign(PRUint16 aAlign,
nsSVGElement *aSVGElement)
{
nsresult rv = mBaseVal.SetAlign(aAlign);
NS_ENSURE_SUCCESS(rv, rv);
@ -286,8 +294,8 @@ nsSVGPreserveAspectRatio::SetBaseAlign(PRUint16 aAlign,
}
nsresult
nsSVGPreserveAspectRatio::SetBaseMeetOrSlice(PRUint16 aMeetOrSlice,
nsSVGElement *aSVGElement)
SVGAnimatedPreserveAspectRatio::SetBaseMeetOrSlice(PRUint16 aMeetOrSlice,
nsSVGElement *aSVGElement)
{
nsresult rv = mBaseVal.SetMeetOrSlice(aMeetOrSlice);
NS_ENSURE_SUCCESS(rv, rv);
@ -304,7 +312,8 @@ nsSVGPreserveAspectRatio::SetBaseMeetOrSlice(PRUint16 aMeetOrSlice,
}
void
nsSVGPreserveAspectRatio::SetAnimValue(PRUint64 aPackedValue, nsSVGElement *aSVGElement)
SVGAnimatedPreserveAspectRatio::SetAnimValue(PRUint64 aPackedValue,
nsSVGElement *aSVGElement)
{
mAnimVal.SetDefer(((aPackedValue & 0xff0000) >> 16) ? PR_TRUE : PR_FALSE);
mAnimVal.SetAlign(PRUint16((aPackedValue & 0xff00) >> 8));
@ -314,7 +323,7 @@ nsSVGPreserveAspectRatio::SetAnimValue(PRUint64 aPackedValue, nsSVGElement *aSVG
}
nsresult
nsSVGPreserveAspectRatio::ToDOMAnimatedPreserveAspectRatio(
SVGAnimatedPreserveAspectRatio::ToDOMAnimatedPreserveAspectRatio(
nsIDOMSVGAnimatedPreserveAspectRatio **aResult,
nsSVGElement *aSVGElement)
{
@ -328,13 +337,13 @@ nsSVGPreserveAspectRatio::ToDOMAnimatedPreserveAspectRatio(
#ifdef MOZ_SMIL
nsISMILAttr*
nsSVGPreserveAspectRatio::ToSMILAttr(nsSVGElement *aSVGElement)
SVGAnimatedPreserveAspectRatio::ToSMILAttr(nsSVGElement *aSVGElement)
{
return new SMILPreserveAspectRatio(this, aSVGElement);
}
static PRUint64
PackPreserveAspectRatio(const nsSVGPreserveAspectRatio::PreserveAspectRatio& par)
PackPreserveAspectRatio(const SVGPreserveAspectRatio& par)
{
// All preserveAspectRatio values are enum values (do not interpolate), so we
// can safely collate them and treat them as a single enum as for SMIL.
@ -345,14 +354,17 @@ PackPreserveAspectRatio(const nsSVGPreserveAspectRatio::PreserveAspectRatio& par
return packed;
}
// typedef for inner class, to make function signatures shorter below:
typedef SVGAnimatedPreserveAspectRatio::SMILPreserveAspectRatio
SMILPreserveAspectRatio;
nsresult
nsSVGPreserveAspectRatio::SMILPreserveAspectRatio
::ValueFromString(const nsAString& aStr,
const nsISMILAnimationElement* /*aSrcElement*/,
nsSMILValue& aValue,
PRBool& aPreventCachingOfSandwich) const
SMILPreserveAspectRatio::ValueFromString(const nsAString& aStr,
const nsISMILAnimationElement* /*aSrcElement*/,
nsSMILValue& aValue,
PRBool& aPreventCachingOfSandwich) const
{
PreserveAspectRatio par;
SVGPreserveAspectRatio par;
nsresult res = ToPreserveAspectRatio(aStr, &par);
NS_ENSURE_SUCCESS(res, res);
@ -364,7 +376,7 @@ nsSVGPreserveAspectRatio::SMILPreserveAspectRatio
}
nsSMILValue
nsSVGPreserveAspectRatio::SMILPreserveAspectRatio::GetBaseValue() const
SMILPreserveAspectRatio::GetBaseValue() const
{
nsSMILValue val(&SMILEnumType::sSingleton);
val.mU.mUint = PackPreserveAspectRatio(mVal->GetBaseValue());
@ -372,16 +384,17 @@ nsSVGPreserveAspectRatio::SMILPreserveAspectRatio::GetBaseValue() const
}
void
nsSVGPreserveAspectRatio::SMILPreserveAspectRatio::ClearAnimValue()
SMILPreserveAspectRatio::ClearAnimValue()
{
if (mVal->mIsAnimated) {
mVal->SetAnimValue(PackPreserveAspectRatio(mVal->GetBaseValue()), mSVGElement);
mVal->SetAnimValue(PackPreserveAspectRatio(mVal->GetBaseValue()),
mSVGElement);
mVal->mIsAnimated = PR_FALSE;
}
}
nsresult
nsSVGPreserveAspectRatio::SMILPreserveAspectRatio::SetAnimValue(const nsSMILValue& aValue)
SMILPreserveAspectRatio::SetAnimValue(const nsSMILValue& aValue)
{
NS_ASSERTION(aValue.mType == &SMILEnumType::sSingleton,
"Unexpected type to assign animated value");

Просмотреть файл

@ -44,52 +44,56 @@
#include "nsSVGElement.h"
#include "nsDOMError.h"
class nsSVGPreserveAspectRatio
namespace mozilla {
class SVGAnimatedPreserveAspectRatio;
class SVGPreserveAspectRatio
{
friend class SVGAnimatedPreserveAspectRatio;
public:
class PreserveAspectRatio
{
friend class nsSVGPreserveAspectRatio;
public:
nsresult SetAlign(PRUint16 aAlign) {
if (aAlign < nsIDOMSVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE ||
aAlign > nsIDOMSVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMAX)
return NS_ERROR_FAILURE;
mAlign = static_cast<PRUint8>(aAlign);
return NS_OK;
};
PRUint16 GetAlign() const {
return mAlign;
};
nsresult SetMeetOrSlice(PRUint16 aMeetOrSlice) {
if (aMeetOrSlice < nsIDOMSVGPreserveAspectRatio::SVG_MEETORSLICE_MEET ||
aMeetOrSlice > nsIDOMSVGPreserveAspectRatio::SVG_MEETORSLICE_SLICE)
return NS_ERROR_FAILURE;
mMeetOrSlice = static_cast<PRUint8>(aMeetOrSlice);
return NS_OK;
};
PRUint16 GetMeetOrSlice() const {
return mMeetOrSlice;
};
void SetDefer(PRBool aDefer) {
mDefer = aDefer;
};
PRBool GetDefer() const {
return mDefer;
};
private:
PRUint8 mAlign;
PRUint8 mMeetOrSlice;
PRPackedBool mDefer;
nsresult SetAlign(PRUint16 aAlign) {
if (aAlign < nsIDOMSVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE ||
aAlign > nsIDOMSVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMAX)
return NS_ERROR_FAILURE;
mAlign = static_cast<PRUint8>(aAlign);
return NS_OK;
};
PRUint16 GetAlign() const {
return mAlign;
};
nsresult SetMeetOrSlice(PRUint16 aMeetOrSlice) {
if (aMeetOrSlice < nsIDOMSVGPreserveAspectRatio::SVG_MEETORSLICE_MEET ||
aMeetOrSlice > nsIDOMSVGPreserveAspectRatio::SVG_MEETORSLICE_SLICE)
return NS_ERROR_FAILURE;
mMeetOrSlice = static_cast<PRUint8>(aMeetOrSlice);
return NS_OK;
};
PRUint16 GetMeetOrSlice() const {
return mMeetOrSlice;
};
void SetDefer(PRBool aDefer) {
mDefer = aDefer;
};
PRBool GetDefer() const {
return mDefer;
};
private:
PRUint8 mAlign;
PRUint8 mMeetOrSlice;
PRPackedBool mDefer;
};
class SVGAnimatedPreserveAspectRatio
{
public:
void Init() {
mBaseVal.mAlign = nsIDOMSVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID;
mBaseVal.mMeetOrSlice = nsIDOMSVGPreserveAspectRatio::SVG_MEETORSLICE_MEET;
@ -107,9 +111,9 @@ public:
nsresult SetBaseMeetOrSlice(PRUint16 aMeetOrSlice, nsSVGElement *aSVGElement);
void SetAnimValue(PRUint64 aPackedValue, nsSVGElement *aSVGElement);
const PreserveAspectRatio &GetBaseValue() const
const SVGPreserveAspectRatio &GetBaseValue() const
{ return mBaseVal; }
const PreserveAspectRatio &GetAnimValue() const
const SVGPreserveAspectRatio &GetAnimValue() const
{ return mAnimVal; }
nsresult ToDOMAnimatedPreserveAspectRatio(
@ -122,8 +126,8 @@ public:
private:
PreserveAspectRatio mAnimVal;
PreserveAspectRatio mBaseVal;
SVGPreserveAspectRatio mAnimVal;
SVGPreserveAspectRatio mBaseVal;
PRPackedBool mIsAnimated;
nsresult ToDOMBaseVal(nsIDOMSVGPreserveAspectRatio **aResult,
@ -137,10 +141,10 @@ public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(DOMBaseVal)
DOMBaseVal(nsSVGPreserveAspectRatio* aVal, nsSVGElement *aSVGElement)
DOMBaseVal(SVGAnimatedPreserveAspectRatio* aVal, nsSVGElement *aSVGElement)
: mVal(aVal), mSVGElement(aSVGElement) {}
nsSVGPreserveAspectRatio* mVal; // kept alive because it belongs to mSVGElement
SVGAnimatedPreserveAspectRatio* mVal; // kept alive because it belongs to mSVGElement
nsRefPtr<nsSVGElement> mSVGElement;
NS_IMETHOD GetAlign(PRUint16* aAlign)
@ -159,10 +163,10 @@ public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(DOMAnimVal)
DOMAnimVal(nsSVGPreserveAspectRatio* aVal, nsSVGElement *aSVGElement)
DOMAnimVal(SVGAnimatedPreserveAspectRatio* aVal, nsSVGElement *aSVGElement)
: mVal(aVal), mSVGElement(aSVGElement) {}
nsSVGPreserveAspectRatio* mVal; // kept alive because it belongs to mSVGElement
SVGAnimatedPreserveAspectRatio* mVal; // kept alive because it belongs to mSVGElement
nsRefPtr<nsSVGElement> mSVGElement;
// Script may have modified animation parameters or timeline -- DOM getters
@ -195,10 +199,13 @@ public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(DOMAnimPAspectRatio)
DOMAnimPAspectRatio(nsSVGPreserveAspectRatio* aVal, nsSVGElement *aSVGElement)
DOMAnimPAspectRatio(SVGAnimatedPreserveAspectRatio* aVal,
nsSVGElement *aSVGElement)
: mVal(aVal), mSVGElement(aSVGElement) {}
nsSVGPreserveAspectRatio* mVal; // kept alive because it belongs to content
// kept alive because it belongs to content:
SVGAnimatedPreserveAspectRatio* mVal;
nsRefPtr<nsSVGElement> mSVGElement;
NS_IMETHOD GetBaseVal(nsIDOMSVGPreserveAspectRatio **aBaseVal)
@ -212,13 +219,14 @@ public:
struct SMILPreserveAspectRatio : public nsISMILAttr
{
public:
SMILPreserveAspectRatio(nsSVGPreserveAspectRatio* aVal, nsSVGElement* aSVGElement)
SMILPreserveAspectRatio(SVGAnimatedPreserveAspectRatio* aVal,
nsSVGElement* aSVGElement)
: mVal(aVal), mSVGElement(aSVGElement) {}
// These will stay alive because a nsISMILAttr only lives as long
// as the Compositing step, and DOM elements don't get a chance to
// die during that.
nsSVGPreserveAspectRatio* mVal;
SVGAnimatedPreserveAspectRatio* mVal;
nsSVGElement* mSVGElement;
// nsISMILAttr methods
@ -233,4 +241,9 @@ public:
#endif // MOZ_SMIL
};
} // namespace mozilla
// XXXdholbert TEMPORARY TYPEDEF
typedef mozilla::SVGAnimatedPreserveAspectRatio nsSVGPreserveAspectRatio;
#endif //__NS_SVGPRESERVEASPECTRATIO_H__

Просмотреть файл

@ -43,13 +43,18 @@
#include "nsSVGPaintServerFrame.h"
#include "gfxMatrix.h"
class nsSVGPreserveAspectRatio;
class nsIFrame;
class nsSVGLength2;
class nsSVGElement;
class gfxContext;
class gfxASurface;
// XXXdholbert TEMPORARY TYPEDEF
namespace mozilla {
class SVGAnimatedPreserveAspectRatio;
}
typedef mozilla::SVGAnimatedPreserveAspectRatio nsSVGPreserveAspectRatio;
typedef nsSVGPaintServerFrame nsSVGPatternFrameBase;
/**

Просмотреть файл

@ -62,7 +62,6 @@ class nsIDOMSVGElement;
class nsIDOMSVGLength;
class nsIURI;
class nsSVGOuterSVGFrame;
class nsSVGPreserveAspectRatio;
class nsIAtom;
class nsSVGLength2;
class nsSVGElement;
@ -81,11 +80,15 @@ class nsSVGGeometryFrame;
class nsSVGDisplayContainerFrame;
namespace mozilla {
class SVGAnimatedPreserveAspectRatio;
namespace dom {
class Element;
} // namespace dom
} // namespace mozilla
// XXXdholbert TEMPORARY TYPEDEF
typedef mozilla::SVGAnimatedPreserveAspectRatio nsSVGPreserveAspectRatio;
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif