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 DOM_SVG_SVGCIRCLEELEMENT_H_
8 #define DOM_SVG_SVGCIRCLEELEMENT_H_
9 
10 #include "nsCSSPropertyID.h"
11 #include "SVGGeometryElement.h"
12 #include "SVGAnimatedLength.h"
13 
14 nsresult NS_NewSVGCircleElement(
15     nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
16 
17 namespace mozilla {
18 class ComputedStyle;
19 
20 namespace dom {
21 
22 using SVGCircleElementBase = SVGGeometryElement;
23 
24 class SVGCircleElement final : public SVGCircleElementBase {
25  protected:
26   explicit SVGCircleElement(
27       already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
28   virtual JSObject* WrapNode(JSContext* cx,
29                              JS::Handle<JSObject*> aGivenProto) override;
30   friend nsresult(::NS_NewSVGCircleElement(
31       nsIContent** aResult,
32       already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
33 
34  public:
35   NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
36 
37   // SVGSVGElement methods:
38   virtual bool HasValidDimensions() const override;
39 
40   // SVGGeometryElement methods:
41   virtual bool GetGeometryBounds(
42       Rect* aBounds, const StrokeOptions& aStrokeOptions,
43       const Matrix& aToBoundsSpace,
44       const Matrix* aToNonScalingStrokeSpace = nullptr) override;
45   virtual already_AddRefed<Path> BuildPath(PathBuilder* aBuilder) override;
46 
47   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
48 
49   static bool IsLengthChangedViaCSS(const ComputedStyle& aNewStyle,
50                                     const ComputedStyle& aOldStyle);
51   static nsCSSPropertyID GetCSSPropertyIdForAttrEnum(uint8_t aAttrEnum);
52 
53   // WebIDL
54   already_AddRefed<DOMSVGAnimatedLength> Cx();
55   already_AddRefed<DOMSVGAnimatedLength> Cy();
56   already_AddRefed<DOMSVGAnimatedLength> R();
57 
58  protected:
59   virtual LengthAttributesInfo GetLengthInfo() override;
60 
61   enum { ATTR_CX, ATTR_CY, ATTR_R };
62   SVGAnimatedLength mLengthAttributes[3];
63   static LengthInfo sLengthInfo[3];
64 };
65 
66 }  // namespace dom
67 }  // namespace mozilla
68 
69 #endif  // DOM_SVG_SVGCIRCLEELEMENT_H_
70