Bug 1663089 [wpt PR 25399] - idle-detection: Implement requestPermission() method...
[gecko.git] / dom / svg / SVGTransformableElement.h
blob77c11bae0818a59b666b8c7e5efc326aef379ab2
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"
17 namespace mozilla {
18 namespace dom {
20 class DOMSVGAnimatedTransformList;
21 class SVGGraphicsElement;
22 class SVGMatrix;
23 class SVGRect;
24 struct SVGBoundingBoxOptions;
26 class SVGTransformableElement : public SVGElement {
27 public:
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;
34 // WebIDL
35 already_AddRefed<DOMSVGAnimatedTransformList> Transform();
36 SVGElement* GetNearestViewportElement();
37 SVGElement* GetFarthestViewportElement();
38 MOZ_CAN_RUN_SCRIPT
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; }
68 protected:
69 /**
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
74 * returned.
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;
86 } // namespace dom
87 } // namespace mozilla
89 #endif // DOM_SVG_SVGTRANSFORMABLEELEMENT_H_