Bug 471551. Stop duplicating SVG string attribute storage by having nsSVGString use the attribute value as the underlying base value (removing mBaseVal); also make mAnimVal an nsAutoPtr<nsString>. r=longsonr,r+sr=roc

--HG--
extra : rebase_source : 319ff11d4321f2f7f41a7d19f17435fe814b1079
This commit is contained in:
Craig Topper 2009-01-22 13:56:51 +13:00
Родитель d83f123df8
Коммит 623a502daa
15 изменённых файлов: 157 добавлений и 107 удалений

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

@ -253,8 +253,9 @@ nsSVGAElement::IsLink(nsIURI** aURI) const
nsIContent::ATTR_VALUE_NO_MATCH) {
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
// Get absolute URI
nsContentUtils::NewURIWithDocumentCharset(aURI,
mStringAttributes[HREF].GetAnimValue(),
nsAutoString str;
mStringAttributes[HREF].GetAnimValue(str, this);
nsContentUtils::NewURIWithDocumentCharset(aURI, str,
GetOwnerDoc(), baseURI);
// must promise out param is non-null if we return true
return !!*aURI;
@ -267,7 +268,7 @@ nsSVGAElement::IsLink(nsIURI** aURI) const
void
nsSVGAElement::GetLinkTarget(nsAString& aTarget)
{
aTarget = mStringAttributes[TARGET].GetAnimValue();
mStringAttributes[TARGET].GetAnimValue(aTarget, this);
if (aTarget.IsEmpty()) {
static nsIContent::AttrValuesArray sShowVals[] =

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

@ -620,7 +620,7 @@ nsSVGElement::UnsetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
if (aNamespaceID == stringInfo.mStringInfo[i].mNamespaceID &&
aName == *stringInfo.mStringInfo[i].mName) {
stringInfo.Reset(i);
DidChangeString(i, PR_FALSE);
DidChangeString(i);
foundMatch = PR_TRUE;
break;
}
@ -1502,22 +1502,30 @@ void nsSVGElement::StringAttributesInfo::Reset(PRUint8 aAttrEnum)
mStrings[aAttrEnum].Init(aAttrEnum);
}
void
nsSVGElement::DidChangeString(PRUint8 aAttrEnum, PRBool aDoSetAttr)
void nsSVGElement::GetStringBaseValue(PRUint8 aAttrEnum, nsAString& aResult) const
{
if (!aDoSetAttr)
return;
StringAttributesInfo info = GetStringInfo();
nsSVGElement::StringAttributesInfo info = const_cast<nsSVGElement*>(this)->GetStringInfo();
NS_ASSERTION(info.mStringCount > 0,
"DidChangeString on element with no string attribs");
"GetBaseValue on element with no string attribs");
NS_ASSERTION(aAttrEnum < info.mStringCount, "aAttrEnum out of range");
GetAttr(info.mStringInfo[aAttrEnum].mNamespaceID,
*info.mStringInfo[aAttrEnum].mName, aResult);
}
void nsSVGElement::SetStringBaseValue(PRUint8 aAttrEnum, const nsAString& aValue)
{
nsSVGElement::StringAttributesInfo info = GetStringInfo();
NS_ASSERTION(info.mStringCount > 0,
"SetBaseValue on element with no string attribs");
NS_ASSERTION(aAttrEnum < info.mStringCount, "aAttrEnum out of range");
SetAttr(info.mStringInfo[aAttrEnum].mNamespaceID,
*info.mStringInfo[aAttrEnum].mName,
info.mStrings[aAttrEnum].GetBaseValue(), PR_TRUE);
*info.mStringInfo[aAttrEnum].mName, aValue, PR_TRUE);
}
nsresult

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

@ -145,7 +145,7 @@ public:
virtual void DidChangeBoolean(PRUint8 aAttrEnum, PRBool aDoSetAttr);
virtual void DidChangeEnum(PRUint8 aAttrEnum, PRBool aDoSetAttr);
virtual void DidChangePreserveAspectRatio(PRBool aDoSetAttr);
virtual void DidChangeString(PRUint8 aAttrEnum, PRBool aDoSetAttr);
virtual void DidChangeString(PRUint8 aAttrEnum) {}
void DidAnimateLength(PRUint8 aAttrEnum);
@ -159,6 +159,9 @@ public:
virtual void RecompileScriptEventListeners();
void GetStringBaseValue(PRUint8 aAttrEnum, nsAString& aResult) const;
void SetStringBaseValue(PRUint8 aAttrEnum, const nsAString& aValue);
protected:
virtual nsresult BeforeSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAString* aValue, PRBool aNotify);

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

