1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
/*
* Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
* Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
* Copyright (C) 2006 Samuel Weinig <sam.weinig@gmial.com>
* Copyright (C) Research In Motion Limited 2011. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef SVGPaint_h
#define SVGPaint_h
#include "core/css/CSSValue.h"
#include "core/css/StyleColor.h"
#include "platform/graphics/Color.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
class SVGPaint : public CSSValue {
public:
enum SVGPaintType {
SVG_PAINTTYPE_UNKNOWN,
SVG_PAINTTYPE_RGBCOLOR,
SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR,
SVG_PAINTTYPE_NONE,
SVG_PAINTTYPE_CURRENTCOLOR,
SVG_PAINTTYPE_URI_NONE,
SVG_PAINTTYPE_URI_CURRENTCOLOR,
SVG_PAINTTYPE_URI_RGBCOLOR,
SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR,
SVG_PAINTTYPE_URI
};
static PassRefPtrWillBeRawPtr<SVGPaint> createUnknown()
{
return adoptRefWillBeNoop(new SVGPaint(SVG_PAINTTYPE_UNKNOWN));
}
static PassRefPtrWillBeRawPtr<SVGPaint> createNone()
{
return adoptRefWillBeNoop(new SVGPaint(SVG_PAINTTYPE_NONE));
}
static PassRefPtrWillBeRawPtr<SVGPaint> createCurrentColor()
{
return adoptRefWillBeNoop(new SVGPaint(SVG_PAINTTYPE_CURRENTCOLOR));
}
static PassRefPtrWillBeRawPtr<SVGPaint> createColor(const Color& color)
{
RefPtrWillBeRawPtr<SVGPaint> paint = adoptRefWillBeNoop(new SVGPaint(SVG_PAINTTYPE_RGBCOLOR));
paint->m_color = color;
return paint.release();
}
static PassRefPtrWillBeRawPtr<SVGPaint> createURI(const String& uri)
{
RefPtrWillBeRawPtr<SVGPaint> paint = adoptRefWillBeNoop(new SVGPaint(SVG_PAINTTYPE_URI, uri));
return paint.release();
}
static PassRefPtrWillBeRawPtr<SVGPaint> createURIAndColor(const String& uri, const Color& color)
{
RefPtrWillBeRawPtr<SVGPaint> paint = adoptRefWillBeNoop(new SVGPaint(SVG_PAINTTYPE_URI_RGBCOLOR, uri));
paint->m_color = color;
return paint.release();
}
static PassRefPtrWillBeRawPtr<SVGPaint> createURIAndNone(const String& uri)
{
RefPtrWillBeRawPtr<SVGPaint> paint = adoptRefWillBeNoop(new SVGPaint(SVG_PAINTTYPE_URI_NONE, uri));
return paint.release();
}
static PassRefPtrWillBeRawPtr<SVGPaint> createURIAndCurrentColor(const String& uri)
{
RefPtrWillBeRawPtr<SVGPaint> paint = adoptRefWillBeNoop(new SVGPaint(SVG_PAINTTYPE_URI_CURRENTCOLOR, uri));
return paint.release();
}
const SVGPaintType& paintType() const { return m_paintType; }
String uri() const { return m_uri; }
String customCSSText() const;
PassRefPtrWillBeRawPtr<SVGPaint> cloneForCSSOM() const;
bool equals(const SVGPaint&) const;
void traceAfterDispatch(Visitor* visitor) { CSSValue::traceAfterDispatch(visitor); }
Color color() const { return m_color; }
void setColor(const Color& color) { m_color = color; m_paintType = SVG_PAINTTYPE_RGBCOLOR; }
static StyleColor colorFromRGBColorString(const String&);
private:
friend class CSSComputedStyleDeclaration;
static PassRefPtrWillBeRawPtr<SVGPaint> create(const SVGPaintType& type, const String& uri, const Color& color)
{
RefPtrWillBeRawPtr<SVGPaint> paint = adoptRefWillBeNoop(new SVGPaint(type, uri));
paint->m_color = color;
return paint.release();
}
private:
SVGPaint(const SVGPaintType&, const String& uri = String());
SVGPaint(const SVGPaint& cloneFrom);
SVGPaintType m_paintType;
Color m_color;
String m_uri;
};
DEFINE_CSS_VALUE_TYPE_CASTS(SVGPaint, isSVGPaint());
} // namespace WebCore
#endif // SVGPaint_h
|