Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: Source/core/rendering/style/BasicShapes.cpp

Issue 144373002: [CSS Shapes] Basic shapes' computed position should be a horizontal and vertical offset (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Try to fix tests Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 return result.release(); 382 return result.release();
369 } 383 }
370 384
371 bool BasicShapeInsetRectangle::operator==(const BasicShape& o) const 385 bool BasicShapeInsetRectangle::operator==(const BasicShape& o) const
372 { 386 {
373 if (!isSameType(o)) 387 if (!isSameType(o))
374 return false; 388 return false;
375 const BasicShapeInsetRectangle& other = toBasicShapeInsetRectangle(o); 389 const BasicShapeInsetRectangle& other = toBasicShapeInsetRectangle(o);
376 return m_right == other.m_right && m_top == other.m_top && m_bottom == other .m_bottom && m_left == other.m_left && m_cornerRadiusX == other.m_cornerRadiusX && m_cornerRadiusY == other.m_cornerRadiusY; 390 return m_right == other.m_right && m_top == other.m_top && m_bottom == other .m_bottom && m_left == other.m_left && m_cornerRadiusX == other.m_cornerRadiusX && m_cornerRadiusY == other.m_cornerRadiusY;
377 } 391 }
392
Bear Travis 2014/01/23 22:04:42 Extra newline.
378 } 393 }
OLDNEW
« Source/core/rendering/style/BasicShapes.h ('K') | « Source/core/rendering/style/BasicShapes.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698