summaryrefslogtreecommitdiffstats
path: root/dom/svg/SVGComponentTransferFunctionElement.h
blob: 01e838d392cd2199efd40d75022793b3a027e126 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/* -*- 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_SVGCOMPONENTTRANSFERFUNCTIONELEMENT_H_
#define DOM_SVG_SVGCOMPONENTTRANSFERFUNCTIONELEMENT_H_

#include "SVGAnimatedEnumeration.h"
#include "SVGAnimatedNumber.h"
#include "SVGAnimatedNumberList.h"
#include "mozilla/dom/SVGFilters.h"

#define NS_SVG_FE_COMPONENT_TRANSFER_FUNCTION_ELEMENT_CID \
  {                                                       \
    0xafab106d, 0xbc18, 0x4f7f, {                         \
      0x9e, 0x29, 0xfe, 0xb4, 0xb0, 0x16, 0x5f, 0xf4      \
    }                                                     \
  }

namespace mozilla::dom {

class DOMSVGAnimatedNumberList;

using SVGComponentTransferFunctionElementBase = SVGFEUnstyledElement;

class SVGComponentTransferFunctionElement
    : public SVGComponentTransferFunctionElementBase {
 protected:
  explicit SVGComponentTransferFunctionElement(
      already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
      : SVGComponentTransferFunctionElementBase(std::move(aNodeInfo)) {}

  virtual ~SVGComponentTransferFunctionElement() = default;

 public:
  using ComponentTransferAttributes = gfx::ComponentTransferAttributes;

  // interfaces:
  NS_DECLARE_STATIC_IID_ACCESSOR(
      NS_SVG_FE_COMPONENT_TRANSFER_FUNCTION_ELEMENT_CID)

  NS_DECL_ISUPPORTS_INHERITED

  bool AttributeAffectsRendering(int32_t aNameSpaceID,
                                 nsAtom* aAttribute) const override;

  virtual int32_t GetChannel() = 0;

  void ComputeAttributes(int32_t aChannel,
                         ComponentTransferAttributes& aAttributes);

  // WebIDL
  JSObject* WrapNode(JSContext* aCx,
                     JS::Handle<JSObject*> aGivenProto) override = 0;
  already_AddRefed<DOMSVGAnimatedEnumeration> Type();
  already_AddRefed<DOMSVGAnimatedNumberList> TableValues();
  already_AddRefed<DOMSVGAnimatedNumber> Slope();
  already_AddRefed<DOMSVGAnimatedNumber> Intercept();
  already_AddRefed<DOMSVGAnimatedNumber> Amplitude();
  already_AddRefed<DOMSVGAnimatedNumber> Exponent();
  already_AddRefed<DOMSVGAnimatedNumber> Offset();

 protected:
  NumberAttributesInfo GetNumberInfo() override;
  EnumAttributesInfo GetEnumInfo() override;
  NumberListAttributesInfo GetNumberListInfo() override;

  enum { TABLEVALUES };
  SVGAnimatedNumberList mNumberListAttributes[1];
  static NumberListInfo sNumberListInfo[1];

  enum { SLOPE, INTERCEPT, AMPLITUDE, EXPONENT, OFFSET };
  SVGAnimatedNumber mNumberAttributes[5];
  static NumberInfo sNumberInfo[5];

  enum { TYPE };
  SVGAnimatedEnumeration mEnumAttributes[1];
  static SVGEnumMapping sTypeMap[];
  static EnumInfo sEnumInfo[1];
};

NS_DEFINE_STATIC_IID_ACCESSOR(SVGComponentTransferFunctionElement,
                              NS_SVG_FE_COMPONENT_TRANSFER_FUNCTION_ELEMENT_CID)

}  // namespace mozilla::dom

nsresult NS_NewSVGFEFuncRElement(
    nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);

namespace mozilla::dom {

class SVGFEFuncRElement : public SVGComponentTransferFunctionElement {
  friend nsresult(::NS_NewSVGFEFuncRElement(
      nsIContent** aResult,
      already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));

 protected:
  explicit SVGFEFuncRElement(
      already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
      : SVGComponentTransferFunctionElement(std::move(aNodeInfo)) {}

 public:
  int32_t GetChannel() override { return 0; }

  nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;

  JSObject* WrapNode(JSContext* aCx,
                     JS::Handle<JSObject*> aGivenProto) override;
};

}  // namespace mozilla::dom

nsresult NS_NewSVGFEFuncGElement(
    nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);

namespace mozilla::dom {

class SVGFEFuncGElement : public SVGComponentTransferFunctionElement {
  friend nsresult(::NS_NewSVGFEFuncGElement(
      nsIContent** aResult,
      already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));

 protected:
  explicit SVGFEFuncGElement(
      already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
      : SVGComponentTransferFunctionElement(std::move(aNodeInfo)) {}

 public:
  int32_t GetChannel() override { return 1; }

  nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;

  JSObject* WrapNode(JSContext* aCx,
                     JS::Handle<JSObject*> aGivenProto) override;
};

}  // namespace mozilla::dom

nsresult NS_NewSVGFEFuncBElement(
    nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);

namespace mozilla::dom {

class SVGFEFuncBElement : public SVGComponentTransferFunctionElement {
  friend nsresult(::NS_NewSVGFEFuncBElement(
      nsIContent** aResult,
      already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));

 protected:
  explicit SVGFEFuncBElement(
      already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
      : SVGComponentTransferFunctionElement(std::move(aNodeInfo)) {}

 public:
  int32_t GetChannel() override { return 2; }

  nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;

  JSObject* WrapNode(JSContext* aCx,
                     JS::Handle<JSObject*> aGivenProto) override;
};

}  // namespace mozilla::dom

nsresult NS_NewSVGFEFuncAElement(
    nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);

namespace mozilla::dom {

class SVGFEFuncAElement : public SVGComponentTransferFunctionElement {
  friend nsresult(::NS_NewSVGFEFuncAElement(
      nsIContent** aResult,
      already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));

 protected:
  explicit SVGFEFuncAElement(
      already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
      : SVGComponentTransferFunctionElement(std::move(aNodeInfo)) {}

 public:
  int32_t GetChannel() override { return 3; }

  nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;

  JSObject* WrapNode(JSContext* aCx,
                     JS::Handle<JSObject*> aGivenProto) override;
};

}  // namespace mozilla::dom

#endif  // DOM_SVG_SVGCOMPONENTTRANSFERFUNCTIONELEMENT_H_