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

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

Issue 805823002: Remove code duplication from the customCSSText() methods of gradient classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rename the new method Created 6 years 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.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/CSSGradientValue.cpp
diff --git a/Source/core/css/CSSGradientValue.cpp b/Source/core/css/CSSGradientValue.cpp
index 1b048ece7a40da7a84ca5a1f9ac8af8b4cc35168..044b9b3ad5acd91d7298570f20e256333cd768cd 100644
--- a/Source/core/css/CSSGradientValue.cpp
+++ b/Source/core/css/CSSGradientValue.cpp
@@ -578,26 +578,7 @@ String CSSLinearGradientValue::customCSSText() const
result.append(m_secondX->cssText());
result.append(' ');
result.append(m_secondY->cssText());
-
- for (unsigned i = 0; i < m_stops.size(); i++) {
- const CSSGradientColorStop& stop = m_stops[i];
- result.appendLiteral(", ");
- if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 0) {
- result.appendLiteral("from(");
- result.append(stop.m_color->cssText());
- result.append(')');
- } else if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 1) {
- result.appendLiteral("to(");
- result.append(stop.m_color->cssText());
- result.append(')');
- } else {
- result.appendLiteral("color-stop(");
- result.appendNumber(stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER));
- result.appendLiteral(", ");
- result.append(stop.m_color->cssText());
- result.append(')');
- }
- }
+ appendCSSTextForDeprecatedColorStops(result);
} else if (m_gradientType == CSSPrefixedLinearGradient) {
if (m_repeating)
result.appendLiteral("-webkit-repeating-linear-gradient(");
@@ -846,6 +827,29 @@ void CSSLinearGradientValue::traceAfterDispatch(Visitor* visitor)
CSSGradientValue::traceAfterDispatch(visitor);
}
+inline void CSSGradientValue::appendCSSTextForDeprecatedColorStops(StringBuilder& result) const
+{
+ for (unsigned i = 0; i < m_stops.size(); i++) {
+ const CSSGradientColorStop& stop = m_stops[i];
+ result.appendLiteral(", ");
+ if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 0) {
+ result.appendLiteral("from(");
+ result.append(stop.m_color->cssText());
+ result.append(')');
+ } else if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 1) {
+ result.appendLiteral("to(");
+ result.append(stop.m_color->cssText());
+ result.append(')');
+ } else {
+ result.appendLiteral("color-stop(");
+ result.appendNumber(stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER));
+ result.appendLiteral(", ");
+ result.append(stop.m_color->cssText());
+ result.append(')');
+ }
+ }
+}
+
String CSSRadialGradientValue::customCSSText() const
{
StringBuilder result;
@@ -863,27 +867,7 @@ String CSSRadialGradientValue::customCSSText() const
result.append(m_secondY->cssText());
result.appendLiteral(", ");
result.append(m_secondRadius->cssText());
-
- // FIXME: share?
- for (unsigned i = 0; i < m_stops.size(); i++) {
- const CSSGradientColorStop& stop = m_stops[i];
- result.appendLiteral(", ");
- if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 0) {
- result.appendLiteral("from(");
- result.append(stop.m_color->cssText());
- result.append(')');
- } else if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 1) {
- result.appendLiteral("to(");
- result.append(stop.m_color->cssText());
- result.append(')');
- } else {
- result.appendLiteral("color-stop(");
- result.appendNumber(stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER));
- result.appendLiteral(", ");
- result.append(stop.m_color->cssText());
- result.append(')');
- }
- }
+ appendCSSTextForDeprecatedColorStops(result);
} else if (m_gradientType == CSSPrefixedRadialGradient) {
if (m_repeating)
result.appendLiteral("-webkit-repeating-radial-gradient(");
« no previous file with comments | « Source/core/css/CSSGradientValue.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698