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