SVGPatternElement.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 mozilla_dom_SVGPatternElement_h
  6. #define mozilla_dom_SVGPatternElement_h
  7. #include "nsAutoPtr.h"
  8. #include "nsSVGEnum.h"
  9. #include "nsSVGLength2.h"
  10. #include "nsSVGString.h"
  11. #include "nsSVGElement.h"
  12. #include "nsSVGViewBox.h"
  13. #include "SVGAnimatedPreserveAspectRatio.h"
  14. #include "nsSVGAnimatedTransformList.h"
  15. class nsSVGPatternFrame;
  16. nsresult NS_NewSVGPatternElement(nsIContent **aResult,
  17. already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
  18. namespace mozilla {
  19. namespace dom {
  20. class SVGAnimatedTransformList;
  21. typedef nsSVGElement SVGPatternElementBase;
  22. class SVGPatternElement final : public SVGPatternElementBase
  23. {
  24. friend class ::nsSVGPatternFrame;
  25. protected:
  26. friend nsresult (::NS_NewSVGPatternElement(nsIContent **aResult,
  27. already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
  28. explicit SVGPatternElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
  29. virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
  30. public:
  31. typedef mozilla::SVGAnimatedPreserveAspectRatio SVGAnimatedPreserveAspectRatio;
  32. // nsIContent interface
  33. NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* name) const override;
  34. virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
  35. // nsSVGSVGElement methods:
  36. virtual bool HasValidDimensions() const override;
  37. virtual mozilla::nsSVGAnimatedTransformList*
  38. GetAnimatedTransformList(uint32_t aFlags = 0) override;
  39. virtual nsIAtom* GetTransformListAttrName() const override {
  40. return nsGkAtoms::patternTransform;
  41. }
  42. // WebIDL
  43. already_AddRefed<SVGAnimatedRect> ViewBox();
  44. already_AddRefed<DOMSVGAnimatedPreserveAspectRatio> PreserveAspectRatio();
  45. already_AddRefed<SVGAnimatedEnumeration> PatternUnits();
  46. already_AddRefed<SVGAnimatedEnumeration> PatternContentUnits();
  47. already_AddRefed<SVGAnimatedTransformList> PatternTransform();
  48. already_AddRefed<SVGAnimatedLength> X();
  49. already_AddRefed<SVGAnimatedLength> Y();
  50. already_AddRefed<SVGAnimatedLength> Width();
  51. already_AddRefed<SVGAnimatedLength> Height();
  52. already_AddRefed<SVGAnimatedString> Href();
  53. protected:
  54. virtual LengthAttributesInfo GetLengthInfo() override;
  55. virtual EnumAttributesInfo GetEnumInfo() override;
  56. virtual nsSVGViewBox *GetViewBox() override;
  57. virtual SVGAnimatedPreserveAspectRatio *GetPreserveAspectRatio() override;
  58. virtual StringAttributesInfo GetStringInfo() override;
  59. enum { ATTR_X, ATTR_Y, ATTR_WIDTH, ATTR_HEIGHT };
  60. nsSVGLength2 mLengthAttributes[4];
  61. static LengthInfo sLengthInfo[4];
  62. enum { PATTERNUNITS, PATTERNCONTENTUNITS };
  63. nsSVGEnum mEnumAttributes[2];
  64. static EnumInfo sEnumInfo[2];
  65. nsAutoPtr<mozilla::nsSVGAnimatedTransformList> mPatternTransform;
  66. enum { HREF, XLINK_HREF };
  67. nsSVGString mStringAttributes[2];
  68. static StringInfo sStringInfo[2];
  69. // SVGFitToViewbox properties
  70. nsSVGViewBox mViewBox;
  71. SVGAnimatedPreserveAspectRatio mPreserveAspectRatio;
  72. };
  73. } // namespace dom
  74. } // namespace mozilla
  75. #endif // mozilla_dom_SVGPatternElement_h