SVGTransformableElement.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef SVGTransformableElement_h
  6. #define SVGTransformableElement_h
  7. #include "mozilla/Attributes.h"
  8. #include "nsAutoPtr.h"
  9. #include "nsSVGAnimatedTransformList.h"
  10. #include "nsSVGElement.h"
  11. #include "gfxMatrix.h"
  12. #include "mozilla/gfx/Matrix.h"
  13. namespace mozilla {
  14. namespace dom {
  15. class SVGAnimatedTransformList;
  16. class SVGGraphicsElement;
  17. class SVGMatrix;
  18. class SVGIRect;
  19. struct SVGBoundingBoxOptions;
  20. class SVGTransformableElement : public nsSVGElement
  21. {
  22. public:
  23. explicit SVGTransformableElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
  24. : nsSVGElement(aNodeInfo) {}
  25. virtual ~SVGTransformableElement() {}
  26. virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override = 0;
  27. // WebIDL
  28. already_AddRefed<SVGAnimatedTransformList> Transform();
  29. nsSVGElement* GetNearestViewportElement();
  30. nsSVGElement* GetFarthestViewportElement();
  31. already_AddRefed<SVGIRect> GetBBox(const SVGBoundingBoxOptions& aOptions,
  32. ErrorResult& rv);
  33. already_AddRefed<SVGMatrix> GetCTM();
  34. already_AddRefed<SVGMatrix> GetScreenCTM();
  35. already_AddRefed<SVGMatrix> GetTransformToElement(SVGGraphicsElement& aElement,
  36. ErrorResult& rv);
  37. // nsIContent interface
  38. NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const override;
  39. nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
  40. int32_t aModType) const override;
  41. // nsSVGElement overrides
  42. virtual bool IsEventAttributeName(nsIAtom* aName) override;
  43. virtual gfxMatrix PrependLocalTransformsTo(
  44. const gfxMatrix &aMatrix,
  45. SVGTransformTypes aWhich = eAllTransforms) const override;
  46. virtual const gfx::Matrix* GetAnimateMotionTransform() const override;
  47. virtual void SetAnimateMotionTransform(const gfx::Matrix* aMatrix) override;
  48. virtual nsSVGAnimatedTransformList*
  49. GetAnimatedTransformList(uint32_t aFlags = 0) override;
  50. virtual nsIAtom* GetTransformListAttrName() const override {
  51. return nsGkAtoms::transform;
  52. }
  53. virtual bool IsTransformable() override { return true; }
  54. protected:
  55. nsAutoPtr<nsSVGAnimatedTransformList> mTransforms;
  56. // XXX maybe move this to property table, to save space on un-animated elems?
  57. nsAutoPtr<gfx::Matrix> mAnimateMotionTransform;
  58. };
  59. } // namespace dom
  60. } // namespace mozilla
  61. #endif // SVGTransformableElement_h