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

Unified Diff: Source/core/css/parser/CSSPropertyParser.cpp

Issue 373603004: Hashless hex color quirk for color/background/border only. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 6 years, 4 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 | « Source/core/css/parser/CSSPropertyParser.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/parser/CSSPropertyParser.cpp
diff --git a/Source/core/css/parser/CSSPropertyParser.cpp b/Source/core/css/parser/CSSPropertyParser.cpp
index 881b7c7ba71ec43c970bc0930f67130237822b91..3a04afe066ca87930e3945a4a3bb6d7993069fd3 100644
--- a/Source/core/css/parser/CSSPropertyParser.cpp
+++ b/Source/core/css/parser/CSSPropertyParser.cpp
@@ -611,7 +611,30 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
if ((id >= CSSValueAqua && id <= CSSValueWebkitText) || id == CSSValueMenu) {
validPrimitive = isValueAllowedInMode(id, m_context.mode());
} else {
- parsedValue = parseColor();
+ if (!inQuirksMode()) {
+ parsedValue = parseColor();
+ if (parsedValue)
+ m_valueList->next();
+ break;
+ }
+
+ bool acceptQuirkyColors = false;
+ switch (propId) {
+ case CSSPropertyBackgroundColor:
+ if (!inShorthand())
+ acceptQuirkyColors = true;
+ break;
+ case CSSPropertyBorderBottomColor:
+ case CSSPropertyBorderLeftColor:
+ case CSSPropertyBorderRightColor:
+ case CSSPropertyBorderTopColor:
+ case CSSPropertyColor:
+ acceptQuirkyColors = true;
+ break;
+ default:
+ break;
+ }
+ parsedValue = parseColor(0, acceptQuirkyColors);
if (parsedValue)
m_valueList->next();
}
@@ -5435,26 +5458,26 @@ bool CSSPropertyParser::parseHSLParameters(CSSParserValue* value, double* colorA
return true;
}
-PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseColor(CSSParserValue* value)
+PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseColor(CSSParserValue* value, bool acceptQuirkyColors)
{
RGBA32 c = Color::transparent;
- if (!parseColorFromValue(value ? value : m_valueList->current(), c))
+ if (!parseColorFromValue(value ? value : m_valueList->current(), c, acceptQuirkyColors))
return nullptr;
return cssValuePool().createColorValue(c);
}
-bool CSSPropertyParser::parseColorFromValue(CSSParserValue* value, RGBA32& c)
+bool CSSPropertyParser::parseColorFromValue(CSSParserValue* value, RGBA32& c, bool acceptQuirkyColors)
{
- if (inQuirksMode() && value->unit == CSSPrimitiveValue::CSS_NUMBER
+ if (acceptQuirkyColors && value->unit == CSSPrimitiveValue::CSS_NUMBER
&& value->fValue >= 0. && value->fValue < 1000000.) {
String str = String::format("%06d", static_cast<int>((value->fValue+.5)));
// FIXME: This should be strict parsing for SVG as well.
- if (!fastParseColor(c, str, !inQuirksMode()))
+ if (!fastParseColor(c, str, !acceptQuirkyColors))
return false;
- } else if (value->unit == CSSPrimitiveValue::CSS_PARSER_HEXCOLOR ||
- value->unit == CSSPrimitiveValue::CSS_IDENT ||
- (inQuirksMode() && value->unit == CSSPrimitiveValue::CSS_DIMENSION)) {
- if (!fastParseColor(c, value->string, !inQuirksMode() && value->unit == CSSPrimitiveValue::CSS_IDENT))
+ } else if (value->unit == CSSPrimitiveValue::CSS_PARSER_HEXCOLOR
+ || value->unit == CSSPrimitiveValue::CSS_IDENT
+ || (acceptQuirkyColors && value->unit == CSSPrimitiveValue::CSS_DIMENSION)) {
+ if (!fastParseColor(c, value->string, !acceptQuirkyColors && value->unit == CSSPrimitiveValue::CSS_IDENT))
return false;
} else if (value->unit == CSSParserValue::Function &&
value->function->args != 0 &&
« no previous file with comments | « Source/core/css/parser/CSSPropertyParser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698