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

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

Issue 1373753002: Change CSSToStyleMap functions to take const CSSValue&s (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed unecessary changes to CSSImageValue Created 5 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 25 matching lines...) Expand all
36 #include "core/css/CSSQuadValue.h" 36 #include "core/css/CSSQuadValue.h"
37 #include "core/css/CSSTimingFunctionValue.h" 37 #include "core/css/CSSTimingFunctionValue.h"
38 #include "core/css/CSSValuePair.h" 38 #include "core/css/CSSValuePair.h"
39 #include "core/css/resolver/StyleBuilderConverter.h" 39 #include "core/css/resolver/StyleBuilderConverter.h"
40 #include "core/css/resolver/StyleResolverState.h" 40 #include "core/css/resolver/StyleResolverState.h"
41 #include "core/style/BorderImageLengthBox.h" 41 #include "core/style/BorderImageLengthBox.h"
42 #include "core/style/FillLayer.h" 42 #include "core/style/FillLayer.h"
43 43
44 namespace blink { 44 namespace blink {
45 45
46 void CSSToStyleMap::mapFillAttachment(StyleResolverState&, FillLayer* layer, CSS Value* 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.isPrimitiveValue())
54 return; 54 return;
55 55
56 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 56 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
57 switch (primitiveValue->getValueID()) { 57 switch (primitiveValue.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, CSSValue* 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.isPrimitiveValue())
80 return; 80 return;
81 81
82 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 82 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
83 layer->setClip(*primitiveValue); 83 layer->setClip(primitiveValue);
84 } 84 }
85 85
86 void CSSToStyleMap::mapFillComposite(StyleResolverState&, FillLayer* layer, CSSV alue* 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.isPrimitiveValue())
94 return; 94 return;
95 95
96 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 96 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
97 layer->setComposite(*primitiveValue); 97 layer->setComposite(primitiveValue);
98 } 98 }
99 99
100 void CSSToStyleMap::mapFillBlendMode(StyleResolverState&, FillLayer* layer, CSSV alue* 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.isPrimitiveValue())
108 return; 108 return;
109 109
110 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 110 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
111 layer->setBlendMode(*primitiveValue); 111 layer->setBlendMode(primitiveValue);
112 } 112 }
113 113
114 void CSSToStyleMap::mapFillOrigin(StyleResolverState&, FillLayer* layer, CSSValu e* 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.isPrimitiveValue())
122 return; 122 return;
123 123
124 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 124 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
125 layer->setOrigin(*primitiveValue); 125 layer->setOrigin(primitiveValue);
126 } 126 }
127 127
128 128
129 void CSSToStyleMap::mapFillImage(StyleResolverState& state, FillLayer* layer, CS SValue* 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, CSSVal ue* 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.isPrimitiveValue())
148 return; 148 return;
149 149
150 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 150 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
151 layer->setRepeatX(*primitiveValue); 151 layer->setRepeatX(primitiveValue);
152 } 152 }
153 153
154 void CSSToStyleMap::mapFillRepeatY(StyleResolverState&, FillLayer* layer, CSSVal ue* 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.isPrimitiveValue())
162 return; 162 return;
163 163
164 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 164 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
165 layer->setRepeatY(*primitiveValue); 165 layer->setRepeatY(primitiveValue);
166 } 166 }
167 167
168 void CSSToStyleMap::mapFillSize(StyleResolverState& state, FillLayer* layer, CSS Value* 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.isPrimitiveValue() && !value.isValuePair())
177 return; 177 return;
178 178
179 if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID() == CSSValueContain) 179 if (value.isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID() == C SSValueContain)
180 layer->setSizeType(Contain); 180 layer->setSizeType(Contain);
181 else if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID () == CSSValueCover) 181 else if (value.isPrimitiveValue() && toCSSPrimitiveValue(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.isPrimitiveValue() && (toCSSPrimitiveValue(value).getValueID() == CSSValueContain || toCSSPrimitiveValue(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 CSSValuePair* pair = toCSSValuePair(value); 197 const CSSValuePair& pair = toCSSValuePair(value);
198 firstLength = StyleBuilderConverter::convertLengthOrAuto(state, &pair->f irst()); 198 // TODO(sashab): Make StyleBuilderConverter take const&s and remove thes e const_casts.
sashab 2015/10/07 01:37:58 convertLengthOrAuto can't be made to take a const
Timothy Loh 2015/10/07 02:27:00 OK
199 secondLength = StyleBuilderConverter::convertLengthOrAuto(state, &pair-> second()); 199 firstLength = StyleBuilderConverter::convertLengthOrAuto(state, const_ca st<CSSValue*>(&pair.first()));
200 secondLength = StyleBuilderConverter::convertLengthOrAuto(state, const_c ast<CSSValue*>(&pair.second()));
200 } else { 201 } else {
201 ASSERT(value->isPrimitiveValue()); 202 ASSERT(value.isPrimitiveValue());
202 firstLength = StyleBuilderConverter::convertLengthOrAuto(state, value); 203 firstLength = StyleBuilderConverter::convertLengthOrAuto(state, const_ca st<CSSValue*>(&value));
203 secondLength = Length(); 204 secondLength = Length();
204 } 205 }
205 206
206 b.setWidth(firstLength); 207 b.setWidth(firstLength);
207 b.setHeight(secondLength); 208 b.setHeight(secondLength);
208 layer->setSizeLength(b); 209 layer->setSizeLength(b);
209 } 210 }
210 211
211 void CSSToStyleMap::mapFillXPosition(StyleResolverState& state, FillLayer* layer , CSSValue* value) 212 void CSSToStyleMap::mapFillXPosition(StyleResolverState& state, FillLayer* layer , const CSSValue& value)
212 { 213 {
213 if (value->isInitialValue()) { 214 if (value.isInitialValue()) {
214 layer->setXPosition(FillLayer::initialFillXPosition(layer->type())); 215 layer->setXPosition(FillLayer::initialFillXPosition(layer->type()));
215 return; 216 return;
216 } 217 }
217 218
218 if (!value->isPrimitiveValue() && !value->isValuePair()) 219 if (!value.isPrimitiveValue() && !value.isValuePair())
219 return; 220 return;
220 221
221 Length length; 222 Length length;
222 if (value->isValuePair()) 223 if (value.isValuePair())
223 length = toCSSPrimitiveValue(toCSSValuePair(value)->second()).convertToL ength(state.cssToLengthConversionData()); 224 length = toCSSPrimitiveValue(toCSSValuePair(value).second()).convertToLe ngth(state.cssToLengthConversionData());
224 else 225 else
225 length = toCSSPrimitiveValue(value)->convertToLength(state.cssToLengthCo nversionData()); 226 length = toCSSPrimitiveValue(value).convertToLength(state.cssToLengthCon versionData());
226 227
227 layer->setXPosition(length); 228 layer->setXPosition(length);
228 if (value->isValuePair()) 229 if (value.isValuePair())
229 layer->setBackgroundXOrigin(toCSSPrimitiveValue(toCSSValuePair(value)->f irst())); 230 layer->setBackgroundXOrigin(toCSSPrimitiveValue(toCSSValuePair(value).fi rst()));
230 } 231 }
231 232
232 void CSSToStyleMap::mapFillYPosition(StyleResolverState& state, FillLayer* layer , CSSValue* value) 233 void CSSToStyleMap::mapFillYPosition(StyleResolverState& state, FillLayer* layer , const CSSValue& value)
233 { 234 {
234 if (value->isInitialValue()) { 235 if (value.isInitialValue()) {
235 layer->setYPosition(FillLayer::initialFillYPosition(layer->type())); 236 layer->setYPosition(FillLayer::initialFillYPosition(layer->type()));
236 return; 237 return;
237 } 238 }
238 239
239 if (!value->isPrimitiveValue() && !value->isValuePair()) 240 if (!value.isPrimitiveValue() && !value.isValuePair())
240 return; 241 return;
241 242
242 CSSPrimitiveValue* primitiveValue; 243 Length length;
243 if (value->isValuePair()) 244 if (value.isValuePair())
244 primitiveValue = &toCSSPrimitiveValue(toCSSValuePair(value)->second()); 245 length = toCSSPrimitiveValue(toCSSValuePair(value).second()).convertToLe ngth(state.cssToLengthConversionData());
245 else 246 else
246 primitiveValue = toCSSPrimitiveValue(value); 247 length = toCSSPrimitiveValue(value).convertToLength(state.cssToLengthCon versionData());
247
248 Length length = primitiveValue->convertToLength(state.cssToLengthConversionD ata());
249 248
250 layer->setYPosition(length); 249 layer->setYPosition(length);
251 if (value->isValuePair()) 250 if (value.isValuePair())
252 layer->setBackgroundYOrigin(toCSSPrimitiveValue(toCSSValuePair(value)->f irst())); 251 layer->setBackgroundYOrigin(toCSSPrimitiveValue(toCSSValuePair(value).fi rst()));
253 } 252 }
254 253
255 void CSSToStyleMap::mapFillMaskSourceType(StyleResolverState&, FillLayer* layer, CSSValue* value) 254 void CSSToStyleMap::mapFillMaskSourceType(StyleResolverState&, FillLayer* layer, const CSSValue& value)
256 { 255 {
257 EMaskSourceType type = FillLayer::initialFillMaskSourceType(layer->type()); 256 EMaskSourceType type = FillLayer::initialFillMaskSourceType(layer->type());
258 if (value->isInitialValue()) { 257 if (value.isInitialValue()) {
259 layer->setMaskSourceType(type); 258 layer->setMaskSourceType(type);
260 return; 259 return;
261 } 260 }
262 261
263 if (!value->isPrimitiveValue()) 262 if (!value.isPrimitiveValue())
264 return; 263 return;
265 264
266 switch (toCSSPrimitiveValue(value)->getValueID()) { 265 switch (toCSSPrimitiveValue(value).getValueID()) {
267 case CSSValueAlpha: 266 case CSSValueAlpha:
268 type = MaskAlpha; 267 type = MaskAlpha;
269 break; 268 break;
270 case CSSValueLuminance: 269 case CSSValueLuminance:
271 type = MaskLuminance; 270 type = MaskLuminance;
272 break; 271 break;
273 case CSSValueAuto: 272 case CSSValueAuto:
274 break; 273 break;
275 default: 274 default:
276 ASSERT_NOT_REACHED(); 275 ASSERT_NOT_REACHED();
277 } 276 }
278 277
279 layer->setMaskSourceType(type); 278 layer->setMaskSourceType(type);
280 } 279 }
281 280
282 double CSSToStyleMap::mapAnimationDelay(CSSValue* value) 281 double CSSToStyleMap::mapAnimationDelay(const CSSValue& value)
283 { 282 {
284 if (value->isInitialValue()) 283 if (value.isInitialValue())
285 return CSSTimingData::initialDelay(); 284 return CSSTimingData::initialDelay();
286 return toCSSPrimitiveValue(value)->computeSeconds(); 285 return toCSSPrimitiveValue(value).computeSeconds();
287 } 286 }
288 287
289 Timing::PlaybackDirection CSSToStyleMap::mapAnimationDirection(CSSValue* value) 288 Timing::PlaybackDirection CSSToStyleMap::mapAnimationDirection(const CSSValue& v alue)
290 { 289 {
291 if (value->isInitialValue()) 290 if (value.isInitialValue())
292 return CSSAnimationData::initialDirection(); 291 return CSSAnimationData::initialDirection();
293 292
294 switch (toCSSPrimitiveValue(value)->getValueID()) { 293 switch (toCSSPrimitiveValue(value).getValueID()) {
295 case CSSValueNormal: 294 case CSSValueNormal:
296 return Timing::PlaybackDirectionNormal; 295 return Timing::PlaybackDirectionNormal;
297 case CSSValueAlternate: 296 case CSSValueAlternate:
298 return Timing::PlaybackDirectionAlternate; 297 return Timing::PlaybackDirectionAlternate;
299 case CSSValueReverse: 298 case CSSValueReverse:
300 return Timing::PlaybackDirectionReverse; 299 return Timing::PlaybackDirectionReverse;
301 case CSSValueAlternateReverse: 300 case CSSValueAlternateReverse:
302 return Timing::PlaybackDirectionAlternateReverse; 301 return Timing::PlaybackDirectionAlternateReverse;
303 default: 302 default:
304 ASSERT_NOT_REACHED(); 303 ASSERT_NOT_REACHED();
305 return CSSAnimationData::initialDirection(); 304 return CSSAnimationData::initialDirection();
306 } 305 }
307 } 306 }
308 307
309 double CSSToStyleMap::mapAnimationDuration(CSSValue* value) 308 double CSSToStyleMap::mapAnimationDuration(const CSSValue& value)
310 { 309 {
311 if (value->isInitialValue()) 310 if (value.isInitialValue())
312 return CSSTimingData::initialDuration(); 311 return CSSTimingData::initialDuration();
313 return toCSSPrimitiveValue(value)->computeSeconds(); 312 return toCSSPrimitiveValue(value).computeSeconds();
314 } 313 }
315 314
316 Timing::FillMode CSSToStyleMap::mapAnimationFillMode(CSSValue* value) 315 Timing::FillMode CSSToStyleMap::mapAnimationFillMode(const CSSValue& value)
317 { 316 {
318 if (value->isInitialValue()) 317 if (value.isInitialValue())
319 return CSSAnimationData::initialFillMode(); 318 return CSSAnimationData::initialFillMode();
320 319
321 switch (toCSSPrimitiveValue(value)->getValueID()) { 320 switch (toCSSPrimitiveValue(value).getValueID()) {
322 case CSSValueNone: 321 case CSSValueNone:
323 return Timing::FillModeNone; 322 return Timing::FillModeNone;
324 case CSSValueForwards: 323 case CSSValueForwards:
325 return Timing::FillModeForwards; 324 return Timing::FillModeForwards;
326 case CSSValueBackwards: 325 case CSSValueBackwards:
327 return Timing::FillModeBackwards; 326 return Timing::FillModeBackwards;
328 case CSSValueBoth: 327 case CSSValueBoth:
329 return Timing::FillModeBoth; 328 return Timing::FillModeBoth;
330 default: 329 default:
331 ASSERT_NOT_REACHED(); 330 ASSERT_NOT_REACHED();
332 return CSSAnimationData::initialFillMode(); 331 return CSSAnimationData::initialFillMode();
333 } 332 }
334 } 333 }
335 334
336 double CSSToStyleMap::mapAnimationIterationCount(CSSValue* value) 335 double CSSToStyleMap::mapAnimationIterationCount(const CSSValue& value)
337 { 336 {
338 if (value->isInitialValue()) 337 if (value.isInitialValue())
339 return CSSAnimationData::initialIterationCount(); 338 return CSSAnimationData::initialIterationCount();
340 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 339 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
341 if (primitiveValue->getValueID() == CSSValueInfinite) 340 if (primitiveValue.getValueID() == CSSValueInfinite)
342 return std::numeric_limits<double>::infinity(); 341 return std::numeric_limits<double>::infinity();
343 return primitiveValue->getFloatValue(); 342 return primitiveValue.getFloatValue();
344 } 343 }
345 344
346 AtomicString CSSToStyleMap::mapAnimationName(CSSValue* value) 345 AtomicString CSSToStyleMap::mapAnimationName(const CSSValue& value)
347 { 346 {
348 if (value->isInitialValue()) 347 if (value.isInitialValue())
349 return CSSAnimationData::initialName(); 348 return CSSAnimationData::initialName();
350 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 349 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
351 if (primitiveValue->getValueID() == CSSValueNone) 350 if (primitiveValue.getValueID() == CSSValueNone)
352 return CSSAnimationData::initialName(); 351 return CSSAnimationData::initialName();
353 return AtomicString(primitiveValue->getStringValue()); 352 return AtomicString(primitiveValue.getStringValue());
354 } 353 }
355 354
356 EAnimPlayState CSSToStyleMap::mapAnimationPlayState(CSSValue* value) 355 EAnimPlayState CSSToStyleMap::mapAnimationPlayState(const CSSValue& value)
357 { 356 {
358 if (value->isInitialValue()) 357 if (value.isInitialValue())
359 return CSSAnimationData::initialPlayState(); 358 return CSSAnimationData::initialPlayState();
360 if (toCSSPrimitiveValue(value)->getValueID() == CSSValuePaused) 359 if (toCSSPrimitiveValue(value).getValueID() == CSSValuePaused)
361 return AnimPlayStatePaused; 360 return AnimPlayStatePaused;
362 ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueRunning); 361 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueRunning);
363 return AnimPlayStatePlaying; 362 return AnimPlayStatePlaying;
364 } 363 }
365 364
366 CSSTransitionData::TransitionProperty CSSToStyleMap::mapAnimationProperty(CSSVal ue* value) 365 CSSTransitionData::TransitionProperty CSSToStyleMap::mapAnimationProperty(const CSSValue& value)
367 { 366 {
368 if (value->isInitialValue()) 367 if (value.isInitialValue())
369 return CSSTransitionData::initialProperty(); 368 return CSSTransitionData::initialProperty();
370 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 369 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
371 if (primitiveValue->isCustomIdent()) 370 if (primitiveValue.isCustomIdent())
372 return CSSTransitionData::TransitionProperty(primitiveValue->getStringVa lue()); 371 return CSSTransitionData::TransitionProperty(primitiveValue.getStringVal ue());
373 if (primitiveValue->getValueID() == CSSValueNone) 372 if (primitiveValue.getValueID() == CSSValueNone)
374 return CSSTransitionData::TransitionProperty(CSSTransitionData::Transiti onNone); 373 return CSSTransitionData::TransitionProperty(CSSTransitionData::Transiti onNone);
375 return CSSTransitionData::TransitionProperty(primitiveValue->getPropertyID() ); 374 return CSSTransitionData::TransitionProperty(primitiveValue.getPropertyID()) ;
376 } 375 }
377 376
378 PassRefPtr<TimingFunction> CSSToStyleMap::mapAnimationTimingFunction(CSSValue* v alue, 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.isPrimitiveValue()) {
386 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 385 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
387 switch (primitiveValue->getValueID()) { 386 switch (primitiveValue.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:: Ease); 390 return CubicBezierTimingFunction::preset(CubicBezierTimingFunction:: Ease);
392 case CSSValueEaseIn: 391 case CSSValueEaseIn:
393 return CubicBezierTimingFunction::preset(CubicBezierTimingFunction:: EaseIn); 392 return CubicBezierTimingFunction::preset(CubicBezierTimingFunction:: EaseIn);
394 case CSSValueEaseOut: 393 case CSSValueEaseOut:
395 return CubicBezierTimingFunction::preset(CubicBezierTimingFunction:: EaseOut); 394 return CubicBezierTimingFunction::preset(CubicBezierTimingFunction:: EaseOut);
396 case CSSValueEaseInOut: 395 case CSSValueEaseInOut:
397 return CubicBezierTimingFunction::preset(CubicBezierTimingFunction:: EaseInOut); 396 return CubicBezierTimingFunction::preset(CubicBezierTimingFunction:: EaseInOut);
398 case CSSValueStepStart: 397 case CSSValueStepStart:
399 return StepsTimingFunction::preset(StepsTimingFunction::Start); 398 return StepsTimingFunction::preset(StepsTimingFunction::Start);
400 case CSSValueStepMiddle: 399 case CSSValueStepMiddle:
401 if (allowStepMiddle) 400 if (allowStepMiddle)
402 return StepsTimingFunction::preset(StepsTimingFunction::Middle); 401 return StepsTimingFunction::preset(StepsTimingFunction::Middle);
403 return CSSTimingData::initialTimingFunction(); 402 return CSSTimingData::initialTimingFunction();
404 case CSSValueStepEnd: 403 case CSSValueStepEnd:
405 return StepsTimingFunction::preset(StepsTimingFunction::End); 404 return StepsTimingFunction::preset(StepsTimingFunction::End);
406 default: 405 default:
407 ASSERT_NOT_REACHED(); 406 ASSERT_NOT_REACHED();
408 return CSSTimingData::initialTimingFunction(); 407 return CSSTimingData::initialTimingFunction();
409 } 408 }
410 } 409 }
411 410
412 if (value->isCubicBezierTimingFunctionValue()) { 411 if (value.isCubicBezierTimingFunctionValue()) {
413 CSSCubicBezierTimingFunctionValue* cubicTimingFunction = toCSSCubicBezie rTimingFunctionValue(value); 412 const CSSCubicBezierTimingFunctionValue& cubicTimingFunction = toCSSCubi cBezierTimingFunctionValue(value);
414 return CubicBezierTimingFunction::create(cubicTimingFunction->x1(), cubi cTimingFunction->y1(), cubicTimingFunction->x2(), cubicTimingFunction->y2()); 413 return CubicBezierTimingFunction::create(cubicTimingFunction.x1(), cubic TimingFunction.y1(), cubicTimingFunction.x2(), cubicTimingFunction.y2());
415 } 414 }
416 415
417 if (value->isInitialValue()) 416 if (value.isInitialValue())
418 return CSSTimingData::initialTimingFunction(); 417 return CSSTimingData::initialTimingFunction();
419 418
420 CSSStepsTimingFunctionValue* stepsTimingFunction = toCSSStepsTimingFunctionV alue(value); 419 const CSSStepsTimingFunctionValue& stepsTimingFunction = toCSSStepsTimingFun ctionValue(value);
421 if (stepsTimingFunction->stepAtPosition() == StepsTimingFunction::Middle && !allowStepMiddle) 420 if (stepsTimingFunction.stepAtPosition() == StepsTimingFunction::Middle && ! allowStepMiddle)
422 return CSSTimingData::initialTimingFunction(); 421 return CSSTimingData::initialTimingFunction();
423 return StepsTimingFunction::create(stepsTimingFunction->numberOfSteps(), ste psTimingFunction->stepAtPosition()); 422 return StepsTimingFunction::create(stepsTimingFunction.numberOfSteps(), step sTimingFunction.stepAtPosition());
424 } 423 }
425 424
426 void CSSToStyleMap::mapNinePieceImage(StyleResolverState& state, CSSPropertyID p roperty, CSSValue* value, NinePieceImage& image) 425 void CSSToStyleMap::mapNinePieceImage(StyleResolverState& state, CSSPropertyID p roperty, const CSSValue& value, NinePieceImage& image)
427 { 426 {
428 // If we're not a value list, then we are "none" and don't need to alter the empty image at all. 427 // If we're not a value list, then we are "none" and don't need to alter the empty image at all.
429 if (!value || !value->isValueList()) 428 if (!value.isValueList())
430 return; 429 return;
431 430
432 // Retrieve the border image value. 431 // Retrieve the border image value.
433 CSSValueList* borderImage = toCSSValueList(value); 432 const CSSValueList& borderImage = toCSSValueList(value);
434 433
435 // Set the image (this kicks off the load). 434 // Set the image (this kicks off the load).
436 CSSPropertyID imageProperty; 435 CSSPropertyID imageProperty;
437 if (property == CSSPropertyWebkitBorderImage) 436 if (property == CSSPropertyWebkitBorderImage)
438 imageProperty = CSSPropertyBorderImageSource; 437 imageProperty = CSSPropertyBorderImageSource;
439 else if (property == CSSPropertyWebkitMaskBoxImage) 438 else if (property == CSSPropertyWebkitMaskBoxImage)
440 imageProperty = CSSPropertyWebkitMaskBoxImageSource; 439 imageProperty = CSSPropertyWebkitMaskBoxImageSource;
441 else 440 else
442 imageProperty = property; 441 imageProperty = property;
443 442
444 for (unsigned i = 0 ; i < borderImage->length() ; ++i) { 443 for (unsigned i = 0 ; i < borderImage.length() ; ++i) {
445 CSSValue* current = borderImage->item(i); 444 const CSSValue& current = *borderImage.item(i);
446 445
447 if (current->isImageValue() || current->isImageGeneratorValue() || curre nt->isImageSetValue()) 446 if (current.isImageValue() || current.isImageGeneratorValue() || current .isImageSetValue()) {
448 image.setImage(state.styleImage(imageProperty, *current)); 447 image.setImage(state.styleImage(imageProperty, current));
449 else if (current->isBorderImageSliceValue()) 448 } else if (current.isBorderImageSliceValue()) {
450 mapNinePieceImageSlice(state, current, image); 449 mapNinePieceImageSlice(state, current, image);
451 else if (current->isValueList()) { 450 } else if (current.isValueList()) {
452 CSSValueList* slashList = toCSSValueList(current); 451 const CSSValueList& slashList = toCSSValueList(current);
453 size_t length = slashList->length(); 452 size_t length = slashList.length();
454 // Map in the image slices. 453 // Map in the image slices.
455 if (length && slashList->item(0)->isBorderImageSliceValue()) 454 if (length && slashList.item(0)->isBorderImageSliceValue())
456 mapNinePieceImageSlice(state, slashList->item(0), image); 455 mapNinePieceImageSlice(state, *slashList.item(0), image);
457 456
458 // Map in the border slices. 457 // Map in the border slices.
459 if (length > 1) 458 if (length > 1)
460 image.setBorderSlices(mapNinePieceImageQuad(state, slashList->it em(1))); 459 image.setBorderSlices(mapNinePieceImageQuad(state, *slashList.it em(1)));
461 460
462 // Map in the outset. 461 // Map in the outset.
463 if (length > 2) 462 if (length > 2)
464 image.setOutset(mapNinePieceImageQuad(state, slashList->item(2)) ); 463 image.setOutset(mapNinePieceImageQuad(state, *slashList.item(2)) );
465 } else if (current->isPrimitiveValue() || current->isValuePair()) { 464 } else if (current.isPrimitiveValue() || current.isValuePair()) {
466 // Set the appropriate rules for stretch/round/repeat of the slices. 465 // Set the appropriate rules for stretch/round/repeat of the slices.
467 mapNinePieceImageRepeat(state, current, image); 466 mapNinePieceImageRepeat(state, current, image);
468 } 467 }
469 } 468 }
470 469
471 if (property == CSSPropertyWebkitBorderImage) { 470 if (property == CSSPropertyWebkitBorderImage) {
472 // We have to preserve the legacy behavior of -webkit-border-image and m ake the border slices 471 // We have to preserve the legacy behavior of -webkit-border-image and m ake the border slices
473 // also set the border widths. We don't need to worry about percentages, since we don't even support 472 // also set the border widths. We don't need to worry about percentages, since we don't even support
474 // those on real borders yet. 473 // those on real borders yet.
475 if (image.borderSlices().top().isLength() && image.borderSlices().top(). length().isFixed()) 474 if (image.borderSlices().top().isLength() && image.borderSlices().top(). length().isFixed())
476 state.style()->setBorderTopWidth(image.borderSlices().top().length() .value()); 475 state.style()->setBorderTopWidth(image.borderSlices().top().length() .value());
477 if (image.borderSlices().right().isLength() && image.borderSlices().righ t().length().isFixed()) 476 if (image.borderSlices().right().isLength() && image.borderSlices().righ t().length().isFixed())
478 state.style()->setBorderRightWidth(image.borderSlices().right().leng th().value()); 477 state.style()->setBorderRightWidth(image.borderSlices().right().leng th().value());
479 if (image.borderSlices().bottom().isLength() && image.borderSlices().bot tom().length().isFixed()) 478 if (image.borderSlices().bottom().isLength() && image.borderSlices().bot tom().length().isFixed())
480 state.style()->setBorderBottomWidth(image.borderSlices().bottom().le ngth().value()); 479 state.style()->setBorderBottomWidth(image.borderSlices().bottom().le ngth().value());
481 if (image.borderSlices().left().isLength() && image.borderSlices().left( ).length().isFixed()) 480 if (image.borderSlices().left().isLength() && image.borderSlices().left( ).length().isFixed())
482 state.style()->setBorderLeftWidth(image.borderSlices().left().length ().value()); 481 state.style()->setBorderLeftWidth(image.borderSlices().left().length ().value());
483 } 482 }
484 } 483 }
485 484
486 void CSSToStyleMap::mapNinePieceImageSlice(StyleResolverState&, CSSValue* value, NinePieceImage& image) 485 void CSSToStyleMap::mapNinePieceImageSlice(StyleResolverState&, const CSSValue& value, NinePieceImage& image)
487 { 486 {
488 if (!value || !value->isBorderImageSliceValue()) 487 if (!value.isBorderImageSliceValue())
489 return; 488 return;
490 489
491 // Retrieve the border image value. 490 // Retrieve the border image value.
492 CSSBorderImageSliceValue* borderImageSlice = toCSSBorderImageSliceValue(valu e); 491 const CSSBorderImageSliceValue& borderImageSlice = toCSSBorderImageSliceValu e(value);
493 492
494 // Set up a length box to represent our image slices. 493 // Set up a length box to represent our image slices.
495 LengthBox box; 494 LengthBox box;
496 CSSQuadValue* slices = borderImageSlice->slices(); 495 CSSQuadValue* slices = borderImageSlice.slices();
497 if (slices->top()->isPercentage()) 496 if (slices->top()->isPercentage())
498 box.m_top = Length(slices->top()->getDoubleValue(), Percent); 497 box.m_top = Length(slices->top()->getDoubleValue(), Percent);
499 else 498 else
500 box.m_top = Length(slices->top()->getIntValue(), Fixed); 499 box.m_top = Length(slices->top()->getIntValue(), Fixed);
501 if (slices->bottom()->isPercentage()) 500 if (slices->bottom()->isPercentage())
502 box.m_bottom = Length(slices->bottom()->getDoubleValue(), Percent); 501 box.m_bottom = Length(slices->bottom()->getDoubleValue(), Percent);
503 else 502 else
504 box.m_bottom = Length(slices->bottom()->getIntValue(), Fixed); 503 box.m_bottom = Length(slices->bottom()->getIntValue(), Fixed);
505 if (slices->left()->isPercentage()) 504 if (slices->left()->isPercentage())
506 box.m_left = Length(slices->left()->getDoubleValue(), Percent); 505 box.m_left = Length(slices->left()->getDoubleValue(), Percent);
507 else 506 else
508 box.m_left = Length(slices->left()->getIntValue(), Fixed); 507 box.m_left = Length(slices->left()->getIntValue(), Fixed);
509 if (slices->right()->isPercentage()) 508 if (slices->right()->isPercentage())
510 box.m_right = Length(slices->right()->getDoubleValue(), Percent); 509 box.m_right = Length(slices->right()->getDoubleValue(), Percent);
511 else 510 else
512 box.m_right = Length(slices->right()->getIntValue(), Fixed); 511 box.m_right = Length(slices->right()->getIntValue(), Fixed);
513 image.setImageSlices(box); 512 image.setImageSlices(box);
514 513
515 // Set our fill mode. 514 // Set our fill mode.
516 image.setFill(borderImageSlice->m_fill); 515 image.setFill(borderImageSlice.m_fill);
517 } 516 }
518 517
519 static BorderImageLength toBorderImageLength(CSSPrimitiveValue& value, const CSS ToLengthConversionData& conversionData) 518 static BorderImageLength toBorderImageLength(CSSPrimitiveValue& value, const CSS ToLengthConversionData& conversionData)
520 { 519 {
521 if (value.isNumber()) 520 if (value.isNumber())
522 return value.getDoubleValue(); 521 return value.getDoubleValue();
523 if (value.isPercentage()) 522 if (value.isPercentage())
524 return Length(value.getDoubleValue(), Percent); 523 return Length(value.getDoubleValue(), Percent);
525 if (value.getValueID() != CSSValueAuto) 524 if (value.getValueID() != CSSValueAuto)
526 return value.computeLength<Length>(conversionData); 525 return value.computeLength<Length>(conversionData);
527 return Length(Auto); 526 return Length(Auto);
528 } 527 }
529 528
530 BorderImageLengthBox CSSToStyleMap::mapNinePieceImageQuad(StyleResolverState& st ate, CSSValue* value) 529 BorderImageLengthBox CSSToStyleMap::mapNinePieceImageQuad(StyleResolverState& st ate, const CSSValue& value)
531 { 530 {
532 if (!value || !value->isQuadValue()) 531 if (!value.isQuadValue())
533 return BorderImageLengthBox(Length(Auto)); 532 return BorderImageLengthBox(Length(Auto));
534 533
535 RefPtrWillBeRawPtr<CSSQuadValue> slices = toCSSQuadValue(value); 534 const CSSQuadValue& slices = toCSSQuadValue(value);
536 535
537 // Set up a border image length box to represent our image slices. 536 // Set up a border image length box to represent our image slices.
538 return BorderImageLengthBox( 537 return BorderImageLengthBox(
539 toBorderImageLength(*slices->top(), state.cssToLengthConversionData()), 538 toBorderImageLength(*slices.top(), state.cssToLengthConversionData()),
540 toBorderImageLength(*slices->right(), state.cssToLengthConversionData()) , 539 toBorderImageLength(*slices.right(), state.cssToLengthConversionData()),
541 toBorderImageLength(*slices->bottom(), state.cssToLengthConversionData() ), 540 toBorderImageLength(*slices.bottom(), state.cssToLengthConversionData()) ,
542 toBorderImageLength(*slices->left(), state.cssToLengthConversionData())) ; 541 toBorderImageLength(*slices.left(), state.cssToLengthConversionData()));
543 } 542 }
544 543
545 void CSSToStyleMap::mapNinePieceImageRepeat(StyleResolverState&, CSSValue* value , NinePieceImage& image) 544 void CSSToStyleMap::mapNinePieceImageRepeat(StyleResolverState&, const CSSValue& value, NinePieceImage& image)
546 { 545 {
547 if (!value || !value->isValuePair()) 546 if (!value.isValuePair())
548 return; 547 return;
549 548
550 const CSSValuePair& pair = toCSSValuePair(*value); 549 const CSSValuePair& pair = toCSSValuePair(value);
551 CSSValueID firstIdentifier = toCSSPrimitiveValue(pair.first()).getValueID(); 550 CSSValueID firstIdentifier = toCSSPrimitiveValue(pair.first()).getValueID();
552 CSSValueID secondIdentifier = toCSSPrimitiveValue(pair.second()).getValueID( ); 551 CSSValueID secondIdentifier = toCSSPrimitiveValue(pair.second()).getValueID( );
553 552
554 ENinePieceImageRule horizontalRule; 553 ENinePieceImageRule horizontalRule;
555 switch (firstIdentifier) { 554 switch (firstIdentifier) {
556 case CSSValueStretch: 555 case CSSValueStretch:
557 horizontalRule = StretchImageRule; 556 horizontalRule = StretchImageRule;
558 break; 557 break;
559 case CSSValueRound: 558 case CSSValueRound:
560 horizontalRule = RoundImageRule; 559 horizontalRule = RoundImageRule;
(...skipping 19 matching lines...) Expand all
580 verticalRule = SpaceImageRule; 579 verticalRule = SpaceImageRule;
581 break; 580 break;
582 default: // CSSValueRepeat 581 default: // CSSValueRepeat
583 verticalRule = RepeatImageRule; 582 verticalRule = RepeatImageRule;
584 break; 583 break;
585 } 584 }
586 image.setVerticalRule(verticalRule); 585 image.setVerticalRule(verticalRule);
587 } 586 }
588 587
589 }; 588 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698