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

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

Issue 2346193002: Split CSSPrimitiveValue into CSSPrimitiveValue and CSSIdentifierValue (Closed)
Patch Set: Rebase please work Created 4 years, 2 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 12 matching lines...) Expand all
23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
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 "core/css/BasicShapeFunctions.h" 30 #include "core/css/BasicShapeFunctions.h"
31 31
32 #include "core/css/CSSBasicShapeValues.h" 32 #include "core/css/CSSBasicShapeValues.h"
33 #include "core/css/CSSIdentifierValue.h"
33 #include "core/css/CSSPrimitiveValueMappings.h" 34 #include "core/css/CSSPrimitiveValueMappings.h"
34 #include "core/css/CSSValuePair.h" 35 #include "core/css/CSSValuePair.h"
35 #include "core/css/resolver/StyleResolverState.h" 36 #include "core/css/resolver/StyleResolverState.h"
36 #include "core/style/BasicShapes.h" 37 #include "core/style/BasicShapes.h"
37 #include "core/style/ComputedStyle.h" 38 #include "core/style/ComputedStyle.h"
38 39
39 namespace blink { 40 namespace blink {
40 41
41 static CSSValue* valueForCenterCoordinate(const ComputedStyle& style, const Basi cShapeCenterCoordinate& center, EBoxOrient orientation) 42 static CSSValue* valueForCenterCoordinate(const ComputedStyle& style, const Basi cShapeCenterCoordinate& center, EBoxOrient orientation)
42 { 43 {
43 if (center.getDirection() == BasicShapeCenterCoordinate::TopLeft) 44 if (center.getDirection() == BasicShapeCenterCoordinate::TopLeft)
44 return CSSPrimitiveValue::create(center.length(), style.effectiveZoom()) ; 45 return CSSValue::create(center.length(), style.effectiveZoom());
45 46
46 CSSValueID keyword = orientation == HORIZONTAL ? CSSValueRight : CSSValueBot tom; 47 CSSValueID keyword = orientation == HORIZONTAL ? CSSValueRight : CSSValueBot tom;
47 48
48 return CSSValuePair::create( 49 return CSSValuePair::create(
49 CSSPrimitiveValue::createIdentifier(keyword), 50 CSSIdentifierValue::create(keyword),
50 CSSPrimitiveValue::create(center.length(), style.effectiveZoom()), 51 CSSValue::create(center.length(), style.effectiveZoom()),
51 CSSValuePair::DropIdenticalValues); 52 CSSValuePair::DropIdenticalValues);
52 } 53 }
53 54
54 static CSSValuePair* valueForLengthSize(const LengthSize& lengthSize, const Comp utedStyle& style) 55 static CSSValuePair* valueForLengthSize(const LengthSize& lengthSize, const Comp utedStyle& style)
55 { 56 {
56 return CSSValuePair::create( 57 return CSSValuePair::create(
57 CSSPrimitiveValue::create(lengthSize.width(), style.effectiveZoom()), 58 CSSValue::create(lengthSize.width(), style.effectiveZoom()),
58 CSSPrimitiveValue::create(lengthSize.height(), style.effectiveZoom()), 59 CSSValue::create(lengthSize.height(), style.effectiveZoom()),
59 CSSValuePair::KeepIdenticalValues); 60 CSSValuePair::KeepIdenticalValues);
60 } 61 }
61 62
62 static CSSPrimitiveValue* basicShapeRadiusToCSSValue(const ComputedStyle& style, const BasicShapeRadius& radius) 63 static CSSValue* basicShapeRadiusToCSSValue(const ComputedStyle& style, const Ba sicShapeRadius& radius)
63 { 64 {
64 switch (radius.type()) { 65 switch (radius.type()) {
65 case BasicShapeRadius::Value: 66 case BasicShapeRadius::Value:
66 return CSSPrimitiveValue::create(radius.value(), style.effectiveZoom()); 67 return CSSValue::create(radius.value(), style.effectiveZoom());
67 case BasicShapeRadius::ClosestSide: 68 case BasicShapeRadius::ClosestSide:
68 return CSSPrimitiveValue::createIdentifier(CSSValueClosestSide); 69 return CSSIdentifierValue::create(CSSValueClosestSide);
69 case BasicShapeRadius::FarthestSide: 70 case BasicShapeRadius::FarthestSide:
70 return CSSPrimitiveValue::createIdentifier(CSSValueFarthestSide); 71 return CSSIdentifierValue::create(CSSValueFarthestSide);
71 } 72 }
72 73
73 ASSERT_NOT_REACHED(); 74 ASSERT_NOT_REACHED();
74 return nullptr; 75 return nullptr;
75 } 76 }
76 77
77 CSSValue* valueForBasicShape(const ComputedStyle& style, const BasicShape* basic Shape) 78 CSSValue* valueForBasicShape(const ComputedStyle& style, const BasicShape* basic Shape)
78 { 79 {
79 switch (basicShape->type()) { 80 switch (basicShape->type()) {
80 case BasicShape::BasicShapeCircleType: { 81 case BasicShape::BasicShapeCircleType: {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 } 147 }
147 148
148 static BasicShapeCenterCoordinate convertToCenterCoordinate(const StyleResolverS tate& state, CSSValue* value) 149 static BasicShapeCenterCoordinate convertToCenterCoordinate(const StyleResolverS tate& state, CSSValue* value)
149 { 150 {
150 BasicShapeCenterCoordinate::Direction direction; 151 BasicShapeCenterCoordinate::Direction direction;
151 Length offset = Length(0, Fixed); 152 Length offset = Length(0, Fixed);
152 153
153 CSSValueID keyword = CSSValueTop; 154 CSSValueID keyword = CSSValueTop;
154 if (!value) { 155 if (!value) {
155 keyword = CSSValueCenter; 156 keyword = CSSValueCenter;
156 } else if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->isValueI D()) { 157 } else if (value->isIdentifierValue()) {
157 keyword = toCSSPrimitiveValue(value)->getValueID(); 158 keyword = toCSSIdentifierValue(value)->getValueID();
158 } else if (value->isValuePair()) { 159 } else if (value->isValuePair()) {
159 keyword = toCSSPrimitiveValue(toCSSValuePair(value)->first()).getValueID (); 160 keyword = toCSSIdentifierValue(toCSSValuePair(value)->first()).getValueI D();
160 offset = convertToLength(state, &toCSSPrimitiveValue(toCSSValuePair(valu e)->second())); 161 offset = convertToLength(state, &toCSSPrimitiveValue(toCSSValuePair(valu e)->second()));
161 } else { 162 } else {
162 offset = convertToLength(state, toCSSPrimitiveValue(value)); 163 offset = convertToLength(state, toCSSPrimitiveValue(value));
163 } 164 }
164 165
165 switch (keyword) { 166 switch (keyword) {
166 case CSSValueTop: 167 case CSSValueTop:
167 case CSSValueLeft: 168 case CSSValueLeft:
168 direction = BasicShapeCenterCoordinate::TopLeft; 169 direction = BasicShapeCenterCoordinate::TopLeft;
169 break; 170 break;
170 case CSSValueRight: 171 case CSSValueRight:
171 case CSSValueBottom: 172 case CSSValueBottom:
172 direction = BasicShapeCenterCoordinate::BottomRight; 173 direction = BasicShapeCenterCoordinate::BottomRight;
173 break; 174 break;
174 case CSSValueCenter: 175 case CSSValueCenter:
175 direction = BasicShapeCenterCoordinate::TopLeft; 176 direction = BasicShapeCenterCoordinate::TopLeft;
176 offset = Length(50, Percent); 177 offset = Length(50, Percent);
177 break; 178 break;
178 default: 179 default:
179 ASSERT_NOT_REACHED(); 180 ASSERT_NOT_REACHED();
180 direction = BasicShapeCenterCoordinate::TopLeft; 181 direction = BasicShapeCenterCoordinate::TopLeft;
181 break; 182 break;
182 } 183 }
183 184
184 return BasicShapeCenterCoordinate(direction, offset); 185 return BasicShapeCenterCoordinate(direction, offset);
185 } 186 }
186 187
187 static BasicShapeRadius cssValueToBasicShapeRadius(const StyleResolverState& sta te, const CSSPrimitiveValue* radius) 188 static BasicShapeRadius cssValueToBasicShapeRadius(const StyleResolverState& sta te, const CSSValue* radius)
188 { 189 {
189 if (!radius) 190 if (!radius)
190 return BasicShapeRadius(BasicShapeRadius::ClosestSide); 191 return BasicShapeRadius(BasicShapeRadius::ClosestSide);
191 192
192 if (radius->isValueID()) { 193 if (radius->isIdentifierValue()) {
193 switch (radius->getValueID()) { 194 switch (toCSSIdentifierValue(radius)->getValueID()) {
194 case CSSValueClosestSide: 195 case CSSValueClosestSide:
195 return BasicShapeRadius(BasicShapeRadius::ClosestSide); 196 return BasicShapeRadius(BasicShapeRadius::ClosestSide);
196 case CSSValueFarthestSide: 197 case CSSValueFarthestSide:
197 return BasicShapeRadius(BasicShapeRadius::FarthestSide); 198 return BasicShapeRadius(BasicShapeRadius::FarthestSide);
198 default: 199 default:
199 ASSERT_NOT_REACHED(); 200 ASSERT_NOT_REACHED();
200 break; 201 break;
201 } 202 }
202 } 203 }
203 204
204 return BasicShapeRadius(convertToLength(state, radius)); 205 return BasicShapeRadius(convertToLength(state, toCSSPrimitiveValue(radius))) ;
205 } 206 }
206 207
207 PassRefPtr<BasicShape> basicShapeForValue(const StyleResolverState& state, const CSSValue& basicShapeValue) 208 PassRefPtr<BasicShape> basicShapeForValue(const StyleResolverState& state, const CSSValue& basicShapeValue)
208 { 209 {
209 RefPtr<BasicShape> basicShape; 210 RefPtr<BasicShape> basicShape;
210 211
211 if (basicShapeValue.isBasicShapeCircleValue()) { 212 if (basicShapeValue.isBasicShapeCircleValue()) {
212 const CSSBasicShapeCircleValue& circleValue = toCSSBasicShapeCircleValue (basicShapeValue); 213 const CSSBasicShapeCircleValue& circleValue = toCSSBasicShapeCircleValue (basicShapeValue);
213 RefPtr<BasicShapeCircle> circle = BasicShapeCircle::create(); 214 RefPtr<BasicShapeCircle> circle = BasicShapeCircle::create();
214 215
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 } 261 }
261 262
262 FloatPoint floatPointForCenterCoordinate(const BasicShapeCenterCoordinate& cente rX, const BasicShapeCenterCoordinate& centerY, FloatSize boxSize) 263 FloatPoint floatPointForCenterCoordinate(const BasicShapeCenterCoordinate& cente rX, const BasicShapeCenterCoordinate& centerY, FloatSize boxSize)
263 { 264 {
264 float x = floatValueForLength(centerX.computedLength(), boxSize.width()); 265 float x = floatValueForLength(centerX.computedLength(), boxSize.width());
265 float y = floatValueForLength(centerY.computedLength(), boxSize.height()); 266 float y = floatValueForLength(centerY.computedLength(), boxSize.height());
266 return FloatPoint(x, y); 267 return FloatPoint(x, y);
267 } 268 }
268 269
269 } // namespace blink 270 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/BUILD.gn ('k') | third_party/WebKit/Source/core/css/CSSBasicShapeValues.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698