@ -35,7 +35,6 @@
* ***** END LICENSE BLOCK ***** */
#include "nsSVGElement.h"
#include "nsSVGLength.h"
#include "nsGkAtoms.h"
#include "nsSVGNumber2.h"
#include "nsSVGInteger.h"
@ -255,7 +254,7 @@ nsSVGFE::ComputeChangeBBox(const nsTArray<nsIntRect>& aSourceChangeBoxes,
}
void
nsSVGFE::GetSourceImageNames(nsTArray<nsSVGString*>* aSources)
nsSVGFE::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
{
}
@ -289,7 +288,7 @@ NS_IMETHODIMP nsSVGFE::GetHeight(nsIDOMSVGAnimatedLength * *aHeight)
/* readonly attribute nsIDOMSVGAnimatedString result; */
NS_IMETHODIMP nsSVGFE::GetResult(nsIDOMSVGAnimatedString * *aResult)
{
return GetResultImageName()->ToDOMAnimatedString(aResult, this);
return GetResultImageName().ToDOMAnimatedString(aResult, this);
}
//----------------------------------------------------------------------
@ -326,8 +325,8 @@ public:
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual nsSVGString* GetResultImageName() { return &mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGString*>* aSources);
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo >& aSources);
virtual nsIntRect ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
const nsSVGFilterInstance& aInstance);
virtual void ComputeNeededSourceBBoxes(const nsIntRect& aTargetBBox,
@ -704,9 +703,9 @@ nsSVGFEGaussianBlurElement::Filter(nsSVGFilterInstance* aInstance,
}
void
nsSVGFEGaussianBlurElement::GetSourceImageNames(nsTArray<nsSVGString*>* aSources)
nsSVGFEGaussianBlurElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
{
aSources->AppendElement(&mStringAttributes[IN1]);
aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN1], this));
}
nsIntRect
@ -784,8 +783,8 @@ public:
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual nsSVGString* GetResultImageName() { return &mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGString*>* aSources);
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources);
// Blend
NS_DECL_NSIDOMSVGFEBLENDELEMENT
@ -936,10 +935,10 @@ nsSVGFEBlendElement::Filter(nsSVGFilterInstance* aInstance,
}
void
nsSVGFEBlendElement::GetSourceImageNames(nsTArray<nsSVGString*>* aSources)
nsSVGFEBlendElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
{
aSources->AppendElement(&mStringAttributes[IN1]);
aSources->AppendElement(&mStringAttributes[IN2]);
aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN1], this));
aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN2], this));
}
//----------------------------------------------------------------------
@ -984,8 +983,8 @@ public:
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual nsSVGString* GetResultImageName() { return &mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGString*>* aSources);
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources);
// Color Matrix
NS_DECL_NSIDOMSVGFECOLORMATRIXELEMENT
@ -1109,9 +1108,9 @@ NS_IMETHODIMP nsSVGFEColorMatrixElement::GetValues(nsIDOMSVGAnimatedNumberList *
}
void
nsSVGFEColorMatrixElement::GetSourceImageNames(nsTArray<nsSVGString*>* aSources)
nsSVGFEColorMatrixElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
{
aSources->AppendElement(&mStringAttributes[IN1]);
aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN1], this));
}
nsresult
@ -1308,8 +1307,8 @@ public:
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual nsSVGString* GetResultImageName() { return &mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGString*>* aSources);
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources);
virtual nsIntRect ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
const nsSVGFilterInstance& aInstance);
@ -1522,10 +1521,10 @@ nsSVGFECompositeElement::Filter(nsSVGFilterInstance *instance,
}
void
nsSVGFECompositeElement::GetSourceImageNames(nsTArray<nsSVGString*>* aSources)
nsSVGFECompositeElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
{
aSources->AppendElement(&mStringAttributes[IN1]);
aSources->AppendElement(&mStringAttributes[IN2]);
aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN1], this));
aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN2], this));
}
nsIntRect
@ -1604,8 +1603,8 @@ public:
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual nsSVGString* GetResultImageName() { return &mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGString*>* aSources);
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources);
// Component Transfer
NS_DECL_NSIDOMSVGFECOMPONENTTRANSFERELEMENT
@ -1765,9 +1764,9 @@ nsSVGFEComponentTransferElement::Filter(nsSVGFilterInstance *instance,
}
void
nsSVGFEComponentTransferElement::GetSourceImageNames(nsTArray<nsSVGString*>* aSources)
nsSVGFEComponentTransferElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
{
aSources->AppendElement(&mStringAttributes[IN1]);
aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN1], this));
}
nsSVGElement::NumberInfo nsSVGComponentTransferFunctionElement::sNumberInfo[5] =
@ -2185,8 +2184,8 @@ public:
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual nsSVGString* GetResultImageName() { return &mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGString*>* aSources);
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources);
// Merge
NS_DECL_NSIDOMSVGFEMERGEELEMENT
@ -2237,7 +2236,7 @@ public:
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
nsSVGString* In1() { return &mStringAttributes[IN1]; }
const nsSVGString* In1() { return &mStringAttributes[IN1]; }
operator nsISupports*() { return static_cast<nsIContent*>(this); }
@ -2292,7 +2291,7 @@ nsSVGFEMergeElement::Filter(nsSVGFilterInstance *instance,
}
void
nsSVGFEMergeElement::GetSourceImageNames(nsTArray<nsSVGString*>* aSources)
nsSVGFEMergeElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
{
PRUint32 count = GetChildCount();
for (PRUint32 i = 0; i < count; i++) {
@ -2300,7 +2299,7 @@ nsSVGFEMergeElement::GetSourceImageNames(nsTArray<nsSVGString*>* aSources)
nsRefPtr<nsSVGFEMergeNodeElement> node;
CallQueryInterface(child, (nsSVGFEMergeNodeElement**)getter_AddRefs(node));
if (node) {
aSources->AppendElement(node->In1());
aSources.AppendElement(nsSVGStringInfo(node->In1(), node));
}
}
}
@ -2391,8 +2390,8 @@ public:
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual nsSVGString* GetResultImageName() { return &mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGString*>* aSources);
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources);
virtual nsIntRect ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
const nsSVGFilterInstance& aInstance);
virtual void ComputeNeededSourceBBoxes(const nsIntRect& aTargetBBox,
@ -2523,9 +2522,9 @@ nsSVGFEOffsetElement::Filter(nsSVGFilterInstance *instance,
}
void
nsSVGFEOffsetElement::GetSourceImageNames(nsTArray<nsSVGString*>* aSources)
nsSVGFEOffsetElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
{
aSources->AppendElement(&mStringAttributes[IN1]);
aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN1], this));
}
nsIntRect
@ -2592,7 +2591,7 @@ public:
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual nsSVGString* GetResultImageName() { return &mStringAttributes[RESULT]; }
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual nsIntRect ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
const nsSVGFilterInstance& aInstance);
@ -2731,8 +2730,8 @@ public:
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual nsSVGString* GetResultImageName() { return &mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGString*>* aSources);
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources);
virtual nsIntRect ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
const nsSVGFilterInstance& aInstance);
virtual void ComputeNeededSourceBBoxes(const nsIntRect& aTargetBBox,
@ -2797,9 +2796,9 @@ NS_IMETHODIMP nsSVGFETileElement::GetIn1(nsIDOMSVGAnimatedString * *aIn)
}
void
nsSVGFETileElement::GetSourceImageNames(nsTArray<nsSVGString*>* aSources)
nsSVGFETileElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
{
aSources->AppendElement(&mStringAttributes[IN1]);
aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN1], this));
}
nsIntRect
@ -2915,7 +2914,7 @@ public:
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual nsSVGString* GetResultImageName() { return &mStringAttributes[RESULT]; }
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual nsIntRect ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
const nsSVGFilterInstance& aInstance);
@ -3429,8 +3428,8 @@ public:
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual nsSVGString* GetResultImageName() { return &mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGString*>* aSources);
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources);
virtual nsIntRect ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
const nsSVGFilterInstance& aInstance);
virtual void ComputeNeededSourceBBoxes(const nsIntRect& aTargetBBox,
@ -3556,9 +3555,9 @@ nsSVGFEMorphologyElement::SetRadius(float rx, float ry)
}
void
nsSVGFEMorphologyElement::GetSourceImageNames(nsTArray<nsSVGString*>* aSources)
nsSVGFEMorphologyElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
{
aSources->AppendElement(&mStringAttributes[IN1]);
aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN1], this));
}
nsIntRect
@ -3750,8 +3749,8 @@ public:
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual nsSVGString* GetResultImageName() { return &mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGString*>* aSources);
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources);
virtual nsIntRect ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
const nsSVGFilterInstance& aInstance);
virtual void ComputeNeededSourceBBoxes(const nsIntRect& aTargetBBox,
@ -3964,9 +3963,9 @@ nsSVGFEConvolveMatrixElement::GetKernelUnitLengthY(nsIDOMSVGAnimatedNumber **aKe
}
void
nsSVGFEConvolveMatrixElement::GetSourceImageNames(nsTArray<nsSVGString*>* aSources)
nsSVGFEConvolveMatrixElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
{
aSources->AppendElement(&mStringAttributes[IN1]);
aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN1], this));
}
nsIntRect
@ -4525,8 +4524,8 @@ public:
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual nsSVGString* GetResultImageName() { return &mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGString*>* aSources);
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources);
// XXX shouldn't we have ComputeTargetBBox here, since the output can
// extend beyond the bounds of the inputs thanks to the convolution kernel?
virtual void ComputeNeededSourceBBoxes(const nsIntRect& aTargetBBox,
@ -4598,9 +4597,9 @@ nsSVGFELightingElement::IsAttributeMapped(const nsIAtom* name) const
}
void
nsSVGFELightingElement::GetSourceImageNames(nsTArray<nsSVGString*>* aSources)
nsSVGFELightingElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
{
aSources->AppendElement(&mStringAttributes[IN1]);
aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN1], this));
}
void
@ -5160,7 +5159,7 @@ public:
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual nsSVGString* GetResultImageName() { return &mStringAttributes[RESULT]; }
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual nsIntRect ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
const nsSVGFilterInstance& aInstance);
@ -5256,7 +5255,8 @@ nsSVGFEImageElement::LoadSVGImage(PRBool aForce, PRBool aNotify)
// resolve href attribute
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
nsAutoString href(mStringAttributes[HREF].GetAnimValue());
nsAutoString href;
mStringAttributes[HREF].GetAnimValue(href, this);
href.Trim(" \t\n\r");
if (baseURI && !href.IsEmpty())
@ -5481,8 +5481,8 @@ public:
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual nsSVGString* GetResultImageName() { return &mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGString*>* aSources);
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources);
virtual nsIntRect ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
const nsSVGFilterInstance& aInstance);
virtual void ComputeNeededSourceBBoxes(const nsIntRect& aTargetBBox,
@ -5678,10 +5678,10 @@ nsSVGFEDisplacementMapElement::Filter(nsSVGFilterInstance *instance,
}
void
nsSVGFEDisplacementMapElement::GetSourceImageNames(nsTArray<nsSVGString*>* aSources)
nsSVGFEDisplacementMapElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
{
aSources->AppendElement(&mStringAttributes[IN1]);
aSources->AppendElement(&mStringAttributes[IN2]);
aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN1], this));
aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN2], this));
}
nsIntRect

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

