SVGRectElement.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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_SVGRectElement_h
  6. #define mozilla_dom_SVGRectElement_h
  7. #include "nsSVGPathGeometryElement.h"
  8. #include "nsSVGLength2.h"
  9. nsresult NS_NewSVGRectElement(nsIContent **aResult,
  10. already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
  11. typedef nsSVGPathGeometryElement SVGRectElementBase;
  12. namespace mozilla {
  13. namespace dom {
  14. class SVGRectElement final : public SVGRectElementBase
  15. {
  16. protected:
  17. explicit SVGRectElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
  18. virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
  19. friend nsresult (::NS_NewSVGRectElement(nsIContent **aResult,
  20. already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
  21. public:
  22. // nsSVGSVGElement methods:
  23. virtual bool HasValidDimensions() const override;
  24. // nsSVGPathGeometryElement methods:
  25. virtual bool GetGeometryBounds(Rect* aBounds, const StrokeOptions& aStrokeOptions,
  26. const Matrix& aToBoundsSpace,
  27. const Matrix* aToNonScalingStrokeSpace = nullptr) override;
  28. virtual void GetAsSimplePath(SimplePath* aSimplePath) override;
  29. virtual already_AddRefed<Path> BuildPath(PathBuilder* aBuilder = nullptr) override;
  30. virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
  31. // WebIDL
  32. already_AddRefed<SVGAnimatedLength> X();
  33. already_AddRefed<SVGAnimatedLength> Y();
  34. already_AddRefed<SVGAnimatedLength> Height();
  35. already_AddRefed<SVGAnimatedLength> Width();
  36. already_AddRefed<SVGAnimatedLength> Rx();
  37. already_AddRefed<SVGAnimatedLength> Ry();
  38. protected:
  39. virtual LengthAttributesInfo GetLengthInfo() override;
  40. enum { ATTR_X, ATTR_Y, ATTR_WIDTH, ATTR_HEIGHT, ATTR_RX, ATTR_RY };
  41. nsSVGLength2 mLengthAttributes[6];
  42. static LengthInfo sLengthInfo[6];
  43. };
  44. } // namespace dom
  45. } // namespace mozilla
  46. #endif // mozilla_dom_SVGRectElement_h