blob: 04ba185a5d4fdc94043c0fb617982b97c230c94c [file] [log] [blame]
darinb9481ed2006-03-20 02:57:59 +00001/*
eric@webkit.orge86c7fe2008-06-07 10:36:10 +00002 Copyright (C) 2008 Eric Seidel <eric@webkit.org>
oliver0099bf72007-10-12 13:47:26 +00003 Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
rwlbuis897f8682007-05-11 09:27:12 +00004 2004, 2005, 2007 Rob Buis <buis@kde.org>
darinb9481ed2006-03-20 02:57:59 +00005 Copyright (C) 2005, 2006 Apple Computer, Inc.
6
darinb9481ed2006-03-20 02:57:59 +00007 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.
11
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.
16
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
ddkilzerc8eccec2007-09-26 02:29:57 +000019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
darinb9481ed2006-03-20 02:57:59 +000021*/
22
23#include "config.h"
darinb9481ed2006-03-20 02:57:59 +000024
zimmermannd79a87b2007-10-21 20:35:24 +000025#if ENABLE(SVG)
eseidel13a64222006-05-16 05:33:34 +000026#include "CSSInheritedValue.h"
27#include "CSSInitialValue.h"
weinige7918082007-07-18 19:56:40 +000028#include "CSSParser.h"
rwlbuis798082e2006-12-30 21:54:06 +000029#include "CSSProperty.h"
darinb9481ed2006-03-20 02:57:59 +000030#include "CSSPropertyNames.h"
eseidel13a64222006-05-16 05:33:34 +000031#include "CSSQuirkPrimitiveValue.h"
darinb9481ed2006-03-20 02:57:59 +000032#include "CSSValueKeywords.h"
eseidel13a64222006-05-16 05:33:34 +000033#include "CSSValueList.h"
weinige7918082007-07-18 19:56:40 +000034#include "SVGPaint.h"
darinb9481ed2006-03-20 02:57:59 +000035
darin7bd70952006-04-13 07:07:34 +000036using namespace std;
37
darinb9481ed2006-03-20 02:57:59 +000038namespace WebCore {
39
darinb9481ed2006-03-20 02:57:59 +000040bool CSSParser::parseSVGValue(int propId, bool important)
41{
hyatt@apple.com51e2fad2008-06-19 21:49:52 +000042 CSSParserValue* value = m_valueList->current();
eseidel13a64222006-05-16 05:33:34 +000043 if (!value)
darinb9481ed2006-03-20 02:57:59 +000044 return false;
45
46 int id = value->id;
eseidel9a857cb2006-04-23 22:57:22 +000047
darinb9481ed2006-03-20 02:57:59 +000048 bool valid_primitive = false;
eric@webkit.orge555a4a2008-02-01 08:00:08 +000049 RefPtr<CSSValue> parsedValue;
darinb9481ed2006-03-20 02:57:59 +000050
aroben801701e2007-07-01 04:52:52 +000051 switch (propId) {
darinb9481ed2006-03-20 02:57:59 +000052 /* The comment to the right defines all valid value of these
53 * properties as defined in SVG 1.1, Appendix N. Property index */
mitz@apple.com920b8e02008-03-19 21:51:30 +000054 case CSSPropertyAlignmentBaseline:
darinb9481ed2006-03-20 02:57:59 +000055 // auto | baseline | before-edge | text-before-edge | middle |
56 // central | after-edge | text-after-edge | ideographic | alphabetic |
57 // hanging | mathematical | inherit
mitz@apple.com920b8e02008-03-19 21:51:30 +000058 if (id == CSSValueAuto || id == CSSValueBaseline || id == CSSValueMiddle ||
59 (id >= CSSValueBeforeEdge && id <= CSSValueMathematical))
darinb9481ed2006-03-20 02:57:59 +000060 valid_primitive = true;
61 break;
62
mitz@apple.com920b8e02008-03-19 21:51:30 +000063 case CSSPropertyBaselineShift:
darinb9481ed2006-03-20 02:57:59 +000064 // baseline | super | sub | <percentage> | <length> | inherit
mitz@apple.com920b8e02008-03-19 21:51:30 +000065 if (id == CSSValueBaseline || id == CSSValueSub ||
66 id >= CSSValueSuper)
darinb9481ed2006-03-20 02:57:59 +000067 valid_primitive = true;
68 else
69 valid_primitive = validUnit(value, FLength|FPercent, false);
70 break;
71
mitz@apple.com920b8e02008-03-19 21:51:30 +000072 case CSSPropertyDominantBaseline:
darinb9481ed2006-03-20 02:57:59 +000073 // auto | use-script | no-change | reset-size | ideographic |
74 // alphabetic | hanging | mathematical | central | middle |
75 // text-after-edge | text-before-edge | inherit
mitz@apple.com920b8e02008-03-19 21:51:30 +000076 if (id == CSSValueAuto || id == CSSValueMiddle ||
77 (id >= CSSValueUseScript && id <= CSSValueResetSize) ||
78 (id >= CSSValueCentral && id <= CSSValueMathematical))
darinb9481ed2006-03-20 02:57:59 +000079 valid_primitive = true;
80 break;
81
mitz@apple.com920b8e02008-03-19 21:51:30 +000082 case CSSPropertyEnableBackground:
darinb9481ed2006-03-20 02:57:59 +000083 // accumulate | new [x] [y] [width] [height] | inherit
mitz@apple.com920b8e02008-03-19 21:51:30 +000084 if (id == CSSValueAccumulate) // TODO : new
darinb9481ed2006-03-20 02:57:59 +000085 valid_primitive = true;
86 break;
87
mitz@apple.com920b8e02008-03-19 21:51:30 +000088 case CSSPropertyMarkerStart:
89 case CSSPropertyMarkerMid:
90 case CSSPropertyMarkerEnd:
91 case CSSPropertyMask:
92 if (id == CSSValueNone)
darinb9481ed2006-03-20 02:57:59 +000093 valid_primitive = true;
eseidel06ac2762006-09-09 01:46:18 +000094 else if (value->unit == CSSPrimitiveValue::CSS_URI) {
darin@apple.com894e8132008-06-17 19:16:22 +000095 parsedValue = CSSPrimitiveValue::create(value->string, CSSPrimitiveValue::CSS_URI);
eseidel13a64222006-05-16 05:33:34 +000096 if (parsedValue)
eric@webkit.org971c22f2008-06-07 10:33:31 +000097 m_valueList->next();
darinb9481ed2006-03-20 02:57:59 +000098 }
99 break;
100
mitz@apple.com920b8e02008-03-19 21:51:30 +0000101 case CSSPropertyClipRule: // nonzero | evenodd | inherit
102 case CSSPropertyFillRule:
103 if (id == CSSValueNonzero || id == CSSValueEvenodd)
darinb9481ed2006-03-20 02:57:59 +0000104 valid_primitive = true;
105 break;
106
mitz@apple.com920b8e02008-03-19 21:51:30 +0000107 case CSSPropertyStrokeMiterlimit: // <miterlimit> | inherit
eseidel7ff565a2007-02-06 15:34:47 +0000108 valid_primitive = validUnit(value, FNumber|FNonNeg, false);
darinb9481ed2006-03-20 02:57:59 +0000109 break;
110
mitz@apple.com920b8e02008-03-19 21:51:30 +0000111 case CSSPropertyStrokeLinejoin: // miter | round | bevel | inherit
112 if (id == CSSValueMiter || id == CSSValueRound || id == CSSValueBevel)
darinb9481ed2006-03-20 02:57:59 +0000113 valid_primitive = true;
114 break;
115
mitz@apple.com920b8e02008-03-19 21:51:30 +0000116 case CSSPropertyStrokeLinecap: // butt | round | square | inherit
117 if (id == CSSValueButt || id == CSSValueRound || id == CSSValueSquare)
darinb9481ed2006-03-20 02:57:59 +0000118 valid_primitive = true;
119 break;
120
mitz@apple.com920b8e02008-03-19 21:51:30 +0000121 case CSSPropertyStrokeOpacity: // <opacity-value> | inherit
122 case CSSPropertyFillOpacity:
123 case CSSPropertyStopOpacity:
124 case CSSPropertyFloodOpacity:
darinb9481ed2006-03-20 02:57:59 +0000125 valid_primitive = (!id && validUnit(value, FNumber|FPercent, false));
126 break;
127
mitz@apple.com920b8e02008-03-19 21:51:30 +0000128 case CSSPropertyShapeRendering:
darinb9481ed2006-03-20 02:57:59 +0000129 // auto | optimizeSpeed | crispEdges | geometricPrecision | inherit
mitz@apple.com920b8e02008-03-19 21:51:30 +0000130 if (id == CSSValueAuto || id == CSSValueOptimizespeed ||
131 id == CSSValueCrispedges || id == CSSValueGeometricprecision)
darinb9481ed2006-03-20 02:57:59 +0000132 valid_primitive = true;
133 break;
134
mitz@apple.com920b8e02008-03-19 21:51:30 +0000135 case CSSPropertyTextRendering: // auto | optimizeSpeed | optimizeLegibility | geometricPrecision | inherit
136 if (id == CSSValueAuto || id == CSSValueOptimizespeed || id == CSSValueOptimizelegibility ||
137 id == CSSValueGeometricprecision)
darinb9481ed2006-03-20 02:57:59 +0000138 valid_primitive = true;
139 break;
140
mitz@apple.com920b8e02008-03-19 21:51:30 +0000141 case CSSPropertyImageRendering: // auto | optimizeSpeed |
142 case CSSPropertyColorRendering: // optimizeQuality | inherit
143 if (id == CSSValueAuto || id == CSSValueOptimizespeed ||
144 id == CSSValueOptimizequality)
darinb9481ed2006-03-20 02:57:59 +0000145 valid_primitive = true;
146 break;
147
mitz@apple.com920b8e02008-03-19 21:51:30 +0000148 case CSSPropertyColorProfile: // auto | sRGB | <name> | <uri> inherit
149 if (id == CSSValueAuto || id == CSSValueSrgb)
darinb9481ed2006-03-20 02:57:59 +0000150 valid_primitive = true;
151 break;
152
mitz@apple.com920b8e02008-03-19 21:51:30 +0000153 case CSSPropertyColorInterpolation: // auto | sRGB | linearRGB | inherit
154 case CSSPropertyColorInterpolationFilters:
155 if (id == CSSValueAuto || id == CSSValueSrgb || id == CSSValueLinearrgb)
darinb9481ed2006-03-20 02:57:59 +0000156 valid_primitive = true;
157 break;
158
159 /* Start of supported CSS properties with validation. This is needed for parseShortHand to work
160 * correctly and allows optimization in applyRule(..)
161 */
162
mitz@apple.com920b8e02008-03-19 21:51:30 +0000163 case CSSPropertyTextAnchor: // start | middle | end | inherit
164 if (id == CSSValueStart || id == CSSValueMiddle || id == CSSValueEnd)
darinb9481ed2006-03-20 02:57:59 +0000165 valid_primitive = true;
166 break;
167
mitz@apple.com920b8e02008-03-19 21:51:30 +0000168 case CSSPropertyGlyphOrientationVertical: // auto | <angle> | inherit
169 if (id == CSSValueAuto) {
darinb9481ed2006-03-20 02:57:59 +0000170 valid_primitive = true;
171 break;
172 }
zimmermannd79a87b2007-10-21 20:35:24 +0000173 /* fallthrough intentional */
mitz@apple.com920b8e02008-03-19 21:51:30 +0000174 case CSSPropertyGlyphOrientationHorizontal: // <angle> (restricted to _deg_ per SVG 1.1 spec) | inherit
zimmermannd79a87b2007-10-21 20:35:24 +0000175 if (value->unit == CSSPrimitiveValue::CSS_DEG || value->unit == CSSPrimitiveValue::CSS_NUMBER) {
darin@apple.com894e8132008-06-17 19:16:22 +0000176 parsedValue = CSSPrimitiveValue::create(value->fValue, CSSPrimitiveValue::CSS_DEG);
zimmermannd79a87b2007-10-21 20:35:24 +0000177
178 if (parsedValue)
eric@webkit.org971c22f2008-06-07 10:33:31 +0000179 m_valueList->next();
zimmermannd79a87b2007-10-21 20:35:24 +0000180 }
darinb9481ed2006-03-20 02:57:59 +0000181 break;
182
mitz@apple.com920b8e02008-03-19 21:51:30 +0000183 case CSSPropertyFill: // <paint> | inherit
184 case CSSPropertyStroke: // <paint> | inherit
darinb9481ed2006-03-20 02:57:59 +0000185 {
mitz@apple.com920b8e02008-03-19 21:51:30 +0000186 if (id == CSSValueNone)
darin@apple.com894e8132008-06-17 19:16:22 +0000187 parsedValue = SVGPaint::create(SVGPaint::SVG_PAINTTYPE_NONE);
mitz@apple.com920b8e02008-03-19 21:51:30 +0000188 else if (id == CSSValueCurrentcolor)
darin@apple.com894e8132008-06-17 19:16:22 +0000189 parsedValue = SVGPaint::create(SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR);
oliver2ac34292007-10-12 12:39:46 +0000190 else if (value->unit == CSSPrimitiveValue::CSS_URI) {
191 RGBA32 c = Color::transparent;
eric@webkit.org971c22f2008-06-07 10:33:31 +0000192 if (m_valueList->next() && parseColorFromValue(m_valueList->current(), c, true)) {
darin@apple.com894e8132008-06-17 19:16:22 +0000193 parsedValue = SVGPaint::create(value->string, c);
oliver2ac34292007-10-12 12:39:46 +0000194 } else
darin@apple.com894e8132008-06-17 19:16:22 +0000195 parsedValue = SVGPaint::create(SVGPaint::SVG_PAINTTYPE_URI, value->string);
oliver2ac34292007-10-12 12:39:46 +0000196 } else
darinb9481ed2006-03-20 02:57:59 +0000197 parsedValue = parseSVGPaint();
198
eseidel13a64222006-05-16 05:33:34 +0000199 if (parsedValue)
eric@webkit.org971c22f2008-06-07 10:33:31 +0000200 m_valueList->next();
darinb9481ed2006-03-20 02:57:59 +0000201 }
202 break;
203
mitz@apple.com920b8e02008-03-19 21:51:30 +0000204 case CSSPropertyColor: // <color> | inherit
205 if ((id >= CSSValueAqua && id <= CSSValueWindowtext) ||
206 (id >= CSSValueAliceblue && id <= CSSValueYellowgreen))
darin@apple.com894e8132008-06-17 19:16:22 +0000207 parsedValue = SVGColor::create(value->string);
darinb9481ed2006-03-20 02:57:59 +0000208 else
209 parsedValue = parseSVGColor();
210
eseidel13a64222006-05-16 05:33:34 +0000211 if (parsedValue)
eric@webkit.org971c22f2008-06-07 10:33:31 +0000212 m_valueList->next();
darinb9481ed2006-03-20 02:57:59 +0000213 break;
214
mitz@apple.com920b8e02008-03-19 21:51:30 +0000215 case CSSPropertyStopColor: // TODO : icccolor
216 case CSSPropertyFloodColor:
217 case CSSPropertyLightingColor:
218 if ((id >= CSSValueAqua && id <= CSSValueWindowtext) ||
219 (id >= CSSValueAliceblue && id <= CSSValueYellowgreen))
darin@apple.com894e8132008-06-17 19:16:22 +0000220 parsedValue = SVGColor::create(value->string);
mitz@apple.com920b8e02008-03-19 21:51:30 +0000221 else if (id == CSSValueCurrentcolor)
darin@apple.com894e8132008-06-17 19:16:22 +0000222 parsedValue = SVGColor::createCurrentColor();
darinb9481ed2006-03-20 02:57:59 +0000223 else // TODO : svgcolor (iccColor)
224 parsedValue = parseSVGColor();
225
eseidel13a64222006-05-16 05:33:34 +0000226 if (parsedValue)
eric@webkit.org971c22f2008-06-07 10:33:31 +0000227 m_valueList->next();
darinb9481ed2006-03-20 02:57:59 +0000228
229 break;
230
mitz@apple.com920b8e02008-03-19 21:51:30 +0000231 case CSSPropertyWritingMode:
darinb9481ed2006-03-20 02:57:59 +0000232 // lr-tb | rl_tb | tb-rl | lr | rl | tb | inherit
mitz@apple.com920b8e02008-03-19 21:51:30 +0000233 if (id >= CSSValueLrTb && id <= CSSValueTb)
darinb9481ed2006-03-20 02:57:59 +0000234 valid_primitive = true;
235 break;
236
mitz@apple.com920b8e02008-03-19 21:51:30 +0000237 case CSSPropertyStrokeWidth: // <length> | inherit
238 case CSSPropertyStrokeDashoffset:
darinb9481ed2006-03-20 02:57:59 +0000239 valid_primitive = validUnit(value, FLength | FPercent, false);
240 break;
mitz@apple.com920b8e02008-03-19 21:51:30 +0000241 case CSSPropertyStrokeDasharray: // none | <dasharray> | inherit
242 if (id == CSSValueNone)
darinb9481ed2006-03-20 02:57:59 +0000243 valid_primitive = true;
244 else
245 parsedValue = parseSVGStrokeDasharray();
246
247 break;
248
mitz@apple.com920b8e02008-03-19 21:51:30 +0000249 case CSSPropertyKerning: // auto | normal | <length> | inherit
250 if (id == CSSValueAuto || id == CSSValueNormal)
darinb9481ed2006-03-20 02:57:59 +0000251 valid_primitive = true;
252 else
253 valid_primitive = validUnit(value, FLength, false);
254 break;
darinb9481ed2006-03-20 02:57:59 +0000255
mitz@apple.com920b8e02008-03-19 21:51:30 +0000256 case CSSPropertyClipPath: // <uri> | none | inherit
257 case CSSPropertyFilter:
258 if (id == CSSValueNone)
darinb9481ed2006-03-20 02:57:59 +0000259 valid_primitive = true;
eseidel06ac2762006-09-09 01:46:18 +0000260 else if (value->unit == CSSPrimitiveValue::CSS_URI) {
darin@apple.com894e8132008-06-17 19:16:22 +0000261 parsedValue = CSSPrimitiveValue::create(value->string, (CSSPrimitiveValue::UnitTypes) value->unit);
eseidel13a64222006-05-16 05:33:34 +0000262 if (parsedValue)
eric@webkit.org971c22f2008-06-07 10:33:31 +0000263 m_valueList->next();
darinb9481ed2006-03-20 02:57:59 +0000264 }
265 break;
266
eseidel9a857cb2006-04-23 22:57:22 +0000267 /* shorthand properties */
mitz@apple.com920b8e02008-03-19 21:51:30 +0000268 case CSSPropertyMarker:
eseidel9a857cb2006-04-23 22:57:22 +0000269 {
rwlbuis@webkit.org796715f2008-03-31 06:49:17 +0000270 ShorthandScope scope(this, propId);
271 m_implicitShorthand = true;
mitz@apple.com920b8e02008-03-19 21:51:30 +0000272 if (!parseValue(CSSPropertyMarkerStart, important))
rwlbuis798082e2006-12-30 21:54:06 +0000273 return false;
eric@webkit.org971c22f2008-06-07 10:33:31 +0000274 if (m_valueList->current()) {
rwlbuis@webkit.org796715f2008-03-31 06:49:17 +0000275 rollbackLastProperties(1);
276 return false;
277 }
eric@webkit.org99261672008-06-06 22:09:40 +0000278 CSSValue* value = m_parsedProperties[m_numParsedProperties - 1]->value();
mitz@apple.com920b8e02008-03-19 21:51:30 +0000279 addProperty(CSSPropertyMarkerMid, value, important);
280 addProperty(CSSPropertyMarkerEnd, value, important);
rwlbuis798082e2006-12-30 21:54:06 +0000281 m_implicitShorthand = false;
282 return true;
eseidel9a857cb2006-04-23 22:57:22 +0000283 }
darinb9481ed2006-03-20 02:57:59 +0000284 default:
oliverf7865032007-10-12 15:32:39 +0000285 // If you crash here, it's because you added a css property and are not handling it
286 // in either this switch statement or the one in CSSParser::parseValue
287 ASSERT_WITH_MESSAGE(0, "unimplemented propertyID: %d", propId);
darinb9481ed2006-03-20 02:57:59 +0000288 return false;
289 }
290
eseidel06ac2762006-09-09 01:46:18 +0000291 if (valid_primitive) {
eseidel13a64222006-05-16 05:33:34 +0000292 if (id != 0)
darin@apple.com894e8132008-06-17 19:16:22 +0000293 parsedValue = CSSPrimitiveValue::createIdentifier(id);
eseidel13a64222006-05-16 05:33:34 +0000294 else if (value->unit == CSSPrimitiveValue::CSS_STRING)
darin@apple.com894e8132008-06-17 19:16:22 +0000295 parsedValue = CSSPrimitiveValue::create(value->string, (CSSPrimitiveValue::UnitTypes) value->unit);
eseidel13a64222006-05-16 05:33:34 +0000296 else if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ)
darin@apple.com894e8132008-06-17 19:16:22 +0000297 parsedValue = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
hyatt@apple.com51e2fad2008-06-19 21:49:52 +0000298 else if (value->unit >= CSSParserValue::Q_EMS)
darin@apple.com894e8132008-06-17 19:16:22 +0000299 parsedValue = CSSQuirkPrimitiveValue::create(value->fValue, CSSPrimitiveValue::CSS_EMS);
eric@webkit.org971c22f2008-06-07 10:33:31 +0000300 m_valueList->next();
darinb9481ed2006-03-20 02:57:59 +0000301 }
eric@webkit.org971c22f2008-06-07 10:33:31 +0000302 if (!parsedValue || (m_valueList->current() && !inShorthand()))
eric@webkit.orge555a4a2008-02-01 08:00:08 +0000303 return false;
304
305 addProperty(propId, parsedValue.release(), important);
306 return true;
darinb9481ed2006-03-20 02:57:59 +0000307}
308
eric@webkit.orge555a4a2008-02-01 08:00:08 +0000309PassRefPtr<CSSValue> CSSParser::parseSVGStrokeDasharray()
darinb9481ed2006-03-20 02:57:59 +0000310{
darin@apple.com894e8132008-06-17 19:16:22 +0000311 RefPtr<CSSValueList> ret = CSSValueList::createCommaSeparated();
hyatt@apple.com51e2fad2008-06-19 21:49:52 +0000312 CSSParserValue* value = m_valueList->current();
darinb9481ed2006-03-20 02:57:59 +0000313 bool valid_primitive = true;
rwlbuis897f8682007-05-11 09:27:12 +0000314 while (value) {
darinb9481ed2006-03-20 02:57:59 +0000315 valid_primitive = validUnit(value, FLength | FPercent |FNonNeg, false);
rwlbuis897f8682007-05-11 09:27:12 +0000316 if (!valid_primitive)
317 break;
eseidel13a64222006-05-16 05:33:34 +0000318 if (value->id != 0)
darin@apple.com894e8132008-06-17 19:16:22 +0000319 ret->append(CSSPrimitiveValue::createIdentifier(value->id));
eseidel13a64222006-05-16 05:33:34 +0000320 else if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ)
darin@apple.com894e8132008-06-17 19:16:22 +0000321 ret->append(CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit));
eric@webkit.org971c22f2008-06-07 10:33:31 +0000322 value = m_valueList->next();
hyatt@apple.com51e2fad2008-06-19 21:49:52 +0000323 if (value && value->unit == CSSParserValue::Operator && value->iValue == ',')
eric@webkit.org971c22f2008-06-07 10:33:31 +0000324 value = m_valueList->next();
darinb9481ed2006-03-20 02:57:59 +0000325 }
darin@apple.com894e8132008-06-17 19:16:22 +0000326 if (!valid_primitive)
327 return 0;
328 return ret.release();
darinb9481ed2006-03-20 02:57:59 +0000329}
330
eric@webkit.orge555a4a2008-02-01 08:00:08 +0000331PassRefPtr<CSSValue> CSSParser::parseSVGPaint()
darinb9481ed2006-03-20 02:57:59 +0000332{
rwlbuis274d6282006-12-29 22:14:41 +0000333 RGBA32 c = Color::transparent;
eric@webkit.org971c22f2008-06-07 10:33:31 +0000334 if (!parseColorFromValue(m_valueList->current(), c, true))
darin@apple.com894e8132008-06-17 19:16:22 +0000335 return SVGPaint::create();
336 return SVGPaint::create(Color(c));
darinb9481ed2006-03-20 02:57:59 +0000337}
338
eric@webkit.orge555a4a2008-02-01 08:00:08 +0000339PassRefPtr<CSSValue> CSSParser::parseSVGColor()
darinb9481ed2006-03-20 02:57:59 +0000340{
rwlbuis274d6282006-12-29 22:14:41 +0000341 RGBA32 c = Color::transparent;
eric@webkit.org971c22f2008-06-07 10:33:31 +0000342 if (!parseColorFromValue(m_valueList->current(), c, true))
darinb9481ed2006-03-20 02:57:59 +0000343 return 0;
darin@apple.com894e8132008-06-17 19:16:22 +0000344 return SVGColor::create(Color(c));
darinb9481ed2006-03-20 02:57:59 +0000345}
346
347}
348
mjsd2948ef2007-02-26 19:29:04 +0000349#endif // ENABLE(SVG)
darinb9481ed2006-03-20 02:57:59 +0000350
351// vim:ts=4:noet