@ -48,6 +48,15 @@ class nsSVGFilterResource;
class nsSVGString;
class nsSVGFilterInstance;
struct nsSVGStringInfo {
nsSVGStringInfo(const nsSVGString* aString,
nsSVGElement *aElement) :
mString(aString), mElement(aElement) {}
const nsSVGString* mString;
nsSVGElement* mElement;
};
typedef nsSVGStylableElement nsSVGFEBase;
#define NS_SVG_FE_CID \
@ -137,10 +146,10 @@ public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMSVGFILTERPRIMITIVESTANDARDATTRIBUTES
virtual nsSVGString* GetResultImageName() = 0;
virtual nsSVGString& GetResultImageName() = 0;
// Return a list of all image names used as sources. Default is to
// return no sources.
virtual void GetSourceImageNames(nsTArray<nsSVGString*>* aSources);
virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources);
// Compute the bounding box of the filter output. The default is just the
// union of the source bounding boxes. The caller is
// responsible for clipping this to the filter primitive subregion, so

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

@ -146,7 +146,8 @@ nsSVGImageElement::LoadSVGImage(PRBool aForce, PRBool aNotify)
// resolve href attribute
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
nsAutoString href(mStringAttributes[HREF].GetAnimValue());
nsAutoString href;
mStringAttributes[HREF].GetAnimValue(href, this);
href.Trim(" \t\n\r");
if (baseURI && !href.IsEmpty())

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

