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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 21 matching lines...) Expand all
32 #include "core/css/CSSBasicShapeValues.h" 32 #include "core/css/CSSBasicShapeValues.h"
33 #include "core/css/CSSPrimitiveValueMappings.h" 33 #include "core/css/CSSPrimitiveValueMappings.h"
34 #include "core/css/CSSValuePair.h" 34 #include "core/css/CSSValuePair.h"
35 #include "core/css/CSSValuePool.h" 35 #include "core/css/CSSValuePool.h"
36 #include "core/css/resolver/StyleResolverState.h" 36 #include "core/css/resolver/StyleResolverState.h"
37 #include "core/style/BasicShapes.h" 37 #include "core/style/BasicShapes.h"
38 #include "core/style/ComputedStyle.h" 38 #include "core/style/ComputedStyle.h"
39 39
40 namespace blink { 40 namespace blink {
41 41
42 static PassRefPtrWillBeRawPtr<CSSValue> valueForCenterCoordinate(CSSValuePool& p ool, const ComputedStyle& style, const BasicShapeCenterCoordinate& center, EBoxO rient orientation) 42 static RawPtr<CSSValue> valueForCenterCoordinate(CSSValuePool& pool, const Compu tedStyle& style, const BasicShapeCenterCoordinate& center, EBoxOrient orientatio n)
43 { 43 {
44 if (center.direction() == BasicShapeCenterCoordinate::TopLeft) 44 if (center.direction() == BasicShapeCenterCoordinate::TopLeft)
45 return pool.createValue(center.length(), style); 45 return pool.createValue(center.length(), style);
46 46
47 CSSValueID keyword = orientation == HORIZONTAL ? CSSValueRight : CSSValueBot tom; 47 CSSValueID keyword = orientation == HORIZONTAL ? CSSValueRight : CSSValueBot tom;
48 48
49 return CSSValuePair::create(pool.createIdentifierValue(keyword), pool.create Value(center.length(), style), CSSValuePair::DropIdenticalValues); 49 return CSSValuePair::create(pool.createIdentifierValue(keyword), pool.create Value(center.length(), style), CSSValuePair::DropIdenticalValues);
50 } 50 }
51 51
52 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> basicShapeRadiusToCSSValue(CSSV aluePool& pool, const ComputedStyle& style, const BasicShapeRadius& radius) 52 static RawPtr<CSSPrimitiveValue> basicShapeRadiusToCSSValue(CSSValuePool& pool, const ComputedStyle& style, const BasicShapeRadius& radius)
53 { 53 {
54 switch (radius.type()) { 54 switch (radius.type()) {
55 case BasicShapeRadius::Value: 55 case BasicShapeRadius::Value:
56 return pool.createValue(radius.value(), style); 56 return pool.createValue(radius.value(), style);
57 case BasicShapeRadius::ClosestSide: 57 case BasicShapeRadius::ClosestSide:
58 return pool.createIdentifierValue(CSSValueClosestSide); 58 return pool.createIdentifierValue(CSSValueClosestSide);
59 case BasicShapeRadius::FarthestSide: 59 case BasicShapeRadius::FarthestSide:
60 return pool.createIdentifierValue(CSSValueFarthestSide); 60 return pool.createIdentifierValue(CSSValueFarthestSide);
61 } 61 }
62 62
63 ASSERT_NOT_REACHED(); 63 ASSERT_NOT_REACHED();
64 return nullptr; 64 return nullptr;
65 } 65 }
66 66
67 PassRefPtrWillBeRawPtr<CSSValue> valueForBasicShape(const ComputedStyle& style, const BasicShape* basicShape) 67 RawPtr<CSSValue> valueForBasicShape(const ComputedStyle& style, const BasicShape * basicShape)
68 { 68 {
69 CSSValuePool& pool = cssValuePool(); 69 CSSValuePool& pool = cssValuePool();
70 switch (basicShape->type()) { 70 switch (basicShape->type()) {
71 case BasicShape::BasicShapeCircleType: { 71 case BasicShape::BasicShapeCircleType: {
72 const BasicShapeCircle* circle = toBasicShapeCircle(basicShape); 72 const BasicShapeCircle* circle = toBasicShapeCircle(basicShape);
73 RefPtrWillBeRawPtr<CSSBasicShapeCircleValue> circleValue = CSSBasicShape CircleValue::create(); 73 RawPtr<CSSBasicShapeCircleValue> circleValue = CSSBasicShapeCircleValue: :create();
74 74
75 circleValue->setCenterX(valueForCenterCoordinate(pool, style, circle->ce nterX(), HORIZONTAL)); 75 circleValue->setCenterX(valueForCenterCoordinate(pool, style, circle->ce nterX(), HORIZONTAL));
76 circleValue->setCenterY(valueForCenterCoordinate(pool, style, circle->ce nterY(), VERTICAL)); 76 circleValue->setCenterY(valueForCenterCoordinate(pool, style, circle->ce nterY(), VERTICAL));
77 circleValue->setRadius(basicShapeRadiusToCSSValue(pool, style, circle->r adius())); 77 circleValue->setRadius(basicShapeRadiusToCSSValue(pool, style, circle->r adius()));
78 return circleValue.release(); 78 return circleValue.release();
79 } 79 }
80 case BasicShape::BasicShapeEllipseType: { 80 case BasicShape::BasicShapeEllipseType: {
81 const BasicShapeEllipse* ellipse = toBasicShapeEllipse(basicShape); 81 const BasicShapeEllipse* ellipse = toBasicShapeEllipse(basicShape);
82 RefPtrWillBeRawPtr<CSSBasicShapeEllipseValue> ellipseValue = CSSBasicSha peEllipseValue::create(); 82 RawPtr<CSSBasicShapeEllipseValue> ellipseValue = CSSBasicShapeEllipseVal ue::create();
83 83
84 ellipseValue->setCenterX(valueForCenterCoordinate(pool, style, ellipse-> centerX(), HORIZONTAL)); 84 ellipseValue->setCenterX(valueForCenterCoordinate(pool, style, ellipse-> centerX(), HORIZONTAL));
85 ellipseValue->setCenterY(valueForCenterCoordinate(pool, style, ellipse-> centerY(), VERTICAL)); 85 ellipseValue->setCenterY(valueForCenterCoordinate(pool, style, ellipse-> centerY(), VERTICAL));
86 ellipseValue->setRadiusX(basicShapeRadiusToCSSValue(pool, style, ellipse ->radiusX())); 86 ellipseValue->setRadiusX(basicShapeRadiusToCSSValue(pool, style, ellipse ->radiusX()));
87 ellipseValue->setRadiusY(basicShapeRadiusToCSSValue(pool, style, ellipse ->radiusY())); 87 ellipseValue->setRadiusY(basicShapeRadiusToCSSValue(pool, style, ellipse ->radiusY()));
88 return ellipseValue.release(); 88 return ellipseValue.release();
89 } 89 }
90 case BasicShape::BasicShapePolygonType: { 90 case BasicShape::BasicShapePolygonType: {
91 const BasicShapePolygon* polygon = toBasicShapePolygon(basicShape); 91 const BasicShapePolygon* polygon = toBasicShapePolygon(basicShape);
92 RefPtrWillBeRawPtr<CSSBasicShapePolygonValue> polygonValue = CSSBasicSha pePolygonValue::create(); 92 RawPtr<CSSBasicShapePolygonValue> polygonValue = CSSBasicShapePolygonVal ue::create();
93 93
94 polygonValue->setWindRule(polygon->windRule()); 94 polygonValue->setWindRule(polygon->windRule());
95 const Vector<Length>& values = polygon->values(); 95 const Vector<Length>& values = polygon->values();
96 for (unsigned i = 0; i < values.size(); i += 2) 96 for (unsigned i = 0; i < values.size(); i += 2)
97 polygonValue->appendPoint(pool.createValue(values.at(i), style), poo l.createValue(values.at(i + 1), style)); 97 polygonValue->appendPoint(pool.createValue(values.at(i), style), poo l.createValue(values.at(i + 1), style));
98 98
99 return polygonValue.release(); 99 return polygonValue.release();
100 } 100 }
101 case BasicShape::BasicShapeInsetType: { 101 case BasicShape::BasicShapeInsetType: {
102 const BasicShapeInset* inset = toBasicShapeInset(basicShape); 102 const BasicShapeInset* inset = toBasicShapeInset(basicShape);
103 RefPtrWillBeRawPtr<CSSBasicShapeInsetValue> insetValue = CSSBasicShapeIn setValue::create(); 103 RawPtr<CSSBasicShapeInsetValue> insetValue = CSSBasicShapeInsetValue::cr eate();
104 104
105 insetValue->setTop(pool.createValue(inset->top(), style)); 105 insetValue->setTop(pool.createValue(inset->top(), style));
106 insetValue->setRight(pool.createValue(inset->right(), style)); 106 insetValue->setRight(pool.createValue(inset->right(), style));
107 insetValue->setBottom(pool.createValue(inset->bottom(), style)); 107 insetValue->setBottom(pool.createValue(inset->bottom(), style));
108 insetValue->setLeft(pool.createValue(inset->left(), style)); 108 insetValue->setLeft(pool.createValue(inset->left(), style));
109 109
110 insetValue->setTopLeftRadius(CSSValuePair::create(inset->topLeftRadius() , style)); 110 insetValue->setTopLeftRadius(CSSValuePair::create(inset->topLeftRadius() , style));
111 insetValue->setTopRightRadius(CSSValuePair::create(inset->topRightRadius (), style)); 111 insetValue->setTopRightRadius(CSSValuePair::create(inset->topRightRadius (), style));
112 insetValue->setBottomRightRadius(CSSValuePair::create(inset->bottomRight Radius(), style)); 112 insetValue->setBottomRightRadius(CSSValuePair::create(inset->bottomRight Radius(), style));
113 insetValue->setBottomLeftRadius(CSSValuePair::create(inset->bottomLeftRa dius(), style)); 113 insetValue->setBottomLeftRadius(CSSValuePair::create(inset->bottomLeftRa dius(), style));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 break; 166 break;
167 default: 167 default:
168 ASSERT_NOT_REACHED(); 168 ASSERT_NOT_REACHED();
169 direction = BasicShapeCenterCoordinate::TopLeft; 169 direction = BasicShapeCenterCoordinate::TopLeft;
170 break; 170 break;
171 } 171 }
172 172
173 return BasicShapeCenterCoordinate(direction, offset); 173 return BasicShapeCenterCoordinate(direction, offset);
174 } 174 }
175 175
176 static BasicShapeRadius cssValueToBasicShapeRadius(const StyleResolverState& sta te, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> radius) 176 static BasicShapeRadius cssValueToBasicShapeRadius(const StyleResolverState& sta te, RawPtr<CSSPrimitiveValue> radius)
177 { 177 {
178 if (!radius) 178 if (!radius)
179 return BasicShapeRadius(BasicShapeRadius::ClosestSide); 179 return BasicShapeRadius(BasicShapeRadius::ClosestSide);
180 180
181 if (radius->isValueID()) { 181 if (radius->isValueID()) {
182 switch (radius->getValueID()) { 182 switch (radius->getValueID()) {
183 case CSSValueClosestSide: 183 case CSSValueClosestSide:
184 return BasicShapeRadius(BasicShapeRadius::ClosestSide); 184 return BasicShapeRadius(BasicShapeRadius::ClosestSide);
185 case CSSValueFarthestSide: 185 case CSSValueFarthestSide:
186 return BasicShapeRadius(BasicShapeRadius::FarthestSide); 186 return BasicShapeRadius(BasicShapeRadius::FarthestSide);
(...skipping 27 matching lines...) Expand all
214 ellipse->setCenterY(convertToCenterCoordinate(state, ellipseValue.center Y())); 214 ellipse->setCenterY(convertToCenterCoordinate(state, ellipseValue.center Y()));
215 ellipse->setRadiusX(cssValueToBasicShapeRadius(state, ellipseValue.radiu sX())); 215 ellipse->setRadiusX(cssValueToBasicShapeRadius(state, ellipseValue.radiu sX()));
216 ellipse->setRadiusY(cssValueToBasicShapeRadius(state, ellipseValue.radiu sY())); 216 ellipse->setRadiusY(cssValueToBasicShapeRadius(state, ellipseValue.radiu sY()));
217 217
218 basicShape = ellipse.release(); 218 basicShape = ellipse.release();
219 } else if (basicShapeValue.isBasicShapePolygonValue()) { 219 } else if (basicShapeValue.isBasicShapePolygonValue()) {
220 const CSSBasicShapePolygonValue& polygonValue = toCSSBasicShapePolygonVa lue(basicShapeValue); 220 const CSSBasicShapePolygonValue& polygonValue = toCSSBasicShapePolygonVa lue(basicShapeValue);
221 RefPtr<BasicShapePolygon> polygon = BasicShapePolygon::create(); 221 RefPtr<BasicShapePolygon> polygon = BasicShapePolygon::create();
222 222
223 polygon->setWindRule(polygonValue.windRule()); 223 polygon->setWindRule(polygonValue.windRule());
224 const WillBeHeapVector<RefPtrWillBeMember<CSSPrimitiveValue>>& values = polygonValue.values(); 224 const HeapVector<Member<CSSPrimitiveValue>>& values = polygonValue.value s();
225 for (unsigned i = 0; i < values.size(); i += 2) 225 for (unsigned i = 0; i < values.size(); i += 2)
226 polygon->appendPoint(convertToLength(state, values.at(i).get()), con vertToLength(state, values.at(i + 1).get())); 226 polygon->appendPoint(convertToLength(state, values.at(i).get()), con vertToLength(state, values.at(i + 1).get()));
227 227
228 basicShape = polygon.release(); 228 basicShape = polygon.release();
229 } else if (basicShapeValue.isBasicShapeInsetValue()) { 229 } else if (basicShapeValue.isBasicShapeInsetValue()) {
230 const CSSBasicShapeInsetValue& rectValue = toCSSBasicShapeInsetValue(bas icShapeValue); 230 const CSSBasicShapeInsetValue& rectValue = toCSSBasicShapeInsetValue(bas icShapeValue);
231 RefPtr<BasicShapeInset> rect = BasicShapeInset::create(); 231 RefPtr<BasicShapeInset> rect = BasicShapeInset::create();
232 232
233 rect->setTop(convertToLength(state, rectValue.top())); 233 rect->setTop(convertToLength(state, rectValue.top()));
234 rect->setRight(convertToLength(state, rectValue.right())); 234 rect->setRight(convertToLength(state, rectValue.right()));
(...skipping 14 matching lines...) Expand all
249 } 249 }
250 250
251 FloatPoint floatPointForCenterCoordinate(const BasicShapeCenterCoordinate& cente rX, const BasicShapeCenterCoordinate& centerY, FloatSize boxSize) 251 FloatPoint floatPointForCenterCoordinate(const BasicShapeCenterCoordinate& cente rX, const BasicShapeCenterCoordinate& centerY, FloatSize boxSize)
252 { 252 {
253 float x = floatValueForLength(centerX.computedLength(), boxSize.width()); 253 float x = floatValueForLength(centerX.computedLength(), boxSize.width());
254 float y = floatValueForLength(centerY.computedLength(), boxSize.height()); 254 float y = floatValueForLength(centerY.computedLength(), boxSize.height());
255 return FloatPoint(x, y); 255 return FloatPoint(x, y);
256 } 256 }
257 257
258 } // namespace blink 258 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698