Bug 602759 part 13 - Update layout to use new matrix and transform types; r=jwatt

This commit is contained in:
Brian Birtles 2011-09-25 22:04:32 +01:00
Родитель 33f23d7afc
Коммит 9058bc1a8c
22 изменённых файлов: 82 добавлений и 116 удалений

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

@ -39,7 +39,6 @@
#include "nsSVGTSpanFrame.h"
#include "nsISVGGlyphFragmentNode.h"
#include "nsSVGGraphicElement.h"
#include "nsSVGMatrix.h"
#include "nsSVGAElement.h"
#include "nsSVGUtils.h"
#include "gfxMatrix.h"
@ -103,7 +102,7 @@ public:
}
private:
nsCOMPtr<nsIDOMSVGMatrix> mCanvasTM;
nsAutoPtr<gfxMatrix> mCanvasTM;
};
//----------------------------------------------------------------------
@ -188,10 +187,10 @@ nsSVGAFrame::GetCanvasTM()
gfxMatrix tm = content->PrependLocalTransformTo(parent->GetCanvasTM());
mCanvasTM = NS_NewSVGMatrix(tm);
mCanvasTM = new gfxMatrix(tm);
}
return nsSVGUtils::ConvertSVGMatrixToThebes(mCanvasTM);
return *mCanvasTM;
}
//----------------------------------------------------------------------

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

@ -43,7 +43,6 @@
#include "nsSVGEffects.h"
#include "nsSVGClipPathElement.h"
#include "gfxContext.h"
#include "nsSVGMatrix.h"
//----------------------------------------------------------------------
// Implementation
@ -71,7 +70,11 @@ nsSVGClipPathFrame::ClipPaint(nsSVGRenderState* aContext,
AutoClipPathReferencer clipRef(this);
mClipParent = aParent;
mClipParentMatrix = NS_NewSVGMatrix(aMatrix);
if (mClipParentMatrix) {
*mClipParentMatrix = aMatrix;
} else {
mClipParentMatrix = new gfxMatrix(aMatrix);
}
PRBool isTrivial = IsTrivial();
@ -183,7 +186,11 @@ nsSVGClipPathFrame::ClipHitTest(nsIFrame* aParent,
AutoClipPathReferencer clipRef(this);
mClipParent = aParent;
mClipParentMatrix = NS_NewSVGMatrix(aMatrix);
if (mClipParentMatrix) {
*mClipParentMatrix = aMatrix;
} else {
mClipParentMatrix = new gfxMatrix(aMatrix);
}
nsSVGClipPathFrame *clipPathFrame =
nsSVGEffects::GetEffectProperties(this).GetClipPathFrame(nsnull);
@ -319,8 +326,9 @@ nsSVGClipPathFrame::GetCanvasTM()
{
nsSVGClipPathElement *content = static_cast<nsSVGClipPathElement*>(mContent);
gfxMatrix tm = content->PrependLocalTransformTo(
nsSVGUtils::ConvertSVGMatrixToThebes(mClipParentMatrix));
gfxMatrix tm =
content->PrependLocalTransformTo(mClipParentMatrix ?
*mClipParentMatrix : gfxMatrix());
return nsSVGUtils::AdjustMatrixForUnits(tm,
&content->mEnumAttributes[nsSVGClipPathElement::CLIPPATHUNITS],

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

@ -49,7 +49,6 @@ class nsSVGClipPathFrame : public nsSVGClipPathFrameBase
protected:
nsSVGClipPathFrame(nsStyleContext* aContext) :
nsSVGClipPathFrameBase(aContext),
mClipParentMatrix(nsnull),
mInUse(PR_FALSE) {}
public:
@ -115,7 +114,7 @@ public:
};
nsIFrame *mClipParent;
nsCOMPtr<nsIDOMSVGMatrix> mClipParentMatrix;
nsAutoPtr<gfxMatrix> mClipParentMatrix;
// recursion prevention flag
PRPackedBool mInUse;

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

@ -47,7 +47,6 @@
#include "nsSVGUtils.h"
#include "nsIURI.h"
#include "nsSVGRect.h"
#include "nsSVGMatrix.h"
#include "nsINameSpaceManager.h"
#include "nsSVGForeignObjectElement.h"
#include "nsSVGContainerFrame.h"
@ -467,9 +466,9 @@ nsSVGForeignObjectFrame::GetCanvasTM()
gfxMatrix tm = content->PrependLocalTransformTo(parent->GetCanvasTM());
mCanvasTM = NS_NewSVGMatrix(tm);
mCanvasTM = new gfxMatrix(tm);
}
return nsSVGUtils::ConvertSVGMatrixToThebes(mCanvasTM);
return *mCanvasTM;
}
//----------------------------------------------------------------------

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

@ -41,7 +41,6 @@
#include "nsContainerFrame.h"
#include "nsISVGChildFrame.h"
#include "nsIDOMSVGMatrix.h"
#include "nsRegion.h"
#include "nsIPresShell.h"
#include "gfxRect.h"
@ -153,7 +152,7 @@ protected:
// If width or height is less than or equal to zero we must disable rendering
PRBool IsDisabled() const { return mRect.width <= 0 || mRect.height <= 0; }
nsCOMPtr<nsIDOMSVGMatrix> mCanvasTM;
nsAutoPtr<gfxMatrix> mCanvasTM;
// Areas dirtied by changes to decendents that are in our document
nsRegion mSameDocDirtyRegion;

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

@ -39,7 +39,6 @@
#include "nsIDOMSVGTransformable.h"
#include "nsSVGGFrame.h"
#include "nsIFrame.h"
#include "nsSVGMatrix.h"
#include "nsGkAtoms.h"
#include "nsSVGUtils.h"
#include "nsSVGGraphicElement.h"
@ -100,9 +99,9 @@ nsSVGGFrame::GetCanvasTM()
gfxMatrix tm = content->PrependLocalTransformTo(parent->GetCanvasTM());
mCanvasTM = NS_NewSVGMatrix(tm);
mCanvasTM = new gfxMatrix(tm);
}
return nsSVGUtils::ConvertSVGMatrixToThebes(mCanvasTM);
return *mCanvasTM;
}
NS_IMETHODIMP

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

