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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 Image* result = getImage(&layoutObject, size); | 65 Image* result = getImage(&layoutObject, size); |
66 if (result) | 66 if (result) |
67 return result; | 67 return result; |
68 } | 68 } |
69 | 69 |
70 // We need to create an image. | 70 // We need to create an image. |
71 RefPtr<Gradient> gradient; | 71 RefPtr<Gradient> gradient; |
72 | 72 |
73 const ComputedStyle* rootStyle = layoutObject.document().documentElement()->
computedStyle(); | 73 const ComputedStyle* rootStyle = layoutObject.document().documentElement()->
computedStyle(); |
74 CSSToLengthConversionData conversionData(layoutObject.style(), rootStyle, la
youtObject.view(), layoutObject.style()->effectiveZoom()); | 74 CSSToLengthConversionData conversionData(layoutObject.style(), rootStyle, la
youtObject.view(), layoutObject.style()->effectiveZoom()); |
75 if (isLinearGradientValue()) | 75 |
| 76 switch (getClassType()) { |
| 77 case LinearGradientClass: |
76 gradient = toCSSLinearGradientValue(this)->createGradient(conversionData
, size, layoutObject); | 78 gradient = toCSSLinearGradientValue(this)->createGradient(conversionData
, size, layoutObject); |
77 else | 79 break; |
| 80 case RadialGradientClass: |
78 gradient = toCSSRadialGradientValue(this)->createGradient(conversionData
, size, layoutObject); | 81 gradient = toCSSRadialGradientValue(this)->createGradient(conversionData
, size, layoutObject); |
| 82 break; |
| 83 case ConicGradientClass: |
| 84 gradient = toCSSConicGradientValue(this)->createGradient(conversionData,
size, layoutObject); |
| 85 break; |
| 86 default: |
| 87 ASSERT_NOT_REACHED(); |
| 88 } |
79 | 89 |
80 RefPtr<Image> newImage = GradientGeneratedImage::create(gradient, size); | 90 RefPtr<Image> newImage = GradientGeneratedImage::create(gradient, size); |
81 if (cacheable) | 91 if (cacheable) |
82 putImage(size, newImage); | 92 putImage(size, newImage); |
83 | 93 |
84 return newImage.release(); | 94 return newImage.release(); |
85 } | 95 } |
86 | 96 |
87 // Should only ever be called for deprecated gradients. | 97 // Should only ever be called for deprecated gradients. |
88 static inline bool compareStops(const CSSGradientColorStop& a, const CSSGradient
ColorStop& b) | 98 static inline bool compareStops(const CSSGradientColorStop& a, const CSSGradient
ColorStop& b) |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 if (hasHints) { | 464 if (hasHints) { |
455 replaceColorHintsWithColorStops(stops, m_stops); | 465 replaceColorHintsWithColorStops(stops, m_stops); |
456 } | 466 } |
457 | 467 |
458 // At this point we have a fully resolved set of stops. Time to perform adju
stments for | 468 // At this point we have a fully resolved set of stops. Time to perform adju
stments for |
459 // repeat gradients and degenerate values if needed. | 469 // repeat gradients and degenerate values if needed. |
460 if (requiresStopsNormalization(stops, gradient)) { | 470 if (requiresStopsNormalization(stops, gradient)) { |
461 // Negative offsets are only an issue for non-repeating radial gradients
: linear gradient | 471 // Negative offsets are only an issue for non-repeating radial gradients
: linear gradient |
462 // points can be repositioned arbitrarily, and for repeating radial grad
ients we shift | 472 // points can be repositioned arbitrarily, and for repeating radial grad
ients we shift |
463 // the radii into equivalent positive values. | 473 // the radii into equivalent positive values. |
464 if (isRadialGradientValue() && !m_repeating) | 474 if ((isRadialGradientValue() && !m_repeating) || isConicGradientValue()) |
465 clampNegativeOffsets(stops); | 475 clampNegativeOffsets(stops); |
466 | 476 |
467 if (normalizeAndAddStops(stops, gradient)) { | 477 if (normalizeAndAddStops(stops, gradient)) { |
468 if (isLinearGradientValue()) { | 478 if (isLinearGradientValue()) { |
469 adjustGradientPointsForOffsetRange(gradient, stops.first().offse
t, stops.last().offset); | 479 adjustGradientPointsForOffsetRange(gradient, stops.first().offse
t, stops.last().offset); |
470 } else { | 480 } else { |
471 adjustGradientRadiiForOffsetRange(gradient, stops.first().offset
, stops.last().offset); | 481 adjustGradientRadiiForOffsetRange(gradient, stops.first().offset
, stops.last().offset); |
472 } | 482 } |
473 } else { | 483 } else { |
474 // Normalization failed because the stop set is coincident. | 484 // Normalization failed because the stop set is coincident. |
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 { | 1225 { |
1216 visitor->trace(m_firstRadius); | 1226 visitor->trace(m_firstRadius); |
1217 visitor->trace(m_secondRadius); | 1227 visitor->trace(m_secondRadius); |
1218 visitor->trace(m_shape); | 1228 visitor->trace(m_shape); |
1219 visitor->trace(m_sizingBehavior); | 1229 visitor->trace(m_sizingBehavior); |
1220 visitor->trace(m_endHorizontalSize); | 1230 visitor->trace(m_endHorizontalSize); |
1221 visitor->trace(m_endVerticalSize); | 1231 visitor->trace(m_endVerticalSize); |
1222 CSSGradientValue::traceAfterDispatch(visitor); | 1232 CSSGradientValue::traceAfterDispatch(visitor); |
1223 } | 1233 } |
1224 | 1234 |
| 1235 String CSSConicGradientValue::customCSSText() const |
| 1236 { |
| 1237 StringBuilder result; |
| 1238 |
| 1239 return result.toString(); |
| 1240 } |
| 1241 |
| 1242 PassRefPtr<Gradient> CSSConicGradientValue::createGradient(const CSSToLengthConv
ersionData& conversionData, const IntSize& size, const LayoutObject& object) |
| 1243 { |
| 1244 ASSERT(!size.isEmpty()); |
| 1245 |
| 1246 FloatPoint point = computeEndPoint(m_firstX.get(), m_firstY.get(), conversio
nData, size); |
| 1247 if (!m_firstX) |
| 1248 point.setX(size.width() / 2); |
| 1249 if (!m_firstY) |
| 1250 point.setY(size.height() / 2); |
| 1251 |
| 1252 RefPtr<Gradient> gradient = Gradient::create(point, 0); // TODO: angle |
| 1253 gradient->setSpreadMethod(m_repeating ? SpreadMethodRepeat : SpreadMethodPad
); |
| 1254 gradient->setDrawsInPMColorSpace(true); |
| 1255 |
| 1256 addStops(gradient.get(), conversionData, object); |
| 1257 |
| 1258 return gradient.release(); |
| 1259 } |
| 1260 |
| 1261 bool CSSConicGradientValue::equals(const CSSConicGradientValue& other) const |
| 1262 { |
| 1263 |
| 1264 return compareCSSValuePtr(m_firstX, other.m_firstX) |
| 1265 && compareCSSValuePtr(m_firstY, other.m_firstY) |
| 1266 && m_stops == other.m_stops; |
| 1267 } |
| 1268 |
| 1269 DEFINE_TRACE_AFTER_DISPATCH(CSSConicGradientValue) |
| 1270 { |
| 1271 CSSGradientValue::traceAfterDispatch(visitor); |
| 1272 } |
| 1273 |
1225 } // namespace blink | 1274 } // namespace blink |
OLD | NEW |