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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 if (value->isNumber()) | 405 if (value->isNumber()) |
406 return value->getFloatValue() * zoomFactor; | 406 return value->getFloatValue() * zoomFactor; |
407 | 407 |
408 int edgeDistance = isHorizontal ? size.width() : size.height(); | 408 int edgeDistance = isHorizontal ? size.width() : size.height(); |
409 if (value->isPercentage()) | 409 if (value->isPercentage()) |
410 return value->getFloatValue() / 100.f * edgeDistance; | 410 return value->getFloatValue() / 100.f * edgeDistance; |
411 | 411 |
412 if (value->isCalculatedPercentageWithLength()) | 412 if (value->isCalculatedPercentageWithLength()) |
413 return value->cssCalcValue()->toCalcValue(style, rootStyle, style->effec
tiveZoom())->evaluate(edgeDistance); | 413 return value->cssCalcValue()->toCalcValue(style, rootStyle, style->effec
tiveZoom())->evaluate(edgeDistance); |
414 | 414 |
415 switch (value->getIdent()) { | 415 switch (value->getValueID()) { |
416 case CSSValueTop: | 416 case CSSValueTop: |
417 ASSERT(!isHorizontal); | 417 ASSERT(!isHorizontal); |
418 return 0; | 418 return 0; |
419 case CSSValueLeft: | 419 case CSSValueLeft: |
420 ASSERT(isHorizontal); | 420 ASSERT(isHorizontal); |
421 return 0; | 421 return 0; |
422 case CSSValueBottom: | 422 case CSSValueBottom: |
423 ASSERT(!isHorizontal); | 423 ASSERT(!isHorizontal); |
424 return size.height(); | 424 return size.height(); |
425 case CSSValueRight: | 425 case CSSValueRight: |
426 ASSERT(isHorizontal); | 426 ASSERT(isHorizontal); |
427 return size.width(); | 427 return size.width(); |
| 428 default: |
| 429 break; |
428 } | 430 } |
429 | 431 |
430 return value->computeLength<float>(style, rootStyle, zoomFactor); | 432 return value->computeLength<float>(style, rootStyle, zoomFactor); |
431 } | 433 } |
432 | 434 |
433 FloatPoint CSSGradientValue::computeEndPoint(CSSPrimitiveValue* horizontal, CSSP
rimitiveValue* vertical, RenderStyle* style, RenderStyle* rootStyle, const IntSi
ze& size) | 435 FloatPoint CSSGradientValue::computeEndPoint(CSSPrimitiveValue* horizontal, CSSP
rimitiveValue* vertical, RenderStyle* style, RenderStyle* rootStyle, const IntSi
ze& size) |
434 { | 436 { |
435 FloatPoint result; | 437 FloatPoint result; |
436 | 438 |
437 if (horizontal) | 439 if (horizontal) |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 if (m_repeating) | 550 if (m_repeating) |
549 result.appendLiteral("repeating-linear-gradient("); | 551 result.appendLiteral("repeating-linear-gradient("); |
550 else | 552 else |
551 result.appendLiteral("linear-gradient("); | 553 result.appendLiteral("linear-gradient("); |
552 | 554 |
553 bool wroteSomething = false; | 555 bool wroteSomething = false; |
554 | 556 |
555 if (m_angle && m_angle->computeDegrees() != 180) { | 557 if (m_angle && m_angle->computeDegrees() != 180) { |
556 result.append(m_angle->cssText()); | 558 result.append(m_angle->cssText()); |
557 wroteSomething = true; | 559 wroteSomething = true; |
558 } else if ((m_firstX || m_firstY) && !(!m_firstX && m_firstY && m_firstY
->getIdent() == CSSValueBottom)) { | 560 } else if ((m_firstX || m_firstY) && !(!m_firstX && m_firstY && m_firstY
->getValueID() == CSSValueBottom)) { |
559 result.appendLiteral("to "); | 561 result.appendLiteral("to "); |
560 if (m_firstX && m_firstY) { | 562 if (m_firstX && m_firstY) { |
561 result.append(m_firstX->cssText()); | 563 result.append(m_firstX->cssText()); |
562 result.append(' '); | 564 result.append(' '); |
563 result.append(m_firstY->cssText()); | 565 result.append(m_firstY->cssText()); |
564 } else if (m_firstX) | 566 } else if (m_firstX) |
565 result.append(m_firstX->cssText()); | 567 result.append(m_firstX->cssText()); |
566 else | 568 else |
567 result.append(m_firstY->cssText()); | 569 result.append(m_firstY->cssText()); |
568 wroteSomething = true; | 570 wroteSomething = true; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 if (m_firstX) | 687 if (m_firstX) |
686 secondPoint.setX(size.width() - firstPoint.x()); | 688 secondPoint.setX(size.width() - firstPoint.x()); |
687 if (m_firstY) | 689 if (m_firstY) |
688 secondPoint.setY(size.height() - firstPoint.y()); | 690 secondPoint.setY(size.height() - firstPoint.y()); |
689 break; | 691 break; |
690 case CSSLinearGradient: | 692 case CSSLinearGradient: |
691 if (m_firstX && m_firstY) { | 693 if (m_firstX && m_firstY) { |
692 // "Magic" corners, so the 50% line touches two corners. | 694 // "Magic" corners, so the 50% line touches two corners. |
693 float rise = size.width(); | 695 float rise = size.width(); |
694 float run = size.height(); | 696 float run = size.height(); |
695 if (m_firstX && m_firstX->getIdent() == CSSValueLeft) | 697 if (m_firstX && m_firstX->getValueID() == CSSValueLeft) |
696 run *= -1; | 698 run *= -1; |
697 if (m_firstY && m_firstY->getIdent() == CSSValueBottom) | 699 if (m_firstY && m_firstY->getValueID() == CSSValueBottom) |
698 rise *= -1; | 700 rise *= -1; |
699 // Compute angle, and flip it back to "bearing angle" degrees. | 701 // Compute angle, and flip it back to "bearing angle" degrees. |
700 float angle = 90 - rad2deg(atan2(rise, run)); | 702 float angle = 90 - rad2deg(atan2(rise, run)); |
701 endPointsFromAngle(angle, size, firstPoint, secondPoint, m_gradi
entType); | 703 endPointsFromAngle(angle, size, firstPoint, secondPoint, m_gradi
entType); |
702 } else if (m_firstX || m_firstY) { | 704 } else if (m_firstX || m_firstY) { |
703 secondPoint = computeEndPoint(m_firstX.get(), m_firstY.get(), re
nderer->style(), rootStyle, size); | 705 secondPoint = computeEndPoint(m_firstX.get(), m_firstY.get(), re
nderer->style(), rootStyle, size); |
704 if (m_firstX) | 706 if (m_firstX) |
705 firstPoint.setX(size.width() - secondPoint.x()); | 707 firstPoint.setX(size.width() - secondPoint.x()); |
706 if (m_firstY) | 708 if (m_firstY) |
707 firstPoint.setY(size.height() - secondPoint.y()); | 709 firstPoint.setY(size.height() - secondPoint.y()); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 } else { | 850 } else { |
849 if (m_repeating) | 851 if (m_repeating) |
850 result.appendLiteral("repeating-radial-gradient("); | 852 result.appendLiteral("repeating-radial-gradient("); |
851 else | 853 else |
852 result.appendLiteral("radial-gradient("); | 854 result.appendLiteral("radial-gradient("); |
853 | 855 |
854 bool wroteSomething = false; | 856 bool wroteSomething = false; |
855 | 857 |
856 // The only ambiguous case that needs an explicit shape to be provided | 858 // The only ambiguous case that needs an explicit shape to be provided |
857 // is when a sizing keyword is used (or all sizing is omitted). | 859 // is when a sizing keyword is used (or all sizing is omitted). |
858 if (m_shape && m_shape->getIdent() != CSSValueEllipse && (m_sizingBehavi
or || (!m_sizingBehavior && !m_endHorizontalSize))) { | 860 if (m_shape && m_shape->getValueID() != CSSValueEllipse && (m_sizingBeha
vior || (!m_sizingBehavior && !m_endHorizontalSize))) { |
859 result.appendLiteral("circle"); | 861 result.appendLiteral("circle"); |
860 wroteSomething = true; | 862 wroteSomething = true; |
861 } | 863 } |
862 | 864 |
863 if (m_sizingBehavior && m_sizingBehavior->getIdent() != CSSValueFarthest
Corner) { | 865 if (m_sizingBehavior && m_sizingBehavior->getValueID() != CSSValueFarthe
stCorner) { |
864 if (wroteSomething) | 866 if (wroteSomething) |
865 result.append(' '); | 867 result.append(' '); |
866 result.append(m_sizingBehavior->cssText()); | 868 result.append(m_sizingBehavior->cssText()); |
867 wroteSomething = true; | 869 wroteSomething = true; |
868 } else if (m_endHorizontalSize) { | 870 } else if (m_endHorizontalSize) { |
869 if (wroteSomething) | 871 if (wroteSomething) |
870 result.append(' '); | 872 result.append(' '); |
871 result.append(m_endHorizontalSize->cssText()); | 873 result.append(m_endHorizontalSize->cssText()); |
872 if (m_endVerticalSize) { | 874 if (m_endVerticalSize) { |
873 result.append(' '); | 875 result.append(' '); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1033 float width = size.width(); | 1035 float width = size.width(); |
1034 float height = size.height(); | 1036 float height = size.height(); |
1035 secondRadius = resolveRadius(m_endHorizontalSize.get(), renderer->style(
), rootStyle, &width); | 1037 secondRadius = resolveRadius(m_endHorizontalSize.get(), renderer->style(
), rootStyle, &width); |
1036 if (m_endVerticalSize) | 1038 if (m_endVerticalSize) |
1037 aspectRatio = secondRadius / resolveRadius(m_endVerticalSize.get(),
renderer->style(), rootStyle, &height); | 1039 aspectRatio = secondRadius / resolveRadius(m_endVerticalSize.get(),
renderer->style(), rootStyle, &height); |
1038 else | 1040 else |
1039 aspectRatio = 1; | 1041 aspectRatio = 1; |
1040 } else { | 1042 } else { |
1041 enum GradientShape { Circle, Ellipse }; | 1043 enum GradientShape { Circle, Ellipse }; |
1042 GradientShape shape = Ellipse; | 1044 GradientShape shape = Ellipse; |
1043 if ((m_shape && m_shape->getIdent() == CSSValueCircle) | 1045 if ((m_shape && m_shape->getValueID() == CSSValueCircle) |
1044 || (!m_shape && !m_sizingBehavior && m_endHorizontalSize && !m_endVe
rticalSize)) | 1046 || (!m_shape && !m_sizingBehavior && m_endHorizontalSize && !m_endVe
rticalSize)) |
1045 shape = Circle; | 1047 shape = Circle; |
1046 | 1048 |
1047 enum GradientFill { ClosestSide, ClosestCorner, FarthestSide, FarthestCo
rner }; | 1049 enum GradientFill { ClosestSide, ClosestCorner, FarthestSide, FarthestCo
rner }; |
1048 GradientFill fill = FarthestCorner; | 1050 GradientFill fill = FarthestCorner; |
1049 | 1051 |
1050 switch (m_sizingBehavior ? m_sizingBehavior->getIdent() : 0) { | 1052 switch (m_sizingBehavior ? m_sizingBehavior->getValueID() : 0) { |
1051 case CSSValueContain: | 1053 case CSSValueContain: |
1052 case CSSValueClosestSide: | 1054 case CSSValueClosestSide: |
1053 fill = ClosestSide; | 1055 fill = ClosestSide; |
1054 break; | 1056 break; |
1055 case CSSValueClosestCorner: | 1057 case CSSValueClosestCorner: |
1056 fill = ClosestCorner; | 1058 fill = ClosestCorner; |
1057 break; | 1059 break; |
1058 case CSSValueFarthestSide: | 1060 case CSSValueFarthestSide: |
1059 fill = FarthestSide; | 1061 fill = FarthestSide; |
1060 break; | 1062 break; |
1061 case CSSValueCover: | 1063 case CSSValueCover: |
1062 case CSSValueFarthestCorner: | 1064 case CSSValueFarthestCorner: |
1063 fill = FarthestCorner; | 1065 fill = FarthestCorner; |
1064 break; | 1066 break; |
| 1067 default: |
| 1068 break; |
1065 } | 1069 } |
1066 | 1070 |
1067 // Now compute the end radii based on the second point, shape and fill. | 1071 // Now compute the end radii based on the second point, shape and fill. |
1068 | 1072 |
1069 // Horizontal | 1073 // Horizontal |
1070 switch (fill) { | 1074 switch (fill) { |
1071 case ClosestSide: { | 1075 case ClosestSide: { |
1072 float xDist = min(secondPoint.x(), size.width() - secondPoint.x()); | 1076 float xDist = min(secondPoint.x(), size.width() - secondPoint.x()); |
1073 float yDist = min(secondPoint.y(), size.height() - secondPoint.y()); | 1077 float yDist = min(secondPoint.y(), size.height() - secondPoint.y()); |
1074 if (shape == Circle) { | 1078 if (shape == Circle) { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1195 CSSGradientValue::reportBaseClassMemoryUsage(memoryObjectInfo); | 1199 CSSGradientValue::reportBaseClassMemoryUsage(memoryObjectInfo); |
1196 info.addMember(m_firstRadius, "firstRadius"); | 1200 info.addMember(m_firstRadius, "firstRadius"); |
1197 info.addMember(m_secondRadius, "secondRadius"); | 1201 info.addMember(m_secondRadius, "secondRadius"); |
1198 info.addMember(m_shape, "shape"); | 1202 info.addMember(m_shape, "shape"); |
1199 info.addMember(m_sizingBehavior, "sizingBehavior"); | 1203 info.addMember(m_sizingBehavior, "sizingBehavior"); |
1200 info.addMember(m_endHorizontalSize, "endHorizontalSize"); | 1204 info.addMember(m_endHorizontalSize, "endHorizontalSize"); |
1201 info.addMember(m_endVerticalSize, "endVerticalSize"); | 1205 info.addMember(m_endVerticalSize, "endVerticalSize"); |
1202 } | 1206 } |
1203 | 1207 |
1204 } // namespace WebCore | 1208 } // namespace WebCore |
OLD | NEW |