@ -86,7 +86,7 @@ public:
// nsSVGContainerFrame methods:
virtual gfxMatrix GetCanvasTM();
nsCOMPtr<nsIDOMSVGMatrix> mCanvasTM;
nsAutoPtr<gfxMatrix> mCanvasTM;
};
#endif

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

@ -639,7 +639,11 @@ nsSVGGlyphFrame::FillCharacters(CharacterIterator *aIter,
gfxRect
nsSVGGlyphFrame::GetBBoxContribution(const gfxMatrix &aToBBoxUserspace)
{
mOverrideCanvasTM = NS_NewSVGMatrix(aToBBoxUserspace);
if (mOverrideCanvasTM) {
*mOverrideCanvasTM = aToBBoxUserspace;
} else {
mOverrideCanvasTM = new gfxMatrix(aToBBoxUserspace);
}
nsRefPtr<gfxContext> tmpCtx = MakeTmpCtx();
SetupGlobalTransform(tmpCtx);
@ -660,7 +664,7 @@ gfxMatrix
nsSVGGlyphFrame::GetCanvasTM()
{
if (mOverrideCanvasTM) {
return nsSVGUtils::ConvertSVGMatrixToThebes(mOverrideCanvasTM);
return *mOverrideCanvasTM;
}
NS_ASSERTION(mParent, "null parent");
return static_cast<nsSVGContainerFrame*>(mParent)->GetCanvasTM();

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

@ -46,7 +46,6 @@
#include "gfxFont.h"
#include "gfxRect.h"
#include "gfxMatrix.h"
#include "nsSVGMatrix.h"
#include "nsTextFragment.h"
class nsSVGTextFrame;
@ -247,7 +246,7 @@ protected:
// Used to support GetBBoxContribution by making GetConvasTM use this as the
// parent transform instead of the real CanvasTM.
nsCOMPtr<nsIDOMSVGMatrix> mOverrideCanvasTM;
nsAutoPtr<gfxMatrix> mOverrideCanvasTM;
// Owning pointer, must call gfxTextRunWordCache::RemoveTextRun before deleting
gfxTextRun *mTextRun;

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

@ -39,8 +39,7 @@
#include "nsIDOMSVGAnimatedNumber.h"
#include "nsIDOMSVGAnimTransformList.h"
#include "nsSVGTransformList.h"
#include "nsSVGMatrix.h"
#include "SVGAnimatedTransformList.h"
#include "nsSVGEffects.h"
#include "nsIDOMSVGStopElement.h"
#include "nsSVGGradientElement.h"
@ -50,6 +49,8 @@
#include "gfxPattern.h"
#include "nsContentUtils.h"
using mozilla::SVGAnimatedTransformList;
//----------------------------------------------------------------------
// Implementation
@ -160,18 +161,14 @@ nsSVGGradientFrame::GetGradientTransform(nsIFrame *aSource,
nsSVGGradientElement *element =
GetGradientWithAttr(nsGkAtoms::gradientTransform, mContent);
if (!element->mGradientTransform)
SVGAnimatedTransformList* animTransformList =
element->GetAnimatedTransformList();
if (!animTransformList)
return bboxMatrix;
nsCOMPtr<nsIDOMSVGTransformList> trans;
element->mGradientTransform->GetAnimVal(getter_AddRefs(trans));
nsCOMPtr<nsIDOMSVGMatrix> gradientTransform =
nsSVGTransformList::GetConsolidationMatrix(trans);
if (!gradientTransform)
return bboxMatrix;
return bboxMatrix.PreMultiply(nsSVGUtils::ConvertSVGMatrixToThebes(gradientTransform));
gfxMatrix gradientTransform =
animTransformList->GetAnimValue().GetConsolidationMatrix();
return bboxMatrix.PreMultiply(gradientTransform);
}
PRUint16

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

@ -41,7 +41,6 @@
#include "nsISVGChildFrame.h"
#include "nsSVGOuterSVGFrame.h"
#include "nsIDOMSVGAnimatedRect.h"
#include "nsSVGMatrix.h"
#include "nsSVGSVGElement.h"
#include "nsSVGContainerFrame.h"
#include "gfxContext.h"
@ -272,8 +271,8 @@ nsSVGInnerSVGFrame::GetCanvasTM()
gfxMatrix tm = content->PrependLocalTransformTo(parent->GetCanvasTM());
mCanvasTM = NS_NewSVGMatrix(tm);
mCanvasTM = new gfxMatrix(tm);
}
return nsSVGUtils::ConvertSVGMatrixToThebes(mCanvasTM);
return *mCanvasTM;
}

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

@ -98,5 +98,5 @@ public:
protected:
nsCOMPtr<nsIDOMSVGMatrix> mCanvasTM;
nsAutoPtr<gfxMatrix> mCanvasTM;
};

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

