Merge mozilla-central to autoland on a CLOSED TREE
[gecko.git] / dom / svg / SVGMarkerElement.h
blob3904b36a87c642caf8f0d7e69554daf7b4270d3b
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_SVGMARKERELEMENT_H_
8 #define DOM_SVG_SVGMARKERELEMENT_H_
10 #include "SVGAnimatedEnumeration.h"
11 #include "SVGAnimatedLength.h"
12 #include "SVGAnimatedOrient.h"
13 #include "SVGAnimatedPreserveAspectRatio.h"
14 #include "SVGAnimatedViewBox.h"
15 #include "mozilla/Attributes.h"
16 #include "mozilla/dom/SVGElement.h"
17 #include "mozilla/dom/SVGMarkerElementBinding.h"
18 #include "mozilla/UniquePtr.h"
20 nsresult NS_NewSVGMarkerElement(
21 nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
23 namespace mozilla {
25 struct SVGMark;
26 class SVGMarkerFrame;
28 namespace dom {
30 class DOMSVGAnimatedAngle;
31 class DOMSVGAnimatedEnumeration;
33 using SVGMarkerElementBase = SVGElement;
35 class SVGMarkerElement final : public SVGMarkerElementBase {
36 friend class mozilla::SVGMarkerFrame;
38 protected:
39 friend nsresult(::NS_NewSVGMarkerElement(
40 nsIContent** aResult,
41 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
42 explicit SVGMarkerElement(
43 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
44 JSObject* WrapNode(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;
46 public:
47 // SVGSVGElement methods:
48 bool HasValidDimensions() const override;
50 // public helpers
51 gfx::Matrix GetMarkerTransform(float aStrokeWidth, const SVGMark& aMark);
52 SVGViewBox GetViewBox();
53 gfx::Matrix GetViewBoxTransform();
55 nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
57 // WebIDL
58 already_AddRefed<SVGAnimatedRect> ViewBox();
59 already_AddRefed<DOMSVGAnimatedPreserveAspectRatio> PreserveAspectRatio();
60 already_AddRefed<DOMSVGAnimatedLength> RefX();
61 already_AddRefed<DOMSVGAnimatedLength> RefY();
62 already_AddRefed<DOMSVGAnimatedEnumeration> MarkerUnits();
63 already_AddRefed<DOMSVGAnimatedLength> MarkerWidth();
64 already_AddRefed<DOMSVGAnimatedLength> MarkerHeight();
65 already_AddRefed<DOMSVGAnimatedEnumeration> OrientType();
66 already_AddRefed<DOMSVGAnimatedAngle> OrientAngle();
67 void SetOrientToAuto();
68 void SetOrientToAngle(DOMSVGAngle& aAngle);
70 protected:
71 void SetParentCoordCtxProvider(SVGViewportElement* aContext);
73 LengthAttributesInfo GetLengthInfo() override;
74 EnumAttributesInfo GetEnumInfo() override;
75 SVGAnimatedOrient* GetAnimatedOrient() override;
76 virtual SVGAnimatedPreserveAspectRatio* GetAnimatedPreserveAspectRatio()
77 override;
78 SVGAnimatedViewBox* GetAnimatedViewBox() override;
80 enum { REFX, REFY, MARKERWIDTH, MARKERHEIGHT };
81 SVGAnimatedLength mLengthAttributes[4];
82 static LengthInfo sLengthInfo[4];
84 enum { MARKERUNITS };
85 SVGAnimatedEnumeration mEnumAttributes[1];
86 static SVGEnumMapping sUnitsMap[];
87 static EnumInfo sEnumInfo[1];
89 SVGAnimatedOrient mOrient;
90 SVGAnimatedViewBox mViewBox;
91 SVGAnimatedPreserveAspectRatio mPreserveAspectRatio;
93 SVGViewportElement* mCoordCtx;
94 UniquePtr<gfx::Matrix> mViewBoxToViewportTransform;
97 } // namespace dom
98 } // namespace mozilla
100 #endif // DOM_SVG_SVGMARKERELEMENT_H_