2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2006-05-03 21:01:28 +04:00
|
|
|
|
2013-01-13 02:22:31 +04:00
|
|
|
#ifndef mozilla_dom_SVGPathElement_h
|
|
|
|
#define mozilla_dom_SVGPathElement_h
|
2006-05-03 21:01:28 +04:00
|
|
|
|
2013-11-18 05:29:06 +04:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2015-10-18 07:40:10 +03:00
|
|
|
#include "mozilla/nsRefPtr.h"
|
2006-07-28 22:10:48 +04:00
|
|
|
#include "nsSVGNumber2.h"
|
2012-01-26 13:57:21 +04:00
|
|
|
#include "nsSVGPathGeometryElement.h"
|
2010-11-08 18:07:00 +03:00
|
|
|
#include "SVGAnimatedPathSegList.h"
|
2013-01-17 00:50:59 +04:00
|
|
|
#include "DOMSVGPathSeg.h"
|
2007-04-17 00:57:09 +04:00
|
|
|
|
2013-01-13 02:22:31 +04:00
|
|
|
nsresult NS_NewSVGPathElement(nsIContent **aResult,
|
2014-06-20 06:01:40 +04:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
|
2013-01-13 02:22:31 +04:00
|
|
|
|
|
|
|
typedef nsSVGPathGeometryElement SVGPathElementBase;
|
|
|
|
|
|
|
|
namespace mozilla {
|
2013-01-17 00:50:59 +04:00
|
|
|
|
|
|
|
class nsISVGPoint;
|
|
|
|
|
2013-01-13 02:22:31 +04:00
|
|
|
namespace dom {
|
2006-05-03 21:01:28 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class SVGPathElement final : public SVGPathElementBase
|
2006-05-03 21:01:28 +04:00
|
|
|
{
|
|
|
|
friend class nsSVGPathFrame;
|
|
|
|
|
2013-11-18 05:29:06 +04:00
|
|
|
typedef mozilla::gfx::Path Path;
|
|
|
|
|
2006-05-03 21:01:28 +04:00
|
|
|
protected:
|
2013-01-13 02:22:31 +04:00
|
|
|
friend nsresult (::NS_NewSVGPathElement(nsIContent **aResult,
|
2014-06-20 06:01:40 +04:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
|
2014-09-01 05:08:04 +04:00
|
|
|
explicit SVGPathElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
2006-05-03 21:01:28 +04:00
|
|
|
|
|
|
|
public:
|
2014-05-26 19:21:23 +04:00
|
|
|
// DOM memory reporter participant
|
|
|
|
NS_DECL_SIZEOF_EXCLUDING_THIS
|
|
|
|
|
2006-05-03 21:01:28 +04:00
|
|
|
// nsIContent interface
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* name) const override;
|
2006-05-03 21:01:28 +04:00
|
|
|
|
2012-03-03 13:21:09 +04:00
|
|
|
// nsSVGSVGElement methods:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool HasValidDimensions() const override;
|
2012-03-03 13:21:09 +04:00
|
|
|
|
2006-06-21 19:42:28 +04:00
|
|
|
// nsSVGPathGeometryElement methods:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool AttributeDefinesGeometry(const nsIAtom *aName) override;
|
|
|
|
virtual bool IsMarkable() override;
|
|
|
|
virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks) override;
|
2015-06-17 17:00:52 +03:00
|
|
|
virtual already_AddRefed<Path> BuildPath(PathBuilder* aBuilder) override;
|
2006-06-21 19:42:28 +04:00
|
|
|
|
2013-11-18 05:29:06 +04:00
|
|
|
/**
|
|
|
|
* This returns a path without the extra little line segments that
|
|
|
|
* ApproximateZeroLengthSubpathSquareCaps can insert if we have square-caps.
|
|
|
|
* See the comment for that function for more info on that.
|
|
|
|
*/
|
2015-06-17 17:00:52 +03:00
|
|
|
virtual already_AddRefed<Path> GetOrBuildPathForMeasuring() override;
|
2006-06-15 19:59:28 +04:00
|
|
|
|
2007-09-06 03:07:34 +04:00
|
|
|
// nsIContent interface
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
|
2006-09-05 14:22:54 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual SVGAnimatedPathSegList* GetAnimPathSegList() override {
|
2010-11-08 18:07:00 +03:00
|
|
|
return &mD;
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsIAtom* GetPathDataAttrName() const override {
|
2010-11-08 18:07:00 +03:00
|
|
|
return nsGkAtoms::d;
|
|
|
|
}
|
|
|
|
|
2011-11-22 01:22:19 +04:00
|
|
|
enum PathLengthScaleForType {
|
|
|
|
eForTextPath,
|
|
|
|
eForStroking
|
|
|
|
};
|
|
|
|
|
2011-11-15 17:11:43 +04:00
|
|
|
/**
|
|
|
|
* Gets the ratio of the actual path length to the content author's estimated
|
|
|
|
* length (as provided by the <path> element's 'pathLength' attribute). This
|
|
|
|
* is used to scale stroke dashing, and to scale offsets along a textPath.
|
|
|
|
*/
|
2014-03-19 05:13:19 +04:00
|
|
|
float GetPathLengthScale(PathLengthScaleForType aFor);
|
2011-05-01 22:26:20 +04:00
|
|
|
|
2013-01-17 00:50:59 +04:00
|
|
|
// WebIDL
|
2013-07-01 11:03:04 +04:00
|
|
|
already_AddRefed<SVGAnimatedNumber> PathLength();
|
2014-07-03 22:50:42 +04:00
|
|
|
float GetTotalLength();
|
2013-01-17 00:50:59 +04:00
|
|
|
already_AddRefed<nsISVGPoint> GetPointAtLength(float distance, ErrorResult& rv);
|
|
|
|
uint32_t GetPathSegAtLength(float distance);
|
|
|
|
already_AddRefed<DOMSVGPathSegClosePath> CreateSVGPathSegClosePath();
|
|
|
|
already_AddRefed<DOMSVGPathSegMovetoAbs> CreateSVGPathSegMovetoAbs(float x, float y);
|
|
|
|
already_AddRefed<DOMSVGPathSegMovetoRel> CreateSVGPathSegMovetoRel(float x, float y);
|
|
|
|
already_AddRefed<DOMSVGPathSegLinetoAbs> CreateSVGPathSegLinetoAbs(float x, float y);
|
|
|
|
already_AddRefed<DOMSVGPathSegLinetoRel> CreateSVGPathSegLinetoRel(float x, float y);
|
|
|
|
already_AddRefed<DOMSVGPathSegCurvetoCubicAbs>
|
|
|
|
CreateSVGPathSegCurvetoCubicAbs(float x, float y, float x1, float y1, float x2, float y2);
|
|
|
|
already_AddRefed<DOMSVGPathSegCurvetoCubicRel>
|
|
|
|
CreateSVGPathSegCurvetoCubicRel(float x, float y, float x1, float y1, float x2, float y2);
|
|
|
|
already_AddRefed<DOMSVGPathSegCurvetoQuadraticAbs>
|
|
|
|
CreateSVGPathSegCurvetoQuadraticAbs(float x, float y, float x1, float y1);
|
|
|
|
already_AddRefed<DOMSVGPathSegCurvetoQuadraticRel>
|
|
|
|
CreateSVGPathSegCurvetoQuadraticRel(float x, float y, float x1, float y1);
|
|
|
|
already_AddRefed<DOMSVGPathSegArcAbs>
|
|
|
|
CreateSVGPathSegArcAbs(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag);
|
|
|
|
already_AddRefed<DOMSVGPathSegArcRel>
|
|
|
|
CreateSVGPathSegArcRel(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag);
|
|
|
|
already_AddRefed<DOMSVGPathSegLinetoHorizontalAbs> CreateSVGPathSegLinetoHorizontalAbs(float x);
|
|
|
|
already_AddRefed<DOMSVGPathSegLinetoHorizontalRel> CreateSVGPathSegLinetoHorizontalRel(float x);
|
|
|
|
already_AddRefed<DOMSVGPathSegLinetoVerticalAbs> CreateSVGPathSegLinetoVerticalAbs(float y);
|
|
|
|
already_AddRefed<DOMSVGPathSegLinetoVerticalRel> CreateSVGPathSegLinetoVerticalRel(float y);
|
|
|
|
already_AddRefed<DOMSVGPathSegCurvetoCubicSmoothAbs>
|
|
|
|
CreateSVGPathSegCurvetoCubicSmoothAbs(float x, float y, float x2, float y2);
|
|
|
|
already_AddRefed<DOMSVGPathSegCurvetoCubicSmoothRel>
|
|
|
|
CreateSVGPathSegCurvetoCubicSmoothRel(float x, float y, float x2, float y2);
|
|
|
|
already_AddRefed<DOMSVGPathSegCurvetoQuadraticSmoothAbs>
|
|
|
|
CreateSVGPathSegCurvetoQuadraticSmoothAbs(float x, float y);
|
|
|
|
already_AddRefed<DOMSVGPathSegCurvetoQuadraticSmoothRel>
|
|
|
|
CreateSVGPathSegCurvetoQuadraticSmoothRel(float x, float y);
|
|
|
|
already_AddRefed<DOMSVGPathSegList> PathSegList();
|
|
|
|
already_AddRefed<DOMSVGPathSegList> AnimatedPathSegList();
|
|
|
|
|
2006-05-03 21:01:28 +04:00
|
|
|
protected:
|
|
|
|
|
2007-09-06 03:07:34 +04:00
|
|
|
// nsSVGElement method
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual NumberAttributesInfo GetNumberInfo() override;
|
2006-05-03 21:01:28 +04:00
|
|
|
|
2010-11-08 18:07:00 +03:00
|
|
|
SVGAnimatedPathSegList mD;
|
2006-07-28 22:10:48 +04:00
|
|
|
nsSVGNumber2 mPathLength;
|
|
|
|
static NumberInfo sNumberInfo;
|
2006-05-03 21:01:28 +04:00
|
|
|
};
|
|
|
|
|
2013-01-13 02:22:31 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_SVGPathElement_h
|