summaryrefslogtreecommitdiffstats
path: root/dom/svg/SVGGradientElement.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /dom/svg/SVGGradientElement.h
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/svg/SVGGradientElement.h')
-rw-r--r--dom/svg/SVGGradientElement.h148
1 files changed, 148 insertions, 0 deletions
diff --git a/dom/svg/SVGGradientElement.h b/dom/svg/SVGGradientElement.h
new file mode 100644
index 0000000000..69d7f6ed95
--- /dev/null
+++ b/dom/svg/SVGGradientElement.h
@@ -0,0 +1,148 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* 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 DOM_SVG_SVGGRADIENTELEMENT_H_
+#define DOM_SVG_SVGGRADIENTELEMENT_H_
+
+#include "SVGAnimatedEnumeration.h"
+#include "SVGAnimatedLength.h"
+#include "SVGAnimatedString.h"
+#include "SVGAnimatedTransformList.h"
+#include "mozilla/dom/SVGElement.h"
+#include "mozilla/UniquePtr.h"
+
+nsresult NS_NewSVGLinearGradientElement(
+ nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
+nsresult NS_NewSVGRadialGradientElement(
+ nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
+
+namespace mozilla {
+class SVGGradientFrame;
+class SVGLinearGradientFrame;
+class SVGRadialGradientFrame;
+
+namespace dom {
+
+class DOMSVGAnimatedTransformList;
+
+//--------------------- Gradients------------------------
+
+using SVGGradientElementBase = SVGElement;
+
+class SVGGradientElement : public SVGGradientElementBase {
+ friend class mozilla::SVGGradientFrame;
+
+ protected:
+ explicit SVGGradientElement(
+ already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
+ JSObject* WrapNode(JSContext* aCx,
+ JS::Handle<JSObject*> aGivenProto) override = 0;
+
+ public:
+ // nsIContent
+ nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override = 0;
+
+ virtual SVGAnimatedTransformList* GetAnimatedTransformList(
+ uint32_t aFlags = 0) override;
+ nsStaticAtom* GetTransformListAttrName() const override {
+ return nsGkAtoms::gradientTransform;
+ }
+
+ // WebIDL
+ already_AddRefed<DOMSVGAnimatedEnumeration> GradientUnits();
+ already_AddRefed<DOMSVGAnimatedTransformList> GradientTransform();
+ already_AddRefed<DOMSVGAnimatedEnumeration> SpreadMethod();
+ already_AddRefed<DOMSVGAnimatedString> Href();
+
+ protected:
+ EnumAttributesInfo GetEnumInfo() override;
+ StringAttributesInfo GetStringInfo() override;
+
+ enum { GRADIENTUNITS, SPREADMETHOD };
+ SVGAnimatedEnumeration mEnumAttributes[2];
+ static SVGEnumMapping sSpreadMethodMap[];
+ static EnumInfo sEnumInfo[2];
+
+ enum { HREF, XLINK_HREF };
+ SVGAnimatedString mStringAttributes[2];
+ static StringInfo sStringInfo[2];
+
+ // SVGGradientElement values
+ UniquePtr<SVGAnimatedTransformList> mGradientTransform;
+};
+
+//---------------------Linear Gradients------------------------
+
+using SVGLinearGradientElementBase = SVGGradientElement;
+
+class SVGLinearGradientElement final : public SVGLinearGradientElementBase {
+ friend class mozilla::SVGLinearGradientFrame;
+ friend nsresult(::NS_NewSVGLinearGradientElement(
+ nsIContent** aResult,
+ already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
+
+ protected:
+ explicit SVGLinearGradientElement(
+ already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
+ virtual JSObject* WrapNode(JSContext* aCx,
+ JS::Handle<JSObject*> aGivenProto) override;
+
+ public:
+ nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
+
+ // WebIDL
+ already_AddRefed<DOMSVGAnimatedLength> X1();
+ already_AddRefed<DOMSVGAnimatedLength> Y1();
+ already_AddRefed<DOMSVGAnimatedLength> X2();
+ already_AddRefed<DOMSVGAnimatedLength> Y2();
+
+ protected:
+ LengthAttributesInfo GetLengthInfo() override;
+
+ enum { ATTR_X1, ATTR_Y1, ATTR_X2, ATTR_Y2 };
+ SVGAnimatedLength mLengthAttributes[4];
+ static LengthInfo sLengthInfo[4];
+};
+
+//-------------------------- Radial Gradients ----------------------------
+
+using SVGRadialGradientElementBase = SVGGradientElement;
+
+class SVGRadialGradientElement final : public SVGRadialGradientElementBase {
+ friend class mozilla::SVGRadialGradientFrame;
+ friend nsresult(::NS_NewSVGRadialGradientElement(
+ nsIContent** aResult,
+ already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
+
+ protected:
+ explicit SVGRadialGradientElement(
+ already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
+ virtual JSObject* WrapNode(JSContext* aCx,
+ JS::Handle<JSObject*> aGivenProto) override;
+
+ public:
+ nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
+
+ // WebIDL
+ already_AddRefed<DOMSVGAnimatedLength> Cx();
+ already_AddRefed<DOMSVGAnimatedLength> Cy();
+ already_AddRefed<DOMSVGAnimatedLength> R();
+ already_AddRefed<DOMSVGAnimatedLength> Fx();
+ already_AddRefed<DOMSVGAnimatedLength> Fy();
+ already_AddRefed<DOMSVGAnimatedLength> Fr();
+
+ protected:
+ LengthAttributesInfo GetLengthInfo() override;
+
+ enum { ATTR_CX, ATTR_CY, ATTR_R, ATTR_FX, ATTR_FY, ATTR_FR };
+ SVGAnimatedLength mLengthAttributes[6];
+ static LengthInfo sLengthInfo[6];
+};
+
+} // namespace dom
+} // namespace mozilla
+
+#endif // DOM_SVG_SVGGRADIENTELEMENT_H_