OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2015 Google Inc. All rights reserved. | 3 * Copyright (C) 2015 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1067 } | 1067 } |
1068 | 1068 |
1069 DEFINE_TRACE_AFTER_DISPATCH(CSSLinearGradientValue) { | 1069 DEFINE_TRACE_AFTER_DISPATCH(CSSLinearGradientValue) { |
1070 visitor->trace(m_angle); | 1070 visitor->trace(m_angle); |
1071 CSSGradientValue::traceAfterDispatch(visitor); | 1071 CSSGradientValue::traceAfterDispatch(visitor); |
1072 } | 1072 } |
1073 | 1073 |
1074 void CSSGradientValue::appendCSSTextForColorStops( | 1074 void CSSGradientValue::appendCSSTextForColorStops( |
1075 StringBuilder& result, | 1075 StringBuilder& result, |
1076 bool requiresSeparator) const { | 1076 bool requiresSeparator) const { |
| 1077 const CSSValue* prevColor = nullptr; |
| 1078 |
1077 for (const auto& stop : m_stops) { | 1079 for (const auto& stop : m_stops) { |
| 1080 bool isColorRepeat = false; |
| 1081 if (RuntimeEnabledFeatures::multipleColorStopPositionsEnabled()) { |
| 1082 isColorRepeat = stop.m_color && stop.m_offset && |
| 1083 dataEquivalent(stop.m_color.get(), prevColor); |
| 1084 } |
| 1085 |
1078 if (requiresSeparator) { | 1086 if (requiresSeparator) { |
1079 result.append(", "); | 1087 if (!isColorRepeat) |
| 1088 result.append(", "); |
1080 } else { | 1089 } else { |
1081 requiresSeparator = true; | 1090 requiresSeparator = true; |
1082 } | 1091 } |
1083 | 1092 |
1084 if (stop.m_color) | 1093 if (stop.m_color && !isColorRepeat) |
1085 result.append(stop.m_color->cssText()); | 1094 result.append(stop.m_color->cssText()); |
1086 if (stop.m_color && stop.m_offset) | 1095 if (stop.m_color && stop.m_offset) |
1087 result.append(' '); | 1096 result.append(' '); |
1088 if (stop.m_offset) | 1097 if (stop.m_offset) |
1089 result.append(stop.m_offset->cssText()); | 1098 result.append(stop.m_offset->cssText()); |
| 1099 |
| 1100 // Reset prevColor if we've emitted a color repeat. |
| 1101 prevColor = isColorRepeat ? nullptr : stop.m_color.get(); |
1090 } | 1102 } |
1091 } | 1103 } |
1092 | 1104 |
1093 void CSSGradientValue::appendCSSTextForDeprecatedColorStops( | 1105 void CSSGradientValue::appendCSSTextForDeprecatedColorStops( |
1094 StringBuilder& result) const { | 1106 StringBuilder& result) const { |
1095 for (unsigned i = 0; i < m_stops.size(); i++) { | 1107 for (unsigned i = 0; i < m_stops.size(); i++) { |
1096 const CSSGradientColorStop& stop = m_stops[i]; | 1108 const CSSGradientColorStop& stop = m_stops[i]; |
1097 result.append(", "); | 1109 result.append(", "); |
1098 if (stop.m_offset->getDoubleValue() == 0) { | 1110 if (stop.m_offset->getDoubleValue() == 0) { |
1099 result.append("from("); | 1111 result.append("from("); |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1508 dataEquivalent(m_fromAngle, other.m_fromAngle) && | 1520 dataEquivalent(m_fromAngle, other.m_fromAngle) && |
1509 m_stops == other.m_stops; | 1521 m_stops == other.m_stops; |
1510 } | 1522 } |
1511 | 1523 |
1512 DEFINE_TRACE_AFTER_DISPATCH(CSSConicGradientValue) { | 1524 DEFINE_TRACE_AFTER_DISPATCH(CSSConicGradientValue) { |
1513 visitor->trace(m_fromAngle); | 1525 visitor->trace(m_fromAngle); |
1514 CSSGradientValue::traceAfterDispatch(visitor); | 1526 CSSGradientValue::traceAfterDispatch(visitor); |
1515 } | 1527 } |
1516 | 1528 |
1517 } // namespace blink | 1529 } // namespace blink |
OLD | NEW |