2015-05-03 19:32:37 +00: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 11:12:37 +00: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 17:01:28 +00:00
|
|
|
|
2013-01-12 22:22:31 +00:00
|
|
|
#ifndef mozilla_dom_SVGPathElement_h
|
|
|
|
#define mozilla_dom_SVGPathElement_h
|
2006-05-03 17:01:28 +00:00
|
|
|
|
2013-11-18 01:29:06 +00:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2015-10-18 05:24:48 +00:00
|
|
|
#include "mozilla/RefPtr.h"
|
2006-07-28 18:10:48 +00:00
|
|
|
#include "nsSVGNumber2.h"
|
2012-01-26 09:57:21 +00:00
|
|
|
#include "nsSVGPathGeometryElement.h"
|
2010-11-08 15:07:00 +00:00
|
|
|
#include "SVGAnimatedPathSegList.h"
|
2013-01-16 20:50:59 +00:00
|
|
|
#include "DOMSVGPathSeg.h"
|
2007-04-16 20:57:09 +00:00
|
|
|
|
2013-01-12 22:22:31 +00:00
|
|
|
nsresult NS_NewSVGPathElement(nsIContent **aResult,
|
2014-06-20 02:01:40 +00:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
|
2013-01-12 22:22:31 +00:00
|
|
|
|
|
|
|
typedef nsSVGPathGeometryElement SVGPathElementBase;
|
|
|
|
|
|
|
|
namespace mozilla {
|
2013-01-16 20:50:59 +00:00
|
|
|
|
|
|
|
class nsISVGPoint;
|
|
|
|
|
2013-01-12 22:22:31 +00:00
|
|
|
namespace dom {
|
2006-05-03 17:01:28 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class SVGPathElement final : public SVGPathElementBase
|
2006-05-03 17:01:28 +00:00
|
|
|
{
|
|
|
|
friend class nsSVGPathFrame;
|
|
|
|
|
2013-11-18 01:29:06 +00:00
|
|
|
typedef mozilla::gfx::Path Path;
|
|
|
|
|
2006-05-03 17:01:28 +00:00
|
|
|
protected:
|
2013-01-12 22:22:31 +00:00
|
|
|
friend nsresult (::NS_NewSVGPathElement(nsIContent **aResult,
|
2014-06-20 02:01:40 +00:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
|
2014-09-01 01:08:04 +00:00
|
|
|
explicit SVGPathElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
2006-05-03 17:01:28 +00:00
|
|
|
|
|
|
|
public:
|
2014-05-26 15:21:23 +00:00
|
|
|
// DOM memory reporter participant
|
|
|
|
NS_DECL_SIZEOF_EXCLUDING_THIS
|
|
|
|
|
2006-05-03 17:01:28 +00:00
|
|
|
// nsIContent interface
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* name) const override;
|
2006-05-03 17:01:28 +00:00
|
|
|
|
2012-03-03 09:21:09 +00:00
|
|
|
// nsSVGSVGElement methods:
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual bool HasValidDimensions() const override;
|
2012-03-03 09:21:09 +00:00
|
|
|
|
2006-06-21 15:42:28 +00:00
|
|
|
// nsSVGPathGeometryElement methods:
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual bool AttributeDefinesGeometry(const nsIAtom *aName) override;
|
|
|
|
virtual bool IsMarkable() override;
|
|
|
|
virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks) override;
|
2015-06-17 14:00:52 +00:00
|
|
|
virtual already_AddRefed<Path> BuildPath(PathBuilder* aBuilder) override;
|
2006-06-21 15:42:28 +00:00
|
|
|
|
2013-11-18 01:29:06 +00: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 14:00:52 +00:00
|
|
|
virtual already_AddRefed<Path> GetOrBuildPathForMeasuring() override;
|
2006-06-15 15:59:28 +00:00
|
|
|
|
2007-09-05 23:07:34 +00:00
|
|
|
// nsIContent interface
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
|
2006-09-05 10:22:54 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual SVGAnimatedPathSegList* GetAnimPathSegList() override {
|
2010-11-08 15:07:00 +00:00
|
|
|
return &mD;
|
|
|
|
}
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual nsIAtom* GetPathDataAttrName() const override {
|
2010-11-08 15:07:00 +00:00
|
|
|
return nsGkAtoms::d;
|
|
|
|
}
|
|
|
|
|
2011-11-21 21:22:19 +00:00
|
|
|
enum PathLengthScaleForType {
|
|
|
|
eForTextPath,
|
|
|
|
eForStroking
|
|
|
|
};
|
|
|
|
|
2011-11-15 13:11:43 +00: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 01:13:19 +00:00
|
|
|
float GetPathLengthScale(PathLengthScaleForType aFor);
|
2011-05-01 18:26:20 +00:00
|
|
|
|
2013-01-16 20:50:59 +00:00
|
|
|
// WebIDL
|
2013-07-01 07:03:04 +00:00
|
|
|
already_AddRefed<SVGAnimatedNumber> PathLength();
|
2014-07-03 18:50:42 +00:00
|
|
|
float GetTotalLength();
|
2013-01-16 20:50:59 +00: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 17:01:28 +00:00
|
|
|
protected:
|
|
|
|
|
2007-09-05 23:07:34 +00:00
|
|
|
// nsSVGElement method
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual NumberAttributesInfo GetNumberInfo() override;
|
2006-05-03 17:01:28 +00:00
|
|
|
|
2010-11-08 15:07:00 +00:00
|
|
|
SVGAnimatedPathSegList mD;
|
2006-07-28 18:10:48 +00:00
|
|
|
nsSVGNumber2 mPathLength;
|
|
|
|
static NumberInfo sNumberInfo;
|
2006-05-03 17:01:28 +00:00
|
|
|
};
|
|
|
|
|
2013-01-12 22:22:31 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_SVGPathElement_h
|