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

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: offset1->offsetLeft 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
« no previous file with comments | « Source/core/css/CSSGradientValue.cpp ('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 383e074066b902632b8d98853423afb22044dd0b..8cd7f031515338b31464bd98c202949c562a8bca 100644
--- a/Source/core/css/parser/CSSPropertyParser.cpp
+++ b/Source/core/css/parser/CSSPropertyParser.cpp
@@ -6824,6 +6824,12 @@ bool CSSPropertyParser::parseGradientColorStops(CSSParserValueList* valueList, C
CSSParserValue* a = valueList->current();
// Now look for color stops.
+ // <color-stop-list> = [ <color-stop> , <color-hint>? ]# , <color-stop>
+ bool supportsColorHints = 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) {
@@ -6836,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 hints in a row are not allowed.
+ if (!stop.m_color && (!supportsColorHints || 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);
@@ -6849,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;
}
« no previous file with comments | « Source/core/css/CSSGradientValue.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698