| OLD | NEW |
| 1 /* | 1 /* |
| 2 Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 2 Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
| 3 Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> | 3 Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> |
| 4 2004, 2005, 2007, 2010 Rob Buis <buis@kde.org> | 4 2004, 2005, 2007, 2010 Rob Buis <buis@kde.org> |
| 5 Copyright (C) 2005, 2006 Apple Computer, Inc. | 5 Copyright (C) 2005, 2006 Apple Computer, Inc. |
| 6 | 6 |
| 7 This library is free software; you can redistribute it and/or | 7 This library is free software; you can redistribute it and/or |
| 8 modify it under the terms of the GNU Library General Public | 8 modify it under the terms of the GNU Library General Public |
| 9 License as published by the Free Software Foundation; either | 9 License as published by the Free Software Foundation; either |
| 10 version 2 of the License, or (at your option) any later version. | 10 version 2 of the License, or (at your option) any later version. |
| 11 | 11 |
| 12 This library is distributed in the hope that it will be useful, | 12 This library is distributed in the hope that it will be useful, |
| 13 but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 Library General Public License for more details. | 15 Library General Public License for more details. |
| 16 | 16 |
| 17 You should have received a copy of the GNU Library General Public License | 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 | 18 along with this library; see the file COPYING.LIB. If not, write to |
| 19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 Boston, MA 02110-1301, USA. | 20 Boston, MA 02110-1301, USA. |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 #include "config.h" | 23 #include "config.h" |
| 24 | 24 |
| 25 #include "CSSPropertyNames.h" | 25 #include "CSSPropertyNames.h" |
| 26 #include "CSSValueKeywords.h" | 26 #include "CSSValueKeywords.h" |
| 27 #include "RuntimeEnabledFeatures.h" |
| 27 #include "core/css/CSSParser.h" | 28 #include "core/css/CSSParser.h" |
| 28 #include "core/css/CSSValueList.h" | 29 #include "core/css/CSSValueList.h" |
| 29 #include "core/rendering/RenderTheme.h" | 30 #include "core/rendering/RenderTheme.h" |
| 30 #include "core/svg/SVGPaint.h" | 31 #include "core/svg/SVGPaint.h" |
| 31 | 32 |
| 32 using namespace std; | 33 using namespace std; |
| 33 | 34 |
| 34 namespace WebCore { | 35 namespace WebCore { |
| 35 | 36 |
| 36 static bool isSystemColor(int id) | 37 static bool isSystemColor(int id) |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 else if (id == CSSValueCurrentcolor) | 219 else if (id == CSSValueCurrentcolor) |
| 219 parsedValue = SVGColor::createCurrentColor(); | 220 parsedValue = SVGColor::createCurrentColor(); |
| 220 else // TODO : svgcolor (iccColor) | 221 else // TODO : svgcolor (iccColor) |
| 221 parsedValue = parseSVGColor(); | 222 parsedValue = parseSVGColor(); |
| 222 | 223 |
| 223 if (parsedValue) | 224 if (parsedValue) |
| 224 m_valueList->next(); | 225 m_valueList->next(); |
| 225 | 226 |
| 226 break; | 227 break; |
| 227 | 228 |
| 229 case CSSPropertyPaintOrder: |
| 230 if (!RuntimeEnabledFeatures::svgPaintOrderEnabled()) |
| 231 return false; |
| 232 |
| 233 if (m_valueList->size() == 1 && id == CSSValueNormal) |
| 234 valid_primitive = true; |
| 235 else if ((parsedValue = parsePaintOrder())) |
| 236 m_valueList->next(); |
| 237 break; |
| 238 |
| 228 case CSSPropertyVectorEffect: // none | non-scaling-stroke | inherit | 239 case CSSPropertyVectorEffect: // none | non-scaling-stroke | inherit |
| 229 if (id == CSSValueNone || id == CSSValueNonScalingStroke) | 240 if (id == CSSValueNone || id == CSSValueNonScalingStroke) |
| 230 valid_primitive = true; | 241 valid_primitive = true; |
| 231 break; | 242 break; |
| 232 | 243 |
| 233 case CSSPropertyWritingMode: | 244 case CSSPropertyWritingMode: |
| 234 // lr-tb | rl_tb | tb-rl | lr | rl | tb | inherit | 245 // lr-tb | rl_tb | tb-rl | lr | rl | tb | inherit |
| 235 if (id == CSSValueLrTb || id == CSSValueRlTb || id == CSSValueTbRl || id
== CSSValueLr || id == CSSValueRl || id == CSSValueTb) | 246 if (id == CSSValueLrTb || id == CSSValueRlTb || id == CSSValueTbRl || id
== CSSValueLr || id == CSSValueRl || id == CSSValueTb) |
| 236 valid_primitive = true; | 247 valid_primitive = true; |
| 237 break; | 248 break; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 } | 372 } |
| 362 | 373 |
| 363 PassRefPtr<CSSValue> CSSParser::parseSVGColor() | 374 PassRefPtr<CSSValue> CSSParser::parseSVGColor() |
| 364 { | 375 { |
| 365 RGBA32 c = Color::transparent; | 376 RGBA32 c = Color::transparent; |
| 366 if (!parseColorFromValue(m_valueList->current(), c)) | 377 if (!parseColorFromValue(m_valueList->current(), c)) |
| 367 return 0; | 378 return 0; |
| 368 return SVGColor::createFromColor(Color(c)); | 379 return SVGColor::createFromColor(Color(c)); |
| 369 } | 380 } |
| 370 | 381 |
| 382 // normal | [ fill || stroke || markers ] |
| 383 PassRefPtr<CSSValue> CSSParser::parsePaintOrder() const |
| 384 { |
| 385 if (m_valueList->size() > 3) |
| 386 return 0; |
| 387 |
| 388 CSSParserValue* value = m_valueList->current(); |
| 389 if (!value) |
| 390 return 0; |
| 391 |
| 392 RefPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSeparated(); |
| 393 |
| 394 // The default paint-order is: Fill, Stroke, Markers. |
| 395 bool seenFill = false, |
| 396 seenStroke = false, |
| 397 seenMarkers = false; |
| 398 |
| 399 do { |
| 400 switch (value->id) { |
| 401 case CSSValueNormal: |
| 402 // normal inside [fill || stroke || markers] not valid |
| 403 return 0; |
| 404 case CSSValueFill: |
| 405 if (seenFill) |
| 406 return 0; |
| 407 |
| 408 seenFill = true; |
| 409 break; |
| 410 case CSSValueStroke: |
| 411 if (seenStroke) |
| 412 return 0; |
| 413 |
| 414 seenStroke = true; |
| 415 break; |
| 416 case CSSValueMarkers: |
| 417 if (seenMarkers) |
| 418 return 0; |
| 419 |
| 420 seenMarkers = true; |
| 421 break; |
| 422 default: |
| 423 return 0; |
| 424 } |
| 425 |
| 426 parsedValues->append(CSSPrimitiveValue::createIdentifier(value->id)); |
| 427 } while (value = m_valueList->next()); |
| 428 |
| 429 // fill out the rest of the paint order |
| 430 if (!seenFill) |
| 431 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill)); |
| 432 if (!seenStroke) |
| 433 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke)
); |
| 434 if (!seenMarkers) |
| 435 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers
)); |
| 436 |
| 437 return parsedValues.release(); |
| 371 } | 438 } |
| 439 |
| 440 } |
| OLD | NEW |