Use #pragma once in WebCore
[WebKit-https.git] / Source / WebCore / svg / SVGComponentTransferFunctionElement.h
1 /*
2  * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3  * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB.  If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20
21 #pragma once
22
23 #include "FEComponentTransfer.h"
24 #include "SVGAnimatedEnumeration.h"
25 #include "SVGAnimatedNumber.h"
26 #include "SVGAnimatedNumberList.h"
27 #include "SVGElement.h"
28
29 namespace WebCore {
30
31 template<>
32 struct SVGPropertyTraits<ComponentTransferType> {
33     static unsigned highestEnumValue() { return FECOMPONENTTRANSFER_TYPE_GAMMA; }
34
35     static String toString(ComponentTransferType type)
36     {
37         switch (type) {
38         case FECOMPONENTTRANSFER_TYPE_UNKNOWN:
39             return emptyString();
40         case FECOMPONENTTRANSFER_TYPE_IDENTITY:
41             return ASCIILiteral("identity");
42         case FECOMPONENTTRANSFER_TYPE_TABLE:
43             return ASCIILiteral("table");
44         case FECOMPONENTTRANSFER_TYPE_DISCRETE:
45             return ASCIILiteral("discrete");
46         case FECOMPONENTTRANSFER_TYPE_LINEAR:
47             return ASCIILiteral("linear");
48         case FECOMPONENTTRANSFER_TYPE_GAMMA:
49             return ASCIILiteral("gamma");
50         }
51
52         ASSERT_NOT_REACHED();
53         return emptyString();
54     }
55
56     static ComponentTransferType fromString(const String& value)
57     {
58         if (value == "identity")
59             return FECOMPONENTTRANSFER_TYPE_IDENTITY;
60         if (value == "table")
61             return FECOMPONENTTRANSFER_TYPE_TABLE;
62         if (value == "discrete")
63             return FECOMPONENTTRANSFER_TYPE_DISCRETE;
64         if (value == "linear")
65             return FECOMPONENTTRANSFER_TYPE_LINEAR;
66         if (value == "gamma")
67             return FECOMPONENTTRANSFER_TYPE_GAMMA;
68         return FECOMPONENTTRANSFER_TYPE_UNKNOWN;
69     }
70 };
71
72 class SVGComponentTransferFunctionElement : public SVGElement {
73 public:
74     ComponentTransferFunction transferFunction() const;
75
76 protected:
77     SVGComponentTransferFunctionElement(const QualifiedName&, Document&);
78
79     void parseAttribute(const QualifiedName&, const AtomicString&) override;
80     void svgAttributeChanged(const QualifiedName&) override;
81
82     bool rendererIsNeeded(const RenderStyle&) override { return false; }
83     
84 private:
85     static bool isSupportedAttribute(const QualifiedName&);
86
87     BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGComponentTransferFunctionElement)
88         DECLARE_ANIMATED_ENUMERATION(Type, type, ComponentTransferType)
89         DECLARE_ANIMATED_NUMBER_LIST(TableValues, tableValues)
90         DECLARE_ANIMATED_NUMBER(Slope, slope)
91         DECLARE_ANIMATED_NUMBER(Intercept, intercept)
92         DECLARE_ANIMATED_NUMBER(Amplitude, amplitude)
93         DECLARE_ANIMATED_NUMBER(Exponent, exponent)
94         DECLARE_ANIMATED_NUMBER(Offset, offset)
95     END_DECLARE_ANIMATED_PROPERTIES
96 };
97
98 } // namespace WebCore