OLD | NEW |
| (Empty) |
1 /* | |
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. | |
5 * | |
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. | |
10 * | |
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. | |
15 * | |
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. | |
20 */ | |
21 | |
22 #ifndef SVGColor_h | |
23 #define SVGColor_h | |
24 | |
25 #include "core/css/CSSValue.h" | |
26 #include "core/css/StyleColor.h" | |
27 #include "platform/graphics/Color.h" | |
28 #include "wtf/PassRefPtr.h" | |
29 | |
30 namespace WebCore { | |
31 | |
32 class ExceptionState; | |
33 class RGBColor; | |
34 | |
35 class SVGColor : public CSSValue { | |
36 public: | |
37 enum SVGColorType { | |
38 SVG_COLORTYPE_UNKNOWN = 0, | |
39 SVG_COLORTYPE_RGBCOLOR = 1, | |
40 SVG_COLORTYPE_RGBCOLOR_ICCCOLOR = 2, | |
41 SVG_COLORTYPE_CURRENTCOLOR = 3 | |
42 }; | |
43 | |
44 static PassRefPtrWillBeRawPtr<SVGColor> createFromString(const String& rgbCo
lor) | |
45 { | |
46 RefPtrWillBeRawPtr<SVGColor> color = adoptRefWillBeRefCountedGarbageColl
ected(new SVGColor(SVG_COLORTYPE_RGBCOLOR)); | |
47 StyleColor styleColor = colorFromRGBColorString(rgbColor); | |
48 ASSERT(!styleColor.isCurrentColor()); | |
49 color->setColor(styleColor.color()); | |
50 return color.release(); | |
51 } | |
52 | |
53 static PassRefPtrWillBeRawPtr<SVGColor> createFromColor(const Color& rgbColo
r) | |
54 { | |
55 RefPtrWillBeRawPtr<SVGColor> color = adoptRefWillBeRefCountedGarbageColl
ected(new SVGColor(SVG_COLORTYPE_RGBCOLOR)); | |
56 color->setColor(rgbColor); | |
57 return color.release(); | |
58 } | |
59 | |
60 static PassRefPtrWillBeRawPtr<SVGColor> createCurrentColor() | |
61 { | |
62 return adoptRefWillBeRefCountedGarbageCollected(new SVGColor(SVG_COLORTY
PE_CURRENTCOLOR)); | |
63 } | |
64 | |
65 const Color& color() const { return m_color; } | |
66 const SVGColorType& colorType() const { return m_colorType; } | |
67 | |
68 static StyleColor colorFromRGBColorString(const String&); | |
69 | |
70 String customCSSText() const; | |
71 | |
72 ~SVGColor() { } | |
73 | |
74 PassRefPtrWillBeRawPtr<SVGColor> cloneForCSSOM() const; | |
75 | |
76 bool equals(const SVGColor&) const; | |
77 | |
78 void traceAfterDispatch(Visitor* visitor) { CSSValue::traceAfterDispatch(vis
itor); } | |
79 | |
80 protected: | |
81 friend class CSSComputedStyleDeclaration; | |
82 | |
83 SVGColor(ClassType, const SVGColorType&); | |
84 SVGColor(ClassType, const SVGColor& cloneFrom); | |
85 | |
86 void setColor(const Color& color) | |
87 { | |
88 m_color = color; | |
89 setColorType(SVG_COLORTYPE_RGBCOLOR); | |
90 } | |
91 void setColorType(const SVGColorType& type) { m_colorType = type; } | |
92 | |
93 private: | |
94 SVGColor(const SVGColorType&); | |
95 | |
96 Color m_color; | |
97 SVGColorType m_colorType; | |
98 }; | |
99 | |
100 DEFINE_CSS_VALUE_TYPE_CASTS(SVGColor, isSVGColor()); | |
101 | |
102 } // namespace WebCore | |
103 | |
104 #endif // SVGColor_h | |
OLD | NEW |