Bug 320622 - removeAttribute doesn't effect some underlying DOM properties. r=longsonr, sr=roc, a=roc

This commit is contained in:
tor@cs.brown.edu 2007-09-05 13:51:21 -07:00
parent 3f5cf3a38d
commit e3feb0186a
11 changed files with 226 additions and 71 deletions

View File

@ -41,49 +41,13 @@
#include "nsSVGAnimatedString.h"
#include "nsContentUtils.h"
////////////////////////////////////////////////////////////////////////
// nsSVGAnimatedString
class nsSVGAnimatedString : public nsIDOMSVGAnimatedString,
public nsSVGValue
{
protected:
friend nsresult NS_NewSVGAnimatedString(nsIDOMSVGAnimatedString** result);
nsSVGAnimatedString();
~nsSVGAnimatedString();
void Init();
public:
// nsISupports interface:
NS_DECL_ISUPPORTS
// nsIDOMSVGAnimatedString interface:
NS_DECL_NSIDOMSVGANIMATEDSTRING
// remainder of nsISVGValue interface:
NS_IMETHOD SetValueString(const nsAString& aValue);
NS_IMETHOD GetValueString(nsAString& aValue);
protected:
nsString mBaseVal;
};
//----------------------------------------------------------------------
// Implementation
nsSVGAnimatedString::nsSVGAnimatedString()
{
}
nsSVGAnimatedString::~nsSVGAnimatedString()
{
}
void
nsSVGAnimatedString::Init()
nsSVGAnimatedString::Clear()
{
mBaseVal.Truncate();
}
//----------------------------------------------------------------------
@ -157,8 +121,6 @@ NS_NewSVGAnimatedString(nsIDOMSVGAnimatedString** aResult)
if(!animatedString) return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(animatedString);
animatedString->Init();
*aResult = (nsIDOMSVGAnimatedString*) animatedString;
return NS_OK;

View File

@ -40,10 +40,34 @@
#define __NS_SVGANIMATEDSTRING_H__
#include "nsIDOMSVGAnimatedString.h"
#include "nsSVGValue.h"
nsresult NS_NewSVGAnimatedString(nsIDOMSVGAnimatedString** result);
////////////////////////////////////////////////////////////////////////
// nsSVGAnimatedString
class nsSVGAnimatedString : public nsIDOMSVGAnimatedString,
public nsSVGValue
{
protected:
friend nsresult NS_NewSVGAnimatedString(nsIDOMSVGAnimatedString** result);
public:
// nsISupports interface:
NS_DECL_ISUPPORTS
// nsIDOMSVGAnimatedString interface:
NS_DECL_NSIDOMSVGANIMATEDSTRING
// remainder of nsISVGValue interface:
NS_IMETHOD SetValueString(const nsAString& aValue);
NS_IMETHOD GetValueString(nsAString& aValue);
void Clear();
protected:
nsString mBaseVal;
};
#endif //__NS_SVGANIMATEDSTRING_H__

View File

