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-04-14 19:09:39 +04:00
|
|
|
|
2013-01-30 02:11:44 +04:00
|
|
|
#ifndef mozilla_dom_SVGMarkerElement_h
|
|
|
|
#define mozilla_dom_SVGMarkerElement_h
|
2006-04-14 19:09:39 +04:00
|
|
|
|
2016-06-07 23:10:18 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2007-10-10 14:07:59 +04:00
|
|
|
#include "nsSVGAngle.h"
|
2012-01-26 13:57:21 +04:00
|
|
|
#include "nsSVGEnum.h"
|
|
|
|
#include "nsSVGLength2.h"
|
2009-02-03 17:42:24 +03:00
|
|
|
#include "nsSVGViewBox.h"
|
2010-12-20 03:45:29 +03:00
|
|
|
#include "SVGAnimatedPreserveAspectRatio.h"
|
2013-01-30 02:11:44 +04:00
|
|
|
#include "nsSVGElement.h"
|
2012-06-19 06:30:09 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-07-01 11:02:46 +04:00
|
|
|
#include "mozilla/dom/SVGAnimatedEnumeration.h"
|
2018-02-18 18:53:13 +03:00
|
|
|
#include "mozilla/dom/SVGMarkerElementBinding.h"
|
2006-04-14 19:09:39 +04:00
|
|
|
|
2013-01-30 02:11:44 +04:00
|
|
|
class nsSVGMarkerFrame;
|
2017-06-08 08:17:07 +03:00
|
|
|
struct nsSVGMark;
|
2013-01-30 02:11:44 +04:00
|
|
|
|
|
|
|
nsresult NS_NewSVGMarkerElement(nsIContent **aResult,
|
2014-06-20 06:01:40 +04:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
|
2013-01-30 02:11:44 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2018-02-18 18:53:13 +03:00
|
|
|
// Non-Exposed Marker Orientation Types
|
|
|
|
static const uint16_t SVG_MARKER_ORIENT_AUTO_START_REVERSE = 3;
|
2013-02-19 02:48:54 +04:00
|
|
|
|
2008-01-09 12:52:14 +03:00
|
|
|
class nsSVGOrientType
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsSVGOrientType()
|
2018-02-18 18:53:13 +03:00
|
|
|
: mAnimVal(SVGMarkerElementBinding::SVG_MARKER_ORIENT_ANGLE),
|
|
|
|
mBaseVal(SVGMarkerElementBinding::SVG_MARKER_ORIENT_ANGLE) {}
|
2008-01-09 12:52:14 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult SetBaseValue(uint16_t aValue,
|
2008-01-09 12:52:14 +03:00
|
|
|
nsSVGElement *aSVGElement);
|
|
|
|
|
2010-02-19 00:50:59 +03:00
|
|
|
// XXX FIXME like https://bugzilla.mozilla.org/show_bug.cgi?id=545550 but
|
|
|
|
// without adding an mIsAnimated member...?
|
2012-08-22 19:56:38 +04:00
|
|
|
void SetBaseValue(uint16_t aValue)
|
|
|
|
{ mAnimVal = mBaseVal = uint8_t(aValue); }
|
2010-02-19 00:50:59 +03:00
|
|
|
// no need to notify, since nsSVGAngle does that
|
2012-08-22 19:56:38 +04:00
|
|
|
void SetAnimValue(uint16_t aValue)
|
|
|
|
{ mAnimVal = uint8_t(aValue); }
|
2008-01-09 12:52:14 +03:00
|
|
|
|
2013-07-12 10:39:38 +04:00
|
|
|
// we want to avoid exposing SVG_MARKER_ORIENT_AUTO_START_REVERSE to
|
|
|
|
// Web content
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t GetBaseValue() const
|
2013-07-12 10:39:38 +04:00
|
|
|
{ return mAnimVal == SVG_MARKER_ORIENT_AUTO_START_REVERSE ?
|
2018-02-18 18:53:13 +03:00
|
|
|
SVGMarkerElementBinding::SVG_MARKER_ORIENT_UNKNOWN : mBaseVal; }
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t GetAnimValue() const
|
2013-07-12 10:39:38 +04:00
|
|
|
{ return mAnimVal == SVG_MARKER_ORIENT_AUTO_START_REVERSE ?
|
2018-02-18 18:53:13 +03:00
|
|
|
SVGMarkerElementBinding::SVG_MARKER_ORIENT_UNKNOWN : mAnimVal; }
|
2013-07-12 10:39:38 +04:00
|
|
|
uint16_t GetAnimValueInternal() const
|
2008-01-09 12:52:14 +03:00
|
|
|
{ return mAnimVal; }
|
|
|
|
|
2013-07-01 11:02:46 +04:00
|
|
|
already_AddRefed<SVGAnimatedEnumeration>
|
2013-01-30 02:11:44 +04:00
|
|
|
ToDOMAnimatedEnum(nsSVGElement* aSVGElement);
|
2008-01-09 12:52:14 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
nsSVGEnumValue mAnimVal;
|
|
|
|
nsSVGEnumValue mBaseVal;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
struct DOMAnimatedEnum final : public SVGAnimatedEnumeration
|
2008-01-09 12:52:14 +03:00
|
|
|
{
|
|
|
|
DOMAnimatedEnum(nsSVGOrientType* aVal,
|
|
|
|
nsSVGElement *aSVGElement)
|
2013-07-01 11:02:46 +04:00
|
|
|
: SVGAnimatedEnumeration(aSVGElement)
|
|
|
|
, mVal(aVal)
|
|
|
|
{}
|
2008-01-09 12:52:14 +03:00
|
|
|
|
|
|
|
nsSVGOrientType *mVal; // kept alive because it belongs to content
|
2013-07-01 11:02:46 +04:00
|
|
|
|
|
|
|
using mozilla::dom::SVGAnimatedEnumeration::SetBaseVal;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual uint16_t BaseVal() override
|
2013-07-01 11:02:46 +04:00
|
|
|
{
|
|
|
|
return mVal->GetBaseValue();
|
|
|
|
}
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void SetBaseVal(uint16_t aBaseVal, ErrorResult& aRv) override
|
2013-07-01 11:02:46 +04:00
|
|
|
{
|
|
|
|
aRv = mVal->SetBaseValue(aBaseVal, mSVGElement);
|
|
|
|
}
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual uint16_t AnimVal() override
|
2013-07-01 11:02:46 +04:00
|
|
|
{
|
|
|
|
return mVal->GetAnimValue();
|
|
|
|
}
|
2008-01-09 12:52:14 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2013-01-30 02:11:44 +04:00
|
|
|
typedef nsSVGElement SVGMarkerElementBase;
|
2006-04-14 19:09:39 +04:00
|
|
|
|
2013-03-28 05:23:09 +04:00
|
|
|
class SVGMarkerElement : public SVGMarkerElementBase
|
2006-04-14 19:09:39 +04:00
|
|
|
{
|
2013-01-30 02:11:44 +04:00
|
|
|
friend class ::nsSVGMarkerFrame;
|
2006-04-14 19:09:39 +04:00
|
|
|
|
|
|
|
protected:
|
2013-01-30 02:11:44 +04:00
|
|
|
friend nsresult (::NS_NewSVGMarkerElement(nsIContent **aResult,
|
2014-06-20 06:01:40 +04:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
|
2014-09-01 05:08:04 +04:00
|
|
|
explicit SVGMarkerElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
|
2006-04-14 19:09:39 +04:00
|
|
|
|
|
|
|
public:
|
|
|
|
// nsIContent interface
|
2017-10-03 01:05:19 +03:00
|
|
|
NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* name) const override;
|
2006-04-14 19:09:39 +04:00
|
|
|
|
2018-01-04 05:03:45 +03:00
|
|
|
virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
|
|
|
|
const nsAttrValue* aValue,
|
|
|
|
const nsAttrValue* aOldValue,
|
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
|
|
|
bool aNotify) override;
|
2006-04-14 19:09:39 +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-04-27 01:02:25 +04:00
|
|
|
// public helpers
|
2017-06-08 08:17:07 +03:00
|
|
|
gfx::Matrix GetMarkerTransform(float aStrokeWidth, const nsSVGMark& aMark);
|
2011-09-21 11:53:09 +04:00
|
|
|
nsSVGViewBoxRect GetViewBoxRect();
|
2013-12-30 10:50:17 +04:00
|
|
|
gfx::Matrix GetViewBoxTransform();
|
2006-04-27 01:02:25 +04:00
|
|
|
|
2017-04-20 22:57:48 +03:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
|
|
|
|
bool aPreallocateChildren) const override;
|
2006-09-05 14:22:54 +04:00
|
|
|
|
2010-02-19 00:50:59 +03:00
|
|
|
nsSVGOrientType* GetOrientType() { return &mOrientType; }
|
|
|
|
|
2013-07-12 10:39:38 +04:00
|
|
|
// Returns the value of svg.marker-improvements.enabled.
|
|
|
|
static bool MarkerImprovementsPrefEnabled();
|
|
|
|
|
2013-01-30 02:11:44 +04:00
|
|
|
// WebIDL
|
2013-05-09 21:42:12 +04:00
|
|
|
already_AddRefed<SVGAnimatedRect> ViewBox();
|
2013-01-30 02:11:44 +04:00
|
|
|
already_AddRefed<DOMSVGAnimatedPreserveAspectRatio> PreserveAspectRatio();
|
|
|
|
already_AddRefed<SVGAnimatedLength> RefX();
|
|
|
|
already_AddRefed<SVGAnimatedLength> RefY();
|
2013-07-01 11:02:46 +04:00
|
|
|
already_AddRefed<SVGAnimatedEnumeration> MarkerUnits();
|
2013-01-30 02:11:44 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength> MarkerWidth();
|
|
|
|
already_AddRefed<SVGAnimatedLength> MarkerHeight();
|
2013-07-01 11:02:46 +04:00
|
|
|
already_AddRefed<SVGAnimatedEnumeration> OrientType();
|
2013-01-30 02:11:44 +04:00
|
|
|
already_AddRefed<SVGAnimatedAngle> OrientAngle();
|
2013-02-19 02:48:54 +04:00
|
|
|
void SetOrientToAuto();
|
2013-01-30 02:11:44 +04:00
|
|
|
void SetOrientToAngle(SVGAngle& angle, ErrorResult& rv);
|
|
|
|
|
2006-04-14 19:09:39 +04:00
|
|
|
protected:
|
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
virtual bool ParseAttribute(int32_t aNameSpaceID, nsAtom* aName,
|
2007-11-20 14:36:39 +03:00
|
|
|
const nsAString& aValue,
|
2017-11-02 06:35:52 +03:00
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsAttrValue& aResult) override;
|
2007-11-20 14:36:39 +03:00
|
|
|
|
2017-10-10 09:58:34 +03:00
|
|
|
void SetParentCoordCtxProvider(SVGViewportElement *aContext);
|
2006-04-14 19:09:39 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual LengthAttributesInfo GetLengthInfo() override;
|
|
|
|
virtual AngleAttributesInfo GetAngleInfo() override;
|
|
|
|
virtual EnumAttributesInfo GetEnumInfo() override;
|
|
|
|
virtual nsSVGViewBox *GetViewBox() override;
|
|
|
|
virtual SVGAnimatedPreserveAspectRatio *GetPreserveAspectRatio() override;
|
2007-08-28 03:11:14 +04:00
|
|
|
|
2006-04-14 19:09:39 +04:00
|
|
|
enum { REFX, REFY, MARKERWIDTH, MARKERHEIGHT };
|
|
|
|
nsSVGLength2 mLengthAttributes[4];
|
|
|
|
static LengthInfo sLengthInfo[4];
|
|
|
|
|
2008-01-09 12:52:14 +03:00
|
|
|
enum { MARKERUNITS };
|
2007-08-28 03:11:14 +04:00
|
|
|
nsSVGEnum mEnumAttributes[1];
|
|
|
|
static nsSVGEnumMapping sUnitsMap[];
|
|
|
|
static EnumInfo sEnumInfo[1];
|
|
|
|
|
2007-10-10 14:07:59 +04:00
|
|
|
enum { ORIENT };
|
|
|
|
nsSVGAngle mAngleAttributes[1];
|
|
|
|
static AngleInfo sAngleInfo[1];
|
|
|
|
|
2009-02-03 17:42:24 +03:00
|
|
|
nsSVGViewBox mViewBox;
|
2010-12-20 03:45:29 +03:00
|
|
|
SVGAnimatedPreserveAspectRatio mPreserveAspectRatio;
|
2009-01-05 04:19:38 +03:00
|
|
|
|
2007-09-15 02:12:20 +04:00
|
|
|
// derived properties (from 'orient') handled separately
|
2008-01-09 12:52:14 +03:00
|
|
|
nsSVGOrientType mOrientType;
|
2007-08-28 03:11:14 +04:00
|
|
|
|
2017-10-10 09:58:34 +03:00
|
|
|
SVGViewportElement* mCoordCtx;
|
2013-12-30 10:50:17 +04:00
|
|
|
nsAutoPtr<gfx::Matrix> mViewBoxToViewportTransform;
|
2006-04-14 19:09:39 +04:00
|
|
|
};
|
|
|
|
|
2013-01-30 02:11:44 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_SVGMarkerElement_h
|