2011-09-26 01:04:27 +04: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 15:12:37 +04: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-26 01:04:27 +04:00
|
|
|
|
2013-12-25 02:09:22 +04:00
|
|
|
#include "SVGTransform.h"
|
|
|
|
|
2013-04-02 23:17:41 +04:00
|
|
|
#include "mozilla/dom/SVGTransform.h"
|
2013-01-12 00:30:21 +04:00
|
|
|
#include "mozilla/dom/SVGMatrix.h"
|
2013-09-17 16:52:39 +04:00
|
|
|
#include "mozilla/dom/SVGTransformBinding.h"
|
2012-07-27 18:03:27 +04:00
|
|
|
#include "nsError.h"
|
2013-04-15 02:56:34 +04:00
|
|
|
#include "nsSVGAnimatedTransformList.h"
|
2013-01-11 11:15:06 +04:00
|
|
|
#include "nsSVGAttrTearoffTable.h"
|
2014-03-05 03:39:42 +04:00
|
|
|
#include "mozilla/DebugOnly.h"
|
2014-10-01 13:26:00 +04:00
|
|
|
#include "mozilla/FloatingPoint.h"
|
2011-09-26 01:04:27 +04:00
|
|
|
|
2013-12-25 02:09:22 +04:00
|
|
|
namespace {
|
2013-12-25 12:33:48 +04:00
|
|
|
const double kRadPerDegree = 2.0 * M_PI / 360.0;
|
2013-12-25 02:09:22 +04:00
|
|
|
}
|
|
|
|
|
2011-09-26 01:04:27 +04:00
|
|
|
namespace mozilla {
|
2013-04-02 23:17:41 +04:00
|
|
|
namespace dom {
|
2011-09-26 01:04:27 +04:00
|
|
|
|
2013-05-31 02:34:53 +04:00
|
|
|
static nsSVGAttrTearoffTable<SVGTransform, SVGMatrix>&
|
|
|
|
SVGMatrixTearoffTable()
|
|
|
|
{
|
|
|
|
static nsSVGAttrTearoffTable<SVGTransform, SVGMatrix> sSVGMatrixTearoffTable;
|
|
|
|
return sSVGMatrixTearoffTable;
|
|
|
|
}
|
2013-01-11 11:15:06 +04:00
|
|
|
|
2011-09-26 01:04:27 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2014-04-25 20:49:00 +04:00
|
|
|
// We could use NS_IMPL_CYCLE_COLLECTION(, except that in Unlink() we need to
|
2011-09-26 01:04:27 +04:00
|
|
|
// 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-02 05:29:05 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(SVGTransform)
|
|
|
|
|
2013-04-02 23:17:41 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(SVGTransform)
|
2011-09-26 01:04:27 +04:00
|
|
|
// We may not belong to a list, so we must null check tmp->mList.
|
|
|
|
if (tmp->mList) {
|
2012-07-30 18:20:58 +04:00
|
|
|
tmp->mList->mItems[tmp->mListIndex] = nullptr;
|
2011-09-26 01:04:27 +04:00
|
|
|
}
|
2012-11-15 11:32:40 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mList)
|
2012-12-23 08:54:20 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
2011-09-26 01:04:27 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
2012-12-23 08:54:20 +04:00
|
|
|
|
2013-04-02 23:17:41 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(SVGTransform)
|
2012-11-15 11:32:40 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mList)
|
2013-01-20 00:56:31 +04:00
|
|
|
SVGMatrix* matrix =
|
2013-05-31 02:34:53 +04:00
|
|
|
SVGMatrixTearoffTable().GetTearoff(tmp);
|
2013-01-20 00:56:31 +04:00
|
|
|
CycleCollectionNoteChild(cb, matrix, "matrix");
|
2012-12-23 08:54:20 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
2011-09-26 01:04:27 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
2013-04-02 23:17:41 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(SVGTransform)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
|
|
|
|
2013-04-02 23:17:41 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(SVGTransform, AddRef)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(SVGTransform, Release)
|
2011-09-26 01:04:27 +04:00
|
|
|
|
2012-12-23 08:54:20 +04:00
|
|
|
JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
SVGTransform::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2012-12-23 08:54:20 +04:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
return SVGTransformBinding::Wrap(aCx, this, aGivenProto);
|
2012-12-23 08:54:20 +04:00
|
|
|
}
|
|
|
|
|
2013-12-25 02:09:22 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Helper class: AutoChangeTransformNotifier
|
|
|
|
// Stack-based helper class to pair calls to WillChangeTransformList
|
|
|
|
// and DidChangeTransformList.
|
|
|
|
class MOZ_STACK_CLASS AutoChangeTransformNotifier
|
|
|
|
{
|
|
|
|
public:
|
2014-09-01 05:08:04 +04:00
|
|
|
explicit AutoChangeTransformNotifier(SVGTransform* aTransform MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
2013-12-25 02:09:22 +04:00
|
|
|
: mTransform(aTransform)
|
|
|
|
{
|
|
|
|
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
2013-12-25 12:33:48 +04:00
|
|
|
MOZ_ASSERT(mTransform, "Expecting non-null transform");
|
2013-12-25 02:09:22 +04:00
|
|
|
if (mTransform->HasOwner()) {
|
|
|
|
mEmptyOrOldValue =
|
|
|
|
mTransform->Element()->WillChangeTransformList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
~AutoChangeTransformNotifier()
|
|
|
|
{
|
|
|
|
if (mTransform->HasOwner()) {
|
|
|
|
mTransform->Element()->DidChangeTransformList(mEmptyOrOldValue);
|
|
|
|
if (mTransform->mList->IsAnimating()) {
|
|
|
|
mTransform->Element()->AnimationNeedsResample();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2013-12-25 12:33:48 +04:00
|
|
|
SVGTransform* const mTransform;
|
2013-12-25 02:09:22 +04:00
|
|
|
nsAttrValue mEmptyOrOldValue;
|
|
|
|
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
|
|
|
};
|
|
|
|
|
2011-09-26 01:04:27 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Ctors:
|
|
|
|
|
2013-04-02 23:17:41 +04:00
|
|
|
SVGTransform::SVGTransform(DOMSVGTransformList *aList,
|
|
|
|
uint32_t aListIndex,
|
|
|
|
bool aIsAnimValItem)
|
2011-09-26 01:04:27 +04:00
|
|
|
: mList(aList)
|
|
|
|
, mListIndex(aListIndex)
|
|
|
|
, mIsAnimValItem(aIsAnimValItem)
|
2012-07-30 18:20:58 +04:00
|
|
|
, mTransform(nullptr)
|
2011-09-26 01:04:27 +04:00
|
|
|
{
|
|
|
|
// These shifts are in sync with the members in the header.
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(aList && aListIndex <= MaxListIndex(), "bad arg");
|
2011-09-26 01:04:27 +04:00
|
|
|
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(IndexIsValid(), "Bad index for DOMSVGNumber!");
|
2011-09-26 01:04:27 +04:00
|
|
|
}
|
|
|
|
|
2013-04-02 23:17:41 +04:00
|
|
|
SVGTransform::SVGTransform()
|
2012-07-30 18:20:58 +04:00
|
|
|
: mList(nullptr)
|
2011-09-26 01:04:27 +04:00
|
|
|
, mListIndex(0)
|
2011-10-17 18:59:28 +04:00
|
|
|
, mIsAnimValItem(false)
|
2013-04-02 23:17:41 +04:00
|
|
|
, mTransform(new nsSVGTransform()) // Default ctor for objects not in a list
|
|
|
|
// initialises to matrix type with identity
|
|
|
|
// matrix
|
2011-09-26 01:04:27 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-04-02 23:17:41 +04:00
|
|
|
SVGTransform::SVGTransform(const gfxMatrix &aMatrix)
|
2012-07-30 18:20:58 +04:00
|
|
|
: mList(nullptr)
|
2011-09-26 01:04:27 +04:00
|
|
|
, mListIndex(0)
|
2011-10-17 18:59:28 +04:00
|
|
|
, mIsAnimValItem(false)
|
2013-04-02 23:17:41 +04:00
|
|
|
, mTransform(new nsSVGTransform(aMatrix))
|
2011-09-26 01:04:27 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-04-02 23:17:41 +04:00
|
|
|
SVGTransform::SVGTransform(const nsSVGTransform &aTransform)
|
2012-07-30 18:20:58 +04:00
|
|
|
: mList(nullptr)
|
2011-09-26 01:04:27 +04:00
|
|
|
, mListIndex(0)
|
2011-10-17 18:59:28 +04:00
|
|
|
, mIsAnimValItem(false)
|
2013-04-02 23:17:41 +04:00
|
|
|
, mTransform(new nsSVGTransform(aTransform))
|
2011-09-26 01:04:27 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-04-02 23:17:41 +04:00
|
|
|
SVGTransform::~SVGTransform()
|
2013-01-11 11:15:06 +04:00
|
|
|
{
|
2013-05-31 02:34:53 +04:00
|
|
|
SVGMatrix* matrix = SVGMatrixTearoffTable().GetTearoff(this);
|
2013-01-20 00:56:31 +04:00
|
|
|
if (matrix) {
|
2013-05-31 02:34:53 +04:00
|
|
|
SVGMatrixTearoffTable().RemoveTearoff(this);
|
2013-01-20 00:56:31 +04:00
|
|
|
NS_RELEASE(matrix);
|
|
|
|
}
|
2013-01-11 11:15:06 +04: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-26 01:04:27 +04:00
|
|
|
|
2012-12-23 08:54:20 +04:00
|
|
|
uint16_t
|
2013-04-02 23:17:41 +04:00
|
|
|
SVGTransform::Type() const
|
2012-12-23 08:54:20 +04:00
|
|
|
{
|
|
|
|
return Transform().Type();
|
|
|
|
}
|
|
|
|
|
2013-01-20 00:56:31 +04:00
|
|
|
SVGMatrix*
|
2014-03-18 06:41:35 +04:00
|
|
|
SVGTransform::GetMatrix()
|
2011-09-26 01:04:27 +04:00
|
|
|
{
|
2013-01-20 00:56:31 +04:00
|
|
|
SVGMatrix* wrapper =
|
2013-05-31 02:34:53 +04:00
|
|
|
SVGMatrixTearoffTable().GetTearoff(this);
|
2013-01-11 11:15:06 +04:00
|
|
|
if (!wrapper) {
|
2013-01-20 00:56:31 +04:00
|
|
|
NS_ADDREF(wrapper = new SVGMatrix(*this));
|
2013-05-31 02:34:53 +04:00
|
|
|
SVGMatrixTearoffTable().AddTearoff(this, wrapper);
|
2011-09-26 01:04:27 +04:00
|
|
|
}
|
2013-01-20 00:56:31 +04:00
|
|
|
return wrapper;
|
2012-12-23 08:54:20 +04:00
|
|
|
}
|
2011-09-26 01:04:27 +04:00
|
|
|
|
2012-12-23 08:54:20 +04:00
|
|
|
float
|
2013-04-02 23:17:41 +04:00
|
|
|
SVGTransform::Angle() const
|
2012-12-23 08:54:20 +04:00
|
|
|
{
|
|
|
|
return Transform().Angle();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-04-02 23:17:41 +04:00
|
|
|
SVGTransform::SetMatrix(SVGMatrix& aMatrix, ErrorResult& rv)
|
2012-12-23 08:54:20 +04:00
|
|
|
{
|
|
|
|
if (mIsAnimValItem) {
|
|
|
|
rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
|
|
|
return;
|
|
|
|
}
|
2014-03-18 06:41:35 +04:00
|
|
|
SetMatrix(aMatrix.GetMatrix());
|
2012-12-23 08:54:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-04-02 23:17:41 +04:00
|
|
|
SVGTransform::SetTranslate(float tx, float ty, ErrorResult& rv)
|
2011-09-26 01:04:27 +04:00
|
|
|
{
|
|
|
|
if (mIsAnimValItem) {
|
2012-12-23 08:54:20 +04:00
|
|
|
rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
|
|
|
return;
|
2011-09-26 01:04:27 +04:00
|
|
|
}
|
|
|
|
|
2012-12-23 08:54:24 +04:00
|
|
|
if (Transform().Type() == SVG_TRANSFORM_TRANSLATE &&
|
2014-06-17 21:35:51 +04:00
|
|
|
Matrixgfx()._31 == tx && Matrixgfx()._32 == ty) {
|
2012-12-23 08:54:20 +04:00
|
|
|
return;
|
2012-02-16 03:40:46 +04:00
|
|
|
}
|
|
|
|
|
2013-12-25 02:09:22 +04:00
|
|
|
AutoChangeTransformNotifier notifier(this);
|
2011-09-26 01:04:27 +04:00
|
|
|
Transform().SetTranslate(tx, ty);
|
|
|
|
}
|
|
|
|
|
2012-12-23 08:54:20 +04:00
|
|
|
void
|
2013-04-02 23:17:41 +04:00
|
|
|
SVGTransform::SetScale(float sx, float sy, ErrorResult& rv)
|
2011-09-26 01:04:27 +04:00
|
|
|
{
|
|
|
|
if (mIsAnimValItem) {
|
2012-12-23 08:54:20 +04:00
|
|
|
rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
|
|
|
return;
|
2011-09-26 01:04:27 +04:00
|
|
|
}
|
|
|
|
|
2012-12-23 08:54:24 +04:00
|
|
|
if (Transform().Type() == SVG_TRANSFORM_SCALE &&
|
2014-06-17 21:35:51 +04:00
|
|
|
Matrixgfx()._11 == sx && Matrixgfx()._22 == sy) {
|
2012-12-23 08:54:20 +04:00
|
|
|
return;
|
2012-02-16 03:40:46 +04:00
|
|
|
}
|
2013-12-25 02:09:22 +04:00
|
|
|
AutoChangeTransformNotifier notifier(this);
|
2011-09-26 01:04:27 +04:00
|
|
|
Transform().SetScale(sx, sy);
|
|
|
|
}
|
|
|
|
|
2012-12-23 08:54:20 +04:00
|
|
|
void
|
2013-04-02 23:17:41 +04:00
|
|
|
SVGTransform::SetRotate(float angle, float cx, float cy, ErrorResult& rv)
|
2011-09-26 01:04:27 +04:00
|
|
|
{
|
|
|
|
if (mIsAnimValItem) {
|
2012-12-23 08:54:20 +04:00
|
|
|
rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
|
|
|
return;
|
2011-09-26 01:04:27 +04:00
|
|
|
}
|
|
|
|
|
2012-12-23 08:54:24 +04:00
|
|
|
if (Transform().Type() == SVG_TRANSFORM_ROTATE) {
|
2012-02-16 03:40:46 +04:00
|
|
|
float currentCx, currentCy;
|
|
|
|
Transform().GetRotationOrigin(currentCx, currentCy);
|
|
|
|
if (Transform().Angle() == angle && currentCx == cx && currentCy == cy) {
|
2012-12-23 08:54:20 +04:00
|
|
|
return;
|
2012-02-16 03:40:46 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-25 02:09:22 +04:00
|
|
|
AutoChangeTransformNotifier notifier(this);
|
2011-09-26 01:04:27 +04:00
|
|
|
Transform().SetRotate(angle, cx, cy);
|
|
|
|
}
|
|
|
|
|
2012-12-23 08:54:20 +04:00
|
|
|
void
|
2013-04-02 23:17:41 +04:00
|
|
|
SVGTransform::SetSkewX(float angle, ErrorResult& rv)
|
2011-09-26 01:04:27 +04:00
|
|
|
{
|
|
|
|
if (mIsAnimValItem) {
|
2012-12-23 08:54:20 +04:00
|
|
|
rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
|
|
|
return;
|
2011-09-26 01:04:27 +04:00
|
|
|
}
|
|
|
|
|
2012-12-23 08:54:24 +04:00
|
|
|
if (Transform().Type() == SVG_TRANSFORM_SKEWX &&
|
2012-02-16 03:40:46 +04:00
|
|
|
Transform().Angle() == angle) {
|
2012-12-23 08:54:20 +04:00
|
|
|
return;
|
2012-02-16 03:40:46 +04:00
|
|
|
}
|
|
|
|
|
2014-10-01 13:26:00 +04:00
|
|
|
if (!IsFinite(tan(angle * kRadPerDegree))) {
|
2015-02-04 14:46:26 +03:00
|
|
|
rv.ThrowRangeError(MSG_INVALID_TRANSFORM_ANGLE_ERROR);
|
2012-12-23 08:54:20 +04:00
|
|
|
return;
|
|
|
|
}
|
2013-12-25 02:09:22 +04:00
|
|
|
|
|
|
|
AutoChangeTransformNotifier notifier(this);
|
2013-12-25 12:33:48 +04:00
|
|
|
DebugOnly<nsresult> result = Transform().SetSkewX(angle);
|
|
|
|
MOZ_ASSERT(NS_SUCCEEDED(result), "SetSkewX unexpectedly failed");
|
2011-09-26 01:04:27 +04:00
|
|
|
}
|
|
|
|
|
2012-12-23 08:54:20 +04:00
|
|
|
void
|
2013-04-02 23:17:41 +04:00
|
|
|
SVGTransform::SetSkewY(float angle, ErrorResult& rv)
|
2011-09-26 01:04:27 +04:00
|
|
|
{
|
|
|
|
if (mIsAnimValItem) {
|
2012-12-23 08:54:20 +04:00
|
|
|
rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
|
|
|
return;
|
2011-09-26 01:04:27 +04:00
|
|
|
}
|
|
|
|
|
2012-12-23 08:54:24 +04:00
|
|
|
if (Transform().Type() == SVG_TRANSFORM_SKEWY &&
|
2012-02-16 03:40:46 +04:00
|
|
|
Transform().Angle() == angle) {
|
2012-12-23 08:54:20 +04:00
|
|
|
return;
|
2012-02-16 03:40:46 +04:00
|
|
|
}
|
|
|
|
|
2014-10-01 13:26:00 +04:00
|
|
|
if (!IsFinite(tan(angle * kRadPerDegree))) {
|
2015-02-04 14:46:26 +03:00
|
|
|
rv.ThrowRangeError(MSG_INVALID_TRANSFORM_ANGLE_ERROR);
|
2012-12-23 08:54:20 +04:00
|
|
|
return;
|
|
|
|
}
|
2013-12-25 02:09:22 +04:00
|
|
|
|
|
|
|
AutoChangeTransformNotifier notifier(this);
|
2013-12-25 12:33:48 +04:00
|
|
|
DebugOnly<nsresult> result = Transform().SetSkewY(angle);
|
|
|
|
MOZ_ASSERT(NS_SUCCEEDED(result), "SetSkewY unexpectedly failed");
|
2012-12-23 08:54:20 +04:00
|
|
|
}
|
2011-09-26 01:04:27 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// List management methods:
|
|
|
|
|
|
|
|
void
|
2013-04-02 23:17:41 +04:00
|
|
|
SVGTransform::InsertingIntoList(DOMSVGTransformList *aList,
|
|
|
|
uint32_t aListIndex,
|
|
|
|
bool aIsAnimValItem)
|
2011-09-26 01:04:27 +04:00
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!HasOwner(), "Inserting item that is already in a list");
|
2011-09-26 01:04:27 +04:00
|
|
|
|
|
|
|
mList = aList;
|
|
|
|
mListIndex = aListIndex;
|
|
|
|
mIsAnimValItem = aIsAnimValItem;
|
2012-07-30 18:20:58 +04:00
|
|
|
mTransform = nullptr;
|
2011-09-26 01:04:27 +04:00
|
|
|
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(IndexIsValid(), "Bad index for DOMSVGLength!");
|
2011-09-26 01:04:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-04-02 23:17:41 +04:00
|
|
|
SVGTransform::RemovingFromList()
|
2011-09-26 01:04:27 +04:00
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!mTransform,
|
|
|
|
"Item in list also has another non-list value associated with it");
|
2011-09-26 01:04:27 +04:00
|
|
|
|
2013-04-02 23:17:41 +04:00
|
|
|
mTransform = new nsSVGTransform(InternalItem());
|
2012-07-30 18:20:58 +04:00
|
|
|
mList = nullptr;
|
2011-10-17 18:59:28 +04:00
|
|
|
mIsAnimValItem = false;
|
2011-09-26 01:04:27 +04:00
|
|
|
}
|
|
|
|
|
2013-04-02 23:17:41 +04:00
|
|
|
nsSVGTransform&
|
2013-04-02 23:17:41 +04:00
|
|
|
SVGTransform::InternalItem()
|
2011-09-26 01:04:27 +04:00
|
|
|
{
|
2013-04-15 02:56:34 +04:00
|
|
|
nsSVGAnimatedTransformList *alist = Element()->GetAnimatedTransformList();
|
2011-09-26 01:04:27 +04:00
|
|
|
return mIsAnimValItem && alist->mAnimVal ?
|
|
|
|
(*alist->mAnimVal)[mListIndex] :
|
|
|
|
alist->mBaseVal[mListIndex];
|
|
|
|
}
|
|
|
|
|
2013-04-02 23:17:41 +04:00
|
|
|
const nsSVGTransform&
|
2013-04-02 23:17:41 +04:00
|
|
|
SVGTransform::InternalItem() const
|
2011-09-26 01:04:27 +04:00
|
|
|
{
|
2013-04-02 23:17:41 +04:00
|
|
|
return const_cast<SVGTransform*>(this)->InternalItem();
|
2011-09-26 01:04:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2013-04-02 23:17:41 +04:00
|
|
|
SVGTransform::IndexIsValid()
|
2011-09-26 01:04:27 +04:00
|
|
|
{
|
2013-04-15 02:56:34 +04:00
|
|
|
nsSVGAnimatedTransformList *alist = Element()->GetAnimatedTransformList();
|
2011-09-26 01:04:27 +04:00
|
|
|
return (mIsAnimValItem &&
|
|
|
|
mListIndex < alist->GetAnimValue().Length()) ||
|
|
|
|
(!mIsAnimValItem &&
|
|
|
|
mListIndex < alist->GetBaseValue().Length());
|
|
|
|
}
|
|
|
|
#endif // DEBUG
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2013-01-12 00:30:21 +04:00
|
|
|
// Interface for SVGMatrix's use
|
2011-09-26 01:04:27 +04:00
|
|
|
|
|
|
|
void
|
2013-04-02 23:17:41 +04:00
|
|
|
SVGTransform::SetMatrix(const gfxMatrix& aMatrix)
|
2011-09-26 01:04:27 +04:00
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!mIsAnimValItem,
|
|
|
|
"Attempting to modify read-only transform");
|
2012-02-16 03:40:46 +04:00
|
|
|
|
2012-12-23 08:54:24 +04:00
|
|
|
if (Transform().Type() == SVG_TRANSFORM_MATRIX &&
|
2013-04-02 23:17:41 +04:00
|
|
|
nsSVGTransform::MatricesEqual(Matrixgfx(), aMatrix)) {
|
2012-02-16 03:40:46 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-12-25 02:09:22 +04:00
|
|
|
AutoChangeTransformNotifier notifier(this);
|
2011-09-26 01:04:27 +04:00
|
|
|
Transform().SetMatrix(aMatrix);
|
|
|
|
}
|
|
|
|
|
2013-04-02 23:17:41 +04:00
|
|
|
} // namespace dom
|
2011-09-26 01:04:27 +04:00
|
|
|
} // namespace mozilla
|