@ -69,6 +69,25 @@
#include "nsSVGNumber2.h"
#include "nsSVGEnum.h"
#include "nsIDOMSVGUnitTypes.h"
#include "nsIDOMSVGAngle.h"
#include "nsIDOMSVGAnimatedAngle.h"
#include "nsIDOMSVGAnimatedBoolean.h"
#include "nsIDOMSVGAnimatedInteger.h"
#include "nsIDOMSVGLength.h"
#include "nsIDOMSVGLengthList.h"
#include "nsIDOMSVGAnimatedLengthList.h"
#include "nsIDOMSVGNumberList.h"
#include "nsIDOMSVGAnimatedNumberList.h"
#include "nsIDOMSVGPointList.h"
#include "nsIDOMSVGAnimatedPoints.h"
#include "nsIDOMSVGPresAspectRatio.h"
#include "nsIDOMSVGAnimPresAspRatio.h"
#include "nsIDOMSVGTransformList.h"
#include "nsIDOMSVGAnimTransformList.h"
#include "nsIDOMSVGAnimatedString.h"
#include "nsIDOMSVGAnimatedRect.h"
#include "nsSVGRect.h"
#include "nsSVGAnimatedString.h"
#include <stdarg.h>
nsSVGEnumMapping nsSVGElement::sSVGUnitTypesMap[] = {
@ -317,6 +336,62 @@ nsSVGElement::UnsetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
break;
}
}
// Now check for one of the old style basetypes going away
nsCOMPtr<nsISVGValue> svg_value = GetMappedAttribute(aNamespaceID, aName);
if (svg_value) {
#ifdef DEBUG_tor
nsCOMPtr<nsIDOMSVGAnimatedAngle> a = do_QueryInterface(svg_value);
NS_ASSERTION(!a, "must provide element processing for unset angle");
nsCOMPtr<nsIDOMSVGAnimatedBoolean> b = do_QueryInterface(svg_value);
NS_ASSERTION(!b, "must provide element processing for unset boolean");
nsCOMPtr<nsIDOMSVGAnimatedInteger> i = do_QueryInterface(svg_value);
NS_ASSERTION(!i, "must provide element processing for unset integer");
#endif
nsCOMPtr<nsIDOMSVGAnimatedRect> r = do_QueryInterface(svg_value);
if (r) {
nsIDOMSVGRect *rect;
r->GetBaseVal(&rect);
static_cast<nsSVGRect*>(rect)->Clear();
}
nsCOMPtr<nsIDOMSVGAnimatedPreserveAspectRatio> ar = do_QueryInterface(svg_value);
if (ar) {
nsIDOMSVGPreserveAspectRatio *par;
ar->GetBaseVal(&par);
par->SetAlign(nsIDOMSVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID);
par->SetMeetOrSlice(nsIDOMSVGPreserveAspectRatio::SVG_MEETORSLICE_MEET);
}
nsCOMPtr<nsIDOMSVGAnimatedString> s = do_QueryInterface(svg_value);
if (s) {
static_cast<nsSVGAnimatedString*>(s.get())->Clear();
}
nsCOMPtr<nsIDOMSVGPointList> pl = do_QueryInterface(svg_value);
if (pl) {
pl->Clear();
}
nsCOMPtr<nsIDOMSVGAnimatedLengthList> ll = do_QueryInterface(svg_value);
if (ll) {
nsIDOMSVGLengthList *lengthlist;
ll->GetBaseVal(&lengthlist);
lengthlist->Clear();
}
nsCOMPtr<nsIDOMSVGAnimatedNumberList> nl = do_QueryInterface(svg_value);
if (nl) {
nsIDOMSVGNumberList *numberlist;
nl->GetBaseVal(&numberlist);
numberlist->Clear();
}
nsCOMPtr<nsIDOMSVGAnimatedTransformList> tl = do_QueryInterface(svg_value);
if (tl) {
nsIDOMSVGTransformList *transform;
tl->GetBaseVal(&transform);
transform->Clear();
}
}
}
}

View File

@ -238,6 +238,20 @@ nsSVGFilterElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
return rv;
}
nsresult
nsSVGFilterElement::UnsetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
PRBool aNotify)
{
if (aName == nsGkAtoms::filterRes && aNamespaceID == kNameSpaceID_None) {
mFilterResX->SetBaseVal(0);
mFilterResY->SetBaseVal(0);
return nsGenericElement::UnsetAttr(aNamespaceID, aName, aNotify);
}
return nsSVGFilterElementBase::UnsetAttr(aNamespaceID, aName, aNotify);
}
NS_IMETHODIMP_(PRBool)
nsSVGFilterElement::IsAttributeMapped(const nsIAtom* name) const
{

View File

@ -79,6 +79,8 @@ public:
virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
nsIAtom* aPrefix, const nsAString& aValue,
PRBool aNotify);
virtual nsresult UnsetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
PRBool aNotify);
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;

View File

