Merge mozilla-central to autoland on a CLOSED TREE
[gecko.git] / dom / svg / SVGTransformableElement.h
blob2f6a504ce2c245d71105ce867ead889e49103d97
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 "gfxMatrix.h"
11 #include "mozilla/Attributes.h"
12 #include "mozilla/dom/SVGAnimatedTransformList.h"
13 #include "mozilla/dom/SVGElement.h"
14 #include "mozilla/gfx/Matrix.h"
15 #include "mozilla/UniquePtr.h"
17 namespace mozilla::dom {
19 class DOMSVGAnimatedTransformList;
20 class SVGGraphicsElement;
21 class SVGMatrix;
22 class SVGRect;
23 struct SVGBoundingBoxOptions;
25 class SVGTransformableElement : public SVGElement {
26 public:
27 explicit SVGTransformableElement(already_AddRefed<dom::NodeInfo>&& aNodeInfo)
28 : SVGElement(std::move(aNodeInfo)) {}
29 virtual ~SVGTransformableElement() = default;
31 nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override = 0;
33 // WebIDL
34 already_AddRefed<DOMSVGAnimatedTransformList> Transform();
36 // nsIContent interface
37 nsChangeHint GetAttributeChangeHint(const nsAtom* aAttribute,
38 int32_t aModType) const override;
40 // SVGElement overrides
41 bool IsEventAttributeNameInternal(nsAtom* aName) override;
43 gfxMatrix PrependLocalTransformsTo(
44 const gfxMatrix& aMatrix,
45 SVGTransformTypes aWhich = eAllTransforms) const override;
46 const gfx::Matrix* GetAnimateMotionTransform() const override;
47 void SetAnimateMotionTransform(const gfx::Matrix* aMatrix) override;
49 SVGAnimatedTransformList* GetAnimatedTransformList(
50 uint32_t aFlags = 0) override;
51 nsStaticAtom* GetTransformListAttrName() const override {
52 return nsGkAtoms::transform;
55 bool IsTransformable() override { return true; }
57 protected:
58 /**
59 * Helper for overrides of PrependLocalTransformsTo. If both arguments are
60 * provided they are multiplied in the order in which the arguments appear,
61 * and the result is returned. If neither argument is provided, the identity
62 * matrix is returned. If only one argument is provided its transform is
63 * returned.
65 static gfxMatrix GetUserToParentTransform(
66 const gfx::Matrix* aAnimateMotionTransform,
67 const SVGAnimatedTransformList* aTransforms);
69 UniquePtr<SVGAnimatedTransformList> mTransforms;
71 // XXX maybe move this to property table, to save space on un-animated elems?
72 UniquePtr<gfx::Matrix> mAnimateMotionTransform;
75 } // namespace mozilla::dom
77 #endif // DOM_SVG_SVGTRANSFORMABLEELEMENT_H_