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

Side by Side Diff: Source/core/css/resolver/StyleBuilderConverter.cpp

Issue 1164573002: CSSValue Immediates: Change CSSValue to an object instead of a pointer (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 4 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * * Redistributions of source code must retain the above copyright 4 * * Redistributions of source code must retain the above copyright
5 * notice, this list of conditions and the following disclaimer. 5 * notice, this list of conditions and the following disclaimer.
6 * * Redistributions in binary form must reproduce the above 6 * * Redistributions in binary form must reproduce the above
7 * copyright notice, this list of conditions and the following disclaimer 7 * copyright notice, this list of conditions and the following disclaimer
8 * in the documentation and/or other materials provided with the 8 * in the documentation and/or other materials provided with the
9 * distribution. 9 * distribution.
10 * * Neither the name of Google Inc. nor the names of its 10 * * Neither the name of Google Inc. nor the names of its
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 if (primitiveValue->getValueID() == CSSValueMinContent) 52 if (primitiveValue->getValueID() == CSSValueMinContent)
53 return Length(MinContent); 53 return Length(MinContent);
54 54
55 if (primitiveValue->getValueID() == CSSValueMaxContent) 55 if (primitiveValue->getValueID() == CSSValueMaxContent)
56 return Length(MaxContent); 56 return Length(MaxContent);
57 57
58 // Fractional unit. 58 // Fractional unit.
59 if (primitiveValue->isFlex()) 59 if (primitiveValue->isFlex())
60 return GridLength(primitiveValue->getDoubleValue()); 60 return GridLength(primitiveValue->getDoubleValue());
61 61
62 return StyleBuilderConverter::convertLengthOrAuto(state, primitiveValue); 62 return StyleBuilderConverter::convertLengthOrAuto(state, CSSValue(*primitive Value));
63 } 63 }
64 64
65 } // namespace 65 } // namespace
66 66
67 PassRefPtr<StyleReflection> StyleBuilderConverter::convertBoxReflect(StyleResolv erState& state, CSSValue* value) 67 PassRefPtr<StyleReflection> StyleBuilderConverter::convertBoxReflect(StyleResolv erState& state, CSSValue value)
68 { 68 {
69 if (value->isPrimitiveValue()) { 69 if (value.isPrimitiveValue()) {
70 ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueNone); 70 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNone);
71 return ComputedStyle::initialBoxReflect(); 71 return ComputedStyle::initialBoxReflect();
72 } 72 }
73 73
74 CSSReflectValue* reflectValue = toCSSReflectValue(value); 74 CSSReflectValue& reflectValue = toCSSReflectValue(value);
75 RefPtr<StyleReflection> reflection = StyleReflection::create(); 75 RefPtr<StyleReflection> reflection = StyleReflection::create();
76 reflection->setDirection(*reflectValue->direction()); 76 reflection->setDirection(*reflectValue.direction());
77 if (reflectValue->offset()) 77 if (reflectValue.offset())
78 reflection->setOffset(reflectValue->offset()->convertToLength(state.cssT oLengthConversionData())); 78 reflection->setOffset(reflectValue.offset()->convertToLength(state.cssTo LengthConversionData()));
79 NinePieceImage mask; 79 NinePieceImage mask;
80 mask.setMaskDefaults(); 80 mask.setMaskDefaults();
81 CSSToStyleMap::mapNinePieceImage(state, CSSPropertyWebkitBoxReflect, reflect Value->mask(), mask); 81 CSSToStyleMap::mapNinePieceImage(state, CSSPropertyWebkitBoxReflect, reflect Value.mask(), mask);
82 reflection->setMask(mask); 82 reflection->setMask(mask);
83 83
84 return reflection.release(); 84 return reflection.release();
85 } 85 }
86 86
87 Color StyleBuilderConverter::convertColor(StyleResolverState& state, CSSValue* v alue, bool forVisitedLink) 87 Color StyleBuilderConverter::convertColor(StyleResolverState& state, CSSValue va lue, bool forVisitedLink)
88 { 88 {
89 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 89 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
90 return state.document().textLinkColors().colorFromPrimitiveValue(primitiveVa lue, state.style()->color(), forVisitedLink); 90 return state.document().textLinkColors().colorFromPrimitiveValue(primitiveVa lue, state.style()->color(), forVisitedLink);
91 } 91 }
92 92
93 AtomicString StyleBuilderConverter::convertFragmentIdentifier(StyleResolverState & state, CSSValue* value) 93 AtomicString StyleBuilderConverter::convertFragmentIdentifier(StyleResolverState & state, CSSValue value)
94 { 94 {
95 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 95 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
96 if (primitiveValue->isURI()) 96 if (primitiveValue.isURI())
97 return SVGURIReference::fragmentIdentifierFromIRIString(primitiveValue-> getStringValue(), state.element()->treeScope()); 97 return SVGURIReference::fragmentIdentifierFromIRIString(primitiveValue.g etStringValue(), state.element()->treeScope());
98 return nullAtom; 98 return nullAtom;
99 } 99 }
100 100
101 LengthBox StyleBuilderConverter::convertClip(StyleResolverState& state, CSSValue * value) 101 LengthBox StyleBuilderConverter::convertClip(StyleResolverState& state, CSSValue value)
102 { 102 {
103 Rect* rect = toCSSPrimitiveValue(value)->getRectValue(); 103 Rect* rect = toCSSPrimitiveValue(value).getRectValue();
104 104
105 return LengthBox(convertLengthOrAuto(state, rect->top()), 105 return LengthBox(convertLengthOrAuto(state, CSSValue(*rect->top())),
106 convertLengthOrAuto(state, rect->right()), 106 convertLengthOrAuto(state, CSSValue(*rect->right())),
107 convertLengthOrAuto(state, rect->bottom()), 107 convertLengthOrAuto(state, CSSValue(*rect->bottom())),
108 convertLengthOrAuto(state, rect->left())); 108 convertLengthOrAuto(state, CSSValue(*rect->left())));
109 } 109 }
110 110
111 static FontDescription::GenericFamilyType convertGenericFamily(CSSValueID valueI D) 111 static FontDescription::GenericFamilyType convertGenericFamily(CSSValueID valueI D)
112 { 112 {
113 switch (valueID) { 113 switch (valueID) {
114 case CSSValueWebkitBody: 114 case CSSValueWebkitBody:
115 return FontDescription::StandardFamily; 115 return FontDescription::StandardFamily;
116 case CSSValueSerif: 116 case CSSValueSerif:
117 return FontDescription::SerifFamily; 117 return FontDescription::SerifFamily;
118 case CSSValueSansSerif: 118 case CSSValueSansSerif:
119 return FontDescription::SansSerifFamily; 119 return FontDescription::SansSerifFamily;
120 case CSSValueCursive: 120 case CSSValueCursive:
121 return FontDescription::CursiveFamily; 121 return FontDescription::CursiveFamily;
122 case CSSValueFantasy: 122 case CSSValueFantasy:
123 return FontDescription::FantasyFamily; 123 return FontDescription::FantasyFamily;
124 case CSSValueMonospace: 124 case CSSValueMonospace:
125 return FontDescription::MonospaceFamily; 125 return FontDescription::MonospaceFamily;
126 case CSSValueWebkitPictograph: 126 case CSSValueWebkitPictograph:
127 return FontDescription::PictographFamily; 127 return FontDescription::PictographFamily;
128 default: 128 default:
129 return FontDescription::NoFamily; 129 return FontDescription::NoFamily;
130 } 130 }
131 } 131 }
132 132
133 static bool convertFontFamilyName(StyleResolverState& state, CSSPrimitiveValue* primitiveValue, 133 static bool convertFontFamilyName(StyleResolverState& state, CSSPrimitiveValue& primitiveValue,
134 FontDescription::GenericFamilyType& genericFamily, AtomicString& familyName) 134 FontDescription::GenericFamilyType& genericFamily, AtomicString& familyName)
135 { 135 {
136 if (primitiveValue->isCustomIdent()) { 136 if (primitiveValue.isCustomIdent()) {
137 genericFamily = FontDescription::NoFamily; 137 genericFamily = FontDescription::NoFamily;
138 familyName = AtomicString(primitiveValue->getStringValue()); 138 familyName = AtomicString(primitiveValue.getStringValue());
139 } else if (state.document().settings()) { 139 } else if (state.document().settings()) {
140 genericFamily = convertGenericFamily(primitiveValue->getValueID()); 140 genericFamily = convertGenericFamily(primitiveValue.getValueID());
141 familyName = state.fontBuilder().genericFontFamilyName(genericFamily); 141 familyName = state.fontBuilder().genericFontFamilyName(genericFamily);
142 } 142 }
143 143
144 return !familyName.isEmpty(); 144 return !familyName.isEmpty();
145 } 145 }
146 146
147 FontDescription::FamilyDescription StyleBuilderConverter::convertFontFamily(Styl eResolverState& state, CSSValue* value) 147 FontDescription::FamilyDescription StyleBuilderConverter::convertFontFamily(Styl eResolverState& state, CSSValue value)
148 { 148 {
149 ASSERT(value->isValueList()); 149 ASSERT(value.isValueList());
150 150
151 FontDescription::FamilyDescription desc(FontDescription::NoFamily); 151 FontDescription::FamilyDescription desc(FontDescription::NoFamily);
152 FontFamily* currFamily = nullptr; 152 FontFamily* currFamily = nullptr;
153 153
154 for (auto& family : toCSSValueList(*value)) { 154 for (auto& family : toCSSValueList(value)) {
155 FontDescription::GenericFamilyType genericFamily = FontDescription::NoFa mily; 155 FontDescription::GenericFamilyType genericFamily = FontDescription::NoFa mily;
156 AtomicString familyName; 156 AtomicString familyName;
157 157
158 if (!convertFontFamilyName(state, toCSSPrimitiveValue(family.get()), gen ericFamily, familyName)) 158 if (!convertFontFamilyName(state, toCSSPrimitiveValue(family), genericFa mily, familyName))
159 continue; 159 continue;
160 160
161 if (!currFamily) { 161 if (!currFamily) {
162 currFamily = &desc.family; 162 currFamily = &desc.family;
163 } else { 163 } else {
164 RefPtr<SharedFontFamily> newFamily = SharedFontFamily::create(); 164 RefPtr<SharedFontFamily> newFamily = SharedFontFamily::create();
165 currFamily->appendFamily(newFamily); 165 currFamily->appendFamily(newFamily);
166 currFamily = newFamily.get(); 166 currFamily = newFamily.get();
167 } 167 }
168 168
169 currFamily->setFamily(familyName); 169 currFamily->setFamily(familyName);
170 170
171 if (genericFamily != FontDescription::NoFamily) 171 if (genericFamily != FontDescription::NoFamily)
172 desc.genericFamily = genericFamily; 172 desc.genericFamily = genericFamily;
173 } 173 }
174 174
175 return desc; 175 return desc;
176 } 176 }
177 177
178 PassRefPtr<FontFeatureSettings> StyleBuilderConverter::convertFontFeatureSetting s(StyleResolverState& state, CSSValue* value) 178 PassRefPtr<FontFeatureSettings> StyleBuilderConverter::convertFontFeatureSetting s(StyleResolverState& state, CSSValue value)
179 { 179 {
180 if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID() == CSSValueNormal) 180 if (value.isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID() == C SSValueNormal)
181 return FontBuilder::initialFeatureSettings(); 181 return FontBuilder::initialFeatureSettings();
182 182
183 CSSValueList* list = toCSSValueList(value); 183 CSSValueList& list = toCSSValueList(value);
184 RefPtr<FontFeatureSettings> settings = FontFeatureSettings::create(); 184 RefPtr<FontFeatureSettings> settings = FontFeatureSettings::create();
185 int len = list->length(); 185 int len = list.length();
186 for (int i = 0; i < len; ++i) { 186 for (int i = 0; i < len; ++i) {
187 CSSFontFeatureValue* feature = toCSSFontFeatureValue(list->item(i)); 187 CSSFontFeatureValue& feature = toCSSFontFeatureValue(list.item(i));
188 settings->append(FontFeature(feature->tag(), feature->value())); 188 settings->append(FontFeature(feature.tag(), feature.value()));
189 } 189 }
190 return settings; 190 return settings;
191 } 191 }
192 192
193 static float computeFontSize(StyleResolverState& state, CSSPrimitiveValue* primi tiveValue, const FontDescription::Size& parentSize) 193 static float computeFontSize(StyleResolverState& state, CSSPrimitiveValue& primi tiveValue, const FontDescription::Size& parentSize)
194 { 194 {
195 float em = state.parentStyle()->specifiedFontSize(); 195 float em = state.parentStyle()->specifiedFontSize();
196 float rem = state.rootElementStyle() ? state.rootElementStyle()->specifiedFo ntSize() : 1.0f; 196 float rem = state.rootElementStyle() ? state.rootElementStyle()->specifiedFo ntSize() : 1.0f;
197 CSSToLengthConversionData::FontSizes fontSizes(em, rem, &state.parentStyle() ->font()); 197 CSSToLengthConversionData::FontSizes fontSizes(em, rem, &state.parentStyle() ->font());
198 CSSToLengthConversionData::ViewportSize viewportSize(state.document().layout View()); 198 CSSToLengthConversionData::ViewportSize viewportSize(state.document().layout View());
199 199
200 CSSToLengthConversionData conversionData(state.style(), fontSizes, viewportS ize, 1.0f); 200 CSSToLengthConversionData conversionData(state.style(), fontSizes, viewportS ize, 1.0f);
201 if (primitiveValue->isLength()) 201 if (primitiveValue.isLength())
202 return primitiveValue->computeLength<float>(conversionData); 202 return primitiveValue.computeLength<float>(conversionData);
203 if (primitiveValue->isCalculatedPercentageWithLength()) 203 if (primitiveValue.isCalculatedPercentageWithLength())
204 return primitiveValue->cssCalcValue()->toCalcValue(conversionData)->eval uate(parentSize.value); 204 return primitiveValue.cssCalcValue()->toCalcValue(conversionData)->evalu ate(parentSize.value);
205 205
206 ASSERT_NOT_REACHED(); 206 ASSERT_NOT_REACHED();
207 return 0; 207 return 0;
208 } 208 }
209 209
210 FontDescription::Size StyleBuilderConverter::convertFontSize(StyleResolverState& state, CSSValue* value) 210 FontDescription::Size StyleBuilderConverter::convertFontSize(StyleResolverState& state, CSSValue value)
211 { 211 {
212 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 212 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
213 213
214 FontDescription::Size parentSize(0, 0.0f, false); 214 FontDescription::Size parentSize(0, 0.0f, false);
215 215
216 // FIXME: Find out when parentStyle could be 0? 216 // FIXME: Find out when parentStyle could be 0?
217 if (state.parentStyle()) 217 if (state.parentStyle())
218 parentSize = state.parentFontDescription().size(); 218 parentSize = state.parentFontDescription().size();
219 219
220 if (CSSValueID valueID = primitiveValue->getValueID()) { 220 if (CSSValueID valueID = primitiveValue.getValueID()) {
221 switch (valueID) { 221 switch (valueID) {
222 case CSSValueXxSmall: 222 case CSSValueXxSmall:
223 case CSSValueXSmall: 223 case CSSValueXSmall:
224 case CSSValueSmall: 224 case CSSValueSmall:
225 case CSSValueMedium: 225 case CSSValueMedium:
226 case CSSValueLarge: 226 case CSSValueLarge:
227 case CSSValueXLarge: 227 case CSSValueXLarge:
228 case CSSValueXxLarge: 228 case CSSValueXxLarge:
229 case CSSValueWebkitXxxLarge: 229 case CSSValueWebkitXxxLarge:
230 return FontDescription::Size(FontSize::keywordSize(valueID), 0.0f, f alse); 230 return FontDescription::Size(FontSize::keywordSize(valueID), 0.0f, f alse);
231 case CSSValueLarger: 231 case CSSValueLarger:
232 return FontDescription::largerSize(parentSize); 232 return FontDescription::largerSize(parentSize);
233 case CSSValueSmaller: 233 case CSSValueSmaller:
234 return FontDescription::smallerSize(parentSize); 234 return FontDescription::smallerSize(parentSize);
235 default: 235 default:
236 ASSERT_NOT_REACHED(); 236 ASSERT_NOT_REACHED();
237 return FontBuilder::initialSize(); 237 return FontBuilder::initialSize();
238 } 238 }
239 } 239 }
240 240
241 bool parentIsAbsoluteSize = state.parentFontDescription().isAbsoluteSize(); 241 bool parentIsAbsoluteSize = state.parentFontDescription().isAbsoluteSize();
242 242
243 if (primitiveValue->isPercentage()) 243 if (primitiveValue.isPercentage())
244 return FontDescription::Size(0, (primitiveValue->getFloatValue() * paren tSize.value / 100.0f), parentIsAbsoluteSize); 244 return FontDescription::Size(0, (primitiveValue.getFloatValue() * parent Size.value / 100.0f), parentIsAbsoluteSize);
245 245
246 return FontDescription::Size(0, computeFontSize(state, primitiveValue, paren tSize), parentIsAbsoluteSize || !primitiveValue->isFontRelativeLength()); 246 return FontDescription::Size(0, computeFontSize(state, primitiveValue, paren tSize), parentIsAbsoluteSize || !primitiveValue.isFontRelativeLength());
247 } 247 }
248 248
249 float StyleBuilderConverter::convertFontSizeAdjust(StyleResolverState& state, CS SValue* value) 249 float StyleBuilderConverter::convertFontSizeAdjust(StyleResolverState& state, CS SValue value)
250 { 250 {
251 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 251 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
252 if (primitiveValue->getValueID() == CSSValueNone) 252 if (primitiveValue.getValueID() == CSSValueNone)
253 return FontBuilder::initialSizeAdjust(); 253 return FontBuilder::initialSizeAdjust();
254 254
255 ASSERT(primitiveValue->isNumber()); 255 ASSERT(primitiveValue.isNumber());
256 return primitiveValue->getFloatValue(); 256 return primitiveValue.getFloatValue();
257 } 257 }
258 258
259 FontWeight StyleBuilderConverter::convertFontWeight(StyleResolverState& state, C SSValue* value) 259 FontWeight StyleBuilderConverter::convertFontWeight(StyleResolverState& state, C SSValue value)
260 { 260 {
261 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 261 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
262 switch (primitiveValue->getValueID()) { 262 switch (primitiveValue.getValueID()) {
263 case CSSValueBolder: 263 case CSSValueBolder:
264 return FontDescription::bolderWeight(state.parentStyle()->fontDescriptio n().weight()); 264 return FontDescription::bolderWeight(state.parentStyle()->fontDescriptio n().weight());
265 case CSSValueLighter: 265 case CSSValueLighter:
266 return FontDescription::lighterWeight(state.parentStyle()->fontDescripti on().weight()); 266 return FontDescription::lighterWeight(state.parentStyle()->fontDescripti on().weight());
267 default: 267 default:
268 return *primitiveValue; 268 return primitiveValue;
269 } 269 }
270 } 270 }
271 271
272 FontDescription::VariantLigatures StyleBuilderConverter::convertFontVariantLigat ures(StyleResolverState&, CSSValue* value) 272 FontDescription::VariantLigatures StyleBuilderConverter::convertFontVariantLigat ures(StyleResolverState&, CSSValue value)
273 { 273 {
274 if (value->isValueList()) { 274 if (value.isValueList()) {
275 FontDescription::VariantLigatures ligatures; 275 FontDescription::VariantLigatures ligatures;
276 CSSValueList* valueList = toCSSValueList(value); 276 CSSValueList& valueList = toCSSValueList(value);
277 for (size_t i = 0; i < valueList->length(); ++i) { 277 for (size_t i = 0; i < valueList.length(); ++i) {
278 CSSValue* item = valueList->item(i); 278 CSSValue item = valueList.item(i);
279 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(item); 279 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(item);
280 switch (primitiveValue->getValueID()) { 280 switch (primitiveValue.getValueID()) {
281 case CSSValueNoCommonLigatures: 281 case CSSValueNoCommonLigatures:
282 ligatures.common = FontDescription::DisabledLigaturesState; 282 ligatures.common = FontDescription::DisabledLigaturesState;
283 break; 283 break;
284 case CSSValueCommonLigatures: 284 case CSSValueCommonLigatures:
285 ligatures.common = FontDescription::EnabledLigaturesState; 285 ligatures.common = FontDescription::EnabledLigaturesState;
286 break; 286 break;
287 case CSSValueNoDiscretionaryLigatures: 287 case CSSValueNoDiscretionaryLigatures:
288 ligatures.discretionary = FontDescription::DisabledLigaturesStat e; 288 ligatures.discretionary = FontDescription::DisabledLigaturesStat e;
289 break; 289 break;
290 case CSSValueDiscretionaryLigatures: 290 case CSSValueDiscretionaryLigatures:
(...skipping 12 matching lines...) Expand all
303 ligatures.contextual = FontDescription::EnabledLigaturesState; 303 ligatures.contextual = FontDescription::EnabledLigaturesState;
304 break; 304 break;
305 default: 305 default:
306 ASSERT_NOT_REACHED(); 306 ASSERT_NOT_REACHED();
307 break; 307 break;
308 } 308 }
309 } 309 }
310 return ligatures; 310 return ligatures;
311 } 311 }
312 312
313 ASSERT_WITH_SECURITY_IMPLICATION(value->isPrimitiveValue()); 313 ASSERT_WITH_SECURITY_IMPLICATION(value.isPrimitiveValue());
314 ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueNormal); 314 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNormal);
315 return FontDescription::VariantLigatures(); 315 return FontDescription::VariantLigatures();
316 } 316 }
317 317
318 EGlyphOrientation StyleBuilderConverter::convertGlyphOrientation(StyleResolverSt ate&, CSSValue* value) 318 EGlyphOrientation StyleBuilderConverter::convertGlyphOrientation(StyleResolverSt ate&, CSSValue value)
319 { 319 {
320 if (!value->isPrimitiveValue()) 320 if (!value.isPrimitiveValue())
321 return GO_0DEG; 321 return GO_0DEG;
322 322
323 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 323 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
324 if (primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_DEG) 324 if (primitiveValue.primitiveType() != CSSPrimitiveValue::CSS_DEG)
325 return GO_0DEG; 325 return GO_0DEG;
326 326
327 float angle = fabsf(fmodf(primitiveValue->getFloatValue(), 360.0f)); 327 float angle = fabsf(fmodf(primitiveValue.getFloatValue(), 360.0f));
328 328
329 if (angle <= 45.0f || angle > 315.0f) 329 if (angle <= 45.0f || angle > 315.0f)
330 return GO_0DEG; 330 return GO_0DEG;
331 if (angle > 45.0f && angle <= 135.0f) 331 if (angle > 45.0f && angle <= 135.0f)
332 return GO_90DEG; 332 return GO_90DEG;
333 if (angle > 135.0f && angle <= 225.0f) 333 if (angle > 135.0f && angle <= 225.0f)
334 return GO_180DEG; 334 return GO_180DEG;
335 return GO_270DEG; 335 return GO_270DEG;
336 } 336 }
337 337
338 StyleSelfAlignmentData StyleBuilderConverter::convertSelfOrDefaultAlignmentData( StyleResolverState&, CSSValue* value) 338 StyleSelfAlignmentData StyleBuilderConverter::convertSelfOrDefaultAlignmentData( StyleResolverState&, CSSValue value)
339 { 339 {
340 StyleSelfAlignmentData alignmentData = ComputedStyle::initialSelfAlignment() ; 340 StyleSelfAlignmentData alignmentData = ComputedStyle::initialSelfAlignment() ;
341 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 341 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
342 if (Pair* pairValue = primitiveValue->getPairValue()) { 342 if (Pair* pairValue = primitiveValue.getPairValue()) {
343 if (pairValue->first()->getValueID() == CSSValueLegacy) { 343 if (pairValue->first()->getValueID() == CSSValueLegacy) {
344 alignmentData.setPositionType(LegacyPosition); 344 alignmentData.setPositionType(LegacyPosition);
345 alignmentData.setPosition(*pairValue->second()); 345 alignmentData.setPosition(*pairValue->second());
346 } else { 346 } else {
347 alignmentData.setPosition(*pairValue->first()); 347 alignmentData.setPosition(*pairValue->first());
348 alignmentData.setOverflow(*pairValue->second()); 348 alignmentData.setOverflow(*pairValue->second());
349 } 349 }
350 } else { 350 } else {
351 alignmentData.setPosition(*primitiveValue); 351 alignmentData.setPosition(primitiveValue);
352 } 352 }
353 return alignmentData; 353 return alignmentData;
354 } 354 }
355 355
356 StyleContentAlignmentData StyleBuilderConverter::convertContentAlignmentData(Sty leResolverState&, CSSValue* value) 356 StyleContentAlignmentData StyleBuilderConverter::convertContentAlignmentData(Sty leResolverState&, CSSValue value)
357 { 357 {
358 StyleContentAlignmentData alignmentData = ComputedStyle::initialContentAlign ment(); 358 StyleContentAlignmentData alignmentData = ComputedStyle::initialContentAlign ment();
359 CSSContentDistributionValue* contentValue = toCSSContentDistributionValue(va lue); 359 CSSContentDistributionValue& contentValue = toCSSContentDistributionValue(va lue);
360 if (contentValue->distribution()->getValueID() != CSSValueInvalid) 360 if (contentValue.distribution()->getValueID() != CSSValueInvalid)
361 alignmentData.setDistribution(*contentValue->distribution()); 361 alignmentData.setDistribution(*contentValue.distribution());
362 if (contentValue->position()->getValueID() != CSSValueInvalid) 362 if (contentValue.position()->getValueID() != CSSValueInvalid)
363 alignmentData.setPosition(*contentValue->position()); 363 alignmentData.setPosition(*contentValue.position());
364 if (contentValue->overflow()->getValueID() != CSSValueInvalid) 364 if (contentValue.overflow()->getValueID() != CSSValueInvalid)
365 alignmentData.setOverflow(*contentValue->overflow()); 365 alignmentData.setOverflow(*contentValue.overflow());
366 return alignmentData; 366 return alignmentData;
367 } 367 }
368 368
369 GridAutoFlow StyleBuilderConverter::convertGridAutoFlow(StyleResolverState&, CSS Value* value) 369 GridAutoFlow StyleBuilderConverter::convertGridAutoFlow(StyleResolverState&, CSS Value value)
370 { 370 {
371 CSSValueList* list = toCSSValueList(value); 371 CSSValueList& list = toCSSValueList(value);
372 372
373 ASSERT(list->length() >= 1); 373 ASSERT(list.length() >= 1);
374 CSSPrimitiveValue* first = toCSSPrimitiveValue(list->item(0)); 374 CSSPrimitiveValue* first = &toCSSPrimitiveValue(list.item(0));
375 CSSPrimitiveValue* second = list->length() == 2 ? toCSSPrimitiveValue(list-> item(1)) : nullptr; 375 CSSPrimitiveValue* second = list.length() == 2 ? &toCSSPrimitiveValue(list.i tem(1)) : nullptr;
376 376
377 switch (first->getValueID()) { 377 switch (first->getValueID()) {
378 case CSSValueRow: 378 case CSSValueRow:
379 if (second && second->getValueID() == CSSValueDense) 379 if (second && second->getValueID() == CSSValueDense)
380 return AutoFlowRowDense; 380 return AutoFlowRowDense;
381 return AutoFlowRow; 381 return AutoFlowRow;
382 case CSSValueColumn: 382 case CSSValueColumn:
383 if (second && second->getValueID() == CSSValueDense) 383 if (second && second->getValueID() == CSSValueDense)
384 return AutoFlowColumnDense; 384 return AutoFlowColumnDense;
385 return AutoFlowColumn; 385 return AutoFlowColumn;
386 case CSSValueDense: 386 case CSSValueDense:
387 if (second && second->getValueID() == CSSValueColumn) 387 if (second && second->getValueID() == CSSValueColumn)
388 return AutoFlowColumnDense; 388 return AutoFlowColumnDense;
389 return AutoFlowRowDense; 389 return AutoFlowRowDense;
390 default: 390 default:
391 ASSERT_NOT_REACHED(); 391 ASSERT_NOT_REACHED();
392 return ComputedStyle::initialGridAutoFlow(); 392 return ComputedStyle::initialGridAutoFlow();
393 } 393 }
394 } 394 }
395 395
396 GridPosition StyleBuilderConverter::convertGridPosition(StyleResolverState&, CSS Value* value) 396 GridPosition StyleBuilderConverter::convertGridPosition(StyleResolverState&, CSS Value value)
397 { 397 {
398 // We accept the specification's grammar: 398 // We accept the specification's grammar:
399 // 'auto' | [ <integer> || <custom-ident> ] | [ span && [ <integer> || <cust om-ident> ] ] | <custom-ident> 399 // 'auto' | [ <integer> || <custom-ident> ] | [ span && [ <integer> || <cust om-ident> ] ] | <custom-ident>
400 400
401 GridPosition position; 401 GridPosition position;
402 402
403 if (value->isPrimitiveValue()) { 403 if (value.isPrimitiveValue()) {
404 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 404 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
405 // We translate <custom-ident> to <string> during parsing as it 405 // We translate <custom-ident> to <string> during parsing as it
406 // makes handling it more simple. 406 // makes handling it more simple.
407 if (primitiveValue->isCustomIdent()) { 407 if (primitiveValue.isCustomIdent()) {
408 position.setNamedGridArea(primitiveValue->getStringValue()); 408 position.setNamedGridArea(primitiveValue.getStringValue());
409 return position; 409 return position;
410 } 410 }
411 411
412 ASSERT(primitiveValue->getValueID() == CSSValueAuto); 412 ASSERT(primitiveValue.getValueID() == CSSValueAuto);
413 return position; 413 return position;
414 } 414 }
415 415
416 CSSValueList* values = toCSSValueList(value); 416 CSSValueList& values = toCSSValueList(value);
417 ASSERT(values->length()); 417 ASSERT(values.length());
418 418
419 bool isSpanPosition = false; 419 bool isSpanPosition = false;
420 // The specification makes the <integer> optional, in which case it default to '1'. 420 // The specification makes the <integer> optional, in which case it default to '1'.
421 int gridLineNumber = 1; 421 int gridLineNumber = 1;
422 String gridLineName; 422 String gridLineName;
423 423
424 auto it = values->begin(); 424 auto it = values.begin();
425 CSSPrimitiveValue* currentValue = toCSSPrimitiveValue(it->get()); 425 CSSPrimitiveValue* currentValue = &toCSSPrimitiveValue(*it);
426 if (currentValue->getValueID() == CSSValueSpan) { 426 if (currentValue->getValueID() == CSSValueSpan) {
427 isSpanPosition = true; 427 isSpanPosition = true;
428 ++it; 428 ++it;
429 currentValue = it != values->end() ? toCSSPrimitiveValue(it->get()) : 0; 429 currentValue = it != values.end() ? &toCSSPrimitiveValue(*it) : 0;
430 } 430 }
431 431
432 if (currentValue && currentValue->isNumber()) { 432 if (currentValue && currentValue->isNumber()) {
433 gridLineNumber = currentValue->getIntValue(); 433 gridLineNumber = currentValue->getIntValue();
434 ++it; 434 ++it;
435 currentValue = it != values->end() ? toCSSPrimitiveValue(it->get()) : 0; 435 currentValue = it != values.end() ? &toCSSPrimitiveValue(*it) : 0;
436 } 436 }
437 437
438 if (currentValue && currentValue->isCustomIdent()) { 438 if (currentValue && currentValue->isCustomIdent()) {
439 gridLineName = currentValue->getStringValue(); 439 gridLineName = currentValue->getStringValue();
440 ++it; 440 ++it;
441 } 441 }
442 442
443 ASSERT(it == values->end()); 443 ASSERT(it == values.end());
444 if (isSpanPosition) 444 if (isSpanPosition)
445 position.setSpanPosition(gridLineNumber, gridLineName); 445 position.setSpanPosition(gridLineNumber, gridLineName);
446 else 446 else
447 position.setExplicitPosition(gridLineNumber, gridLineName); 447 position.setExplicitPosition(gridLineNumber, gridLineName);
448 448
449 return position; 449 return position;
450 } 450 }
451 451
452 GridTrackSize StyleBuilderConverter::convertGridTrackSize(StyleResolverState& st ate, CSSValue* value) 452 GridTrackSize StyleBuilderConverter::convertGridTrackSize(StyleResolverState& st ate, CSSValue value)
453 { 453 {
454 if (value->isPrimitiveValue()) 454 if (value.isPrimitiveValue())
455 return GridTrackSize(convertGridTrackBreadth(state, toCSSPrimitiveValue( value))); 455 return GridTrackSize(convertGridTrackBreadth(state, &toCSSPrimitiveValue (value)));
456 456
457 CSSFunctionValue* minmaxFunction = toCSSFunctionValue(value); 457 CSSFunctionValue& minmaxFunction = toCSSFunctionValue(value);
458 ASSERT_WITH_SECURITY_IMPLICATION(minmaxFunction->length() == 2); 458 ASSERT_WITH_SECURITY_IMPLICATION(minmaxFunction.length() == 2);
459 GridLength minTrackBreadth(convertGridTrackBreadth(state, toCSSPrimitiveValu e(minmaxFunction->item(0)))); 459 GridLength minTrackBreadth(convertGridTrackBreadth(state, &toCSSPrimitiveVal ue(minmaxFunction.item(0))));
460 GridLength maxTrackBreadth(convertGridTrackBreadth(state, toCSSPrimitiveValu e(minmaxFunction->item(1)))); 460 GridLength maxTrackBreadth(convertGridTrackBreadth(state, &toCSSPrimitiveVal ue(minmaxFunction.item(1))));
461 return GridTrackSize(minTrackBreadth, maxTrackBreadth); 461 return GridTrackSize(minTrackBreadth, maxTrackBreadth);
462 } 462 }
463 463
464 bool StyleBuilderConverter::convertGridTrackList(CSSValue* value, Vector<GridTra ckSize>& trackSizes, NamedGridLinesMap& namedGridLines, OrderedNamedGridLines& o rderedNamedGridLines, StyleResolverState& state) 464 bool StyleBuilderConverter::convertGridTrackList(CSSValue value, Vector<GridTrac kSize>& trackSizes, NamedGridLinesMap& namedGridLines, OrderedNamedGridLines& or deredNamedGridLines, StyleResolverState& state)
465 { 465 {
466 // Handle 'none'. 466 // Handle 'none'.
467 if (value->isPrimitiveValue()) { 467 if (value.isPrimitiveValue()) {
468 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 468 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
469 return primitiveValue->getValueID() == CSSValueNone; 469 return primitiveValue.getValueID() == CSSValueNone;
470 } 470 }
471 471
472 if (!value->isValueList()) 472 if (!value.isValueList())
473 return false; 473 return false;
474 474
475 size_t currentNamedGridLine = 0; 475 size_t currentNamedGridLine = 0;
476 for (auto& currValue : *toCSSValueList(value)) { 476 for (auto& currValue : toCSSValueList(value)) {
477 if (currValue->isGridLineNamesValue()) { 477 if (currValue.isGridLineNamesValue()) {
478 for (auto& namedGridLineValue : toCSSGridLineNamesValue(*currValue)) { 478 for (auto& namedGridLineValue : toCSSGridLineNamesValue(currValue)) {
479 String namedGridLine = toCSSPrimitiveValue(namedGridLineValue.ge t())->getStringValue(); 479 String namedGridLine = toCSSPrimitiveValue(namedGridLineValue).g etStringValue();
480 NamedGridLinesMap::AddResult result = namedGridLines.add(namedGr idLine, Vector<size_t>()); 480 NamedGridLinesMap::AddResult result = namedGridLines.add(namedGr idLine, Vector<size_t>());
481 result.storedValue->value.append(currentNamedGridLine); 481 result.storedValue->value.append(currentNamedGridLine);
482 OrderedNamedGridLines::AddResult orderedInsertionResult = ordere dNamedGridLines.add(currentNamedGridLine, Vector<String>()); 482 OrderedNamedGridLines::AddResult orderedInsertionResult = ordere dNamedGridLines.add(currentNamedGridLine, Vector<String>());
483 orderedInsertionResult.storedValue->value.append(namedGridLine); 483 orderedInsertionResult.storedValue->value.append(namedGridLine);
484 } 484 }
485 continue; 485 continue;
486 } 486 }
487 487
488 ++currentNamedGridLine; 488 ++currentNamedGridLine;
489 trackSizes.append(convertGridTrackSize(state, currValue.get())); 489 trackSizes.append(convertGridTrackSize(state, currValue));
490 } 490 }
491 491
492 // The parser should have rejected any <track-list> without any <track-size> as 492 // The parser should have rejected any <track-list> without any <track-size> as
493 // this is not conformant to the syntax. 493 // this is not conformant to the syntax.
494 ASSERT(!trackSizes.isEmpty()); 494 ASSERT(!trackSizes.isEmpty());
495 return true; 495 return true;
496 } 496 }
497 497
498 void StyleBuilderConverter::convertOrderedNamedGridLinesMapToNamedGridLinesMap(c onst OrderedNamedGridLines& orderedNamedGridLines, NamedGridLinesMap& namedGridL ines) 498 void StyleBuilderConverter::convertOrderedNamedGridLinesMapToNamedGridLinesMap(c onst OrderedNamedGridLines& orderedNamedGridLines, NamedGridLinesMap& namedGridL ines)
499 { 499 {
(...skipping 25 matching lines...) Expand all
525 std::sort(startResult.storedValue->value.begin(), startResult.stored Value->value.end()); 525 std::sort(startResult.storedValue->value.begin(), startResult.stored Value->value.end());
526 } 526 }
527 { 527 {
528 NamedGridLinesMap::AddResult endResult = namedGridLines.add(namedGri dAreaEntry.key + "-end", Vector<size_t>()); 528 NamedGridLinesMap::AddResult endResult = namedGridLines.add(namedGri dAreaEntry.key + "-end", Vector<size_t>());
529 endResult.storedValue->value.append(areaSpan.resolvedFinalPosition.t oInt() + 1); 529 endResult.storedValue->value.append(areaSpan.resolvedFinalPosition.t oInt() + 1);
530 std::sort(endResult.storedValue->value.begin(), endResult.storedValu e->value.end()); 530 std::sort(endResult.storedValue->value.begin(), endResult.storedValu e->value.end());
531 } 531 }
532 } 532 }
533 } 533 }
534 534
535 Length StyleBuilderConverter::convertLength(const StyleResolverState& state, CSS Value* value) 535 Length StyleBuilderConverter::convertLength(const StyleResolverState& state, CSS Value value)
536 { 536 {
537 return toCSSPrimitiveValue(value)->convertToLength(state.cssToLengthConversi onData()); 537 return toCSSPrimitiveValue(value).convertToLength(state.cssToLengthConversio nData());
538 } 538 }
539 539
540 UnzoomedLength StyleBuilderConverter::convertUnzoomedLength(const StyleResolverS tate& state, CSSValue* value) 540 UnzoomedLength StyleBuilderConverter::convertUnzoomedLength(const StyleResolverS tate& state, CSSValue value)
541 { 541 {
542 return UnzoomedLength(toCSSPrimitiveValue(value)->convertToLength(state.cssT oLengthConversionData().copyWithAdjustedZoom(1.0f))); 542 return UnzoomedLength(toCSSPrimitiveValue(value).convertToLength(state.cssTo LengthConversionData().copyWithAdjustedZoom(1.0f)));
543 } 543 }
544 544
545 Length StyleBuilderConverter::convertLengthOrAuto(const StyleResolverState& stat e, CSSValue* value) 545 Length StyleBuilderConverter::convertLengthOrAuto(const StyleResolverState& stat e, CSSValue value)
546 { 546 {
547 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 547 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
548 if (primitiveValue->getValueID() == CSSValueAuto) 548 if (primitiveValue.getValueID() == CSSValueAuto)
549 return Length(Auto); 549 return Length(Auto);
550 return primitiveValue->convertToLength(state.cssToLengthConversionData()); 550 return primitiveValue.convertToLength(state.cssToLengthConversionData());
551 } 551 }
552 552
553 Length StyleBuilderConverter::convertLengthSizing(StyleResolverState& state, CSS Value* value) 553 Length StyleBuilderConverter::convertLengthSizing(StyleResolverState& state, CSS Value value)
554 { 554 {
555 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 555 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
556 switch (primitiveValue->getValueID()) { 556 switch (primitiveValue.getValueID()) {
557 case CSSValueInvalid: 557 case CSSValueInvalid:
558 return convertLength(state, value); 558 return convertLength(state, value);
559 case CSSValueIntrinsic: 559 case CSSValueIntrinsic:
560 return Length(Intrinsic); 560 return Length(Intrinsic);
561 case CSSValueMinIntrinsic: 561 case CSSValueMinIntrinsic:
562 return Length(MinIntrinsic); 562 return Length(MinIntrinsic);
563 case CSSValueMinContent: 563 case CSSValueMinContent:
564 case CSSValueWebkitMinContent: 564 case CSSValueWebkitMinContent:
565 return Length(MinContent); 565 return Length(MinContent);
566 case CSSValueMaxContent: 566 case CSSValueMaxContent:
567 case CSSValueWebkitMaxContent: 567 case CSSValueWebkitMaxContent:
568 return Length(MaxContent); 568 return Length(MaxContent);
569 case CSSValueWebkitFillAvailable: 569 case CSSValueWebkitFillAvailable:
570 return Length(FillAvailable); 570 return Length(FillAvailable);
571 case CSSValueWebkitFitContent: 571 case CSSValueWebkitFitContent:
572 return Length(FitContent); 572 return Length(FitContent);
573 case CSSValueAuto: 573 case CSSValueAuto:
574 return Length(Auto); 574 return Length(Auto);
575 default: 575 default:
576 ASSERT_NOT_REACHED(); 576 ASSERT_NOT_REACHED();
577 return Length(); 577 return Length();
578 } 578 }
579 } 579 }
580 580
581 Length StyleBuilderConverter::convertLengthMaxSizing(StyleResolverState& state, CSSValue* value) 581 Length StyleBuilderConverter::convertLengthMaxSizing(StyleResolverState& state, CSSValue value)
582 { 582 {
583 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 583 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
584 if (primitiveValue->getValueID() == CSSValueNone) 584 if (primitiveValue.getValueID() == CSSValueNone)
585 return Length(MaxSizeNone); 585 return Length(MaxSizeNone);
586 return convertLengthSizing(state, value); 586 return convertLengthSizing(state, value);
587 } 587 }
588 588
589 TabSize StyleBuilderConverter::convertLengthOrTabSpaces(StyleResolverState& stat e, CSSValue* value) 589 TabSize StyleBuilderConverter::convertLengthOrTabSpaces(StyleResolverState& stat e, CSSValue value)
590 { 590 {
591 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 591 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
592 if (primitiveValue->isNumber()) 592 if (primitiveValue.isNumber())
593 return TabSize(primitiveValue->getIntValue()); 593 return TabSize(primitiveValue.getIntValue());
594 return TabSize(primitiveValue->computeLength<float>(state.cssToLengthConvers ionData())); 594 return TabSize(primitiveValue.computeLength<float>(state.cssToLengthConversi onData()));
595 } 595 }
596 596
597 LineBoxContain StyleBuilderConverter::convertLineBoxContain(StyleResolverState&, CSSValue* value) 597 LineBoxContain StyleBuilderConverter::convertLineBoxContain(StyleResolverState&, CSSValue value)
598 { 598 {
599 if (value->isPrimitiveValue()) { 599 if (value.isPrimitiveValue()) {
600 ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueNone); 600 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNone);
601 return LineBoxContainNone; 601 return LineBoxContainNone;
602 } 602 }
603 603
604 return toCSSLineBoxContainValue(value)->value(); 604 return toCSSLineBoxContainValue(value).value();
605 } 605 }
606 606
607 static CSSToLengthConversionData lineHeightToLengthConversionData(StyleResolverS tate& state) 607 static CSSToLengthConversionData lineHeightToLengthConversionData(StyleResolverS tate& state)
608 { 608 {
609 float multiplier = state.style()->effectiveZoom(); 609 float multiplier = state.style()->effectiveZoom();
610 if (LocalFrame* frame = state.document().frame()) 610 if (LocalFrame* frame = state.document().frame())
611 multiplier *= frame->textZoomFactor(); 611 multiplier *= frame->textZoomFactor();
612 return state.cssToLengthConversionData().copyWithAdjustedZoom(multiplier); 612 return state.cssToLengthConversionData().copyWithAdjustedZoom(multiplier);
613 } 613 }
614 614
615 Length StyleBuilderConverter::convertLineHeight(StyleResolverState& state, CSSVa lue* value) 615 Length StyleBuilderConverter::convertLineHeight(StyleResolverState& state, CSSVa lue value)
616 { 616 {
617 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 617 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
618 618
619 if (primitiveValue->isLength()) 619 if (primitiveValue.isLength())
620 return primitiveValue->computeLength<Length>(lineHeightToLengthConversio nData(state)); 620 return primitiveValue.computeLength<Length>(lineHeightToLengthConversion Data(state));
621 if (primitiveValue->isPercentage()) 621 if (primitiveValue.isPercentage())
622 return Length((state.style()->computedFontSize() * primitiveValue->getIn tValue()) / 100.0, Fixed); 622 return Length((state.style()->computedFontSize() * primitiveValue.getInt Value()) / 100.0, Fixed);
623 if (primitiveValue->isNumber()) 623 if (primitiveValue.isNumber())
624 return Length(primitiveValue->getDoubleValue() * 100.0, Percent); 624 return Length(primitiveValue.getDoubleValue() * 100.0, Percent);
625 if (primitiveValue->isCalculated()) { 625 if (primitiveValue.isCalculated()) {
626 Length zoomedLength = Length(primitiveValue->cssCalcValue()->toCalcValue (lineHeightToLengthConversionData(state))); 626 Length zoomedLength = Length(primitiveValue.cssCalcValue()->toCalcValue( lineHeightToLengthConversionData(state)));
627 return Length(valueForLength(zoomedLength, state.style()->fontSize()), F ixed); 627 return Length(valueForLength(zoomedLength, state.style()->fontSize()), F ixed);
628 } 628 }
629 629
630 ASSERT(primitiveValue->getValueID() == CSSValueNormal); 630 ASSERT(primitiveValue.getValueID() == CSSValueNormal);
631 return ComputedStyle::initialLineHeight(); 631 return ComputedStyle::initialLineHeight();
632 } 632 }
633 633
634 float StyleBuilderConverter::convertNumberOrPercentage(StyleResolverState& state , CSSValue* value) 634 float StyleBuilderConverter::convertNumberOrPercentage(StyleResolverState& state , CSSValue value)
635 { 635 {
636 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 636 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
637 ASSERT(primitiveValue->isNumber() || primitiveValue->isPercentage()); 637 ASSERT(primitiveValue.isNumber() || primitiveValue.isPercentage());
638 if (primitiveValue->isNumber()) 638 if (primitiveValue.isNumber())
639 return primitiveValue->getFloatValue(); 639 return primitiveValue.getFloatValue();
640 return primitiveValue->getFloatValue() / 100.0f; 640 return primitiveValue.getFloatValue() / 100.0f;
641 } 641 }
642 642
643 template <CSSValueID cssValueFor0, CSSValueID cssValueFor100> 643 template <CSSValueID cssValueFor0, CSSValueID cssValueFor100>
644 static Length convertPositionLength(StyleResolverState& state, CSSPrimitiveValue * primitiveValue) 644 static Length convertPositionLength(StyleResolverState& state, CSSPrimitiveValue * primitiveValue)
645 { 645 {
646 if (Pair* pair = primitiveValue->getPairValue()) { 646 if (Pair* pair = primitiveValue->getPairValue()) {
647 Length length = StyleBuilderConverter::convertLength(state, pair->second ()); 647 Length length = StyleBuilderConverter::convertLength(state, CSSValue(*pa ir->second()));
648 if (pair->first()->getValueID() == cssValueFor0) 648 if (pair->first()->getValueID() == cssValueFor0)
649 return length; 649 return length;
650 ASSERT(pair->first()->getValueID() == cssValueFor100); 650 ASSERT(pair->first()->getValueID() == cssValueFor100);
651 return length.subtractFromOneHundredPercent(); 651 return length.subtractFromOneHundredPercent();
652 } 652 }
653 653
654 return StyleBuilderConverter::convertLength(state, primitiveValue); 654 return StyleBuilderConverter::convertLength(state, CSSValue(*primitiveValue) );
655 } 655 }
656 656
657 LengthPoint StyleBuilderConverter::convertPosition(StyleResolverState& state, CS SValue* value) 657 LengthPoint StyleBuilderConverter::convertPosition(StyleResolverState& state, CS SValue value)
658 { 658 {
659 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 659 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
660 Pair* pair = primitiveValue->getPairValue(); 660 Pair* pair = primitiveValue.getPairValue();
661 return LengthPoint( 661 return LengthPoint(
662 convertPositionLength<CSSValueLeft, CSSValueRight>(state, pair->first()) , 662 convertPositionLength<CSSValueLeft, CSSValueRight>(state, pair->first()) ,
663 convertPositionLength<CSSValueTop, CSSValueBottom>(state, pair->second() ) 663 convertPositionLength<CSSValueTop, CSSValueBottom>(state, pair->second() )
664 ); 664 );
665 } 665 }
666 666
667 static float convertPerspectiveLength(StyleResolverState& state, CSSPrimitiveVal ue* primitiveValue) 667 static float convertPerspectiveLength(StyleResolverState& state, CSSPrimitiveVal ue& primitiveValue)
668 { 668 {
669 return std::max(primitiveValue->computeLength<float>(state.cssToLengthConver sionData()), 0.0f); 669 return std::max(primitiveValue.computeLength<float>(state.cssToLengthConvers ionData()), 0.0f);
670 } 670 }
671 671
672 float StyleBuilderConverter::convertPerspective(StyleResolverState& state, CSSVa lue* value) 672 float StyleBuilderConverter::convertPerspective(StyleResolverState& state, CSSVa lue value)
673 { 673 {
674 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 674 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
675 675
676 if (primitiveValue->getValueID() == CSSValueNone) 676 if (primitiveValue.getValueID() == CSSValueNone)
677 return ComputedStyle::initialPerspective(); 677 return ComputedStyle::initialPerspective();
678 return convertPerspectiveLength(state, primitiveValue); 678 return convertPerspectiveLength(state, primitiveValue);
679 } 679 }
680 680
681 template <CSSValueID cssValueFor0, CSSValueID cssValueFor100> 681 template <CSSValueID cssValueFor0, CSSValueID cssValueFor100>
682 static Length convertOriginLength(StyleResolverState& state, CSSPrimitiveValue* primitiveValue) 682 static Length convertOriginLength(StyleResolverState& state, CSSPrimitiveValue& primitiveValue)
683 { 683 {
684 if (primitiveValue->isValueID()) { 684 if (primitiveValue.isValueID()) {
685 switch (primitiveValue->getValueID()) { 685 switch (primitiveValue.getValueID()) {
686 case cssValueFor0: 686 case cssValueFor0:
687 return Length(0, Percent); 687 return Length(0, Percent);
688 case cssValueFor100: 688 case cssValueFor100:
689 return Length(100, Percent); 689 return Length(100, Percent);
690 case CSSValueCenter: 690 case CSSValueCenter:
691 return Length(50, Percent); 691 return Length(50, Percent);
692 default: 692 default:
693 ASSERT_NOT_REACHED(); 693 ASSERT_NOT_REACHED();
694 } 694 }
695 } 695 }
696 696
697 return StyleBuilderConverter::convertLength(state, primitiveValue); 697 return StyleBuilderConverter::convertLength(state, CSSValue(primitiveValue)) ;
698 } 698 }
699 699
700 LengthPoint StyleBuilderConverter::convertPerspectiveOrigin(StyleResolverState& state, CSSValue* value) 700 LengthPoint StyleBuilderConverter::convertPerspectiveOrigin(StyleResolverState& state, CSSValue value)
701 { 701 {
702 CSSValueList* list = toCSSValueList(value); 702 CSSValueList& list = toCSSValueList(value);
703 ASSERT(list->length() == 2); 703 ASSERT(list.length() == 2);
704 704
705 CSSPrimitiveValue* primitiveValueX = toCSSPrimitiveValue(list->item(0)); 705 CSSPrimitiveValue& primitiveValueX = toCSSPrimitiveValue(list.item(0));
706 CSSPrimitiveValue* primitiveValueY = toCSSPrimitiveValue(list->item(1)); 706 CSSPrimitiveValue& primitiveValueY = toCSSPrimitiveValue(list.item(1));
707 707
708 return LengthPoint( 708 return LengthPoint(
709 convertOriginLength<CSSValueLeft, CSSValueRight>(state, primitiveValueX) , 709 convertOriginLength<CSSValueLeft, CSSValueRight>(state, primitiveValueX) ,
710 convertOriginLength<CSSValueTop, CSSValueBottom>(state, primitiveValueY) 710 convertOriginLength<CSSValueTop, CSSValueBottom>(state, primitiveValueY)
711 ); 711 );
712 } 712 }
713 713
714 EPaintOrder StyleBuilderConverter::convertPaintOrder(StyleResolverState&, CSSVal ue* cssPaintOrder) 714 EPaintOrder StyleBuilderConverter::convertPaintOrder(StyleResolverState&, CSSVal ue cssPaintOrder)
715 { 715 {
716 if (cssPaintOrder->isValueList()) { 716 if (cssPaintOrder.isValueList()) {
717 int paintOrder = 0; 717 int paintOrder = 0;
718 const CSSValueList& list = *toCSSValueList(cssPaintOrder); 718 const CSSValueList& list = toCSSValueList(cssPaintOrder);
719 for (size_t i = 0; i < list.length(); ++i) { 719 for (size_t i = 0; i < list.length(); ++i) {
720 EPaintOrderType paintOrderType = PT_NONE; 720 EPaintOrderType paintOrderType = PT_NONE;
721 switch (toCSSPrimitiveValue(list.item(i))->getValueID()) { 721 switch (toCSSPrimitiveValue(list.item(i)).getValueID()) {
722 case CSSValueFill: 722 case CSSValueFill:
723 paintOrderType = PT_FILL; 723 paintOrderType = PT_FILL;
724 break; 724 break;
725 case CSSValueStroke: 725 case CSSValueStroke:
726 paintOrderType = PT_STROKE; 726 paintOrderType = PT_STROKE;
727 break; 727 break;
728 case CSSValueMarkers: 728 case CSSValueMarkers:
729 paintOrderType = PT_MARKERS; 729 paintOrderType = PT_MARKERS;
730 break; 730 break;
731 default: 731 default:
732 ASSERT_NOT_REACHED(); 732 ASSERT_NOT_REACHED();
733 break; 733 break;
734 } 734 }
735 735
736 paintOrder |= (paintOrderType << kPaintOrderBitwidth*i); 736 paintOrder |= (paintOrderType << kPaintOrderBitwidth*i);
737 } 737 }
738 return (EPaintOrder)paintOrder; 738 return (EPaintOrder)paintOrder;
739 } 739 }
740 740
741 return PO_NORMAL; 741 return PO_NORMAL;
742 } 742 }
743 743
744 Length StyleBuilderConverter::convertQuirkyLength(StyleResolverState& state, CSS Value* value) 744 Length StyleBuilderConverter::convertQuirkyLength(StyleResolverState& state, CSS Value value)
745 { 745 {
746 Length length = convertLengthOrAuto(state, value); 746 Length length = convertLengthOrAuto(state, value);
747 // This is only for margins which use __qem 747 // This is only for margins which use __qem
748 length.setQuirk(toCSSPrimitiveValue(value)->isQuirkValue()); 748 length.setQuirk(toCSSPrimitiveValue(value).isQuirkValue());
749 return length; 749 return length;
750 } 750 }
751 751
752 PassRefPtr<QuotesData> StyleBuilderConverter::convertQuotes(StyleResolverState&, CSSValue* value) 752 PassRefPtr<QuotesData> StyleBuilderConverter::convertQuotes(StyleResolverState&, CSSValue value)
753 { 753 {
754 if (value->isValueList()) { 754 if (value.isValueList()) {
755 CSSValueList* list = toCSSValueList(value); 755 CSSValueList& list = toCSSValueList(value);
756 RefPtr<QuotesData> quotes = QuotesData::create(); 756 RefPtr<QuotesData> quotes = QuotesData::create();
757 for (size_t i = 0; i < list->length(); i += 2) { 757 for (size_t i = 0; i < list.length(); i += 2) {
758 CSSValue* first = list->item(i); 758 CSSValue first = list.item(i);
759 CSSValue* second = list->item(i + 1); 759 CSSValue second = list.item(i + 1);
760 String startQuote = toCSSPrimitiveValue(first)->getStringValue(); 760 String startQuote = toCSSPrimitiveValue(first).getStringValue();
761 String endQuote = toCSSPrimitiveValue(second)->getStringValue(); 761 String endQuote = toCSSPrimitiveValue(second).getStringValue();
762 quotes->addPair(std::make_pair(startQuote, endQuote)); 762 quotes->addPair(std::make_pair(startQuote, endQuote));
763 } 763 }
764 return quotes.release(); 764 return quotes.release();
765 } 765 }
766 // FIXME: We should assert we're a primitive value with valueID = CSSValueNo ne 766 // FIXME: We should assert we're a primitive value with valueID = CSSValueNo ne
767 return QuotesData::create(); 767 return QuotesData::create();
768 } 768 }
769 769
770 LengthSize StyleBuilderConverter::convertRadius(StyleResolverState& state, CSSVa lue* value) 770 LengthSize StyleBuilderConverter::convertRadius(StyleResolverState& state, CSSVa lue value)
771 { 771 {
772 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 772 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
773 Pair* pair = primitiveValue->getPairValue(); 773 Pair* pair = primitiveValue.getPairValue();
774 Length radiusWidth = pair->first()->convertToLength(state.cssToLengthConvers ionData()); 774 Length radiusWidth = pair->first()->convertToLength(state.cssToLengthConvers ionData());
775 Length radiusHeight = pair->second()->convertToLength(state.cssToLengthConve rsionData()); 775 Length radiusHeight = pair->second()->convertToLength(state.cssToLengthConve rsionData());
776 float width = radiusWidth.value(); 776 float width = radiusWidth.value();
777 float height = radiusHeight.value(); 777 float height = radiusHeight.value();
778 ASSERT(width >= 0 && height >= 0); 778 ASSERT(width >= 0 && height >= 0);
779 if (width <= 0 || height <= 0) 779 if (width <= 0 || height <= 0)
780 return LengthSize(Length(0, Fixed), Length(0, Fixed)); 780 return LengthSize(Length(0, Fixed), Length(0, Fixed));
781 return LengthSize(radiusWidth, radiusHeight); 781 return LengthSize(radiusWidth, radiusHeight);
782 } 782 }
783 783
784 PassRefPtr<ShadowList> StyleBuilderConverter::convertShadow(StyleResolverState& state, CSSValue* value) 784 PassRefPtr<ShadowList> StyleBuilderConverter::convertShadow(StyleResolverState& state, CSSValue value)
785 { 785 {
786 if (value->isPrimitiveValue()) { 786 if (value.isPrimitiveValue()) {
787 ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueNone); 787 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNone);
788 return PassRefPtr<ShadowList>(); 788 return PassRefPtr<ShadowList>();
789 } 789 }
790 790
791 const CSSValueList* valueList = toCSSValueList(value); 791 const CSSValueList& valueList = toCSSValueList(value);
792 size_t shadowCount = valueList->length(); 792 size_t shadowCount = valueList.length();
793 ShadowDataVector shadows; 793 ShadowDataVector shadows;
794 for (size_t i = 0; i < shadowCount; ++i) { 794 for (size_t i = 0; i < shadowCount; ++i) {
795 const CSSShadowValue* item = toCSSShadowValue(valueList->item(i)); 795 const CSSShadowValue& item = toCSSShadowValue(valueList.item(i));
796 float x = item->x->computeLength<float>(state.cssToLengthConversionData( )); 796 float x = item.x->computeLength<float>(state.cssToLengthConversionData() );
797 float y = item->y->computeLength<float>(state.cssToLengthConversionData( )); 797 float y = item.y->computeLength<float>(state.cssToLengthConversionData() );
798 float blur = item->blur ? item->blur->computeLength<float>(state.cssToLe ngthConversionData()) : 0; 798 float blur = item.blur ? item.blur->computeLength<float>(state.cssToLeng thConversionData()) : 0;
799 float spread = item->spread ? item->spread->computeLength<float>(state.c ssToLengthConversionData()) : 0; 799 float spread = item.spread ? item.spread->computeLength<float>(state.css ToLengthConversionData()) : 0;
800 ShadowStyle shadowStyle = item->style && item->style->getValueID() == CS SValueInset ? Inset : Normal; 800 ShadowStyle shadowStyle = item.style && item.style->getValueID() == CSSV alueInset ? Inset : Normal;
801 StyleColor color = StyleColor::currentColor(); 801 StyleColor color = StyleColor::currentColor();
802 if (item->color) 802 if (item.color)
803 color = convertStyleColor(state, item->color.get()); 803 color = convertStyleColor(state, CSSValue(*item.color));
804 shadows.append(ShadowData(FloatPoint(x, y), blur, spread, shadowStyle, c olor)); 804 shadows.append(ShadowData(FloatPoint(x, y), blur, spread, shadowStyle, c olor));
805 } 805 }
806 return ShadowList::adopt(shadows); 806 return ShadowList::adopt(shadows);
807 } 807 }
808 808
809 PassRefPtr<ShapeValue> StyleBuilderConverter::convertShapeValue(StyleResolverSta te& state, CSSValue* value) 809 PassRefPtr<ShapeValue> StyleBuilderConverter::convertShapeValue(StyleResolverSta te& state, CSSValue value)
810 { 810 {
811 if (value->isPrimitiveValue()) { 811 if (value.isPrimitiveValue()) {
812 ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueNone); 812 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNone);
813 return nullptr; 813 return nullptr;
814 } 814 }
815 815
816 if (value->isImageValue() || value->isImageGeneratorValue() || value->isImag eSetValue()) 816 if (value.isImageValue() || value.isImageGeneratorValue() || value.isImageSe tValue())
817 return ShapeValue::createImageValue(state.styleImage(CSSPropertyShapeOut side, value)); 817 return ShapeValue::createImageValue(state.styleImage(CSSPropertyShapeOut side, value));
818 818
819 RefPtr<BasicShape> shape; 819 RefPtr<BasicShape> shape;
820 CSSBoxType cssBox = BoxMissing; 820 CSSBoxType cssBox = BoxMissing;
821 CSSValueList* valueList = toCSSValueList(value); 821 CSSValueList& valueList = toCSSValueList(value);
822 for (unsigned i = 0; i < valueList->length(); ++i) { 822 for (unsigned i = 0; i < valueList.length(); ++i) {
823 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(valueList->item( i)); 823 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(valueList.item(i ));
824 if (primitiveValue->isShape()) 824 if (primitiveValue.isShape())
825 shape = basicShapeForValue(state, primitiveValue->getShapeValue()); 825 shape = basicShapeForValue(state, primitiveValue.getShapeValue());
826 else 826 else
827 cssBox = CSSBoxType(*primitiveValue); 827 cssBox = CSSBoxType(primitiveValue);
828 } 828 }
829 829
830 if (shape) 830 if (shape)
831 return ShapeValue::createShapeValue(shape.release(), cssBox); 831 return ShapeValue::createShapeValue(shape.release(), cssBox);
832 832
833 ASSERT(cssBox != BoxMissing); 833 ASSERT(cssBox != BoxMissing);
834 return ShapeValue::createBoxShapeValue(cssBox); 834 return ShapeValue::createBoxShapeValue(cssBox);
835 } 835 }
836 836
837 float StyleBuilderConverter::convertSpacing(StyleResolverState& state, CSSValue* value) 837 float StyleBuilderConverter::convertSpacing(StyleResolverState& state, CSSValue value)
838 { 838 {
839 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 839 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
840 if (primitiveValue->getValueID() == CSSValueNormal) 840 if (primitiveValue.getValueID() == CSSValueNormal)
841 return 0; 841 return 0;
842 return primitiveValue->computeLength<float>(state.cssToLengthConversionData( )); 842 return primitiveValue.computeLength<float>(state.cssToLengthConversionData() );
843 } 843 }
844 844
845 PassRefPtr<SVGDashArray> StyleBuilderConverter::convertStrokeDasharray(StyleReso lverState& state, CSSValue* value) 845 PassRefPtr<SVGDashArray> StyleBuilderConverter::convertStrokeDasharray(StyleReso lverState& state, CSSValue value)
846 { 846 {
847 if (!value->isValueList()) 847 if (!value.isValueList())
848 return SVGComputedStyle::initialStrokeDashArray(); 848 return SVGComputedStyle::initialStrokeDashArray();
849 849
850 CSSValueList* dashes = toCSSValueList(value); 850 CSSValueList& dashes = toCSSValueList(value);
851 851
852 RefPtr<SVGDashArray> array = SVGDashArray::create(); 852 RefPtr<SVGDashArray> array = SVGDashArray::create();
853 size_t length = dashes->length(); 853 size_t length = dashes.length();
854 for (size_t i = 0; i < length; ++i) { 854 for (size_t i = 0; i < length; ++i) {
855 CSSValue* currValue = dashes->item(i); 855 CSSValue currValue = dashes.item(i);
856 if (!currValue->isPrimitiveValue()) 856 if (!currValue.isPrimitiveValue())
857 continue; 857 continue;
858 858
859 CSSPrimitiveValue* dash = toCSSPrimitiveValue(dashes->item(i)); 859 array->append(convertLength(state, currValue));
860 array->append(convertLength(state, dash));
861 } 860 }
862 861
863 return array.release(); 862 return array.release();
864 } 863 }
865 864
866 StyleColor StyleBuilderConverter::convertStyleColor(StyleResolverState& state, C SSValue* value, bool forVisitedLink) 865 StyleColor StyleBuilderConverter::convertStyleColor(StyleResolverState& state, C SSValue value, bool forVisitedLink)
867 { 866 {
868 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 867 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
869 if (primitiveValue->getValueID() == CSSValueCurrentcolor) 868 if (primitiveValue.getValueID() == CSSValueCurrentcolor)
870 return StyleColor::currentColor(); 869 return StyleColor::currentColor();
871 return state.document().textLinkColors().colorFromPrimitiveValue(primitiveVa lue, Color(), forVisitedLink); 870 return state.document().textLinkColors().colorFromPrimitiveValue(primitiveVa lue, Color(), forVisitedLink);
872 } 871 }
873 872
874 float StyleBuilderConverter::convertTextStrokeWidth(StyleResolverState& state, C SSValue* value) 873 float StyleBuilderConverter::convertTextStrokeWidth(StyleResolverState& state, C SSValue value)
875 { 874 {
876 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 875 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
877 if (primitiveValue->getValueID()) { 876 if (primitiveValue.getValueID()) {
878 float multiplier = convertLineWidth<float>(state, value); 877 float multiplier = convertLineWidth<float>(state, value);
879 return CSSPrimitiveValue::create(multiplier / 48, CSSPrimitiveValue::CSS _EMS)->computeLength<float>(state.cssToLengthConversionData()); 878 return CSSPrimitiveValue::create(multiplier / 48, CSSPrimitiveValue::CSS _EMS)->computeLength<float>(state.cssToLengthConversionData());
880 } 879 }
881 return primitiveValue->computeLength<float>(state.cssToLengthConversionData( )); 880 return primitiveValue.computeLength<float>(state.cssToLengthConversionData() );
882 } 881 }
883 882
884 TransformOrigin StyleBuilderConverter::convertTransformOrigin(StyleResolverState & state, CSSValue* value) 883 TransformOrigin StyleBuilderConverter::convertTransformOrigin(StyleResolverState & state, CSSValue value)
885 { 884 {
886 CSSValueList* list = toCSSValueList(value); 885 CSSValueList& list = toCSSValueList(value);
887 ASSERT(list->length() == 3); 886 ASSERT(list.length() == 3);
888 887
889 CSSPrimitiveValue* primitiveValueX = toCSSPrimitiveValue(list->item(0)); 888 CSSPrimitiveValue& primitiveValueX = toCSSPrimitiveValue(list.item(0));
890 CSSPrimitiveValue* primitiveValueY = toCSSPrimitiveValue(list->item(1)); 889 CSSPrimitiveValue& primitiveValueY = toCSSPrimitiveValue(list.item(1));
891 CSSPrimitiveValue* primitiveValueZ = toCSSPrimitiveValue(list->item(2));
892 890
893 return TransformOrigin( 891 return TransformOrigin(
894 convertOriginLength<CSSValueLeft, CSSValueRight>(state, primitiveValueX) , 892 convertOriginLength<CSSValueLeft, CSSValueRight>(state, primitiveValueX) ,
895 convertOriginLength<CSSValueTop, CSSValueBottom>(state, primitiveValueY) , 893 convertOriginLength<CSSValueTop, CSSValueBottom>(state, primitiveValueY) ,
896 StyleBuilderConverter::convertComputedLength<float>(state, primitiveValu eZ) 894 StyleBuilderConverter::convertComputedLength<float>(state, list.item(2))
897 ); 895 );
898 } 896 }
899 897
900 ScrollSnapPoints StyleBuilderConverter::convertSnapPoints(StyleResolverState& st ate, CSSValue* value) 898 ScrollSnapPoints StyleBuilderConverter::convertSnapPoints(StyleResolverState& st ate, CSSValue value)
901 { 899 {
902 // Handles: none | repeat(<length>) 900 // Handles: none | repeat(<length>)
903 ScrollSnapPoints points; 901 ScrollSnapPoints points;
904 points.hasRepeat = false; 902 points.hasRepeat = false;
905 903
906 if (!value->isFunctionValue()) 904 if (!value.isFunctionValue())
907 return points; 905 return points;
908 906
909 CSSFunctionValue* repeatFunction = toCSSFunctionValue(value); 907 CSSFunctionValue& repeatFunction = toCSSFunctionValue(value);
910 ASSERT_WITH_SECURITY_IMPLICATION(repeatFunction->length() == 1); 908 ASSERT_WITH_SECURITY_IMPLICATION(repeatFunction.length() == 1);
911 points.repeatOffset = convertLength(state, toCSSPrimitiveValue(repeatFunctio n->item(0))); 909 points.repeatOffset = convertLength(state, repeatFunction.item(0));
912 points.hasRepeat = true; 910 points.hasRepeat = true;
913 911
914 return points; 912 return points;
915 } 913 }
916 914
917 Vector<LengthPoint> StyleBuilderConverter::convertSnapCoordinates(StyleResolverS tate& state, CSSValue* value) 915 Vector<LengthPoint> StyleBuilderConverter::convertSnapCoordinates(StyleResolverS tate& state, CSSValue value)
918 { 916 {
919 // Handles: none | <position># 917 // Handles: none | <position>#
920 Vector<LengthPoint> coordinates; 918 Vector<LengthPoint> coordinates;
921 919
922 if (!value->isValueList()) 920 if (!value.isValueList())
923 return coordinates; 921 return coordinates;
924 922
925 CSSValueList* valueList = toCSSValueList(value); 923 CSSValueList& valueList = toCSSValueList(value);
926 coordinates.reserveInitialCapacity(valueList->length()); 924 coordinates.reserveInitialCapacity(valueList.length());
927 for (auto& snapCoordinate : *valueList) { 925 for (auto& snapCoordinate : valueList) {
928 coordinates.uncheckedAppend(convertPosition(state, snapCoordinate.get()) ); 926 coordinates.uncheckedAppend(convertPosition(state, snapCoordinate));
929 } 927 }
930 928
931 return coordinates; 929 return coordinates;
932 } 930 }
933 931
934 PassRefPtr<TranslateTransformOperation> StyleBuilderConverter::convertTranslate( StyleResolverState& state, CSSValue* value) 932 PassRefPtr<TranslateTransformOperation> StyleBuilderConverter::convertTranslate( StyleResolverState& state, CSSValue value)
935 { 933 {
936 CSSValueList& list = *toCSSValueList(value); 934 CSSValueList& list = toCSSValueList(value);
937 ASSERT(list.length() <= 3); 935 ASSERT(list.length() <= 3);
938 Length tx = convertLength(state, list.item(0)); 936 Length tx = convertLength(state, list.item(0));
939 Length ty(0, Fixed); 937 Length ty(0, Fixed);
940 double tz = 0; 938 double tz = 0;
941 if (list.length() >= 2) 939 if (list.length() >= 2)
942 ty = convertLength(state, list.item(1)); 940 ty = convertLength(state, list.item(1));
943 if (list.length() == 3) 941 if (list.length() == 3)
944 tz = toCSSPrimitiveValue(list.item(2))->getDoubleValue(); 942 tz = toCSSPrimitiveValue(list.item(2)).getDoubleValue();
945 943
946 return TranslateTransformOperation::create(tx, ty, tz, TransformOperation::T ranslate3D); 944 return TranslateTransformOperation::create(tx, ty, tz, TransformOperation::T ranslate3D);
947 } 945 }
948 946
949 PassRefPtr<RotateTransformOperation> StyleBuilderConverter::convertRotate(StyleR esolverState& state, CSSValue* value) 947 PassRefPtr<RotateTransformOperation> StyleBuilderConverter::convertRotate(StyleR esolverState& state, CSSValue value)
950 { 948 {
951 CSSValueList& list = *toCSSValueList(value); 949 CSSValueList& list = toCSSValueList(value);
952 ASSERT(list.length() == 1 || list.length() == 4); 950 ASSERT(list.length() == 1 || list.length() == 4);
953 double angle = toCSSPrimitiveValue(list.item(0))->computeDegrees(); 951 double angle = toCSSPrimitiveValue(list.item(0)).computeDegrees();
954 double x = 0; 952 double x = 0;
955 double y = 0; 953 double y = 0;
956 double z = 1; 954 double z = 1;
957 if (list.length() == 4) { 955 if (list.length() == 4) {
958 x = toCSSPrimitiveValue(list.item(1))->getDoubleValue(); 956 x = toCSSPrimitiveValue(list.item(1)).getDoubleValue();
959 y = toCSSPrimitiveValue(list.item(2))->getDoubleValue(); 957 y = toCSSPrimitiveValue(list.item(2)).getDoubleValue();
960 z = toCSSPrimitiveValue(list.item(3))->getDoubleValue(); 958 z = toCSSPrimitiveValue(list.item(3)).getDoubleValue();
961 } 959 }
962 960
963 return RotateTransformOperation::create(x, y, z, angle, TransformOperation:: Rotate3D); 961 return RotateTransformOperation::create(x, y, z, angle, TransformOperation:: Rotate3D);
964 } 962 }
965 963
966 PassRefPtr<ScaleTransformOperation> StyleBuilderConverter::convertScale(StyleRes olverState& state, CSSValue* value) 964 PassRefPtr<ScaleTransformOperation> StyleBuilderConverter::convertScale(StyleRes olverState& state, CSSValue value)
967 { 965 {
968 CSSValueList& list = *toCSSValueList(value); 966 CSSValueList& list = toCSSValueList(value);
969 ASSERT(list.length() <= 3); 967 ASSERT(list.length() <= 3);
970 double sx = toCSSPrimitiveValue(list.item(0))->getDoubleValue(); 968 double sx = toCSSPrimitiveValue(list.item(0)).getDoubleValue();
971 double sy = sx; 969 double sy = sx;
972 double sz = 1; 970 double sz = 1;
973 if (list.length() >= 2) 971 if (list.length() >= 2)
974 sy = toCSSPrimitiveValue(list.item(1))->getDoubleValue(); 972 sy = toCSSPrimitiveValue(list.item(1)).getDoubleValue();
975 if (list.length() == 3) 973 if (list.length() == 3)
976 sz = toCSSPrimitiveValue(list.item(2))->getDoubleValue(); 974 sz = toCSSPrimitiveValue(list.item(2)).getDoubleValue();
977 975
978 return ScaleTransformOperation::create(sx, sy, sz, TransformOperation::Scale 3D); 976 return ScaleTransformOperation::create(sx, sy, sz, TransformOperation::Scale 3D);
979 } 977 }
980 978
981 } // namespace blink 979 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/resolver/StyleBuilderConverter.h ('k') | Source/core/css/resolver/StyleBuilderCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698