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

Side by Side Diff: Source/core/css/BasicShapeFunctions.cpp

Issue 370073002: Use type cast macro for AnimatableLengthPoint|3D instead of manual toFoo() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased Created 6 years, 5 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 return nullptr; 65 return nullptr;
66 } 66 }
67 67
68 PassRefPtrWillBeRawPtr<CSSValue> valueForBasicShape(const RenderStyle& style, co nst BasicShape* basicShape) 68 PassRefPtrWillBeRawPtr<CSSValue> valueForBasicShape(const RenderStyle& style, co nst BasicShape* basicShape)
69 { 69 {
70 CSSValuePool& pool = cssValuePool(); 70 CSSValuePool& pool = cssValuePool();
71 71
72 RefPtrWillBeRawPtr<CSSBasicShape> basicShapeValue = nullptr; 72 RefPtrWillBeRawPtr<CSSBasicShape> basicShapeValue = nullptr;
73 switch (basicShape->type()) { 73 switch (basicShape->type()) {
74 case BasicShape::BasicShapeCircleType: { 74 case BasicShape::BasicShapeCircleType: {
75 const BasicShapeCircle* circle = static_cast<const BasicShapeCircle*>(ba sicShape); 75 const BasicShapeCircle* circle = toBasicShapeCircle(basicShape);
76 RefPtrWillBeRawPtr<CSSBasicShapeCircle> circleValue = CSSBasicShapeCircl e::create(); 76 RefPtrWillBeRawPtr<CSSBasicShapeCircle> circleValue = CSSBasicShapeCircl e::create();
77 77
78 circleValue->setCenterX(valueForCenterCoordinate(pool, style, circle->ce nterX(), HORIZONTAL)); 78 circleValue->setCenterX(valueForCenterCoordinate(pool, style, circle->ce nterX(), HORIZONTAL));
79 circleValue->setCenterY(valueForCenterCoordinate(pool, style, circle->ce nterY(), VERTICAL)); 79 circleValue->setCenterY(valueForCenterCoordinate(pool, style, circle->ce nterY(), VERTICAL));
80 circleValue->setRadius(basicShapeRadiusToCSSValue(pool, style, circle->r adius())); 80 circleValue->setRadius(basicShapeRadiusToCSSValue(pool, style, circle->r adius()));
81 basicShapeValue = circleValue.release(); 81 basicShapeValue = circleValue.release();
82 break; 82 break;
83 } 83 }
84 case BasicShape::BasicShapeEllipseType: { 84 case BasicShape::BasicShapeEllipseType: {
85 const BasicShapeEllipse* ellipse = static_cast<const BasicShapeEllipse*> (basicShape); 85 const BasicShapeEllipse* ellipse = toBasicShapeEllipse(basicShape);
86 RefPtrWillBeRawPtr<CSSBasicShapeEllipse> ellipseValue = CSSBasicShapeEll ipse::create(); 86 RefPtrWillBeRawPtr<CSSBasicShapeEllipse> ellipseValue = CSSBasicShapeEll ipse::create();
87 87
88 ellipseValue->setCenterX(valueForCenterCoordinate(pool, style, ellipse-> centerX(), HORIZONTAL)); 88 ellipseValue->setCenterX(valueForCenterCoordinate(pool, style, ellipse-> centerX(), HORIZONTAL));
89 ellipseValue->setCenterY(valueForCenterCoordinate(pool, style, ellipse-> centerY(), VERTICAL)); 89 ellipseValue->setCenterY(valueForCenterCoordinate(pool, style, ellipse-> centerY(), VERTICAL));
90 ellipseValue->setRadiusX(basicShapeRadiusToCSSValue(pool, style, ellipse ->radiusX())); 90 ellipseValue->setRadiusX(basicShapeRadiusToCSSValue(pool, style, ellipse ->radiusX()));
91 ellipseValue->setRadiusY(basicShapeRadiusToCSSValue(pool, style, ellipse ->radiusY())); 91 ellipseValue->setRadiusY(basicShapeRadiusToCSSValue(pool, style, ellipse ->radiusY()));
92 basicShapeValue = ellipseValue.release(); 92 basicShapeValue = ellipseValue.release();
93 break; 93 break;
94 } 94 }
95 case BasicShape::BasicShapePolygonType: { 95 case BasicShape::BasicShapePolygonType: {
96 const BasicShapePolygon* polygon = static_cast<const BasicShapePolygon*> (basicShape); 96 const BasicShapePolygon* polygon = toBasicShapePolygon(basicShape);
97 RefPtrWillBeRawPtr<CSSBasicShapePolygon> polygonValue = CSSBasicShapePol ygon::create(); 97 RefPtrWillBeRawPtr<CSSBasicShapePolygon> polygonValue = CSSBasicShapePol ygon::create();
98 98
99 polygonValue->setWindRule(polygon->windRule()); 99 polygonValue->setWindRule(polygon->windRule());
100 const Vector<Length>& values = polygon->values(); 100 const Vector<Length>& values = polygon->values();
101 for (unsigned i = 0; i < values.size(); i += 2) 101 for (unsigned i = 0; i < values.size(); i += 2)
102 polygonValue->appendPoint(pool.createValue(values.at(i), style), poo l.createValue(values.at(i + 1), style)); 102 polygonValue->appendPoint(pool.createValue(values.at(i), style), poo l.createValue(values.at(i + 1), style));
103 103
104 basicShapeValue = polygonValue.release(); 104 basicShapeValue = polygonValue.release();
105 break; 105 break;
106 } 106 }
107 case BasicShape::BasicShapeInsetType: { 107 case BasicShape::BasicShapeInsetType: {
108 const BasicShapeInset* inset = static_cast<const BasicShapeInset*>(basic Shape); 108 const BasicShapeInset* inset = toBasicShapeInset(basicShape);
109 RefPtrWillBeRawPtr<CSSBasicShapeInset> insetValue = CSSBasicShapeInset:: create(); 109 RefPtrWillBeRawPtr<CSSBasicShapeInset> insetValue = CSSBasicShapeInset:: create();
110 110
111 insetValue->setTop(pool.createValue(inset->top(), style)); 111 insetValue->setTop(pool.createValue(inset->top(), style));
112 insetValue->setRight(pool.createValue(inset->right(), style)); 112 insetValue->setRight(pool.createValue(inset->right(), style));
113 insetValue->setBottom(pool.createValue(inset->bottom(), style)); 113 insetValue->setBottom(pool.createValue(inset->bottom(), style));
114 insetValue->setLeft(pool.createValue(inset->left(), style)); 114 insetValue->setLeft(pool.createValue(inset->left(), style));
115 115
116 insetValue->setTopLeftRadius(CSSPrimitiveValue::create(inset->topLeftRad ius(), style)); 116 insetValue->setTopLeftRadius(CSSPrimitiveValue::create(inset->topLeftRad ius(), style));
117 insetValue->setTopRightRadius(CSSPrimitiveValue::create(inset->topRightR adius(), style)); 117 insetValue->setTopRightRadius(CSSPrimitiveValue::create(inset->topRightR adius(), style));
118 insetValue->setBottomRightRadius(CSSPrimitiveValue::create(inset->bottom RightRadius(), style)); 118 insetValue->setBottomRightRadius(CSSPrimitiveValue::create(inset->bottom RightRadius(), style));
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 { 271 {
272 FloatPoint p; 272 FloatPoint p;
273 float offset = floatValueForLength(centerX.length(), boxSize.width()); 273 float offset = floatValueForLength(centerX.length(), boxSize.width());
274 p.setX(centerX.direction() == BasicShapeCenterCoordinate::TopLeft ? offset : boxSize.width() - offset); 274 p.setX(centerX.direction() == BasicShapeCenterCoordinate::TopLeft ? offset : boxSize.width() - offset);
275 offset = floatValueForLength(centerY.length(), boxSize.height()); 275 offset = floatValueForLength(centerY.length(), boxSize.height());
276 p.setY(centerY.direction() == BasicShapeCenterCoordinate::TopLeft ? offset : boxSize.height() - offset); 276 p.setY(centerY.direction() == BasicShapeCenterCoordinate::TopLeft ? offset : boxSize.height() - offset);
277 return p; 277 return p;
278 } 278 }
279 279
280 } 280 }
OLDNEW
« no previous file with comments | « Source/core/animation/interpolation/LegacyStyleInterpolation.h ('k') | Source/core/css/parser/CSSPropertyParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698