@ -39,10 +39,8 @@
#include "nsSVGContainerFrame.h"
#include "nsSVGMaskElement.h"
#include "nsSVGEffects.h"
#include "nsIDOMSVGMatrix.h"
#include "gfxContext.h"
#include "gfxImageSurface.h"
#include "nsSVGMatrix.h"
//----------------------------------------------------------------------
// Implementation
@ -118,7 +116,11 @@ nsSVGMaskFrame::ComputeMaskAlpha(nsSVGRenderState *aContext,
nsSVGRenderState tmpState(image);
mMaskParent = aParent;
mMaskParentMatrix = NS_NewSVGMatrix(aMatrix);
if (mMaskParentMatrix) {
*mMaskParentMatrix = aMatrix;
} else {
mMaskParentMatrix = new gfxMatrix(aMatrix);
}
for (nsIFrame* kid = mFrames.FirstChild(); kid;
kid = kid->GetNextSibling()) {
@ -203,8 +205,9 @@ nsSVGMaskFrame::GetCanvasTM()
nsSVGMaskElement *mask = static_cast<nsSVGMaskElement*>(mContent);
return nsSVGUtils::AdjustMatrixForUnits(nsSVGUtils::ConvertSVGMatrixToThebes(mMaskParentMatrix),
&mask->mEnumAttributes[nsSVGMaskElement::MASKCONTENTUNITS],
mMaskParent);
return nsSVGUtils::AdjustMatrixForUnits(
mMaskParentMatrix ? *mMaskParentMatrix : gfxMatrix(),
&mask->mEnumAttributes[nsSVGMaskElement::MASKCONTENTUNITS],
mMaskParent);
}

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

@ -52,7 +52,6 @@ class nsSVGMaskFrame : public nsSVGMaskFrameBase
protected:
nsSVGMaskFrame(nsStyleContext* aContext) :
nsSVGMaskFrameBase(aContext),
mMaskParentMatrix(nsnull),
mInUse(PR_FALSE) {}
public:
@ -109,7 +108,7 @@ private:
};
nsIFrame *mMaskParent;
nsCOMPtr<nsIDOMSVGMatrix> mMaskParentMatrix;
nsAutoPtr<gfxMatrix> mMaskParentMatrix;
// recursion prevention flag
PRPackedBool mInUse;

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

