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) 2006 Samuel Weinig <sam.weinig@gmial.com>
5 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
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.
26 #include "core/css/CSSValue.h"
27 #include "core/css/StyleColor.h"
28 #include "platform/graphics/Color.h"
29 #include "wtf/text/WTFString.h"
33 class SVGPaint : public CSSValue {
36 SVG_PAINTTYPE_UNKNOWN,
37 SVG_PAINTTYPE_RGBCOLOR,
38 SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR,
40 SVG_PAINTTYPE_CURRENTCOLOR,
41 SVG_PAINTTYPE_URI_NONE,
42 SVG_PAINTTYPE_URI_CURRENTCOLOR,
43 SVG_PAINTTYPE_URI_RGBCOLOR,
44 SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR,
48 static PassRefPtrWillBeRawPtr<SVGPaint> createUnknown()
50 return adoptRefWillBeNoop(new SVGPaint(SVG_PAINTTYPE_UNKNOWN));
53 static PassRefPtrWillBeRawPtr<SVGPaint> createNone()
55 return adoptRefWillBeNoop(new SVGPaint(SVG_PAINTTYPE_NONE));
58 static PassRefPtrWillBeRawPtr<SVGPaint> createCurrentColor()
60 return adoptRefWillBeNoop(new SVGPaint(SVG_PAINTTYPE_CURRENTCOLOR));
63 static PassRefPtrWillBeRawPtr<SVGPaint> createColor(const Color& color)
65 RefPtrWillBeRawPtr<SVGPaint> paint = adoptRefWillBeNoop(new SVGPaint(SVG_PAINTTYPE_RGBCOLOR));
66 paint->m_color = color;
67 return paint.release();
70 static PassRefPtrWillBeRawPtr<SVGPaint> createURI(const String& uri)
72 RefPtrWillBeRawPtr<SVGPaint> paint = adoptRefWillBeNoop(new SVGPaint(SVG_PAINTTYPE_URI, uri));
73 return paint.release();
76 static PassRefPtrWillBeRawPtr<SVGPaint> createURIAndColor(const String& uri, const Color& color)
78 RefPtrWillBeRawPtr<SVGPaint> paint = adoptRefWillBeNoop(new SVGPaint(SVG_PAINTTYPE_URI_RGBCOLOR, uri));
79 paint->m_color = color;
80 return paint.release();
83 static PassRefPtrWillBeRawPtr<SVGPaint> createURIAndNone(const String& uri)
85 RefPtrWillBeRawPtr<SVGPaint> paint = adoptRefWillBeNoop(new SVGPaint(SVG_PAINTTYPE_URI_NONE, uri));
86 return paint.release();
89 static PassRefPtrWillBeRawPtr<SVGPaint> createURIAndCurrentColor(const String& uri)
91 RefPtrWillBeRawPtr<SVGPaint> paint = adoptRefWillBeNoop(new SVGPaint(SVG_PAINTTYPE_URI_CURRENTCOLOR, uri));
92 return paint.release();
95 const SVGPaintType& paintType() const { return m_paintType; }
96 String uri() const { return m_uri; }
98 String customCSSText() const;
100 PassRefPtrWillBeRawPtr<SVGPaint> cloneForCSSOM() const;
102 bool equals(const SVGPaint&) const;
104 void traceAfterDispatch(Visitor* visitor) { CSSValue::traceAfterDispatch(visitor); }
106 Color color() const { return m_color; }
107 void setColor(const Color& color) { m_color = color; m_paintType = SVG_PAINTTYPE_RGBCOLOR; }
109 static StyleColor colorFromRGBColorString(const String&);
112 friend class CSSComputedStyleDeclaration;
114 static PassRefPtrWillBeRawPtr<SVGPaint> create(const SVGPaintType& type, const String& uri, const Color& color)
116 RefPtrWillBeRawPtr<SVGPaint> paint = adoptRefWillBeNoop(new SVGPaint(type, uri));
117 paint->m_color = color;
118 return paint.release();
122 SVGPaint(const SVGPaintType&, const String& uri = String());
123 SVGPaint(const SVGPaint& cloneFrom);
125 SVGPaintType m_paintType;
130 DEFINE_CSS_VALUE_TYPE_CASTS(SVGPaint, isSVGPaint());
132 } // namespace WebCore