- add third_party src.
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / 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 #ifndef SVGComponentTransferFunctionElement_h
22 #define SVGComponentTransferFunctionElement_h
23
24 #include "core/platform/graphics/filters/FEComponentTransfer.h"
25 #include "core/svg/SVGAnimatedEnumeration.h"
26 #include "core/svg/SVGAnimatedNumber.h"
27 #include "core/svg/SVGAnimatedNumberList.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 "identity";
42         case FECOMPONENTTRANSFER_TYPE_TABLE:
43             return "table";
44         case FECOMPONENTTRANSFER_TYPE_DISCRETE:
45             return "discrete";
46         case FECOMPONENTTRANSFER_TYPE_LINEAR:
47             return "linear";
48         case FECOMPONENTTRANSFER_TYPE_GAMMA:
49             return "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     bool isSupportedAttribute(const QualifiedName&);
80     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
81     virtual void svgAttributeChanged(const QualifiedName&);
82
83     virtual bool rendererIsNeeded(const RenderStyle&) OVERRIDE { return false; }
84
85 private:
86     BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGComponentTransferFunctionElement)
87         DECLARE_ANIMATED_ENUMERATION(Type, type, ComponentTransferType)
88         DECLARE_ANIMATED_NUMBER_LIST(TableValues, tableValues)
89         DECLARE_ANIMATED_NUMBER(Slope, slope)
90         DECLARE_ANIMATED_NUMBER(Intercept, intercept)
91         DECLARE_ANIMATED_NUMBER(Amplitude, amplitude)
92         DECLARE_ANIMATED_NUMBER(Exponent, exponent)
93         DECLARE_ANIMATED_NUMBER(Offset, offset)
94     END_DECLARE_ANIMATED_PROPERTIES
95 };
96
97 } // namespace WebCore
98
99 #endif