Chromium Code Reviews| 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::svg2Enabled()) | |
| 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 int defaultPaintOrder[] = { CSSValueFill, CSSValueStroke, CSSValueMarkers }; | |
| 395 bool seen[] = { false, false, false }; | |
|
pdr.
2013/06/25 15:30:45
Style nit (fix at your discretion)
I think this f
| |
| 396 bool valid = true; | |
| 397 | |
| 398 do { | |
| 399 switch (value->id) { | |
| 400 case CSSValueNormal: | |
| 401 // normal inside [fill || stroke || markers] not valid | |
| 402 return 0; | |
| 403 case CSSValueFill: | |
| 404 if (seen[0]) | |
| 405 return 0; | |
| 406 | |
| 407 seen[0] = true; | |
| 408 break; | |
| 409 case CSSValueStroke: | |
| 410 if (seen[1]) | |
| 411 return 0; | |
| 412 | |
| 413 seen[1] = true; | |
| 414 break; | |
| 415 case CSSValueMarkers: | |
| 416 if (seen[2]) | |
| 417 return 0; | |
| 418 | |
| 419 seen[2] = true; | |
| 420 break; | |
| 421 } | |
| 422 | |
| 423 parsedValues->append(CSSPrimitiveValue::createIdentifier(value->id)); | |
| 424 } while (value = m_valueList->next()); | |
| 425 | |
| 426 // fill out the rest of the paint order | |
| 427 for (int i = 0; i < 3; i++) | |
|
pdr.
2013/06/25 15:30:45
Nit: if you choose to keep this, because the body
| |
| 428 if (!seen[i]) | |
| 429 parsedValues->append(CSSPrimitiveValue::createIdentifier(defaultPain tOrder[i])); | |
| 430 | |
| 431 return parsedValues; | |
| 371 } | 432 } |
| 433 | |
| 434 } | |
| OLD | NEW |