fix tricky regression noticed by Vyacheslav Tokarev on Google Reader.
[kdelibs.git] / khtml / svg / SVGColor.cpp
blob6914f7cd3410d7927d2660ab965e3cd380cdbe99
1 /*
2 Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
3 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
5 This file is part of the KDE project
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
23 #include "config.h"
24 #include "wtf/Platform.h"
25 #if ENABLE(SVG)
26 #include "SVGColor.h"
28 //#include "CSSParser.h"
29 #include "SVGException.h"
31 namespace WebCore {
33 SVGColor::SVGColor()
34 : CSSValue()
35 , m_colorType(SVG_COLORTYPE_UNKNOWN)
39 SVGColor::SVGColor(const String& rgbColor)
40 : CSSValue()
41 , m_colorType(SVG_COLORTYPE_RGBCOLOR)
43 setRGBColor(rgbColor);
46 SVGColor::SVGColor(unsigned short colorType)
47 : CSSValue()
48 , m_colorType(colorType)
52 SVGColor::SVGColor(const Color& c)
53 : CSSValue()
54 , m_color(c)
55 , m_colorType(SVG_COLORTYPE_RGBCOLOR)
60 SVGColor::~SVGColor()
64 unsigned short SVGColor::colorType() const
66 return m_colorType;
69 unsigned SVGColor::rgbColor() const
71 return m_color.rgb();
74 void SVGColor::setRGBColor(const String& rgbColor, ExceptionCode& ec)
76 Color color = SVGColor::colorFromRGBColorString(rgbColor);
77 if (color.isValid())
78 m_color = color;
79 else
80 ec = SVGException::SVG_INVALID_VALUE_ERR;
83 Color SVGColor::colorFromRGBColorString(const String& colorString)
85 /*String s = colorString.stripWhiteSpace();
86 // hsl, hsla and rgba are not in the SVG spec.
87 // FIXME: rework css parser so it is more svg aware
88 if (s.startsWith("hsl") || s.startsWith("rgba"))
89 return Color();
90 RGBA32 color;
91 if (CSSParser::parseColor(color, s))
92 return color;
93 return Color();*/
94 return QColor(colorString.string());
97 void SVGColor::setRGBColorICCColor(const String& /* rgbColor */, const String& /* iccColor */, ExceptionCode& ec)
99 // TODO: implement me!
102 void SVGColor::setColor(unsigned short colorType, const String& /* rgbColor */ , const String& /* iccColor */, ExceptionCode& ec)
104 // TODO: implement me!
105 m_colorType = colorType;
108 String SVGColor::cssText() const
110 if (m_colorType == SVG_COLORTYPE_RGBCOLOR)
111 return m_color.name();
113 return String();
116 const Color& SVGColor::color() const
118 return m_color;
123 // vim:ts=4
124 #endif // ENABLE(SVG)