Bug 952977: Switch SetAnimateMotionTransform to gfx::Matrix r=nical

This commit is contained in:
David Zbarsky 2013-12-28 16:37:40 -05:00
parent bc3a02bf90
commit d57142d56d
4 changed files with 17 additions and 10 deletions

View File

@ -11,6 +11,7 @@
#include "nsSMILValue.h" #include "nsSMILValue.h"
#include "nsDebug.h" #include "nsDebug.h"
#include "nsSVGElement.h" #include "nsSVGElement.h"
#include "gfx2DGlue.h"
namespace mozilla { namespace mozilla {
@ -40,7 +41,7 @@ SVGMotionSMILAttr::ClearAnimValue()
nsresult nsresult
SVGMotionSMILAttr::SetAnimValue(const nsSMILValue& aValue) SVGMotionSMILAttr::SetAnimValue(const nsSMILValue& aValue)
{ {
gfxMatrix matrix = SVGMotionSMILType::CreateMatrix(aValue); gfx::Matrix matrix = gfx::ToMatrix(SVGMotionSMILType::CreateMatrix(aValue));
mSVGElement->SetAnimateMotionTransform(&matrix); mSVGElement->SetAnimateMotionTransform(&matrix);
return NS_OK; return NS_OK;
} }

View File

@ -109,7 +109,7 @@ SVGTransformableElement::PrependLocalTransformsTo(const gfxMatrix &aMatrix,
// any transformations from the |transform| attribute. So since we're // any transformations from the |transform| attribute. So since we're
// PRE-multiplying, we need to apply the animateMotion transform *first*. // PRE-multiplying, we need to apply the animateMotion transform *first*.
if (mAnimateMotionTransform) { if (mAnimateMotionTransform) {
result.PreMultiply(*mAnimateMotionTransform); result.PreMultiply(ThebesMatrix(*mAnimateMotionTransform));
} }
if (mTransforms) { if (mTransforms) {
@ -119,20 +119,20 @@ SVGTransformableElement::PrependLocalTransformsTo(const gfxMatrix &aMatrix,
return result; return result;
} }
const gfxMatrix* const gfx::Matrix*
SVGTransformableElement::GetAnimateMotionTransform() const SVGTransformableElement::GetAnimateMotionTransform() const
{ {
return mAnimateMotionTransform.get(); return mAnimateMotionTransform.get();
} }
void void
SVGTransformableElement::SetAnimateMotionTransform(const gfxMatrix* aMatrix) SVGTransformableElement::SetAnimateMotionTransform(const gfx::Matrix* aMatrix)
{ {
if ((!aMatrix && !mAnimateMotionTransform) || if ((!aMatrix && !mAnimateMotionTransform) ||
(aMatrix && mAnimateMotionTransform && *aMatrix == *mAnimateMotionTransform)) { (aMatrix && mAnimateMotionTransform && *aMatrix == *mAnimateMotionTransform)) {
return; return;
} }
mAnimateMotionTransform = aMatrix ? new gfxMatrix(*aMatrix) : nullptr; mAnimateMotionTransform = aMatrix ? new gfx::Matrix(*aMatrix) : nullptr;
DidAnimateTransformList(); DidAnimateTransformList();
nsIFrame* frame = GetPrimaryFrame(); nsIFrame* frame = GetPrimaryFrame();
if (frame) { if (frame) {

View File

@ -10,6 +10,7 @@
#include "nsSVGAnimatedTransformList.h" #include "nsSVGAnimatedTransformList.h"
#include "nsSVGElement.h" #include "nsSVGElement.h"
#include "gfxMatrix.h" #include "gfxMatrix.h"
#include "mozilla/gfx/Matrix.h"
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
@ -50,8 +51,8 @@ public:
virtual gfxMatrix PrependLocalTransformsTo(const gfxMatrix &aMatrix, virtual gfxMatrix PrependLocalTransformsTo(const gfxMatrix &aMatrix,
TransformTypes aWhich = eAllTransforms) const MOZ_OVERRIDE; TransformTypes aWhich = eAllTransforms) const MOZ_OVERRIDE;
virtual const gfxMatrix* GetAnimateMotionTransform() const MOZ_OVERRIDE; virtual const gfx::Matrix* GetAnimateMotionTransform() const MOZ_OVERRIDE;
virtual void SetAnimateMotionTransform(const gfxMatrix* aMatrix) MOZ_OVERRIDE; virtual void SetAnimateMotionTransform(const gfx::Matrix* aMatrix) MOZ_OVERRIDE;
virtual nsSVGAnimatedTransformList* virtual nsSVGAnimatedTransformList*
GetAnimatedTransformList(uint32_t aFlags = 0) MOZ_OVERRIDE; GetAnimatedTransformList(uint32_t aFlags = 0) MOZ_OVERRIDE;
@ -67,7 +68,7 @@ protected:
nsAutoPtr<nsSVGAnimatedTransformList> mTransforms; nsAutoPtr<nsSVGAnimatedTransformList> mTransforms;
// XXX maybe move this to property table, to save space on un-animated elems? // XXX maybe move this to property table, to save space on un-animated elems?
nsAutoPtr<gfxMatrix> mAnimateMotionTransform; nsAutoPtr<gfx::Matrix> mAnimateMotionTransform;
}; };
} // namespace dom } // namespace dom

View File

@ -57,6 +57,11 @@ class SVGAnimatedPreserveAspectRatio;
class nsSVGAnimatedTransformList; class nsSVGAnimatedTransformList;
class SVGStringList; class SVGStringList;
class DOMSVGStringList; class DOMSVGStringList;
namespace gfx {
class Matrix;
}
} }
struct gfxMatrix; struct gfxMatrix;
@ -168,8 +173,8 @@ public:
// Setter for to set the current <animateMotion> transformation // Setter for to set the current <animateMotion> transformation
// Only visible for nsSVGGraphicElement, so it's a no-op here, and that // Only visible for nsSVGGraphicElement, so it's a no-op here, and that
// subclass has the useful implementation. // subclass has the useful implementation.
virtual void SetAnimateMotionTransform(const gfxMatrix* aMatrix) {/*no-op*/} virtual void SetAnimateMotionTransform(const mozilla::gfx::Matrix* aMatrix) {/*no-op*/}
virtual const gfxMatrix* GetAnimateMotionTransform() const { return nullptr; } virtual const mozilla::gfx::Matrix* GetAnimateMotionTransform() const { return nullptr; }
bool IsStringAnimatable(uint8_t aAttrEnum) { bool IsStringAnimatable(uint8_t aAttrEnum) {
return GetStringInfo().mStringInfo[aAttrEnum].mIsAnimatable; return GetStringInfo().mStringInfo[aAttrEnum].mIsAnimatable;