Bug 409811. r+sr=tor,a1.9=blocking1.9+

This commit is contained in:
longsonr@gmail.com 2008-01-09 01:52:14 -08:00
Родитель ab982faa16
Коммит f8eccc8861
3 изменённых файлов: 86 добавлений и 14 удалений

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

@ -50,8 +50,6 @@ struct nsSVGEnumMapping {
class nsSVGEnum
{
friend class nsSVGMarkerElement;
public:
void Init(PRUint8 aAttrEnum, PRUint16 aValue) {
mAnimVal = mBaseVal = PRUint8(aValue);
@ -83,10 +81,6 @@ private:
nsSVGEnumMapping *GetMapping(nsSVGElement *aSVGElement);
nsresult SetBaseValue(PRUint16 aValue)
{ mAnimVal = mBaseVal = PRUint8(aValue);
return NS_OK; }
struct DOMAnimatedEnum : public nsIDOMSVGAnimatedEnumeration
{
NS_DECL_ISUPPORTS
@ -106,4 +100,4 @@ private:
};
};
#endif //__NS_SVGENUM2_H__
#endif //__NS_SVGENUM_H__

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

@ -78,6 +78,15 @@ NS_IMPL_NS_NEW_SVG_ELEMENT(Marker)
//----------------------------------------------------------------------
// nsISupports methods
NS_IMPL_ADDREF(nsSVGOrientType::DOMAnimatedEnum)
NS_IMPL_RELEASE(nsSVGOrientType::DOMAnimatedEnum)
NS_INTERFACE_MAP_BEGIN(nsSVGOrientType::DOMAnimatedEnum)
NS_INTERFACE_MAP_ENTRY(nsIDOMSVGAnimatedEnumeration)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGAnimatedEnumeration)
NS_INTERFACE_MAP_END
NS_IMPL_ADDREF_INHERITED(nsSVGMarkerElement,nsSVGMarkerElementBase)
NS_IMPL_RELEASE_INHERITED(nsSVGMarkerElement,nsSVGMarkerElementBase)
@ -93,6 +102,35 @@ NS_INTERFACE_MAP_END_INHERITING(nsSVGMarkerElementBase)
//----------------------------------------------------------------------
// Implementation
nsresult
nsSVGOrientType::SetBaseValue(PRUint16 aValue,
nsSVGElement *aSVGElement)
{
if (aValue == nsIDOMSVGMarkerElement::SVG_MARKER_ORIENT_AUTO ||
aValue == nsIDOMSVGMarkerElement::SVG_MARKER_ORIENT_ANGLE) {
SetBaseValue(aValue);
aSVGElement->SetAttr(
kNameSpaceID_None, nsGkAtoms::orient, nsnull,
(aValue ==nsIDOMSVGMarkerElement::SVG_MARKER_ORIENT_AUTO ?
NS_LITERAL_STRING("auto") : NS_LITERAL_STRING("0")),
PR_TRUE);
return NS_OK;
}
return NS_ERROR_FAILURE;
}
nsresult
nsSVGOrientType::ToDOMAnimatedEnum(nsIDOMSVGAnimatedEnumeration **aResult,
nsSVGElement *aSVGElement)
{
*aResult = new DOMAnimatedEnum(this, aSVGElement);
if (!*aResult)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aResult);
return NS_OK;
}
nsSVGMarkerElement::nsSVGMarkerElement(nsINodeInfo *aNodeInfo)
: nsSVGMarkerElementBase(aNodeInfo), mCoordCtx(nsnull)
{
@ -104,11 +142,6 @@ nsSVGMarkerElement::Init()
nsresult rv = nsSVGMarkerElementBase::Init();
NS_ENSURE_SUCCESS(rv,rv);
// derived (non-attrib) DOM properties
// DOM property: orientType
mOrientType.Init(ORIENTTYPE, SVG_MARKER_ORIENT_ANGLE);
// Create mapped properties:
// DOM property: viewBox

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

@ -44,6 +44,51 @@
#include "nsSVGEnum.h"
#include "nsSVGAngle.h"
class nsSVGOrientType
{
public:
nsSVGOrientType()
: mAnimVal(nsIDOMSVGMarkerElement::SVG_MARKER_ORIENT_ANGLE),
mBaseVal(nsIDOMSVGMarkerElement::SVG_MARKER_ORIENT_ANGLE) {}
nsresult SetBaseValue(PRUint16 aValue,
nsSVGElement *aSVGElement);
void SetBaseValue(PRUint16 aValue)
{ mAnimVal = mBaseVal = PRUint8(aValue); }
PRUint16 GetBaseValue() const
{ return mBaseVal; }
PRUint16 GetAnimValue() const
{ return mAnimVal; }
nsresult ToDOMAnimatedEnum(nsIDOMSVGAnimatedEnumeration **aResult,
nsSVGElement* aSVGElement);
private:
nsSVGEnumValue mAnimVal;
nsSVGEnumValue mBaseVal;
struct DOMAnimatedEnum : public nsIDOMSVGAnimatedEnumeration
{
NS_DECL_ISUPPORTS
DOMAnimatedEnum(nsSVGOrientType* aVal,
nsSVGElement *aSVGElement)
: mVal(aVal), mSVGElement(aSVGElement) {}
nsSVGOrientType *mVal; // kept alive because it belongs to content
nsRefPtr<nsSVGElement> mSVGElement;
NS_IMETHOD GetBaseVal(PRUint16* aResult)
{ *aResult = mVal->GetBaseValue(); return NS_OK; }
NS_IMETHOD SetBaseVal(PRUint16 aValue)
{ return mVal->SetBaseValue(aValue, mSVGElement); }
NS_IMETHOD GetAnimVal(PRUint16* aResult)
{ *aResult = mVal->GetAnimValue(); return NS_OK; }
};
};
typedef nsSVGGraphicElement nsSVGMarkerElementBase;
class nsSVGMarkerElement : public nsSVGMarkerElementBase,
@ -109,7 +154,7 @@ protected:
nsSVGLength2 mLengthAttributes[4];
static LengthInfo sLengthInfo[4];
enum { MARKERUNITS, ORIENTTYPE = 0xFF };
enum { MARKERUNITS };
nsSVGEnum mEnumAttributes[1];
static nsSVGEnumMapping sUnitsMap[];
static EnumInfo sEnumInfo[1];
@ -119,7 +164,7 @@ protected:
static AngleInfo sAngleInfo[1];
// derived properties (from 'orient') handled separately
nsSVGEnum mOrientType;
nsSVGOrientType mOrientType;
nsSVGSVGElement *mCoordCtx;
nsCOMPtr<nsIDOMSVGAnimatedRect> mViewBox;