darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 1 | /* |
eric@webkit.org | e86c7fe | 2008-06-07 10:36:10 +0000 | [diff] [blame] | 2 | Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
oliver | 0099bf7 | 2007-10-12 13:47:26 +0000 | [diff] [blame] | 3 | Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> |
rwlbuis | 897f868 | 2007-05-11 09:27:12 +0000 | [diff] [blame] | 4 | 2004, 2005, 2007 Rob Buis <buis@kde.org> |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 5 | Copyright (C) 2005, 2006 Apple Computer, Inc. |
| 6 | |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 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. |
| 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 |
ddkilzer | c8eccec | 2007-09-26 02:29:57 +0000 | [diff] [blame] | 19 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 | Boston, MA 02110-1301, USA. |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 21 | */ |
| 22 | |
| 23 | #include "config.h" |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 24 | |
zimmermann | d79a87b | 2007-10-21 20:35:24 +0000 | [diff] [blame] | 25 | #if ENABLE(SVG) |
eseidel | 13a6422 | 2006-05-16 05:33:34 +0000 | [diff] [blame] | 26 | #include "CSSInheritedValue.h" |
| 27 | #include "CSSInitialValue.h" |
weinig | e791808 | 2007-07-18 19:56:40 +0000 | [diff] [blame] | 28 | #include "CSSParser.h" |
rwlbuis | 798082e | 2006-12-30 21:54:06 +0000 | [diff] [blame] | 29 | #include "CSSProperty.h" |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 30 | #include "CSSPropertyNames.h" |
eseidel | 13a6422 | 2006-05-16 05:33:34 +0000 | [diff] [blame] | 31 | #include "CSSQuirkPrimitiveValue.h" |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 32 | #include "CSSValueKeywords.h" |
eseidel | 13a6422 | 2006-05-16 05:33:34 +0000 | [diff] [blame] | 33 | #include "CSSValueList.h" |
weinig | e791808 | 2007-07-18 19:56:40 +0000 | [diff] [blame] | 34 | #include "SVGPaint.h" |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 35 | |
darin | 7bd7095 | 2006-04-13 07:07:34 +0000 | [diff] [blame] | 36 | using namespace std; |
| 37 | |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 38 | namespace WebCore { |
| 39 | |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 40 | bool CSSParser::parseSVGValue(int propId, bool important) |
| 41 | { |
hyatt@apple.com | 51e2fad | 2008-06-19 21:49:52 +0000 | [diff] [blame] | 42 | CSSParserValue* value = m_valueList->current(); |
eseidel | 13a6422 | 2006-05-16 05:33:34 +0000 | [diff] [blame] | 43 | if (!value) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 44 | return false; |
| 45 | |
| 46 | int id = value->id; |
eseidel | 9a857cb | 2006-04-23 22:57:22 +0000 | [diff] [blame] | 47 | |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 48 | bool valid_primitive = false; |
eric@webkit.org | e555a4a | 2008-02-01 08:00:08 +0000 | [diff] [blame] | 49 | RefPtr<CSSValue> parsedValue; |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 50 | |
aroben | 801701e | 2007-07-01 04:52:52 +0000 | [diff] [blame] | 51 | switch (propId) { |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 52 | /* 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.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 54 | case CSSPropertyAlignmentBaseline: |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 55 | // auto | baseline | before-edge | text-before-edge | middle | |
| 56 | // central | after-edge | text-after-edge | ideographic | alphabetic | |
| 57 | // hanging | mathematical | inherit |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 58 | if (id == CSSValueAuto || id == CSSValueBaseline || id == CSSValueMiddle || |
| 59 | (id >= CSSValueBeforeEdge && id <= CSSValueMathematical)) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 60 | valid_primitive = true; |
| 61 | break; |
| 62 | |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 63 | case CSSPropertyBaselineShift: |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 64 | // baseline | super | sub | <percentage> | <length> | inherit |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 65 | if (id == CSSValueBaseline || id == CSSValueSub || |
| 66 | id >= CSSValueSuper) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 67 | valid_primitive = true; |
| 68 | else |
| 69 | valid_primitive = validUnit(value, FLength|FPercent, false); |
| 70 | break; |
| 71 | |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 72 | case CSSPropertyDominantBaseline: |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 73 | // auto | use-script | no-change | reset-size | ideographic | |
| 74 | // alphabetic | hanging | mathematical | central | middle | |
| 75 | // text-after-edge | text-before-edge | inherit |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 76 | if (id == CSSValueAuto || id == CSSValueMiddle || |
| 77 | (id >= CSSValueUseScript && id <= CSSValueResetSize) || |
| 78 | (id >= CSSValueCentral && id <= CSSValueMathematical)) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 79 | valid_primitive = true; |
| 80 | break; |
| 81 | |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 82 | case CSSPropertyEnableBackground: |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 83 | // accumulate | new [x] [y] [width] [height] | inherit |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 84 | if (id == CSSValueAccumulate) // TODO : new |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 85 | valid_primitive = true; |
| 86 | break; |
| 87 | |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 88 | case CSSPropertyMarkerStart: |
| 89 | case CSSPropertyMarkerMid: |
| 90 | case CSSPropertyMarkerEnd: |
| 91 | case CSSPropertyMask: |
| 92 | if (id == CSSValueNone) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 93 | valid_primitive = true; |
eseidel | 06ac276 | 2006-09-09 01:46:18 +0000 | [diff] [blame] | 94 | else if (value->unit == CSSPrimitiveValue::CSS_URI) { |
darin@apple.com | 894e813 | 2008-06-17 19:16:22 +0000 | [diff] [blame] | 95 | parsedValue = CSSPrimitiveValue::create(value->string, CSSPrimitiveValue::CSS_URI); |
eseidel | 13a6422 | 2006-05-16 05:33:34 +0000 | [diff] [blame] | 96 | if (parsedValue) |
eric@webkit.org | 971c22f | 2008-06-07 10:33:31 +0000 | [diff] [blame] | 97 | m_valueList->next(); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 98 | } |
| 99 | break; |
| 100 | |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 101 | case CSSPropertyClipRule: // nonzero | evenodd | inherit |
| 102 | case CSSPropertyFillRule: |
| 103 | if (id == CSSValueNonzero || id == CSSValueEvenodd) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 104 | valid_primitive = true; |
| 105 | break; |
| 106 | |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 107 | case CSSPropertyStrokeMiterlimit: // <miterlimit> | inherit |
eseidel | 7ff565a | 2007-02-06 15:34:47 +0000 | [diff] [blame] | 108 | valid_primitive = validUnit(value, FNumber|FNonNeg, false); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 109 | break; |
| 110 | |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 111 | case CSSPropertyStrokeLinejoin: // miter | round | bevel | inherit |
| 112 | if (id == CSSValueMiter || id == CSSValueRound || id == CSSValueBevel) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 113 | valid_primitive = true; |
| 114 | break; |
| 115 | |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 116 | case CSSPropertyStrokeLinecap: // butt | round | square | inherit |
| 117 | if (id == CSSValueButt || id == CSSValueRound || id == CSSValueSquare) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 118 | valid_primitive = true; |
| 119 | break; |
| 120 | |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 121 | case CSSPropertyStrokeOpacity: // <opacity-value> | inherit |
| 122 | case CSSPropertyFillOpacity: |
| 123 | case CSSPropertyStopOpacity: |
| 124 | case CSSPropertyFloodOpacity: |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 125 | valid_primitive = (!id && validUnit(value, FNumber|FPercent, false)); |
| 126 | break; |
| 127 | |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 128 | case CSSPropertyShapeRendering: |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 129 | // auto | optimizeSpeed | crispEdges | geometricPrecision | inherit |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 130 | if (id == CSSValueAuto || id == CSSValueOptimizespeed || |
| 131 | id == CSSValueCrispedges || id == CSSValueGeometricprecision) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 132 | valid_primitive = true; |
| 133 | break; |
| 134 | |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 135 | case CSSPropertyTextRendering: // auto | optimizeSpeed | optimizeLegibility | geometricPrecision | inherit |
| 136 | if (id == CSSValueAuto || id == CSSValueOptimizespeed || id == CSSValueOptimizelegibility || |
| 137 | id == CSSValueGeometricprecision) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 138 | valid_primitive = true; |
| 139 | break; |
| 140 | |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 141 | case CSSPropertyImageRendering: // auto | optimizeSpeed | |
| 142 | case CSSPropertyColorRendering: // optimizeQuality | inherit |
| 143 | if (id == CSSValueAuto || id == CSSValueOptimizespeed || |
| 144 | id == CSSValueOptimizequality) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 145 | valid_primitive = true; |
| 146 | break; |
| 147 | |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 148 | case CSSPropertyColorProfile: // auto | sRGB | <name> | <uri> inherit |
| 149 | if (id == CSSValueAuto || id == CSSValueSrgb) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 150 | valid_primitive = true; |
| 151 | break; |
| 152 | |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 153 | case CSSPropertyColorInterpolation: // auto | sRGB | linearRGB | inherit |
| 154 | case CSSPropertyColorInterpolationFilters: |
| 155 | if (id == CSSValueAuto || id == CSSValueSrgb || id == CSSValueLinearrgb) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 156 | 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.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 163 | case CSSPropertyTextAnchor: // start | middle | end | inherit |
| 164 | if (id == CSSValueStart || id == CSSValueMiddle || id == CSSValueEnd) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 165 | valid_primitive = true; |
| 166 | break; |
| 167 | |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 168 | case CSSPropertyGlyphOrientationVertical: // auto | <angle> | inherit |
| 169 | if (id == CSSValueAuto) { |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 170 | valid_primitive = true; |
| 171 | break; |
| 172 | } |
zimmermann | d79a87b | 2007-10-21 20:35:24 +0000 | [diff] [blame] | 173 | /* fallthrough intentional */ |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 174 | case CSSPropertyGlyphOrientationHorizontal: // <angle> (restricted to _deg_ per SVG 1.1 spec) | inherit |
zimmermann | d79a87b | 2007-10-21 20:35:24 +0000 | [diff] [blame] | 175 | if (value->unit == CSSPrimitiveValue::CSS_DEG || value->unit == CSSPrimitiveValue::CSS_NUMBER) { |
darin@apple.com | 894e813 | 2008-06-17 19:16:22 +0000 | [diff] [blame] | 176 | parsedValue = CSSPrimitiveValue::create(value->fValue, CSSPrimitiveValue::CSS_DEG); |
zimmermann | d79a87b | 2007-10-21 20:35:24 +0000 | [diff] [blame] | 177 | |
| 178 | if (parsedValue) |
eric@webkit.org | 971c22f | 2008-06-07 10:33:31 +0000 | [diff] [blame] | 179 | m_valueList->next(); |
zimmermann | d79a87b | 2007-10-21 20:35:24 +0000 | [diff] [blame] | 180 | } |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 181 | break; |
| 182 | |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 183 | case CSSPropertyFill: // <paint> | inherit |
| 184 | case CSSPropertyStroke: // <paint> | inherit |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 185 | { |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 186 | if (id == CSSValueNone) |
darin@apple.com | 894e813 | 2008-06-17 19:16:22 +0000 | [diff] [blame] | 187 | parsedValue = SVGPaint::create(SVGPaint::SVG_PAINTTYPE_NONE); |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 188 | else if (id == CSSValueCurrentcolor) |
darin@apple.com | 894e813 | 2008-06-17 19:16:22 +0000 | [diff] [blame] | 189 | parsedValue = SVGPaint::create(SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR); |
oliver | 2ac3429 | 2007-10-12 12:39:46 +0000 | [diff] [blame] | 190 | else if (value->unit == CSSPrimitiveValue::CSS_URI) { |
| 191 | RGBA32 c = Color::transparent; |
eric@webkit.org | 971c22f | 2008-06-07 10:33:31 +0000 | [diff] [blame] | 192 | if (m_valueList->next() && parseColorFromValue(m_valueList->current(), c, true)) { |
darin@apple.com | 894e813 | 2008-06-17 19:16:22 +0000 | [diff] [blame] | 193 | parsedValue = SVGPaint::create(value->string, c); |
oliver | 2ac3429 | 2007-10-12 12:39:46 +0000 | [diff] [blame] | 194 | } else |
darin@apple.com | 894e813 | 2008-06-17 19:16:22 +0000 | [diff] [blame] | 195 | parsedValue = SVGPaint::create(SVGPaint::SVG_PAINTTYPE_URI, value->string); |
oliver | 2ac3429 | 2007-10-12 12:39:46 +0000 | [diff] [blame] | 196 | } else |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 197 | parsedValue = parseSVGPaint(); |
| 198 | |
eseidel | 13a6422 | 2006-05-16 05:33:34 +0000 | [diff] [blame] | 199 | if (parsedValue) |
eric@webkit.org | 971c22f | 2008-06-07 10:33:31 +0000 | [diff] [blame] | 200 | m_valueList->next(); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 201 | } |
| 202 | break; |
| 203 | |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 204 | case CSSPropertyColor: // <color> | inherit |
| 205 | if ((id >= CSSValueAqua && id <= CSSValueWindowtext) || |
| 206 | (id >= CSSValueAliceblue && id <= CSSValueYellowgreen)) |
darin@apple.com | 894e813 | 2008-06-17 19:16:22 +0000 | [diff] [blame] | 207 | parsedValue = SVGColor::create(value->string); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 208 | else |
| 209 | parsedValue = parseSVGColor(); |
| 210 | |
eseidel | 13a6422 | 2006-05-16 05:33:34 +0000 | [diff] [blame] | 211 | if (parsedValue) |
eric@webkit.org | 971c22f | 2008-06-07 10:33:31 +0000 | [diff] [blame] | 212 | m_valueList->next(); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 213 | break; |
| 214 | |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 215 | case CSSPropertyStopColor: // TODO : icccolor |
| 216 | case CSSPropertyFloodColor: |
| 217 | case CSSPropertyLightingColor: |
| 218 | if ((id >= CSSValueAqua && id <= CSSValueWindowtext) || |
| 219 | (id >= CSSValueAliceblue && id <= CSSValueYellowgreen)) |
darin@apple.com | 894e813 | 2008-06-17 19:16:22 +0000 | [diff] [blame] | 220 | parsedValue = SVGColor::create(value->string); |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 221 | else if (id == CSSValueCurrentcolor) |
darin@apple.com | 894e813 | 2008-06-17 19:16:22 +0000 | [diff] [blame] | 222 | parsedValue = SVGColor::createCurrentColor(); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 223 | else // TODO : svgcolor (iccColor) |
| 224 | parsedValue = parseSVGColor(); |
| 225 | |
eseidel | 13a6422 | 2006-05-16 05:33:34 +0000 | [diff] [blame] | 226 | if (parsedValue) |
eric@webkit.org | 971c22f | 2008-06-07 10:33:31 +0000 | [diff] [blame] | 227 | m_valueList->next(); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 228 | |
| 229 | break; |
| 230 | |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 231 | case CSSPropertyWritingMode: |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 232 | // lr-tb | rl_tb | tb-rl | lr | rl | tb | inherit |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 233 | if (id >= CSSValueLrTb && id <= CSSValueTb) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 234 | valid_primitive = true; |
| 235 | break; |
| 236 | |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 237 | case CSSPropertyStrokeWidth: // <length> | inherit |
| 238 | case CSSPropertyStrokeDashoffset: |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 239 | valid_primitive = validUnit(value, FLength | FPercent, false); |
| 240 | break; |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 241 | case CSSPropertyStrokeDasharray: // none | <dasharray> | inherit |
| 242 | if (id == CSSValueNone) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 243 | valid_primitive = true; |
| 244 | else |
| 245 | parsedValue = parseSVGStrokeDasharray(); |
| 246 | |
| 247 | break; |
| 248 | |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 249 | case CSSPropertyKerning: // auto | normal | <length> | inherit |
| 250 | if (id == CSSValueAuto || id == CSSValueNormal) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 251 | valid_primitive = true; |
| 252 | else |
| 253 | valid_primitive = validUnit(value, FLength, false); |
| 254 | break; |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 255 | |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 256 | case CSSPropertyClipPath: // <uri> | none | inherit |
| 257 | case CSSPropertyFilter: |
| 258 | if (id == CSSValueNone) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 259 | valid_primitive = true; |
eseidel | 06ac276 | 2006-09-09 01:46:18 +0000 | [diff] [blame] | 260 | else if (value->unit == CSSPrimitiveValue::CSS_URI) { |
darin@apple.com | 894e813 | 2008-06-17 19:16:22 +0000 | [diff] [blame] | 261 | parsedValue = CSSPrimitiveValue::create(value->string, (CSSPrimitiveValue::UnitTypes) value->unit); |
eseidel | 13a6422 | 2006-05-16 05:33:34 +0000 | [diff] [blame] | 262 | if (parsedValue) |
eric@webkit.org | 971c22f | 2008-06-07 10:33:31 +0000 | [diff] [blame] | 263 | m_valueList->next(); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 264 | } |
| 265 | break; |
| 266 | |
eseidel | 9a857cb | 2006-04-23 22:57:22 +0000 | [diff] [blame] | 267 | /* shorthand properties */ |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 268 | case CSSPropertyMarker: |
eseidel | 9a857cb | 2006-04-23 22:57:22 +0000 | [diff] [blame] | 269 | { |
rwlbuis@webkit.org | 796715f | 2008-03-31 06:49:17 +0000 | [diff] [blame] | 270 | ShorthandScope scope(this, propId); |
| 271 | m_implicitShorthand = true; |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 272 | if (!parseValue(CSSPropertyMarkerStart, important)) |
rwlbuis | 798082e | 2006-12-30 21:54:06 +0000 | [diff] [blame] | 273 | return false; |
eric@webkit.org | 971c22f | 2008-06-07 10:33:31 +0000 | [diff] [blame] | 274 | if (m_valueList->current()) { |
rwlbuis@webkit.org | 796715f | 2008-03-31 06:49:17 +0000 | [diff] [blame] | 275 | rollbackLastProperties(1); |
| 276 | return false; |
| 277 | } |
eric@webkit.org | 9926167 | 2008-06-06 22:09:40 +0000 | [diff] [blame] | 278 | CSSValue* value = m_parsedProperties[m_numParsedProperties - 1]->value(); |
mitz@apple.com | 920b8e0 | 2008-03-19 21:51:30 +0000 | [diff] [blame] | 279 | addProperty(CSSPropertyMarkerMid, value, important); |
| 280 | addProperty(CSSPropertyMarkerEnd, value, important); |
rwlbuis | 798082e | 2006-12-30 21:54:06 +0000 | [diff] [blame] | 281 | m_implicitShorthand = false; |
| 282 | return true; |
eseidel | 9a857cb | 2006-04-23 22:57:22 +0000 | [diff] [blame] | 283 | } |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 284 | default: |
oliver | f786503 | 2007-10-12 15:32:39 +0000 | [diff] [blame] | 285 | // 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); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 288 | return false; |
| 289 | } |
| 290 | |
eseidel | 06ac276 | 2006-09-09 01:46:18 +0000 | [diff] [blame] | 291 | if (valid_primitive) { |
eseidel | 13a6422 | 2006-05-16 05:33:34 +0000 | [diff] [blame] | 292 | if (id != 0) |
darin@apple.com | 894e813 | 2008-06-17 19:16:22 +0000 | [diff] [blame] | 293 | parsedValue = CSSPrimitiveValue::createIdentifier(id); |
eseidel | 13a6422 | 2006-05-16 05:33:34 +0000 | [diff] [blame] | 294 | else if (value->unit == CSSPrimitiveValue::CSS_STRING) |
darin@apple.com | 894e813 | 2008-06-17 19:16:22 +0000 | [diff] [blame] | 295 | parsedValue = CSSPrimitiveValue::create(value->string, (CSSPrimitiveValue::UnitTypes) value->unit); |
eseidel | 13a6422 | 2006-05-16 05:33:34 +0000 | [diff] [blame] | 296 | else if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ) |
darin@apple.com | 894e813 | 2008-06-17 19:16:22 +0000 | [diff] [blame] | 297 | parsedValue = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit); |
hyatt@apple.com | 51e2fad | 2008-06-19 21:49:52 +0000 | [diff] [blame] | 298 | else if (value->unit >= CSSParserValue::Q_EMS) |
darin@apple.com | 894e813 | 2008-06-17 19:16:22 +0000 | [diff] [blame] | 299 | parsedValue = CSSQuirkPrimitiveValue::create(value->fValue, CSSPrimitiveValue::CSS_EMS); |
eric@webkit.org | 971c22f | 2008-06-07 10:33:31 +0000 | [diff] [blame] | 300 | m_valueList->next(); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 301 | } |
eric@webkit.org | 971c22f | 2008-06-07 10:33:31 +0000 | [diff] [blame] | 302 | if (!parsedValue || (m_valueList->current() && !inShorthand())) |
eric@webkit.org | e555a4a | 2008-02-01 08:00:08 +0000 | [diff] [blame] | 303 | return false; |
| 304 | |
| 305 | addProperty(propId, parsedValue.release(), important); |
| 306 | return true; |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 307 | } |
| 308 | |
eric@webkit.org | e555a4a | 2008-02-01 08:00:08 +0000 | [diff] [blame] | 309 | PassRefPtr<CSSValue> CSSParser::parseSVGStrokeDasharray() |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 310 | { |
darin@apple.com | 894e813 | 2008-06-17 19:16:22 +0000 | [diff] [blame] | 311 | RefPtr<CSSValueList> ret = CSSValueList::createCommaSeparated(); |
hyatt@apple.com | 51e2fad | 2008-06-19 21:49:52 +0000 | [diff] [blame] | 312 | CSSParserValue* value = m_valueList->current(); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 313 | bool valid_primitive = true; |
rwlbuis | 897f868 | 2007-05-11 09:27:12 +0000 | [diff] [blame] | 314 | while (value) { |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 315 | valid_primitive = validUnit(value, FLength | FPercent |FNonNeg, false); |
rwlbuis | 897f868 | 2007-05-11 09:27:12 +0000 | [diff] [blame] | 316 | if (!valid_primitive) |
| 317 | break; |
eseidel | 13a6422 | 2006-05-16 05:33:34 +0000 | [diff] [blame] | 318 | if (value->id != 0) |
darin@apple.com | 894e813 | 2008-06-17 19:16:22 +0000 | [diff] [blame] | 319 | ret->append(CSSPrimitiveValue::createIdentifier(value->id)); |
eseidel | 13a6422 | 2006-05-16 05:33:34 +0000 | [diff] [blame] | 320 | else if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ) |
darin@apple.com | 894e813 | 2008-06-17 19:16:22 +0000 | [diff] [blame] | 321 | ret->append(CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit)); |
eric@webkit.org | 971c22f | 2008-06-07 10:33:31 +0000 | [diff] [blame] | 322 | value = m_valueList->next(); |
hyatt@apple.com | 51e2fad | 2008-06-19 21:49:52 +0000 | [diff] [blame] | 323 | if (value && value->unit == CSSParserValue::Operator && value->iValue == ',') |
eric@webkit.org | 971c22f | 2008-06-07 10:33:31 +0000 | [diff] [blame] | 324 | value = m_valueList->next(); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 325 | } |
darin@apple.com | 894e813 | 2008-06-17 19:16:22 +0000 | [diff] [blame] | 326 | if (!valid_primitive) |
| 327 | return 0; |
| 328 | return ret.release(); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 329 | } |
| 330 | |
eric@webkit.org | e555a4a | 2008-02-01 08:00:08 +0000 | [diff] [blame] | 331 | PassRefPtr<CSSValue> CSSParser::parseSVGPaint() |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 332 | { |
rwlbuis | 274d628 | 2006-12-29 22:14:41 +0000 | [diff] [blame] | 333 | RGBA32 c = Color::transparent; |
eric@webkit.org | 971c22f | 2008-06-07 10:33:31 +0000 | [diff] [blame] | 334 | if (!parseColorFromValue(m_valueList->current(), c, true)) |
darin@apple.com | 894e813 | 2008-06-17 19:16:22 +0000 | [diff] [blame] | 335 | return SVGPaint::create(); |
| 336 | return SVGPaint::create(Color(c)); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 337 | } |
| 338 | |
eric@webkit.org | e555a4a | 2008-02-01 08:00:08 +0000 | [diff] [blame] | 339 | PassRefPtr<CSSValue> CSSParser::parseSVGColor() |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 340 | { |
rwlbuis | 274d628 | 2006-12-29 22:14:41 +0000 | [diff] [blame] | 341 | RGBA32 c = Color::transparent; |
eric@webkit.org | 971c22f | 2008-06-07 10:33:31 +0000 | [diff] [blame] | 342 | if (!parseColorFromValue(m_valueList->current(), c, true)) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 343 | return 0; |
darin@apple.com | 894e813 | 2008-06-17 19:16:22 +0000 | [diff] [blame] | 344 | return SVGColor::create(Color(c)); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | } |
| 348 | |
mjs | d2948ef | 2007-02-26 19:29:04 +0000 | [diff] [blame] | 349 | #endif // ENABLE(SVG) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 350 | |
| 351 | // vim:ts=4:noet |