Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(393)

Unified Diff: third_party/WebKit/Source/core/html/HTMLElement.cpp

Issue 1921823006: Fix parsing of <body link vlink alink> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLElement.cpp b/third_party/WebKit/Source/core/html/HTMLElement.cpp
index 6c0a92df0a19f5eb2ce43ca4718d0dd0755d202e..4e1860dc70c6098ff08b564ba690d58a5d021d3b 100644
--- a/third_party/WebKit/Source/core/html/HTMLElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLElement.cpp
@@ -915,32 +915,41 @@ static RGBA32 parseColorStringWithCrazyLegacyRules(const String& colorString)
}
// Color parsing that matches HTML's "rules for parsing a legacy color value"
-void HTMLElement::addHTMLColorToStyle(MutableStylePropertySet* style, CSSPropertyID propertyID, const String& attributeValue)
+bool HTMLElement::parseColorWithLegacyRules(const String& attributeValue, Color& parsedColor)
{
// An empty string doesn't apply a color. (One containing only whitespace does, which is why this check occurs before stripping.)
if (attributeValue.isEmpty())
- return;
+ return false;
String colorString = attributeValue.stripWhiteSpace();
// "transparent" doesn't apply a color either.
if (equalIgnoringCase(colorString, "transparent"))
- return;
-
- Color color;
+ return false;
// If the string is a 3/6-digit hex color or a named CSS color, use that. Apply legacy rules otherwise. Note color.setFromString()
// accepts 4/8-digit hex color, so restrict its use with length checks here to support legacy HTML attributes.
bool success = false;
if ((colorString.length() == 4 || colorString.length() == 7) && colorString[0] == '#')
- success = color.setFromString(colorString);
- if (!success)
- success = color.setNamedColor(colorString);
+ success = parsedColor.setFromString(colorString);
if (!success)
- color.setRGB(parseColorStringWithCrazyLegacyRules(colorString));
+ success = parsedColor.setNamedColor(colorString);
+ if (!success) {
+ parsedColor.setRGB(parseColorStringWithCrazyLegacyRules(colorString));
+ success = true;
+ }
+
+ return success;
+}
+
+void HTMLElement::addHTMLColorToStyle(MutableStylePropertySet* style, CSSPropertyID propertyID, const String& attributeValue)
+{
+ Color parsedColor;
+ if (!parseColorWithLegacyRules(attributeValue, parsedColor))
+ return;
- style->setProperty(propertyID, cssValuePool().createColorValue(color.rgb()));
+ style->setProperty(propertyID, cssValuePool().createColorValue(parsedColor.rgb()));
}
bool HTMLElement::isInteractiveContent() const
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698