Changeset 55308 in webkit
- Timestamp:
- Feb 26, 2010 1:43:44 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r55306 r55308 1 2010-02-24 Stephen White <senorblanco@chromium.org> 2 3 Reviewed by Darin Adler. 4 5 This CL implements a simple ad-hoc parser for CSS rgb() values. 6 If it fails, it returns false and the normal lex/yacc parser will 7 be invoked. 8 9 https://bugs.webkit.org/show_bug.cgi?id=35362 10 11 Covered by fast/canvas/canvas-bg.html, fast/canvas/canvas-bg-zoom.html, 12 and many more. 13 14 * css/CSSParser.cpp: 15 (WebCore::parseInt): 16 (WebCore::CSSParser::parseColor): 17 1 18 2010-02-26 Jarkko Sakkinen <jarkko.sakkinen@tieto.com> 2 19 -
trunk/WebCore/css/CSSParser.cpp
r55066 r55308 3492 3492 } 3493 3493 3494 static inline bool isCSSWhitespace(UChar c) 3495 { 3496 return c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\f'; 3497 } 3498 3499 static inline bool parseInt(const UChar*& string, const UChar* end, UChar terminator, int& value) 3500 { 3501 const UChar* current = string; 3502 int localValue = 0; 3503 while (current != end && isCSSWhitespace(*current)) 3504 current++; 3505 if (current == end || !isASCIIDigit(*current)) 3506 return false; 3507 while (current != end && isASCIIDigit(*current)) 3508 localValue = localValue * 10 + *current++ - '0'; 3509 while (current != end && isCSSWhitespace(*current)) 3510 current++; 3511 if (current == end || *current++ != terminator) 3512 return false; 3513 value = localValue; 3514 string = current; 3515 return true; 3516 } 3517 3494 3518 bool CSSParser::parseColor(const String &name, RGBA32& rgb, bool strict) 3495 3519 { … … 3504 3528 return true; 3505 3529 } 3506 3530 if (name.startsWith("rgb(")) { 3531 const UChar* current = name.characters() + 4; 3532 const UChar* end = name.characters() + name.length(); 3533 int red; 3534 int green; 3535 int blue; 3536 if (!parseInt(current, end, ',', red)) 3537 return false; 3538 if (!parseInt(current, end, ',', green)) 3539 return false; 3540 if (!parseInt(current, end, ')', blue)) 3541 return false; 3542 if (current != end) 3543 return false; 3544 rgb = makeRGB(red, green, blue); 3545 return true; 3546 } 3507 3547 return false; 3508 3548 } … … 4703 4743 } 4704 4744 4705 static inline bool isCSSWhitespace(UChar c)4706 {4707 return c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\f';4708 }4709 4710 4745 void CSSParser::recheckAtKeyword(const UChar* str, int len) 4711 4746 {
Note: See TracChangeset
for help on using the changeset viewer.