@ -85,7 +85,7 @@ public:
virtual PRBool HasScriptContent();
// nsSVGElement specializations:
virtual void DidChangeString(PRUint8 aAttrEnum, PRBool aDoSetAttr);
virtual void DidChangeString(PRUint8 aAttrEnum);
// nsIContent specializations:
virtual nsresult DoneAddingChildren(PRBool aHaveNotified);
@ -147,7 +147,8 @@ nsSVGScriptElement::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
}
nsCOMPtr<nsINode> kungFuDeathGrip = it;
nsresult rv = CopyInnerTo(it);
nsresult rv = it->Init();
rv |= CopyInnerTo(it);
NS_ENSURE_SUCCESS(rv, rv);
// The clone should be marked evaluated if we are.
@ -204,7 +205,8 @@ already_AddRefed<nsIURI>
nsSVGScriptElement::GetScriptURI()
{
nsIURI *uri = nsnull;
const nsString &src = mStringAttributes[HREF].GetAnimValue();
nsAutoString src;
mStringAttributes[HREF].GetAnimValue(src, this);
if (!src.IsEmpty()) {
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
NS_NewURI(&uri, src, nsnull, baseURI);
@ -236,7 +238,9 @@ nsSVGScriptElement::GetScriptDeferred()
PRBool
nsSVGScriptElement::HasScriptContent()
{
return !mStringAttributes[HREF].GetAnimValue().IsEmpty() ||
nsAutoString str;
mStringAttributes[HREF].GetAnimValue(str, this);
return !str.IsEmpty() ||
nsContentUtils::HasNonEmptyTextContent(this);
}
@ -244,9 +248,9 @@ nsSVGScriptElement::HasScriptContent()
// nsSVGElement methods
void
nsSVGScriptElement::DidChangeString(PRUint8 aAttrEnum, PRBool aDoSetAttr)
nsSVGScriptElement::DidChangeString(PRUint8 aAttrEnum)
{
nsSVGScriptElementBase::DidChangeString(aAttrEnum, aDoSetAttr);
nsSVGScriptElementBase::DidChangeString(aAttrEnum);
if (aAttrEnum == HREF) {
MaybeProcessScript();
@ -286,3 +290,4 @@ nsSVGScriptElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
return NS_OK;
}

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

@ -54,8 +54,24 @@ nsSVGString::SetBaseValue(const nsAString& aValue,
nsSVGElement *aSVGElement,
PRBool aDoSetAttr)
{
mAnimVal = mBaseVal = aValue;
aSVGElement->DidChangeString(mAttrEnum, aDoSetAttr);
NS_ASSERTION(aSVGElement, "Null element passed to SetBaseValue");
mAnimVal = nsnull;
if (aDoSetAttr) {
aSVGElement->SetStringBaseValue(mAttrEnum, aValue);
}
aSVGElement->DidChangeString(mAttrEnum);
}
void
nsSVGString::GetAnimValue(nsAString& aResult, const nsSVGElement* aSVGElement) const
{
if (mAnimVal)
aResult = *mAnimVal;
aSVGElement->GetStringBaseValue(mAttrEnum, aResult);
}
nsresult

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

@ -46,26 +46,24 @@ class nsSVGString
public:
void Init(PRUint8 aAttrEnum) {
mAnimVal.Truncate();
mBaseVal.Truncate();
mAnimVal = nsnull;
mAttrEnum = aAttrEnum;
}
void SetBaseValue(const nsAString& aValue,
nsSVGElement *aSVGElement,
PRBool aDoSetAttr);
const nsString &GetBaseValue() const
{ return mBaseVal; }
const nsString &GetAnimValue() const
{ return mAnimVal; }
void GetBaseValue(nsAString& aValue, nsSVGElement* aSVGElement) const
{ aSVGElement->GetStringBaseValue(mAttrEnum, aValue); }
void GetAnimValue(nsAString& aValue, const nsSVGElement* aSVGElement) const;
nsresult ToDOMAnimatedString(nsIDOMSVGAnimatedString **aResult,
nsSVGElement* aSVGElement);
private:
nsString mAnimVal;
nsString mBaseVal;
nsAutoPtr<nsString> mAnimVal;
PRUint8 mAttrEnum; // element specified tracking for attribute
struct DOMAnimatedString : public nsIDOMSVGAnimatedString
@ -80,12 +78,12 @@ private:
nsRefPtr<nsSVGElement> mSVGElement;
NS_IMETHOD GetBaseVal(nsAString & aResult)
{ aResult = mVal->GetBaseValue(); return NS_OK; }
{ mVal->GetBaseValue(aResult, mSVGElement); return NS_OK; }
NS_IMETHOD SetBaseVal(const nsAString & aValue)
{ mVal->SetBaseValue(aValue, mSVGElement, PR_TRUE); return NS_OK; }
NS_IMETHOD GetAnimVal(nsAString & aResult)
{ aResult = mVal->GetAnimValue(); return NS_OK; }
{ mVal->GetAnimValue(aResult, mSVGElement); return NS_OK; }
};
};

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

@ -238,7 +238,8 @@ nsIContent*
nsSVGUseElement::CreateAnonymousContent()
{
#ifdef DEBUG_tor
const nsString &href = mStringAttributes[HREF].GetAnimValue();
nsAutoString href;
mStringAttributes[HREF].GetAnimValue(href, this);
fprintf(stderr, "<svg:use> reclone of \"%s\"\n", ToNewCString(href));
#endif
@ -421,7 +422,8 @@ nsSVGUseElement::SyncWidthHeight(PRUint8 aAttrEnum)
void
nsSVGUseElement::LookupHref()
{
const nsString &href = mStringAttributes[HREF].GetAnimValue();
nsAutoString href;
mStringAttributes[HREF].GetAnimValue(href, this);
if (href.IsEmpty())
return;
@ -471,9 +473,9 @@ nsSVGUseElement::GetLengthInfo()
}
void
nsSVGUseElement::DidChangeString(PRUint8 aAttrEnum, PRBool aDoSetAttr)
nsSVGUseElement::DidChangeString(PRUint8 aAttrEnum)
{
nsSVGUseElementBase::DidChangeString(aAttrEnum, aDoSetAttr);
nsSVGUseElementBase::DidChangeString(aAttrEnum);
if (aAttrEnum == HREF) {
// we're changing our nature, clear out the clone information
@ -510,3 +512,4 @@ nsSVGUseElement::IsAttributeMapped(const nsIAtom* name) const
return FindAttributeDependence(name, map, NS_ARRAY_LENGTH(map)) ||
nsSVGUseElementBase::IsAttributeMapped(name);
}

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

@ -100,7 +100,7 @@ public:
// nsSVGElement specializations:
virtual void DidChangeLength(PRUint8 aAttrEnum, PRBool aDoSetAttr);
virtual void DidChangeString(PRUint8 aAttrEnum, PRBool aDoSetAttr);
virtual void DidChangeString(PRUint8 aAttrEnum);
// nsIContent interface
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;

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

@ -200,11 +200,12 @@ nsSVGFilterInstance::BuildPrimitives()
for (i = 0; i < mPrimitives.Length(); ++i) {
PrimitiveInfo* info = &mPrimitives[i];
nsSVGFE* filter = info->mFE;
nsAutoTArray<nsSVGString*,2> sources;
filter->GetSourceImageNames(&sources);
nsAutoTArray<nsSVGStringInfo,2> sources;
filter->GetSourceImageNames(sources);
for (PRUint32 j=0; j<sources.Length(); ++j) {
const nsString& str = sources[j]->GetAnimValue();
nsAutoString str;
sources[j].mString->GetAnimValue(str, sources[j].mElement);
PrimitiveInfo* sourceInfo;
if (str.EqualsLiteral("SourceGraphic")) {
@ -231,8 +232,10 @@ nsSVGFilterInstance::BuildPrimitives()
ComputeFilterPrimitiveSubregion(info);
ImageAnalysisEntry* entry =
imageTable.PutEntry(filter->GetResultImageName()->GetAnimValue());
nsAutoString str;
filter->GetResultImageName().GetAnimValue(str, filter);
ImageAnalysisEntry* entry = imageTable.PutEntry(str);
if (entry) {
entry->mInfo = info;
}

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

@ -282,7 +282,8 @@ nsSVGGradientFrame::GetReferencedGradient()
if (!property) {
// Fetch our gradient element's xlink:href attribute
nsSVGGradientElement *grad = static_cast<nsSVGGradientElement *>(mContent);
const nsString &href = grad->mStringAttributes[nsSVGGradientElement::HREF].GetAnimValue();
nsAutoString href;
grad->mStringAttributes[nsSVGGradientElement::HREF].GetAnimValue(href, grad);
if (href.IsEmpty()) {
mNoHRefURI = PR_TRUE;
return nsnull; // no URL

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

@ -444,7 +444,8 @@ nsSVGPatternFrame::GetReferencedPattern()
if (!property) {
// Fetch our pattern element's xlink:href attribute
nsSVGPatternElement *pattern = static_cast<nsSVGPatternElement *>(mContent);
const nsString &href = pattern->mStringAttributes[nsSVGPatternElement::HREF].GetAnimValue();
nsAutoString href;
pattern->mStringAttributes[nsSVGPatternElement::HREF].GetAnimValue(href, pattern);
if (href.IsEmpty()) {
mNoHRefURI = PR_TRUE;
return nsnull; // no URL

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

@ -117,7 +117,8 @@ nsSVGTextPathFrame::GetPathFrame()
if (!property) {
nsSVGTextPathElement *tp = static_cast<nsSVGTextPathElement*>(mContent);
const nsString &href = tp->mStringAttributes[nsSVGTextPathElement::HREF].GetAnimValue();
nsAutoString href;
tp->mStringAttributes[nsSVGTextPathElement::HREF].GetAnimValue(href, tp);
if (href.IsEmpty()) {
return nsnull; // no URL
}