2011-09-25 21:04:27 +00: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 11:12:37 +00: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 21:04:27 +00:00
|
|
|
|
2013-04-02 19:17:41 +00:00
|
|
|
#ifndef mozilla_dom_SVGTransform_h
|
|
|
|
#define mozilla_dom_SVGTransform_h
|
2011-09-25 21:04:27 +00:00
|
|
|
|
|
|
|
#include "DOMSVGTransformList.h"
|
|
|
|
#include "nsAutoPtr.h"
|
2012-01-26 09:57:21 +00:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsDebug.h"
|
|
|
|
#include "nsID.h"
|
2013-04-02 19:17:41 +00:00
|
|
|
#include "nsSVGTransform.h"
|
2012-12-23 04:54:20 +00:00
|
|
|
#include "nsWrapperCache.h"
|
2012-06-19 02:30:09 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-01-26 09:57:21 +00:00
|
|
|
|
|
|
|
class nsSVGElement;
|
|
|
|
|
2014-06-25 11:59:46 +00:00
|
|
|
class gfxMatrix;
|
2011-09-25 21:04:27 +00:00
|
|
|
|
2012-09-23 00:48:27 +00:00
|
|
|
#define MOZ_SVG_LIST_INDEX_BIT_COUNT 31 // supports > 2 billion list items
|
2011-09-25 21:04:27 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
2013-01-11 20:30:21 +00:00
|
|
|
namespace dom {
|
2013-04-02 19:17:41 +00:00
|
|
|
|
2013-01-11 20:30:21 +00:00
|
|
|
class SVGMatrix;
|
2011-09-25 21:04:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* DOM wrapper for an SVG transform. See DOMSVGLength.h.
|
|
|
|
*/
|
2013-04-02 19:17:41 +00:00
|
|
|
class SVGTransform MOZ_FINAL : public nsWrapperCache
|
2011-09-25 21:04:27 +00:00
|
|
|
{
|
2013-12-24 22:09:22 +00:00
|
|
|
friend class AutoChangeTransformNotifier;
|
|
|
|
|
2011-09-25 21:04:27 +00:00
|
|
|
public:
|
2013-04-02 19:17:41 +00:00
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(SVGTransform)
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(SVGTransform)
|
2011-09-25 21:04:27 +00:00
|
|
|
|
|
|
|
/**
|
2013-04-02 19:17:41 +00:00
|
|
|
* Generic ctor for SVGTransform objects that are created for an attribute.
|
2011-09-25 21:04:27 +00:00
|
|
|
*/
|
2013-04-02 19:17:41 +00:00
|
|
|
SVGTransform(DOMSVGTransformList *aList,
|
|
|
|
uint32_t aListIndex,
|
|
|
|
bool aIsAnimValItem);
|
2011-09-25 21:04:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Ctors for creating the objects returned by:
|
|
|
|
* SVGSVGElement.createSVGTransform(),
|
|
|
|
* SVGSVGElement.createSVGTransformFromMatrix(in SVGMatrix matrix),
|
|
|
|
* SVGTransformList.createSVGTransformFromMatrix(in SVGMatrix matrix)
|
|
|
|
* which do not initially belong to an attribute.
|
|
|
|
*/
|
2013-04-02 19:17:41 +00:00
|
|
|
explicit SVGTransform();
|
|
|
|
explicit SVGTransform(const gfxMatrix &aMatrix);
|
2011-09-25 21:04:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Ctor for creating an unowned copy. Used with Clone().
|
|
|
|
*/
|
2013-04-02 19:17:41 +00:00
|
|
|
explicit SVGTransform(const nsSVGTransform &aMatrix);
|
2011-09-25 21:04:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create an unowned copy of an owned transform. The caller is responsible for
|
|
|
|
* the first AddRef().
|
|
|
|
*/
|
2013-04-02 19:17:41 +00:00
|
|
|
SVGTransform* Clone() {
|
2011-09-25 21:04:27 +00:00
|
|
|
NS_ASSERTION(mList, "unexpected caller");
|
2013-04-02 19:17:41 +00:00
|
|
|
return new SVGTransform(InternalItem());
|
2011-09-25 21:04:27 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsInList() const {
|
2011-09-25 21:04:27 +00:00
|
|
|
return !!mList;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* In future, if this class is used for non-list transforms, this will be
|
|
|
|
* different to IsInList().
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
bool HasOwner() const {
|
2011-09-25 21:04:27 +00:00
|
|
|
return !!mList;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This method is called to notify this DOM object that it is being inserted
|
|
|
|
* into a list, and give it the information it needs as a result.
|
|
|
|
*
|
|
|
|
* This object MUST NOT already belong to a list when this method is called.
|
|
|
|
* That's not to say that script can't move these DOM objects between
|
|
|
|
* lists - it can - it's just that the logic to handle that (and send out
|
|
|
|
* the necessary notifications) is located elsewhere (in
|
|
|
|
* DOMSVGTransformList).)
|
|
|
|
*/
|
|
|
|
void InsertingIntoList(DOMSVGTransformList *aList,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aListIndex,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aIsAnimValItem);
|
2011-09-25 21:04:27 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
static uint32_t MaxListIndex() {
|
2011-09-25 21:04:27 +00:00
|
|
|
return (1U << MOZ_SVG_LIST_INDEX_BIT_COUNT) - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// This method is called to notify this object that its list index changed.
|
2012-08-22 15:56:38 +00:00
|
|
|
void UpdateListIndex(uint32_t aListIndex) {
|
2011-09-25 21:04:27 +00:00
|
|
|
mListIndex = aListIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This method is called to notify this DOM object that it is about to be
|
|
|
|
* removed from its current DOM list so that it can first make a copy of its
|
|
|
|
* internal counterpart's values. (If it didn't do this, then it would
|
|
|
|
* "lose" its value on being removed.)
|
|
|
|
*/
|
|
|
|
void RemovingFromList();
|
|
|
|
|
2013-04-02 19:17:41 +00:00
|
|
|
nsSVGTransform ToSVGTransform() const {
|
2011-09-25 21:04:27 +00:00
|
|
|
return Transform();
|
|
|
|
}
|
|
|
|
|
2012-12-23 04:54:20 +00:00
|
|
|
// WebIDL
|
|
|
|
DOMSVGTransformList* GetParentObject() const { return mList; }
|
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 14:13:33 +00:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) MOZ_OVERRIDE;
|
2012-12-23 04:54:20 +00:00
|
|
|
uint16_t Type() const;
|
2014-03-18 02:41:35 +00:00
|
|
|
dom::SVGMatrix* GetMatrix();
|
2012-12-23 04:54:20 +00:00
|
|
|
float Angle() const;
|
2013-01-11 20:30:21 +00:00
|
|
|
void SetMatrix(dom::SVGMatrix& matrix, ErrorResult& rv);
|
2012-12-23 04:54:20 +00:00
|
|
|
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);
|
|
|
|
void SetSkewX(float angle, ErrorResult& rv);
|
|
|
|
void SetSkewY(float angle, ErrorResult& rv);
|
|
|
|
|
2011-09-25 21:04:27 +00:00
|
|
|
protected:
|
2014-06-24 16:36:45 +00:00
|
|
|
~SVGTransform();
|
|
|
|
|
2013-01-11 20:30:21 +00:00
|
|
|
// Interface for SVGMatrix's use
|
|
|
|
friend class dom::SVGMatrix;
|
2011-09-29 06:19:26 +00:00
|
|
|
const bool IsAnimVal() const {
|
2011-09-25 21:04:27 +00:00
|
|
|
return mIsAnimValItem;
|
|
|
|
}
|
2012-12-23 04:54:20 +00:00
|
|
|
const gfxMatrix& Matrixgfx() const {
|
2014-03-18 02:41:35 +00:00
|
|
|
return Transform().GetMatrix();
|
2011-09-25 21:04:27 +00:00
|
|
|
}
|
|
|
|
void SetMatrix(const gfxMatrix& aMatrix);
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsSVGElement* Element() {
|
|
|
|
return mList->Element();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-04-02 19:17:41 +00:00
|
|
|
* Get a reference to the internal nsSVGTransform list item that this DOM
|
2011-09-25 21:04:27 +00:00
|
|
|
* wrapper object currently wraps.
|
|
|
|
*/
|
2013-04-02 19:17:41 +00:00
|
|
|
nsSVGTransform& InternalItem();
|
|
|
|
const nsSVGTransform& InternalItem() const;
|
2011-09-25 21:04:27 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IndexIsValid();
|
2011-09-25 21:04:27 +00:00
|
|
|
#endif
|
|
|
|
|
2013-04-02 19:17:41 +00:00
|
|
|
const nsSVGTransform& Transform() const {
|
2011-09-25 21:04:27 +00:00
|
|
|
return HasOwner() ? InternalItem() : *mTransform;
|
|
|
|
}
|
2013-04-02 19:17:41 +00:00
|
|
|
nsSVGTransform& Transform() {
|
2011-09-25 21:04:27 +00:00
|
|
|
return HasOwner() ? InternalItem() : *mTransform;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRefPtr<DOMSVGTransformList> mList;
|
|
|
|
|
|
|
|
// Bounds for the following are checked in the ctor, so be sure to update
|
|
|
|
// that if you change the capacity of any of the following.
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mListIndex:MOZ_SVG_LIST_INDEX_BIT_COUNT;
|
2012-09-23 00:48:27 +00:00
|
|
|
uint32_t mIsAnimValItem:1;
|
2011-09-25 21:04:27 +00:00
|
|
|
|
2013-04-02 19:17:41 +00:00
|
|
|
// Usually this class acts as a wrapper for an nsSVGTransform object which is
|
2011-09-25 21:04:27 +00:00
|
|
|
// part of a list and is accessed by going via the owning Element.
|
|
|
|
//
|
|
|
|
// However, in some circumstances, objects of this class may not be associated
|
2013-04-02 19:17:41 +00:00
|
|
|
// with any particular list and thus, no internal nsSVGTransform object. In
|
|
|
|
// that case we allocate an nsSVGTransform object on the heap to store the data.
|
|
|
|
nsAutoPtr<nsSVGTransform> mTransform;
|
2011-09-25 21:04:27 +00:00
|
|
|
};
|
|
|
|
|
2013-04-02 19:17:41 +00:00
|
|
|
} // namespace dom
|
2011-09-25 21:04:27 +00:00
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#undef MOZ_SVG_LIST_INDEX_BIT_COUNT
|
|
|
|
|
2013-04-02 19:17:41 +00:00
|
|
|
#endif // mozilla_dom_SVGTransform_h
|