From 97132dbab905a3454a32cf724f5526bf51b8e4b4 Mon Sep 17 00:00:00 2001 From: Jonathan Watt Date: Thu, 16 Jun 2011 11:53:13 +0100 Subject: [PATCH] Bug 664130 - const-ify some SVG element class methods. r=dholbert. --- content/svg/content/src/nsSVGElement.cpp | 4 ++-- content/svg/content/src/nsSVGElement.h | 4 ++-- .../content/src/nsSVGForeignObjectElement.cpp | 5 +++-- .../svg/content/src/nsSVGForeignObjectElement.h | 2 +- content/svg/content/src/nsSVGGraphicElement.cpp | 2 +- content/svg/content/src/nsSVGGraphicElement.h | 2 +- content/svg/content/src/nsSVGSVGElement.cpp | 16 ++++++++-------- content/svg/content/src/nsSVGSVGElement.h | 12 ++++++------ content/svg/content/src/nsSVGUseElement.cpp | 4 ++-- content/svg/content/src/nsSVGUseElement.h | 2 +- layout/svg/base/src/nsSVGUtils.cpp | 4 ++-- layout/svg/base/src/nsSVGUtils.h | 4 ++-- 12 files changed, 31 insertions(+), 30 deletions(-) diff --git a/content/svg/content/src/nsSVGElement.cpp b/content/svg/content/src/nsSVGElement.cpp index 79696aab323..a748250425c 100644 --- a/content/svg/content/src/nsSVGElement.cpp +++ b/content/svg/content/src/nsSVGElement.cpp @@ -1405,7 +1405,7 @@ nsIAtom* nsSVGElement::GetEventNameForAttr(nsIAtom* aAttr) } nsSVGSVGElement * -nsSVGElement::GetCtx() +nsSVGElement::GetCtx() const { nsIContent* ancestor = GetFlattenedTreeParent(); @@ -1425,7 +1425,7 @@ nsSVGElement::GetCtx() } /* virtual */ gfxMatrix -nsSVGElement::PrependLocalTransformTo(const gfxMatrix &aMatrix) +nsSVGElement::PrependLocalTransformTo(const gfxMatrix &aMatrix) const { return aMatrix; } diff --git a/content/svg/content/src/nsSVGElement.h b/content/svg/content/src/nsSVGElement.h index a846053b465..1933f215a5d 100644 --- a/content/svg/content/src/nsSVGElement.h +++ b/content/svg/content/src/nsSVGElement.h @@ -152,13 +152,13 @@ public: // Gets the element that establishes the rectangular viewport against which // we should resolve percentage lengths (our "coordinate context"). Returns // nsnull for outer or SVG without an parent (invalid SVG). - nsSVGSVGElement* GetCtx(); + nsSVGSVGElement* GetCtx() const; /** * Returns aMatrix post-multiplied by the transform from the userspace * established by this element to the userspace established by its parent. */ - virtual gfxMatrix PrependLocalTransformTo(const gfxMatrix &aMatrix); + virtual gfxMatrix PrependLocalTransformTo(const gfxMatrix &aMatrix) const; // Setter for to set the current transformation // Only visible for nsSVGGraphicElement, so it's a no-op here, and that diff --git a/content/svg/content/src/nsSVGForeignObjectElement.cpp b/content/svg/content/src/nsSVGForeignObjectElement.cpp index 73a608739cc..00d1b2b5576 100644 --- a/content/svg/content/src/nsSVGForeignObjectElement.cpp +++ b/content/svg/content/src/nsSVGForeignObjectElement.cpp @@ -108,14 +108,15 @@ NS_IMETHODIMP nsSVGForeignObjectElement::GetHeight(nsIDOMSVGAnimatedLength * *aH // nsSVGElement methods /* virtual */ gfxMatrix -nsSVGForeignObjectElement::PrependLocalTransformTo(const gfxMatrix &aMatrix) +nsSVGForeignObjectElement::PrependLocalTransformTo(const gfxMatrix &aMatrix) const { // 'transform' attribute: gfxMatrix matrix = nsSVGForeignObjectElementBase::PrependLocalTransformTo(aMatrix); // now translate by our 'x' and 'y': float x, y; - GetAnimatedLengthValues(&x, &y, nsnull); + const_cast(this)-> + GetAnimatedLengthValues(&x, &y, nsnull); return gfxMatrix().Translate(gfxPoint(x, y)) * matrix; } diff --git a/content/svg/content/src/nsSVGForeignObjectElement.h b/content/svg/content/src/nsSVGForeignObjectElement.h index 76263b0eb46..6f9ef15566c 100644 --- a/content/svg/content/src/nsSVGForeignObjectElement.h +++ b/content/svg/content/src/nsSVGForeignObjectElement.h @@ -67,7 +67,7 @@ public: NS_FORWARD_NSIDOMSVGELEMENT(nsSVGForeignObjectElementBase::) // nsSVGElement specializations: - virtual gfxMatrix PrependLocalTransformTo(const gfxMatrix &aMatrix); + virtual gfxMatrix PrependLocalTransformTo(const gfxMatrix &aMatrix) const; // nsIContent interface NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* name) const; diff --git a/content/svg/content/src/nsSVGGraphicElement.cpp b/content/svg/content/src/nsSVGGraphicElement.cpp index 0a67a4bfe78..d04a0a3d021 100644 --- a/content/svg/content/src/nsSVGGraphicElement.cpp +++ b/content/svg/content/src/nsSVGGraphicElement.cpp @@ -184,7 +184,7 @@ nsSVGGraphicElement::IsEventName(nsIAtom* aName) } gfxMatrix -nsSVGGraphicElement::PrependLocalTransformTo(const gfxMatrix &aMatrix) +nsSVGGraphicElement::PrependLocalTransformTo(const gfxMatrix &aMatrix) const { gfxMatrix result(aMatrix); diff --git a/content/svg/content/src/nsSVGGraphicElement.h b/content/svg/content/src/nsSVGGraphicElement.h index 0fcf5d27cba..6792364125d 100644 --- a/content/svg/content/src/nsSVGGraphicElement.h +++ b/content/svg/content/src/nsSVGGraphicElement.h @@ -62,7 +62,7 @@ public: // nsIContent interface NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; - virtual gfxMatrix PrependLocalTransformTo(const gfxMatrix &aMatrix); + virtual gfxMatrix PrependLocalTransformTo(const gfxMatrix &aMatrix) const; virtual void SetAnimateMotionTransform(const gfxMatrix* aMatrix); protected: diff --git a/content/svg/content/src/nsSVGSVGElement.cpp b/content/svg/content/src/nsSVGSVGElement.cpp index d823aef17b0..c7396ff487b 100644 --- a/content/svg/content/src/nsSVGSVGElement.cpp +++ b/content/svg/content/src/nsSVGSVGElement.cpp @@ -952,22 +952,22 @@ nsSVGSVGElement::IsEventName(nsIAtom* aName) // resolve percentage lengths. (It can only be used to resolve // 'em'/'ex'-valued units). inline float -ComputeSynthesizedViewBoxDimension(nsSVGLength2& aLength, +ComputeSynthesizedViewBoxDimension(const nsSVGLength2& aLength, float aViewportLength, - nsSVGSVGElement* aSelf) + const nsSVGSVGElement* aSelf) { if (aLength.IsPercentage()) { return aViewportLength * aLength.GetAnimValInSpecifiedUnits() / 100.0f; } - return aLength.GetAnimValue(aSelf); + return aLength.GetAnimValue(const_cast(aSelf)); } //---------------------------------------------------------------------- // public helpers: gfxMatrix -nsSVGSVGElement::GetViewBoxTransform() +nsSVGSVGElement::GetViewBoxTransform() const { // Do we have an override preserveAspectRatio value? const SVGPreserveAspectRatio* overridePARPtr = @@ -1178,11 +1178,11 @@ nsSVGSVGElement::GetLength(PRUint8 aCtxType) // nsSVGElement methods /* virtual */ gfxMatrix -nsSVGSVGElement::PrependLocalTransformTo(const gfxMatrix &aMatrix) +nsSVGSVGElement::PrependLocalTransformTo(const gfxMatrix &aMatrix) const { if (IsInner()) { float x, y; - GetAnimatedLengthValues(&x, &y, nsnull); + const_cast(this)->GetAnimatedLengthValues(&x, &y, nsnull); return GetViewBoxTransform() * gfxMatrix().Translate(gfxPoint(x, y)) * aMatrix; } @@ -1272,7 +1272,7 @@ nsSVGSVGElement::GetPreserveAspectRatio() } PRBool -nsSVGSVGElement::ShouldSynthesizeViewBox() +nsSVGSVGElement::ShouldSynthesizeViewBox() const { NS_ABORT_IF_FALSE(!HasValidViewbox(), "Should only be called if we lack a viewBox"); @@ -1361,7 +1361,7 @@ nsSVGSVGElement::ClearImageOverridePreserveAspectRatio() } const SVGPreserveAspectRatio* -nsSVGSVGElement::GetImageOverridePreserveAspectRatio() +nsSVGSVGElement::GetImageOverridePreserveAspectRatio() const { void* valPtr = GetProperty(nsGkAtoms::overridePreserveAspectRatio); #ifdef DEBUG diff --git a/content/svg/content/src/nsSVGSVGElement.h b/content/svg/content/src/nsSVGSVGElement.h index bce1065d496..4906f0d0147 100644 --- a/content/svg/content/src/nsSVGSVGElement.h +++ b/content/svg/content/src/nsSVGSVGElement.h @@ -192,7 +192,7 @@ public: #endif // MOZ_SMIL // nsSVGElement specializations: - virtual gfxMatrix PrependLocalTransformTo(const gfxMatrix &aMatrix); + virtual gfxMatrix PrependLocalTransformTo(const gfxMatrix &aMatrix) const; virtual void DidChangeLength(PRUint8 aAttrEnum, PRBool aDoSetAttr); virtual void DidChangeEnum(PRUint8 aAttrEnum, PRBool aDoSetAttr); virtual void DidChangeViewBox(PRBool aDoSetAttr); @@ -205,7 +205,7 @@ public: float GetLength(PRUint8 mCtxType); // public helpers: - gfxMatrix GetViewBoxTransform(); + gfxMatrix GetViewBoxTransform() const; PRBool HasValidViewbox() const { return mViewBox.IsValid(); } // This services any pending notifications for the transform on on this root @@ -232,13 +232,13 @@ private: // particular) have access. void SetImageOverridePreserveAspectRatio(const SVGPreserveAspectRatio& aPAR); void ClearImageOverridePreserveAspectRatio(); - const SVGPreserveAspectRatio* GetImageOverridePreserveAspectRatio(); + const SVGPreserveAspectRatio* GetImageOverridePreserveAspectRatio() const; // Returns PR_TRUE if we should synthesize a viewBox for ourselves (that is, // if we're the outermost in an image document, and we're not currently // being painted by an element). This method also assumes that we // lack a valid viewBox attribute. - PRBool ShouldSynthesizeViewBox(); + PRBool ShouldSynthesizeViewBox() const; protected: // nsSVGElement overrides @@ -253,7 +253,7 @@ protected: // implementation helpers: - PRBool IsRoot() { + PRBool IsRoot() const { NS_ASSERTION((IsInDoc() && !GetParent()) == (GetOwnerDoc() && (GetOwnerDoc()->GetRootElement() == this)), "Can't determine if we're root"); @@ -264,7 +264,7 @@ protected: * Returns true if this is an SVG element that is the child of * another non-foreignObject SVG element. */ - PRBool IsInner() { + PRBool IsInner() const { const nsIContent *parent = GetFlattenedTreeParent(); return parent && parent->GetNameSpaceID() == kNameSpaceID_SVG && parent->Tag() != nsGkAtoms::foreignObject; diff --git a/content/svg/content/src/nsSVGUseElement.cpp b/content/svg/content/src/nsSVGUseElement.cpp index 68b97539cb4..17b850a255a 100644 --- a/content/svg/content/src/nsSVGUseElement.cpp +++ b/content/svg/content/src/nsSVGUseElement.cpp @@ -480,14 +480,14 @@ nsSVGUseElement::UnlinkSource() // nsSVGElement methods /* virtual */ gfxMatrix -nsSVGUseElement::PrependLocalTransformTo(const gfxMatrix &aMatrix) +nsSVGUseElement::PrependLocalTransformTo(const gfxMatrix &aMatrix) const { // 'transform' attribute: gfxMatrix matrix = nsSVGUseElementBase::PrependLocalTransformTo(aMatrix); // now translate by our 'x' and 'y': float x, y; - GetAnimatedLengthValues(&x, &y, nsnull); + const_cast(this)->GetAnimatedLengthValues(&x, &y, nsnull); return matrix.PreMultiply(gfxMatrix().Translate(gfxPoint(x, y))); } diff --git a/content/svg/content/src/nsSVGUseElement.h b/content/svg/content/src/nsSVGUseElement.h index 2a67b3029f9..a04fc0020e8 100644 --- a/content/svg/content/src/nsSVGUseElement.h +++ b/content/svg/content/src/nsSVGUseElement.h @@ -102,7 +102,7 @@ public: void DestroyAnonymousContent(); // nsSVGElement specializations: - virtual gfxMatrix PrependLocalTransformTo(const gfxMatrix &aMatrix); + virtual gfxMatrix PrependLocalTransformTo(const gfxMatrix &aMatrix) const; virtual void DidChangeLength(PRUint8 aAttrEnum, PRBool aDoSetAttr); virtual void DidChangeString(PRUint8 aAttrEnum); virtual void DidAnimateString(PRUint8 aAttrEnum); diff --git a/layout/svg/base/src/nsSVGUtils.cpp b/layout/svg/base/src/nsSVGUtils.cpp index 4c62e34b63c..c81247b0e1e 100644 --- a/layout/svg/base/src/nsSVGUtils.cpp +++ b/layout/svg/base/src/nsSVGUtils.cpp @@ -749,7 +749,7 @@ nsSVGUtils::GetOuterSVGFrameAndCoveredRegion(nsIFrame* aFrame, nsRect* aRect) } gfxMatrix -nsSVGUtils::GetViewBoxTransform(nsSVGElement* aElement, +nsSVGUtils::GetViewBoxTransform(const nsSVGElement* aElement, float aViewportWidth, float aViewportHeight, float aViewboxX, float aViewboxY, float aViewboxWidth, float aViewboxHeight, @@ -763,7 +763,7 @@ nsSVGUtils::GetViewBoxTransform(nsSVGElement* aElement, } gfxMatrix -nsSVGUtils::GetViewBoxTransform(nsSVGElement* aElement, +nsSVGUtils::GetViewBoxTransform(const nsSVGElement* aElement, float aViewportWidth, float aViewportHeight, float aViewboxX, float aViewboxY, float aViewboxWidth, float aViewboxHeight, diff --git a/layout/svg/base/src/nsSVGUtils.h b/layout/svg/base/src/nsSVGUtils.h index 738ee722186..3e911a13b3d 100644 --- a/layout/svg/base/src/nsSVGUtils.h +++ b/layout/svg/base/src/nsSVGUtils.h @@ -382,14 +382,14 @@ public: /* Generate a viewbox to viewport tranformation matrix */ static gfxMatrix - GetViewBoxTransform(nsSVGElement* aElement, + GetViewBoxTransform(const nsSVGElement* aElement, float aViewportWidth, float aViewportHeight, float aViewboxX, float aViewboxY, float aViewboxWidth, float aViewboxHeight, const SVGAnimatedPreserveAspectRatio &aPreserveAspectRatio); static gfxMatrix - GetViewBoxTransform(nsSVGElement* aElement, + GetViewBoxTransform(const nsSVGElement* aElement, float aViewportWidth, float aViewportHeight, float aViewboxX, float aViewboxY, float aViewboxWidth, float aViewboxHeight,