@ -53,7 +53,6 @@
#include "nsPIDOMWindow.h"
#include "nsIObjectLoadingContent.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsSVGMatrix.h"
namespace dom = mozilla::dom;
@ -793,9 +792,9 @@ nsSVGOuterSVGFrame::GetCanvasTM()
}
gfxMatrix TM = viewBoxTM * zoomPanTM * gfxMatrix().Scale(devPxPerCSSPx, devPxPerCSSPx);
mCanvasTM = NS_NewSVGMatrix(TM);
mCanvasTM = new gfxMatrix(TM);
}
return nsSVGUtils::ConvertSVGMatrixToThebes(mCanvasTM);
return *mCanvasTM;
}
//----------------------------------------------------------------------

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

@ -171,7 +171,7 @@ protected:
nsTHashtable<nsVoidPtrHashKey> mForeignObjectHash;
PRUint32 mRedrawSuspendCount;
nsCOMPtr<nsIDOMSVGMatrix> mCanvasTM;
nsAutoPtr<gfxMatrix> mCanvasTM;
float mFullZoom;

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

@ -40,18 +40,16 @@
#include "nsGkAtoms.h"
#include "nsIDOMSVGAnimatedRect.h"
#include "nsSVGTransformList.h"
#include "SVGAnimatedTransformList.h"
#include "nsStyleContext.h"
#include "nsINameSpaceManager.h"
#include "nsISVGChildFrame.h"
#include "nsSVGMatrix.h"
#include "nsSVGRect.h"
#include "nsSVGUtils.h"
#include "nsSVGEffects.h"
#include "nsSVGOuterSVGFrame.h"
#include "nsSVGPatternElement.h"
#include "nsSVGGeometryFrame.h"
#include "nsSVGAnimatedTransformList.h"
#include "gfxContext.h"
#include "gfxPlatform.h"
#include "gfxPattern.h"
@ -164,7 +162,7 @@ gfxMatrix
nsSVGPatternFrame::GetCanvasTM()
{
if (mCTM) {
return nsSVGUtils::ConvertSVGMatrixToThebes(mCTM);
return *mCTM;
}
// Do we know our rendering parent?
@ -241,7 +239,11 @@ nsSVGPatternFrame::PaintPattern(gfxASurface** surface,
// Get the pattern we are going to render
nsSVGPatternFrame *patternFrame =
static_cast<nsSVGPatternFrame*>(firstKid->GetParent());
patternFrame->mCTM = NS_NewSVGMatrix(ctm);
if (patternFrame->mCTM) {
*patternFrame->mCTM = ctm;
} else {
patternFrame->mCTM = new gfxMatrix(ctm);
}
// Get the bounding box of the pattern. This will be used to determine
// the size of the surface, and will also be used to define the bounding
@ -270,13 +272,11 @@ nsSVGPatternFrame::PaintPattern(gfxASurface** surface,
patternWidth != surfaceSize.width ||
patternHeight != surfaceSize.height) {
// scale drawing to pattern surface size
nsCOMPtr<nsIDOMSVGMatrix> tempTM, aCTM;
NS_NewSVGMatrix(getter_AddRefs(tempTM),
surfaceSize.width / patternWidth, 0.0f,
0.0f, surfaceSize.height / patternHeight,
0.0f, 0.0f);
patternFrame->mCTM->Multiply(tempTM, getter_AddRefs(aCTM));
aCTM.swap(patternFrame->mCTM);
gfxMatrix tempTM =
gfxMatrix(surfaceSize.width / patternWidth, 0.0f,
0.0f, surfaceSize.height / patternHeight,
0.0f, 0.0f);
patternFrame->mCTM->PreMultiply(tempTM);
// and rescale pattern to compensate
patternMatrix->Scale(patternWidth / surfaceSize.width,
@ -380,17 +380,13 @@ nsSVGPatternFrame::GetEnumValue(PRUint32 aIndex, nsIContent *aDefault)
mEnumAttributes[aIndex].GetAnimValue();
}
nsIDOMSVGAnimatedTransformList*
SVGAnimatedTransformList*
nsSVGPatternFrame::GetPatternTransformList(nsIContent* aDefault)
{
nsIDOMSVGAnimatedTransformList *thisTransformList =
static_cast<nsSVGPatternElement *>(mContent)->mPatternTransform.get();
SVGAnimatedTransformList *thisTransformList =
static_cast<nsSVGPatternElement *>(mContent)->GetAnimatedTransformList();
// XXX We should be able to do something cleaner than this casting once
// bug 602759 is fixed and we have a proper animated transform list class
const nsSVGAnimatedTransformList *thisListAsConcreteType =
static_cast<const nsSVGAnimatedTransformList *>(thisTransformList);
if (thisListAsConcreteType && thisListAsConcreteType->IsExplicitlySet())
if (thisTransformList->IsExplicitlySet())
return thisTransformList;
AutoPatternReferencer patternRef(this);
@ -403,21 +399,12 @@ nsSVGPatternFrame::GetPatternTransformList(nsIContent* aDefault)
gfxMatrix
nsSVGPatternFrame::GetPatternTransform()
{
nsIDOMSVGAnimatedTransformList* transformList =
SVGAnimatedTransformList* animTransformList =
GetPatternTransformList(mContent);
if (!animTransformList)
return gfxMatrix();
static const gfxMatrix identityMatrix;
if (!transformList) {
return identityMatrix;
}
nsCOMPtr<nsIDOMSVGTransformList> lTrans;
transformList->GetAnimVal(getter_AddRefs(lTrans));
nsCOMPtr<nsIDOMSVGMatrix> patternTransform =
nsSVGTransformList::GetConsolidationMatrix(lTrans);
if (!patternTransform) {
return identityMatrix;
}
return nsSVGUtils::ConvertSVGMatrixToThebes(patternTransform);
return animTransformList->GetAnimValue().GetConsolidationMatrix();
}
const nsSVGViewBox &

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

@ -39,7 +39,6 @@
#ifndef __NS_SVGPATTERNFRAME_H__
#define __NS_SVGPATTERNFRAME_H__
#include "nsIDOMSVGMatrix.h"
#include "nsSVGPaintServerFrame.h"
#include "gfxMatrix.h"
#include "nsIDOMSVGAnimTransformList.h"
@ -52,6 +51,7 @@ class gfxASurface;
namespace mozilla {
class SVGAnimatedPreserveAspectRatio;
class SVGAnimatedTransformList;
} // namespace mozilla
typedef nsSVGPaintServerFrame nsSVGPatternFrameBase;
@ -121,7 +121,8 @@ protected:
{
return GetEnumValue(aIndex, mContent);
}
nsIDOMSVGAnimatedTransformList* GetPatternTransformList(nsIContent* aDefault);
mozilla::SVGAnimatedTransformList* GetPatternTransformList(
nsIContent* aDefault);
gfxMatrix GetPatternTransform();
const nsSVGViewBox &GetViewBox(nsIContent *aDefault);
const nsSVGViewBox &GetViewBox() { return GetViewBox(mContent); }
@ -162,7 +163,7 @@ private:
// referencing our pattern. This must be temporary because different
// referencing frames will all reference this one frame
nsSVGGeometryFrame *mSource;
nsCOMPtr<nsIDOMSVGMatrix> mCTM;
nsAutoPtr<gfxMatrix> mCTM;
protected:
// This flag is used to detect loops in xlink:href processing

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

@ -47,7 +47,6 @@
#include "nsSVGOuterSVGFrame.h"
#include "nsIDOMSVGRect.h"
#include "nsSVGRect.h"
#include "nsSVGMatrix.h"
#include "nsGkAtoms.h"
#include "nsSVGTextPathFrame.h"
#include "nsSVGPathElement.h"
@ -278,10 +277,10 @@ nsSVGTextFrame::GetCanvasTM()
gfxMatrix tm = content->PrependLocalTransformTo(parent->GetCanvasTM());
mCanvasTM = NS_NewSVGMatrix(tm);
mCanvasTM = new gfxMatrix(tm);
}
return nsSVGUtils::ConvertSVGMatrixToThebes(mCanvasTM);
return *mCanvasTM;
}
//----------------------------------------------------------------------

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

@ -123,7 +123,7 @@ private:
void SetWhitespaceHandling(nsSVGGlyphFrame *aFrame);
nsCOMPtr<nsIDOMSVGMatrix> mCanvasTM;
nsAutoPtr<gfxMatrix> mCanvasTM;
enum UpdateState { unsuspended, suspended };
UpdateState mMetricsState;

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

@ -60,7 +60,6 @@
#include "nsSVGOuterSVGFrame.h"
#include "nsSVGInnerSVGFrame.h"
#include "SVGAnimatedPreserveAspectRatio.h"
#include "nsSVGMatrix.h"
#include "nsSVGClipPathFrame.h"
#include "nsSVGMaskFrame.h"
#include "nsSVGContainerFrame.h"
@ -1160,22 +1159,6 @@ nsSVGUtils::ConvertToSurfaceSize(const gfxSize& aSize,
return surfaceSize;
}
gfxMatrix
nsSVGUtils::ConvertSVGMatrixToThebes(nsIDOMSVGMatrix *aMatrix)
{
if (!aMatrix) {
return gfxMatrix();
}
float A, B, C, D, E, F;
aMatrix->GetA(&A);
aMatrix->GetB(&B);
aMatrix->GetC(&C);
aMatrix->GetD(&D);
aMatrix->GetE(&E);
aMatrix->GetF(&F);
return gfxMatrix(A, B, C, D, E, F);
}
PRBool
nsSVGUtils::HitTestRect(const gfxMatrix &aMatrix,
float aRX, float aRY, float aRWidth, float aRHeight,

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

@ -48,7 +48,6 @@
#include "nsRenderingContext.h"
#include "gfxRect.h"
#include "gfxMatrix.h"
#include "nsSVGMatrix.h"
class nsIDocument;
class nsPresContext;
@ -453,12 +452,6 @@ public:
static gfxIntSize ConvertToSurfaceSize(const gfxSize& aSize,
PRBool *aResultOverflows);
/*
* Convert a nsIDOMSVGMatrix to a gfxMatrix.
*/
static gfxMatrix
ConvertSVGMatrixToThebes(nsIDOMSVGMatrix *aMatrix);
/*
* Hit test a given rectangle/matrix.
*/