| 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 newStops[y].color = blend(leftColor, rightColor, weighting); | 185 newStops[y].color = blend(leftColor, rightColor, weighting); |
| 186 } | 186 } |
| 187 | 187 |
| 188 // Replace the color hint with the new color stops. | 188 // Replace the color hint with the new color stops. |
| 189 stops.remove(x); | 189 stops.remove(x); |
| 190 stops.insert(x, newStops, 9); | 190 stops.insert(x, newStops, 9); |
| 191 indexOffset += 8; | 191 indexOffset += 8; |
| 192 } | 192 } |
| 193 } | 193 } |
| 194 | 194 |
| 195 static Color resolveStopColor(CSSPrimitiveValue* stopColor, const LayoutObject&
object) | 195 static Color resolveStopColor(CSSPrimitiveValue& stopColor, const LayoutObject&
object) |
| 196 { | 196 { |
| 197 return object.document().textLinkColors().colorFromPrimitiveValue(stopColor,
object.resolveColor(CSSPropertyColor)); | 197 return object.document().textLinkColors().colorFromPrimitiveValue(stopColor,
object.resolveColor(CSSPropertyColor)); |
| 198 } | 198 } |
| 199 | 199 |
| 200 void CSSGradientValue::addDeprecatedStops(Gradient* gradient, const LayoutObject
& object) | 200 void CSSGradientValue::addDeprecatedStops(Gradient* gradient, const LayoutObject
& object) |
| 201 { | 201 { |
| 202 ASSERT(m_gradientType == CSSDeprecatedLinearGradient || m_gradientType == CS
SDeprecatedRadialGradient); | 202 ASSERT(m_gradientType == CSSDeprecatedLinearGradient || m_gradientType == CS
SDeprecatedRadialGradient); |
| 203 | 203 |
| 204 if (!m_stopsSorted) { | 204 if (!m_stopsSorted) { |
| 205 if (m_stops.size()) | 205 if (m_stops.size()) |
| 206 std::stable_sort(m_stops.begin(), m_stops.end(), compareStops); | 206 std::stable_sort(m_stops.begin(), m_stops.end(), compareStops); |
| 207 m_stopsSorted = true; | 207 m_stopsSorted = true; |
| 208 } | 208 } |
| 209 | 209 |
| 210 for (const auto& stop : m_stops) { | 210 for (const auto& stop : m_stops) { |
| 211 float offset; | 211 float offset; |
| 212 if (stop.m_position->isPercentage()) | 212 if (stop.m_position->isPercentage()) |
| 213 offset = stop.m_position->getFloatValue() / 100; | 213 offset = stop.m_position->getFloatValue() / 100; |
| 214 else | 214 else |
| 215 offset = stop.m_position->getFloatValue(); | 215 offset = stop.m_position->getFloatValue(); |
| 216 | 216 |
| 217 gradient->addColorStop(offset, resolveStopColor(stop.m_color.get(), obje
ct)); | 217 gradient->addColorStop(offset, resolveStopColor(*stop.m_color.get(), obj
ect)); |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 | 220 |
| 221 static bool requiresStopsNormalization(const Vector<GradientStop>& stops, const
Gradient* gradient) | 221 static bool requiresStopsNormalization(const Vector<GradientStop>& stops, const
Gradient* gradient) |
| 222 { | 222 { |
| 223 // We need at least two stops to normalize | 223 // We need at least two stops to normalize |
| 224 if (stops.size() < 2) | 224 if (stops.size() < 2) |
| 225 return false; | 225 return false; |
| 226 | 226 |
| 227 // Repeating gradients are implemented using a normalized stop offset range | 227 // Repeating gradients are implemented using a normalized stop offset range |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 else if (isRadialGradientValue()) | 369 else if (isRadialGradientValue()) |
| 370 gradientEnd = gradientStart + FloatSize(gradient->endRadius(), 0); | 370 gradientEnd = gradientStart + FloatSize(gradient->endRadius(), 0); |
| 371 float gradientLength = FloatSize(gradientStart - gradientEnd).diagonalLength
(); | 371 float gradientLength = FloatSize(gradientStart - gradientEnd).diagonalLength
(); |
| 372 | 372 |
| 373 for (size_t i = 0; i < numStops; ++i) { | 373 for (size_t i = 0; i < numStops; ++i) { |
| 374 const CSSGradientColorStop& stop = m_stops[i]; | 374 const CSSGradientColorStop& stop = m_stops[i]; |
| 375 | 375 |
| 376 if (stop.isHint()) | 376 if (stop.isHint()) |
| 377 hasHints = true; | 377 hasHints = true; |
| 378 else | 378 else |
| 379 stops[i].color = resolveStopColor(stop.m_color.get(), object); | 379 stops[i].color = resolveStopColor(*stop.m_color.get(), object); |
| 380 | 380 |
| 381 if (stop.m_position) { | 381 if (stop.m_position) { |
| 382 if (stop.m_position->isPercentage()) | 382 if (stop.m_position->isPercentage()) |
| 383 stops[i].offset = stop.m_position->getFloatValue() / 100; | 383 stops[i].offset = stop.m_position->getFloatValue() / 100; |
| 384 else if (stop.m_position->isLength() || stop.m_position->isCalculate
dPercentageWithLength()) { | 384 else if (stop.m_position->isLength() || stop.m_position->isCalculate
dPercentageWithLength()) { |
| 385 float length; | 385 float length; |
| 386 if (stop.m_position->isLength()) | 386 if (stop.m_position->isLength()) |
| 387 length = stop.m_position->computeLength<float>(conversionDat
a); | 387 length = stop.m_position->computeLength<float>(conversionDat
a); |
| 388 else | 388 else |
| 389 length = stop.m_position->cssCalcValue()->toCalcValue(conver
sionData)->evaluate(gradientLength); | 389 length = stop.m_position->cssCalcValue()->toCalcValue(conver
sionData)->evaluate(gradientLength); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 return false; | 556 return false; |
| 557 } | 557 } |
| 558 | 558 |
| 559 return true; | 559 return true; |
| 560 } | 560 } |
| 561 | 561 |
| 562 bool CSSGradientValue::knownToBeOpaque(const LayoutObject* object) const | 562 bool CSSGradientValue::knownToBeOpaque(const LayoutObject* object) const |
| 563 { | 563 { |
| 564 ASSERT(object); | 564 ASSERT(object); |
| 565 for (auto& stop : m_stops) { | 565 for (auto& stop : m_stops) { |
| 566 if (!stop.isHint() && resolveStopColor(stop.m_color.get(), *object).hasA
lpha()) | 566 if (!stop.isHint() && resolveStopColor(*stop.m_color.get(), *object).has
Alpha()) |
| 567 return false; | 567 return false; |
| 568 } | 568 } |
| 569 return true; | 569 return true; |
| 570 } | 570 } |
| 571 | 571 |
| 572 DEFINE_TRACE_AFTER_DISPATCH(CSSGradientValue) | 572 DEFINE_TRACE_AFTER_DISPATCH(CSSGradientValue) |
| 573 { | 573 { |
| 574 #if ENABLE(OILPAN) | 574 #if ENABLE(OILPAN) |
| 575 visitor->trace(m_firstX); | 575 visitor->trace(m_firstX); |
| 576 visitor->trace(m_firstY); | 576 visitor->trace(m_firstY); |
| (...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 visitor->trace(m_firstRadius); | 1204 visitor->trace(m_firstRadius); |
| 1205 visitor->trace(m_secondRadius); | 1205 visitor->trace(m_secondRadius); |
| 1206 visitor->trace(m_shape); | 1206 visitor->trace(m_shape); |
| 1207 visitor->trace(m_sizingBehavior); | 1207 visitor->trace(m_sizingBehavior); |
| 1208 visitor->trace(m_endHorizontalSize); | 1208 visitor->trace(m_endHorizontalSize); |
| 1209 visitor->trace(m_endVerticalSize); | 1209 visitor->trace(m_endVerticalSize); |
| 1210 CSSGradientValue::traceAfterDispatch(visitor); | 1210 CSSGradientValue::traceAfterDispatch(visitor); |
| 1211 } | 1211 } |
| 1212 | 1212 |
| 1213 } // namespace blink | 1213 } // namespace blink |
| OLD | NEW |