Bug 664130 - const-ify some SVG element class methods. r=dholbert.

This commit is contained in:
Jonathan Watt 2011-06-16 11:53:13 +01:00
parent 13b7699b24
commit 97132dbab9
12 changed files with 31 additions and 30 deletions

View File

@ -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;
}

View File

@ -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 <svg> or SVG without an <svg> 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 <animateMotion> transformation
// Only visible for nsSVGGraphicElement, so it's a no-op here, and that

View File

@ -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<nsSVGForeignObjectElement*>(this)->
GetAnimatedLengthValues(&x, &y, nsnull);
return gfxMatrix().Translate(gfxPoint(x, y)) * matrix;
}

View File

@ -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;

View File

@ -184,7 +184,7 @@ nsSVGGraphicElement::IsEventName(nsIAtom* aName)
}
gfxMatrix
nsSVGGraphicElement::PrependLocalTransformTo(const gfxMatrix &aMatrix)
nsSVGGraphicElement::PrependLocalTransformTo(const gfxMatrix &aMatrix) const
{
gfxMatrix result(aMatrix);

View File

@ -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:

View File

@ -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<nsSVGSVGElement*>(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<nsSVGSVGElement*>(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

View File

@ -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 <svg> in an image document, and we're not currently
// being painted by an <svg:image> 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 <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;

View File

@ -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<nsSVGUseElement*>(this)->GetAnimatedLengthValues(&x, &y, nsnull);
return matrix.PreMultiply(gfxMatrix().Translate(gfxPoint(x, y)));
}

View File

@ -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);

View File

@ -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,

View File

@ -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,