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

Side by Side Diff: third_party/WebKit/Source/core/css/resolver/CSSToStyleMap.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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r ights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r ights reserved.
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 namespace blink { 44 namespace blink {
45 45
46 void CSSToStyleMap::mapFillAttachment(StyleResolverState&, FillLayer* layer, con st CSSValue& value) 46 void CSSToStyleMap::mapFillAttachment(StyleResolverState&, FillLayer* layer, con st CSSValue& value)
47 { 47 {
48 if (value.isInitialValue()) { 48 if (value.isInitialValue()) {
49 layer->setAttachment(FillLayer::initialFillAttachment(layer->type())); 49 layer->setAttachment(FillLayer::initialFillAttachment(layer->type()));
50 return; 50 return;
51 } 51 }
52 52
53 if (!value.isPrimitiveValue()) 53 if (!value.isIdentifierValue())
54 return; 54 return;
55 55
56 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); 56 const CSSIdentifierValue& identifierValue = toCSSIdentifierValue(value);
57 switch (primitiveValue.getValueID()) { 57 switch (identifierValue.getValueID()) {
58 case CSSValueFixed: 58 case CSSValueFixed:
59 layer->setAttachment(FixedBackgroundAttachment); 59 layer->setAttachment(FixedBackgroundAttachment);
60 break; 60 break;
61 case CSSValueScroll: 61 case CSSValueScroll:
62 layer->setAttachment(ScrollBackgroundAttachment); 62 layer->setAttachment(ScrollBackgroundAttachment);
63 break; 63 break;
64 case CSSValueLocal: 64 case CSSValueLocal:
65 layer->setAttachment(LocalBackgroundAttachment); 65 layer->setAttachment(LocalBackgroundAttachment);
66 break; 66 break;
67 default: 67 default:
68 return; 68 return;
69 } 69 }
70 } 70 }
71 71
72 void CSSToStyleMap::mapFillClip(StyleResolverState&, FillLayer* layer, const CSS Value& value) 72 void CSSToStyleMap::mapFillClip(StyleResolverState&, FillLayer* layer, const CSS Value& value)
73 { 73 {
74 if (value.isInitialValue()) { 74 if (value.isInitialValue()) {
75 layer->setClip(FillLayer::initialFillClip(layer->type())); 75 layer->setClip(FillLayer::initialFillClip(layer->type()));
76 return; 76 return;
77 } 77 }
78 78
79 if (!value.isPrimitiveValue()) 79 if (!value.isIdentifierValue())
80 return; 80 return;
81 81
82 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); 82 const CSSIdentifierValue& identifierValue = toCSSIdentifierValue(value);
83 layer->setClip(primitiveValue.convertTo<EFillBox>()); 83 layer->setClip(identifierValue.convertTo<EFillBox>());
84 } 84 }
85 85
86 void CSSToStyleMap::mapFillComposite(StyleResolverState&, FillLayer* layer, cons t CSSValue& value) 86 void CSSToStyleMap::mapFillComposite(StyleResolverState&, FillLayer* layer, cons t CSSValue& value)
87 { 87 {
88 if (value.isInitialValue()) { 88 if (value.isInitialValue()) {
89 layer->setComposite(FillLayer::initialFillComposite(layer->type())); 89 layer->setComposite(FillLayer::initialFillComposite(layer->type()));
90 return; 90 return;
91 } 91 }
92 92
93 if (!value.isPrimitiveValue()) 93 if (!value.isIdentifierValue())
94 return; 94 return;
95 95
96 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); 96 const CSSIdentifierValue& identifierValue = toCSSIdentifierValue(value);
97 layer->setComposite(primitiveValue.convertTo<CompositeOperator>()); 97 layer->setComposite(identifierValue.convertTo<CompositeOperator>());
98 } 98 }
99 99
100 void CSSToStyleMap::mapFillBlendMode(StyleResolverState&, FillLayer* layer, cons t CSSValue& value) 100 void CSSToStyleMap::mapFillBlendMode(StyleResolverState&, FillLayer* layer, cons t CSSValue& value)
101 { 101 {
102 if (value.isInitialValue()) { 102 if (value.isInitialValue()) {
103 layer->setBlendMode(FillLayer::initialFillBlendMode(layer->type())); 103 layer->setBlendMode(FillLayer::initialFillBlendMode(layer->type()));
104 return; 104 return;
105 } 105 }
106 106
107 if (!value.isPrimitiveValue()) 107 if (!value.isIdentifierValue())
108 return; 108 return;
109 109
110 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); 110 const CSSIdentifierValue& identifierValue = toCSSIdentifierValue(value);
111 layer->setBlendMode(primitiveValue.convertTo<WebBlendMode>()); 111 layer->setBlendMode(identifierValue.convertTo<WebBlendMode>());
112 } 112 }
113 113
114 void CSSToStyleMap::mapFillOrigin(StyleResolverState&, FillLayer* layer, const C SSValue& value) 114 void CSSToStyleMap::mapFillOrigin(StyleResolverState&, FillLayer* layer, const C SSValue& value)
115 { 115 {
116 if (value.isInitialValue()) { 116 if (value.isInitialValue()) {
117 layer->setOrigin(FillLayer::initialFillOrigin(layer->type())); 117 layer->setOrigin(FillLayer::initialFillOrigin(layer->type()));
118 return; 118 return;
119 } 119 }
120 120
121 if (!value.isPrimitiveValue()) 121 if (!value.isIdentifierValue())
122 return; 122 return;
123 123
124 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); 124 const CSSIdentifierValue& identifierValue = toCSSIdentifierValue(value);
125 layer->setOrigin(primitiveValue.convertTo<EFillBox>()); 125 layer->setOrigin(identifierValue.convertTo<EFillBox>());
126 } 126 }
127 127
128 128
129 void CSSToStyleMap::mapFillImage(StyleResolverState& state, FillLayer* layer, co nst CSSValue& value) 129 void CSSToStyleMap::mapFillImage(StyleResolverState& state, FillLayer* layer, co nst CSSValue& value)
130 { 130 {
131 if (value.isInitialValue()) { 131 if (value.isInitialValue()) {
132 layer->setImage(FillLayer::initialFillImage(layer->type())); 132 layer->setImage(FillLayer::initialFillImage(layer->type()));
133 return; 133 return;
134 } 134 }
135 135
136 CSSPropertyID property = layer->type() == BackgroundFillLayer ? CSSPropertyB ackgroundImage : CSSPropertyWebkitMaskImage; 136 CSSPropertyID property = layer->type() == BackgroundFillLayer ? CSSPropertyB ackgroundImage : CSSPropertyWebkitMaskImage;
137 layer->setImage(state.styleImage(property, value)); 137 layer->setImage(state.styleImage(property, value));
138 } 138 }
139 139
140 void CSSToStyleMap::mapFillRepeatX(StyleResolverState&, FillLayer* layer, const CSSValue& value) 140 void CSSToStyleMap::mapFillRepeatX(StyleResolverState&, FillLayer* layer, const CSSValue& value)
141 { 141 {
142 if (value.isInitialValue()) { 142 if (value.isInitialValue()) {
143 layer->setRepeatX(FillLayer::initialFillRepeatX(layer->type())); 143 layer->setRepeatX(FillLayer::initialFillRepeatX(layer->type()));
144 return; 144 return;
145 } 145 }
146 146
147 if (!value.isPrimitiveValue()) 147 if (!value.isIdentifierValue())
148 return; 148 return;
149 149
150 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); 150 const CSSIdentifierValue& identifierValue = toCSSIdentifierValue(value);
151 layer->setRepeatX(primitiveValue.convertTo<EFillRepeat>()); 151 layer->setRepeatX(identifierValue.convertTo<EFillRepeat>());
152 } 152 }
153 153
154 void CSSToStyleMap::mapFillRepeatY(StyleResolverState&, FillLayer* layer, const CSSValue& value) 154 void CSSToStyleMap::mapFillRepeatY(StyleResolverState&, FillLayer* layer, const CSSValue& value)
155 { 155 {
156 if (value.isInitialValue()) { 156 if (value.isInitialValue()) {
157 layer->setRepeatY(FillLayer::initialFillRepeatY(layer->type())); 157 layer->setRepeatY(FillLayer::initialFillRepeatY(layer->type()));
158 return; 158 return;
159 } 159 }
160 160
161 if (!value.isPrimitiveValue()) 161 if (!value.isIdentifierValue())
162 return; 162 return;
163 163
164 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); 164 const CSSIdentifierValue& identifierValue = toCSSIdentifierValue(value);
165 layer->setRepeatY(primitiveValue.convertTo<EFillRepeat>()); 165 layer->setRepeatY(identifierValue.convertTo<EFillRepeat>());
166 } 166 }
167 167
168 void CSSToStyleMap::mapFillSize(StyleResolverState& state, FillLayer* layer, con st CSSValue& value) 168 void CSSToStyleMap::mapFillSize(StyleResolverState& state, FillLayer* layer, con st CSSValue& value)
169 { 169 {
170 if (value.isInitialValue()) { 170 if (value.isInitialValue()) {
171 layer->setSizeType(FillLayer::initialFillSizeType(layer->type())); 171 layer->setSizeType(FillLayer::initialFillSizeType(layer->type()));
172 layer->setSizeLength(FillLayer::initialFillSizeLength(layer->type())); 172 layer->setSizeLength(FillLayer::initialFillSizeLength(layer->type()));
173 return; 173 return;
174 } 174 }
175 175
176 if (!value.isPrimitiveValue() && !value.isValuePair()) 176 if (!value.isIdentifierValue() && !value.isPrimitiveValue() && !value.isValu ePair())
177 return; 177 return;
178 178
179 if (value.isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID() == C SSValueContain) 179 if (value.isIdentifierValue() && toCSSIdentifierValue(value).getValueID() == CSSValueContain)
180 layer->setSizeType(Contain); 180 layer->setSizeType(Contain);
181 else if (value.isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID() == CSSValueCover) 181 else if (value.isIdentifierValue() && toCSSIdentifierValue(value).getValueID () == CSSValueCover)
182 layer->setSizeType(Cover); 182 layer->setSizeType(Cover);
183 else 183 else
184 layer->setSizeType(SizeLength); 184 layer->setSizeType(SizeLength);
185 185
186 LengthSize b = FillLayer::initialFillSizeLength(layer->type()); 186 LengthSize b = FillLayer::initialFillSizeLength(layer->type());
187 187
188 if (value.isPrimitiveValue() && (toCSSPrimitiveValue(value).getValueID() == CSSValueContain || toCSSPrimitiveValue(value).getValueID() == CSSValueCover)) { 188 if (value.isIdentifierValue() && (toCSSIdentifierValue(value).getValueID() = = CSSValueContain || toCSSIdentifierValue(value).getValueID() == CSSValueCover)) {
189 layer->setSizeLength(b); 189 layer->setSizeLength(b);
190 return; 190 return;
191 } 191 }
192 192
193 Length firstLength; 193 Length firstLength;
194 Length secondLength; 194 Length secondLength;
195 195
196 if (value.isValuePair()) { 196 if (value.isValuePair()) {
197 const CSSValuePair& pair = toCSSValuePair(value); 197 const CSSValuePair& pair = toCSSValuePair(value);
198 firstLength = StyleBuilderConverter::convertLengthOrAuto(state, pair.fir st()); 198 firstLength = StyleBuilderConverter::convertLengthOrAuto(state, pair.fir st());
199 secondLength = StyleBuilderConverter::convertLengthOrAuto(state, pair.se cond()); 199 secondLength = StyleBuilderConverter::convertLengthOrAuto(state, pair.se cond());
200 } else { 200 } else {
201 ASSERT(value.isPrimitiveValue()); 201 DCHECK(value.isPrimitiveValue() || value.isIdentifierValue());
202 firstLength = StyleBuilderConverter::convertLengthOrAuto(state, value); 202 firstLength = StyleBuilderConverter::convertLengthOrAuto(state, value);
203 secondLength = Length(); 203 secondLength = Length();
204 } 204 }
205 205
206 b.setWidth(firstLength); 206 b.setWidth(firstLength);
207 b.setHeight(secondLength); 207 b.setHeight(secondLength);
208 layer->setSizeLength(b); 208 layer->setSizeLength(b);
209 } 209 }
210 210
211 void CSSToStyleMap::mapFillXPosition(StyleResolverState& state, FillLayer* layer , const CSSValue& value) 211 void CSSToStyleMap::mapFillXPosition(StyleResolverState& state, FillLayer* layer , const CSSValue& value)
212 { 212 {
213 if (value.isInitialValue()) { 213 if (value.isInitialValue()) {
214 layer->setXPosition(FillLayer::initialFillXPosition(layer->type())); 214 layer->setXPosition(FillLayer::initialFillXPosition(layer->type()));
215 return; 215 return;
216 } 216 }
217 217
218 if (!value.isPrimitiveValue() && !value.isValuePair()) 218 if (!value.isIdentifierValue() && !value.isPrimitiveValue() && !value.isValu ePair())
219 return; 219 return;
220 220
221 Length length; 221 Length length;
222 if (value.isValuePair()) 222 if (value.isValuePair())
223 length = toCSSPrimitiveValue(toCSSValuePair(value).second()).convertToLe ngth(state.cssToLengthConversionData()); 223 length = toCSSPrimitiveValue(toCSSValuePair(value).second()).convertToLe ngth(state.cssToLengthConversionData());
224 else 224 else
225 length = StyleBuilderConverter::convertPositionLength<CSSValueLeft, CSSV alueRight>(state, toCSSPrimitiveValue(value)); 225 length = StyleBuilderConverter::convertPositionLength<CSSValueLeft, CSSV alueRight>(state, value);
226 226
227 layer->setXPosition(length); 227 layer->setXPosition(length);
228 if (value.isValuePair()) 228 if (value.isValuePair())
229 layer->setBackgroundXOrigin(toCSSPrimitiveValue(toCSSValuePair(value).fi rst()).convertTo<BackgroundEdgeOrigin>()); 229 layer->setBackgroundXOrigin(toCSSIdentifierValue(toCSSValuePair(value).f irst()).convertTo<BackgroundEdgeOrigin>());
230 } 230 }
231 231
232 void CSSToStyleMap::mapFillYPosition(StyleResolverState& state, FillLayer* layer , const CSSValue& value) 232 void CSSToStyleMap::mapFillYPosition(StyleResolverState& state, FillLayer* layer , const CSSValue& value)
233 { 233 {
234 if (value.isInitialValue()) { 234 if (value.isInitialValue()) {
235 layer->setYPosition(FillLayer::initialFillYPosition(layer->type())); 235 layer->setYPosition(FillLayer::initialFillYPosition(layer->type()));
236 return; 236 return;
237 } 237 }
238 238
239 if (!value.isPrimitiveValue() && !value.isValuePair()) 239 if (!value.isIdentifierValue() && !value.isPrimitiveValue() && !value.isValu ePair())
240 return; 240 return;
241 241
242 Length length; 242 Length length;
243 if (value.isValuePair()) 243 if (value.isValuePair())
244 length = toCSSPrimitiveValue(toCSSValuePair(value).second()).convertToLe ngth(state.cssToLengthConversionData()); 244 length = toCSSPrimitiveValue(toCSSValuePair(value).second()).convertToLe ngth(state.cssToLengthConversionData());
245 else 245 else
246 length = StyleBuilderConverter::convertPositionLength<CSSValueTop, CSSVa lueBottom>(state, toCSSPrimitiveValue(value)); 246 length = StyleBuilderConverter::convertPositionLength<CSSValueTop, CSSVa lueBottom>(state, value);
247 247
248 layer->setYPosition(length); 248 layer->setYPosition(length);
249 if (value.isValuePair()) 249 if (value.isValuePair())
250 layer->setBackgroundYOrigin(toCSSPrimitiveValue(toCSSValuePair(value).fi rst()).convertTo<BackgroundEdgeOrigin>()); 250 layer->setBackgroundYOrigin(toCSSIdentifierValue(toCSSValuePair(value).f irst()).convertTo<BackgroundEdgeOrigin>());
251 } 251 }
252 252
253 void CSSToStyleMap::mapFillMaskSourceType(StyleResolverState&, FillLayer* layer, const CSSValue& value) 253 void CSSToStyleMap::mapFillMaskSourceType(StyleResolverState&, FillLayer* layer, const CSSValue& value)
254 { 254 {
255 EMaskSourceType type = FillLayer::initialFillMaskSourceType(layer->type()); 255 EMaskSourceType type = FillLayer::initialFillMaskSourceType(layer->type());
256 if (value.isInitialValue()) { 256 if (value.isInitialValue()) {
257 layer->setMaskSourceType(type); 257 layer->setMaskSourceType(type);
258 return; 258 return;
259 } 259 }
260 260
261 if (!value.isPrimitiveValue()) 261 if (!value.isIdentifierValue())
262 return; 262 return;
263 263
264 switch (toCSSPrimitiveValue(value).getValueID()) { 264 switch (toCSSIdentifierValue(value).getValueID()) {
265 case CSSValueAlpha: 265 case CSSValueAlpha:
266 type = MaskAlpha; 266 type = MaskAlpha;
267 break; 267 break;
268 case CSSValueLuminance: 268 case CSSValueLuminance:
269 type = MaskLuminance; 269 type = MaskLuminance;
270 break; 270 break;
271 case CSSValueAuto: 271 case CSSValueAuto:
272 break; 272 break;
273 default: 273 default:
274 ASSERT_NOT_REACHED(); 274 ASSERT_NOT_REACHED();
275 } 275 }
276 276
277 layer->setMaskSourceType(type); 277 layer->setMaskSourceType(type);
278 } 278 }
279 279
280 double CSSToStyleMap::mapAnimationDelay(const CSSValue& value) 280 double CSSToStyleMap::mapAnimationDelay(const CSSValue& value)
281 { 281 {
282 if (value.isInitialValue()) 282 if (value.isInitialValue())
283 return CSSTimingData::initialDelay(); 283 return CSSTimingData::initialDelay();
284 return toCSSPrimitiveValue(value).computeSeconds(); 284 return toCSSPrimitiveValue(value).computeSeconds();
285 } 285 }
286 286
287 Timing::PlaybackDirection CSSToStyleMap::mapAnimationDirection(const CSSValue& v alue) 287 Timing::PlaybackDirection CSSToStyleMap::mapAnimationDirection(const CSSValue& v alue)
288 { 288 {
289 if (value.isInitialValue()) 289 if (value.isInitialValue())
290 return CSSAnimationData::initialDirection(); 290 return CSSAnimationData::initialDirection();
291 291
292 switch (toCSSPrimitiveValue(value).getValueID()) { 292 switch (toCSSIdentifierValue(value).getValueID()) {
293 case CSSValueNormal: 293 case CSSValueNormal:
294 return Timing::PlaybackDirection::NORMAL; 294 return Timing::PlaybackDirection::NORMAL;
295 case CSSValueAlternate: 295 case CSSValueAlternate:
296 return Timing::PlaybackDirection::ALTERNATE_NORMAL; 296 return Timing::PlaybackDirection::ALTERNATE_NORMAL;
297 case CSSValueReverse: 297 case CSSValueReverse:
298 return Timing::PlaybackDirection::REVERSE; 298 return Timing::PlaybackDirection::REVERSE;
299 case CSSValueAlternateReverse: 299 case CSSValueAlternateReverse:
300 return Timing::PlaybackDirection::ALTERNATE_REVERSE; 300 return Timing::PlaybackDirection::ALTERNATE_REVERSE;
301 default: 301 default:
302 ASSERT_NOT_REACHED(); 302 ASSERT_NOT_REACHED();
303 return CSSAnimationData::initialDirection(); 303 return CSSAnimationData::initialDirection();
304 } 304 }
305 } 305 }
306 306
307 double CSSToStyleMap::mapAnimationDuration(const CSSValue& value) 307 double CSSToStyleMap::mapAnimationDuration(const CSSValue& value)
308 { 308 {
309 if (value.isInitialValue()) 309 if (value.isInitialValue())
310 return CSSTimingData::initialDuration(); 310 return CSSTimingData::initialDuration();
311 return toCSSPrimitiveValue(value).computeSeconds(); 311 return toCSSPrimitiveValue(value).computeSeconds();
312 } 312 }
313 313
314 Timing::FillMode CSSToStyleMap::mapAnimationFillMode(const CSSValue& value) 314 Timing::FillMode CSSToStyleMap::mapAnimationFillMode(const CSSValue& value)
315 { 315 {
316 if (value.isInitialValue()) 316 if (value.isInitialValue())
317 return CSSAnimationData::initialFillMode(); 317 return CSSAnimationData::initialFillMode();
318 318
319 switch (toCSSPrimitiveValue(value).getValueID()) { 319 switch (toCSSIdentifierValue(value).getValueID()) {
320 case CSSValueNone: 320 case CSSValueNone:
321 return Timing::FillMode::NONE; 321 return Timing::FillMode::NONE;
322 case CSSValueForwards: 322 case CSSValueForwards:
323 return Timing::FillMode::FORWARDS; 323 return Timing::FillMode::FORWARDS;
324 case CSSValueBackwards: 324 case CSSValueBackwards:
325 return Timing::FillMode::BACKWARDS; 325 return Timing::FillMode::BACKWARDS;
326 case CSSValueBoth: 326 case CSSValueBoth:
327 return Timing::FillMode::BOTH; 327 return Timing::FillMode::BOTH;
328 default: 328 default:
329 ASSERT_NOT_REACHED(); 329 ASSERT_NOT_REACHED();
330 return CSSAnimationData::initialFillMode(); 330 return CSSAnimationData::initialFillMode();
331 } 331 }
332 } 332 }
333 333
334 double CSSToStyleMap::mapAnimationIterationCount(const CSSValue& value) 334 double CSSToStyleMap::mapAnimationIterationCount(const CSSValue& value)
335 { 335 {
336 if (value.isInitialValue()) 336 if (value.isInitialValue())
337 return CSSAnimationData::initialIterationCount(); 337 return CSSAnimationData::initialIterationCount();
338 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); 338 if (value.isIdentifierValue() && toCSSIdentifierValue(value).getValueID() == CSSValueInfinite)
339 if (primitiveValue.getValueID() == CSSValueInfinite)
340 return std::numeric_limits<double>::infinity(); 339 return std::numeric_limits<double>::infinity();
341 return primitiveValue.getFloatValue(); 340 return toCSSPrimitiveValue(value).getFloatValue();
342 } 341 }
343 342
344 AtomicString CSSToStyleMap::mapAnimationName(const CSSValue& value) 343 AtomicString CSSToStyleMap::mapAnimationName(const CSSValue& value)
345 { 344 {
346 if (value.isInitialValue()) 345 if (value.isInitialValue())
347 return CSSAnimationData::initialName(); 346 return CSSAnimationData::initialName();
348 if (value.isCustomIdentValue()) 347 if (value.isCustomIdentValue())
349 return AtomicString(toCSSCustomIdentValue(value).value()); 348 return AtomicString(toCSSCustomIdentValue(value).value());
350 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNone); 349 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone);
351 return CSSAnimationData::initialName(); 350 return CSSAnimationData::initialName();
352 } 351 }
353 352
354 EAnimPlayState CSSToStyleMap::mapAnimationPlayState(const CSSValue& value) 353 EAnimPlayState CSSToStyleMap::mapAnimationPlayState(const CSSValue& value)
355 { 354 {
356 if (value.isInitialValue()) 355 if (value.isInitialValue())
357 return CSSAnimationData::initialPlayState(); 356 return CSSAnimationData::initialPlayState();
358 if (toCSSPrimitiveValue(value).getValueID() == CSSValuePaused) 357 if (toCSSIdentifierValue(value).getValueID() == CSSValuePaused)
359 return AnimPlayStatePaused; 358 return AnimPlayStatePaused;
360 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueRunning); 359 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueRunning);
361 return AnimPlayStatePlaying; 360 return AnimPlayStatePlaying;
362 } 361 }
363 362
364 CSSTransitionData::TransitionProperty CSSToStyleMap::mapAnimationProperty(const CSSValue& value) 363 CSSTransitionData::TransitionProperty CSSToStyleMap::mapAnimationProperty(const CSSValue& value)
365 { 364 {
366 if (value.isInitialValue()) 365 if (value.isInitialValue())
367 return CSSTransitionData::initialProperty(); 366 return CSSTransitionData::initialProperty();
368 if (value.isCustomIdentValue()) { 367 if (value.isCustomIdentValue()) {
369 const CSSCustomIdentValue& customIdentValue = toCSSCustomIdentValue(valu e); 368 const CSSCustomIdentValue& customIdentValue = toCSSCustomIdentValue(valu e);
370 if (customIdentValue.isKnownPropertyID()) 369 if (customIdentValue.isKnownPropertyID())
371 return CSSTransitionData::TransitionProperty(customIdentValue.valueA sPropertyID()); 370 return CSSTransitionData::TransitionProperty(customIdentValue.valueA sPropertyID());
372 return CSSTransitionData::TransitionProperty(customIdentValue.value()); 371 return CSSTransitionData::TransitionProperty(customIdentValue.value());
373 } 372 }
374 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNone); 373 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone);
375 return CSSTransitionData::TransitionProperty(CSSTransitionData::TransitionNo ne); 374 return CSSTransitionData::TransitionProperty(CSSTransitionData::TransitionNo ne);
376 } 375 }
377 376
378 PassRefPtr<TimingFunction> CSSToStyleMap::mapAnimationTimingFunction(const CSSVa lue& value, bool allowStepMiddle) 377 PassRefPtr<TimingFunction> CSSToStyleMap::mapAnimationTimingFunction(const CSSVa lue& value, bool allowStepMiddle)
379 { 378 {
380 // FIXME: We should probably only call into this function with a valid 379 // FIXME: We should probably only call into this function with a valid
381 // single timing function value which isn't initial or inherit. We can 380 // single timing function value which isn't initial or inherit. We can
382 // currently get into here with initial since the parser expands unset 381 // currently get into here with initial since the parser expands unset
383 // properties in shorthands to initial. 382 // properties in shorthands to initial.
384 383
385 if (value.isPrimitiveValue()) { 384 if (value.isIdentifierValue()) {
386 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); 385 const CSSIdentifierValue& identifierValue = toCSSIdentifierValue(value);
387 switch (primitiveValue.getValueID()) { 386 switch (identifierValue.getValueID()) {
388 case CSSValueLinear: 387 case CSSValueLinear:
389 return LinearTimingFunction::shared(); 388 return LinearTimingFunction::shared();
390 case CSSValueEase: 389 case CSSValueEase:
391 return CubicBezierTimingFunction::preset(CubicBezierTimingFunction:: EaseType::EASE); 390 return CubicBezierTimingFunction::preset(CubicBezierTimingFunction:: EaseType::EASE);
392 case CSSValueEaseIn: 391 case CSSValueEaseIn:
393 return CubicBezierTimingFunction::preset(CubicBezierTimingFunction:: EaseType::EASE_IN); 392 return CubicBezierTimingFunction::preset(CubicBezierTimingFunction:: EaseType::EASE_IN);
394 case CSSValueEaseOut: 393 case CSSValueEaseOut:
395 return CubicBezierTimingFunction::preset(CubicBezierTimingFunction:: EaseType::EASE_OUT); 394 return CubicBezierTimingFunction::preset(CubicBezierTimingFunction:: EaseType::EASE_OUT);
396 case CSSValueEaseInOut: 395 case CSSValueEaseInOut:
397 return CubicBezierTimingFunction::preset(CubicBezierTimingFunction:: EaseType::EASE_IN_OUT); 396 return CubicBezierTimingFunction::preset(CubicBezierTimingFunction:: EaseType::EASE_IN_OUT);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 { 493 {
495 if (!value.isBorderImageSliceValue()) 494 if (!value.isBorderImageSliceValue())
496 return; 495 return;
497 496
498 // Retrieve the border image value. 497 // Retrieve the border image value.
499 const CSSBorderImageSliceValue& borderImageSlice = toCSSBorderImageSliceValu e(value); 498 const CSSBorderImageSliceValue& borderImageSlice = toCSSBorderImageSliceValu e(value);
500 499
501 // Set up a length box to represent our image slices. 500 // Set up a length box to represent our image slices.
502 LengthBox box; 501 LengthBox box;
503 const CSSQuadValue& slices = borderImageSlice.slices(); 502 const CSSQuadValue& slices = borderImageSlice.slices();
504 box.m_top = convertBorderImageSliceSide(*slices.top()); 503 box.m_top = convertBorderImageSliceSide(toCSSPrimitiveValue(*slices.top()));
505 box.m_bottom = convertBorderImageSliceSide(*slices.bottom()); 504 box.m_bottom = convertBorderImageSliceSide(toCSSPrimitiveValue(*slices.botto m()));
506 box.m_left = convertBorderImageSliceSide(*slices.left()); 505 box.m_left = convertBorderImageSliceSide(toCSSPrimitiveValue(*slices.left()) );
507 box.m_right = convertBorderImageSliceSide(*slices.right()); 506 box.m_right = convertBorderImageSliceSide(toCSSPrimitiveValue(*slices.right( )));
508 image.setImageSlices(box); 507 image.setImageSlices(box);
509 508
510 // Set our fill mode. 509 // Set our fill mode.
511 image.setFill(borderImageSlice.fill()); 510 image.setFill(borderImageSlice.fill());
512 } 511 }
513 512
514 static BorderImageLength toBorderImageLength(CSSPrimitiveValue& value, const CSS ToLengthConversionData& conversionData) 513 static BorderImageLength toBorderImageLength(CSSValue& value, const CSSToLengthC onversionData& conversionData)
515 { 514 {
516 if (value.isNumber()) 515 if (value.isPrimitiveValue()) {
517 return value.getDoubleValue(); 516 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
518 if (value.isPercentage()) 517 if (primitiveValue.isNumber())
519 return Length(value.getDoubleValue(), Percent); 518 return primitiveValue.getDoubleValue();
520 if (value.getValueID() != CSSValueAuto) 519 if (primitiveValue.isPercentage())
521 return value.computeLength<Length>(conversionData); 520 return Length(primitiveValue.getDoubleValue(), Percent);
521 return primitiveValue.computeLength<Length>(conversionData);
522 }
523 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueAuto);
522 return Length(Auto); 524 return Length(Auto);
523 } 525 }
524 526
525 BorderImageLengthBox CSSToStyleMap::mapNinePieceImageQuad(StyleResolverState& st ate, const CSSValue& value) 527 BorderImageLengthBox CSSToStyleMap::mapNinePieceImageQuad(StyleResolverState& st ate, const CSSValue& value)
526 { 528 {
527 if (!value.isQuadValue()) 529 if (!value.isQuadValue())
528 return BorderImageLengthBox(Length(Auto)); 530 return BorderImageLengthBox(Length(Auto));
529 531
530 const CSSQuadValue& slices = toCSSQuadValue(value); 532 const CSSQuadValue& slices = toCSSQuadValue(value);
531 533
532 // Set up a border image length box to represent our image slices. 534 // Set up a border image length box to represent our image slices.
533 return BorderImageLengthBox( 535 return BorderImageLengthBox(
534 toBorderImageLength(*slices.top(), state.cssToLengthConversionData()), 536 toBorderImageLength(*slices.top(), state.cssToLengthConversionData()),
535 toBorderImageLength(*slices.right(), state.cssToLengthConversionData()), 537 toBorderImageLength(*slices.right(), state.cssToLengthConversionData()),
536 toBorderImageLength(*slices.bottom(), state.cssToLengthConversionData()) , 538 toBorderImageLength(*slices.bottom(), state.cssToLengthConversionData()) ,
537 toBorderImageLength(*slices.left(), state.cssToLengthConversionData())); 539 toBorderImageLength(*slices.left(), state.cssToLengthConversionData()));
538 } 540 }
539 541
540 void CSSToStyleMap::mapNinePieceImageRepeat(StyleResolverState&, const CSSValue& value, NinePieceImage& image) 542 void CSSToStyleMap::mapNinePieceImageRepeat(StyleResolverState&, const CSSValue& value, NinePieceImage& image)
541 { 543 {
542 if (!value.isValuePair()) 544 if (!value.isValuePair())
543 return; 545 return;
544 546
545 const CSSValuePair& pair = toCSSValuePair(value); 547 const CSSValuePair& pair = toCSSValuePair(value);
546 CSSValueID firstIdentifier = toCSSPrimitiveValue(pair.first()).getValueID(); 548 CSSValueID firstIdentifier = toCSSIdentifierValue(pair.first()).getValueID() ;
547 CSSValueID secondIdentifier = toCSSPrimitiveValue(pair.second()).getValueID( ); 549 CSSValueID secondIdentifier = toCSSIdentifierValue(pair.second()).getValueID ();
548 550
549 ENinePieceImageRule horizontalRule; 551 ENinePieceImageRule horizontalRule;
550 switch (firstIdentifier) { 552 switch (firstIdentifier) {
551 case CSSValueStretch: 553 case CSSValueStretch:
552 horizontalRule = StretchImageRule; 554 horizontalRule = StretchImageRule;
553 break; 555 break;
554 case CSSValueRound: 556 case CSSValueRound:
555 horizontalRule = RoundImageRule; 557 horizontalRule = RoundImageRule;
556 break; 558 break;
557 case CSSValueSpace: 559 case CSSValueSpace:
(...skipping 17 matching lines...) Expand all
575 verticalRule = SpaceImageRule; 577 verticalRule = SpaceImageRule;
576 break; 578 break;
577 default: // CSSValueRepeat 579 default: // CSSValueRepeat
578 verticalRule = RepeatImageRule; 580 verticalRule = RepeatImageRule;
579 break; 581 break;
580 } 582 }
581 image.setVerticalRule(verticalRule); 583 image.setVerticalRule(verticalRule);
582 } 584 }
583 585
584 } // namespace blink 586 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698