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

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
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 fd68fa31ba72fa0ed183a71a9b33b27b5f67b11e..df381a0effb796c49a57a2a5c10f331036b934c2 100644
--- a/third_party/WebKit/Source/core/html/HTMLElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLElement.cpp
@@ -915,23 +915,31 @@ 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;
+ return false;
// If the string is a named CSS color or a 3/6-digit hex color, use that.
- Color parsedColor;
if (!parsedColor.setFromString(colorString))
parsedColor.setRGB(parseColorStringWithCrazyLegacyRules(colorString));
+ return true;
+}
+
+void HTMLElement::addHTMLColorToStyle(MutableStylePropertySet* style, CSSPropertyID propertyID, const String& attributeValue)
+{
+ Color parsedColor;
+ if (!parseColorWithLegacyRules(attributeValue, parsedColor))
+ return;
+
style->setProperty(propertyID, cssValuePool().createColorValue(parsedColor.rgb()));
}

Powered by Google App Engine
This is Rietveld 408576698