1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef DOM_SVG_SVGTRANSFORMABLEELEMENT_H_
8 #define DOM_SVG_SVGTRANSFORMABLEELEMENT_H_
10 #include "SVGAnimatedTransformList.h"
11 #include "gfxMatrix.h"
12 #include "mozilla/Attributes.h"
13 #include "mozilla/dom/SVGElement.h"
14 #include "mozilla/gfx/Matrix.h"
15 #include "mozilla/UniquePtr.h"
20 class DOMSVGAnimatedTransformList
;
21 class SVGGraphicsElement
;
24 struct SVGBoundingBoxOptions
;
26 class SVGTransformableElement
: public SVGElement
{
28 explicit SVGTransformableElement(already_AddRefed
<dom::NodeInfo
>&& aNodeInfo
)
29 : SVGElement(std::move(aNodeInfo
)) {}
30 virtual ~SVGTransformableElement() = default;
32 virtual nsresult
Clone(dom::NodeInfo
*, nsINode
** aResult
) const override
= 0;
35 already_AddRefed
<DOMSVGAnimatedTransformList
> Transform();
36 SVGElement
* GetNearestViewportElement();
37 SVGElement
* GetFarthestViewportElement();
39 already_AddRefed
<SVGRect
> GetBBox(const SVGBoundingBoxOptions
&);
40 already_AddRefed
<SVGMatrix
> GetCTM();
41 already_AddRefed
<SVGMatrix
> GetScreenCTM();
42 already_AddRefed
<SVGMatrix
> GetTransformToElement(
43 SVGGraphicsElement
& aElement
, ErrorResult
& rv
);
45 // nsIContent interface
46 NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom
* aAttribute
) const override
;
48 nsChangeHint
GetAttributeChangeHint(const nsAtom
* aAttribute
,
49 int32_t aModType
) const override
;
51 // SVGElement overrides
52 virtual bool IsEventAttributeNameInternal(nsAtom
* aName
) override
;
54 virtual gfxMatrix
PrependLocalTransformsTo(
55 const gfxMatrix
& aMatrix
,
56 SVGTransformTypes aWhich
= eAllTransforms
) const override
;
57 virtual const gfx::Matrix
* GetAnimateMotionTransform() const override
;
58 virtual void SetAnimateMotionTransform(const gfx::Matrix
* aMatrix
) override
;
60 virtual SVGAnimatedTransformList
* GetAnimatedTransformList(
61 uint32_t aFlags
= 0) override
;
62 virtual nsStaticAtom
* GetTransformListAttrName() const override
{
63 return nsGkAtoms::transform
;
66 virtual bool IsTransformable() override
{ return true; }
70 * Helper for overrides of PrependLocalTransformsTo. If both arguments are
71 * provided they are multiplied in the order in which the arguments appear,
72 * and the result is returned. If neither argument is provided, the identity
73 * matrix is returned. If only one argument is provided its transform is
76 static gfxMatrix
GetUserToParentTransform(
77 const gfx::Matrix
* aAnimateMotionTransform
,
78 const SVGAnimatedTransformList
* aTransforms
);
80 UniquePtr
<SVGAnimatedTransformList
> mTransforms
;
82 // XXX maybe move this to property table, to save space on un-animated elems?
83 UniquePtr
<gfx::Matrix
> mAnimateMotionTransform
;
87 } // namespace mozilla
89 #endif // DOM_SVG_SVGTRANSFORMABLEELEMENT_H_