| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 RefPtr<Image> newImage = GradientGeneratedImage::create(gradient, size); | 80 RefPtr<Image> newImage = GradientGeneratedImage::create(gradient, size); |
| 81 if (cacheable) | 81 if (cacheable) |
| 82 putImage(size, newImage); | 82 putImage(size, newImage); |
| 83 | 83 |
| 84 return newImage.release(); | 84 return newImage.release(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 // Should only ever be called for deprecated gradients. | 87 // Should only ever be called for deprecated gradients. |
| 88 static inline bool compareStops(const CSSGradientColorStop& a, const CSSGradient
ColorStop& b) | 88 static inline bool compareStops(const CSSGradientColorStop& a, const CSSGradient
ColorStop& b) |
| 89 { | 89 { |
| 90 double aVal = toCSSPrimitiveValue(*a.m_position).getDoubleValue(); | 90 double aVal = toCSSPrimitiveValue(a.m_position).getDoubleValue(); |
| 91 double bVal = toCSSPrimitiveValue(*b.m_position).getDoubleValue(); | 91 double bVal = toCSSPrimitiveValue(b.m_position).getDoubleValue(); |
| 92 | 92 |
| 93 return aVal < bVal; | 93 return aVal < bVal; |
| 94 } | 94 } |
| 95 | 95 |
| 96 struct GradientStop { | 96 struct GradientStop { |
| 97 Color color; | 97 Color color; |
| 98 float offset; | 98 float offset; |
| 99 bool specified; | 99 bool specified; |
| 100 | 100 |
| 101 GradientStop() | 101 GradientStop() |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 (toCSSPrimitiveValue(*stop.m_position).isPercentage()) | 212 if (toCSSPrimitiveValue(stop.m_position).isPercentage()) |
| 213 offset = toCSSPrimitiveValue(*stop.m_position).getFloatValue() / 100
; | 213 offset = toCSSPrimitiveValue(stop.m_position).getFloatValue() / 100; |
| 214 else | 214 else |
| 215 offset = toCSSPrimitiveValue(*stop.m_position).getFloatValue(); | 215 offset = toCSSPrimitiveValue(stop.m_position).getFloatValue(); |
| 216 | 216 |
| 217 gradient->addColorStop(offset, resolveStopColor(toCSSPrimitiveValue(*sto
p.m_color), object)); | 217 gradient->addColorStop(offset, resolveStopColor(toCSSPrimitiveValue(stop
.m_color), object)); |
| 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(toCSSPrimitiveValue(*stop.m_color)
, object); | 379 stops[i].color = resolveStopColor(toCSSPrimitiveValue(stop.m_color),
object); |
| 380 | 380 |
| 381 if (stop.m_position) { | 381 if (stop.m_position) { |
| 382 CSSPrimitiveValue stopPosition = toCSSPrimitiveValue(*stop.m_positio
n); | 382 const CSSPrimitiveValue& stopPosition = toCSSPrimitiveValue(stop.m_p
osition); |
| 383 if (stopPosition.isPercentage()) { | 383 if (stopPosition.isPercentage()) { |
| 384 stops[i].offset = toCSSPrimitiveValue(*stop.m_position).getFloat
Value() / 100; | 384 stops[i].offset = toCSSPrimitiveValue(stop.m_position).getFloatV
alue() / 100; |
| 385 } else if (stopPosition.isLength() || stopPosition.isCalculatedPerce
ntageWithLength()) { | 385 } else if (stopPosition.isLength() || stopPosition.isCalculatedPerce
ntageWithLength()) { |
| 386 float length; | 386 float length; |
| 387 if (stopPosition.isLength()) | 387 if (stopPosition.isLength()) |
| 388 length = stopPosition.computeLength<float>(conversionData); | 388 length = stopPosition.computeLength<float>(conversionData); |
| 389 else | 389 else |
| 390 length = stopPosition.cssCalcValue()->toCalcValue(conversion
Data)->evaluate(gradientLength); | 390 length = stopPosition.cssCalcValue()->toCalcValue(conversion
Data)->evaluate(gradientLength); |
| 391 stops[i].offset = (gradientLength > 0) ? length / gradientLength
: 0; | 391 stops[i].offset = (gradientLength > 0) ? length / gradientLength
: 0; |
| 392 } else { | 392 } else { |
| 393 ASSERT_NOT_REACHED(); | 393 ASSERT_NOT_REACHED(); |
| 394 stops[i].offset = 0; | 394 stops[i].offset = 0; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 | 483 |
| 484 static float positionFromValue(CSSPrimitiveValue value, const CSSToLengthConvers
ionData& conversionData, const IntSize& size, bool isHorizontal) | 484 static float positionFromValue(CSSPrimitiveValue value, const CSSToLengthConvers
ionData& conversionData, const IntSize& size, bool isHorizontal) |
| 485 { | 485 { |
| 486 int origin = 0; | 486 int origin = 0; |
| 487 int sign = 1; | 487 int sign = 1; |
| 488 int edgeDistance = isHorizontal ? size.width() : size.height(); | 488 int edgeDistance = isHorizontal ? size.width() : size.height(); |
| 489 | 489 |
| 490 // In this case the center of the gradient is given relative to an edge in t
he form of: | 490 // In this case the center of the gradient is given relative to an edge in t
he form of: |
| 491 // [ top | bottom | right | left ] [ <percentage> | <length> ]. | 491 // [ top | bottom | right | left ] [ <percentage> | <length> ]. |
| 492 if (Pair* pair = value.getPairValue()) { | 492 if (Pair* pair = value.getPairValue()) { |
| 493 CSSValueID originID = toCSSPrimitiveValue(*pair->first()).getValueID(); | 493 CSSValueID originID = pair->first().getValueID(); |
| 494 value = toCSSPrimitiveValue(*pair->second()); | 494 value = pair->second(); |
| 495 | 495 |
| 496 if (originID == CSSValueRight || originID == CSSValueBottom) { | 496 if (originID == CSSValueRight || originID == CSSValueBottom) { |
| 497 // For right/bottom, the offset is relative to the far edge. | 497 // For right/bottom, the offset is relative to the far edge. |
| 498 origin = edgeDistance; | 498 origin = edgeDistance; |
| 499 sign = -1; | 499 sign = -1; |
| 500 } | 500 } |
| 501 } | 501 } |
| 502 | 502 |
| 503 if (value.isNumber()) | 503 if (value.isNumber()) |
| 504 return origin + sign * value.getFloatValue() * conversionData.zoom(); | 504 return origin + sign * value.getFloatValue() * conversionData.zoom(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 527 } | 527 } |
| 528 | 528 |
| 529 return origin + sign * value.computeLength<float>(conversionData); | 529 return origin + sign * value.computeLength<float>(conversionData); |
| 530 } | 530 } |
| 531 | 531 |
| 532 FloatPoint CSSGradientValue::computeEndPoint(NullableCSSValue horizontal, Nullab
leCSSValue vertical, const CSSToLengthConversionData& conversionData, const IntS
ize& size) | 532 FloatPoint CSSGradientValue::computeEndPoint(NullableCSSValue horizontal, Nullab
leCSSValue vertical, const CSSToLengthConversionData& conversionData, const IntS
ize& size) |
| 533 { | 533 { |
| 534 FloatPoint result; | 534 FloatPoint result; |
| 535 | 535 |
| 536 if (horizontal) | 536 if (horizontal) |
| 537 result.setX(positionFromValue(toCSSPrimitiveValue(*horizontal), conversi
onData, size, true)); | 537 result.setX(positionFromValue(toCSSPrimitiveValue(horizontal), conversio
nData, size, true)); |
| 538 | 538 |
| 539 if (vertical) | 539 if (vertical) |
| 540 result.setY(positionFromValue(toCSSPrimitiveValue(*vertical), conversion
Data, size, false)); | 540 result.setY(positionFromValue(toCSSPrimitiveValue(vertical), conversionD
ata, size, false)); |
| 541 | 541 |
| 542 return result; | 542 return result; |
| 543 } | 543 } |
| 544 | 544 |
| 545 bool CSSGradientValue::isCacheable() const | 545 bool CSSGradientValue::isCacheable() const |
| 546 { | 546 { |
| 547 for (size_t i = 0; i < m_stops.size(); ++i) { | 547 for (size_t i = 0; i < m_stops.size(); ++i) { |
| 548 const CSSGradientColorStop& stop = m_stops[i]; | 548 const CSSGradientColorStop& stop = m_stops[i]; |
| 549 | 549 |
| 550 if (!stop.isHint() && toCSSPrimitiveValue(*stop.m_color).colorIsDerivedF
romElement()) | 550 if (!stop.isHint() && toCSSPrimitiveValue(stop.m_color).colorIsDerivedFr
omElement()) |
| 551 return false; | 551 return false; |
| 552 | 552 |
| 553 if (!stop.m_position) | 553 if (!stop.m_position) |
| 554 continue; | 554 continue; |
| 555 | 555 |
| 556 if (toCSSPrimitiveValue(*stop.m_position).isFontRelativeLength()) | 556 if (toCSSPrimitiveValue(stop.m_position).isFontRelativeLength()) |
| 557 return false; | 557 return false; |
| 558 } | 558 } |
| 559 | 559 |
| 560 return true; | 560 return true; |
| 561 } | 561 } |
| 562 | 562 |
| 563 bool CSSGradientValue::knownToBeOpaque(const LayoutObject* object) const | 563 bool CSSGradientValue::knownToBeOpaque(const LayoutObject* object) const |
| 564 { | 564 { |
| 565 ASSERT(object); | 565 ASSERT(object); |
| 566 for (auto& stop : m_stops) { | 566 for (auto& stop : m_stops) { |
| 567 if (!stop.isHint() && resolveStopColor(toCSSPrimitiveValue(*stop.m_color
), *object).hasAlpha()) | 567 if (!stop.isHint() && resolveStopColor(toCSSPrimitiveValue(stop.m_color)
, *object).hasAlpha()) |
| 568 return false; | 568 return false; |
| 569 } | 569 } |
| 570 return true; | 570 return true; |
| 571 } | 571 } |
| 572 | 572 |
| 573 DEFINE_TRACE_AFTER_DISPATCH(CSSGradientValue) | 573 DEFINE_TRACE_AFTER_DISPATCH(CSSGradientValue) |
| 574 { | 574 { |
| 575 #if ENABLE(OILPAN) | 575 #if ENABLE(OILPAN) |
| 576 visitor->trace(m_firstX); | 576 visitor->trace(m_firstX); |
| 577 visitor->trace(m_firstY); | 577 visitor->trace(m_firstY); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 } | 627 } |
| 628 } | 628 } |
| 629 } else { | 629 } else { |
| 630 if (m_repeating) | 630 if (m_repeating) |
| 631 result.appendLiteral("repeating-linear-gradient("); | 631 result.appendLiteral("repeating-linear-gradient("); |
| 632 else | 632 else |
| 633 result.appendLiteral("linear-gradient("); | 633 result.appendLiteral("linear-gradient("); |
| 634 | 634 |
| 635 bool wroteSomething = false; | 635 bool wroteSomething = false; |
| 636 | 636 |
| 637 if (m_angle && toCSSPrimitiveValue(*m_angle).computeDegrees() != 180) { | 637 if (m_angle && toCSSPrimitiveValue(m_angle).computeDegrees() != 180) { |
| 638 result.append(m_angle->cssText()); | 638 result.append(m_angle->cssText()); |
| 639 wroteSomething = true; | 639 wroteSomething = true; |
| 640 } else if ((m_firstX || m_firstY) && !(!m_firstX && m_firstY && toCSSPri
mitiveValue(*m_firstY).getValueID() == CSSValueBottom)) { | 640 } else if ((m_firstX || m_firstY) && !(!m_firstX && m_firstY && toCSSPri
mitiveValue(m_firstY).getValueID() == CSSValueBottom)) { |
| 641 result.appendLiteral("to "); | 641 result.appendLiteral("to "); |
| 642 if (m_firstX && m_firstY) { | 642 if (m_firstX && m_firstY) { |
| 643 result.append(m_firstX->cssText()); | 643 result.append(m_firstX->cssText()); |
| 644 result.append(' '); | 644 result.append(' '); |
| 645 result.append(m_firstY->cssText()); | 645 result.append(m_firstY->cssText()); |
| 646 } else if (m_firstX) | 646 } else if (m_firstX) |
| 647 result.append(m_firstX->cssText()); | 647 result.append(m_firstX->cssText()); |
| 648 else | 648 else |
| 649 result.append(m_firstY->cssText()); | 649 result.append(m_firstY->cssText()); |
| 650 wroteSomething = true; | 650 wroteSomething = true; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 firstPoint.set(halfWidth - endX, halfHeight + endY); | 739 firstPoint.set(halfWidth - endX, halfHeight + endY); |
| 740 } | 740 } |
| 741 | 741 |
| 742 PassRefPtr<Gradient> CSSLinearGradientValue::createGradient(const CSSToLengthCon
versionData& conversionData, const IntSize& size, const LayoutObject& object) | 742 PassRefPtr<Gradient> CSSLinearGradientValue::createGradient(const CSSToLengthCon
versionData& conversionData, const IntSize& size, const LayoutObject& object) |
| 743 { | 743 { |
| 744 ASSERT(!size.isEmpty()); | 744 ASSERT(!size.isEmpty()); |
| 745 | 745 |
| 746 FloatPoint firstPoint; | 746 FloatPoint firstPoint; |
| 747 FloatPoint secondPoint; | 747 FloatPoint secondPoint; |
| 748 if (m_angle) { | 748 if (m_angle) { |
| 749 float angle = toCSSPrimitiveValue(*m_angle).computeDegrees(); | 749 float angle = toCSSPrimitiveValue(m_angle).computeDegrees(); |
| 750 endPointsFromAngle(angle, size, firstPoint, secondPoint, m_gradientType)
; | 750 endPointsFromAngle(angle, size, firstPoint, secondPoint, m_gradientType)
; |
| 751 } else { | 751 } else { |
| 752 switch (m_gradientType) { | 752 switch (m_gradientType) { |
| 753 case CSSDeprecatedLinearGradient: | 753 case CSSDeprecatedLinearGradient: |
| 754 firstPoint = computeEndPoint(m_firstX, m_firstY, conversionData, siz
e); | 754 firstPoint = computeEndPoint(m_firstX, m_firstY, conversionData, siz
e); |
| 755 if (m_secondX || m_secondY) | 755 if (m_secondX || m_secondY) |
| 756 secondPoint = computeEndPoint(m_secondX, m_secondY, conversionDa
ta, size); | 756 secondPoint = computeEndPoint(m_secondX, m_secondY, conversionDa
ta, size); |
| 757 else { | 757 else { |
| 758 if (m_firstX) | 758 if (m_firstX) |
| 759 secondPoint.setX(size.width() - firstPoint.x()); | 759 secondPoint.setX(size.width() - firstPoint.x()); |
| 760 if (m_firstY) | 760 if (m_firstY) |
| 761 secondPoint.setY(size.height() - firstPoint.y()); | 761 secondPoint.setY(size.height() - firstPoint.y()); |
| 762 } | 762 } |
| 763 break; | 763 break; |
| 764 case CSSPrefixedLinearGradient: | 764 case CSSPrefixedLinearGradient: |
| 765 firstPoint = computeEndPoint(m_firstX, m_firstY, conversionData, siz
e); | 765 firstPoint = computeEndPoint(m_firstX, m_firstY, conversionData, siz
e); |
| 766 if (m_firstX) | 766 if (m_firstX) |
| 767 secondPoint.setX(size.width() - firstPoint.x()); | 767 secondPoint.setX(size.width() - firstPoint.x()); |
| 768 if (m_firstY) | 768 if (m_firstY) |
| 769 secondPoint.setY(size.height() - firstPoint.y()); | 769 secondPoint.setY(size.height() - firstPoint.y()); |
| 770 break; | 770 break; |
| 771 case CSSLinearGradient: | 771 case CSSLinearGradient: |
| 772 if (m_firstX && m_firstY) { | 772 if (m_firstX && m_firstY) { |
| 773 // "Magic" corners, so the 50% line touches two corners. | 773 // "Magic" corners, so the 50% line touches two corners. |
| 774 float rise = size.width(); | 774 float rise = size.width(); |
| 775 float run = size.height(); | 775 float run = size.height(); |
| 776 if (m_firstX && toCSSPrimitiveValue(*m_firstX).getValueID() == C
SSValueLeft) | 776 if (m_firstX && toCSSPrimitiveValue(m_firstX).getValueID() == CS
SValueLeft) |
| 777 run *= -1; | 777 run *= -1; |
| 778 if (m_firstY && toCSSPrimitiveValue(*m_firstY).getValueID() == C
SSValueBottom) | 778 if (m_firstY && toCSSPrimitiveValue(m_firstY).getValueID() == CS
SValueBottom) |
| 779 rise *= -1; | 779 rise *= -1; |
| 780 // Compute angle, and flip it back to "bearing angle" degrees. | 780 // Compute angle, and flip it back to "bearing angle" degrees. |
| 781 float angle = 90 - rad2deg(atan2(rise, run)); | 781 float angle = 90 - rad2deg(atan2(rise, run)); |
| 782 endPointsFromAngle(angle, size, firstPoint, secondPoint, m_gradi
entType); | 782 endPointsFromAngle(angle, size, firstPoint, secondPoint, m_gradi
entType); |
| 783 } else if (m_firstX || m_firstY) { | 783 } else if (m_firstX || m_firstY) { |
| 784 secondPoint = computeEndPoint(m_firstX, m_firstY, conversionData
, size); | 784 secondPoint = computeEndPoint(m_firstX, m_firstY, conversionData
, size); |
| 785 if (m_firstX) | 785 if (m_firstX) |
| 786 firstPoint.setX(size.width() - secondPoint.x()); | 786 firstPoint.setX(size.width() - secondPoint.x()); |
| 787 if (m_firstY) | 787 if (m_firstY) |
| 788 firstPoint.setY(size.height() - secondPoint.y()); | 788 firstPoint.setY(size.height() - secondPoint.y()); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 { | 842 { |
| 843 visitor->trace(m_angle); | 843 visitor->trace(m_angle); |
| 844 CSSGradientValue::traceAfterDispatch(visitor); | 844 CSSGradientValue::traceAfterDispatch(visitor); |
| 845 } | 845 } |
| 846 | 846 |
| 847 inline void CSSGradientValue::appendCSSTextForDeprecatedColorStops(StringBuilder
& result) const | 847 inline void CSSGradientValue::appendCSSTextForDeprecatedColorStops(StringBuilder
& result) const |
| 848 { | 848 { |
| 849 for (unsigned i = 0; i < m_stops.size(); i++) { | 849 for (unsigned i = 0; i < m_stops.size(); i++) { |
| 850 const CSSGradientColorStop& stop = m_stops[i]; | 850 const CSSGradientColorStop& stop = m_stops[i]; |
| 851 result.appendLiteral(", "); | 851 result.appendLiteral(", "); |
| 852 double stopValue = toCSSPrimitiveValue(*stop.m_position).getDoubleValue(
); | 852 double stopValue = toCSSPrimitiveValue(stop.m_position).getDoubleValue()
; |
| 853 if (stopValue == 0) { | 853 if (stopValue == 0) { |
| 854 result.appendLiteral("from("); | 854 result.appendLiteral("from("); |
| 855 result.append(stop.m_color->cssText()); | 855 result.append(stop.m_color->cssText()); |
| 856 result.append(')'); | 856 result.append(')'); |
| 857 } else if (stopValue == 1) { | 857 } else if (stopValue == 1) { |
| 858 result.appendLiteral("to("); | 858 result.appendLiteral("to("); |
| 859 result.append(stop.m_color->cssText()); | 859 result.append(stop.m_color->cssText()); |
| 860 result.append(')'); | 860 result.append(')'); |
| 861 } else { | 861 } else { |
| 862 result.appendLiteral("color-stop("); | 862 result.appendLiteral("color-stop("); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 } else { | 935 } else { |
| 936 if (m_repeating) | 936 if (m_repeating) |
| 937 result.appendLiteral("repeating-radial-gradient("); | 937 result.appendLiteral("repeating-radial-gradient("); |
| 938 else | 938 else |
| 939 result.appendLiteral("radial-gradient("); | 939 result.appendLiteral("radial-gradient("); |
| 940 | 940 |
| 941 bool wroteSomething = false; | 941 bool wroteSomething = false; |
| 942 | 942 |
| 943 // The only ambiguous case that needs an explicit shape to be provided | 943 // The only ambiguous case that needs an explicit shape to be provided |
| 944 // is when a sizing keyword is used (or all sizing is omitted). | 944 // is when a sizing keyword is used (or all sizing is omitted). |
| 945 if (m_shape && toCSSPrimitiveValue(*m_shape).getValueID() != CSSValueEll
ipse && (m_sizingBehavior || (!m_sizingBehavior && !m_endHorizontalSize))) { | 945 if (m_shape && toCSSPrimitiveValue(m_shape).getValueID() != CSSValueElli
pse && (m_sizingBehavior || (!m_sizingBehavior && !m_endHorizontalSize))) { |
| 946 result.appendLiteral("circle"); | 946 result.appendLiteral("circle"); |
| 947 wroteSomething = true; | 947 wroteSomething = true; |
| 948 } | 948 } |
| 949 | 949 |
| 950 if (m_sizingBehavior && toCSSPrimitiveValue(*m_sizingBehavior).getValueI
D() != CSSValueFarthestCorner) { | 950 if (m_sizingBehavior && toCSSPrimitiveValue(m_sizingBehavior).getValueID
() != CSSValueFarthestCorner) { |
| 951 if (wroteSomething) | 951 if (wroteSomething) |
| 952 result.append(' '); | 952 result.append(' '); |
| 953 result.append(m_sizingBehavior->cssText()); | 953 result.append(m_sizingBehavior->cssText()); |
| 954 wroteSomething = true; | 954 wroteSomething = true; |
| 955 } else if (m_endHorizontalSize) { | 955 } else if (m_endHorizontalSize) { |
| 956 if (wroteSomething) | 956 if (wroteSomething) |
| 957 result.append(' '); | 957 result.append(' '); |
| 958 result.append(m_endHorizontalSize->cssText()); | 958 result.append(m_endHorizontalSize->cssText()); |
| 959 if (m_endVerticalSize) { | 959 if (m_endVerticalSize) { |
| 960 result.append(' '); | 960 result.append(' '); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 firstPoint.setY(size.height() / 2); | 1095 firstPoint.setY(size.height() / 2); |
| 1096 | 1096 |
| 1097 FloatPoint secondPoint = computeEndPoint(m_secondX.get(), m_secondY.get(), c
onversionData, size); | 1097 FloatPoint secondPoint = computeEndPoint(m_secondX.get(), m_secondY.get(), c
onversionData, size); |
| 1098 if (!m_secondX) | 1098 if (!m_secondX) |
| 1099 secondPoint.setX(size.width() / 2); | 1099 secondPoint.setX(size.width() / 2); |
| 1100 if (!m_secondY) | 1100 if (!m_secondY) |
| 1101 secondPoint.setY(size.height() / 2); | 1101 secondPoint.setY(size.height() / 2); |
| 1102 | 1102 |
| 1103 float firstRadius = 0; | 1103 float firstRadius = 0; |
| 1104 if (m_firstRadius) | 1104 if (m_firstRadius) |
| 1105 firstRadius = resolveRadius(toCSSPrimitiveValue(*m_firstRadius), convers
ionData); | 1105 firstRadius = resolveRadius(toCSSPrimitiveValue(m_firstRadius), conversi
onData); |
| 1106 | 1106 |
| 1107 FloatSize secondRadius(0, 0); | 1107 FloatSize secondRadius(0, 0); |
| 1108 if (m_secondRadius) { | 1108 if (m_secondRadius) { |
| 1109 secondRadius.setWidth(resolveRadius(toCSSPrimitiveValue(*m_secondRadius)
, conversionData)); | 1109 secondRadius.setWidth(resolveRadius(toCSSPrimitiveValue(m_secondRadius),
conversionData)); |
| 1110 secondRadius.setHeight(secondRadius.width()); | 1110 secondRadius.setHeight(secondRadius.width()); |
| 1111 } else if (m_endHorizontalSize) { | 1111 } else if (m_endHorizontalSize) { |
| 1112 float width = size.width(); | 1112 float width = size.width(); |
| 1113 float height = size.height(); | 1113 float height = size.height(); |
| 1114 secondRadius.setWidth(resolveRadius(toCSSPrimitiveValue(*m_endHorizontal
Size), conversionData, &width)); | 1114 secondRadius.setWidth(resolveRadius(toCSSPrimitiveValue(m_endHorizontalS
ize), conversionData, &width)); |
| 1115 secondRadius.setHeight(m_endVerticalSize | 1115 secondRadius.setHeight(m_endVerticalSize |
| 1116 ? resolveRadius(toCSSPrimitiveValue(*m_endVerticalSize), conversionD
ata, &height) | 1116 ? resolveRadius(toCSSPrimitiveValue(m_endVerticalSize), conversionDa
ta, &height) |
| 1117 : secondRadius.width()); | 1117 : secondRadius.width()); |
| 1118 } else { | 1118 } else { |
| 1119 EndShapeType shape = (m_shape && toCSSPrimitiveValue(*m_shape).getValueI
D() == CSSValueCircle) | 1119 EndShapeType shape = (m_shape && toCSSPrimitiveValue(m_shape).getValueID
() == CSSValueCircle) |
| 1120 || (!m_shape && !m_sizingBehavior && m_endHorizontalSize && !m_endVe
rticalSize) | 1120 || (!m_shape && !m_sizingBehavior && m_endHorizontalSize && !m_endVe
rticalSize) |
| 1121 ? CircleEndShape | 1121 ? CircleEndShape |
| 1122 : EllipseEndShape; | 1122 : EllipseEndShape; |
| 1123 | 1123 |
| 1124 switch (m_sizingBehavior ? toCSSPrimitiveValue(*m_sizingBehavior).getVal
ueID() : 0) { | 1124 switch (m_sizingBehavior ? toCSSPrimitiveValue(m_sizingBehavior).getValu
eID() : 0) { |
| 1125 case CSSValueContain: | 1125 case CSSValueContain: |
| 1126 case CSSValueClosestSide: | 1126 case CSSValueClosestSide: |
| 1127 secondRadius = radiusToSide(secondPoint, size, shape, | 1127 secondRadius = radiusToSide(secondPoint, size, shape, |
| 1128 [] (float a, float b) { return a < b; }); | 1128 [] (float a, float b) { return a < b; }); |
| 1129 break; | 1129 break; |
| 1130 case CSSValueFarthestSide: | 1130 case CSSValueFarthestSide: |
| 1131 secondRadius = radiusToSide(secondPoint, size, shape, | 1131 secondRadius = radiusToSide(secondPoint, size, shape, |
| 1132 [] (float a, float b) { return a > b; }); | 1132 [] (float a, float b) { return a > b; }); |
| 1133 break; | 1133 break; |
| 1134 case CSSValueClosestCorner: | 1134 case CSSValueClosestCorner: |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1206 visitor->trace(m_firstRadius); | 1206 visitor->trace(m_firstRadius); |
| 1207 visitor->trace(m_secondRadius); | 1207 visitor->trace(m_secondRadius); |
| 1208 visitor->trace(m_shape); | 1208 visitor->trace(m_shape); |
| 1209 visitor->trace(m_sizingBehavior); | 1209 visitor->trace(m_sizingBehavior); |
| 1210 visitor->trace(m_endHorizontalSize); | 1210 visitor->trace(m_endHorizontalSize); |
| 1211 visitor->trace(m_endVerticalSize); | 1211 visitor->trace(m_endVerticalSize); |
| 1212 CSSGradientValue::traceAfterDispatch(visitor); | 1212 CSSGradientValue::traceAfterDispatch(visitor); |
| 1213 } | 1213 } |
| 1214 | 1214 |
| 1215 } // namespace blink | 1215 } // namespace blink |
| OLD | NEW |