mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 828715 - Move DOMSVGMatrix to mozilla::dom::SVGMatrix r=longsonr
--HG-- rename : content/svg/content/src/DOMSVGMatrix.cpp => content/svg/content/src/SVGMatrix.cpp rename : content/svg/content/src/DOMSVGMatrix.h => content/svg/content/src/SVGMatrix.h
This commit is contained in:
parent
37313b9bf0
commit
6f81fa5b99
@ -10,7 +10,7 @@
|
||||
#include "nsSVGElement.h"
|
||||
#include "nsError.h"
|
||||
#include "nsContentUtils.h" // NS_ENSURE_FINITE
|
||||
#include "DOMSVGMatrix.h"
|
||||
#include "mozilla/dom/SVGMatrix.h"
|
||||
#include "mozilla/dom/SVGPointBinding.h"
|
||||
|
||||
// See the architecture comment in DOMSVGPointList.h.
|
||||
@ -115,7 +115,7 @@ DOMSVGPoint::SetY(float aY, ErrorResult& rv)
|
||||
}
|
||||
|
||||
already_AddRefed<nsISVGPoint>
|
||||
DOMSVGPoint::MatrixTransform(DOMSVGMatrix& matrix)
|
||||
DOMSVGPoint::MatrixTransform(dom::SVGMatrix& matrix)
|
||||
{
|
||||
float x = HasOwner() ? InternalItem().mX : mPt.mX;
|
||||
float y = HasOwner() ? InternalItem().mY : mPt.mY;
|
||||
|
@ -32,7 +32,9 @@ class nsSVGElement;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class DOMSVGMatrix;
|
||||
namespace dom {
|
||||
class SVGMatrix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class DOMSVGPoint
|
||||
@ -125,7 +127,7 @@ public:
|
||||
virtual void SetX(float aX, ErrorResult& rv);
|
||||
virtual float Y();
|
||||
virtual void SetY(float aY, ErrorResult& rv);
|
||||
virtual already_AddRefed<nsISVGPoint> MatrixTransform(DOMSVGMatrix& matrix);
|
||||
virtual already_AddRefed<nsISVGPoint> MatrixTransform(dom::SVGMatrix& matrix);
|
||||
nsISupports* GetParentObject() MOZ_OVERRIDE {
|
||||
return mList;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "DOMSVGTransform.h"
|
||||
#include "DOMSVGMatrix.h"
|
||||
#include "mozilla/dom/SVGMatrix.h"
|
||||
#include "SVGAnimatedTransformList.h"
|
||||
#include "nsError.h"
|
||||
#include <math.h>
|
||||
@ -16,7 +16,9 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
static nsSVGAttrTearoffTable<DOMSVGTransform, DOMSVGMatrix> sSVGMatrixTearoffTable;
|
||||
using namespace dom;
|
||||
|
||||
static nsSVGAttrTearoffTable<DOMSVGTransform, SVGMatrix> sSVGMatrixTearoffTable;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods:
|
||||
@ -125,13 +127,13 @@ DOMSVGTransform::Type() const
|
||||
return Transform().Type();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGMatrix>
|
||||
already_AddRefed<SVGMatrix>
|
||||
DOMSVGTransform::Matrix()
|
||||
{
|
||||
nsRefPtr<DOMSVGMatrix> wrapper =
|
||||
nsRefPtr<SVGMatrix> wrapper =
|
||||
sSVGMatrixTearoffTable.GetTearoff(this);
|
||||
if (!wrapper) {
|
||||
wrapper = new DOMSVGMatrix(*this);
|
||||
wrapper = new SVGMatrix(*this);
|
||||
sSVGMatrixTearoffTable.AddTearoff(this, wrapper);
|
||||
}
|
||||
return wrapper.forget();
|
||||
@ -144,7 +146,7 @@ DOMSVGTransform::Angle() const
|
||||
}
|
||||
|
||||
void
|
||||
DOMSVGTransform::SetMatrix(DOMSVGMatrix& aMatrix, ErrorResult& rv)
|
||||
DOMSVGTransform::SetMatrix(SVGMatrix& aMatrix, ErrorResult& rv)
|
||||
{
|
||||
if (mIsAnimValItem) {
|
||||
rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
||||
@ -311,7 +313,7 @@ DOMSVGTransform::IndexIsValid()
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Interface for DOMSVGMatrix's use
|
||||
// Interface for SVGMatrix's use
|
||||
|
||||
void
|
||||
DOMSVGTransform::SetMatrix(const gfxMatrix& aMatrix)
|
||||
|
@ -34,7 +34,9 @@ struct gfxMatrix;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class DOMSVGMatrix;
|
||||
namespace dom {
|
||||
class SVGMatrix;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOM wrapper for an SVG transform. See DOMSVGLength.h.
|
||||
@ -131,9 +133,9 @@ public:
|
||||
DOMSVGTransformList* GetParentObject() const { return mList; }
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope, bool* aTriedToWrap);
|
||||
uint16_t Type() const;
|
||||
already_AddRefed<DOMSVGMatrix> Matrix();
|
||||
already_AddRefed<dom::SVGMatrix> Matrix();
|
||||
float Angle() const;
|
||||
void SetMatrix(DOMSVGMatrix& matrix, ErrorResult& rv);
|
||||
void SetMatrix(dom::SVGMatrix& matrix, ErrorResult& rv);
|
||||
void SetTranslate(float tx, float ty, ErrorResult& rv);
|
||||
void SetScale(float sx, float sy, ErrorResult& rv);
|
||||
void SetRotate(float angle, float cx, float cy, ErrorResult& rv);
|
||||
@ -141,8 +143,8 @@ public:
|
||||
void SetSkewY(float angle, ErrorResult& rv);
|
||||
|
||||
protected:
|
||||
// Interface for DOMSVGMatrix's use
|
||||
friend class DOMSVGMatrix;
|
||||
// Interface for SVGMatrix's use
|
||||
friend class dom::SVGMatrix;
|
||||
const bool IsAnimVal() const {
|
||||
return mIsAnimValItem;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include "DOMSVGTransformList.h"
|
||||
#include "DOMSVGTransform.h"
|
||||
#include "DOMSVGMatrix.h"
|
||||
#include "mozilla/dom/SVGMatrix.h"
|
||||
#include "SVGAnimatedTransformList.h"
|
||||
#include "nsSVGElement.h"
|
||||
#include "nsContentUtils.h"
|
||||
@ -316,7 +316,7 @@ DOMSVGTransformList::RemoveItem(uint32_t index, ErrorResult& error)
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGTransform>
|
||||
DOMSVGTransformList::CreateSVGTransformFromMatrix(DOMSVGMatrix& matrix)
|
||||
DOMSVGTransformList::CreateSVGTransformFromMatrix(dom::SVGMatrix& matrix)
|
||||
{
|
||||
nsCOMPtr<DOMSVGTransform> result = new DOMSVGTransform(matrix.Matrix());
|
||||
return result.forget();
|
||||
|
@ -21,7 +21,10 @@ class nsSVGElement;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class DOMSVGMatrix;
|
||||
namespace dom {
|
||||
class SVGMatrix;
|
||||
}
|
||||
|
||||
class DOMSVGTransform;
|
||||
|
||||
/**
|
||||
@ -120,7 +123,7 @@ public:
|
||||
{
|
||||
return InsertItemBefore(newItem, LengthNoFlush(), error);
|
||||
}
|
||||
already_AddRefed<DOMSVGTransform> CreateSVGTransformFromMatrix(DOMSVGMatrix& matrix);
|
||||
already_AddRefed<DOMSVGTransform> CreateSVGTransformFromMatrix(dom::SVGMatrix& matrix);
|
||||
already_AddRefed<DOMSVGTransform> Consolidate(ErrorResult& error);
|
||||
uint32_t Length() const
|
||||
{
|
||||
|
@ -23,7 +23,6 @@ CPPSRCS = \
|
||||
DOMSVGAnimatedTransformList.cpp \
|
||||
DOMSVGLength.cpp \
|
||||
DOMSVGLengthList.cpp \
|
||||
DOMSVGMatrix.cpp \
|
||||
DOMSVGNumber.cpp \
|
||||
DOMSVGNumberList.cpp \
|
||||
DOMSVGPathSeg.cpp \
|
||||
@ -98,6 +97,7 @@ CPPSRCS = \
|
||||
SVGLengthListSMILType.cpp \
|
||||
SVGLineElement.cpp \
|
||||
SVGLocatableElement.cpp \
|
||||
SVGMatrix.cpp \
|
||||
SVGMetadataElement.cpp \
|
||||
SVGMotionSMILType.cpp \
|
||||
SVGMotionSMILAttr.cpp \
|
||||
@ -173,6 +173,7 @@ EXPORTS_mozilla/dom = \
|
||||
SVGImageElement.h \
|
||||
SVGLineElement.h \
|
||||
SVGLocatableElement.h \
|
||||
SVGMatrix.h \
|
||||
SVGMetadataElement.h \
|
||||
SVGMPathElement.h \
|
||||
SVGPolygonElement.h \
|
||||
|
@ -2,13 +2,13 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "SVGLocatableElement.h"
|
||||
#include "DOMSVGMatrix.h"
|
||||
#include "mozilla/dom/SVGLocatableElement.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsISVGChildFrame.h"
|
||||
#include "nsSVGRect.h"
|
||||
#include "nsSVGUtils.h"
|
||||
#include "SVGContentUtils.h"
|
||||
#include "mozilla/dom/SVGMatrix.h"
|
||||
#include "mozilla/dom/SVGSVGElement.h"
|
||||
|
||||
namespace mozilla {
|
||||
@ -87,7 +87,7 @@ SVGLocatableElement::GetBBox(ErrorResult& rv)
|
||||
return rect.forget();
|
||||
}
|
||||
|
||||
/* DOMSVGMatrix getCTM (); */
|
||||
/* SVGMatrix getCTM (); */
|
||||
NS_IMETHODIMP
|
||||
SVGLocatableElement::GetCTM(nsISupports * *aCTM)
|
||||
{
|
||||
@ -95,15 +95,15 @@ SVGLocatableElement::GetCTM(nsISupports * *aCTM)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGMatrix>
|
||||
already_AddRefed<SVGMatrix>
|
||||
SVGLocatableElement::GetCTM()
|
||||
{
|
||||
gfxMatrix m = SVGContentUtils::GetCTM(this, false);
|
||||
nsCOMPtr<DOMSVGMatrix> mat = m.IsSingular() ? nullptr : new DOMSVGMatrix(m);
|
||||
nsCOMPtr<SVGMatrix> mat = m.IsSingular() ? nullptr : new SVGMatrix(m);
|
||||
return mat.forget();
|
||||
}
|
||||
|
||||
/* DOMSVGMatrix getScreenCTM (); */
|
||||
/* SVGMatrix getScreenCTM (); */
|
||||
NS_IMETHODIMP
|
||||
SVGLocatableElement::GetScreenCTM(nsISupports * *aCTM)
|
||||
{
|
||||
@ -111,15 +111,15 @@ SVGLocatableElement::GetScreenCTM(nsISupports * *aCTM)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGMatrix>
|
||||
already_AddRefed<SVGMatrix>
|
||||
SVGLocatableElement::GetScreenCTM()
|
||||
{
|
||||
gfxMatrix m = SVGContentUtils::GetCTM(this, true);
|
||||
nsCOMPtr<DOMSVGMatrix> mat = m.IsSingular() ? nullptr : new DOMSVGMatrix(m);
|
||||
nsCOMPtr<SVGMatrix> mat = m.IsSingular() ? nullptr : new SVGMatrix(m);
|
||||
return mat.forget();
|
||||
}
|
||||
|
||||
/* DOMSVGMatrix getTransformToElement (in nsIDOMSVGElement element); */
|
||||
/* SVGMatrix getTransformToElement (in nsIDOMSVGElement element); */
|
||||
NS_IMETHODIMP
|
||||
SVGLocatableElement::GetTransformToElement(nsIDOMSVGElement *element,
|
||||
nsISupports **_retval)
|
||||
@ -132,7 +132,7 @@ SVGLocatableElement::GetTransformToElement(nsIDOMSVGElement *element,
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGMatrix>
|
||||
already_AddRefed<SVGMatrix>
|
||||
SVGLocatableElement::GetTransformToElement(nsSVGElement& aElement,
|
||||
ErrorResult& rv)
|
||||
{
|
||||
@ -143,17 +143,17 @@ SVGLocatableElement::GetTransformToElement(nsSVGElement& aElement,
|
||||
}
|
||||
|
||||
// the easiest way to do this (if likely to increase rounding error):
|
||||
nsCOMPtr<DOMSVGMatrix> ourScreenCTM = GetScreenCTM();
|
||||
nsCOMPtr<DOMSVGMatrix> targetScreenCTM;
|
||||
nsCOMPtr<SVGMatrix> ourScreenCTM = GetScreenCTM();
|
||||
nsCOMPtr<SVGMatrix> targetScreenCTM;
|
||||
target->GetScreenCTM(getter_AddRefs(targetScreenCTM));
|
||||
if (!ourScreenCTM || !targetScreenCTM) {
|
||||
rv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
nsCOMPtr<DOMSVGMatrix> tmp = targetScreenCTM->Inverse(rv);
|
||||
nsCOMPtr<SVGMatrix> tmp = targetScreenCTM->Inverse(rv);
|
||||
if (rv.Failed()) return nullptr;
|
||||
|
||||
nsCOMPtr<DOMSVGMatrix> mat = tmp->Multiply(*ourScreenCTM).get();
|
||||
nsCOMPtr<SVGMatrix> mat = tmp->Multiply(*ourScreenCTM).get();
|
||||
return mat.forget();
|
||||
}
|
||||
|
||||
|
@ -14,9 +14,10 @@
|
||||
{0x89, 0xec, 0xe6, 0x69, 0x6c, 0xb7, 0xb8, 0xb3} }
|
||||
|
||||
namespace mozilla {
|
||||
class DOMSVGMatrix;
|
||||
|
||||
namespace dom {
|
||||
class SVGMatrix;
|
||||
|
||||
class SVGLocatableElement : public nsSVGElement,
|
||||
public nsIDOMSVGLocatable
|
||||
{
|
||||
@ -33,10 +34,10 @@ public:
|
||||
nsSVGElement* GetNearestViewportElement();
|
||||
nsSVGElement* GetFarthestViewportElement();
|
||||
already_AddRefed<nsIDOMSVGRect> GetBBox(ErrorResult& rv);
|
||||
already_AddRefed<DOMSVGMatrix> GetCTM();
|
||||
already_AddRefed<DOMSVGMatrix> GetScreenCTM();
|
||||
already_AddRefed<DOMSVGMatrix> GetTransformToElement(nsSVGElement& aElement,
|
||||
ErrorResult& rv);
|
||||
already_AddRefed<SVGMatrix> GetCTM();
|
||||
already_AddRefed<SVGMatrix> GetScreenCTM();
|
||||
already_AddRefed<SVGMatrix> GetTransformToElement(nsSVGElement& aElement,
|
||||
ErrorResult& rv);
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(SVGLocatableElement,
|
||||
|
@ -4,7 +4,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "DOMSVGMatrix.h"
|
||||
#include "mozilla/dom/SVGMatrix.h"
|
||||
#include "nsError.h"
|
||||
#include <math.h>
|
||||
#include "nsContentUtils.h"
|
||||
@ -13,50 +13,49 @@
|
||||
const double radPerDegree = 2.0 * M_PI / 360.0;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods:
|
||||
|
||||
// Make sure we clear the weak ref in the owning transform (if there is one)
|
||||
// upon unlink.
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(DOMSVGMatrix)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(DOMSVGMatrix)
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(SVGMatrix)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(SVGMatrix)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mTransform)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(DOMSVGMatrix)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(SVGMatrix)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTransform)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(DOMSVGMatrix)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(SVGMatrix)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMSVGMatrix)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMSVGMatrix)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(SVGMatrix)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(SVGMatrix)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMSVGMatrix)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SVGMatrix)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(mozilla::DOMSVGMatrix) // pseudo-interface
|
||||
NS_INTERFACE_MAP_ENTRY(mozilla::dom::SVGMatrix) // pseudo-interface
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
DOMSVGTransform*
|
||||
DOMSVGMatrix::GetParentObject() const
|
||||
SVGMatrix::GetParentObject() const
|
||||
{
|
||||
return mTransform;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
DOMSVGMatrix::WrapObject(JSContext* aCx, JSObject* aScope, bool* aTriedToWrap)
|
||||
SVGMatrix::WrapObject(JSContext* aCx, JSObject* aScope, bool* aTriedToWrap)
|
||||
{
|
||||
return mozilla::dom::SVGMatrixBinding::Wrap(aCx, aScope, this, aTriedToWrap);
|
||||
return SVGMatrixBinding::Wrap(aCx, aScope, this, aTriedToWrap);
|
||||
}
|
||||
|
||||
void
|
||||
DOMSVGMatrix::SetA(float aA, ErrorResult& rv)
|
||||
SVGMatrix::SetA(float aA, ErrorResult& rv)
|
||||
{
|
||||
if (IsAnimVal()) {
|
||||
rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
||||
@ -69,7 +68,7 @@ DOMSVGMatrix::SetA(float aA, ErrorResult& rv)
|
||||
}
|
||||
|
||||
void
|
||||
DOMSVGMatrix::SetB(float aB, ErrorResult& rv)
|
||||
SVGMatrix::SetB(float aB, ErrorResult& rv)
|
||||
{
|
||||
if (IsAnimVal()) {
|
||||
rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
||||
@ -82,7 +81,7 @@ DOMSVGMatrix::SetB(float aB, ErrorResult& rv)
|
||||
}
|
||||
|
||||
void
|
||||
DOMSVGMatrix::SetC(float aC, ErrorResult& rv)
|
||||
SVGMatrix::SetC(float aC, ErrorResult& rv)
|
||||
{
|
||||
if (IsAnimVal()) {
|
||||
rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
||||
@ -95,7 +94,7 @@ DOMSVGMatrix::SetC(float aC, ErrorResult& rv)
|
||||
}
|
||||
|
||||
void
|
||||
DOMSVGMatrix::SetD(float aD, ErrorResult& rv)
|
||||
SVGMatrix::SetD(float aD, ErrorResult& rv)
|
||||
{
|
||||
if (IsAnimVal()) {
|
||||
rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
||||
@ -108,7 +107,7 @@ DOMSVGMatrix::SetD(float aD, ErrorResult& rv)
|
||||
}
|
||||
|
||||
void
|
||||
DOMSVGMatrix::SetE(float aE, ErrorResult& rv)
|
||||
SVGMatrix::SetE(float aE, ErrorResult& rv)
|
||||
{
|
||||
if (IsAnimVal()) {
|
||||
rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
||||
@ -121,7 +120,7 @@ DOMSVGMatrix::SetE(float aE, ErrorResult& rv)
|
||||
}
|
||||
|
||||
void
|
||||
DOMSVGMatrix::SetF(float aF, ErrorResult& rv)
|
||||
SVGMatrix::SetF(float aF, ErrorResult& rv)
|
||||
{
|
||||
if (IsAnimVal()) {
|
||||
rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
||||
@ -133,88 +132,88 @@ DOMSVGMatrix::SetF(float aF, ErrorResult& rv)
|
||||
SetMatrix(mx);
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGMatrix>
|
||||
DOMSVGMatrix::Multiply(DOMSVGMatrix& aMatrix)
|
||||
already_AddRefed<SVGMatrix>
|
||||
SVGMatrix::Multiply(SVGMatrix& aMatrix)
|
||||
{
|
||||
nsCOMPtr<DOMSVGMatrix> matrix = new DOMSVGMatrix(aMatrix.Matrix() * Matrix());
|
||||
nsCOMPtr<SVGMatrix> matrix = new SVGMatrix(aMatrix.Matrix() * Matrix());
|
||||
return matrix.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGMatrix>
|
||||
DOMSVGMatrix::Inverse(ErrorResult& rv)
|
||||
already_AddRefed<SVGMatrix>
|
||||
SVGMatrix::Inverse(ErrorResult& rv)
|
||||
{
|
||||
if (Matrix().IsSingular()) {
|
||||
rv.Throw(NS_ERROR_DOM_SVG_MATRIX_NOT_INVERTABLE);
|
||||
return nullptr;
|
||||
}
|
||||
nsRefPtr<DOMSVGMatrix> matrix = new DOMSVGMatrix(gfxMatrix(Matrix()).Invert());
|
||||
nsRefPtr<SVGMatrix> matrix = new SVGMatrix(gfxMatrix(Matrix()).Invert());
|
||||
return matrix.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGMatrix>
|
||||
DOMSVGMatrix::Translate(float x, float y)
|
||||
already_AddRefed<SVGMatrix>
|
||||
SVGMatrix::Translate(float x, float y)
|
||||
{
|
||||
nsRefPtr<DOMSVGMatrix> matrix =
|
||||
new DOMSVGMatrix(gfxMatrix(Matrix()).Translate(gfxPoint(x, y)));
|
||||
nsRefPtr<SVGMatrix> matrix =
|
||||
new SVGMatrix(gfxMatrix(Matrix()).Translate(gfxPoint(x, y)));
|
||||
return matrix.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGMatrix>
|
||||
DOMSVGMatrix::Scale(float scaleFactor)
|
||||
already_AddRefed<SVGMatrix>
|
||||
SVGMatrix::Scale(float scaleFactor)
|
||||
{
|
||||
return ScaleNonUniform(scaleFactor, scaleFactor);
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGMatrix>
|
||||
DOMSVGMatrix::ScaleNonUniform(float scaleFactorX,
|
||||
float scaleFactorY)
|
||||
already_AddRefed<SVGMatrix>
|
||||
SVGMatrix::ScaleNonUniform(float scaleFactorX,
|
||||
float scaleFactorY)
|
||||
{
|
||||
nsRefPtr<DOMSVGMatrix> matrix =
|
||||
new DOMSVGMatrix(gfxMatrix(Matrix()).Scale(scaleFactorX, scaleFactorY));
|
||||
nsRefPtr<SVGMatrix> matrix =
|
||||
new SVGMatrix(gfxMatrix(Matrix()).Scale(scaleFactorX, scaleFactorY));
|
||||
return matrix.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGMatrix>
|
||||
DOMSVGMatrix::Rotate(float angle)
|
||||
already_AddRefed<SVGMatrix>
|
||||
SVGMatrix::Rotate(float angle)
|
||||
{
|
||||
nsRefPtr<DOMSVGMatrix> matrix =
|
||||
new DOMSVGMatrix(gfxMatrix(Matrix()).Rotate(angle*radPerDegree));
|
||||
nsRefPtr<SVGMatrix> matrix =
|
||||
new SVGMatrix(gfxMatrix(Matrix()).Rotate(angle*radPerDegree));
|
||||
return matrix.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGMatrix>
|
||||
DOMSVGMatrix::RotateFromVector(float x, float y, ErrorResult& rv)
|
||||
already_AddRefed<SVGMatrix>
|
||||
SVGMatrix::RotateFromVector(float x, float y, ErrorResult& rv)
|
||||
{
|
||||
if (x == 0.0 || y == 0.0) {
|
||||
rv.Throw(NS_ERROR_RANGE_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsRefPtr<DOMSVGMatrix> matrix =
|
||||
new DOMSVGMatrix(gfxMatrix(Matrix()).Rotate(atan2(y, x)));
|
||||
nsRefPtr<SVGMatrix> matrix =
|
||||
new SVGMatrix(gfxMatrix(Matrix()).Rotate(atan2(y, x)));
|
||||
return matrix.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGMatrix>
|
||||
DOMSVGMatrix::FlipX()
|
||||
already_AddRefed<SVGMatrix>
|
||||
SVGMatrix::FlipX()
|
||||
{
|
||||
const gfxMatrix& mx = Matrix();
|
||||
nsRefPtr<DOMSVGMatrix> matrix =
|
||||
new DOMSVGMatrix(gfxMatrix(-mx.xx, -mx.yx, mx.xy, mx.yy, mx.x0, mx.y0));
|
||||
nsRefPtr<SVGMatrix> matrix =
|
||||
new SVGMatrix(gfxMatrix(-mx.xx, -mx.yx, mx.xy, mx.yy, mx.x0, mx.y0));
|
||||
return matrix.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGMatrix>
|
||||
DOMSVGMatrix::FlipY()
|
||||
already_AddRefed<SVGMatrix>
|
||||
SVGMatrix::FlipY()
|
||||
{
|
||||
const gfxMatrix& mx = Matrix();
|
||||
nsRefPtr<DOMSVGMatrix> matrix =
|
||||
new DOMSVGMatrix(gfxMatrix(mx.xx, mx.yx, -mx.xy, -mx.yy, mx.x0, mx.y0));
|
||||
nsRefPtr<SVGMatrix> matrix =
|
||||
new SVGMatrix(gfxMatrix(mx.xx, mx.yx, -mx.xy, -mx.yy, mx.x0, mx.y0));
|
||||
return matrix.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGMatrix>
|
||||
DOMSVGMatrix::SkewX(float angle, ErrorResult& rv)
|
||||
already_AddRefed<SVGMatrix>
|
||||
SVGMatrix::SkewX(float angle, ErrorResult& rv)
|
||||
{
|
||||
double ta = tan( angle*radPerDegree );
|
||||
if (!NS_finite(ta)) {
|
||||
@ -226,12 +225,12 @@ DOMSVGMatrix::SkewX(float angle, ErrorResult& rv)
|
||||
gfxMatrix skewMx(mx.xx, mx.yx,
|
||||
(float) (mx.xy + mx.xx*ta), (float) (mx.yy + mx.yx*ta),
|
||||
mx.x0, mx.y0);
|
||||
nsRefPtr<DOMSVGMatrix> matrix = new DOMSVGMatrix(skewMx);
|
||||
nsRefPtr<SVGMatrix> matrix = new SVGMatrix(skewMx);
|
||||
return matrix.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGMatrix>
|
||||
DOMSVGMatrix::SkewY(float angle, ErrorResult& rv)
|
||||
already_AddRefed<SVGMatrix>
|
||||
SVGMatrix::SkewY(float angle, ErrorResult& rv)
|
||||
{
|
||||
double ta = tan( angle*radPerDegree );
|
||||
if (!NS_finite(ta)) {
|
||||
@ -244,9 +243,9 @@ DOMSVGMatrix::SkewY(float angle, ErrorResult& rv)
|
||||
mx.xy, mx.yy,
|
||||
mx.x0, mx.y0);
|
||||
|
||||
nsRefPtr<DOMSVGMatrix> matrix = new DOMSVGMatrix(skewMx);
|
||||
nsRefPtr<SVGMatrix> matrix = new SVGMatrix(skewMx);
|
||||
return matrix.forget();
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -34,8 +34,8 @@
|
||||
* up.
|
||||
*/
|
||||
|
||||
#ifndef MOZILLA_DOMSVGMATRIX_H__
|
||||
#define MOZILLA_DOMSVGMATRIX_H__
|
||||
#ifndef mozilla_dom_SVGMatrix_h
|
||||
#define mozilla_dom_SVGMatrix_h
|
||||
|
||||
#include "DOMSVGTransform.h"
|
||||
#include "gfxMatrix.h"
|
||||
@ -54,34 +54,35 @@
|
||||
{ 0x8A, 0x9A, 0x85, 0x6F, 0x63, 0x5E, 0x90, 0xA3 } }
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
/**
|
||||
* DOM wrapper for an SVG matrix.
|
||||
*/
|
||||
class DOMSVGMatrix MOZ_FINAL : public nsISupports,
|
||||
public nsWrapperCache
|
||||
class SVGMatrix MOZ_FINAL : public nsISupports,
|
||||
public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_DOMSVGMATRIX_IID)
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMSVGMatrix)
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(SVGMatrix)
|
||||
|
||||
/**
|
||||
* Ctor for DOMSVGMatrix objects that belong to a DOMSVGTransform.
|
||||
* Ctor for SVGMatrix objects that belong to a DOMSVGTransform.
|
||||
*/
|
||||
DOMSVGMatrix(DOMSVGTransform& aTransform) : mTransform(&aTransform) {
|
||||
SVGMatrix(DOMSVGTransform& aTransform) : mTransform(&aTransform) {
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ctors for DOMSVGMatrix objects created independently of a DOMSVGTransform.
|
||||
* Ctors for SVGMatrix objects created independently of a DOMSVGTransform.
|
||||
*/
|
||||
// Default ctor for gfxMatrix will produce identity mx
|
||||
DOMSVGMatrix() {
|
||||
SVGMatrix() {
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
DOMSVGMatrix(const gfxMatrix &aMatrix) : mMatrix(aMatrix) {
|
||||
SVGMatrix(const gfxMatrix &aMatrix) : mMatrix(aMatrix) {
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
@ -105,20 +106,20 @@ public:
|
||||
void SetE(float aE, ErrorResult& rv);
|
||||
float F() const { return static_cast<float>(Matrix().y0); }
|
||||
void SetF(float aF, ErrorResult& rv);
|
||||
already_AddRefed<DOMSVGMatrix> Multiply(DOMSVGMatrix& aMatrix);
|
||||
already_AddRefed<DOMSVGMatrix> Inverse(ErrorResult& aRv);
|
||||
already_AddRefed<DOMSVGMatrix> Translate(float x, float y);
|
||||
already_AddRefed<DOMSVGMatrix> Scale(float scaleFactor);
|
||||
already_AddRefed<DOMSVGMatrix> ScaleNonUniform(float scaleFactorX,
|
||||
float scaleFactorY);
|
||||
already_AddRefed<DOMSVGMatrix> Rotate(float angle);
|
||||
already_AddRefed<DOMSVGMatrix> RotateFromVector(float x,
|
||||
float y,
|
||||
ErrorResult& aRv);
|
||||
already_AddRefed<DOMSVGMatrix> FlipX();
|
||||
already_AddRefed<DOMSVGMatrix> FlipY();
|
||||
already_AddRefed<DOMSVGMatrix> SkewX(float angle, ErrorResult& rv);
|
||||
already_AddRefed<DOMSVGMatrix> SkewY(float angle, ErrorResult& rv);
|
||||
already_AddRefed<SVGMatrix> Multiply(SVGMatrix& aMatrix);
|
||||
already_AddRefed<SVGMatrix> Inverse(ErrorResult& aRv);
|
||||
already_AddRefed<SVGMatrix> Translate(float x, float y);
|
||||
already_AddRefed<SVGMatrix> Scale(float scaleFactor);
|
||||
already_AddRefed<SVGMatrix> ScaleNonUniform(float scaleFactorX,
|
||||
float scaleFactorY);
|
||||
already_AddRefed<SVGMatrix> Rotate(float angle);
|
||||
already_AddRefed<SVGMatrix> RotateFromVector(float x,
|
||||
float y,
|
||||
ErrorResult& aRv);
|
||||
already_AddRefed<SVGMatrix> FlipX();
|
||||
already_AddRefed<SVGMatrix> FlipY();
|
||||
already_AddRefed<SVGMatrix> SkewX(float angle, ErrorResult& rv);
|
||||
already_AddRefed<SVGMatrix> SkewY(float angle, ErrorResult& rv);
|
||||
|
||||
private:
|
||||
void SetMatrix(const gfxMatrix& aMatrix) {
|
||||
@ -140,8 +141,9 @@ private:
|
||||
gfxMatrix mMatrix;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(DOMSVGMatrix, MOZILLA_DOMSVGMATRIX_IID)
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(SVGMatrix, MOZILLA_DOMSVGMATRIX_IID)
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // MOZILLA_DOMSVGMATRIX_H__
|
||||
#endif // mozilla_dom_SVGMatrix_h
|
@ -17,7 +17,7 @@
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "DOMSVGMatrix.h"
|
||||
#include "mozilla/dom/SVGMatrix.h"
|
||||
#include "DOMSVGPoint.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIFrame.h"
|
||||
@ -93,7 +93,7 @@ nsSVGTranslatePoint::DOMVal::SetY(float aValue, ErrorResult& rv)
|
||||
}
|
||||
|
||||
already_AddRefed<nsISVGPoint>
|
||||
nsSVGTranslatePoint::DOMVal::MatrixTransform(DOMSVGMatrix& matrix)
|
||||
nsSVGTranslatePoint::DOMVal::MatrixTransform(SVGMatrix& matrix)
|
||||
{
|
||||
float a = matrix.A(), b = matrix.B(), c = matrix.C();
|
||||
float d = matrix.D(), e = matrix.E(), f = matrix.F();
|
||||
@ -611,7 +611,7 @@ SVGSVGElement::CreateSVGPoint()
|
||||
return point.forget();
|
||||
}
|
||||
|
||||
/* DOMSVGMatrix createSVGMatrix (); */
|
||||
/* SVGMatrix createSVGMatrix (); */
|
||||
NS_IMETHODIMP
|
||||
SVGSVGElement::CreateSVGMatrix(nsISupports **_retval)
|
||||
{
|
||||
@ -619,10 +619,10 @@ SVGSVGElement::CreateSVGMatrix(nsISupports **_retval)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGMatrix>
|
||||
already_AddRefed<SVGMatrix>
|
||||
SVGSVGElement::CreateSVGMatrix()
|
||||
{
|
||||
nsRefPtr<DOMSVGMatrix> matrix = new DOMSVGMatrix();
|
||||
nsRefPtr<SVGMatrix> matrix = new SVGMatrix();
|
||||
return matrix.forget();
|
||||
}
|
||||
|
||||
@ -657,12 +657,12 @@ SVGSVGElement::CreateSVGTransform()
|
||||
return transform.forget();
|
||||
}
|
||||
|
||||
/* DOMSVGTransform createSVGTransformFromMatrix (in DOMSVGMatrix matrix); */
|
||||
/* DOMSVGTransform createSVGTransformFromMatrix (in SVGMatrix matrix); */
|
||||
NS_IMETHODIMP
|
||||
SVGSVGElement::CreateSVGTransformFromMatrix(nsISupports *matrix,
|
||||
nsISupports **_retval)
|
||||
{
|
||||
nsCOMPtr<DOMSVGMatrix> domItem = do_QueryInterface(matrix);
|
||||
nsCOMPtr<SVGMatrix> domItem = do_QueryInterface(matrix);
|
||||
if (!domItem) {
|
||||
return NS_ERROR_DOM_SVG_WRONG_TYPE_ERR;
|
||||
}
|
||||
@ -672,7 +672,7 @@ SVGSVGElement::CreateSVGTransformFromMatrix(nsISupports *matrix,
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGTransform>
|
||||
SVGSVGElement::CreateSVGTransformFromMatrix(DOMSVGMatrix& matrix)
|
||||
SVGSVGElement::CreateSVGTransformFromMatrix(SVGMatrix& matrix)
|
||||
{
|
||||
nsRefPtr<DOMSVGTransform> transform = new DOMSVGTransform(matrix.Matrix());
|
||||
return transform.forget();
|
||||
|
@ -30,12 +30,12 @@ class nsSVGImageFrame;
|
||||
|
||||
namespace mozilla {
|
||||
class DOMSVGAnimatedPreserveAspectRatio;
|
||||
class DOMSVGMatrix;
|
||||
class DOMSVGTransform;
|
||||
class SVGFragmentIdentifier;
|
||||
|
||||
namespace dom {
|
||||
class SVGAngle;
|
||||
class SVGMatrix;
|
||||
class SVGViewElement;
|
||||
|
||||
class SVGSVGElement;
|
||||
@ -81,7 +81,7 @@ private:
|
||||
virtual float Y() { return mVal->GetY(); }
|
||||
virtual void SetX(float aValue, ErrorResult& rv);
|
||||
virtual void SetY(float aValue, ErrorResult& rv);
|
||||
virtual already_AddRefed<nsISVGPoint> MatrixTransform(DOMSVGMatrix& matrix);
|
||||
virtual already_AddRefed<nsISVGPoint> MatrixTransform(SVGMatrix& matrix);
|
||||
|
||||
virtual nsISupports* GetParentObject() MOZ_OVERRIDE;
|
||||
|
||||
@ -285,10 +285,10 @@ public:
|
||||
already_AddRefed<nsIDOMSVGLength> CreateSVGLength();
|
||||
already_AddRefed<SVGAngle> CreateSVGAngle();
|
||||
already_AddRefed<nsISVGPoint> CreateSVGPoint();
|
||||
already_AddRefed<DOMSVGMatrix> CreateSVGMatrix();
|
||||
already_AddRefed<SVGMatrix> CreateSVGMatrix();
|
||||
already_AddRefed<nsIDOMSVGRect> CreateSVGRect();
|
||||
already_AddRefed<DOMSVGTransform> CreateSVGTransform();
|
||||
already_AddRefed<DOMSVGTransform> CreateSVGTransformFromMatrix(DOMSVGMatrix& matrix);
|
||||
already_AddRefed<DOMSVGTransform> CreateSVGTransformFromMatrix(SVGMatrix& matrix);
|
||||
Element* GetElementById(const nsAString& elementId, ErrorResult& rv);
|
||||
already_AddRefed<nsIDOMSVGAnimatedRect> ViewBox();
|
||||
already_AddRefed<DOMSVGAnimatedPreserveAspectRatio> PreserveAspectRatio();
|
||||
|
@ -19,7 +19,9 @@ class nsSVGElement;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class DOMSVGMatrix;
|
||||
namespace dom {
|
||||
class SVGMatrix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class nsISVGPoint
|
||||
@ -46,7 +48,7 @@ public:
|
||||
virtual void SetX(float aX, ErrorResult& rv) = 0;
|
||||
virtual float Y() = 0;
|
||||
virtual void SetY(float aY, ErrorResult& rv) = 0;
|
||||
virtual already_AddRefed<nsISVGPoint> MatrixTransform(DOMSVGMatrix& matrix) = 0;
|
||||
virtual already_AddRefed<nsISVGPoint> MatrixTransform(dom::SVGMatrix& matrix) = 0;
|
||||
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
|
||||
bool *triedToWrap)
|
||||
{ return dom::SVGPointBinding::Wrap(cx, scope, this, triedToWrap); }
|
||||
|
@ -653,11 +653,6 @@ DOMInterfaces = {
|
||||
'headerFile': 'mozilla/dom/SVGGradientElement.h',
|
||||
},
|
||||
|
||||
'SVGMatrix': {
|
||||
'nativeType': 'mozilla::DOMSVGMatrix',
|
||||
'headerFile': 'DOMSVGMatrix.h'
|
||||
},
|
||||
|
||||
'SVGNumberList': {
|
||||
'nativeType': 'mozilla::DOMSVGNumberList',
|
||||
'headerFile': 'DOMSVGNumberList.h',
|
||||
|
Loading…
Reference in New Issue
Block a user