SVGLineElement.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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_SVGLineElement_h
  6. #define mozilla_dom_SVGLineElement_h
  7. #include "nsSVGPathGeometryElement.h"
  8. #include "nsSVGLength2.h"
  9. nsresult NS_NewSVGLineElement(nsIContent **aResult,
  10. already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
  11. namespace mozilla {
  12. namespace dom {
  13. typedef nsSVGPathGeometryElement SVGLineElementBase;
  14. class SVGLineElement final : public SVGLineElementBase
  15. {
  16. protected:
  17. explicit SVGLineElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
  18. virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
  19. friend nsresult (::NS_NewSVGLineElement(nsIContent **aResult,
  20. already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
  21. // If the input line has length zero and linecaps aren't butt, adjust |aX2| by
  22. // a tiny amount to a barely-nonzero-length line that all of our draw targets
  23. // will render
  24. void MaybeAdjustForZeroLength(float aX1, float aY1, float& aX2, float aY2);
  25. public:
  26. // nsIContent interface
  27. NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* name) const override;
  28. // nsSVGPathGeometryElement methods:
  29. virtual bool IsMarkable() override { return true; }
  30. virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks) override;
  31. virtual void GetAsSimplePath(SimplePath* aSimplePath) override;
  32. virtual already_AddRefed<Path> BuildPath(PathBuilder* aBuilder) override;
  33. virtual bool GetGeometryBounds(Rect* aBounds, const StrokeOptions& aStrokeOptions,
  34. const Matrix& aToBoundsSpace,
  35. const Matrix* aToNonScalingStrokeSpace = nullptr) override;
  36. virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
  37. // WebIDL
  38. already_AddRefed<SVGAnimatedLength> X1();
  39. already_AddRefed<SVGAnimatedLength> Y1();
  40. already_AddRefed<SVGAnimatedLength> X2();
  41. already_AddRefed<SVGAnimatedLength> Y2();
  42. protected:
  43. virtual LengthAttributesInfo GetLengthInfo() override;
  44. enum { ATTR_X1, ATTR_Y1, ATTR_X2, ATTR_Y2 };
  45. nsSVGLength2 mLengthAttributes[4];
  46. static LengthInfo sLengthInfo[4];
  47. };
  48. } // namespace dom
  49. } // namespace mozilla
  50. #endif // mozilla_dom_SVGLineElement_h