Bug 984280 - Convert DOMSVGPoint from Thebes to Moz2d. r=heycam

This commit is contained in:
Jonathan Watt 2014-03-19 09:13:18 +08:00
parent 831522a3e6
commit c47047aab1
3 changed files with 9 additions and 16 deletions

View File

@ -6,6 +6,7 @@
#include "DOMSVGPoint.h"
#include "DOMSVGPointList.h"
#include "SVGPoint.h"
#include "gfx2DGlue.h"
#include "nsSVGElement.h"
#include "nsError.h"
#include "mozilla/dom/SVGMatrix.h"
@ -13,6 +14,7 @@
// See the architecture comment in DOMSVGPointList.h.
using namespace mozilla;
using namespace mozilla::gfx;
namespace mozilla {
@ -112,7 +114,7 @@ DOMSVGPoint::MatrixTransform(dom::SVGMatrix& matrix)
float x = HasOwner() ? InternalItem().mX : mPt.mX;
float y = HasOwner() ? InternalItem().mY : mPt.mY;
gfxPoint pt = matrix.GetMatrix().Transform(gfxPoint(x, y));
Point pt = ToMatrix(matrix.GetMatrix()) * Point(x, y);
nsCOMPtr<nsISVGPoint> newPoint = new DOMSVGPoint(pt);
return newPoint.forget();
}

View File

@ -7,7 +7,6 @@
#define MOZILLA_DOMSVGPOINT_H__
#include "DOMSVGPointList.h"
#include "gfxPoint.h"
#include "mozilla/gfx/2D.h"
#include "nsAutoPtr.h"
#include "nsDebug.h"
@ -87,15 +86,6 @@ public:
"DOMSVGPoint coords are not finite");
}
explicit DOMSVGPoint(const gfxPoint &aPt)
: nsISVGPoint()
{
mPt.mX = float(aPt.x);
mPt.mY = float(aPt.y);
NS_ASSERTION(NS_finite(mPt.mX) && NS_finite(mPt.mX),
"DOMSVGPoint coords are not finite");
}
// WebIDL
virtual float X();

View File

@ -4152,7 +4152,8 @@ SVGTextFrame::GetStartPositionOfChar(nsIContent* aContent,
// We need to return the start position of the whole glyph.
uint32_t startIndex = it.GlyphStartTextElementCharIndex();
NS_ADDREF(*aResult = new DOMSVGPoint(mPositions[startIndex].mPosition));
NS_ADDREF(*aResult =
new DOMSVGPoint(ToPoint(mPositions[startIndex].mPosition)));
return NS_OK;
}
@ -4184,10 +4185,10 @@ SVGTextFrame::GetEndPositionOfChar(nsIContent* aContent,
// The end position is the start position plus the advance in the direction
// of the glyph's rotation.
gfxMatrix m;
m.Translate(mPositions[startIndex].mPosition);
m.Rotate(mPositions[startIndex].mAngle);
gfxPoint p = m.Transform(gfxPoint(advance / mFontSizeScaleFactor, 0));
Matrix m =
Matrix::Rotation(mPositions[startIndex].mAngle) *
Matrix::Translation(ToPoint(mPositions[startIndex].mPosition));
Point p = m * Point(advance / mFontSizeScaleFactor, 0);
NS_ADDREF(*aResult = new DOMSVGPoint(p));
return NS_OK;