Source/WebCore/ChangeLog

 12011-12-02 Andreas Kling <kling@webkit.org>
 2
 3 StyledElement: Simplify addCSSColor().
 4 <http://webkit.org/b/73703>
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 The Color(const String&) constructor handles both named and 3/6-digit
 9 hex colors, so there's no need to handle those separately here.
 10 Also tweaked some comments and minor things.
 11
 12 * dom/StyledElement.cpp:
 13 (WebCore::StyledElement::addCSSColor):
 14
1152011-12-02 Sheriff Bot <webkit.review.bot@gmail.com>
216
317 Unreviewed, rolling out r101805.

Source/WebCore/dom/StyledElement.cpp

@@static String parseColorStringWithCrazyLegacyRules(const String& colorString)
371371// Color parsing that matches HTML's "rules for parsing a legacy color value"
372372void StyledElement::addCSSColor(Attribute* attribute, int id, const String& attributeValue)
373373{
374  // The empty string doesn't apply a color. (Just whitespace does, which is why this check occurs before trimming.)
375  if (!attributeValue.length())
 374 // An empty string doesn't apply a color. (Only whitespace does, which is why this check occurs before trimming.)
 375 if (attributeValue.isEmpty())
376376 return;
377377
378  String color = attributeValue.stripWhiteSpace();
 378 String colorString = attributeValue.stripWhiteSpace();
379379
380380 // "transparent" doesn't apply a color either.
381  if (equalIgnoringCase(color, "transparent"))
 381 if (equalIgnoringCase(colorString, "transparent"))
382382 return;
383383
384384 if (!attribute->decl())
385385 createMappedDecl(attribute);
386386
387  // If the string is a named CSS color, use that color.
388  Color foundColor;
389  foundColor.setNamedColor(color);
390  if (foundColor.isValid()) {
391  attribute->decl()->setProperty(id, color, false);
 387 // If the string is a named CSS color or a 3/6-digit hex color, use that.
 388 Color color(colorString);
 389 if (color.isValid()) {
 390 attribute->decl()->setProperty(id, colorString, false);
392391 return;
393392 }
394393
395  // If the string is a 3 or 6-digit hex color, use that color.
396  if (color[0] == '#' && (color.length() == 4 || color.length() == 7) && attribute->decl()->setProperty(id, color, false))
397  return;
398 
399  attribute->decl()->setProperty(id, parseColorStringWithCrazyLegacyRules(color), false);
 394 attribute->decl()->setProperty(id, parseColorStringWithCrazyLegacyRules(colorString), false);
400395}
401396
402397void StyledElement::createMappedDecl(Attribute* attr)