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/. */
|
|
|
|
|
2020-07-15 02:40:05 +03:00
|
|
|
#ifndef DOM_SVG_SVGGRADIENTELEMENT_H_
|
|
|
|
#define DOM_SVG_SVGGRADIENTELEMENT_H_
|
2013-01-11 12:43:01 +04:00
|
|
|
|
2019-04-04 20:40:56 +03:00
|
|
|
#include "SVGAnimatedEnumeration.h"
|
2019-04-09 23:04:33 +03:00
|
|
|
#include "SVGAnimatedLength.h"
|
2019-04-04 20:40:56 +03:00
|
|
|
#include "SVGAnimatedString.h"
|
2019-01-02 21:24:11 +03:00
|
|
|
#include "SVGAnimatedTransformList.h"
|
|
|
|
#include "mozilla/dom/SVGElement.h"
|
2020-02-25 23:03:26 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2013-01-11 12:43:01 +04:00
|
|
|
|
|
|
|
nsresult NS_NewSVGLinearGradientElement(
|
2014-06-20 06:01:40 +04:00
|
|
|
nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
|
2013-01-11 12:43:01 +04:00
|
|
|
nsresult NS_NewSVGRadialGradientElement(
|
2014-06-20 06:01:40 +04:00
|
|
|
nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
|
2013-01-11 12:43:01 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2020-07-07 16:49:30 +03:00
|
|
|
class SVGGradientFrame;
|
|
|
|
class SVGLinearGradientFrame;
|
|
|
|
class SVGRadialGradientFrame;
|
|
|
|
|
2013-03-20 07:20:38 +04:00
|
|
|
namespace dom {
|
2013-03-20 06:31:44 +04:00
|
|
|
|
2018-12-23 14:08:14 +03:00
|
|
|
class DOMSVGAnimatedTransformList;
|
2013-04-15 02:56:34 +04:00
|
|
|
|
2013-01-11 12:43:01 +04:00
|
|
|
//--------------------- Gradients------------------------
|
|
|
|
|
2020-07-15 13:37:55 +03:00
|
|
|
using SVGGradientElementBase = SVGElement;
|
2013-01-11 12:43:01 +04:00
|
|
|
|
|
|
|
class SVGGradientElement : public SVGGradientElementBase {
|
2020-07-07 16:49:30 +03:00
|
|
|
friend class mozilla::SVGGradientFrame;
|
2013-01-11 12:43:01 +04:00
|
|
|
|
|
|
|
protected:
|
2018-09-21 23:45:49 +03: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:
|
2018-08-09 02:58:44 +03:00
|
|
|
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override = 0;
|
2013-03-31 06:27:27 +04:00
|
|
|
|
2013-01-11 12:43:01 +04:00
|
|
|
// nsIContent
|
2017-10-03 01:05:19 +03:00
|
|
|
NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
|
2013-01-11 12:43:01 +04:00
|
|
|
|
2018-12-27 02:46:38 +03:00
|
|
|
virtual SVGAnimatedTransformList* GetAnimatedTransformList(
|
2015-03-21 19:28:04 +03:00
|
|
|
uint32_t aFlags = 0) override;
|
2018-03-29 12:45:24 +03:00
|
|
|
virtual nsStaticAtom* GetTransformListAttrName() const override {
|
2013-01-11 12:43:01 +04:00
|
|
|
return nsGkAtoms::gradientTransform;
|
|
|
|
}
|
|
|
|
|
|
|
|
// WebIDL
|
2019-03-19 03:01:03 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedEnumeration> GradientUnits();
|
2018-12-23 14:08:14 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedTransformList> GradientTransform();
|
2019-03-19 03:01:03 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedEnumeration> SpreadMethod();
|
|
|
|
already_AddRefed<DOMSVGAnimatedString> 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 };
|
2019-04-04 20:40:56 +03:00
|
|
|
SVGAnimatedEnumeration mEnumAttributes[2];
|
2019-01-02 21:24:11 +03:00
|
|
|
static SVGEnumMapping sSpreadMethodMap[];
|
2013-01-11 12:43:01 +04:00
|
|
|
static EnumInfo sEnumInfo[2];
|
|
|
|
|
2016-07-07 09:26:57 +03:00
|
|
|
enum { HREF, XLINK_HREF };
|
2019-04-04 20:40:56 +03:00
|
|
|
SVGAnimatedString mStringAttributes[2];
|
2016-07-07 09:26:57 +03:00
|
|
|
static StringInfo sStringInfo[2];
|
2013-01-11 12:43:01 +04:00
|
|
|
|
2013-02-03 00:23:16 +04:00
|
|
|
// SVGGradientElement values
|
2020-02-25 23:03:26 +03:00
|
|
|
UniquePtr<SVGAnimatedTransformList> mGradientTransform;
|
2013-01-11 12:43:01 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------Linear Gradients------------------------
|
|
|
|
|
2020-07-15 13:37:55 +03:00
|
|
|
using SVGLinearGradientElementBase = SVGGradientElement;
|
2013-01-11 12:43:01 +04:00
|
|
|
|
|
|
|
class SVGLinearGradientElement : public SVGLinearGradientElementBase {
|
2020-07-07 16:49:30 +03:00
|
|
|
friend class mozilla::SVGLinearGradientFrame;
|
2013-01-11 12:43:01 +04:00
|
|
|
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:
|
2018-09-21 23:45:49 +03: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:
|
2018-08-09 02:58:44 +03:00
|
|
|
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
|
2013-01-11 12:43:01 +04:00
|
|
|
|
|
|
|
// WebIDL
|
2019-03-19 03:01:03 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedLength> X1();
|
|
|
|
already_AddRefed<DOMSVGAnimatedLength> Y1();
|
|
|
|
already_AddRefed<DOMSVGAnimatedLength> X2();
|
|
|
|
already_AddRefed<DOMSVGAnimatedLength> 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 };
|
2019-04-09 23:04:33 +03:00
|
|
|
SVGAnimatedLength mLengthAttributes[4];
|
2013-01-11 12:43:01 +04:00
|
|
|
static LengthInfo sLengthInfo[4];
|
|
|
|
};
|
|
|
|
|
|
|
|
//-------------------------- Radial Gradients ----------------------------
|
|
|
|
|
2020-07-15 13:37:55 +03:00
|
|
|
using SVGRadialGradientElementBase = SVGGradientElement;
|
2013-01-11 12:43:01 +04:00
|
|
|
|
|
|
|
class SVGRadialGradientElement : public SVGRadialGradientElementBase {
|
2020-07-07 16:49:30 +03:00
|
|
|
friend class mozilla::SVGRadialGradientFrame;
|
2013-01-11 12:43:01 +04:00
|
|
|
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:
|
2018-09-21 23:45:49 +03: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:
|
2018-08-09 02:58:44 +03:00
|
|
|
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
|
2013-01-11 12:43:01 +04:00
|
|
|
|
|
|
|
// WebIDL
|
2019-03-19 03:01:03 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedLength> Cx();
|
|
|
|
already_AddRefed<DOMSVGAnimatedLength> Cy();
|
|
|
|
already_AddRefed<DOMSVGAnimatedLength> R();
|
|
|
|
already_AddRefed<DOMSVGAnimatedLength> Fx();
|
|
|
|
already_AddRefed<DOMSVGAnimatedLength> Fy();
|
|
|
|
already_AddRefed<DOMSVGAnimatedLength> 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 };
|
2019-04-09 23:04:33 +03:00
|
|
|
SVGAnimatedLength mLengthAttributes[6];
|
2017-05-23 09:15:02 +03:00
|
|
|
static LengthInfo sLengthInfo[6];
|
2013-01-11 12:43:01 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2020-07-15 02:40:05 +03:00
|
|
|
#endif // DOM_SVG_SVGGRADIENTELEMENT_H_
|