Bug 435356. Stop using nsIDOMSVGMatrix internally. r=longsonr
This commit is contained in:
Родитель
876fcce1ff
Коммит
c35c73bbc6
|
@ -932,8 +932,8 @@ nsSVGElement::GetOwnerSVGElement(nsIDOMSVGSVGElement * *aOwnerSVGElement)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsSVGElement::GetViewportElement(nsIDOMSVGElement * *aViewportElement)
|
nsSVGElement::GetViewportElement(nsIDOMSVGElement * *aViewportElement)
|
||||||
{
|
{
|
||||||
nsSVGUtils::GetNearestViewportElement(this, aViewportElement);
|
*aViewportElement = nsSVGUtils::GetNearestViewportElement(this).get();
|
||||||
return NS_OK; // we can't throw exceptions from this API.
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
|
@ -57,6 +57,7 @@
|
||||||
#include "nsIDocument.h"
|
#include "nsIDocument.h"
|
||||||
#include "nsIFrame.h"
|
#include "nsIFrame.h"
|
||||||
#include "gfxContext.h"
|
#include "gfxContext.h"
|
||||||
|
#include "gfxMatrix.h"
|
||||||
#include "nsSVGLengthList.h"
|
#include "nsSVGLengthList.h"
|
||||||
#include "nsIDOMSVGURIReference.h"
|
#include "nsIDOMSVGURIReference.h"
|
||||||
#include "nsImageLoadingContent.h"
|
#include "nsImageLoadingContent.h"
|
||||||
|
@ -64,7 +65,6 @@
|
||||||
#include "nsNetUtil.h"
|
#include "nsNetUtil.h"
|
||||||
#include "nsSVGPreserveAspectRatio.h"
|
#include "nsSVGPreserveAspectRatio.h"
|
||||||
#include "nsIInterfaceRequestorUtils.h"
|
#include "nsIInterfaceRequestorUtils.h"
|
||||||
#include "nsSVGMatrix.h"
|
|
||||||
#include "nsSVGFilterElement.h"
|
#include "nsSVGFilterElement.h"
|
||||||
#include "nsSVGString.h"
|
#include "nsSVGString.h"
|
||||||
|
|
||||||
|
@ -5392,17 +5392,19 @@ nsSVGFEImageElement::Filter(nsSVGFilterInstance *instance,
|
||||||
imageContainer->GetWidth(&nativeWidth);
|
imageContainer->GetWidth(&nativeWidth);
|
||||||
imageContainer->GetHeight(&nativeHeight);
|
imageContainer->GetHeight(&nativeHeight);
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> trans;
|
|
||||||
const gfxRect& filterSubregion = aTarget->mFilterPrimitiveSubregion;
|
const gfxRect& filterSubregion = aTarget->mFilterPrimitiveSubregion;
|
||||||
trans = nsSVGUtils::GetViewBoxTransform(filterSubregion.Width(), filterSubregion.Height(),
|
|
||||||
0, 0, nativeWidth, nativeHeight,
|
gfxMatrix viewBoxTM =
|
||||||
mPreserveAspectRatio);
|
nsSVGUtils::GetViewBoxTransform(filterSubregion.Width(), filterSubregion.Height(),
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> xy, fini;
|
0,0, nativeWidth, nativeHeight,
|
||||||
NS_NewSVGMatrix(getter_AddRefs(xy), 1, 0, 0, 1, filterSubregion.X(), filterSubregion.Y());
|
mPreserveAspectRatio);
|
||||||
xy->Multiply(trans, getter_AddRefs(fini));
|
|
||||||
|
gfxMatrix xyTM = gfxMatrix().Translate(gfxPoint(filterSubregion.X(), filterSubregion.Y()));
|
||||||
|
|
||||||
|
gfxMatrix TM = viewBoxTM * xyTM;
|
||||||
|
|
||||||
gfxContext ctx(aTarget->mImage);
|
gfxContext ctx(aTarget->mImage);
|
||||||
nsSVGUtils::CompositePatternMatrix(&ctx, thebesPattern, fini, nativeWidth, nativeHeight, 1.0);
|
nsSVGUtils::CompositePatternMatrix(&ctx, thebesPattern, TM, nativeWidth, nativeHeight, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
|
@ -117,25 +117,6 @@ nsSVGForeignObjectElement::PrependLocalTransformTo(const gfxMatrix &aMatrix)
|
||||||
return gfxMatrix().Translate(gfxPoint(x, y)) * matrix;
|
return gfxMatrix().Translate(gfxPoint(x, y)) * matrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsSVGForeignObjectElement::AppendTransform(nsIDOMSVGMatrix *aCTM,
|
|
||||||
nsIDOMSVGMatrix **_retval)
|
|
||||||
{
|
|
||||||
nsresult rv;
|
|
||||||
// foreignObject is one of establishing-viewport elements.
|
|
||||||
// so we are translated by foreignObject's x and y attribs.
|
|
||||||
float x, y;
|
|
||||||
GetAnimatedLengthValues(&x, &y, nsnull);
|
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> translate;
|
|
||||||
rv = NS_NewSVGMatrix(getter_AddRefs(translate), 1, 0, 0, 1, x, y);
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> tmp;
|
|
||||||
rv = aCTM->Multiply(translate, getter_AddRefs(tmp));
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
|
|
||||||
return nsSVGGraphicElement::AppendTransform(tmp, _retval);
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// nsIContent methods
|
// nsIContent methods
|
||||||
|
|
||||||
|
|
|
@ -74,9 +74,6 @@ public:
|
||||||
|
|
||||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||||
|
|
||||||
// public helpers
|
|
||||||
nsresult AppendTransform(nsIDOMSVGMatrix *aCTM,
|
|
||||||
nsIDOMSVGMatrix **_retval);
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual LengthAttributesInfo GetLengthInfo();
|
virtual LengthAttributesInfo GetLengthInfo();
|
||||||
|
|
|
@ -75,14 +75,15 @@ nsSVGGraphicElement::nsSVGGraphicElement(nsINodeInfo *aNodeInfo)
|
||||||
/* readonly attribute nsIDOMSVGElement nearestViewportElement; */
|
/* readonly attribute nsIDOMSVGElement nearestViewportElement; */
|
||||||
NS_IMETHODIMP nsSVGGraphicElement::GetNearestViewportElement(nsIDOMSVGElement * *aNearestViewportElement)
|
NS_IMETHODIMP nsSVGGraphicElement::GetNearestViewportElement(nsIDOMSVGElement * *aNearestViewportElement)
|
||||||
{
|
{
|
||||||
nsSVGUtils::GetNearestViewportElement(this, aNearestViewportElement);
|
*aNearestViewportElement = nsSVGUtils::GetNearestViewportElement(this).get();
|
||||||
return NS_OK; // we can't throw exceptions from this API.
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* readonly attribute nsIDOMSVGElement farthestViewportElement; */
|
/* readonly attribute nsIDOMSVGElement farthestViewportElement; */
|
||||||
NS_IMETHODIMP nsSVGGraphicElement::GetFarthestViewportElement(nsIDOMSVGElement * *aFarthestViewportElement)
|
NS_IMETHODIMP nsSVGGraphicElement::GetFarthestViewportElement(nsIDOMSVGElement * *aFarthestViewportElement)
|
||||||
{
|
{
|
||||||
return nsSVGUtils::GetFarthestViewportElement(this, aFarthestViewportElement);
|
*aFarthestViewportElement = nsSVGUtils::GetFarthestViewportElement(this).get();
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* nsIDOMSVGRect getBBox (); */
|
/* nsIDOMSVGRect getBBox (); */
|
||||||
|
@ -102,41 +103,20 @@ NS_IMETHODIMP nsSVGGraphicElement::GetBBox(nsIDOMSVGRect **_retval)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Helper for GetCTM and GetScreenCTM */
|
|
||||||
nsresult
|
|
||||||
nsSVGGraphicElement::AppendTransform(nsIDOMSVGMatrix *aCTM,
|
|
||||||
nsIDOMSVGMatrix **_retval)
|
|
||||||
{
|
|
||||||
if (!mTransforms) {
|
|
||||||
*_retval = aCTM;
|
|
||||||
NS_ADDREF(*_retval);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
// append our local transformations
|
|
||||||
nsCOMPtr<nsIDOMSVGTransformList> transforms;
|
|
||||||
mTransforms->GetAnimVal(getter_AddRefs(transforms));
|
|
||||||
NS_ENSURE_TRUE(transforms, NS_ERROR_FAILURE);
|
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> matrix =
|
|
||||||
nsSVGTransformList::GetConsolidationMatrix(transforms);
|
|
||||||
if (!matrix) {
|
|
||||||
*_retval = aCTM;
|
|
||||||
NS_ADDREF(*_retval);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
return aCTM->Multiply(matrix, _retval); // addrefs, so we don't
|
|
||||||
}
|
|
||||||
|
|
||||||
/* nsIDOMSVGMatrix getCTM (); */
|
/* nsIDOMSVGMatrix getCTM (); */
|
||||||
NS_IMETHODIMP nsSVGGraphicElement::GetCTM(nsIDOMSVGMatrix * *aCTM)
|
NS_IMETHODIMP nsSVGGraphicElement::GetCTM(nsIDOMSVGMatrix * *aCTM)
|
||||||
{
|
{
|
||||||
return nsSVGUtils::GetCTM(this, aCTM);
|
gfxMatrix m = nsSVGUtils::GetCTM(this, PR_FALSE);
|
||||||
|
*aCTM = m.IsSingular() ? nsnull : NS_NewSVGMatrix(m).get();
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* nsIDOMSVGMatrix getScreenCTM (); */
|
/* nsIDOMSVGMatrix getScreenCTM (); */
|
||||||
NS_IMETHODIMP nsSVGGraphicElement::GetScreenCTM(nsIDOMSVGMatrix * *aCTM)
|
NS_IMETHODIMP nsSVGGraphicElement::GetScreenCTM(nsIDOMSVGMatrix * *aCTM)
|
||||||
{
|
{
|
||||||
return nsSVGUtils::GetScreenCTM(this, aCTM);
|
gfxMatrix m = nsSVGUtils::GetCTM(this, PR_TRUE);
|
||||||
|
*aCTM = m.IsSingular() ? nsnull : NS_NewSVGMatrix(m).get();
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* nsIDOMSVGMatrix getTransformToElement (in nsIDOMSVGElement element); */
|
/* nsIDOMSVGMatrix getTransformToElement (in nsIDOMSVGElement element); */
|
||||||
|
|
|
@ -64,9 +64,6 @@ public:
|
||||||
|
|
||||||
virtual gfxMatrix PrependLocalTransformTo(const gfxMatrix &aMatrix);
|
virtual gfxMatrix PrependLocalTransformTo(const gfxMatrix &aMatrix);
|
||||||
|
|
||||||
// public helpers
|
|
||||||
virtual nsresult AppendTransform(nsIDOMSVGMatrix *aCTM,
|
|
||||||
nsIDOMSVGMatrix **_retval);
|
|
||||||
protected:
|
protected:
|
||||||
// nsSVGElement overrides
|
// nsSVGElement overrides
|
||||||
virtual PRBool IsEventName(nsIAtom* aName);
|
virtual PRBool IsEventName(nsIAtom* aName);
|
||||||
|
|
|
@ -38,7 +38,6 @@
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
#include "nsSVGLength.h"
|
#include "nsSVGLength.h"
|
||||||
#include "nsIDOMSVGMatrix.h"
|
|
||||||
#include "nsGkAtoms.h"
|
#include "nsGkAtoms.h"
|
||||||
#include "nsSVGValue.h"
|
#include "nsSVGValue.h"
|
||||||
#include "nsTextFormatter.h"
|
#include "nsTextFormatter.h"
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include "nsDOMError.h"
|
#include "nsDOMError.h"
|
||||||
#include "nsSVGUtils.h"
|
#include "nsSVGUtils.h"
|
||||||
#include "nsSVGMarkerElement.h"
|
#include "nsSVGMarkerElement.h"
|
||||||
|
#include "gfxMatrix.h"
|
||||||
|
|
||||||
nsSVGElement::LengthInfo nsSVGMarkerElement::sLengthInfo[4] =
|
nsSVGElement::LengthInfo nsSVGMarkerElement::sLengthInfo[4] =
|
||||||
{
|
{
|
||||||
|
@ -376,10 +377,9 @@ nsSVGMarkerElement::GetPreserveAspectRatio()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// public helpers
|
// public helpers
|
||||||
|
|
||||||
nsresult
|
gfxMatrix
|
||||||
nsSVGMarkerElement::GetMarkerTransform(float aStrokeWidth,
|
nsSVGMarkerElement::GetMarkerTransform(float aStrokeWidth,
|
||||||
float aX, float aY, float aAngle,
|
float aX, float aY, float aAngle)
|
||||||
nsIDOMSVGMatrix **_retval)
|
|
||||||
{
|
{
|
||||||
float scale = 1.0;
|
float scale = 1.0;
|
||||||
if (mEnumAttributes[MARKERUNITS].GetAnimValue() ==
|
if (mEnumAttributes[MARKERUNITS].GetAnimValue() ==
|
||||||
|
@ -390,22 +390,14 @@ nsSVGMarkerElement::GetMarkerTransform(float aStrokeWidth,
|
||||||
aAngle = mAngleAttributes[ORIENT].GetAnimValue();
|
aAngle = mAngleAttributes[ORIENT].GetAnimValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> matrix;
|
return gfxMatrix(cos(aAngle) * scale, sin(aAngle) * scale,
|
||||||
NS_NewSVGMatrix(getter_AddRefs(matrix),
|
-sin(aAngle) * scale, cos(aAngle) * scale,
|
||||||
cos(aAngle) * scale, sin(aAngle) * scale,
|
aX, aY);
|
||||||
-sin(aAngle) * scale, cos(aAngle) * scale,
|
|
||||||
aX, aY);
|
|
||||||
|
|
||||||
*_retval = matrix;
|
|
||||||
NS_IF_ADDREF(*_retval);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
gfxMatrix
|
||||||
nsSVGMarkerElement::GetViewboxToViewportTransform(nsIDOMSVGMatrix **_retval)
|
nsSVGMarkerElement::GetViewBoxTransform()
|
||||||
{
|
{
|
||||||
*_retval = nsnull;
|
|
||||||
|
|
||||||
if (!mViewBoxToViewportTransform) {
|
if (!mViewBoxToViewportTransform) {
|
||||||
float viewportWidth =
|
float viewportWidth =
|
||||||
mLengthAttributes[MARKERWIDTH].GetAnimValue(mCoordCtx);
|
mLengthAttributes[MARKERWIDTH].GetAnimValue(mCoordCtx);
|
||||||
|
@ -415,32 +407,27 @@ nsSVGMarkerElement::GetViewboxToViewportTransform(nsIDOMSVGMatrix **_retval)
|
||||||
const nsSVGViewBoxRect& viewbox = mViewBox.GetAnimValue();
|
const nsSVGViewBoxRect& viewbox = mViewBox.GetAnimValue();
|
||||||
|
|
||||||
if (viewbox.width <= 0.0f || viewbox.height <= 0.0f) {
|
if (viewbox.width <= 0.0f || viewbox.height <= 0.0f) {
|
||||||
return NS_ERROR_FAILURE; // invalid - don't paint element
|
return gfxMatrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // invalid - don't paint element
|
||||||
}
|
}
|
||||||
|
|
||||||
float refX = mLengthAttributes[REFX].GetAnimValue(mCoordCtx);
|
float refX = mLengthAttributes[REFX].GetAnimValue(mCoordCtx);
|
||||||
float refY = mLengthAttributes[REFY].GetAnimValue(mCoordCtx);
|
float refY = mLengthAttributes[REFY].GetAnimValue(mCoordCtx);
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> vb2vp =
|
gfxMatrix viewBoxTM =
|
||||||
nsSVGUtils::GetViewBoxTransform(viewportWidth, viewportHeight,
|
nsSVGUtils::GetViewBoxTransform(viewportWidth, viewportHeight,
|
||||||
viewbox.x, viewbox.y,
|
viewbox.x, viewbox.y,
|
||||||
viewbox.width, viewbox.height,
|
viewbox.width, viewbox.height,
|
||||||
mPreserveAspectRatio,
|
mPreserveAspectRatio,
|
||||||
PR_TRUE);
|
PR_TRUE);
|
||||||
NS_ENSURE_TRUE(vb2vp, NS_ERROR_OUT_OF_MEMORY);
|
|
||||||
gfxPoint ref = nsSVGUtils::ConvertSVGMatrixToThebes(vb2vp).
|
|
||||||
Transform(gfxPoint(refX, refY));
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> translate;
|
gfxPoint ref = viewBoxTM.Transform(gfxPoint(refX, refY));
|
||||||
NS_NewSVGMatrix(getter_AddRefs(translate),
|
|
||||||
1.0f, 0.0f, 0.0f, 1.0f, -ref.x, -ref.y);
|
gfxMatrix TM = viewBoxTM * gfxMatrix().Translate(gfxPoint(-ref.x, -ref.y));
|
||||||
NS_ENSURE_TRUE(translate, NS_ERROR_OUT_OF_MEMORY);
|
|
||||||
translate->Multiply(vb2vp, getter_AddRefs(mViewBoxToViewportTransform));
|
mViewBoxToViewportTransform = NS_NewSVGMatrix(TM);
|
||||||
}
|
}
|
||||||
|
|
||||||
*_retval = mViewBoxToViewportTransform;
|
return nsSVGUtils::ConvertSVGMatrixToThebes(mViewBoxToViewportTransform);
|
||||||
NS_IF_ADDREF(*_retval);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -131,10 +131,9 @@ public:
|
||||||
virtual void DidChangePreserveAspectRatio(PRBool aDoSetAttr);
|
virtual void DidChangePreserveAspectRatio(PRBool aDoSetAttr);
|
||||||
|
|
||||||
// public helpers
|
// public helpers
|
||||||
nsresult GetMarkerTransform(float aStrokeWidth,
|
gfxMatrix GetMarkerTransform(float aStrokeWidth,
|
||||||
float aX, float aY, float aAngle,
|
float aX, float aY, float aAngle);
|
||||||
nsIDOMSVGMatrix **_retval);
|
gfxMatrix GetViewBoxTransform();
|
||||||
nsresult GetViewboxToViewportTransform(nsIDOMSVGMatrix **_retval);
|
|
||||||
|
|
||||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ nsSVGPathElement::GetTotalLength(float *_retval)
|
||||||
{
|
{
|
||||||
*_retval = 0;
|
*_retval = 0;
|
||||||
|
|
||||||
nsRefPtr<gfxFlattenedPath> flat = GetFlattenedPath(nsnull);
|
nsRefPtr<gfxFlattenedPath> flat = GetFlattenedPath(gfxMatrix());
|
||||||
|
|
||||||
if (!flat)
|
if (!flat)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
@ -118,7 +118,7 @@ nsSVGPathElement::GetPointAtLength(float distance, nsIDOMSVGPoint **_retval)
|
||||||
{
|
{
|
||||||
NS_ENSURE_FINITE(distance, NS_ERROR_ILLEGAL_VALUE);
|
NS_ENSURE_FINITE(distance, NS_ERROR_ILLEGAL_VALUE);
|
||||||
|
|
||||||
nsRefPtr<gfxFlattenedPath> flat = GetFlattenedPath(nsnull);
|
nsRefPtr<gfxFlattenedPath> flat = GetFlattenedPath(gfxMatrix());
|
||||||
if (!flat)
|
if (!flat)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
@ -494,16 +494,12 @@ nsSVGPathElement::DidModifySVGObservable(nsISVGValue* observable,
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<gfxFlattenedPath>
|
already_AddRefed<gfxFlattenedPath>
|
||||||
nsSVGPathElement::GetFlattenedPath(nsIDOMSVGMatrix *aMatrix)
|
nsSVGPathElement::GetFlattenedPath(const gfxMatrix &aMatrix)
|
||||||
{
|
{
|
||||||
gfxContext ctx(nsSVGUtils::GetThebesComputationalSurface());
|
gfxContext ctx(nsSVGUtils::GetThebesComputationalSurface());
|
||||||
|
|
||||||
if (aMatrix) {
|
ctx.SetMatrix(aMatrix);
|
||||||
ctx.SetMatrix(nsSVGUtils::ConvertSVGMatrixToThebes(aMatrix));
|
|
||||||
}
|
|
||||||
|
|
||||||
mPathData.Playback(&ctx);
|
mPathData.Playback(&ctx);
|
||||||
|
|
||||||
ctx.IdentityMatrix();
|
ctx.IdentityMatrix();
|
||||||
|
|
||||||
return ctx.GetFlattenedPath();
|
return ctx.GetFlattenedPath();
|
||||||
|
|
|
@ -104,7 +104,7 @@ public:
|
||||||
virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks);
|
virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks);
|
||||||
virtual void ConstructPath(gfxContext *aCtx);
|
virtual void ConstructPath(gfxContext *aCtx);
|
||||||
|
|
||||||
virtual already_AddRefed<gfxFlattenedPath> GetFlattenedPath(nsIDOMSVGMatrix *aMatrix);
|
virtual already_AddRefed<gfxFlattenedPath> GetFlattenedPath(const gfxMatrix &aMatrix);
|
||||||
|
|
||||||
// nsIContent interface
|
// nsIContent interface
|
||||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||||
|
|
|
@ -67,7 +67,7 @@ nsSVGPathGeometryElement::GetMarkPoints(nsTArray<nsSVGMark> *aMarks)
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<gfxFlattenedPath>
|
already_AddRefed<gfxFlattenedPath>
|
||||||
nsSVGPathGeometryElement::GetFlattenedPath(nsIDOMSVGMatrix *aMatrix)
|
nsSVGPathGeometryElement::GetFlattenedPath(const gfxMatrix &aMatrix)
|
||||||
{
|
{
|
||||||
return nsnull;
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include "nsSVGGraphicElement.h"
|
#include "nsSVGGraphicElement.h"
|
||||||
#include "nsTArray.h"
|
#include "nsTArray.h"
|
||||||
#include "gfxPath.h"
|
#include "gfxPath.h"
|
||||||
|
#include "gfxMatrix.h"
|
||||||
|
|
||||||
struct nsSVGMark {
|
struct nsSVGMark {
|
||||||
float x, y, angle;
|
float x, y, angle;
|
||||||
|
@ -47,7 +48,6 @@ struct nsSVGMark {
|
||||||
x(aX), y(aY), angle(aAngle) {}
|
x(aX), y(aY), angle(aAngle) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class nsIDOMSVGMatrix;
|
|
||||||
class gfxContext;
|
class gfxContext;
|
||||||
|
|
||||||
typedef nsSVGGraphicElement nsSVGPathGeometryElementBase;
|
typedef nsSVGGraphicElement nsSVGPathGeometryElementBase;
|
||||||
|
@ -61,7 +61,7 @@ public:
|
||||||
virtual PRBool IsMarkable();
|
virtual PRBool IsMarkable();
|
||||||
virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks);
|
virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks);
|
||||||
virtual void ConstructPath(gfxContext *aCtx) = 0;
|
virtual void ConstructPath(gfxContext *aCtx) = 0;
|
||||||
virtual already_AddRefed<gfxFlattenedPath> GetFlattenedPath(nsIDOMSVGMatrix *aMatrix);
|
virtual already_AddRefed<gfxFlattenedPath> GetFlattenedPath(const gfxMatrix &aMatrix);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -40,7 +40,6 @@
|
||||||
#include "nsSVGAnimatedTransformList.h"
|
#include "nsSVGAnimatedTransformList.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsGkAtoms.h"
|
#include "nsGkAtoms.h"
|
||||||
#include "nsSVGMatrix.h"
|
|
||||||
#include "nsSVGPatternElement.h"
|
#include "nsSVGPatternElement.h"
|
||||||
#include "nsIFrame.h"
|
#include "nsIFrame.h"
|
||||||
|
|
||||||
|
|
|
@ -746,15 +746,16 @@ nsSVGSVGElement::GetPreserveAspectRatio(nsIDOMSVGAnimatedPreserveAspectRatio
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsSVGSVGElement::GetNearestViewportElement(nsIDOMSVGElement * *aNearestViewportElement)
|
nsSVGSVGElement::GetNearestViewportElement(nsIDOMSVGElement * *aNearestViewportElement)
|
||||||
{
|
{
|
||||||
nsSVGUtils::GetNearestViewportElement(this, aNearestViewportElement);
|
*aNearestViewportElement = nsSVGUtils::GetNearestViewportElement(this).get();
|
||||||
return NS_OK; // we can't throw exceptions from this API.
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* readonly attribute nsIDOMSVGElement farthestViewportElement; */
|
/* readonly attribute nsIDOMSVGElement farthestViewportElement; */
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsSVGSVGElement::GetFarthestViewportElement(nsIDOMSVGElement * *aFarthestViewportElement)
|
nsSVGSVGElement::GetFarthestViewportElement(nsIDOMSVGElement * *aFarthestViewportElement)
|
||||||
{
|
{
|
||||||
return nsSVGUtils::GetFarthestViewportElement(this, aFarthestViewportElement);
|
*aFarthestViewportElement = nsSVGUtils::GetFarthestViewportElement(this).get();
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* nsIDOMSVGRect getBBox (); */
|
/* nsIDOMSVGRect getBBox (); */
|
||||||
|
@ -775,68 +776,22 @@ nsSVGSVGElement::GetBBox(nsIDOMSVGRect **_retval)
|
||||||
return NS_ERROR_NOT_IMPLEMENTED; // XXX: outer svg
|
return NS_ERROR_NOT_IMPLEMENTED; // XXX: outer svg
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsSVGSVGElement::AppendTransform(nsIDOMSVGMatrix *aCTM,
|
|
||||||
nsIDOMSVGMatrix **_retval)
|
|
||||||
{
|
|
||||||
nsresult rv;
|
|
||||||
|
|
||||||
// first check what are our parents and calculate offsets accordingly.
|
|
||||||
|
|
||||||
float s=1, x=0, y=0;
|
|
||||||
nsIContent *ancestor = nsSVGUtils::GetParentElement(this);
|
|
||||||
if (ancestor && ancestor->GetNameSpaceID() == kNameSpaceID_SVG &&
|
|
||||||
ancestor->Tag() == nsGkAtoms::foreignObject) {
|
|
||||||
// this is a nested <svg> element. immediate parent is an <foreignObject> element.
|
|
||||||
// we ignore this <svg> element's x and y attribs in layout so do the same.
|
|
||||||
} else {
|
|
||||||
nsCOMPtr<nsIDOMSVGElement> nearestViewportElement;
|
|
||||||
rv = nsSVGUtils::GetNearestViewportElement(this, getter_AddRefs(nearestViewportElement));
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
|
|
||||||
if (!nearestViewportElement) {
|
|
||||||
if (IsRoot()) {
|
|
||||||
// we're the root element. get our currentScale and currentTranslate vals
|
|
||||||
s = mCurrentScale;
|
|
||||||
x = mCurrentTranslate.GetX();
|
|
||||||
y = mCurrentTranslate.GetY();
|
|
||||||
} else {
|
|
||||||
// we're inline in some non-SVG content. get our offset from the root
|
|
||||||
GetOffsetToAncestor(nsnull, x, y);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// this is a nested <svg> element.
|
|
||||||
GetAnimatedLengthValues(&x, &y, nsnull);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> local;
|
|
||||||
rv = NS_NewSVGMatrix(getter_AddRefs(local), s, 0, 0, s, x, y);
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
|
|
||||||
// finally append our viewbox transform
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> viewbox;
|
|
||||||
rv = GetViewboxToViewportTransform(getter_AddRefs(viewbox));
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> tmp;
|
|
||||||
rv = local->Multiply(viewbox, getter_AddRefs(tmp)); // addrefs, so we don't
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
return aCTM->Multiply(tmp, _retval); // addrefs, so we don't
|
|
||||||
}
|
|
||||||
|
|
||||||
/* nsIDOMSVGMatrix getCTM (); */
|
/* nsIDOMSVGMatrix getCTM (); */
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsSVGSVGElement::GetCTM(nsIDOMSVGMatrix * *aCTM)
|
nsSVGSVGElement::GetCTM(nsIDOMSVGMatrix * *aCTM)
|
||||||
{
|
{
|
||||||
return nsSVGUtils::GetCTM(this, aCTM);
|
gfxMatrix m = nsSVGUtils::GetCTM(this, PR_FALSE);
|
||||||
|
*aCTM = m.IsSingular() ? nsnull : NS_NewSVGMatrix(m).get();
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* nsIDOMSVGMatrix getScreenCTM (); */
|
/* nsIDOMSVGMatrix getScreenCTM (); */
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsSVGSVGElement::GetScreenCTM(nsIDOMSVGMatrix **aCTM)
|
nsSVGSVGElement::GetScreenCTM(nsIDOMSVGMatrix **aCTM)
|
||||||
{
|
{
|
||||||
return nsSVGUtils::GetScreenCTM(this, aCTM);
|
gfxMatrix m = nsSVGUtils::GetCTM(this, PR_TRUE);
|
||||||
|
*aCTM = m.IsSingular() ? nsnull : NS_NewSVGMatrix(m).get();
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* nsIDOMSVGMatrix getTransformToElement (in nsIDOMSVGElement element); */
|
/* nsIDOMSVGMatrix getTransformToElement (in nsIDOMSVGElement element); */
|
||||||
|
@ -1027,43 +982,36 @@ nsSVGSVGElement::IsEventName(nsIAtom* aName)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// public helpers:
|
// public helpers:
|
||||||
|
|
||||||
nsresult
|
gfxMatrix
|
||||||
nsSVGSVGElement::GetViewboxToViewportTransform(nsIDOMSVGMatrix **_retval)
|
nsSVGSVGElement::GetViewBoxTransform()
|
||||||
{
|
{
|
||||||
*_retval = nsnull;
|
|
||||||
|
|
||||||
float viewportWidth, viewportHeight;
|
float viewportWidth, viewportHeight;
|
||||||
nsSVGSVGElement *ctx = GetCtx();
|
if (nsSVGUtils::IsInnerSVG(this)) {
|
||||||
if (!ctx) {
|
nsSVGSVGElement *ctx = GetCtx();
|
||||||
// outer svg
|
|
||||||
viewportWidth = mViewportWidth;
|
|
||||||
viewportHeight = mViewportHeight;
|
|
||||||
} else {
|
|
||||||
viewportWidth = mLengthAttributes[WIDTH].GetAnimValue(ctx);
|
viewportWidth = mLengthAttributes[WIDTH].GetAnimValue(ctx);
|
||||||
viewportHeight = mLengthAttributes[HEIGHT].GetAnimValue(ctx);
|
viewportHeight = mLengthAttributes[HEIGHT].GetAnimValue(ctx);
|
||||||
}
|
|
||||||
|
|
||||||
nsSVGViewBoxRect viewbox;
|
|
||||||
if (mViewBox.IsValid()) {
|
|
||||||
viewbox = mViewBox.GetAnimValue();
|
|
||||||
} else {
|
} else {
|
||||||
viewbox.x = viewbox.y = 0.0f;
|
viewportWidth = mViewportWidth;
|
||||||
viewbox.width = viewportWidth;
|
viewportHeight = mViewportHeight;
|
||||||
viewbox.height = viewportHeight;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (viewbox.width <= 0.0f || viewbox.height <= 0.0f) {
|
nsSVGViewBoxRect viewBox;
|
||||||
return NS_ERROR_FAILURE; // invalid - don't paint element
|
if (mViewBox.IsValid()) {
|
||||||
|
viewBox = mViewBox.GetAnimValue();
|
||||||
|
} else {
|
||||||
|
viewBox.x = viewBox.y = 0.0f;
|
||||||
|
viewBox.width = viewportWidth;
|
||||||
|
viewBox.height = viewportHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> xform =
|
if (viewBox.width <= 0.0f || viewBox.height <= 0.0f) {
|
||||||
nsSVGUtils::GetViewBoxTransform(viewportWidth, viewportHeight,
|
return gfxMatrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
|
||||||
viewbox.x, viewbox.y,
|
}
|
||||||
viewbox.width, viewbox.height,
|
|
||||||
mPreserveAspectRatio);
|
|
||||||
xform.swap(*_retval);
|
|
||||||
|
|
||||||
return NS_OK;
|
return nsSVGUtils::GetViewBoxTransform(viewportWidth, viewportHeight,
|
||||||
|
viewBox.x, viewBox.y,
|
||||||
|
viewBox.width, viewBox.height,
|
||||||
|
mPreserveAspectRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MOZ_SMIL
|
#ifdef MOZ_SMIL
|
||||||
|
@ -1124,43 +1072,6 @@ nsSVGSVGElement::UnbindFromTree(PRBool aDeep, PRBool aNullParent)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// implementation helpers
|
// implementation helpers
|
||||||
|
|
||||||
// if an ancestor isn't specified, obtains offset from root frame
|
|
||||||
void nsSVGSVGElement::GetOffsetToAncestor(nsIContent* ancestor,
|
|
||||||
float &x, float &y)
|
|
||||||
{
|
|
||||||
x = 0.0f;
|
|
||||||
y = 0.0f;
|
|
||||||
|
|
||||||
nsIDocument *document = GetCurrentDoc();
|
|
||||||
if (!document) return;
|
|
||||||
|
|
||||||
// Flush all pending notifications so that our frames are uptodate
|
|
||||||
// Make sure to do this before we start grabbing layout objects like
|
|
||||||
// presshells.
|
|
||||||
document->FlushPendingNotifications(Flush_Layout);
|
|
||||||
|
|
||||||
nsIPresShell *presShell = document->GetPrimaryShell();
|
|
||||||
if (!presShell) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsPresContext *context = presShell->GetPresContext();
|
|
||||||
if (!context) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsIFrame* frame = presShell->GetPrimaryFrameFor(this);
|
|
||||||
nsIFrame* ancestorFrame = ancestor ?
|
|
||||||
presShell->GetPrimaryFrameFor(ancestor) :
|
|
||||||
presShell->GetRootFrame();
|
|
||||||
|
|
||||||
if (frame && ancestorFrame) {
|
|
||||||
nsPoint point = frame->GetOffsetTo(ancestorFrame);
|
|
||||||
x = nsPresContext::AppUnitsToFloatCSSPixels(point.x);
|
|
||||||
y = nsPresContext::AppUnitsToFloatCSSPixels(point.y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef MOZ_SMIL
|
#ifdef MOZ_SMIL
|
||||||
PRBool
|
PRBool
|
||||||
nsSVGSVGElement::WillBeOutermostSVG(nsIContent* aParent,
|
nsSVGSVGElement::WillBeOutermostSVG(nsIContent* aParent,
|
||||||
|
@ -1261,19 +1172,21 @@ nsSVGSVGElement::GetMMPerPx(PRUint8 aCtxType)
|
||||||
/* virtual */ gfxMatrix
|
/* virtual */ gfxMatrix
|
||||||
nsSVGSVGElement::PrependLocalTransformTo(const gfxMatrix &aMatrix)
|
nsSVGSVGElement::PrependLocalTransformTo(const gfxMatrix &aMatrix)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(GetCtx(), "Should not be called on outer-<svg>");
|
if (nsSVGUtils::IsInnerSVG(this)) {
|
||||||
|
float x, y;
|
||||||
float x, y;
|
GetAnimatedLengthValues(&x, &y, nsnull);
|
||||||
GetAnimatedLengthValues(&x, &y, nsnull);
|
return GetViewBoxTransform() * gfxMatrix().Translate(gfxPoint(x, y)) * aMatrix;
|
||||||
gfxMatrix matrix = aMatrix;
|
|
||||||
matrix.PreMultiply(gfxMatrix().Translate(gfxPoint(x, y)));
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> viewBoxTM;
|
|
||||||
nsresult res = GetViewboxToViewportTransform(getter_AddRefs(viewBoxTM));
|
|
||||||
if (NS_FAILED(res)) {
|
|
||||||
return gfxMatrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
|
|
||||||
}
|
}
|
||||||
return matrix.PreMultiply(nsSVGUtils::ConvertSVGMatrixToThebes(viewBoxTM));
|
|
||||||
|
if (IsRoot()) {
|
||||||
|
gfxMatrix zoomPanTM;
|
||||||
|
zoomPanTM.Translate(gfxPoint(mCurrentTranslate.GetX(), mCurrentTranslate.GetY()));
|
||||||
|
zoomPanTM.Scale(mCurrentScale, mCurrentScale);
|
||||||
|
return GetViewBoxTransform() * zoomPanTM * aMatrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
// outer-<svg>, but inline in some other content:
|
||||||
|
return GetViewBoxTransform() * aMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -199,9 +199,7 @@ public:
|
||||||
float GetMMPerPx(PRUint8 mCtxType = 0);
|
float GetMMPerPx(PRUint8 mCtxType = 0);
|
||||||
|
|
||||||
// public helpers:
|
// public helpers:
|
||||||
nsresult GetViewboxToViewportTransform(nsIDOMSVGMatrix **_retval);
|
gfxMatrix GetViewBoxTransform();
|
||||||
nsresult AppendTransform(nsIDOMSVGMatrix *aCTM,
|
|
||||||
nsIDOMSVGMatrix **_retval);
|
|
||||||
|
|
||||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||||
|
|
||||||
|
@ -226,7 +224,6 @@ protected:
|
||||||
#endif // MOZ_SMIL
|
#endif // MOZ_SMIL
|
||||||
|
|
||||||
// implementation helpers:
|
// implementation helpers:
|
||||||
void GetOffsetToAncestor(nsIContent* ancestor, float &x, float &y);
|
|
||||||
|
|
||||||
PRBool IsRoot() {
|
PRBool IsRoot() {
|
||||||
NS_ASSERTION((IsInDoc() && !GetParent()) ==
|
NS_ASSERTION((IsInDoc() && !GetParent()) ==
|
||||||
|
|
|
@ -48,7 +48,6 @@
|
||||||
|
|
||||||
class gfxContext;
|
class gfxContext;
|
||||||
class nsPresContext;
|
class nsPresContext;
|
||||||
class nsIDOMSVGMatrix;
|
|
||||||
class nsSVGRenderState;
|
class nsSVGRenderState;
|
||||||
|
|
||||||
class nsISVGChildFrame : public nsQueryFrame
|
class nsISVGChildFrame : public nsQueryFrame
|
||||||
|
|
|
@ -56,7 +56,7 @@ NS_NewSVGClipPathFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
||||||
nsresult
|
nsresult
|
||||||
nsSVGClipPathFrame::ClipPaint(nsSVGRenderState* aContext,
|
nsSVGClipPathFrame::ClipPaint(nsSVGRenderState* aContext,
|
||||||
nsIFrame* aParent,
|
nsIFrame* aParent,
|
||||||
nsIDOMSVGMatrix *aMatrix)
|
const gfxMatrix &aMatrix)
|
||||||
{
|
{
|
||||||
// If the flag is set when we get here, it means this clipPath frame
|
// If the flag is set when we get here, it means this clipPath frame
|
||||||
// has already been used painting the current clip, and the document
|
// has already been used painting the current clip, and the document
|
||||||
|
@ -68,7 +68,7 @@ nsSVGClipPathFrame::ClipPaint(nsSVGRenderState* aContext,
|
||||||
AutoClipPathReferencer clipRef(this);
|
AutoClipPathReferencer clipRef(this);
|
||||||
|
|
||||||
mClipParent = aParent,
|
mClipParent = aParent,
|
||||||
mClipParentMatrix = aMatrix;
|
mClipParentMatrix = NS_NewSVGMatrix(aMatrix);
|
||||||
|
|
||||||
PRBool isTrivial = IsTrivial();
|
PRBool isTrivial = IsTrivial();
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ nsSVGClipPathFrame::ClipPaint(nsSVGRenderState* aContext,
|
||||||
|
|
||||||
PRBool
|
PRBool
|
||||||
nsSVGClipPathFrame::ClipHitTest(nsIFrame* aParent,
|
nsSVGClipPathFrame::ClipHitTest(nsIFrame* aParent,
|
||||||
nsIDOMSVGMatrix *aMatrix,
|
const gfxMatrix &aMatrix,
|
||||||
const nsPoint &aPoint)
|
const nsPoint &aPoint)
|
||||||
{
|
{
|
||||||
// If the flag is set when we get here, it means this clipPath frame
|
// If the flag is set when we get here, it means this clipPath frame
|
||||||
|
@ -110,7 +110,7 @@ nsSVGClipPathFrame::ClipHitTest(nsIFrame* aParent,
|
||||||
AutoClipPathReferencer clipRef(this);
|
AutoClipPathReferencer clipRef(this);
|
||||||
|
|
||||||
mClipParent = aParent,
|
mClipParent = aParent,
|
||||||
mClipParentMatrix = aMatrix;
|
mClipParentMatrix = NS_NewSVGMatrix(aMatrix);
|
||||||
|
|
||||||
for (nsIFrame* kid = mFrames.FirstChild(); kid;
|
for (nsIFrame* kid = mFrames.FirstChild(); kid;
|
||||||
kid = kid->GetNextSibling()) {
|
kid = kid->GetNextSibling()) {
|
||||||
|
@ -169,18 +169,12 @@ nsSVGClipPathFrame::GetType() const
|
||||||
gfxMatrix
|
gfxMatrix
|
||||||
nsSVGClipPathFrame::GetCanvasTM()
|
nsSVGClipPathFrame::GetCanvasTM()
|
||||||
{
|
{
|
||||||
NS_ASSERTION(mClipParentMatrix, "null parent matrix");
|
|
||||||
|
|
||||||
nsSVGClipPathElement *content = static_cast<nsSVGClipPathElement*>(mContent);
|
nsSVGClipPathElement *content = static_cast<nsSVGClipPathElement*>(mContent);
|
||||||
|
|
||||||
gfxMatrix tm = content->PrependLocalTransformTo(
|
gfxMatrix tm = content->PrependLocalTransformTo(
|
||||||
nsSVGUtils::ConvertSVGMatrixToThebes(mClipParentMatrix));
|
nsSVGUtils::ConvertSVGMatrixToThebes(mClipParentMatrix));
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> canvasTM = NS_NewSVGMatrix(tm);
|
return nsSVGUtils::AdjustMatrixForUnits(tm,
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> fini =
|
|
||||||
nsSVGUtils::AdjustMatrixForUnits(canvasTM,
|
|
||||||
&content->mEnumAttributes[nsSVGClipPathElement::CLIPPATHUNITS],
|
&content->mEnumAttributes[nsSVGClipPathElement::CLIPPATHUNITS],
|
||||||
mClipParent);
|
mClipParent);
|
||||||
|
|
||||||
return nsSVGUtils::ConvertSVGMatrixToThebes(fini);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,10 +56,10 @@ public:
|
||||||
// nsSVGClipPathFrame methods:
|
// nsSVGClipPathFrame methods:
|
||||||
nsresult ClipPaint(nsSVGRenderState* aContext,
|
nsresult ClipPaint(nsSVGRenderState* aContext,
|
||||||
nsIFrame* aParent,
|
nsIFrame* aParent,
|
||||||
nsIDOMSVGMatrix *aMatrix);
|
const gfxMatrix &aMatrix);
|
||||||
|
|
||||||
PRBool ClipHitTest(nsIFrame* aParent,
|
PRBool ClipHitTest(nsIFrame* aParent,
|
||||||
nsIDOMSVGMatrix *aMatrix,
|
const gfxMatrix &aMatrix,
|
||||||
const nsPoint &aPoint);
|
const nsPoint &aPoint);
|
||||||
|
|
||||||
// Check if this clipPath is made up of more than one geometry object.
|
// Check if this clipPath is made up of more than one geometry object.
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
|
|
||||||
#include "nsContainerFrame.h"
|
#include "nsContainerFrame.h"
|
||||||
#include "nsISVGChildFrame.h"
|
#include "nsISVGChildFrame.h"
|
||||||
#include "nsIDOMSVGMatrix.h"
|
|
||||||
#include "nsSVGSVGElement.h"
|
#include "nsSVGSVGElement.h"
|
||||||
#include "gfxRect.h"
|
#include "gfxRect.h"
|
||||||
#include "gfxMatrix.h"
|
#include "gfxMatrix.h"
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
|
|
||||||
#include "nsSVGFilterFrame.h"
|
#include "nsSVGFilterFrame.h"
|
||||||
#include "nsIDocument.h"
|
#include "nsIDocument.h"
|
||||||
#include "nsSVGMatrix.h"
|
|
||||||
#include "nsSVGOuterSVGFrame.h"
|
#include "nsSVGOuterSVGFrame.h"
|
||||||
#include "nsGkAtoms.h"
|
#include "nsGkAtoms.h"
|
||||||
#include "nsSVGUtils.h"
|
#include "nsSVGUtils.h"
|
||||||
|
@ -141,8 +140,7 @@ nsAutoFilterInstance::nsAutoFilterInstance(nsIFrame *aTarget,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> userToDeviceSpace =
|
gfxMatrix userToDeviceSpace = nsSVGUtils::GetCanvasTM(aTarget);
|
||||||
NS_NewSVGMatrix(nsSVGUtils::GetCanvasTM(aTarget));
|
|
||||||
|
|
||||||
// Calculate filterRes (the width and height of the pixel buffer of the
|
// Calculate filterRes (the width and height of the pixel buffer of the
|
||||||
// temporary offscreen surface that we'll paint into):
|
// temporary offscreen surface that we'll paint into):
|
||||||
|
@ -183,16 +181,14 @@ nsAutoFilterInstance::nsAutoFilterInstance(nsIFrame *aTarget,
|
||||||
|
|
||||||
// Convert the dirty rects to filter space, and create our nsSVGFilterInstance:
|
// Convert the dirty rects to filter space, and create our nsSVGFilterInstance:
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> filterToUserSpace, filterToDeviceSpace;
|
gfxMatrix filterToUserSpace(filterRegion.Width() / filterRes.width, 0.0f,
|
||||||
NS_NewSVGMatrix(getter_AddRefs(filterToUserSpace),
|
0.0f, filterRegion.Height() / filterRes.height,
|
||||||
filterRegion.Width() / filterRes.width, 0.0f,
|
filterRegion.X(), filterRegion.Y());
|
||||||
0.0f, filterRegion.Height() / filterRes.height,
|
gfxMatrix filterToDeviceSpace = filterToUserSpace * userToDeviceSpace;
|
||||||
filterRegion.X(), filterRegion.Y());
|
|
||||||
userToDeviceSpace->Multiply(filterToUserSpace, getter_AddRefs(filterToDeviceSpace));
|
|
||||||
|
|
||||||
// filterToDeviceSpace is always invertible
|
// filterToDeviceSpace is always invertible
|
||||||
gfxMatrix deviceToFilterSpace
|
gfxMatrix deviceToFilterSpace = filterToDeviceSpace;
|
||||||
= nsSVGUtils::ConvertSVGMatrixToThebes(filterToDeviceSpace).Invert();
|
deviceToFilterSpace.Invert();
|
||||||
|
|
||||||
nsIntRect dirtyOutputRect =
|
nsIntRect dirtyOutputRect =
|
||||||
MapDeviceRectToFilterSpace(deviceToFilterSpace, filterRes, aDirtyOutputRect);
|
MapDeviceRectToFilterSpace(deviceToFilterSpace, filterRes, aDirtyOutputRect);
|
||||||
|
@ -234,8 +230,7 @@ nsSVGFilterFrame::FilterPaint(nsSVGRenderState *aContext,
|
||||||
static nsresult
|
static nsresult
|
||||||
TransformFilterSpaceToDeviceSpace(nsSVGFilterInstance *aInstance, nsIntRect *aRect)
|
TransformFilterSpaceToDeviceSpace(nsSVGFilterInstance *aInstance, nsIntRect *aRect)
|
||||||
{
|
{
|
||||||
gfxMatrix m = nsSVGUtils::ConvertSVGMatrixToThebes(
|
gfxMatrix m = aInstance->GetFilterSpaceToDeviceSpaceTransform();
|
||||||
aInstance->GetFilterSpaceToDeviceSpaceTransform());
|
|
||||||
gfxRect r(aRect->x, aRect->y, aRect->width, aRect->height);
|
gfxRect r(aRect->x, aRect->y, aRect->width, aRect->height);
|
||||||
r = m.TransformBounds(r);
|
r = m.TransformBounds(r);
|
||||||
r.RoundOut();
|
r.RoundOut();
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
#include "nsSVGFilterInstance.h"
|
#include "nsSVGFilterInstance.h"
|
||||||
#include "nsSVGUtils.h"
|
#include "nsSVGUtils.h"
|
||||||
#include "nsIDOMSVGUnitTypes.h"
|
#include "nsIDOMSVGUnitTypes.h"
|
||||||
#include "nsSVGMatrix.h"
|
|
||||||
#include "gfxPlatform.h"
|
#include "gfxPlatform.h"
|
||||||
#include "nsSVGFilterPaintCallback.h"
|
#include "nsSVGFilterPaintCallback.h"
|
||||||
#include "nsSVGFilterElement.h"
|
#include "nsSVGFilterElement.h"
|
||||||
|
@ -96,18 +95,14 @@ nsSVGFilterInstance::UserSpaceToFilterSpace(const gfxRect& aRect) const
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<nsIDOMSVGMatrix>
|
gfxMatrix
|
||||||
nsSVGFilterInstance::GetUserSpaceToFilterSpaceTransform() const
|
nsSVGFilterInstance::GetUserSpaceToFilterSpaceTransform() const
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> filterTransform;
|
|
||||||
gfxFloat widthScale = mFilterSpaceSize.width / mFilterRect.Width();
|
gfxFloat widthScale = mFilterSpaceSize.width / mFilterRect.Width();
|
||||||
gfxFloat heightScale = mFilterSpaceSize.height / mFilterRect.Height();
|
gfxFloat heightScale = mFilterSpaceSize.height / mFilterRect.Height();
|
||||||
NS_NewSVGMatrix(getter_AddRefs(filterTransform),
|
return gfxMatrix(widthScale, 0.0f,
|
||||||
widthScale, 0.0f,
|
0.0f, heightScale,
|
||||||
0.0f, heightScale,
|
-mFilterRect.X() * widthScale, -mFilterRect.Y() * heightScale);
|
||||||
-mFilterRect.X() * widthScale,
|
|
||||||
-mFilterRect.Y() * heightScale);
|
|
||||||
return filterTransform.forget();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -341,12 +336,7 @@ nsSVGFilterInstance::BuildSourceImages()
|
||||||
offscreen->SetDeviceOffset(gfxPoint(-mSurfaceRect.x, -mSurfaceRect.y));
|
offscreen->SetDeviceOffset(gfxPoint(-mSurfaceRect.x, -mSurfaceRect.y));
|
||||||
|
|
||||||
nsSVGRenderState tmpState(offscreen);
|
nsSVGRenderState tmpState(offscreen);
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> userSpaceToFilterSpaceTransform
|
gfxMatrix userSpaceToFilterSpace = GetUserSpaceToFilterSpaceTransform();
|
||||||
= GetUserSpaceToFilterSpaceTransform();
|
|
||||||
if (!userSpaceToFilterSpaceTransform)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
gfxMatrix userSpaceToFilterSpace =
|
|
||||||
nsSVGUtils::ConvertSVGMatrixToThebes(userSpaceToFilterSpaceTransform);
|
|
||||||
|
|
||||||
gfxRect r(neededRect.x, neededRect.y, neededRect.width, neededRect.height);
|
gfxRect r(neededRect.x, neededRect.y, neededRect.width, neededRect.height);
|
||||||
gfxMatrix m = userSpaceToFilterSpace;
|
gfxMatrix m = userSpaceToFilterSpace;
|
||||||
|
@ -369,8 +359,7 @@ nsSVGFilterInstance::BuildSourceImages()
|
||||||
// space to device space and back again). However, that would make the
|
// space to device space and back again). However, that would make the
|
||||||
// code more complex while being hard to get right without introducing
|
// code more complex while being hard to get right without introducing
|
||||||
// subtle bugs, and in practice it probably makes no real difference.)
|
// subtle bugs, and in practice it probably makes no real difference.)
|
||||||
gfxMatrix deviceToFilterSpace =
|
gfxMatrix deviceToFilterSpace = GetFilterSpaceToDeviceSpaceTransform().Invert();
|
||||||
nsSVGUtils::ConvertSVGMatrixToThebes(GetFilterSpaceToDeviceSpaceTransform()).Invert();
|
|
||||||
tmpState.GetGfxContext()->Multiply(deviceToFilterSpace);
|
tmpState.GetGfxContext()->Multiply(deviceToFilterSpace);
|
||||||
mPaintCallback->Paint(&tmpState, mTargetFrame, &dirty);
|
mPaintCallback->Paint(&tmpState, mTargetFrame, &dirty);
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ public:
|
||||||
const gfxRect &aTargetBBox,
|
const gfxRect &aTargetBBox,
|
||||||
const gfxRect& aFilterRect,
|
const gfxRect& aFilterRect,
|
||||||
const nsIntSize& aFilterSpaceSize,
|
const nsIntSize& aFilterSpaceSize,
|
||||||
nsIDOMSVGMatrix *aFilterSpaceToDeviceSpaceTransform,
|
const gfxMatrix &aFilterSpaceToDeviceSpaceTransform,
|
||||||
const nsIntRect& aDirtyOutputRect,
|
const nsIntRect& aDirtyOutputRect,
|
||||||
const nsIntRect& aDirtyInputRect,
|
const nsIntRect& aDirtyInputRect,
|
||||||
PRUint16 aPrimitiveUnits) :
|
PRUint16 aPrimitiveUnits) :
|
||||||
|
@ -107,9 +107,9 @@ public:
|
||||||
nsresult ComputeSourceNeededRect(nsIntRect* aDirty);
|
nsresult ComputeSourceNeededRect(nsIntRect* aDirty);
|
||||||
nsresult ComputeOutputBBox(nsIntRect* aBBox);
|
nsresult ComputeOutputBBox(nsIntRect* aBBox);
|
||||||
|
|
||||||
already_AddRefed<nsIDOMSVGMatrix> GetUserSpaceToFilterSpaceTransform() const;
|
gfxMatrix GetUserSpaceToFilterSpaceTransform() const;
|
||||||
nsIDOMSVGMatrix* GetFilterSpaceToDeviceSpaceTransform() const {
|
gfxMatrix GetFilterSpaceToDeviceSpaceTransform() const {
|
||||||
return mFilterSpaceToDeviceSpaceTransform.get();
|
return mFilterSpaceToDeviceSpaceTransform;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -185,7 +185,7 @@ private:
|
||||||
nsSVGFilterPaintCallback* mPaintCallback;
|
nsSVGFilterPaintCallback* mPaintCallback;
|
||||||
nsSVGFilterElement* mFilterElement;
|
nsSVGFilterElement* mFilterElement;
|
||||||
gfxRect mTargetBBox;
|
gfxRect mTargetBBox;
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> mFilterSpaceToDeviceSpaceTransform;
|
gfxMatrix mFilterSpaceToDeviceSpaceTransform;
|
||||||
gfxRect mFilterRect;
|
gfxRect mFilterRect;
|
||||||
nsIntSize mFilterSpaceSize;
|
nsIntSize mFilterSpaceSize;
|
||||||
nsIntRect mDirtyOutputRect;
|
nsIntRect mDirtyOutputRect;
|
||||||
|
|
|
@ -35,7 +35,6 @@
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
#include "nsSVGPathGeometryFrame.h"
|
#include "nsSVGPathGeometryFrame.h"
|
||||||
#include "nsIDOMSVGMatrix.h"
|
|
||||||
#include "imgIContainer.h"
|
#include "imgIContainer.h"
|
||||||
#include "nsStubImageDecoderObserver.h"
|
#include "nsStubImageDecoderObserver.h"
|
||||||
#include "nsImageLoadingContent.h"
|
#include "nsImageLoadingContent.h"
|
||||||
|
@ -43,8 +42,8 @@
|
||||||
#include "nsLayoutUtils.h"
|
#include "nsLayoutUtils.h"
|
||||||
#include "nsSVGImageElement.h"
|
#include "nsSVGImageElement.h"
|
||||||
#include "nsSVGUtils.h"
|
#include "nsSVGUtils.h"
|
||||||
#include "nsSVGMatrix.h"
|
|
||||||
#include "gfxContext.h"
|
#include "gfxContext.h"
|
||||||
|
#include "gfxMatrix.h"
|
||||||
#include "nsIInterfaceRequestorUtils.h"
|
#include "nsIInterfaceRequestorUtils.h"
|
||||||
|
|
||||||
class nsSVGImageFrame;
|
class nsSVGImageFrame;
|
||||||
|
@ -111,7 +110,7 @@ public:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
already_AddRefed<nsIDOMSVGMatrix> GetImageTransform();
|
gfxMatrix GetImageTransform();
|
||||||
|
|
||||||
nsCOMPtr<imgIDecoderObserver> mListener;
|
nsCOMPtr<imgIDecoderObserver> mListener;
|
||||||
|
|
||||||
|
@ -186,11 +185,9 @@ nsSVGImageFrame::AttributeChanged(PRInt32 aNameSpaceID,
|
||||||
aAttribute, aModType);
|
aAttribute, aModType);
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<nsIDOMSVGMatrix>
|
gfxMatrix
|
||||||
nsSVGImageFrame::GetImageTransform()
|
nsSVGImageFrame::GetImageTransform()
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> ctm = NS_NewSVGMatrix(GetCanvasTM());
|
|
||||||
|
|
||||||
float x, y, width, height;
|
float x, y, width, height;
|
||||||
nsSVGImageElement *element = static_cast<nsSVGImageElement*>(mContent);
|
nsSVGImageElement *element = static_cast<nsSVGImageElement*>(mContent);
|
||||||
element->GetAnimatedLengthValues(&x, &y, &width, &height, nsnull);
|
element->GetAnimatedLengthValues(&x, &y, &width, &height, nsnull);
|
||||||
|
@ -199,17 +196,12 @@ nsSVGImageFrame::GetImageTransform()
|
||||||
mImageContainer->GetWidth(&nativeWidth);
|
mImageContainer->GetWidth(&nativeWidth);
|
||||||
mImageContainer->GetHeight(&nativeHeight);
|
mImageContainer->GetHeight(&nativeHeight);
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> trans, ctmXY, fini;
|
gfxMatrix viewBoxTM =
|
||||||
trans = nsSVGUtils::GetViewBoxTransform(width, height,
|
nsSVGUtils::GetViewBoxTransform(width, height,
|
||||||
0, 0,
|
0, 0, nativeWidth, nativeHeight,
|
||||||
nativeWidth, nativeHeight,
|
element->mPreserveAspectRatio);
|
||||||
element->mPreserveAspectRatio);
|
|
||||||
ctm->Translate(x, y, getter_AddRefs(ctmXY));
|
|
||||||
ctmXY->Multiply(trans, getter_AddRefs(fini));
|
|
||||||
|
|
||||||
nsIDOMSVGMatrix *retval = nsnull;
|
return viewBoxTM * gfxMatrix().Translate(gfxPoint(x, y)) * GetCanvasTM();
|
||||||
fini.swap(retval);
|
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -264,8 +256,6 @@ nsSVGImageFrame::PaintSVG(nsSVGRenderState *aContext,
|
||||||
nsSVGUtils::SetClipRect(gfx, GetCanvasTM(), clipRect);
|
nsSVGUtils::SetClipRect(gfx, GetCanvasTM(), clipRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> fini = GetImageTransform();
|
|
||||||
|
|
||||||
// fill-opacity doesn't affect <image>, so if we're allowed to
|
// fill-opacity doesn't affect <image>, so if we're allowed to
|
||||||
// optimize group opacity, the opacity used for compositing the
|
// optimize group opacity, the opacity used for compositing the
|
||||||
// image into the current canvas is just the group opacity.
|
// image into the current canvas is just the group opacity.
|
||||||
|
@ -278,7 +268,8 @@ nsSVGImageFrame::PaintSVG(nsSVGRenderState *aContext,
|
||||||
mImageContainer->GetWidth(&nativeWidth);
|
mImageContainer->GetWidth(&nativeWidth);
|
||||||
mImageContainer->GetHeight(&nativeHeight);
|
mImageContainer->GetHeight(&nativeHeight);
|
||||||
|
|
||||||
nsSVGUtils::CompositePatternMatrix(gfx, thebesPattern, fini, nativeWidth, nativeHeight, opacity);
|
nsSVGUtils::CompositePatternMatrix(gfx, thebesPattern, GetImageTransform(),
|
||||||
|
nativeWidth, nativeHeight, opacity);
|
||||||
|
|
||||||
if (GetStyleDisplay()->IsScrollableOverflow())
|
if (GetStyleDisplay()->IsScrollableOverflow())
|
||||||
gfx->Restore();
|
gfx->Restore();
|
||||||
|
@ -295,9 +286,7 @@ nsSVGImageFrame::GetFrameForPoint(const nsPoint &aPoint)
|
||||||
mImageContainer->GetWidth(&nativeWidth);
|
mImageContainer->GetWidth(&nativeWidth);
|
||||||
mImageContainer->GetHeight(&nativeHeight);
|
mImageContainer->GetHeight(&nativeHeight);
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> fini = GetImageTransform();
|
if (!nsSVGUtils::HitTestRect(GetImageTransform(),
|
||||||
|
|
||||||
if (!nsSVGUtils::HitTestRect(fini,
|
|
||||||
0, 0, nativeWidth, nativeHeight,
|
0, 0, nativeWidth, nativeHeight,
|
||||||
PresContext()->AppUnitsToDevPixels(aPoint.x),
|
PresContext()->AppUnitsToDevPixels(aPoint.x),
|
||||||
PresContext()->AppUnitsToDevPixels(aPoint.y))) {
|
PresContext()->AppUnitsToDevPixels(aPoint.y))) {
|
||||||
|
|
|
@ -159,17 +159,13 @@ NS_IMETHODIMP_(nsIFrame*)
|
||||||
nsSVGInnerSVGFrame::GetFrameForPoint(const nsPoint &aPoint)
|
nsSVGInnerSVGFrame::GetFrameForPoint(const nsPoint &aPoint)
|
||||||
{
|
{
|
||||||
if (GetStyleDisplay()->IsScrollableOverflow()) {
|
if (GetStyleDisplay()->IsScrollableOverflow()) {
|
||||||
|
nsSVGElement *content = static_cast<nsSVGElement*>(mContent);
|
||||||
|
nsSVGContainerFrame *parent = static_cast<nsSVGContainerFrame*>(mParent);
|
||||||
|
|
||||||
float clipX, clipY, clipWidth, clipHeight;
|
float clipX, clipY, clipWidth, clipHeight;
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> clipTransform;
|
content->GetAnimatedLengthValues(&clipX, &clipY, &clipWidth, &clipHeight, nsnull);
|
||||||
|
|
||||||
nsSVGElement *svg = static_cast<nsSVGElement*>(mContent);
|
if (!nsSVGUtils::HitTestRect(parent->GetCanvasTM(),
|
||||||
svg->GetAnimatedLengthValues(&clipX, &clipY, &clipWidth, &clipHeight, nsnull);
|
|
||||||
|
|
||||||
nsSVGContainerFrame *parent = static_cast<nsSVGContainerFrame*>
|
|
||||||
(mParent);
|
|
||||||
clipTransform = NS_NewSVGMatrix(parent->GetCanvasTM());
|
|
||||||
|
|
||||||
if (!nsSVGUtils::HitTestRect(clipTransform,
|
|
||||||
clipX, clipY, clipWidth, clipHeight,
|
clipX, clipY, clipWidth, clipHeight,
|
||||||
PresContext()->AppUnitsToDevPixels(aPoint.x),
|
PresContext()->AppUnitsToDevPixels(aPoint.x),
|
||||||
PresContext()->AppUnitsToDevPixels(aPoint.y))) {
|
PresContext()->AppUnitsToDevPixels(aPoint.y))) {
|
||||||
|
|
|
@ -42,7 +42,6 @@
|
||||||
#include "nsRegion.h"
|
#include "nsRegion.h"
|
||||||
#include "nsLayoutUtils.h"
|
#include "nsLayoutUtils.h"
|
||||||
#include "nsDisplayList.h"
|
#include "nsDisplayList.h"
|
||||||
#include "nsSVGMatrix.h"
|
|
||||||
#include "nsSVGFilterPaintCallback.h"
|
#include "nsSVGFilterPaintCallback.h"
|
||||||
#include "nsSVGFilterFrame.h"
|
#include "nsSVGFilterFrame.h"
|
||||||
#include "nsSVGClipPathFrame.h"
|
#include "nsSVGClipPathFrame.h"
|
||||||
|
@ -284,7 +283,7 @@ nsSVGIntegrationUtils::PaintFramesWithEffects(nsIRenderingContext* aCtx,
|
||||||
userSpaceRect = userSpaceRect.ToNearestPixels(appUnitsPerDevPixel).ToAppUnits(appUnitsPerDevPixel);
|
userSpaceRect = userSpaceRect.ToNearestPixels(appUnitsPerDevPixel).ToAppUnits(appUnitsPerDevPixel);
|
||||||
aCtx->Translate(userSpaceRect.x, userSpaceRect.y);
|
aCtx->Translate(userSpaceRect.x, userSpaceRect.y);
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> matrix = GetInitialMatrix(aEffectsFrame);
|
gfxMatrix matrix = GetInitialMatrix(aEffectsFrame);
|
||||||
|
|
||||||
PRBool complexEffects = PR_FALSE;
|
PRBool complexEffects = PR_FALSE;
|
||||||
/* Check if we need to do additional operations on this child's
|
/* Check if we need to do additional operations on this child's
|
||||||
|
@ -359,19 +358,18 @@ nsSVGIntegrationUtils::PaintFramesWithEffects(nsIRenderingContext* aCtx,
|
||||||
gfx->SetMatrix(savedCTM);
|
gfx->SetMatrix(savedCTM);
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<nsIDOMSVGMatrix>
|
gfxMatrix
|
||||||
nsSVGIntegrationUtils::GetInitialMatrix(nsIFrame* aNonSVGFrame)
|
nsSVGIntegrationUtils::GetInitialMatrix(nsIFrame* aNonSVGFrame)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(!aNonSVGFrame->IsFrameOfType(nsIFrame::eSVG),
|
NS_ASSERTION(!aNonSVGFrame->IsFrameOfType(nsIFrame::eSVG),
|
||||||
"SVG frames should not get here");
|
"SVG frames should not get here");
|
||||||
PRInt32 appUnitsPerDevPixel = aNonSVGFrame->PresContext()->AppUnitsPerDevPixel();
|
PRInt32 appUnitsPerDevPixel = aNonSVGFrame->PresContext()->AppUnitsPerDevPixel();
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> matrix;
|
|
||||||
float devPxPerCSSPx =
|
float devPxPerCSSPx =
|
||||||
1 / nsPresContext::AppUnitsToFloatCSSPixels(appUnitsPerDevPixel);
|
1 / nsPresContext::AppUnitsToFloatCSSPixels(appUnitsPerDevPixel);
|
||||||
NS_NewSVGMatrix(getter_AddRefs(matrix),
|
|
||||||
devPxPerCSSPx, 0.0f,
|
return gfxMatrix(devPxPerCSSPx, 0.0,
|
||||||
0.0f, devPxPerCSSPx);
|
0.0, devPxPerCSSPx,
|
||||||
return matrix.forget();
|
0.0, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfxRect
|
gfxRect
|
||||||
|
|
|
@ -41,12 +41,12 @@
|
||||||
#include "nsPoint.h"
|
#include "nsPoint.h"
|
||||||
#include "nsRect.h"
|
#include "nsRect.h"
|
||||||
#include "gfxRect.h"
|
#include "gfxRect.h"
|
||||||
|
#include "gfxMatrix.h"
|
||||||
|
|
||||||
class nsIFrame;
|
class nsIFrame;
|
||||||
class nsDisplayListBuilder;
|
class nsDisplayListBuilder;
|
||||||
class nsDisplayList;
|
class nsDisplayList;
|
||||||
class nsIRenderingContext;
|
class nsIRenderingContext;
|
||||||
class nsIDOMSVGMatrix;
|
|
||||||
|
|
||||||
/***** Integration of SVG effects with regular frame painting *****/
|
/***** Integration of SVG effects with regular frame painting *****/
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ public:
|
||||||
nsDisplayListBuilder* aBuilder,
|
nsDisplayListBuilder* aBuilder,
|
||||||
nsDisplayList* aInnerList);
|
nsDisplayList* aInnerList);
|
||||||
|
|
||||||
static already_AddRefed<nsIDOMSVGMatrix>
|
static gfxMatrix
|
||||||
GetInitialMatrix(nsIFrame* aNonSVGFrame);
|
GetInitialMatrix(nsIFrame* aNonSVGFrame);
|
||||||
/**
|
/**
|
||||||
* Returns aNonSVGFrame's rect in CSS pixel units. This is the union
|
* Returns aNonSVGFrame's rect in CSS pixel units. This is the union
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
#include "nsIDocument.h"
|
#include "nsIDocument.h"
|
||||||
#include "nsSVGMarkerFrame.h"
|
#include "nsSVGMarkerFrame.h"
|
||||||
#include "nsSVGPathGeometryFrame.h"
|
#include "nsSVGPathGeometryFrame.h"
|
||||||
#include "nsSVGMatrix.h"
|
|
||||||
#include "nsSVGEffects.h"
|
#include "nsSVGEffects.h"
|
||||||
#include "nsSVGMarkerElement.h"
|
#include "nsSVGMarkerElement.h"
|
||||||
#include "nsSVGPathGeometryElement.h"
|
#include "nsSVGPathGeometryElement.h"
|
||||||
|
@ -113,18 +112,10 @@ nsSVGMarkerFrame::GetCanvasTM()
|
||||||
gfxMatrix markedTM = mMarkedFrame->GetCanvasTM();
|
gfxMatrix markedTM = mMarkedFrame->GetCanvasTM();
|
||||||
mInUse2 = PR_FALSE;
|
mInUse2 = PR_FALSE;
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> markerTM;
|
gfxMatrix markerTM = content->GetMarkerTransform(mStrokeWidth, mX, mY, mAngle);
|
||||||
content->GetMarkerTransform(mStrokeWidth, mX, mY, mAngle, getter_AddRefs(markerTM));
|
gfxMatrix viewBoxTM = content->GetViewBoxTransform();
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> viewBoxTM;
|
return viewBoxTM * markerTM * markedTM;
|
||||||
nsresult res = content->GetViewboxToViewportTransform(getter_AddRefs(viewBoxTM));
|
|
||||||
if (NS_FAILED(res)) {
|
|
||||||
return gfxMatrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
|
|
||||||
}
|
|
||||||
|
|
||||||
markedTM.PreMultiply(nsSVGUtils::ConvertSVGMatrixToThebes(markerTM));
|
|
||||||
markedTM.PreMultiply(nsSVGUtils::ConvertSVGMatrixToThebes(viewBoxTM));
|
|
||||||
return markedTM;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include "nsIDOMSVGMatrix.h"
|
#include "nsIDOMSVGMatrix.h"
|
||||||
#include "gfxContext.h"
|
#include "gfxContext.h"
|
||||||
#include "gfxImageSurface.h"
|
#include "gfxImageSurface.h"
|
||||||
|
#include "nsSVGMatrix.h"
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// Implementation
|
// Implementation
|
||||||
|
@ -54,7 +55,7 @@ NS_NewSVGMaskFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
||||||
already_AddRefed<gfxPattern>
|
already_AddRefed<gfxPattern>
|
||||||
nsSVGMaskFrame::ComputeMaskAlpha(nsSVGRenderState *aContext,
|
nsSVGMaskFrame::ComputeMaskAlpha(nsSVGRenderState *aContext,
|
||||||
nsIFrame* aParent,
|
nsIFrame* aParent,
|
||||||
nsIDOMSVGMatrix* aMatrix,
|
const gfxMatrix &aMatrix,
|
||||||
float aOpacity)
|
float aOpacity)
|
||||||
{
|
{
|
||||||
// If the flag is set when we get here, it means this mask frame
|
// If the flag is set when we get here, it means this mask frame
|
||||||
|
@ -84,11 +85,11 @@ nsSVGMaskFrame::ComputeMaskAlpha(nsSVGRenderState *aContext,
|
||||||
&mask->mLengthAttributes[nsSVGMaskElement::X], bbox, aParent);
|
&mask->mLengthAttributes[nsSVGMaskElement::X], bbox, aParent);
|
||||||
|
|
||||||
gfx->Save();
|
gfx->Save();
|
||||||
nsSVGUtils::SetClipRect(gfx, nsSVGUtils::ConvertSVGMatrixToThebes(aMatrix), maskArea);
|
nsSVGUtils::SetClipRect(gfx, aMatrix, maskArea);
|
||||||
}
|
}
|
||||||
|
|
||||||
mMaskParent = aParent;
|
mMaskParent = aParent;
|
||||||
mMaskParentMatrix = aMatrix;
|
mMaskParentMatrix = NS_NewSVGMatrix(aMatrix);
|
||||||
|
|
||||||
for (nsIFrame* kid = mFrames.FirstChild(); kid;
|
for (nsIFrame* kid = mFrames.FirstChild(); kid;
|
||||||
kid = kid->GetNextSibling()) {
|
kid = kid->GetNextSibling()) {
|
||||||
|
@ -185,11 +186,8 @@ nsSVGMaskFrame::GetCanvasTM()
|
||||||
|
|
||||||
nsSVGMaskElement *mask = static_cast<nsSVGMaskElement*>(mContent);
|
nsSVGMaskElement *mask = static_cast<nsSVGMaskElement*>(mContent);
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> matrix =
|
return nsSVGUtils::AdjustMatrixForUnits(nsSVGUtils::ConvertSVGMatrixToThebes(mMaskParentMatrix),
|
||||||
nsSVGUtils::AdjustMatrixForUnits(mMaskParentMatrix,
|
|
||||||
&mask->mEnumAttributes[nsSVGMaskElement::MASKCONTENTUNITS],
|
&mask->mEnumAttributes[nsSVGMaskElement::MASKCONTENTUNITS],
|
||||||
mMaskParent);
|
mMaskParent);
|
||||||
|
|
||||||
return nsSVGUtils::ConvertSVGMatrixToThebes(matrix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ public:
|
||||||
// nsSVGMaskFrame method:
|
// nsSVGMaskFrame method:
|
||||||
already_AddRefed<gfxPattern> ComputeMaskAlpha(nsSVGRenderState *aContext,
|
already_AddRefed<gfxPattern> ComputeMaskAlpha(nsSVGRenderState *aContext,
|
||||||
nsIFrame* aParent,
|
nsIFrame* aParent,
|
||||||
nsIDOMSVGMatrix* aMatrix,
|
const gfxMatrix &aMatrix,
|
||||||
float aOpacity = 1.0f);
|
float aOpacity = 1.0f);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
|
@ -741,41 +741,23 @@ gfxMatrix
|
||||||
nsSVGOuterSVGFrame::GetCanvasTM()
|
nsSVGOuterSVGFrame::GetCanvasTM()
|
||||||
{
|
{
|
||||||
if (!mCanvasTM) {
|
if (!mCanvasTM) {
|
||||||
nsSVGSVGElement *svgElement = static_cast<nsSVGSVGElement*>(mContent);
|
nsSVGSVGElement *content = static_cast<nsSVGSVGElement*>(mContent);
|
||||||
|
|
||||||
float devPxPerCSSPx =
|
float devPxPerCSSPx =
|
||||||
1 / PresContext()->AppUnitsToFloatCSSPixels(
|
1.0f / PresContext()->AppUnitsToFloatCSSPixels(
|
||||||
PresContext()->AppUnitsPerDevPixel());
|
PresContext()->AppUnitsPerDevPixel());
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> devPxToCSSPxMatrix;
|
|
||||||
NS_NewSVGMatrix(getter_AddRefs(devPxToCSSPxMatrix),
|
|
||||||
devPxPerCSSPx, 0.0f,
|
|
||||||
0.0f, devPxPerCSSPx);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> viewBoxTM;
|
gfxMatrix viewBoxTM = content->GetViewBoxTransform();
|
||||||
nsresult res =
|
|
||||||
svgElement->GetViewboxToViewportTransform(getter_AddRefs(viewBoxTM));
|
|
||||||
if (NS_SUCCEEDED(res) && viewBoxTM) {
|
|
||||||
// PRE-multiply px conversion!
|
|
||||||
devPxToCSSPxMatrix->Multiply(viewBoxTM, getter_AddRefs(mCanvasTM));
|
|
||||||
} else {
|
|
||||||
NS_WARNING("We should propagate the fact that the viewBox is invalid.");
|
|
||||||
mCanvasTM = devPxToCSSPxMatrix;
|
|
||||||
}
|
|
||||||
|
|
||||||
// our content is the document element so we must premultiply the values
|
gfxMatrix zoomPanTM;
|
||||||
// of its currentScale and currentTranslate properties
|
|
||||||
if (mIsRootContent) {
|
if (mIsRootContent) {
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> zoomPanMatrix;
|
const nsSVGTranslatePoint& translate = content->GetCurrentTranslate();
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> temp;
|
zoomPanTM.Translate(gfxPoint(translate.GetX(), translate.GetY()));
|
||||||
float scale = svgElement->GetCurrentScale();
|
zoomPanTM.Scale(content->GetCurrentScale(), content->GetCurrentScale());
|
||||||
const nsSVGTranslatePoint& translate = svgElement->GetCurrentTranslate();
|
|
||||||
|
|
||||||
svgElement->CreateSVGMatrix(getter_AddRefs(zoomPanMatrix));
|
|
||||||
zoomPanMatrix->Translate(translate.GetX(), translate.GetY(), getter_AddRefs(temp));
|
|
||||||
temp->Scale(scale, getter_AddRefs(zoomPanMatrix));
|
|
||||||
zoomPanMatrix->Multiply(mCanvasTM, getter_AddRefs(temp));
|
|
||||||
temp.swap(mCanvasTM);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gfxMatrix TM = viewBoxTM * zoomPanTM * gfxMatrix().Scale(devPxPerCSSPx, devPxPerCSSPx);
|
||||||
|
mCanvasTM = NS_NewSVGMatrix(TM);
|
||||||
}
|
}
|
||||||
return nsSVGUtils::ConvertSVGMatrixToThebes(mCanvasTM);
|
return nsSVGUtils::ConvertSVGMatrixToThebes(mCanvasTM);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
#include "nsSVGPathGeometryFrame.h"
|
#include "nsSVGPathGeometryFrame.h"
|
||||||
#include "nsGkAtoms.h"
|
#include "nsGkAtoms.h"
|
||||||
#include "nsSVGMarkerFrame.h"
|
#include "nsSVGMarkerFrame.h"
|
||||||
#include "nsSVGMatrix.h"
|
|
||||||
#include "nsSVGUtils.h"
|
#include "nsSVGUtils.h"
|
||||||
#include "nsSVGEffects.h"
|
#include "nsSVGEffects.h"
|
||||||
#include "nsSVGGraphicElement.h"
|
#include "nsSVGGraphicElement.h"
|
||||||
|
|
|
@ -48,7 +48,6 @@
|
||||||
#include "gfxMatrix.h"
|
#include "gfxMatrix.h"
|
||||||
|
|
||||||
class nsPresContext;
|
class nsPresContext;
|
||||||
class nsIDOMSVGMatrix;
|
|
||||||
class nsSVGMarkerFrame;
|
class nsSVGMarkerFrame;
|
||||||
class nsSVGMarkerProperty;
|
class nsSVGMarkerProperty;
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@
|
||||||
#include "gfxContext.h"
|
#include "gfxContext.h"
|
||||||
#include "gfxPlatform.h"
|
#include "gfxPlatform.h"
|
||||||
#include "gfxPattern.h"
|
#include "gfxPattern.h"
|
||||||
|
#include "gfxMatrix.h"
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -197,16 +198,19 @@ nsSVGPatternFrame::PaintPattern(gfxASurface** surface,
|
||||||
// the geometry that is being rendered with a pattern
|
// the geometry that is being rendered with a pattern
|
||||||
nsSVGElement *callerContent;
|
nsSVGElement *callerContent;
|
||||||
gfxRect callerBBox;
|
gfxRect callerBBox;
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> callerCTM;
|
gfxMatrix callerCTM;
|
||||||
if (NS_FAILED(GetTargetGeometry(getter_AddRefs(callerCTM),
|
if (NS_FAILED(GetTargetGeometry(&callerCTM,
|
||||||
&callerBBox,
|
&callerBBox,
|
||||||
&callerContent, aSource)))
|
&callerContent, aSource)))
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
// Construct the CTM that we will provide to our children when we
|
// Construct the CTM that we will provide to our children when we
|
||||||
// render them into the tile.
|
// render them into the tile.
|
||||||
if (NS_FAILED(ConstructCTM(getter_AddRefs(mCTM), callerBBox, callerCTM)))
|
gfxMatrix ctm = ConstructCTM(callerBBox, callerCTM);
|
||||||
|
if (ctm.IsSingular()) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
mCTM = NS_NewSVGMatrix(ctm);
|
||||||
|
|
||||||
// Get the bounding box of the pattern. This will be used to determine
|
// 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
|
// the size of the surface, and will also be used to define the bounding
|
||||||
|
@ -474,7 +478,7 @@ nsSVGPatternFrame::GetPatternWithAttr(nsIAtom *aAttrName, nsIContent *aDefault)
|
||||||
|
|
||||||
gfxRect
|
gfxRect
|
||||||
nsSVGPatternFrame::GetPatternRect(const gfxRect &aTargetBBox,
|
nsSVGPatternFrame::GetPatternRect(const gfxRect &aTargetBBox,
|
||||||
nsIDOMSVGMatrix *aTargetCTM,
|
const gfxMatrix &aTargetCTM,
|
||||||
nsSVGElement *aTarget)
|
nsSVGElement *aTarget)
|
||||||
{
|
{
|
||||||
// Get our type
|
// Get our type
|
||||||
|
@ -512,52 +516,42 @@ GetLengthValue(const nsSVGLength2 *aLength)
|
||||||
return aLength->GetAnimValue(static_cast<nsSVGSVGElement*>(nsnull));
|
return aLength->GetAnimValue(static_cast<nsSVGSVGElement*>(nsnull));
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
gfxMatrix
|
||||||
nsSVGPatternFrame::ConstructCTM(nsIDOMSVGMatrix **aCTM,
|
nsSVGPatternFrame::ConstructCTM(const gfxRect &callerBBox,
|
||||||
const gfxRect &callerBBox,
|
const gfxMatrix &callerCTM)
|
||||||
nsIDOMSVGMatrix *callerCTM)
|
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> tCTM, tempTM;
|
gfxMatrix tCTM;
|
||||||
|
|
||||||
// Begin by handling the objectBoundingBox conversion since
|
// The objectBoundingBox conversion must be handled in the CTM:
|
||||||
// this must be handled in the CTM
|
if (GetPatternContentUnits() ==
|
||||||
PRUint16 type = GetPatternContentUnits();
|
nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
|
||||||
|
tCTM.Scale(callerBBox.Width(), callerBBox.Height());
|
||||||
if (type == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
|
|
||||||
NS_NewSVGMatrix(getter_AddRefs(tCTM), callerBBox.Width(), 0.0f, 0.0f,
|
|
||||||
callerBBox.Height(), 0.0f, 0.0f);
|
|
||||||
} else {
|
} else {
|
||||||
float scale = nsSVGUtils::MaxExpansion(callerCTM);
|
float scale = nsSVGUtils::MaxExpansion(callerCTM);
|
||||||
NS_NewSVGMatrix(getter_AddRefs(tCTM), scale, 0, 0, scale, 0, 0);
|
tCTM.Scale(scale, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gfxMatrix viewBoxTM;
|
||||||
const nsSVGViewBoxRect viewBox = GetViewBox().GetAnimValue();
|
const nsSVGViewBoxRect viewBox = GetViewBox().GetAnimValue();
|
||||||
|
|
||||||
if (viewBox.height > 0.0f && viewBox.width > 0.0f) {
|
if (viewBox.height > 0.0f && viewBox.width > 0.0f) {
|
||||||
|
|
||||||
float viewportWidth = GetLengthValue(GetWidth());
|
float viewportWidth = GetLengthValue(GetWidth());
|
||||||
float viewportHeight = GetLengthValue(GetHeight());
|
float viewportHeight = GetLengthValue(GetHeight());
|
||||||
float refX = GetLengthValue(GetX());
|
float refX = GetLengthValue(GetX());
|
||||||
float refY = GetLengthValue(GetY());
|
float refY = GetLengthValue(GetY());
|
||||||
|
viewBoxTM = nsSVGUtils::GetViewBoxTransform(viewportWidth, viewportHeight,
|
||||||
tempTM = nsSVGUtils::GetViewBoxTransform(viewportWidth, viewportHeight,
|
viewBox.x + refX, viewBox.y + refY,
|
||||||
viewBox.x + refX, viewBox.y + refY,
|
viewBox.width, viewBox.height,
|
||||||
viewBox.width, viewBox.height,
|
GetPreserveAspectRatio(),
|
||||||
GetPreserveAspectRatio(),
|
PR_TRUE);
|
||||||
PR_TRUE);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// No viewBox, construct from the (modified) parent matrix
|
|
||||||
NS_NewSVGMatrix(getter_AddRefs(tempTM));
|
|
||||||
}
|
}
|
||||||
tCTM->Multiply(tempTM, aCTM);
|
return viewBoxTM * tCTM;
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gfxMatrix
|
gfxMatrix
|
||||||
nsSVGPatternFrame::GetPatternMatrix(const gfxRect &bbox,
|
nsSVGPatternFrame::GetPatternMatrix(const gfxRect &bbox,
|
||||||
const gfxRect &callerBBox,
|
const gfxRect &callerBBox,
|
||||||
nsIDOMSVGMatrix *callerCTM)
|
const gfxMatrix &callerCTM)
|
||||||
{
|
{
|
||||||
// Get the pattern transform
|
// Get the pattern transform
|
||||||
gfxMatrix patternTransform = GetPatternTransform();
|
gfxMatrix patternTransform = GetPatternTransform();
|
||||||
|
@ -580,12 +574,11 @@ nsSVGPatternFrame::GetPatternMatrix(const gfxRect &bbox,
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsSVGPatternFrame::GetTargetGeometry(nsIDOMSVGMatrix **aCTM,
|
nsSVGPatternFrame::GetTargetGeometry(gfxMatrix *aCTM,
|
||||||
gfxRect *aBBox,
|
gfxRect *aBBox,
|
||||||
nsSVGElement **aTargetContent,
|
nsSVGElement **aTargetContent,
|
||||||
nsSVGGeometryFrame *aTarget)
|
nsSVGGeometryFrame *aTarget)
|
||||||
{
|
{
|
||||||
*aCTM = nsnull;
|
|
||||||
*aTargetContent = nsnull;
|
*aTargetContent = nsnull;
|
||||||
|
|
||||||
// Make sure the callerContent is an SVG element. If we are attempting
|
// Make sure the callerContent is an SVG element. If we are attempting
|
||||||
|
@ -618,7 +611,7 @@ nsSVGPatternFrame::GetTargetGeometry(nsIDOMSVGMatrix **aCTM,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the transformation matrix from our calling geometry
|
// Get the transformation matrix from our calling geometry
|
||||||
*aCTM = NS_NewSVGMatrix(aTarget->GetCanvasTM()).get();
|
*aCTM = aTarget->GetCanvasTM();
|
||||||
|
|
||||||
// OK, now fix up the bounding box to reflect user coordinates
|
// OK, now fix up the bounding box to reflect user coordinates
|
||||||
// We handle device unit scaling in pattern matrix
|
// We handle device unit scaling in pattern matrix
|
||||||
|
|
|
@ -129,15 +129,14 @@ protected:
|
||||||
|
|
||||||
NS_IMETHOD GetPatternFirstChild(nsIFrame **kid);
|
NS_IMETHOD GetPatternFirstChild(nsIFrame **kid);
|
||||||
gfxRect GetPatternRect(const gfxRect &bbox,
|
gfxRect GetPatternRect(const gfxRect &bbox,
|
||||||
nsIDOMSVGMatrix *callerCTM,
|
const gfxMatrix &callerCTM,
|
||||||
nsSVGElement *content);
|
nsSVGElement *content);
|
||||||
gfxMatrix GetPatternMatrix(const gfxRect &bbox,
|
gfxMatrix GetPatternMatrix(const gfxRect &bbox,
|
||||||
const gfxRect &callerBBox,
|
const gfxRect &callerBBox,
|
||||||
nsIDOMSVGMatrix *callerCTM);
|
const gfxMatrix &callerCTM);
|
||||||
nsresult ConstructCTM(nsIDOMSVGMatrix **ctm,
|
gfxMatrix ConstructCTM(const gfxRect &callerBBox,
|
||||||
const gfxRect &callerBBox,
|
const gfxMatrix &callerCTM);
|
||||||
nsIDOMSVGMatrix *callerCTM);
|
nsresult GetTargetGeometry(gfxMatrix *aCTM,
|
||||||
nsresult GetTargetGeometry(nsIDOMSVGMatrix **aCTM,
|
|
||||||
gfxRect *aBBox,
|
gfxRect *aBBox,
|
||||||
nsSVGElement **aTargetContent,
|
nsSVGElement **aTargetContent,
|
||||||
nsSVGGeometryFrame *aTarget);
|
nsSVGGeometryFrame *aTarget);
|
||||||
|
|
|
@ -41,7 +41,6 @@
|
||||||
#include "nsSVGUtils.h"
|
#include "nsSVGUtils.h"
|
||||||
#include "nsSVGTextFrame.h"
|
#include "nsSVGTextFrame.h"
|
||||||
#include "nsSVGOuterSVGFrame.h"
|
#include "nsSVGOuterSVGFrame.h"
|
||||||
#include "nsSVGMatrix.h"
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// Implementation
|
// Implementation
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
#include "nsSVGContainerFrame.h"
|
#include "nsSVGContainerFrame.h"
|
||||||
#include "nsSVGTextFrame.h"
|
#include "nsSVGTextFrame.h"
|
||||||
#include "nsSVGUtils.h"
|
#include "nsSVGUtils.h"
|
||||||
#include "nsSVGMatrix.h"
|
|
||||||
#include "nsSVGOuterSVGFrame.h"
|
#include "nsSVGOuterSVGFrame.h"
|
||||||
#include "nsIDOMSVGTextElement.h"
|
#include "nsIDOMSVGTextElement.h"
|
||||||
#include "nsIDOMSVGAnimatedLengthList.h"
|
#include "nsIDOMSVGAnimatedLengthList.h"
|
||||||
|
|
|
@ -42,7 +42,6 @@
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
#include "nsSVGPathElement.h"
|
#include "nsSVGPathElement.h"
|
||||||
#include "nsSVGTextPathElement.h"
|
#include "nsSVGTextPathElement.h"
|
||||||
#include "nsSVGMatrix.h"
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// Implementation
|
// Implementation
|
||||||
|
@ -153,13 +152,11 @@ already_AddRefed<gfxFlattenedPath>
|
||||||
nsSVGTextPathFrame::GetFlattenedPath(nsIFrame *path)
|
nsSVGTextPathFrame::GetFlattenedPath(nsIFrame *path)
|
||||||
{
|
{
|
||||||
NS_PRECONDITION(path, "Unexpected null path");
|
NS_PRECONDITION(path, "Unexpected null path");
|
||||||
nsSVGPathGeometryElement *element = static_cast<nsSVGPathGeometryElement*>
|
|
||||||
(path->GetContent());
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> localTM =
|
nsSVGPathGeometryElement *element =
|
||||||
NS_NewSVGMatrix(element->PrependLocalTransformTo(gfxMatrix()));
|
static_cast<nsSVGPathGeometryElement*>(path->GetContent());
|
||||||
|
|
||||||
return element->GetFlattenedPath(localTM);
|
return element->GetFlattenedPath(element->PrependLocalTransformTo(gfxMatrix()));
|
||||||
}
|
}
|
||||||
|
|
||||||
gfxFloat
|
gfxFloat
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
|
|
||||||
#include "nsSVGGFrame.h"
|
#include "nsSVGGFrame.h"
|
||||||
#include "nsIAnonymousContentCreator.h"
|
#include "nsIAnonymousContentCreator.h"
|
||||||
#include "nsSVGMatrix.h"
|
|
||||||
#include "nsIDOMSVGUseElement.h"
|
#include "nsIDOMSVGUseElement.h"
|
||||||
#include "nsIDOMSVGTransformable.h"
|
#include "nsIDOMSVGTransformable.h"
|
||||||
#include "nsSVGElement.h"
|
#include "nsSVGElement.h"
|
||||||
|
|
|
@ -436,124 +436,111 @@ nsSVGUtils::CoordToFloat(nsPresContext *aPresContext,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
PRBool
|
||||||
nsSVGUtils::GetNearestViewportElement(nsIContent *aContent,
|
nsSVGUtils::EstablishesViewport(nsIContent *aContent)
|
||||||
nsIDOMSVGElement * *aNearestViewportElement)
|
|
||||||
{
|
{
|
||||||
*aNearestViewportElement = nsnull;
|
return aContent && aContent->GetNameSpaceID() == kNameSpaceID_SVG &&
|
||||||
|
(aContent->Tag() == nsGkAtoms::svg ||
|
||||||
|
aContent->Tag() == nsGkAtoms::image ||
|
||||||
|
aContent->Tag() == nsGkAtoms::foreignObject ||
|
||||||
|
aContent->Tag() == nsGkAtoms::symbol);
|
||||||
|
}
|
||||||
|
|
||||||
|
already_AddRefed<nsIDOMSVGElement>
|
||||||
|
nsSVGUtils::GetNearestViewportElement(nsIContent *aContent)
|
||||||
|
{
|
||||||
|
nsIContent *element = GetParentElement(aContent);
|
||||||
|
|
||||||
|
while (element && element->GetNameSpaceID() == kNameSpaceID_SVG) {
|
||||||
|
if (EstablishesViewport(element)) {
|
||||||
|
if (element->Tag() == nsGkAtoms::foreignObject) {
|
||||||
|
return nsnull;
|
||||||
|
}
|
||||||
|
return nsCOMPtr<nsIDOMSVGElement>(do_QueryInterface(element)).forget();
|
||||||
|
}
|
||||||
|
element = GetParentElement(element);
|
||||||
|
}
|
||||||
|
return nsnull;
|
||||||
|
}
|
||||||
|
|
||||||
|
already_AddRefed<nsIDOMSVGElement>
|
||||||
|
nsSVGUtils::GetFarthestViewportElement(nsIContent *aContent)
|
||||||
|
{
|
||||||
|
nsIContent *element = nsnull;
|
||||||
nsIContent *ancestor = GetParentElement(aContent);
|
nsIContent *ancestor = GetParentElement(aContent);
|
||||||
|
|
||||||
while (ancestor && ancestor->GetNameSpaceID() == kNameSpaceID_SVG &&
|
while (ancestor && ancestor->GetNameSpaceID() == kNameSpaceID_SVG &&
|
||||||
ancestor->Tag() != nsGkAtoms::foreignObject) {
|
ancestor->Tag() != nsGkAtoms::foreignObject) {
|
||||||
|
element = ancestor;
|
||||||
nsCOMPtr<nsIDOMSVGFitToViewBox> fitToViewBox = do_QueryInterface(ancestor);
|
ancestor = GetParentElement(element);
|
||||||
|
|
||||||
if (fitToViewBox) {
|
|
||||||
// right interface
|
|
||||||
nsCOMPtr<nsIDOMSVGElement> element = do_QueryInterface(ancestor);
|
|
||||||
element.swap(*aNearestViewportElement);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
ancestor = GetParentElement(ancestor);
|
|
||||||
}
|
}
|
||||||
if (ancestor && ancestor->GetNameSpaceID() == kNameSpaceID_SVG &&
|
|
||||||
ancestor->Tag() == nsGkAtoms::foreignObject )
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
|
|
||||||
return NS_OK;
|
if (element && element->Tag() == nsGkAtoms::svg) {
|
||||||
|
return nsCOMPtr<nsIDOMSVGElement>(do_QueryInterface(element)).forget();
|
||||||
|
}
|
||||||
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
gfxMatrix
|
||||||
nsSVGUtils::AppendTransformUptoElement(nsIContent *aContent, nsIDOMSVGElement *aElement, nsIDOMSVGMatrix * *aCTM){
|
nsSVGUtils::GetCTM(nsSVGElement *aElement, PRBool aScreenCTM)
|
||||||
nsresult rv;
|
|
||||||
nsCOMPtr<nsIDOMSVGElement> element = do_QueryInterface(aContent);
|
|
||||||
nsIContent *ancestor = GetParentElement(aContent);
|
|
||||||
if (!aElement) {
|
|
||||||
// calculating GetScreenCTM(): traverse upto the root or non-SVG content.
|
|
||||||
if (ancestor && ancestor->GetNameSpaceID() == kNameSpaceID_SVG) {
|
|
||||||
if (ancestor->Tag() == nsGkAtoms::foreignObject && aContent->Tag() != nsGkAtoms::svg)
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
rv = AppendTransformUptoElement(ancestor, aElement, aCTM);
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
}
|
|
||||||
} else if (element != aElement) { // calculating GetCTM(): stop at aElement.
|
|
||||||
NS_ASSERTION(ancestor != nsnull, "ancestor shouldn't be null.");
|
|
||||||
if (!ancestor)
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
rv = AppendTransformUptoElement(ancestor, aElement, aCTM);
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> tmp;
|
|
||||||
if (nsCOMPtr<nsIDOMSVGSVGElement>(do_QueryInterface(aContent))) {
|
|
||||||
nsSVGSVGElement *svgElement = static_cast<nsSVGSVGElement*>(aContent);
|
|
||||||
rv = svgElement->AppendTransform(*aCTM, getter_AddRefs(tmp));
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
} else if (nsCOMPtr<nsIDOMSVGTransformable>(do_QueryInterface(aContent))) {
|
|
||||||
nsSVGGraphicElement *graphicElement = static_cast<nsSVGGraphicElement*>(aContent);
|
|
||||||
rv = graphicElement->AppendTransform(*aCTM, getter_AddRefs(tmp));
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
} else {
|
|
||||||
//XXX aContent may be other type of viewport-establising elements
|
|
||||||
// (e.g. <use> and <symbol>) and handle them?
|
|
||||||
}
|
|
||||||
if (tmp)
|
|
||||||
tmp.swap(*aCTM);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsSVGUtils::GetCTM(nsIContent *aContent, nsIDOMSVGMatrix * *aCTM)
|
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsIDocument* currentDoc = aElement->GetCurrentDoc();
|
||||||
nsIDocument* currentDoc = aContent->GetCurrentDoc();
|
|
||||||
if (currentDoc) {
|
if (currentDoc) {
|
||||||
// Flush all pending notifications so that our frames are uptodate
|
// Flush all pending notifications so that our frames are up to date
|
||||||
currentDoc->FlushPendingNotifications(Flush_Layout);
|
currentDoc->FlushPendingNotifications(Flush_Layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
*aCTM = nsnull;
|
gfxMatrix matrix = aElement->PrependLocalTransformTo(gfxMatrix());
|
||||||
nsCOMPtr<nsIDOMSVGElement> nearestViewportElement;
|
nsSVGElement *element = aElement;
|
||||||
rv = GetNearestViewportElement(aContent, getter_AddRefs(nearestViewportElement));
|
nsIContent *ancestor = GetParentElement(aElement);
|
||||||
// According to the spec(http://www.w3.org/TR/SVG11/types.html#InterfaceSVGLocatable),
|
|
||||||
// GetCTM is strictly defined to be the CTM for nearestViewportElement,
|
|
||||||
// Thus, if it is null, this is null, too.
|
|
||||||
if (NS_FAILED(rv) || !nearestViewportElement)
|
|
||||||
return NS_OK; // we can't throw exceptions from this API.
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> tmp;
|
while (ancestor && ancestor->GetNameSpaceID() == kNameSpaceID_SVG &&
|
||||||
rv = NS_NewSVGMatrix(getter_AddRefs(tmp), 1, 0, 0, 1, 0, 0);
|
ancestor->Tag() != nsGkAtoms::foreignObject) {
|
||||||
if (NS_FAILED(rv)) return NS_OK; // we can't throw exceptions from this API.
|
element = static_cast<nsSVGElement*>(ancestor);
|
||||||
tmp.swap(*aCTM);
|
matrix *= element->PrependLocalTransformTo(gfxMatrix()); // i.e. *A*ppend
|
||||||
rv = AppendTransformUptoElement(aContent, nearestViewportElement, aCTM);
|
if (!aScreenCTM && EstablishesViewport(element)) {
|
||||||
if (NS_FAILED(rv))
|
if (!element->NodeInfo()->Equals(nsGkAtoms::svg, kNameSpaceID_SVG) &&
|
||||||
tmp.swap(*aCTM);
|
!element->NodeInfo()->Equals(nsGkAtoms::symbol, kNameSpaceID_SVG)) {
|
||||||
return NS_OK; // we can't throw exceptions from this API.
|
NS_ERROR("New (SVG > 1.1) SVG viewport establishing element?");
|
||||||
}
|
return gfxMatrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
|
||||||
|
}
|
||||||
nsresult
|
// XXX spec seems to say x,y translation should be undone for IsInnerSVG
|
||||||
nsSVGUtils::GetScreenCTM(nsIContent *aContent, nsIDOMSVGMatrix * *aCTM)
|
return matrix;
|
||||||
{
|
}
|
||||||
nsresult rv;
|
ancestor = GetParentElement(element);
|
||||||
nsIDocument* currentDoc = aContent->GetCurrentDoc();
|
|
||||||
if (currentDoc) {
|
|
||||||
// Flush all pending notifications so that our frames are uptodate
|
|
||||||
currentDoc->FlushPendingNotifications(Flush_Layout);
|
|
||||||
}
|
}
|
||||||
|
if (!aScreenCTM) {
|
||||||
*aCTM = nsnull;
|
// didn't find a nearestViewportElement
|
||||||
|
return gfxMatrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> tmp;
|
}
|
||||||
rv = NS_NewSVGMatrix(getter_AddRefs(tmp), 1, 0, 0, 1, 0, 0);
|
if (!ancestor || !ancestor->IsNodeOfType(nsINode::eELEMENT)) {
|
||||||
if (NS_FAILED(rv)) return NS_OK; // we can't throw exceptions from this API.
|
return matrix;
|
||||||
tmp.swap(*aCTM);
|
}
|
||||||
rv = AppendTransformUptoElement(aContent, nsnull, aCTM);
|
if (ancestor->GetNameSpaceID() == kNameSpaceID_SVG) {
|
||||||
if (NS_FAILED(rv))
|
if (element->Tag() != nsGkAtoms::svg) {
|
||||||
tmp.swap(*aCTM);
|
return gfxMatrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
|
||||||
return NS_OK; // we can't throw exceptions from this API.
|
}
|
||||||
|
return matrix * GetCTM(static_cast<nsSVGElement*>(ancestor), PR_TRUE);
|
||||||
|
}
|
||||||
|
// XXX this does not take into account CSS transform, or that the non-SVG
|
||||||
|
// content that we've hit may itself be inside an SVG foreignObject higher up
|
||||||
|
float x = 0.0f, y = 0.0f;
|
||||||
|
if (element->NodeInfo()->Equals(nsGkAtoms::svg, kNameSpaceID_SVG)) {
|
||||||
|
nsIPresShell *presShell = currentDoc->GetPrimaryShell();
|
||||||
|
if (element && presShell) {
|
||||||
|
nsPresContext *context = presShell->GetPresContext();
|
||||||
|
if (context) {
|
||||||
|
nsIFrame* frame = presShell->GetPrimaryFrameFor(element);
|
||||||
|
nsIFrame* ancestorFrame = presShell->GetRootFrame();
|
||||||
|
if (frame && ancestorFrame) {
|
||||||
|
nsPoint point = frame->GetOffsetTo(ancestorFrame);
|
||||||
|
x = nsPresContext::AppUnitsToFloatCSSPixels(point.x);
|
||||||
|
y = nsPresContext::AppUnitsToFloatCSSPixels(point.y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return matrix * gfxMatrix().Translate(gfxPoint(x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
nsSVGDisplayContainerFrame*
|
nsSVGDisplayContainerFrame*
|
||||||
|
@ -574,33 +561,6 @@ nsSVGUtils::GetNearestSVGViewport(nsIFrame *aFrame)
|
||||||
return nsnull;
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsSVGUtils::GetFarthestViewportElement(nsIContent *aContent,
|
|
||||||
nsIDOMSVGElement * *aFarthestViewportElement)
|
|
||||||
{
|
|
||||||
*aFarthestViewportElement = nsnull;
|
|
||||||
|
|
||||||
nsIContent *ancestor = GetParentElement(aContent);
|
|
||||||
nsCOMPtr<nsIDOMSVGElement> element;
|
|
||||||
|
|
||||||
while (ancestor && ancestor->GetNameSpaceID() == kNameSpaceID_SVG &&
|
|
||||||
ancestor->Tag() != nsGkAtoms::foreignObject) {
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMSVGFitToViewBox> fitToViewBox = do_QueryInterface(ancestor);
|
|
||||||
|
|
||||||
if (fitToViewBox) {
|
|
||||||
// right interface
|
|
||||||
element = do_QueryInterface(ancestor);
|
|
||||||
}
|
|
||||||
|
|
||||||
ancestor = GetParentElement(ancestor);
|
|
||||||
}
|
|
||||||
|
|
||||||
element.swap(*aFarthestViewportElement);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsRect
|
nsRect
|
||||||
nsSVGUtils::FindFilterInvalidation(nsIFrame *aFrame, const nsRect& aRect)
|
nsSVGUtils::FindFilterInvalidation(nsIFrame *aFrame, const nsRect& aRect)
|
||||||
{
|
{
|
||||||
|
@ -805,7 +765,7 @@ nsSVGUtils::GetOuterSVGFrameAndCoveredRegion(nsIFrame* aFrame, nsRect* aRect)
|
||||||
return GetOuterSVGFrame(aFrame);
|
return GetOuterSVGFrame(aFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<nsIDOMSVGMatrix>
|
gfxMatrix
|
||||||
nsSVGUtils::GetViewBoxTransform(float aViewportWidth, float aViewportHeight,
|
nsSVGUtils::GetViewBoxTransform(float aViewportWidth, float aViewportHeight,
|
||||||
float aViewboxX, float aViewboxY,
|
float aViewboxX, float aViewboxY,
|
||||||
float aViewboxWidth, float aViewboxHeight,
|
float aViewboxWidth, float aViewboxHeight,
|
||||||
|
@ -891,9 +851,7 @@ nsSVGUtils::GetViewBoxTransform(float aViewportWidth, float aViewportHeight,
|
||||||
if (aViewboxX) e += -a * aViewboxX;
|
if (aViewboxX) e += -a * aViewboxX;
|
||||||
if (aViewboxY) f += -d * aViewboxY;
|
if (aViewboxY) f += -d * aViewboxY;
|
||||||
|
|
||||||
nsIDOMSVGMatrix *retval;
|
return gfxMatrix(a, 0.0f, 0.0f, d, e, f);
|
||||||
NS_NewSVGMatrix(&retval, a, 0.0f, 0.0f, d, e, f);
|
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gfxMatrix
|
gfxMatrix
|
||||||
|
@ -902,8 +860,7 @@ nsSVGUtils::GetCanvasTM(nsIFrame *aFrame)
|
||||||
// XXX yuck, we really need a common interface for GetCanvasTM
|
// XXX yuck, we really need a common interface for GetCanvasTM
|
||||||
|
|
||||||
if (!aFrame->IsFrameOfType(nsIFrame::eSVG)) {
|
if (!aFrame->IsFrameOfType(nsIFrame::eSVG)) {
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> matrix = nsSVGIntegrationUtils::GetInitialMatrix(aFrame);
|
return nsSVGIntegrationUtils::GetInitialMatrix(aFrame);
|
||||||
return ConvertSVGMatrixToThebes(matrix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIAtom* type = aFrame->GetType();
|
nsIAtom* type = aFrame->GetType();
|
||||||
|
@ -1038,8 +995,9 @@ nsSVGUtils::PaintFrameWithEffects(nsSVGRenderState *aContext,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> matrix =
|
gfxMatrix matrix;
|
||||||
(clipPathFrame || maskFrame) ? NS_NewSVGMatrix(GetCanvasTM(aFrame)) : nsnull;
|
if (clipPathFrame || maskFrame)
|
||||||
|
matrix = GetCanvasTM(aFrame);
|
||||||
|
|
||||||
/* Check if we need to do additional operations on this child's
|
/* Check if we need to do additional operations on this child's
|
||||||
* rendering, which necessitates rendering into another surface. */
|
* rendering, which necessitates rendering into another surface. */
|
||||||
|
@ -1122,8 +1080,7 @@ nsSVGUtils::HitTestClip(nsIFrame *aFrame, const nsPoint &aPoint)
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> matrix = NS_NewSVGMatrix(GetCanvasTM(aFrame));
|
return clipPathFrame->ClipHitTest(aFrame, GetCanvasTM(aFrame), aPoint);
|
||||||
return clipPathFrame->ClipHitTest(aFrame, matrix, aPoint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIFrame *
|
nsIFrame *
|
||||||
|
@ -1274,25 +1231,19 @@ nsSVGUtils::ConvertSVGMatrixToThebes(nsIDOMSVGMatrix *aMatrix)
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool
|
PRBool
|
||||||
nsSVGUtils::HitTestRect(nsIDOMSVGMatrix *aMatrix,
|
nsSVGUtils::HitTestRect(const gfxMatrix &aMatrix,
|
||||||
float aRX, float aRY, float aRWidth, float aRHeight,
|
float aRX, float aRY, float aRWidth, float aRHeight,
|
||||||
float aX, float aY)
|
float aX, float aY)
|
||||||
{
|
{
|
||||||
PRBool result = PR_TRUE;
|
if (aMatrix.IsSingular()) {
|
||||||
|
return PR_FALSE;
|
||||||
if (aMatrix) {
|
|
||||||
gfxContext ctx(GetThebesComputationalSurface());
|
|
||||||
ctx.SetMatrix(ConvertSVGMatrixToThebes(aMatrix));
|
|
||||||
|
|
||||||
ctx.NewPath();
|
|
||||||
ctx.Rectangle(gfxRect(aRX, aRY, aRWidth, aRHeight));
|
|
||||||
ctx.IdentityMatrix();
|
|
||||||
|
|
||||||
if (!ctx.PointInFill(gfxPoint(aX, aY)))
|
|
||||||
result = PR_FALSE;
|
|
||||||
}
|
}
|
||||||
|
gfxContext ctx(GetThebesComputationalSurface());
|
||||||
return result;
|
ctx.SetMatrix(aMatrix);
|
||||||
|
ctx.NewPath();
|
||||||
|
ctx.Rectangle(gfxRect(aRX, aRY, aRWidth, aRHeight));
|
||||||
|
ctx.IdentityMatrix();
|
||||||
|
return ctx.PointInFill(gfxPoint(aX, aY));
|
||||||
}
|
}
|
||||||
|
|
||||||
gfxRect
|
gfxRect
|
||||||
|
@ -1339,40 +1290,31 @@ nsSVGUtils::GetClipRectForFrame(nsIFrame *aFrame,
|
||||||
void
|
void
|
||||||
nsSVGUtils::CompositeSurfaceMatrix(gfxContext *aContext,
|
nsSVGUtils::CompositeSurfaceMatrix(gfxContext *aContext,
|
||||||
gfxASurface *aSurface,
|
gfxASurface *aSurface,
|
||||||
nsIDOMSVGMatrix *aCTM, float aOpacity)
|
const gfxMatrix &aCTM, float aOpacity)
|
||||||
{
|
{
|
||||||
gfxMatrix matrix = ConvertSVGMatrixToThebes(aCTM);
|
if (aCTM.IsSingular())
|
||||||
if (matrix.IsSingular())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
aContext->Save();
|
aContext->Save();
|
||||||
|
aContext->Multiply(aCTM);
|
||||||
aContext->Multiply(matrix);
|
|
||||||
|
|
||||||
aContext->SetSource(aSurface);
|
aContext->SetSource(aSurface);
|
||||||
aContext->Paint(aOpacity);
|
aContext->Paint(aOpacity);
|
||||||
|
|
||||||
aContext->Restore();
|
aContext->Restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nsSVGUtils::CompositePatternMatrix(gfxContext *aContext,
|
nsSVGUtils::CompositePatternMatrix(gfxContext *aContext,
|
||||||
gfxPattern *aPattern,
|
gfxPattern *aPattern,
|
||||||
nsIDOMSVGMatrix *aCTM, float aWidth, float aHeight, float aOpacity)
|
const gfxMatrix &aCTM, float aWidth, float aHeight, float aOpacity)
|
||||||
{
|
{
|
||||||
gfxMatrix matrix = ConvertSVGMatrixToThebes(aCTM);
|
if (aCTM.IsSingular())
|
||||||
if (matrix.IsSingular())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
aContext->Save();
|
aContext->Save();
|
||||||
|
SetClipRect(aContext, aCTM, gfxRect(0, 0, aWidth, aHeight));
|
||||||
SetClipRect(aContext, ConvertSVGMatrixToThebes(aCTM), gfxRect(0, 0, aWidth, aHeight));
|
aContext->Multiply(aCTM);
|
||||||
|
|
||||||
aContext->Multiply(matrix);
|
|
||||||
|
|
||||||
aContext->SetPattern(aPattern);
|
aContext->SetPattern(aPattern);
|
||||||
aContext->Paint(aOpacity);
|
aContext->Paint(aOpacity);
|
||||||
|
|
||||||
aContext->Restore();
|
aContext->Restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1461,40 +1403,34 @@ nsSVGUtils::CanOptimizeOpacity(nsIFrame *aFrame)
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
nsSVGUtils::MaxExpansion(nsIDOMSVGMatrix *aMatrix)
|
nsSVGUtils::MaxExpansion(const gfxMatrix &aMatrix)
|
||||||
{
|
{
|
||||||
float a, b, c, d;
|
|
||||||
aMatrix->GetA(&a);
|
|
||||||
aMatrix->GetB(&b);
|
|
||||||
aMatrix->GetC(&c);
|
|
||||||
aMatrix->GetD(&d);
|
|
||||||
|
|
||||||
// maximum expansion derivation from
|
// maximum expansion derivation from
|
||||||
// http://lists.cairographics.org/archives/cairo/2004-October/001980.html
|
// http://lists.cairographics.org/archives/cairo/2004-October/001980.html
|
||||||
float f = (a * a + b * b + c * c + d * d) / 2;
|
// and also implemented in cairo_matrix_transformed_circle_major_axis
|
||||||
float g = (a * a + b * b - c * c - d * d) / 2;
|
double a = aMatrix.xx;
|
||||||
float h = a * c + b * d;
|
double b = aMatrix.yx;
|
||||||
|
double c = aMatrix.xy;
|
||||||
|
double d = aMatrix.yy;
|
||||||
|
double f = (a * a + b * b + c * c + d * d) / 2;
|
||||||
|
double g = (a * a + b * b - c * c - d * d) / 2;
|
||||||
|
double h = a * c + b * d;
|
||||||
return sqrt(f + sqrt(g * g + h * h));
|
return sqrt(f + sqrt(g * g + h * h));
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<nsIDOMSVGMatrix>
|
gfxMatrix
|
||||||
nsSVGUtils::AdjustMatrixForUnits(nsIDOMSVGMatrix *aMatrix,
|
nsSVGUtils::AdjustMatrixForUnits(const gfxMatrix &aMatrix,
|
||||||
nsSVGEnum *aUnits,
|
nsSVGEnum *aUnits,
|
||||||
nsIFrame *aFrame)
|
nsIFrame *aFrame)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> fini = aMatrix;
|
|
||||||
|
|
||||||
if (aFrame &&
|
if (aFrame &&
|
||||||
aUnits->GetAnimValue() == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
|
aUnits->GetAnimValue() == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
|
||||||
gfxRect bbox = GetBBox(aFrame);
|
gfxRect bbox = GetBBox(aFrame);
|
||||||
nsCOMPtr<nsIDOMSVGMatrix> tmp;
|
return gfxMatrix().Scale(bbox.Width(), bbox.Height()) *
|
||||||
aMatrix->Translate(bbox.X(), bbox.Y(), getter_AddRefs(tmp));
|
gfxMatrix().Translate(gfxPoint(bbox.X(), bbox.Y())) *
|
||||||
tmp->ScaleNonUniform(bbox.Width(), bbox.Height(), getter_AddRefs(fini));
|
aMatrix;
|
||||||
}
|
}
|
||||||
|
return aMatrix;
|
||||||
nsIDOMSVGMatrix* retval = fini.get();
|
|
||||||
NS_IF_ADDREF(retval);
|
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIFrame*
|
nsIFrame*
|
||||||
|
@ -1567,6 +1503,17 @@ nsSVGUtils::PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents,
|
||||||
return strokeExtents;
|
return strokeExtents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* static */ PRBool
|
||||||
|
nsSVGUtils::IsInnerSVG(nsIContent* aContent)
|
||||||
|
{
|
||||||
|
if (!aContent->NodeInfo()->Equals(nsGkAtoms::svg, kNameSpaceID_SVG)) {
|
||||||
|
return PR_FALSE;
|
||||||
|
}
|
||||||
|
nsIContent *ancestor = GetParentElement(aContent);
|
||||||
|
return ancestor && ancestor->GetNameSpaceID() == kNameSpaceID_SVG &&
|
||||||
|
ancestor->Tag() != nsGkAtoms::foreignObject;
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
nsSVGRenderState::nsSVGRenderState(nsIRenderingContext *aContext) :
|
nsSVGRenderState::nsSVGRenderState(nsIRenderingContext *aContext) :
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#include "nsIRenderingContext.h"
|
#include "nsIRenderingContext.h"
|
||||||
#include "gfxRect.h"
|
#include "gfxRect.h"
|
||||||
#include "gfxMatrix.h"
|
#include "gfxMatrix.h"
|
||||||
|
#include "nsSVGMatrix.h"
|
||||||
|
|
||||||
class nsIDocument;
|
class nsIDocument;
|
||||||
class nsPresContext;
|
class nsPresContext;
|
||||||
|
@ -58,7 +59,6 @@ class nsIFrame;
|
||||||
struct nsStyleSVGPaint;
|
struct nsStyleSVGPaint;
|
||||||
class nsIDOMSVGElement;
|
class nsIDOMSVGElement;
|
||||||
class nsIDOMSVGLength;
|
class nsIDOMSVGLength;
|
||||||
class nsIDOMSVGMatrix;
|
|
||||||
class nsIURI;
|
class nsIURI;
|
||||||
class nsSVGOuterSVGFrame;
|
class nsSVGOuterSVGFrame;
|
||||||
class nsIPresShell;
|
class nsIPresShell;
|
||||||
|
@ -251,32 +251,19 @@ public:
|
||||||
nsSVGElement *aContent,
|
nsSVGElement *aContent,
|
||||||
const nsStyleCoord &aCoord);
|
const nsStyleCoord &aCoord);
|
||||||
|
|
||||||
/*
|
static gfxMatrix GetCTM(nsSVGElement *aElement, PRBool aScreenCTM);
|
||||||
* This does the actual job for GetCTM and GetScreenCTM. When called,
|
|
||||||
* this goes up the tree starting from aContent, until reaching to aElement.
|
|
||||||
* When aElement is null, this goes up to the outermost SVG parent. Then,
|
|
||||||
* this post-multiplies aCTM by each parent node's transformation matrix,
|
|
||||||
* going down the tree from aElement to aContent.
|
|
||||||
* This doesn't initialize aCTM. So callers usually should pass
|
|
||||||
* the identity matrix by aCTM.
|
|
||||||
*/
|
|
||||||
static nsresult AppendTransformUptoElement(nsIContent *aContent,
|
|
||||||
nsIDOMSVGElement *aElement,
|
|
||||||
nsIDOMSVGMatrix * *aCTM);
|
|
||||||
/*
|
|
||||||
* Return the CTM
|
|
||||||
*/
|
|
||||||
static nsresult GetCTM(nsIContent *aContent, nsIDOMSVGMatrix * *aCTM);
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Return the screen CTM
|
* Check if this is one of the SVG elements that SVG 1.1 Full says
|
||||||
|
* establishes a viewport: svg, symbol, image or foreignObject.
|
||||||
*/
|
*/
|
||||||
static nsresult GetScreenCTM(nsIContent *aContent, nsIDOMSVGMatrix * *aCTM);
|
static PRBool EstablishesViewport(nsIContent *aContent);
|
||||||
/*
|
|
||||||
* Return the nearest viewport element
|
static already_AddRefed<nsIDOMSVGElement>
|
||||||
*/
|
GetNearestViewportElement(nsIContent *aContent);
|
||||||
static nsresult GetNearestViewportElement(nsIContent *aContent,
|
|
||||||
nsIDOMSVGElement * *aNearestViewportElement);
|
static already_AddRefed<nsIDOMSVGElement>
|
||||||
|
GetFarthestViewportElement(nsIContent *aContent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the nearest nsSVGInnerSVGFrame or nsSVGOuterSVGFrame frame. aFrame
|
* Gets the nearest nsSVGInnerSVGFrame or nsSVGOuterSVGFrame frame. aFrame
|
||||||
|
@ -285,12 +272,6 @@ public:
|
||||||
*/
|
*/
|
||||||
static nsSVGDisplayContainerFrame* GetNearestSVGViewport(nsIFrame *aFrame);
|
static nsSVGDisplayContainerFrame* GetNearestSVGViewport(nsIFrame *aFrame);
|
||||||
|
|
||||||
/*
|
|
||||||
* Get the farthest viewport element
|
|
||||||
*/
|
|
||||||
static nsresult GetFarthestViewportElement(nsIContent *aContent,
|
|
||||||
nsIDOMSVGElement * *aFarthestViewportElement);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Figures out the worst case invalidation area for a frame, taking
|
* Figures out the worst case invalidation area for a frame, taking
|
||||||
* filters into account.
|
* filters into account.
|
||||||
|
@ -361,7 +342,7 @@ public:
|
||||||
|
|
||||||
/* Generate a viewbox to viewport tranformation matrix */
|
/* Generate a viewbox to viewport tranformation matrix */
|
||||||
|
|
||||||
static already_AddRefed<nsIDOMSVGMatrix>
|
static gfxMatrix
|
||||||
GetViewBoxTransform(float aViewportWidth, float aViewportHeight,
|
GetViewBoxTransform(float aViewportWidth, float aViewportHeight,
|
||||||
float aViewboxX, float aViewboxY,
|
float aViewboxX, float aViewboxY,
|
||||||
float aViewboxWidth, float aViewboxHeight,
|
float aViewboxWidth, float aViewboxHeight,
|
||||||
|
@ -441,7 +422,7 @@ public:
|
||||||
* Hit test a given rectangle/matrix.
|
* Hit test a given rectangle/matrix.
|
||||||
*/
|
*/
|
||||||
static PRBool
|
static PRBool
|
||||||
HitTestRect(nsIDOMSVGMatrix *aMatrix,
|
HitTestRect(const gfxMatrix &aMatrix,
|
||||||
float aRX, float aRY, float aRWidth, float aRHeight,
|
float aRX, float aRY, float aRWidth, float aRHeight,
|
||||||
float aX, float aY);
|
float aX, float aY);
|
||||||
|
|
||||||
|
@ -459,11 +440,11 @@ public:
|
||||||
|
|
||||||
static void CompositeSurfaceMatrix(gfxContext *aContext,
|
static void CompositeSurfaceMatrix(gfxContext *aContext,
|
||||||
gfxASurface *aSurface,
|
gfxASurface *aSurface,
|
||||||
nsIDOMSVGMatrix *aCTM, float aOpacity);
|
const gfxMatrix &aCTM, float aOpacity);
|
||||||
|
|
||||||
static void CompositePatternMatrix(gfxContext *aContext,
|
static void CompositePatternMatrix(gfxContext *aContext,
|
||||||
gfxPattern *aPattern,
|
gfxPattern *aPattern,
|
||||||
nsIDOMSVGMatrix *aCTM, float aWidth, float aHeight, float aOpacity);
|
const gfxMatrix &aCTM, float aWidth, float aHeight, float aOpacity);
|
||||||
|
|
||||||
static void SetClipRect(gfxContext *aContext,
|
static void SetClipRect(gfxContext *aContext,
|
||||||
const gfxMatrix &aCTM,
|
const gfxMatrix &aCTM,
|
||||||
|
@ -491,7 +472,7 @@ public:
|
||||||
|
|
||||||
/* Calculate the maximum expansion of a matrix */
|
/* Calculate the maximum expansion of a matrix */
|
||||||
static float
|
static float
|
||||||
MaxExpansion(nsIDOMSVGMatrix *aMatrix);
|
MaxExpansion(const gfxMatrix &aMatrix);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Take the CTM to userspace for an element, and adjust it to a CTM to its
|
* Take the CTM to userspace for an element, and adjust it to a CTM to its
|
||||||
|
@ -501,8 +482,8 @@ public:
|
||||||
*
|
*
|
||||||
* If the bbox is empty, this will return a singular matrix.
|
* If the bbox is empty, this will return a singular matrix.
|
||||||
*/
|
*/
|
||||||
static already_AddRefed<nsIDOMSVGMatrix>
|
static gfxMatrix
|
||||||
AdjustMatrixForUnits(nsIDOMSVGMatrix *aMatrix,
|
AdjustMatrixForUnits(const gfxMatrix &aMatrix,
|
||||||
nsSVGEnum *aUnits,
|
nsSVGEnum *aUnits,
|
||||||
nsIFrame *aFrame);
|
nsIFrame *aFrame);
|
||||||
|
|
||||||
|
@ -551,6 +532,12 @@ public:
|
||||||
static gfxRect PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents,
|
static gfxRect PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents,
|
||||||
nsSVGGeometryFrame* aFrame);
|
nsSVGGeometryFrame* aFrame);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if aContent is an SVG <svg> element that is the child of
|
||||||
|
* another non-foreignObject SVG element.
|
||||||
|
*/
|
||||||
|
static PRBool IsInnerSVG(nsIContent* aContent);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* Computational (nil) surfaces */
|
/* Computational (nil) surfaces */
|
||||||
static gfxASurface *mThebesComputationalSurface;
|
static gfxASurface *mThebesComputationalSurface;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче