OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2012 Adobe Systems Incorporated. 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 * | 7 * |
8 * 1. Redistributions of source code must retain the above | 8 * 1. Redistributions of source code must retain the above |
9 * copyright notice, this list of conditions and the following | 9 * copyright notice, this list of conditions and the following |
10 * disclaimer. | 10 * disclaimer. |
(...skipping 13 matching lines...) Expand all Loading... |
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR |
25 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF | 25 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF |
26 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 26 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
27 * SUCH DAMAGE. | 27 * SUCH DAMAGE. |
28 */ | 28 */ |
29 | 29 |
30 #include "config.h" | 30 #include "config.h" |
31 #include "core/rendering/style/BasicShapes.h" | 31 #include "core/rendering/style/BasicShapes.h" |
32 | 32 |
33 #include "core/css/BasicShapeFunctions.h" | 33 #include "core/css/BasicShapeFunctions.h" |
| 34 #include "platform/CalculationValue.h" |
34 #include "platform/LengthFunctions.h" | 35 #include "platform/LengthFunctions.h" |
35 #include "platform/geometry/FloatRect.h" | 36 #include "platform/geometry/FloatRect.h" |
36 #include "platform/graphics/Path.h" | 37 #include "platform/graphics/Path.h" |
37 | 38 |
38 namespace WebCore { | 39 namespace WebCore { |
39 | 40 |
| 41 void BasicShapeCenterCoordinate::updateComputedLength() |
| 42 { |
| 43 if (m_direction == TopLeft) { |
| 44 m_computedLength = m_length.isUndefined() ? Length(0, Fixed) : m_length; |
| 45 return; |
| 46 } |
| 47 if (m_length.isUndefined()) { |
| 48 m_computedLength = Length(100, Percent); |
| 49 return; |
| 50 } |
| 51 |
| 52 OwnPtr<CalcExpressionLength> lhs = adoptPtr(new CalcExpressionLength(Length(
100, Percent))); |
| 53 OwnPtr<CalcExpressionLength> rhs = adoptPtr(new CalcExpressionLength(m_lengt
h)); |
| 54 OwnPtr<CalcExpressionBinaryOperation> op = adoptPtr(new CalcExpressionBinary
Operation(lhs.release(), rhs.release(), CalcSubtract)); |
| 55 m_computedLength = Length(CalculationValue::create(op.release(), ValueRangeA
ll)); |
| 56 } |
| 57 |
40 bool BasicShape::canBlend(const BasicShape* other) const | 58 bool BasicShape::canBlend(const BasicShape* other) const |
41 { | 59 { |
42 // FIXME: Support animations between different shapes in the future. | 60 // FIXME: Support animations between different shapes in the future. |
43 if (!other || !isSameType(*other)) | 61 if (!other || !isSameType(*other)) |
44 return false; | 62 return false; |
45 | 63 |
46 // Just polygons with same number of vertices can be animated. | 64 // Just polygons with same number of vertices can be animated. |
47 if (type() == BasicShape::BasicShapePolygonType | 65 if (type() == BasicShape::BasicShapePolygonType |
48 && (static_cast<const BasicShapePolygon*>(this)->values().size() != stat
ic_cast<const BasicShapePolygon*>(other)->values().size() | 66 && (static_cast<const BasicShapePolygon*>(this)->values().size() != stat
ic_cast<const BasicShapePolygon*>(other)->values().size() |
49 || static_cast<const BasicShapePolygon*>(this)->windRule() != static_cas
t<const BasicShapePolygon*>(other)->windRule())) | 67 || static_cast<const BasicShapePolygon*>(this)->windRule() != static_cas
t<const BasicShapePolygon*>(other)->windRule())) |
50 return false; | 68 return false; |
51 | 69 |
52 // Circles with keywords for radii or center coordinates cannot be animated. | 70 // Circles with keywords for radii or center coordinates cannot be animated. |
53 if (type() == BasicShape::BasicShapeCircleType) { | 71 if (type() == BasicShape::BasicShapeCircleType) { |
54 const BasicShapeCircle* thisCircle = static_cast<const BasicShapeCircle*
>(this); | 72 const BasicShapeCircle* thisCircle = static_cast<const BasicShapeCircle*
>(this); |
55 const BasicShapeCircle* otherCircle = static_cast<const BasicShapeCircle
*>(other); | 73 const BasicShapeCircle* otherCircle = static_cast<const BasicShapeCircle
*>(other); |
56 if (!thisCircle->radius().canBlend(otherCircle->radius()) | 74 if (!thisCircle->radius().canBlend(otherCircle->radius())) |
57 || !thisCircle->centerX().canBlend(otherCircle->centerX()) | |
58 || !thisCircle->centerY().canBlend(otherCircle->centerY())) | |
59 return false; | 75 return false; |
60 } | 76 } |
61 | 77 |
62 // Ellipses with keywords for radii or center coordinates cannot be animated
. | 78 // Ellipses with keywords for radii or center coordinates cannot be animated
. |
63 if (type() != BasicShape::BasicShapeEllipseType) | 79 if (type() != BasicShape::BasicShapeEllipseType) |
64 return true; | 80 return true; |
65 | 81 |
66 const BasicShapeEllipse* thisEllipse = static_cast<const BasicShapeEllipse*>
(this); | 82 const BasicShapeEllipse* thisEllipse = static_cast<const BasicShapeEllipse*>
(this); |
67 const BasicShapeEllipse* otherEllipse = static_cast<const BasicShapeEllipse*
>(other); | 83 const BasicShapeEllipse* otherEllipse = static_cast<const BasicShapeEllipse*
>(other); |
68 return (thisEllipse->radiusX().canBlend(otherEllipse->radiusX()) | 84 return (thisEllipse->radiusX().canBlend(otherEllipse->radiusX()) |
69 && thisEllipse->radiusY().canBlend(otherEllipse->radiusY()) | 85 && thisEllipse->radiusY().canBlend(otherEllipse->radiusY())); |
70 && thisEllipse->centerX().canBlend(otherEllipse->centerX()) | |
71 && thisEllipse->centerY().canBlend(otherEllipse->centerY())); | |
72 } | 86 } |
73 | 87 |
74 void BasicShapeRectangle::path(Path& path, const FloatRect& boundingBox) | 88 void BasicShapeRectangle::path(Path& path, const FloatRect& boundingBox) |
75 { | 89 { |
76 ASSERT(path.isEmpty()); | 90 ASSERT(path.isEmpty()); |
77 path.addRoundedRect( | 91 path.addRoundedRect( |
78 FloatRect( | 92 FloatRect( |
79 floatValueForLength(m_x, boundingBox.width()) + boundingBox.x(), | 93 floatValueForLength(m_x, boundingBox.width()) + boundingBox.x(), |
80 floatValueForLength(m_y, boundingBox.height()) + boundingBox.y(), | 94 floatValueForLength(m_y, boundingBox.height()) + boundingBox.y(), |
81 floatValueForLength(m_width, boundingBox.width()), | 95 floatValueForLength(m_width, boundingBox.width()), |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 && m_top == other.m_top | 431 && m_top == other.m_top |
418 && m_bottom == other.m_bottom | 432 && m_bottom == other.m_bottom |
419 && m_left == other.m_left | 433 && m_left == other.m_left |
420 && m_topLeftRadius == other.m_topLeftRadius | 434 && m_topLeftRadius == other.m_topLeftRadius |
421 && m_topRightRadius == other.m_topRightRadius | 435 && m_topRightRadius == other.m_topRightRadius |
422 && m_bottomRightRadius == other.m_bottomRightRadius | 436 && m_bottomRightRadius == other.m_bottomRightRadius |
423 && m_bottomLeftRadius == other.m_bottomLeftRadius; | 437 && m_bottomLeftRadius == other.m_bottomLeftRadius; |
424 } | 438 } |
425 | 439 |
426 } | 440 } |
OLD | NEW |