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.
28 #include <wtf/text/WTFString.h>
32 class SVGPaint : public SVGColor {
35 SVG_PAINTTYPE_UNKNOWN = 0,
36 SVG_PAINTTYPE_RGBCOLOR = 1,
37 SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR = 2,
38 SVG_PAINTTYPE_NONE = 101,
39 SVG_PAINTTYPE_CURRENTCOLOR = 102,
40 SVG_PAINTTYPE_URI_NONE = 103,
41 SVG_PAINTTYPE_URI_CURRENTCOLOR = 104,
42 SVG_PAINTTYPE_URI_RGBCOLOR = 105,
43 SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR = 106,
44 SVG_PAINTTYPE_URI = 107
47 static PassRefPtr<SVGPaint> createUnknown()
49 return adoptRef(new SVGPaint(SVG_PAINTTYPE_UNKNOWN));
52 static PassRefPtr<SVGPaint> createNone()
54 return adoptRef(new SVGPaint(SVG_PAINTTYPE_NONE));
57 static PassRefPtr<SVGPaint> createCurrentColor()
59 return adoptRef(new SVGPaint(SVG_PAINTTYPE_CURRENTCOLOR));
62 static PassRefPtr<SVGPaint> createColor(const Color& color)
64 RefPtr<SVGPaint> paint = adoptRef(new SVGPaint(SVG_PAINTTYPE_RGBCOLOR));
65 paint->setColor(color);
66 return paint.release();
69 static PassRefPtr<SVGPaint> createURI(const String& uri)
71 RefPtr<SVGPaint> paint = adoptRef(new SVGPaint(SVG_PAINTTYPE_URI, uri));
72 return paint.release();
75 static PassRefPtr<SVGPaint> createURIAndColor(const String& uri, const Color& color)
77 RefPtr<SVGPaint> paint = adoptRef(new SVGPaint(SVG_PAINTTYPE_URI_RGBCOLOR, uri));
78 paint->setColor(color);
79 return paint.release();
82 static PassRefPtr<SVGPaint> createURIAndNone(const String& uri)
84 RefPtr<SVGPaint> paint = adoptRef(new SVGPaint(SVG_PAINTTYPE_URI_NONE, uri));
85 return paint.release();
88 const SVGPaintType& paintType() const { return m_paintType; }
89 String uri() const { return m_uri; }
91 void setUri(const String&);
92 void setPaint(unsigned short paintType, const String& uri, const String& rgbColor, const String& iccColor, ExceptionCode&);
94 bool matchesTargetURI(const String& referenceId);
97 friend class CSSComputedStyleDeclaration;
99 static PassRefPtr<SVGPaint> create(const SVGPaintType& type, const String& uri, const Color& color)
101 RefPtr<SVGPaint> paint = adoptRef(new SVGPaint(type, uri));
102 paint->setColor(color);
103 return paint.release();
107 SVGPaint(const SVGPaintType&, const String& uri = String());
109 virtual bool isSVGPaint() const { return true; }
110 virtual String cssText() const;
112 SVGPaintType m_paintType;
116 } // namespace WebCore
118 #endif // ENABLE(SVG)