@ -3010,6 +3010,8 @@ public:
const nsAString& aValue,
nsAttrValue& aResult);
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
virtual nsresult UnsetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
PRBool aNotify);
protected:
virtual NumberAttributesInfo GetNumberInfo();
@ -3234,6 +3236,18 @@ nsSVGFETurbulenceElement::ParseAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
aValue, aResult);
}
nsresult
nsSVGFETurbulenceElement::UnsetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
PRBool aNotify)
{
if (aNamespaceID == kNameSpaceID_None && aName == nsGkAtoms::numOctaves) {
mNumOctaves->SetBaseVal(1);
return nsGenericElement::UnsetAttr(aNamespaceID, aName, aNotify);
}
return nsSVGFETurbulenceElementBase::UnsetAttr(aNamespaceID, aName, aNotify);
}
NS_IMETHODIMP
nsSVGFETurbulenceElement::Filter(nsSVGFilterInstance *instance)
{
@ -3835,6 +3849,8 @@ public:
const nsAString& aValue,
nsAttrValue& aResult);
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
virtual nsresult UnsetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
PRBool aNotify);
protected:
virtual PRBool OperatesOnPremultipledAlpha() {
@ -3951,7 +3967,7 @@ nsSVGFEConvolveMatrixElement::Init()
NS_ENSURE_SUCCESS(rv,rv);
}
// DOM property: targetY , #IMPLIED attrib: targetY
// DOM property: preserveAlpha , #IMPLIED attrib: preserveAlpha
{
rv = NS_NewSVGAnimatedBoolean(getter_AddRefs(mPreserveAlpha), PR_FALSE);
NS_ENSURE_SUCCESS(rv,rv);
@ -4119,6 +4135,35 @@ nsSVGFEConvolveMatrixElement::ParseAttribute(PRInt32 aNameSpaceID, nsIAtom* aNam
aValue, aResult);
}
nsresult
nsSVGFEConvolveMatrixElement::UnsetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
PRBool aNotify)
{
if (aNamespaceID == kNameSpaceID_None) {
PRBool processed = PR_FALSE;
if (aName == nsGkAtoms::order) {
mOrderX->SetBaseVal(0);
mOrderY->SetBaseVal(0);
processed = PR_TRUE;
} else if (aName == nsGkAtoms::targetX) {
mTargetX->SetBaseVal(0);
processed = PR_TRUE;
} else if (aName == nsGkAtoms::targetY) {
mTargetY->SetBaseVal(0);
processed = PR_TRUE;
} else if (aName == nsGkAtoms::preserveAlpha) {
mPreserveAlpha->SetBaseVal(PR_FALSE);
processed = PR_TRUE;
}
if (processed) {
return nsGenericElement::UnsetAttr(aNamespaceID, aName, aNotify);
}
}
return nsSVGFEConvolveMatrixElementBase::UnsetAttr(aNamespaceID, aName, aNotify);
}
#define BOUND(val, min, max) \
PR_MIN(PR_MAX(val, min), max)

View File

@ -306,7 +306,13 @@ nsSVGMarkerElement::UnsetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
vb->SetHeight(mLengthAttributes[MARKERHEIGHT].GetAnimValue(mCoordCtx));
} else if (aName == nsGkAtoms::orient) {
mOrientType.SetBaseValue(SVG_MARKER_ORIENT_AUTO, this, PR_FALSE);
nsIDOMSVGAngle *angle;
mOrient->GetBaseVal(&angle);
angle->NewValueSpecifiedUnits(nsIDOMSVGAngle::SVG_ANGLETYPE_UNSPECIFIED,
0.0f);
}
return nsGenericElement::UnsetAttr(aNamespaceID, aName, aNotify);
}
return nsSVGMarkerElementBase::UnsetAttr(aNamespaceID, aName, aNotify);

View File

