OSDN Git Service

Merge Webkit at r70949: Initial merge by git.
[android-x86/external-webkit.git] / WebCore / svg / SVGColor.h
1 /*
2  * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
3  * Copyright (C) 2004, 2005, 2006, 2007 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 SVGColor_h
22 #define SVGColor_h
23 #if ENABLE(SVG)
24
25 #include "CSSValue.h"
26 #include "Color.h"
27 #include <wtf/PassRefPtr.h>
28
29 namespace WebCore {
30
31     class RGBColor;
32
33     class SVGColor : public CSSValue {
34     public:
35         static PassRefPtr<SVGColor> create(const String& color)
36         {
37             return adoptRef(new SVGColor(color));
38         }
39         static PassRefPtr<SVGColor> create(const Color& color)
40         {
41             return adoptRef(new SVGColor(color));
42         }
43         static PassRefPtr<SVGColor> createCurrentColor()
44         {
45             return adoptRef(new SVGColor(SVG_COLORTYPE_CURRENTCOLOR));
46         }
47
48         enum SVGColorType {
49             SVG_COLORTYPE_UNKNOWN                   = 0,
50             SVG_COLORTYPE_RGBCOLOR                  = 1,
51             SVG_COLORTYPE_RGBCOLOR_ICCCOLOR         = 2,
52             SVG_COLORTYPE_CURRENTCOLOR              = 3
53         };
54
55         // 'SVGColor' functions
56         unsigned short colorType() const { return m_colorType; }
57
58         PassRefPtr<RGBColor> rgbColor() const;
59
60         static Color colorFromRGBColorString(const String&);
61
62         void setRGBColor(const String& rgbColor) { ExceptionCode ignored = 0; setRGBColor(rgbColor, ignored); }
63         void setRGBColor(const String& rgbColor, ExceptionCode&);
64         void setRGBColorICCColor(const String& rgbColor, const String& iccColor, ExceptionCode&);
65         void setColor(unsigned short colorType, const String& rgbColor, const String& iccColor, ExceptionCode&);
66
67         const Color& color() const { return m_color; }
68
69     protected:
70         SVGColor();
71         SVGColor(const String& color);
72         SVGColor(const Color&);
73
74         virtual String cssText() const;
75
76     private:
77         SVGColor(SVGColorType);
78
79         static void create(int); // compile-time guard 
80
81         virtual bool isSVGColor() const { return true; }
82
83         Color m_color;
84         unsigned short m_colorType;
85     };
86
87 } // namespace WebCore
88
89 #endif // ENABLE(SVG)
90 #endif // SVGColor_h
91
92 // vim:ts=4:noet