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

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

Issue 200633005: [CSS Shapes] Remove deprecated shapes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix test expectations Created 6 years, 9 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 ASSERT_NOT_REACHED(); 64 ASSERT_NOT_REACHED();
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; 72 RefPtrWillBeRawPtr<CSSBasicShape> basicShapeValue;
73 switch (basicShape->type()) { 73 switch (basicShape->type()) {
74 case BasicShape::BasicShapeRectangleType: {
75 const BasicShapeRectangle* rectangle = static_cast<const BasicShapeRecta ngle*>(basicShape);
76 RefPtrWillBeRawPtr<CSSBasicShapeRectangle> rectangleValue = CSSBasicShap eRectangle::create();
77
78 rectangleValue->setX(pool.createValue(rectangle->x(), style));
79 rectangleValue->setY(pool.createValue(rectangle->y(), style));
80 rectangleValue->setWidth(pool.createValue(rectangle->width(), style));
81 rectangleValue->setHeight(pool.createValue(rectangle->height(), style));
82 rectangleValue->setRadiusX(pool.createValue(rectangle->cornerRadiusX(), style));
83 rectangleValue->setRadiusY(pool.createValue(rectangle->cornerRadiusY(), style));
84
85 basicShapeValue = rectangleValue.release();
86 break;
87 }
88 case BasicShape::DeprecatedBasicShapeCircleType: {
89 const DeprecatedBasicShapeCircle* circle = static_cast<const DeprecatedB asicShapeCircle*>(basicShape);
90 RefPtrWillBeRawPtr<CSSDeprecatedBasicShapeCircle> circleValue = CSSDepre catedBasicShapeCircle::create();
91
92 circleValue->setCenterX(pool.createValue(circle->centerX(), style));
93 circleValue->setCenterY(pool.createValue(circle->centerY(), style));
94 circleValue->setRadius(pool.createValue(circle->radius(), style));
95
96 basicShapeValue = circleValue.release();
97 break;
98 }
99 case BasicShape::BasicShapeCircleType: { 74 case BasicShape::BasicShapeCircleType: {
100 const BasicShapeCircle* circle = static_cast<const BasicShapeCircle*>(ba sicShape); 75 const BasicShapeCircle* circle = static_cast<const BasicShapeCircle*>(ba sicShape);
101 RefPtrWillBeRawPtr<CSSBasicShapeCircle> circleValue = CSSBasicShapeCircl e::create(); 76 RefPtrWillBeRawPtr<CSSBasicShapeCircle> circleValue = CSSBasicShapeCircl e::create();
102 77
103 circleValue->setCenterX(valueForCenterCoordinate(pool, style, circle->ce nterX(), HORIZONTAL)); 78 circleValue->setCenterX(valueForCenterCoordinate(pool, style, circle->ce nterX(), HORIZONTAL));
104 circleValue->setCenterY(valueForCenterCoordinate(pool, style, circle->ce nterY(), VERTICAL)); 79 circleValue->setCenterY(valueForCenterCoordinate(pool, style, circle->ce nterY(), VERTICAL));
105 circleValue->setRadius(basicShapeRadiusToCSSValue(pool, style, circle->r adius())); 80 circleValue->setRadius(basicShapeRadiusToCSSValue(pool, style, circle->r adius()));
106 basicShapeValue = circleValue.release(); 81 basicShapeValue = circleValue.release();
107 break; 82 break;
108 } 83 }
109 case BasicShape::DeprecatedBasicShapeEllipseType: {
110 const DeprecatedBasicShapeEllipse* ellipse = static_cast<const Deprecate dBasicShapeEllipse*>(basicShape);
111 RefPtrWillBeRawPtr<CSSDeprecatedBasicShapeEllipse> ellipseValue = CSSDep recatedBasicShapeEllipse::create();
112
113 ellipseValue->setCenterX(pool.createValue(ellipse->centerX(), style));
114 ellipseValue->setCenterY(pool.createValue(ellipse->centerY(), style));
115 ellipseValue->setRadiusX(pool.createValue(ellipse->radiusX(), style));
116 ellipseValue->setRadiusY(pool.createValue(ellipse->radiusY(), style));
117
118 basicShapeValue = ellipseValue.release();
119 break;
120 }
121 case BasicShape::BasicShapeEllipseType: { 84 case BasicShape::BasicShapeEllipseType: {
122 const BasicShapeEllipse* ellipse = static_cast<const BasicShapeEllipse*> (basicShape); 85 const BasicShapeEllipse* ellipse = static_cast<const BasicShapeEllipse*> (basicShape);
123 RefPtrWillBeRawPtr<CSSBasicShapeEllipse> ellipseValue = CSSBasicShapeEll ipse::create(); 86 RefPtrWillBeRawPtr<CSSBasicShapeEllipse> ellipseValue = CSSBasicShapeEll ipse::create();
124 87
125 ellipseValue->setCenterX(valueForCenterCoordinate(pool, style, ellipse-> centerX(), HORIZONTAL)); 88 ellipseValue->setCenterX(valueForCenterCoordinate(pool, style, ellipse-> centerX(), HORIZONTAL));
126 ellipseValue->setCenterY(valueForCenterCoordinate(pool, style, ellipse-> centerY(), VERTICAL)); 89 ellipseValue->setCenterY(valueForCenterCoordinate(pool, style, ellipse-> centerY(), VERTICAL));
127 ellipseValue->setRadiusX(basicShapeRadiusToCSSValue(pool, style, ellipse ->radiusX())); 90 ellipseValue->setRadiusX(basicShapeRadiusToCSSValue(pool, style, ellipse ->radiusX()));
128 ellipseValue->setRadiusY(basicShapeRadiusToCSSValue(pool, style, ellipse ->radiusY())); 91 ellipseValue->setRadiusY(basicShapeRadiusToCSSValue(pool, style, ellipse ->radiusY()));
129 basicShapeValue = ellipseValue.release(); 92 basicShapeValue = ellipseValue.release();
130 break; 93 break;
131 } 94 }
132 case BasicShape::BasicShapePolygonType: { 95 case BasicShape::BasicShapePolygonType: {
133 const BasicShapePolygon* polygon = static_cast<const BasicShapePolygon*> (basicShape); 96 const BasicShapePolygon* polygon = static_cast<const BasicShapePolygon*> (basicShape);
134 RefPtrWillBeRawPtr<CSSBasicShapePolygon> polygonValue = CSSBasicShapePol ygon::create(); 97 RefPtrWillBeRawPtr<CSSBasicShapePolygon> polygonValue = CSSBasicShapePol ygon::create();
135 98
136 polygonValue->setWindRule(polygon->windRule()); 99 polygonValue->setWindRule(polygon->windRule());
137 const Vector<Length>& values = polygon->values(); 100 const Vector<Length>& values = polygon->values();
138 for (unsigned i = 0; i < values.size(); i += 2) 101 for (unsigned i = 0; i < values.size(); i += 2)
139 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));
140 103
141 basicShapeValue = polygonValue.release(); 104 basicShapeValue = polygonValue.release();
142 break; 105 break;
143 } 106 }
144 case BasicShape::BasicShapeInsetRectangleType: {
145 const BasicShapeInsetRectangle* rectangle = static_cast<const BasicShape InsetRectangle*>(basicShape);
146 RefPtrWillBeRawPtr<CSSBasicShapeInsetRectangle> rectangleValue = CSSBasi cShapeInsetRectangle::create();
147
148 rectangleValue->setTop(cssValuePool().createValue(rectangle->top()));
149 rectangleValue->setRight(cssValuePool().createValue(rectangle->right())) ;
150 rectangleValue->setBottom(cssValuePool().createValue(rectangle->bottom() ));
151 rectangleValue->setLeft(cssValuePool().createValue(rectangle->left()));
152 rectangleValue->setRadiusX(cssValuePool().createValue(rectangle->cornerR adiusX()));
153 rectangleValue->setRadiusY(cssValuePool().createValue(rectangle->cornerR adiusY()));
154
155 basicShapeValue = rectangleValue.release();
156 break;
157 }
158 case BasicShape::BasicShapeInsetType: { 107 case BasicShape::BasicShapeInsetType: {
159 const BasicShapeInset* inset = static_cast<const BasicShapeInset*>(basic Shape); 108 const BasicShapeInset* inset = static_cast<const BasicShapeInset*>(basic Shape);
160 RefPtrWillBeRawPtr<CSSBasicShapeInset> insetValue = CSSBasicShapeInset:: create(); 109 RefPtrWillBeRawPtr<CSSBasicShapeInset> insetValue = CSSBasicShapeInset:: create();
161 110
162 insetValue->setTop(CSSPrimitiveValue::create(inset->top())); 111 insetValue->setTop(CSSPrimitiveValue::create(inset->top()));
163 insetValue->setRight(CSSPrimitiveValue::create(inset->right())); 112 insetValue->setRight(CSSPrimitiveValue::create(inset->right()));
164 insetValue->setBottom(CSSPrimitiveValue::create(inset->bottom())); 113 insetValue->setBottom(CSSPrimitiveValue::create(inset->bottom()));
165 insetValue->setLeft(CSSPrimitiveValue::create(inset->left())); 114 insetValue->setLeft(CSSPrimitiveValue::create(inset->left()));
166 115
167 insetValue->setTopLeftRadius(CSSPrimitiveValue::create(inset->topLeftRad ius())); 116 insetValue->setTopLeftRadius(CSSPrimitiveValue::create(inset->topLeftRad ius()));
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 } 201 }
253 202
254 return BasicShapeRadius(convertToLength(state, radius.get())); 203 return BasicShapeRadius(convertToLength(state, radius.get()));
255 } 204 }
256 205
257 PassRefPtr<BasicShape> basicShapeForValue(const StyleResolverState& state, const CSSBasicShape* basicShapeValue) 206 PassRefPtr<BasicShape> basicShapeForValue(const StyleResolverState& state, const CSSBasicShape* basicShapeValue)
258 { 207 {
259 RefPtr<BasicShape> basicShape; 208 RefPtr<BasicShape> basicShape;
260 209
261 switch (basicShapeValue->type()) { 210 switch (basicShapeValue->type()) {
262 case CSSBasicShape::CSSBasicShapeRectangleType: {
263 const CSSBasicShapeRectangle* rectValue = static_cast<const CSSBasicShap eRectangle *>(basicShapeValue);
264 RefPtr<BasicShapeRectangle> rect = BasicShapeRectangle::create();
265
266 rect->setX(convertToLength(state, rectValue->x()));
267 rect->setY(convertToLength(state, rectValue->y()));
268 rect->setWidth(convertToLength(state, rectValue->width()));
269 rect->setHeight(convertToLength(state, rectValue->height()));
270 if (rectValue->radiusX()) {
271 Length radiusX = convertToLength(state, rectValue->radiusX());
272 rect->setCornerRadiusX(radiusX);
273 if (rectValue->radiusY())
274 rect->setCornerRadiusY(convertToLength(state, rectValue->radiusY ()));
275 else
276 rect->setCornerRadiusY(radiusX);
277 } else {
278 rect->setCornerRadiusX(Length(0, Fixed));
279 rect->setCornerRadiusY(Length(0, Fixed));
280 }
281 basicShape = rect.release();
282 break;
283 }
284 case CSSBasicShape::CSSDeprecatedBasicShapeCircleType: {
285 const CSSDeprecatedBasicShapeCircle* circleValue = static_cast<const CSS DeprecatedBasicShapeCircle *>(basicShapeValue);
286 RefPtr<DeprecatedBasicShapeCircle> circle = DeprecatedBasicShapeCircle:: create();
287
288 circle->setCenterX(convertToLength(state, circleValue->centerX()));
289 circle->setCenterY(convertToLength(state, circleValue->centerY()));
290 circle->setRadius(convertToLength(state, circleValue->radius()));
291
292 basicShape = circle.release();
293 break;
294 }
295 case CSSBasicShape::CSSBasicShapeCircleType: { 211 case CSSBasicShape::CSSBasicShapeCircleType: {
296 const CSSBasicShapeCircle* circleValue = static_cast<const CSSBasicShape Circle *>(basicShapeValue); 212 const CSSBasicShapeCircle* circleValue = static_cast<const CSSBasicShape Circle *>(basicShapeValue);
297 RefPtr<BasicShapeCircle> circle = BasicShapeCircle::create(); 213 RefPtr<BasicShapeCircle> circle = BasicShapeCircle::create();
298 214
299 circle->setCenterX(convertToCenterCoordinate(state, circleValue->centerX ())); 215 circle->setCenterX(convertToCenterCoordinate(state, circleValue->centerX ()));
300 circle->setCenterY(convertToCenterCoordinate(state, circleValue->centerY ())); 216 circle->setCenterY(convertToCenterCoordinate(state, circleValue->centerY ()));
301 circle->setRadius(cssValueToBasicShapeRadius(state, circleValue->radius( ))); 217 circle->setRadius(cssValueToBasicShapeRadius(state, circleValue->radius( )));
302 218
303 basicShape = circle.release(); 219 basicShape = circle.release();
304 break; 220 break;
305 } 221 }
306 case CSSBasicShape::CSSDeprecatedBasicShapeEllipseType: {
307 const CSSDeprecatedBasicShapeEllipse* ellipseValue = static_cast<const C SSDeprecatedBasicShapeEllipse *>(basicShapeValue);
308 RefPtr<DeprecatedBasicShapeEllipse> ellipse = DeprecatedBasicShapeEllips e::create();
309
310 ellipse->setCenterX(convertToLength(state, ellipseValue->centerX()));
311 ellipse->setCenterY(convertToLength(state, ellipseValue->centerY()));
312 ellipse->setRadiusX(convertToLength(state, ellipseValue->radiusX()));
313 ellipse->setRadiusY(convertToLength(state, ellipseValue->radiusY()));
314
315 basicShape = ellipse.release();
316 break;
317 }
318 case CSSBasicShape::CSSBasicShapeEllipseType: { 222 case CSSBasicShape::CSSBasicShapeEllipseType: {
319 const CSSBasicShapeEllipse* ellipseValue = static_cast<const CSSBasicSha peEllipse *>(basicShapeValue); 223 const CSSBasicShapeEllipse* ellipseValue = static_cast<const CSSBasicSha peEllipse *>(basicShapeValue);
320 RefPtr<BasicShapeEllipse> ellipse = BasicShapeEllipse::create(); 224 RefPtr<BasicShapeEllipse> ellipse = BasicShapeEllipse::create();
321 225
322 ellipse->setCenterX(convertToCenterCoordinate(state, ellipseValue->cente rX())); 226 ellipse->setCenterX(convertToCenterCoordinate(state, ellipseValue->cente rX()));
323 ellipse->setCenterY(convertToCenterCoordinate(state, ellipseValue->cente rY())); 227 ellipse->setCenterY(convertToCenterCoordinate(state, ellipseValue->cente rY()));
324 ellipse->setRadiusX(cssValueToBasicShapeRadius(state, ellipseValue->radi usX())); 228 ellipse->setRadiusX(cssValueToBasicShapeRadius(state, ellipseValue->radi usX()));
325 ellipse->setRadiusY(cssValueToBasicShapeRadius(state, ellipseValue->radi usY())); 229 ellipse->setRadiusY(cssValueToBasicShapeRadius(state, ellipseValue->radi usY()));
326 230
327 basicShape = ellipse.release(); 231 basicShape = ellipse.release();
328 break; 232 break;
329 } 233 }
330 case CSSBasicShape::CSSBasicShapePolygonType: { 234 case CSSBasicShape::CSSBasicShapePolygonType: {
331 const CSSBasicShapePolygon* polygonValue = static_cast<const CSSBasicSha pePolygon *>(basicShapeValue); 235 const CSSBasicShapePolygon* polygonValue = static_cast<const CSSBasicSha pePolygon *>(basicShapeValue);
332 RefPtr<BasicShapePolygon> polygon = BasicShapePolygon::create(); 236 RefPtr<BasicShapePolygon> polygon = BasicShapePolygon::create();
333 237
334 polygon->setWindRule(polygonValue->windRule()); 238 polygon->setWindRule(polygonValue->windRule());
335 const WillBeHeapVector<RefPtrWillBeMember<CSSPrimitiveValue> >& values = polygonValue->values(); 239 const WillBeHeapVector<RefPtrWillBeMember<CSSPrimitiveValue> >& values = polygonValue->values();
336 for (unsigned i = 0; i < values.size(); i += 2) 240 for (unsigned i = 0; i < values.size(); i += 2)
337 polygon->appendPoint(convertToLength(state, values.at(i).get()), con vertToLength(state, values.at(i + 1).get())); 241 polygon->appendPoint(convertToLength(state, values.at(i).get()), con vertToLength(state, values.at(i + 1).get()));
338 242
339 basicShape = polygon.release(); 243 basicShape = polygon.release();
340 break; 244 break;
341 } 245 }
342 case CSSBasicShape::CSSBasicShapeInsetRectangleType: {
343 const CSSBasicShapeInsetRectangle* rectValue = static_cast<const CSSBasi cShapeInsetRectangle *>(basicShapeValue);
344 RefPtr<BasicShapeInsetRectangle> rect = BasicShapeInsetRectangle::create ();
345
346 rect->setTop(convertToLength(state, rectValue->top()));
347 rect->setRight(convertToLength(state, rectValue->right()));
348 rect->setBottom(convertToLength(state, rectValue->bottom()));
349 rect->setLeft(convertToLength(state, rectValue->left()));
350 if (rectValue->radiusX()) {
351 Length radiusX = convertToLength(state, rectValue->radiusX());
352 rect->setCornerRadiusX(radiusX);
353 if (rectValue->radiusY())
354 rect->setCornerRadiusY(convertToLength(state, rectValue->radiusY ()));
355 else
356 rect->setCornerRadiusY(radiusX);
357 } else {
358 rect->setCornerRadiusX(Length(0, Fixed));
359 rect->setCornerRadiusY(Length(0, Fixed));
360 }
361 basicShape = rect.release();
362 break;
363 }
364 case CSSBasicShape::CSSBasicShapeInsetType: { 246 case CSSBasicShape::CSSBasicShapeInsetType: {
365 const CSSBasicShapeInset* rectValue = static_cast<const CSSBasicShapeIns et* >(basicShapeValue); 247 const CSSBasicShapeInset* rectValue = static_cast<const CSSBasicShapeIns et* >(basicShapeValue);
366 RefPtr<BasicShapeInset> rect = BasicShapeInset::create(); 248 RefPtr<BasicShapeInset> rect = BasicShapeInset::create();
367 249
368 rect->setTop(convertToLength(state, rectValue->top())); 250 rect->setTop(convertToLength(state, rectValue->top()));
369 rect->setRight(convertToLength(state, rectValue->right())); 251 rect->setRight(convertToLength(state, rectValue->right()));
370 rect->setBottom(convertToLength(state, rectValue->bottom())); 252 rect->setBottom(convertToLength(state, rectValue->bottom()));
371 rect->setLeft(convertToLength(state, rectValue->left())); 253 rect->setLeft(convertToLength(state, rectValue->left()));
372 254
373 rect->setTopLeftRadius(convertToLengthSize(state, rectValue->topLeftRadi us())); 255 rect->setTopLeftRadius(convertToLengthSize(state, rectValue->topLeftRadi us()));
(...skipping 15 matching lines...) Expand all
389 { 271 {
390 FloatPoint p; 272 FloatPoint p;
391 float offset = floatValueForLength(centerX.length(), boxSize.width()); 273 float offset = floatValueForLength(centerX.length(), boxSize.width());
392 p.setX(centerX.direction() == BasicShapeCenterCoordinate::TopLeft ? offset : boxSize.width() - offset); 274 p.setX(centerX.direction() == BasicShapeCenterCoordinate::TopLeft ? offset : boxSize.width() - offset);
393 offset = floatValueForLength(centerY.length(), boxSize.height()); 275 offset = floatValueForLength(centerY.length(), boxSize.height());
394 p.setY(centerY.direction() == BasicShapeCenterCoordinate::TopLeft ? offset : boxSize.height() - offset); 276 p.setY(centerY.direction() == BasicShapeCenterCoordinate::TopLeft ? offset : boxSize.height() - offset);
395 return p; 277 return p;
396 } 278 }
397 279
398 } 280 }
OLDNEW
« no previous file with comments | « LayoutTests/webexposed/nonstable-css-properties-expected.txt ('k') | Source/core/css/CSSBasicShapes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698