@ -442,6 +442,24 @@ nsSVGPathElement::BeforeSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
aValue, aNotify);
}
nsresult
nsSVGPathElement::UnsetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
PRBool aNotify)
{
if (aNamespaceID == kNameSpaceID_None && aName == nsGkAtoms::d) {
if (mSegments) {
NS_REMOVE_SVGVALUE_OBSERVER(mSegments);
mSegments = nsnull;
}
mPathData.Clear();
return nsGenericElement::UnsetAttr(aNamespaceID, aName, aNotify);
}
return nsSVGPathElementBase::UnsetAttr(aNamespaceID, aName, aNotify);
}
NS_IMETHODIMP
nsSVGPathElement::DidModifySVGObservable(nsISVGValue* observable,
nsISVGValue::modificationType aModType)

View File

@ -56,10 +56,9 @@ public:
nsSVGPathList() : mArguments(nsnull), mNumCommands(0), mNumArguments(0) {}
~nsSVGPathList() { Clear(); }
void Playback(gfxContext *aCtx);
protected:
void Clear();
protected:
float *mArguments;
PRUint32 mNumCommands;
PRUint32 mNumArguments;
@ -106,13 +105,17 @@ public:
virtual already_AddRefed<gfxFlattenedPath> GetFlattenedPath(nsIDOMSVGMatrix *aMatrix);
// nsIContent interface
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
virtual nsresult BeforeSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAString* aValue, PRBool aNotify);
virtual nsresult UnsetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
PRBool aNotify);
protected:
// nsSVGElement method
virtual NumberAttributesInfo GetNumberInfo();
virtual nsresult BeforeSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAString* aValue, PRBool aNotify);
// Helper for lazily creating pathseg list
nsresult CreatePathSegList();

View File

@ -48,30 +48,6 @@
#include "nsContentUtils.h"
#include "nsDOMError.h"
////////////////////////////////////////////////////////////////////////
// nsSVGRect class
class nsSVGRect : public nsIDOMSVGRect,
public nsSVGValue
{
public:
nsSVGRect(float x=0.0f, float y=0.0f, float w=0.0f, float h=0.0f);
// nsISupports interface:
NS_DECL_ISUPPORTS
// nsIDOMSVGRect interface:
NS_DECL_NSIDOMSVGRECT
// nsISVGValue interface:
NS_IMETHOD SetValueString(const nsAString& aValue);
NS_IMETHOD GetValueString(nsAString& aValue);
protected:
float mX, mY, mWidth, mHeight;
};
//----------------------------------------------------------------------
// implementation:
@ -80,6 +56,12 @@ nsSVGRect::nsSVGRect(float x, float y, float w, float h)
{
}
void
nsSVGRect::Clear()
{
mX = mY = mWidth = mHeight = 0.0f;
}
//----------------------------------------------------------------------
// nsISupports methods:

View File

@ -41,10 +41,9 @@
#define __NS_SVGRECT_H__
#include "nsIDOMSVGRect.h"
#include "nsSVGValue.h"
#include "gfxRect.h"
class nsIDOMSVGLength;
nsresult
NS_NewSVGRect(nsIDOMSVGRect** result,
float x=0.0f, float y=0.0f,
@ -58,4 +57,29 @@ NS_NewSVGReadonlyRect(nsIDOMSVGRect** result,
float x=0.0f, float y=0.0f,
float width=0.0f, float height=0.0f);
////////////////////////////////////////////////////////////////////////
// nsSVGRect class
class nsSVGRect : public nsIDOMSVGRect,
public nsSVGValue
{
public:
nsSVGRect(float x=0.0f, float y=0.0f, float w=0.0f, float h=0.0f);
// nsISupports interface:
NS_DECL_ISUPPORTS
// nsIDOMSVGRect interface:
NS_DECL_NSIDOMSVGRECT
// nsISVGValue interface:
NS_IMETHOD SetValueString(const nsAString& aValue);
NS_IMETHOD GetValueString(nsAString& aValue);
void Clear();
protected:
float mX, mY, mWidth, mHeight;
};
#endif //__NS_SVGRECT_H__