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

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

Issue 631753002: Adding support for color interpolation hints to CSS gradients. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: NeedsRebaseline Created 6 years, 2 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: Source/core/css/parser/CSSPropertyParser.cpp
diff --git a/Source/core/css/parser/CSSPropertyParser.cpp b/Source/core/css/parser/CSSPropertyParser.cpp
index 99840173992ec605b59de9bde4dc1a70b1854375..9837f52fd0cee293a11874ee096806881f1f8768 100644
--- a/Source/core/css/parser/CSSPropertyParser.cpp
+++ b/Source/core/css/parser/CSSPropertyParser.cpp
@@ -6823,6 +6823,13 @@ bool CSSPropertyParser::parseGradientColorStops(CSSParserValueList* valueList, C
CSSParserValue* a = valueList->current();
// Now look for color stops.
+ // <color-stop-list> = [ <color-stop> , <color-hint>? ]# , <color-stop>
+ const bool kSupportColorHints =
f(malita) 2014/10/08 16:13:54 bool supportsColorHints = ... (not a static const
rosca 2014/10/08 17:18:52 Done.
+ gradient->gradientType() == CSSLinearGradient
+ || gradient->gradientType() == CSSRadialGradient;
+
+ // The first color stop cannot be a color hint.
+ bool previousStopWasColorHint = true;
while (a) {
// Look for the comma before the next stop.
if (expectComma) {
@@ -6835,12 +6842,18 @@ bool CSSPropertyParser::parseGradientColorStops(CSSParserValueList* valueList, C
}
// <color-stop> = <color> [ <percentage> | <length> ]?
+ // <color-hint> = <length> | <percentage>
CSSGradientColorStop stop;
stop.m_color = parseGradientColorOrKeyword(this, a);
- if (!stop.m_color)
+
+ // Two midpoints in a row is not allowed.
f(malita) 2014/10/08 16:13:54 // Two hints in a row are not allowed.
rosca 2014/10/08 17:18:52 Done.
+ if (!stop.m_color && (!kSupportColorHints || previousStopWasColorHint))
return false;
+ previousStopWasColorHint = !stop.m_color;
+
+ if (stop.m_color)
+ a = valueList->next();
- a = valueList->next();
if (a) {
if (validUnit(a, FLength | FPercent)) {
stop.m_position = createPrimitiveNumericValue(a);
@@ -6848,10 +6861,17 @@ bool CSSPropertyParser::parseGradientColorStops(CSSParserValueList* valueList, C
}
}
+ if (!stop.m_color && !stop.m_position)
+ return false;
+
gradient->addStop(stop);
expectComma = true;
}
+ // The last color stop cannot be a color hint.
+ if (previousStopWasColorHint)
+ return false;
+
// Must have 2 or more stops to be valid.
return gradient->stopCount() >= 2;
}
« Source/core/css/CSSGradientValue.cpp ('K') | « Source/core/css/CSSGradientValue.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698