| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 void CSSGradientValue::sortStopsIfNeeded() | 94 void CSSGradientValue::sortStopsIfNeeded() |
| 95 { | 95 { |
| 96 ASSERT(m_gradientType == CSSDeprecatedLinearGradient || m_gradientType == CS
SDeprecatedRadialGradient); | 96 ASSERT(m_gradientType == CSSDeprecatedLinearGradient || m_gradientType == CS
SDeprecatedRadialGradient); |
| 97 if (!m_stopsSorted) { | 97 if (!m_stopsSorted) { |
| 98 if (m_stops.size()) | 98 if (m_stops.size()) |
| 99 std::stable_sort(m_stops.begin(), m_stops.end(), compareStops); | 99 std::stable_sort(m_stops.begin(), m_stops.end(), compareStops); |
| 100 m_stopsSorted = true; | 100 m_stopsSorted = true; |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 | 103 |
| 104 class GradientStop { | 104 struct GradientStop { |
| 105 ALLOW_ONLY_INLINE_ALLOCATION(); | |
| 106 public: | |
| 107 Color color; | 105 Color color; |
| 108 float offset; | 106 float offset; |
| 109 bool specified; | 107 bool specified; |
| 110 | 108 |
| 111 GradientStop() | 109 GradientStop() |
| 112 : offset(0) | 110 : offset(0) |
| 113 , specified(false) | 111 , specified(false) |
| 114 { } | 112 { } |
| 115 }; | 113 }; |
| 116 | 114 |
| 117 void replaceColorHintsWithColorStops(WillBeHeapVector<GradientStop>& stops, cons
t WillBeHeapVector<CSSGradientColorStop, 2>& cssGradientStops) | 115 static void replaceColorHintsWithColorStops(Vector<GradientStop>& stops, const W
illBeHeapVector<CSSGradientColorStop, 2>& cssGradientStops) |
| 118 { | 116 { |
| 119 // This algorithm will replace each color interpolation hint with 9 regular | 117 // This algorithm will replace each color interpolation hint with 9 regular |
| 120 // color stops. The color values for the new color stops will be calculated | 118 // color stops. The color values for the new color stops will be calculated |
| 121 // using the color weighting formula defined in the spec. The new color | 119 // using the color weighting formula defined in the spec. The new color |
| 122 // stops will be positioned in such a way that all the pixels between the tw
o | 120 // stops will be positioned in such a way that all the pixels between the tw
o |
| 123 // user defined color stops have color values close to the interpolation cur
ve. | 121 // user defined color stops have color values close to the interpolation cur
ve. |
| 124 // If the hint is closer to the left color stop, add 2 stops to the left and | 122 // If the hint is closer to the left color stop, add 2 stops to the left and |
| 125 // 6 to the right, else add 6 stops to the left and 2 to the right. | 123 // 6 to the right, else add 6 stops to the left and 2 to the right. |
| 126 // The color stops on the side with more space start midway because | 124 // The color stops on the side with more space start midway because |
| 127 // the curve approximates a line in that region. | 125 // the curve approximates a line in that region. |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 offset = stop.m_position->getFloatValue(CSSPrimitiveValue::CSS_N
UMBER); | 220 offset = stop.m_position->getFloatValue(CSSPrimitiveValue::CSS_N
UMBER); |
| 223 | 221 |
| 224 gradient->addColorStop(offset, resolveStopColor(stop.m_color.get(),
object)); | 222 gradient->addColorStop(offset, resolveStopColor(stop.m_color.get(),
object)); |
| 225 } | 223 } |
| 226 | 224 |
| 227 return; | 225 return; |
| 228 } | 226 } |
| 229 | 227 |
| 230 size_t numStops = m_stops.size(); | 228 size_t numStops = m_stops.size(); |
| 231 | 229 |
| 232 WillBeHeapVector<GradientStop> stops(numStops); | 230 Vector<GradientStop> stops(numStops); |
| 233 | 231 |
| 234 float gradientLength = 0; | 232 float gradientLength = 0; |
| 235 bool computedGradientLength = false; | 233 bool computedGradientLength = false; |
| 236 | 234 |
| 237 bool hasHints = false; | 235 bool hasHints = false; |
| 238 | 236 |
| 239 FloatPoint gradientStart = gradient->p0(); | 237 FloatPoint gradientStart = gradient->p0(); |
| 240 FloatPoint gradientEnd; | 238 FloatPoint gradientEnd; |
| 241 if (isLinearGradientValue()) | 239 if (isLinearGradientValue()) |
| 242 gradientEnd = gradient->p1(); | 240 gradientEnd = gradient->p1(); |
| (...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1266 visitor->trace(m_firstRadius); | 1264 visitor->trace(m_firstRadius); |
| 1267 visitor->trace(m_secondRadius); | 1265 visitor->trace(m_secondRadius); |
| 1268 visitor->trace(m_shape); | 1266 visitor->trace(m_shape); |
| 1269 visitor->trace(m_sizingBehavior); | 1267 visitor->trace(m_sizingBehavior); |
| 1270 visitor->trace(m_endHorizontalSize); | 1268 visitor->trace(m_endHorizontalSize); |
| 1271 visitor->trace(m_endVerticalSize); | 1269 visitor->trace(m_endVerticalSize); |
| 1272 CSSGradientValue::traceAfterDispatch(visitor); | 1270 CSSGradientValue::traceAfterDispatch(visitor); |
| 1273 } | 1271 } |
| 1274 | 1272 |
| 1275 } // namespace blink | 1273 } // namespace blink |
| OLD | NEW |