2011-09-25 14:04:27 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
|
2012-05-21 04:12:37 -07:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* 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/. */
|
2011-09-25 14:04:27 -07:00
|
|
|
|
2013-04-02 12:17:41 -07:00
|
|
|
#include "mozilla/dom/SVGTransform.h"
|
2013-01-11 12:30:21 -08:00
|
|
|
#include "mozilla/dom/SVGMatrix.h"
|
2013-09-17 05:52:39 -07:00
|
|
|
#include "mozilla/dom/SVGTransformBinding.h"
|
2012-07-27 07:03:27 -07:00
|
|
|
#include "nsError.h"
|
2013-04-14 15:56:34 -07:00
|
|
|
#include "nsSVGAnimatedTransformList.h"
|
2013-01-10 23:15:06 -08:00
|
|
|
#include "nsSVGAttrTearoffTable.h"
|
2011-09-25 14:04:27 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
2013-04-02 12:17:41 -07:00
|
|
|
namespace dom {
|
2011-09-25 14:04:27 -07:00
|
|
|
|
2013-05-30 15:34:53 -07:00
|
|
|
static nsSVGAttrTearoffTable<SVGTransform, SVGMatrix>&
|
|
|
|
SVGMatrixTearoffTable()
|
|
|
|
{
|
|
|
|
static nsSVGAttrTearoffTable<SVGTransform, SVGMatrix> sSVGMatrixTearoffTable;
|
|
|
|
return sSVGMatrixTearoffTable;
|
|
|
|
}
|
2013-01-10 23:15:06 -08:00
|
|
|
|
2011-09-25 14:04:27 -07:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// We could use NS_IMPL_CYCLE_COLLECTION_1, except that in Unlink() we need to
|
|
|
|
// clear our list's weak ref to us to be safe. (The other option would be to
|
|
|
|
// not unlink and rely on the breaking of the other edges in the cycle, as
|
|
|
|
// NS_SVG_VAL_IMPL_CYCLE_COLLECTION does.)
|
2013-08-01 18:29:05 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(SVGTransform)
|
|
|
|
|
2013-04-02 12:17:41 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(SVGTransform)
|
2011-09-25 14:04:27 -07:00
|
|
|
// We may not belong to a list, so we must null check tmp->mList.
|
|
|
|
if (tmp->mList) {
|
2012-07-30 07:20:58 -07:00
|
|
|
tmp->mList->mItems[tmp->mListIndex] = nullptr;
|
2011-09-25 14:04:27 -07:00
|
|
|
}
|
2012-11-14 23:32:40 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mList)
|
2012-12-22 20:54:20 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
2011-09-25 14:04:27 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
2012-12-22 20:54:20 -08:00
|
|
|
|
2013-04-02 12:17:41 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(SVGTransform)
|
2012-11-14 23:32:40 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mList)
|
2013-01-19 12:56:31 -08:00
|
|
|
SVGMatrix* matrix =
|
2013-05-30 15:34:53 -07:00
|
|
|
SVGMatrixTearoffTable().GetTearoff(tmp);
|
2013-01-19 12:56:31 -08:00
|
|
|
CycleCollectionNoteChild(cb, matrix, "matrix");
|
2012-12-22 20:54:20 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
2011-09-25 14:04:27 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
2013-04-02 12:17:41 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(SVGTransform)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
|
|
|
|
2013-04-02 12:17:41 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(SVGTransform, AddRef)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(SVGTransform, Release)
|
2011-09-25 14:04:27 -07:00
|
|
|
|
2012-12-22 20:54:20 -08:00
|
|
|
JSObject*
|
2013-04-25 09:29:54 -07:00
|
|
|
SVGTransform::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
2012-12-22 20:54:20 -08:00
|
|
|
{
|
2013-04-02 12:17:41 -07:00
|
|
|
return SVGTransformBinding::Wrap(aCx, aScope, this);
|
2012-12-22 20:54:20 -08:00
|
|
|
}
|
|
|
|
|
2011-09-25 14:04:27 -07:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Ctors:
|
|
|
|
|
2013-04-02 12:17:41 -07:00
|
|
|
SVGTransform::SVGTransform(DOMSVGTransformList *aList,
|
|
|
|
uint32_t aListIndex,
|
|
|
|
bool aIsAnimValItem)
|
2011-09-25 14:04:27 -07:00
|
|
|
: mList(aList)
|
|
|
|
, mListIndex(aListIndex)
|
|
|
|
, mIsAnimValItem(aIsAnimValItem)
|
2012-07-30 07:20:58 -07:00
|
|
|
, mTransform(nullptr)
|
2011-09-25 14:04:27 -07:00
|
|
|
{
|
2012-12-22 20:54:20 -08:00
|
|
|
SetIsDOMBinding();
|
2011-09-25 14:04:27 -07:00
|
|
|
// These shifts are in sync with the members in the header.
|
|
|
|
NS_ABORT_IF_FALSE(aList &&
|
2012-09-22 17:48:27 -07:00
|
|
|
aListIndex <= MaxListIndex(), "bad arg");
|
2011-09-25 14:04:27 -07:00
|
|
|
|
|
|
|
NS_ABORT_IF_FALSE(IndexIsValid(), "Bad index for DOMSVGNumber!");
|
|
|
|
}
|
|
|
|
|
2013-04-02 12:17:41 -07:00
|
|
|
SVGTransform::SVGTransform()
|
2012-07-30 07:20:58 -07:00
|
|
|
: mList(nullptr)
|
2011-09-25 14:04:27 -07:00
|
|
|
, mListIndex(0)
|
2011-10-17 07:59:28 -07:00
|
|
|
, mIsAnimValItem(false)
|
2013-04-02 12:17:41 -07:00
|
|
|
, mTransform(new nsSVGTransform()) // Default ctor for objects not in a list
|
|
|
|
// initialises to matrix type with identity
|
|
|
|
// matrix
|
2011-09-25 14:04:27 -07:00
|
|
|
{
|
2012-12-22 20:54:20 -08:00
|
|
|
SetIsDOMBinding();
|
2011-09-25 14:04:27 -07:00
|
|
|
}
|
|
|
|
|
2013-04-02 12:17:41 -07:00
|
|
|
SVGTransform::SVGTransform(const gfxMatrix &aMatrix)
|
2012-07-30 07:20:58 -07:00
|
|
|
: mList(nullptr)
|
2011-09-25 14:04:27 -07:00
|
|
|
, mListIndex(0)
|
2011-10-17 07:59:28 -07:00
|
|
|
, mIsAnimValItem(false)
|
2013-04-02 12:17:41 -07:00
|
|
|
, mTransform(new nsSVGTransform(aMatrix))
|
2011-09-25 14:04:27 -07:00
|
|
|
{
|
2012-12-22 20:54:20 -08:00
|
|
|
SetIsDOMBinding();
|
2011-09-25 14:04:27 -07:00
|
|
|
}
|
|
|
|
|
2013-04-02 12:17:41 -07:00
|
|
|
SVGTransform::SVGTransform(const nsSVGTransform &aTransform)
|
2012-07-30 07:20:58 -07:00
|
|
|
: mList(nullptr)
|
2011-09-25 14:04:27 -07:00
|
|
|
, mListIndex(0)
|
2011-10-17 07:59:28 -07:00
|
|
|
, mIsAnimValItem(false)
|
2013-04-02 12:17:41 -07:00
|
|
|
, mTransform(new nsSVGTransform(aTransform))
|
2011-09-25 14:04:27 -07:00
|
|
|
{
|
2012-12-22 20:54:20 -08:00
|
|
|
SetIsDOMBinding();
|
2011-09-25 14:04:27 -07:00
|
|
|
}
|
|
|
|
|
2013-04-02 12:17:41 -07:00
|
|
|
SVGTransform::~SVGTransform()
|
2013-01-10 23:15:06 -08:00
|
|
|
{
|
2013-05-30 15:34:53 -07:00
|
|
|
SVGMatrix* matrix = SVGMatrixTearoffTable().GetTearoff(this);
|
2013-01-19 12:56:31 -08:00
|
|
|
if (matrix) {
|
2013-05-30 15:34:53 -07:00
|
|
|
SVGMatrixTearoffTable().RemoveTearoff(this);
|
2013-01-19 12:56:31 -08:00
|
|
|
NS_RELEASE(matrix);
|
|
|
|
}
|
2013-01-10 23:15:06 -08:00
|
|
|
// Our mList's weak ref to us must be nulled out when we die. If GC has
|
|
|
|
// unlinked us using the cycle collector code, then that has already
|
|
|
|
// happened, and mList is null.
|
|
|
|
if (mList) {
|
|
|
|
mList->mItems[mListIndex] = nullptr;
|
|
|
|
}
|
|
|
|
}
|
2011-09-25 14:04:27 -07:00
|
|
|
|
2012-12-22 20:54:20 -08:00
|
|
|
uint16_t
|
2013-04-02 12:17:41 -07:00
|
|
|
SVGTransform::Type() const
|
2012-12-22 20:54:20 -08:00
|
|
|
{
|
|
|
|
return Transform().Type();
|
|
|
|
}
|
|
|
|
|
2013-01-19 12:56:31 -08:00
|
|
|
SVGMatrix*
|
2013-04-02 12:17:41 -07:00
|
|
|
SVGTransform::Matrix()
|
2011-09-25 14:04:27 -07:00
|
|
|
{
|
2013-01-19 12:56:31 -08:00
|
|
|
SVGMatrix* wrapper =
|
2013-05-30 15:34:53 -07:00
|
|
|
SVGMatrixTearoffTable().GetTearoff(this);
|
2013-01-10 23:15:06 -08:00
|
|
|
if (!wrapper) {
|
2013-01-19 12:56:31 -08:00
|
|
|
NS_ADDREF(wrapper = new SVGMatrix(*this));
|
2013-05-30 15:34:53 -07:00
|
|
|
SVGMatrixTearoffTable().AddTearoff(this, wrapper);
|
2011-09-25 14:04:27 -07:00
|
|
|
}
|
2013-01-19 12:56:31 -08:00
|
|
|
return wrapper;
|
2012-12-22 20:54:20 -08:00
|
|
|
}
|
2011-09-25 14:04:27 -07:00
|
|
|
|
2012-12-22 20:54:20 -08:00
|
|
|
float
|
2013-04-02 12:17:41 -07:00
|
|
|
SVGTransform::Angle() const
|
2012-12-22 20:54:20 -08:00
|
|
|
{
|
|
|
|
return Transform().Angle();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-04-02 12:17:41 -07:00
|
|
|
SVGTransform::SetMatrix(SVGMatrix& aMatrix, ErrorResult& rv)
|
2012-12-22 20:54:20 -08:00
|
|
|
{
|
|
|
|
if (mIsAnimValItem) {
|
|
|
|
rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
SetMatrix(aMatrix.Matrix());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-04-02 12:17:41 -07:00
|
|
|
SVGTransform::SetTranslate(float tx, float ty, ErrorResult& rv)
|
2011-09-25 14:04:27 -07:00
|
|
|
{
|
|
|
|
if (mIsAnimValItem) {
|
2012-12-22 20:54:20 -08:00
|
|
|
rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
|
|
|
return;
|
2011-09-25 14:04:27 -07:00
|
|
|
}
|
|
|
|
|
2012-12-22 20:54:24 -08:00
|
|
|
if (Transform().Type() == SVG_TRANSFORM_TRANSLATE &&
|
2012-12-22 20:54:20 -08:00
|
|
|
Matrixgfx().x0 == tx && Matrixgfx().y0 == ty) {
|
|
|
|
return;
|
2012-02-15 15:40:46 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
nsAttrValue emptyOrOldValue = NotifyElementWillChange();
|
2011-09-25 14:04:27 -07:00
|
|
|
Transform().SetTranslate(tx, ty);
|
2012-02-15 15:40:46 -08:00
|
|
|
NotifyElementDidChange(emptyOrOldValue);
|
2011-09-25 14:04:27 -07:00
|
|
|
}
|
|
|
|
|
2012-12-22 20:54:20 -08:00
|
|
|
void
|
2013-04-02 12:17:41 -07:00
|
|
|
SVGTransform::SetScale(float sx, float sy, ErrorResult& rv)
|
2011-09-25 14:04:27 -07:00
|
|
|
{
|
|
|
|
if (mIsAnimValItem) {
|
2012-12-22 20:54:20 -08:00
|
|
|
rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
|
|
|
return;
|
2011-09-25 14:04:27 -07:00
|
|
|
}
|
|
|
|
|
2012-12-22 20:54:24 -08:00
|
|
|
if (Transform().Type() == SVG_TRANSFORM_SCALE &&
|
2012-12-22 20:54:20 -08:00
|
|
|
Matrixgfx().xx == sx && Matrixgfx().yy == sy) {
|
|
|
|
return;
|
2012-02-15 15:40:46 -08:00
|
|
|
}
|
|
|
|
nsAttrValue emptyOrOldValue = NotifyElementWillChange();
|
2011-09-25 14:04:27 -07:00
|
|
|
Transform().SetScale(sx, sy);
|
2012-02-15 15:40:46 -08:00
|
|
|
NotifyElementDidChange(emptyOrOldValue);
|
2011-09-25 14:04:27 -07:00
|
|
|
}
|
|
|
|
|
2012-12-22 20:54:20 -08:00
|
|
|
void
|
2013-04-02 12:17:41 -07:00
|
|
|
SVGTransform::SetRotate(float angle, float cx, float cy, ErrorResult& rv)
|
2011-09-25 14:04:27 -07:00
|
|
|
{
|
|
|
|
if (mIsAnimValItem) {
|
2012-12-22 20:54:20 -08:00
|
|
|
rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
|
|
|
return;
|
2011-09-25 14:04:27 -07:00
|
|
|
}
|
|
|
|
|
2012-12-22 20:54:24 -08:00
|
|
|
if (Transform().Type() == SVG_TRANSFORM_ROTATE) {
|
2012-02-15 15:40:46 -08:00
|
|
|
float currentCx, currentCy;
|
|
|
|
Transform().GetRotationOrigin(currentCx, currentCy);
|
|
|
|
if (Transform().Angle() == angle && currentCx == cx && currentCy == cy) {
|
2012-12-22 20:54:20 -08:00
|
|
|
return;
|
2012-02-15 15:40:46 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAttrValue emptyOrOldValue = NotifyElementWillChange();
|
2011-09-25 14:04:27 -07:00
|
|
|
Transform().SetRotate(angle, cx, cy);
|
2012-02-15 15:40:46 -08:00
|
|
|
NotifyElementDidChange(emptyOrOldValue);
|
2011-09-25 14:04:27 -07:00
|
|
|
}
|
|
|
|
|
2012-12-22 20:54:20 -08:00
|
|
|
void
|
2013-04-02 12:17:41 -07:00
|
|
|
SVGTransform::SetSkewX(float angle, ErrorResult& rv)
|
2011-09-25 14:04:27 -07:00
|
|
|
{
|
|
|
|
if (mIsAnimValItem) {
|
2012-12-22 20:54:20 -08:00
|
|
|
rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
|
|
|
return;
|
2011-09-25 14:04:27 -07:00
|
|
|
}
|
|
|
|
|
2012-12-22 20:54:24 -08:00
|
|
|
if (Transform().Type() == SVG_TRANSFORM_SKEWX &&
|
2012-02-15 15:40:46 -08:00
|
|
|
Transform().Angle() == angle) {
|
2012-12-22 20:54:20 -08:00
|
|
|
return;
|
2012-02-15 15:40:46 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
nsAttrValue emptyOrOldValue = NotifyElementWillChange();
|
2012-12-22 20:54:20 -08:00
|
|
|
nsresult result = Transform().SetSkewX(angle);
|
|
|
|
if (NS_FAILED(result)) {
|
|
|
|
rv.Throw(result);
|
|
|
|
return;
|
|
|
|
}
|
2012-02-15 15:40:46 -08:00
|
|
|
NotifyElementDidChange(emptyOrOldValue);
|
2011-09-25 14:04:27 -07:00
|
|
|
}
|
|
|
|
|
2012-12-22 20:54:20 -08:00
|
|
|
void
|
2013-04-02 12:17:41 -07:00
|
|
|
SVGTransform::SetSkewY(float angle, ErrorResult& rv)
|
2011-09-25 14:04:27 -07:00
|
|
|
{
|
|
|
|
if (mIsAnimValItem) {
|
2012-12-22 20:54:20 -08:00
|
|
|
rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
|
|
|
return;
|
2011-09-25 14:04:27 -07:00
|
|
|
}
|
|
|
|
|
2012-12-22 20:54:24 -08:00
|
|
|
if (Transform().Type() == SVG_TRANSFORM_SKEWY &&
|
2012-02-15 15:40:46 -08:00
|
|
|
Transform().Angle() == angle) {
|
2012-12-22 20:54:20 -08:00
|
|
|
return;
|
2012-02-15 15:40:46 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
nsAttrValue emptyOrOldValue = NotifyElementWillChange();
|
2012-12-22 20:54:20 -08:00
|
|
|
nsresult result = Transform().SetSkewY(angle);
|
|
|
|
if (NS_FAILED(result)) {
|
|
|
|
rv.Throw(result);
|
|
|
|
return;
|
|
|
|
}
|
2012-02-15 15:40:46 -08:00
|
|
|
NotifyElementDidChange(emptyOrOldValue);
|
2012-12-22 20:54:20 -08:00
|
|
|
}
|
2011-09-25 14:04:27 -07:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// List management methods:
|
|
|
|
|
|
|
|
void
|
2013-04-02 12:17:41 -07:00
|
|
|
SVGTransform::InsertingIntoList(DOMSVGTransformList *aList,
|
|
|
|
uint32_t aListIndex,
|
|
|
|
bool aIsAnimValItem)
|
2011-09-25 14:04:27 -07:00
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(!HasOwner(), "Inserting item that is already in a list");
|
|
|
|
|
|
|
|
mList = aList;
|
|
|
|
mListIndex = aListIndex;
|
|
|
|
mIsAnimValItem = aIsAnimValItem;
|
2012-07-30 07:20:58 -07:00
|
|
|
mTransform = nullptr;
|
2011-09-25 14:04:27 -07:00
|
|
|
|
|
|
|
NS_ABORT_IF_FALSE(IndexIsValid(), "Bad index for DOMSVGLength!");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-04-02 12:17:41 -07:00
|
|
|
SVGTransform::RemovingFromList()
|
2011-09-25 14:04:27 -07:00
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(!mTransform,
|
|
|
|
"Item in list also has another non-list value associated with it");
|
|
|
|
|
2013-04-02 12:17:41 -07:00
|
|
|
mTransform = new nsSVGTransform(InternalItem());
|
2012-07-30 07:20:58 -07:00
|
|
|
mList = nullptr;
|
2011-10-17 07:59:28 -07:00
|
|
|
mIsAnimValItem = false;
|
2011-09-25 14:04:27 -07:00
|
|
|
}
|
|
|
|
|
2013-04-02 12:17:41 -07:00
|
|
|
nsSVGTransform&
|
2013-04-02 12:17:41 -07:00
|
|
|
SVGTransform::InternalItem()
|
2011-09-25 14:04:27 -07:00
|
|
|
{
|
2013-04-14 15:56:34 -07:00
|
|
|
nsSVGAnimatedTransformList *alist = Element()->GetAnimatedTransformList();
|
2011-09-25 14:04:27 -07:00
|
|
|
return mIsAnimValItem && alist->mAnimVal ?
|
|
|
|
(*alist->mAnimVal)[mListIndex] :
|
|
|
|
alist->mBaseVal[mListIndex];
|
|
|
|
}
|
|
|
|
|
2013-04-02 12:17:41 -07:00
|
|
|
const nsSVGTransform&
|
2013-04-02 12:17:41 -07:00
|
|
|
SVGTransform::InternalItem() const
|
2011-09-25 14:04:27 -07:00
|
|
|
{
|
2013-04-02 12:17:41 -07:00
|
|
|
return const_cast<SVGTransform*>(this)->InternalItem();
|
2011-09-25 14:04:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2013-04-02 12:17:41 -07:00
|
|
|
SVGTransform::IndexIsValid()
|
2011-09-25 14:04:27 -07:00
|
|
|
{
|
2013-04-14 15:56:34 -07:00
|
|
|
nsSVGAnimatedTransformList *alist = Element()->GetAnimatedTransformList();
|
2011-09-25 14:04:27 -07:00
|
|
|
return (mIsAnimValItem &&
|
|
|
|
mListIndex < alist->GetAnimValue().Length()) ||
|
|
|
|
(!mIsAnimValItem &&
|
|
|
|
mListIndex < alist->GetBaseValue().Length());
|
|
|
|
}
|
|
|
|
#endif // DEBUG
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2013-01-11 12:30:21 -08:00
|
|
|
// Interface for SVGMatrix's use
|
2011-09-25 14:04:27 -07:00
|
|
|
|
|
|
|
void
|
2013-04-02 12:17:41 -07:00
|
|
|
SVGTransform::SetMatrix(const gfxMatrix& aMatrix)
|
2011-09-25 14:04:27 -07:00
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(!mIsAnimValItem,
|
|
|
|
"Attempting to modify read-only transform");
|
2012-02-15 15:40:46 -08:00
|
|
|
|
2012-12-22 20:54:24 -08:00
|
|
|
if (Transform().Type() == SVG_TRANSFORM_MATRIX &&
|
2013-04-02 12:17:41 -07:00
|
|
|
nsSVGTransform::MatricesEqual(Matrixgfx(), aMatrix)) {
|
2012-02-15 15:40:46 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAttrValue emptyOrOldValue = NotifyElementWillChange();
|
2011-09-25 14:04:27 -07:00
|
|
|
Transform().SetMatrix(aMatrix);
|
2012-02-15 15:40:46 -08:00
|
|
|
NotifyElementDidChange(emptyOrOldValue);
|
2011-09-25 14:04:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation helpers
|
|
|
|
|
|
|
|
void
|
2013-04-02 12:17:41 -07:00
|
|
|
SVGTransform::NotifyElementDidChange(const nsAttrValue& aEmptyOrOldValue)
|
2011-09-25 14:04:27 -07:00
|
|
|
{
|
|
|
|
if (HasOwner()) {
|
2012-02-15 15:40:46 -08:00
|
|
|
Element()->DidChangeTransformList(aEmptyOrOldValue);
|
2011-09-25 14:04:27 -07:00
|
|
|
if (mList->mAList->IsAnimating()) {
|
|
|
|
Element()->AnimationNeedsResample();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-02 12:17:41 -07:00
|
|
|
} // namespace dom
|
2011-09-25 14:04:27 -07:00
|
|
|
} // namespace mozilla
|