2 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
4 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
27 #include "CSSParser.h"
29 #include "SVGException.h"
33 SVGColor::SVGColor(const SVGColorType& colorType)
34 : CSSValue(SVGColorClass)
35 , m_colorType(colorType)
39 SVGColor::SVGColor(ClassType classType, const SVGColorType& colorType)
41 , m_colorType(colorType)
45 PassRefPtr<RGBColor> SVGColor::rgbColor() const
47 return RGBColor::create(m_color.rgb());
50 Color SVGColor::colorFromRGBColorString(const String& colorString)
52 // FIXME: Rework css parser so it is more SVG aware.
54 if (CSSParser::parseColor(color, colorString.stripWhiteSpace()))
59 void SVGColor::setRGBColor(const String&, ExceptionCode& ec)
61 // The whole SVGColor interface is deprecated in SVG 1.1 (2nd edition).
62 // The setters are the most problematic part so we remove the support for those first.
63 ec = NO_MODIFICATION_ALLOWED_ERR;
66 void SVGColor::setRGBColorICCColor(const String&, const String&, ExceptionCode& ec)
68 ec = NO_MODIFICATION_ALLOWED_ERR;
71 void SVGColor::setColor(unsigned short, const String&, const String&, ExceptionCode& ec)
73 ec = NO_MODIFICATION_ALLOWED_ERR;
76 String SVGColor::customCssText() const
78 switch (m_colorType) {
79 case SVG_COLORTYPE_UNKNOWN:
81 case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR:
82 case SVG_COLORTYPE_RGBCOLOR:
83 // FIXME: No ICC color support.
84 return m_color.serialized();
85 case SVG_COLORTYPE_CURRENTCOLOR:
86 if (m_color.isValid())
87 return m_color.serialized();
88 return "currentColor";