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/. */
7 #ifndef DOM_SVG_SVGLINEELEMENT_H_
8 #define DOM_SVG_SVGLINEELEMENT_H_
10 #include "SVGAnimatedLength.h"
11 #include "SVGGeometryElement.h"
13 nsresult
NS_NewSVGLineElement(
14 nsIContent
** aResult
, already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
16 namespace mozilla::dom
{
18 using SVGLineElementBase
= SVGGeometryElement
;
20 class SVGLineElement final
: public SVGLineElementBase
{
22 explicit SVGLineElement(already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
23 JSObject
* WrapNode(JSContext
* cx
, JS::Handle
<JSObject
*> aGivenProto
) override
;
24 friend nsresult(::NS_NewSVGLineElement(
26 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
));
27 // If the input line has length zero and linecaps aren't butt, adjust |aX2| by
28 // a tiny amount to a barely-nonzero-length line that all of our draw targets
30 void MaybeAdjustForZeroLength(float aX1
, float aY1
, float& aX2
, float aY2
);
33 // SVGGeometryElement methods:
34 bool IsMarkable() override
{ return true; }
35 void GetMarkPoints(nsTArray
<SVGMark
>* aMarks
) override
;
36 void GetAsSimplePath(SimplePath
* aSimplePath
) override
;
37 already_AddRefed
<Path
> BuildPath(PathBuilder
* aBuilder
) override
;
38 bool GetGeometryBounds(
39 Rect
* aBounds
, const StrokeOptions
& aStrokeOptions
,
40 const Matrix
& aToBoundsSpace
,
41 const Matrix
* aToNonScalingStrokeSpace
= nullptr) override
;
43 nsresult
Clone(dom::NodeInfo
*, nsINode
** aResult
) const override
;
46 already_AddRefed
<DOMSVGAnimatedLength
> X1();
47 already_AddRefed
<DOMSVGAnimatedLength
> Y1();
48 already_AddRefed
<DOMSVGAnimatedLength
> X2();
49 already_AddRefed
<DOMSVGAnimatedLength
> Y2();
52 LengthAttributesInfo
GetLengthInfo() override
;
54 enum { ATTR_X1
, ATTR_Y1
, ATTR_X2
, ATTR_Y2
};
55 SVGAnimatedLength mLengthAttributes
[4];
56 static LengthInfo sLengthInfo
[4];
59 } // namespace mozilla::dom
61 #endif // DOM_SVG_SVGLINEELEMENT_H_