1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 #ifndef mozilla_dom_SVGFECompositeElement_h
8 #define mozilla_dom_SVGFECompositeElement_h
9 
10 #include "nsSVGEnum.h"
11 #include "nsSVGFilters.h"
12 #include "nsSVGNumber2.h"
13 
14 nsresult NS_NewSVGFECompositeElement(
15     nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
16 
17 namespace mozilla {
18 namespace dom {
19 
20 typedef nsSVGFE SVGFECompositeElementBase;
21 
22 class SVGFECompositeElement : public SVGFECompositeElementBase {
23   friend nsresult(::NS_NewSVGFECompositeElement(
24       nsIContent** aResult,
25       already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
26 
27  protected:
SVGFECompositeElement(already_AddRefed<mozilla::dom::NodeInfo> & aNodeInfo)28   explicit SVGFECompositeElement(
29       already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
30       : SVGFECompositeElementBase(aNodeInfo) {}
31   virtual JSObject* WrapNode(JSContext* aCx,
32                              JS::Handle<JSObject*> aGivenProto) override;
33 
34  public:
35   virtual FilterPrimitiveDescription GetPrimitiveDescription(
36       nsSVGFilterInstance* aInstance, const IntRect& aFilterSubregion,
37       const nsTArray<bool>& aInputsAreTainted,
38       nsTArray<RefPtr<SourceSurface>>& aInputImages) override;
39   virtual bool AttributeAffectsRendering(int32_t aNameSpaceID,
40                                          nsAtom* aAttribute) const override;
GetResultImageName()41   virtual nsSVGString& GetResultImageName() override {
42     return mStringAttributes[RESULT];
43   }
44   virtual void GetSourceImageNames(
45       nsTArray<nsSVGStringInfo>& aSources) override;
46 
47   virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult,
48                          bool aPreallocateChildren) const override;
49 
50   // WebIDL
51   already_AddRefed<SVGAnimatedString> In1();
52   already_AddRefed<SVGAnimatedString> In2();
53   already_AddRefed<SVGAnimatedEnumeration> Operator();
54   already_AddRefed<SVGAnimatedNumber> K1();
55   already_AddRefed<SVGAnimatedNumber> K2();
56   already_AddRefed<SVGAnimatedNumber> K3();
57   already_AddRefed<SVGAnimatedNumber> K4();
58   void SetK(float k1, float k2, float k3, float k4);
59 
60  protected:
61   virtual NumberAttributesInfo GetNumberInfo() override;
62   virtual EnumAttributesInfo GetEnumInfo() override;
63   virtual StringAttributesInfo GetStringInfo() override;
64 
65   enum { ATTR_K1, ATTR_K2, ATTR_K3, ATTR_K4 };
66   nsSVGNumber2 mNumberAttributes[4];
67   static NumberInfo sNumberInfo[4];
68 
69   enum { OPERATOR };
70   nsSVGEnum mEnumAttributes[1];
71   static nsSVGEnumMapping sOperatorMap[];
72   static EnumInfo sEnumInfo[1];
73 
74   enum { RESULT, IN1, IN2 };
75   nsSVGString mStringAttributes[3];
76   static StringInfo sStringInfo[3];
77 };
78 
79 }  // namespace dom
80 }  // namespace mozilla
81 
82 #endif  // mozilla_dom_SVGFECompositeElement_h
83