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

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: greedy color repeat serializer + more tests 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..691df9be72aab2bc2c33ad313aec46024759a00c 100644
--- a/third_party/WebKit/Source/core/css/CSSGradientValue.cpp
+++ b/third_party/WebKit/Source/core/css/CSSGradientValue.cpp
@@ -1074,19 +1074,31 @@ DEFINE_TRACE_AFTER_DISPATCH(CSSLinearGradientValue) {
void CSSGradientValue::appendCSSTextForColorStops(
StringBuilder& result,
bool requiresSeparator) const {
+ const CSSValue* prevColor = nullptr;
+
for (const auto& stop : m_stops) {
+ bool isColorRepeat = false;
+ if (RuntimeEnabledFeatures::multipleColorStopPositionsEnabled()) {
+ isColorRepeat = stop.m_color && stop.m_offset &&
+ dataEquivalent(stop.m_color.get(), prevColor);
+ }
+
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(' ');
if (stop.m_offset)
result.append(stop.m_offset->cssText());
+
+ // Reset prevColor if we've emitted a color repeat.
+ prevColor = isColorRepeat ? nullptr : stop.m_color.get();
}
}

Powered by Google App Engine
This is Rietveld 408576698