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 for (const auto& stop : m_stops) { | 1077 for (size_t i = 0; i < m_stops.size(); ++i) { |
1078 const auto& stop = m_stops[i]; | |
1079 const bool isColorRepeat = | |
1080 (i > 0) && !stop.isHint() && stop.m_color == m_stops[i - 1].m_color; | |
1081 // 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
| |
1082 DCHECK(!isColorRepeat || i < 2 || stop.m_color != m_stops[i - 2].m_color); | |
1083 | |
1078 if (requiresSeparator) { | 1084 if (requiresSeparator) { |
1079 result.append(", "); | 1085 if (!isColorRepeat) |
1086 result.append(", "); | |
1080 } else { | 1087 } else { |
1081 requiresSeparator = true; | 1088 requiresSeparator = true; |
1082 } | 1089 } |
1083 | 1090 |
1084 if (stop.m_color) | 1091 if (stop.m_color && !isColorRepeat) |
1085 result.append(stop.m_color->cssText()); | 1092 result.append(stop.m_color->cssText()); |
1086 if (stop.m_color && stop.m_offset) | 1093 if (stop.m_color && stop.m_offset) |
1087 result.append(' '); | 1094 result.append(' '); |
1088 if (stop.m_offset) | 1095 if (stop.m_offset) |
1089 result.append(stop.m_offset->cssText()); | 1096 result.append(stop.m_offset->cssText()); |
1090 } | 1097 } |
1091 } | 1098 } |
1092 | 1099 |
1093 void CSSGradientValue::appendCSSTextForDeprecatedColorStops( | 1100 void CSSGradientValue::appendCSSTextForDeprecatedColorStops( |
1094 StringBuilder& result) const { | 1101 StringBuilder& result) const { |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1508 dataEquivalent(m_fromAngle, other.m_fromAngle) && | 1515 dataEquivalent(m_fromAngle, other.m_fromAngle) && |
1509 m_stops == other.m_stops; | 1516 m_stops == other.m_stops; |
1510 } | 1517 } |
1511 | 1518 |
1512 DEFINE_TRACE_AFTER_DISPATCH(CSSConicGradientValue) { | 1519 DEFINE_TRACE_AFTER_DISPATCH(CSSConicGradientValue) { |
1513 visitor->trace(m_fromAngle); | 1520 visitor->trace(m_fromAngle); |
1514 CSSGradientValue::traceAfterDispatch(visitor); | 1521 CSSGradientValue::traceAfterDispatch(visitor); |
1515 } | 1522 } |
1516 | 1523 |
1517 } // namespace blink | 1524 } // namespace blink |
OLD | NEW |