SVGTextPathElement.h (2859B)
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_SVGTEXTPATHELEMENT_H_ 8 #define DOM_SVG_SVGTEXTPATHELEMENT_H_ 9 10 #include "SVGAnimatedEnumeration.h" 11 #include "SVGAnimatedLength.h" 12 #include "SVGAnimatedPathSegList.h" 13 #include "SVGAnimatedString.h" 14 #include "mozilla/dom/SVGTextContentElement.h" 15 16 class nsAtom; 17 class nsIContent; 18 19 nsresult NS_NewSVGTextPathElement( 20 nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo); 21 22 namespace mozilla::dom { 23 24 // textPath side types 25 static const uint16_t TEXTPATH_SIDETYPE_LEFT = 1; 26 static const uint16_t TEXTPATH_SIDETYPE_RIGHT = 2; 27 28 using SVGTextPathElementBase = SVGTextContentElement; 29 30 class SVGTextPathElement final : public SVGTextPathElementBase { 31 friend class mozilla::SVGTextFrame; 32 33 protected: 34 friend nsresult(::NS_NewSVGTextPathElement( 35 nsIContent** aResult, 36 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)); 37 explicit SVGTextPathElement( 38 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo); 39 JSObject* WrapNode(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override; 40 41 public: 42 // nsIContent interface 43 nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override; 44 45 SVGAnimatedPathSegList* GetAnimPathSegList() override { return &mPath; } 46 47 nsStaticAtom* GetPathDataAttrName() const override { return nsGkAtoms::path; } 48 49 // WebIDL 50 already_AddRefed<DOMSVGAnimatedLength> StartOffset(); 51 already_AddRefed<DOMSVGAnimatedEnumeration> Method(); 52 already_AddRefed<DOMSVGAnimatedEnumeration> Spacing(); 53 already_AddRefed<DOMSVGAnimatedEnumeration> Side(); 54 already_AddRefed<DOMSVGAnimatedString> Href(); 55 56 void HrefAsString(nsAString& aHref); 57 58 protected: 59 LengthAttributesInfo GetLengthInfo() override; 60 EnumAttributesInfo GetEnumInfo() override; 61 StringAttributesInfo GetStringInfo() override; 62 63 enum { /* TEXTLENGTH, */ STARTOFFSET = 1 }; 64 SVGAnimatedLength mLengthAttributes[2]; 65 SVGAnimatedLength* LengthAttributes() override { return mLengthAttributes; } 66 static LengthInfo sLengthInfo[2]; 67 68 enum { /* LENGTHADJUST, */ METHOD = 1, SPACING, SIDE }; 69 SVGAnimatedEnumeration mEnumAttributes[4]; 70 SVGAnimatedEnumeration* EnumAttributes() override { return mEnumAttributes; } 71 static SVGEnumMapping sMethodMap[]; 72 static SVGEnumMapping sSpacingMap[]; 73 static SVGEnumMapping sSideMap[]; 74 static EnumInfo sEnumInfo[4]; 75 76 enum { HREF, XLINK_HREF }; 77 SVGAnimatedString mStringAttributes[2]; 78 static StringInfo sStringInfo[2]; 79 80 SVGAnimatedPathSegList mPath; 81 }; 82 83 } // namespace mozilla::dom 84 85 #endif // DOM_SVG_SVGTEXTPATHELEMENT_H_