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: */
|
2013-01-11 12:43:01 +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/. */
|
|
|
|
|
|
|
|
#ifndef __NS_SVGGRADIENTELEMENT_H__
|
|
|
|
#define __NS_SVGGRADIENTELEMENT_H__
|
|
|
|
|
2016-06-07 23:10:18 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2013-04-15 02:56:34 +04:00
|
|
|
#include "nsSVGAnimatedTransformList.h"
|
2013-01-11 12:43:01 +04:00
|
|
|
#include "nsSVGElement.h"
|
|
|
|
#include "nsSVGLength2.h"
|
|
|
|
#include "nsSVGEnum.h"
|
|
|
|
#include "nsSVGString.h"
|
|
|
|
|
2013-02-03 00:23:16 +04:00
|
|
|
static const unsigned short SVG_SPREADMETHOD_UNKNOWN = 0;
|
|
|
|
static const unsigned short SVG_SPREADMETHOD_PAD = 1;
|
|
|
|
static const unsigned short SVG_SPREADMETHOD_REFLECT = 2;
|
|
|
|
static const unsigned short SVG_SPREADMETHOD_REPEAT = 3;
|
|
|
|
|
2013-01-11 12:43:01 +04:00
|
|
|
class nsSVGGradientFrame;
|
|
|
|
class nsSVGLinearGradientFrame;
|
|
|
|
class nsSVGRadialGradientFrame;
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
NS_NewSVGLinearGradientElement(nsIContent** aResult,
|
2014-06-20 06:01:40 +04:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
|
2013-01-11 12:43:01 +04:00
|
|
|
nsresult
|
|
|
|
NS_NewSVGRadialGradientElement(nsIContent** aResult,
|
2014-06-20 06:01:40 +04:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
|
2013-01-11 12:43:01 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2013-03-20 07:20:38 +04:00
|
|
|
namespace dom {
|
2013-03-20 06:31:44 +04:00
|
|
|
|
2013-04-15 02:56:34 +04:00
|
|
|
class SVGAnimatedTransformList;
|
|
|
|
|
2013-01-11 12:43:01 +04:00
|
|
|
//--------------------- Gradients------------------------
|
|
|
|
|
|
|
|
typedef nsSVGElement SVGGradientElementBase;
|
|
|
|
|
|
|
|
class SVGGradientElement : public SVGGradientElementBase
|
|
|
|
{
|
|
|
|
friend class ::nsSVGGradientFrame;
|
|
|
|
|
|
|
|
protected:
|
2014-09-01 05:08:04 +04:00
|
|
|
explicit SVGGradientElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override = 0;
|
2013-01-11 12:43:01 +04:00
|
|
|
|
|
|
|
public:
|
2017-04-20 22:57:48 +03:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
|
|
|
|
bool aPreallocateChildren) const override = 0;
|
2013-03-31 06:27:27 +04:00
|
|
|
|
2013-01-11 12:43:01 +04:00
|
|
|
// nsIContent
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const override;
|
2013-01-11 12:43:01 +04:00
|
|
|
|
2013-04-15 02:56:34 +04:00
|
|
|
virtual nsSVGAnimatedTransformList*
|
2015-03-21 19:28:04 +03:00
|
|
|
GetAnimatedTransformList(uint32_t aFlags = 0) override;
|
|
|
|
virtual nsIAtom* GetTransformListAttrName() const override {
|
2013-01-11 12:43:01 +04:00
|
|
|
return nsGkAtoms::gradientTransform;
|
|
|
|
}
|
|
|
|
|
|
|
|
// WebIDL
|
2013-07-01 11:02:46 +04:00
|
|
|
already_AddRefed<SVGAnimatedEnumeration> GradientUnits();
|
2013-04-15 02:56:34 +04:00
|
|
|
already_AddRefed<SVGAnimatedTransformList> GradientTransform();
|
2013-07-01 11:02:46 +04:00
|
|
|
already_AddRefed<SVGAnimatedEnumeration> SpreadMethod();
|
2013-06-15 02:37:27 +04:00
|
|
|
already_AddRefed<SVGAnimatedString> Href();
|
2013-01-11 12:43:01 +04:00
|
|
|
|
|
|
|
protected:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual EnumAttributesInfo GetEnumInfo() override;
|
|
|
|
virtual StringAttributesInfo GetStringInfo() override;
|
2013-01-11 12:43:01 +04:00
|
|
|
|
|
|
|
enum { GRADIENTUNITS, SPREADMETHOD };
|
|
|
|
nsSVGEnum mEnumAttributes[2];
|
|
|
|
static nsSVGEnumMapping sSpreadMethodMap[];
|
|
|
|
static EnumInfo sEnumInfo[2];
|
|
|
|
|
2016-07-07 09:26:57 +03:00
|
|
|
enum { HREF, XLINK_HREF };
|
|
|
|
nsSVGString mStringAttributes[2];
|
|
|
|
static StringInfo sStringInfo[2];
|
2013-01-11 12:43:01 +04:00
|
|
|
|
2013-02-03 00:23:16 +04:00
|
|
|
// SVGGradientElement values
|
2013-04-15 02:56:34 +04:00
|
|
|
nsAutoPtr<nsSVGAnimatedTransformList> mGradientTransform;
|
2013-01-11 12:43:01 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------Linear Gradients------------------------
|
|
|
|
|
|
|
|
typedef SVGGradientElement SVGLinearGradientElementBase;
|
|
|
|
|
|
|
|
class SVGLinearGradientElement : public SVGLinearGradientElementBase
|
|
|
|
{
|
|
|
|
friend class ::nsSVGLinearGradientFrame;
|
|
|
|
friend nsresult
|
|
|
|
(::NS_NewSVGLinearGradientElement(nsIContent** aResult,
|
2014-06-20 06:01:40 +04:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
|
2013-01-11 12:43:01 +04:00
|
|
|
|
|
|
|
protected:
|
2014-09-01 05:08:04 +04:00
|
|
|
explicit SVGLinearGradientElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-01-11 12:43:01 +04:00
|
|
|
|
|
|
|
public:
|
2017-04-20 22:57:48 +03:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
|
|
|
|
bool aPreallocateChildren) const override;
|
2013-01-11 12:43:01 +04:00
|
|
|
|
|
|
|
// WebIDL
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength> X1();
|
|
|
|
already_AddRefed<SVGAnimatedLength> Y1();
|
|
|
|
already_AddRefed<SVGAnimatedLength> X2();
|
|
|
|
already_AddRefed<SVGAnimatedLength> Y2();
|
2013-01-11 12:43:01 +04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual LengthAttributesInfo GetLengthInfo() override;
|
2013-01-11 12:43:01 +04:00
|
|
|
|
|
|
|
enum { ATTR_X1, ATTR_Y1, ATTR_X2, ATTR_Y2 };
|
|
|
|
nsSVGLength2 mLengthAttributes[4];
|
|
|
|
static LengthInfo sLengthInfo[4];
|
|
|
|
};
|
|
|
|
|
|
|
|
//-------------------------- Radial Gradients ----------------------------
|
|
|
|
|
|
|
|
typedef SVGGradientElement SVGRadialGradientElementBase;
|
|
|
|
|
|
|
|
class SVGRadialGradientElement : public SVGRadialGradientElementBase
|
|
|
|
{
|
|
|
|
friend class ::nsSVGRadialGradientFrame;
|
|
|
|
friend nsresult
|
|
|
|
(::NS_NewSVGRadialGradientElement(nsIContent** aResult,
|
2014-06-20 06:01:40 +04:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
|
2013-01-11 12:43:01 +04:00
|
|
|
|
|
|
|
protected:
|
2014-09-01 05:08:04 +04:00
|
|
|
explicit SVGRadialGradientElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-01-11 12:43:01 +04:00
|
|
|
|
|
|
|
public:
|
2017-04-20 22:57:48 +03:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
|
|
|
|
bool aPreallocateChildren) const override;
|
2013-01-11 12:43:01 +04:00
|
|
|
|
|
|
|
// WebIDL
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength> Cx();
|
|
|
|
already_AddRefed<SVGAnimatedLength> Cy();
|
|
|
|
already_AddRefed<SVGAnimatedLength> R();
|
|
|
|
already_AddRefed<SVGAnimatedLength> Fx();
|
|
|
|
already_AddRefed<SVGAnimatedLength> Fy();
|
2017-05-23 09:15:02 +03:00
|
|
|
already_AddRefed<SVGAnimatedLength> Fr();
|
2013-01-11 12:43:01 +04:00
|
|
|
protected:
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual LengthAttributesInfo GetLengthInfo() override;
|
2013-01-11 12:43:01 +04:00
|
|
|
|
2017-05-23 09:15:02 +03:00
|
|
|
enum { ATTR_CX, ATTR_CY, ATTR_R, ATTR_FX, ATTR_FY, ATTR_FR };
|
|
|
|
nsSVGLength2 mLengthAttributes[6];
|
|
|
|
static LengthInfo sLengthInfo[6];
|
2013-01-11 12:43:01 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|