tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

SVGMarkerElement.h (3226B)


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