OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@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. | 4 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 void SVGColor::setRGBColor(const String& rgbColor, ExceptionCode& ec) | 43 void SVGColor::setRGBColor(const String& rgbColor, ExceptionCode& ec) |
44 { | 44 { |
45 Color color = SVGColor::colorFromRGBColorString(rgbColor); | 45 Color color = SVGColor::colorFromRGBColorString(rgbColor); |
46 if (!color.isValid()) { | 46 if (!color.isValid()) { |
47 ec = SVGException::SVG_INVALID_VALUE_ERR; | 47 ec = SVGException::SVG_INVALID_VALUE_ERR; |
48 return; | 48 return; |
49 } | 49 } |
50 | 50 |
51 m_color = color; | 51 m_color = color; |
52 m_colorType = SVG_COLORTYPE_RGBCOLOR; | 52 m_colorType = SVG_COLORTYPE_RGBCOLOR; |
53 setNeedsStyleRecalc(); | 53 // FIXME: A follow up patch will call valueChanged() here. |
54 } | 54 } |
55 | 55 |
56 Color SVGColor::colorFromRGBColorString(const String& colorString) | 56 Color SVGColor::colorFromRGBColorString(const String& colorString) |
57 { | 57 { |
58 // FIXME: Rework css parser so it is more SVG aware. | 58 // FIXME: Rework css parser so it is more SVG aware. |
59 RGBA32 color; | 59 RGBA32 color; |
60 if (CSSParser::parseColor(color, colorString.stripWhiteSpace())) | 60 if (CSSParser::parseColor(color, colorString.stripWhiteSpace())) |
61 return color; | 61 return color; |
62 return Color(); | 62 return Color(); |
63 } | 63 } |
64 | 64 |
65 void SVGColor::setRGBColorICCColor(const String& rgbColor, const String& iccColo
r, ExceptionCode& ec) | 65 void SVGColor::setRGBColorICCColor(const String& rgbColor, const String& iccColo
r, ExceptionCode& ec) |
66 { | 66 { |
67 if (rgbColor.isEmpty() || iccColor.isEmpty()) { | 67 if (rgbColor.isEmpty() || iccColor.isEmpty()) { |
68 ec = SVGException::SVG_INVALID_VALUE_ERR; | 68 ec = SVGException::SVG_INVALID_VALUE_ERR; |
69 return; | 69 return; |
70 } | 70 } |
71 | 71 |
72 // FIXME: No support for ICC colors. We're just ignoring it. | 72 // FIXME: No support for ICC colors. We're just ignoring it. |
73 setRGBColor(rgbColor, ec); | 73 setRGBColor(rgbColor, ec); |
74 if (ec) | 74 if (ec) |
75 return; | 75 return; |
76 | 76 |
77 m_colorType = SVG_COLORTYPE_RGBCOLOR_ICCCOLOR; | 77 m_colorType = SVG_COLORTYPE_RGBCOLOR_ICCCOLOR; |
78 setNeedsStyleRecalc(); | 78 // FIXME: A follow up patch will call valueChanged() here. |
79 } | 79 } |
80 | 80 |
81 void SVGColor::setColor(unsigned short colorType, const String& rgbColor, const
String& iccColor, ExceptionCode& ec) | 81 void SVGColor::setColor(unsigned short colorType, const String& rgbColor, const
String& iccColor, ExceptionCode& ec) |
82 { | 82 { |
83 if (colorType > SVG_COLORTYPE_CURRENTCOLOR) { | 83 if (colorType > SVG_COLORTYPE_CURRENTCOLOR) { |
84 ec = SVGException::SVG_WRONG_TYPE_ERR; | 84 ec = SVGException::SVG_WRONG_TYPE_ERR; |
85 return; | 85 return; |
86 } | 86 } |
87 | 87 |
88 bool requiresRGBColor = false; | 88 bool requiresRGBColor = false; |
(...skipping 19 matching lines...) Expand all Loading... |
108 ec = SVGException::SVG_INVALID_VALUE_ERR; | 108 ec = SVGException::SVG_INVALID_VALUE_ERR; |
109 return; | 109 return; |
110 } | 110 } |
111 | 111 |
112 // Spec: If colorType requires an SVGICCColor, then iccColor must be a strin
g that matches <icccolor>; otherwise, iccColor must be null. | 112 // Spec: If colorType requires an SVGICCColor, then iccColor must be a strin
g that matches <icccolor>; otherwise, iccColor must be null. |
113 if (requiresICCColor && iccColor.isEmpty()) { | 113 if (requiresICCColor && iccColor.isEmpty()) { |
114 ec = SVGException::SVG_INVALID_VALUE_ERR; | 114 ec = SVGException::SVG_INVALID_VALUE_ERR; |
115 return; | 115 return; |
116 } | 116 } |
117 | 117 |
118 setNeedsStyleRecalc(); | 118 // FIXME: A follow up patch will call valueChanged() here. |
119 m_colorType = type; | 119 m_colorType = type; |
120 if (!requiresRGBColor) { | 120 if (!requiresRGBColor) { |
121 ASSERT(!requiresICCColor); | 121 ASSERT(!requiresICCColor); |
122 m_color = Color(); | 122 m_color = Color(); |
123 return; | 123 return; |
124 } | 124 } |
125 | 125 |
126 if (requiresICCColor) | 126 if (requiresICCColor) |
127 setRGBColorICCColor(rgbColor, iccColor, ec); | 127 setRGBColorICCColor(rgbColor, iccColor, ec); |
128 else | 128 else |
(...skipping 15 matching lines...) Expand all Loading... |
144 return "currentColor"; | 144 return "currentColor"; |
145 } | 145 } |
146 | 146 |
147 ASSERT_NOT_REACHED(); | 147 ASSERT_NOT_REACHED(); |
148 return String(); | 148 return String(); |
149 } | 149 } |
150 | 150 |
151 } | 151 } |
152 | 152 |
153 #endif // ENABLE(SVG) | 153 #endif // ENABLE(SVG) |
OLD | NEW |