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

Unified Diff: third_party/WebKit/Source/core/css/CSSGradientValue.cpp

Issue 2799793002: Implement color stop position syntax from CSS Image Values 4 (Closed)
Patch Set: hide behind RTEF Created 3 years, 8 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/css/CSSGradientValue.cpp
diff --git a/third_party/WebKit/Source/core/css/CSSGradientValue.cpp b/third_party/WebKit/Source/core/css/CSSGradientValue.cpp
index 0bed19512a45267777c92044beaa6f14bdc2a1f7..5cdcaf44038153fc163556d387273a218b2686f6 100644
--- a/third_party/WebKit/Source/core/css/CSSGradientValue.cpp
+++ b/third_party/WebKit/Source/core/css/CSSGradientValue.cpp
@@ -1074,14 +1074,21 @@ DEFINE_TRACE_AFTER_DISPATCH(CSSLinearGradientValue) {
void CSSGradientValue::appendCSSTextForColorStops(
StringBuilder& result,
bool requiresSeparator) const {
- for (const auto& stop : m_stops) {
+ for (size_t i = 0; i < m_stops.size(); ++i) {
+ const auto& stop = m_stops[i];
+ const bool isColorRepeat =
+ (i > 0) && !stop.isHint() && stop.m_color == m_stops[i - 1].m_color;
+ // At most two consecutive stops can share the same CSS value for color.
fs 2017/04/06 19:58:48 Could we add a test for this as well - both the "c
f(malita) 2017/04/06 20:29:42 Actually, the current impl bends over backwards to
fs 2017/04/06 20:44:36 Oh, yeah, right, the stop.color == stops[i - 1].co
+ DCHECK(!isColorRepeat || i < 2 || stop.m_color != m_stops[i - 2].m_color);
+
if (requiresSeparator) {
- result.append(", ");
+ if (!isColorRepeat)
+ result.append(", ");
} else {
requiresSeparator = true;
}
- if (stop.m_color)
+ if (stop.m_color && !isColorRepeat)
result.append(stop.m_color->cssText());
if (stop.m_color && stop.m_offset)
result.append(' ');

Powered by Google App Engine
This is Rietveld 408576698