OLD | NEW |
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 17 matching lines...) Expand all Loading... |
28 | 28 |
29 #include "core/css/BasicShapeFunctions.h" | 29 #include "core/css/BasicShapeFunctions.h" |
30 #include "core/css/CSSBasicShapeValues.h" | 30 #include "core/css/CSSBasicShapeValues.h" |
31 #include "core/css/CSSContentDistributionValue.h" | 31 #include "core/css/CSSContentDistributionValue.h" |
32 #include "core/css/CSSCustomIdentValue.h" | 32 #include "core/css/CSSCustomIdentValue.h" |
33 #include "core/css/CSSFontFamilyValue.h" | 33 #include "core/css/CSSFontFamilyValue.h" |
34 #include "core/css/CSSFontFeatureValue.h" | 34 #include "core/css/CSSFontFeatureValue.h" |
35 #include "core/css/CSSFunctionValue.h" | 35 #include "core/css/CSSFunctionValue.h" |
36 #include "core/css/CSSGridAutoRepeatValue.h" | 36 #include "core/css/CSSGridAutoRepeatValue.h" |
37 #include "core/css/CSSGridLineNamesValue.h" | 37 #include "core/css/CSSGridLineNamesValue.h" |
| 38 #include "core/css/CSSIdentifierValue.h" |
38 #include "core/css/CSSPathValue.h" | 39 #include "core/css/CSSPathValue.h" |
39 #include "core/css/CSSPrimitiveValueMappings.h" | 40 #include "core/css/CSSPrimitiveValueMappings.h" |
40 #include "core/css/CSSQuadValue.h" | 41 #include "core/css/CSSQuadValue.h" |
41 #include "core/css/CSSReflectValue.h" | 42 #include "core/css/CSSReflectValue.h" |
42 #include "core/css/CSSShadowValue.h" | 43 #include "core/css/CSSShadowValue.h" |
43 #include "core/css/CSSStringValue.h" | 44 #include "core/css/CSSStringValue.h" |
44 #include "core/css/CSSURIValue.h" | 45 #include "core/css/CSSURIValue.h" |
45 #include "core/css/CSSValuePair.h" | 46 #include "core/css/CSSValuePair.h" |
46 #include "core/css/resolver/FilterOperationResolver.h" | 47 #include "core/css/resolver/FilterOperationResolver.h" |
47 #include "core/frame/LocalFrame.h" | 48 #include "core/frame/LocalFrame.h" |
48 #include "core/style/ClipPathOperation.h" | 49 #include "core/style/ClipPathOperation.h" |
49 #include "core/style/TextSizeAdjust.h" | 50 #include "core/style/TextSizeAdjust.h" |
50 #include "core/svg/SVGURIReference.h" | 51 #include "core/svg/SVGURIReference.h" |
51 #include "platform/transforms/RotateTransformOperation.h" | 52 #include "platform/transforms/RotateTransformOperation.h" |
52 #include "platform/transforms/ScaleTransformOperation.h" | 53 #include "platform/transforms/ScaleTransformOperation.h" |
53 #include "platform/transforms/TranslateTransformOperation.h" | 54 #include "platform/transforms/TranslateTransformOperation.h" |
54 #include <algorithm> | 55 #include <algorithm> |
55 | 56 |
56 namespace blink { | 57 namespace blink { |
57 | 58 |
58 namespace { | 59 namespace { |
59 | 60 |
60 static GridLength convertGridTrackBreadth(const StyleResolverState& state, const
CSSPrimitiveValue& primitiveValue) | 61 static GridLength convertGridTrackBreadth(const StyleResolverState& state, const
CSSValue& value) |
61 { | 62 { |
62 if (primitiveValue.getValueID() == CSSValueMinContent) | 63 // Fractional unit. |
| 64 if (value.isPrimitiveValue() && toCSSPrimitiveValue(value).isFlex()) |
| 65 return GridLength(toCSSPrimitiveValue(value).getDoubleValue()); |
| 66 |
| 67 if (value.isIdentifierValue() && toCSSIdentifierValue(value).getValueID() ==
CSSValueMinContent) |
63 return Length(MinContent); | 68 return Length(MinContent); |
64 | 69 |
65 if (primitiveValue.getValueID() == CSSValueMaxContent) | 70 if (value.isIdentifierValue() && toCSSIdentifierValue(value).getValueID() ==
CSSValueMaxContent) |
66 return Length(MaxContent); | 71 return Length(MaxContent); |
67 | 72 |
68 // Fractional unit. | 73 return StyleBuilderConverter::convertLengthOrAuto(state, value); |
69 if (primitiveValue.isFlex()) | |
70 return GridLength(primitiveValue.getDoubleValue()); | |
71 | |
72 return StyleBuilderConverter::convertLengthOrAuto(state, primitiveValue); | |
73 } | 74 } |
74 | 75 |
75 } // namespace | 76 } // namespace |
76 | 77 |
77 PassRefPtr<StyleReflection> StyleBuilderConverter::convertBoxReflect(StyleResolv
erState& state, const CSSValue& value) | 78 PassRefPtr<StyleReflection> StyleBuilderConverter::convertBoxReflect(StyleResolv
erState& state, const CSSValue& value) |
78 { | 79 { |
79 if (value.isPrimitiveValue()) { | 80 if (value.isIdentifierValue()) { |
80 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNone); | 81 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); |
81 return ComputedStyle::initialBoxReflect(); | 82 return ComputedStyle::initialBoxReflect(); |
82 } | 83 } |
83 | 84 |
84 const CSSReflectValue& reflectValue = toCSSReflectValue(value); | 85 const CSSReflectValue& reflectValue = toCSSReflectValue(value); |
85 RefPtr<StyleReflection> reflection = StyleReflection::create(); | 86 RefPtr<StyleReflection> reflection = StyleReflection::create(); |
86 reflection->setDirection(reflectValue.direction()->convertTo<CSSReflectionDi
rection>()); | 87 reflection->setDirection(reflectValue.direction()->convertTo<CSSReflectionDi
rection>()); |
87 if (reflectValue.offset()) | 88 if (reflectValue.offset()) |
88 reflection->setOffset(reflectValue.offset()->convertToLength(state.cssTo
LengthConversionData())); | 89 reflection->setOffset(reflectValue.offset()->convertToLength(state.cssTo
LengthConversionData())); |
89 if (reflectValue.mask()) { | 90 if (reflectValue.mask()) { |
90 NinePieceImage mask; | 91 NinePieceImage mask; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 if (value.isURIValue()) { | 126 if (value.isURIValue()) { |
126 SVGURLReferenceResolver resolver(toCSSURIValue(value).value(), state.doc
ument()); | 127 SVGURLReferenceResolver resolver(toCSSURIValue(value).value(), state.doc
ument()); |
127 // If the reference is non-local, then the fragment will remain as a | 128 // If the reference is non-local, then the fragment will remain as a |
128 // null string, which makes the element lookup fail. | 129 // null string, which makes the element lookup fail. |
129 AtomicString fragmentIdentifier; | 130 AtomicString fragmentIdentifier; |
130 if (resolver.isLocal()) | 131 if (resolver.isLocal()) |
131 fragmentIdentifier = resolver.fragmentIdentifier(); | 132 fragmentIdentifier = resolver.fragmentIdentifier(); |
132 // TODO(fs): Doesn't work with forward or external SVG references (crbug
.com/391604, crbug.com/109212, ...) | 133 // TODO(fs): Doesn't work with forward or external SVG references (crbug
.com/391604, crbug.com/109212, ...) |
133 return ReferenceClipPathOperation::create(toCSSURIValue(value).value(),
fragmentIdentifier); | 134 return ReferenceClipPathOperation::create(toCSSURIValue(value).value(),
fragmentIdentifier); |
134 } | 135 } |
135 DCHECK(value.isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID() =
= CSSValueNone); | 136 DCHECK(value.isIdentifierValue() && toCSSIdentifierValue(value).getValueID()
== CSSValueNone); |
136 return nullptr; | 137 return nullptr; |
137 } | 138 } |
138 | 139 |
139 FilterOperations StyleBuilderConverter::convertFilterOperations(StyleResolverSta
te& state, const CSSValue& value) | 140 FilterOperations StyleBuilderConverter::convertFilterOperations(StyleResolverSta
te& state, const CSSValue& value) |
140 { | 141 { |
141 return FilterOperationResolver::createFilterOperations(state, value); | 142 return FilterOperationResolver::createFilterOperations(state, value); |
142 } | 143 } |
143 | 144 |
144 static FontDescription::GenericFamilyType convertGenericFamily(CSSValueID valueI
D) | 145 static FontDescription::GenericFamilyType convertGenericFamily(CSSValueID valueI
D) |
145 { | 146 { |
(...skipping 17 matching lines...) Expand all Loading... |
163 } | 164 } |
164 } | 165 } |
165 | 166 |
166 static bool convertFontFamilyName(StyleResolverState& state, const CSSValue& val
ue, | 167 static bool convertFontFamilyName(StyleResolverState& state, const CSSValue& val
ue, |
167 FontDescription::GenericFamilyType& genericFamily, AtomicString& familyName) | 168 FontDescription::GenericFamilyType& genericFamily, AtomicString& familyName) |
168 { | 169 { |
169 if (value.isFontFamilyValue()) { | 170 if (value.isFontFamilyValue()) { |
170 genericFamily = FontDescription::NoFamily; | 171 genericFamily = FontDescription::NoFamily; |
171 familyName = AtomicString(toCSSFontFamilyValue(value).value()); | 172 familyName = AtomicString(toCSSFontFamilyValue(value).value()); |
172 } else if (state.document().settings()) { | 173 } else if (state.document().settings()) { |
173 genericFamily = convertGenericFamily(toCSSPrimitiveValue(value).getValue
ID()); | 174 genericFamily = convertGenericFamily(toCSSIdentifierValue(value).getValu
eID()); |
174 familyName = state.fontBuilder().genericFontFamilyName(genericFamily); | 175 familyName = state.fontBuilder().genericFontFamilyName(genericFamily); |
175 } | 176 } |
176 | 177 |
177 return !familyName.isEmpty(); | 178 return !familyName.isEmpty(); |
178 } | 179 } |
179 | 180 |
180 FontDescription::FamilyDescription StyleBuilderConverter::convertFontFamily(Styl
eResolverState& state, const CSSValue& value) | 181 FontDescription::FamilyDescription StyleBuilderConverter::convertFontFamily(Styl
eResolverState& state, const CSSValue& value) |
181 { | 182 { |
182 ASSERT(value.isValueList()); | 183 ASSERT(value.isValueList()); |
183 | 184 |
(...skipping 19 matching lines...) Expand all Loading... |
203 | 204 |
204 if (genericFamily != FontDescription::NoFamily) | 205 if (genericFamily != FontDescription::NoFamily) |
205 desc.genericFamily = genericFamily; | 206 desc.genericFamily = genericFamily; |
206 } | 207 } |
207 | 208 |
208 return desc; | 209 return desc; |
209 } | 210 } |
210 | 211 |
211 PassRefPtr<FontFeatureSettings> StyleBuilderConverter::convertFontFeatureSetting
s(StyleResolverState& state, const CSSValue& value) | 212 PassRefPtr<FontFeatureSettings> StyleBuilderConverter::convertFontFeatureSetting
s(StyleResolverState& state, const CSSValue& value) |
212 { | 213 { |
213 if (value.isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID() == C
SSValueNormal) | 214 if (value.isIdentifierValue() && toCSSIdentifierValue(value).getValueID() ==
CSSValueNormal) |
214 return FontBuilder::initialFeatureSettings(); | 215 return FontBuilder::initialFeatureSettings(); |
215 | 216 |
216 const CSSValueList& list = toCSSValueList(value); | 217 const CSSValueList& list = toCSSValueList(value); |
217 RefPtr<FontFeatureSettings> settings = FontFeatureSettings::create(); | 218 RefPtr<FontFeatureSettings> settings = FontFeatureSettings::create(); |
218 int len = list.length(); | 219 int len = list.length(); |
219 for (int i = 0; i < len; ++i) { | 220 for (int i = 0; i < len; ++i) { |
220 const CSSFontFeatureValue& feature = toCSSFontFeatureValue(list.item(i))
; | 221 const CSSFontFeatureValue& feature = toCSSFontFeatureValue(list.item(i))
; |
221 settings->append(FontFeature(feature.tag(), feature.value())); | 222 settings->append(FontFeature(feature.tag(), feature.value())); |
222 } | 223 } |
223 return settings; | 224 return settings; |
224 } | 225 } |
225 | 226 |
226 static float computeFontSize(StyleResolverState& state, const CSSPrimitiveValue&
primitiveValue, const FontDescription::Size& parentSize) | 227 static float computeFontSize(StyleResolverState& state, const CSSPrimitiveValue&
primitiveValue, const FontDescription::Size& parentSize) |
227 { | 228 { |
228 if (primitiveValue.isLength()) | 229 if (primitiveValue.isLength()) |
229 return primitiveValue.computeLength<float>(state.fontSizeConversionData(
)); | 230 return primitiveValue.computeLength<float>(state.fontSizeConversionData(
)); |
230 if (primitiveValue.isCalculatedPercentageWithLength()) | 231 if (primitiveValue.isCalculatedPercentageWithLength()) |
231 return primitiveValue.cssCalcValue()->toCalcValue(state.fontSizeConversi
onData())->evaluate(parentSize.value); | 232 return primitiveValue.cssCalcValue()->toCalcValue(state.fontSizeConversi
onData())->evaluate(parentSize.value); |
232 | 233 |
233 ASSERT_NOT_REACHED(); | 234 ASSERT_NOT_REACHED(); |
234 return 0; | 235 return 0; |
235 } | 236 } |
236 | 237 |
237 FontDescription::Size StyleBuilderConverter::convertFontSize(StyleResolverState&
state, const CSSValue& value) | 238 FontDescription::Size StyleBuilderConverter::convertFontSize(StyleResolverState&
state, const CSSValue& value) |
238 { | 239 { |
239 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | |
240 | |
241 FontDescription::Size parentSize(0, 0.0f, false); | 240 FontDescription::Size parentSize(0, 0.0f, false); |
242 | 241 |
243 // FIXME: Find out when parentStyle could be 0? | 242 // FIXME: Find out when parentStyle could be 0? |
244 if (state.parentStyle()) | 243 if (state.parentStyle()) |
245 parentSize = state.parentFontDescription().getSize(); | 244 parentSize = state.parentFontDescription().getSize(); |
246 | 245 |
247 if (CSSValueID valueID = primitiveValue.getValueID()) { | 246 if (value.isIdentifierValue()) { |
| 247 CSSValueID valueID = toCSSIdentifierValue(value).getValueID(); |
248 if (FontSize::isValidValueID(valueID)) | 248 if (FontSize::isValidValueID(valueID)) |
249 return FontDescription::Size(FontSize::keywordSize(valueID), 0.0f, f
alse); | 249 return FontDescription::Size(FontSize::keywordSize(valueID), 0.0f, f
alse); |
250 if (valueID == CSSValueSmaller) | 250 if (valueID == CSSValueSmaller) |
251 return FontDescription::smallerSize(parentSize); | 251 return FontDescription::smallerSize(parentSize); |
252 if (valueID == CSSValueLarger) | 252 if (valueID == CSSValueLarger) |
253 return FontDescription::largerSize(parentSize); | 253 return FontDescription::largerSize(parentSize); |
254 ASSERT_NOT_REACHED(); | 254 ASSERT_NOT_REACHED(); |
255 return FontBuilder::initialSize(); | 255 return FontBuilder::initialSize(); |
256 } | 256 } |
257 | 257 |
258 bool parentIsAbsoluteSize = state.parentFontDescription().isAbsoluteSize(); | 258 bool parentIsAbsoluteSize = state.parentFontDescription().isAbsoluteSize(); |
259 | 259 |
| 260 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
260 if (primitiveValue.isPercentage()) | 261 if (primitiveValue.isPercentage()) |
261 return FontDescription::Size(0, (primitiveValue.getFloatValue() * parent
Size.value / 100.0f), parentIsAbsoluteSize); | 262 return FontDescription::Size(0, (primitiveValue.getFloatValue() * parent
Size.value / 100.0f), parentIsAbsoluteSize); |
262 | 263 |
263 return FontDescription::Size(0, computeFontSize(state, primitiveValue, paren
tSize), parentIsAbsoluteSize || !primitiveValue.isFontRelativeLength()); | 264 return FontDescription::Size(0, computeFontSize(state, primitiveValue, paren
tSize), parentIsAbsoluteSize || !primitiveValue.isFontRelativeLength()); |
264 } | 265 } |
265 | 266 |
266 float StyleBuilderConverter::convertFontSizeAdjust(StyleResolverState& state, co
nst CSSValue& value) | 267 float StyleBuilderConverter::convertFontSizeAdjust(StyleResolverState& state, co
nst CSSValue& value) |
267 { | 268 { |
268 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 269 if (value.isIdentifierValue() && toCSSIdentifierValue(value).getValueID() ==
CSSValueNone) |
269 if (primitiveValue.getValueID() == CSSValueNone) | |
270 return FontBuilder::initialSizeAdjust(); | 270 return FontBuilder::initialSizeAdjust(); |
271 | 271 |
| 272 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
272 ASSERT(primitiveValue.isNumber()); | 273 ASSERT(primitiveValue.isNumber()); |
273 return primitiveValue.getFloatValue(); | 274 return primitiveValue.getFloatValue(); |
274 } | 275 } |
275 | 276 |
276 FontWeight StyleBuilderConverter::convertFontWeight(StyleResolverState& state, c
onst CSSValue& value) | 277 FontWeight StyleBuilderConverter::convertFontWeight(StyleResolverState& state, c
onst CSSValue& value) |
277 { | 278 { |
278 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 279 const CSSIdentifierValue& identifierValue = toCSSIdentifierValue(value); |
279 switch (primitiveValue.getValueID()) { | 280 switch (identifierValue.getValueID()) { |
280 case CSSValueBolder: | 281 case CSSValueBolder: |
281 return FontDescription::bolderWeight(state.parentStyle()->getFontDescrip
tion().weight()); | 282 return FontDescription::bolderWeight(state.parentStyle()->getFontDescrip
tion().weight()); |
282 case CSSValueLighter: | 283 case CSSValueLighter: |
283 return FontDescription::lighterWeight(state.parentStyle()->getFontDescri
ption().weight()); | 284 return FontDescription::lighterWeight(state.parentStyle()->getFontDescri
ption().weight()); |
284 default: | 285 default: |
285 return primitiveValue.convertTo<FontWeight>(); | 286 return identifierValue.convertTo<FontWeight>(); |
286 } | 287 } |
287 } | 288 } |
288 | 289 |
289 FontDescription::FontVariantCaps StyleBuilderConverter::convertFontVariantCaps(S
tyleResolverState&, const CSSValue& value) | 290 FontDescription::FontVariantCaps StyleBuilderConverter::convertFontVariantCaps(S
tyleResolverState&, const CSSValue& value) |
290 { | 291 { |
291 ASSERT_WITH_SECURITY_IMPLICATION(value.isPrimitiveValue()); | 292 SECURITY_DCHECK(value.isIdentifierValue()); |
292 CSSValueID valueID = toCSSPrimitiveValue(value).getValueID(); | 293 CSSValueID valueID = toCSSIdentifierValue(value).getValueID(); |
293 switch (valueID) { | 294 switch (valueID) { |
294 case CSSValueNormal: | 295 case CSSValueNormal: |
295 return FontDescription::CapsNormal; | 296 return FontDescription::CapsNormal; |
296 case CSSValueSmallCaps: | 297 case CSSValueSmallCaps: |
297 return FontDescription::SmallCaps; | 298 return FontDescription::SmallCaps; |
298 case CSSValueAllSmallCaps: | 299 case CSSValueAllSmallCaps: |
299 return FontDescription::AllSmallCaps; | 300 return FontDescription::AllSmallCaps; |
300 case CSSValuePetiteCaps: | 301 case CSSValuePetiteCaps: |
301 return FontDescription::PetiteCaps; | 302 return FontDescription::PetiteCaps; |
302 case CSSValueAllPetiteCaps: | 303 case CSSValueAllPetiteCaps: |
303 return FontDescription::AllPetiteCaps; | 304 return FontDescription::AllPetiteCaps; |
304 case CSSValueUnicase: | 305 case CSSValueUnicase: |
305 return FontDescription::Unicase; | 306 return FontDescription::Unicase; |
306 case CSSValueTitlingCaps: | 307 case CSSValueTitlingCaps: |
307 return FontDescription::TitlingCaps; | 308 return FontDescription::TitlingCaps; |
308 default: | 309 default: |
309 return FontDescription::CapsNormal; | 310 return FontDescription::CapsNormal; |
310 } | 311 } |
311 } | 312 } |
312 | 313 |
313 FontDescription::VariantLigatures StyleBuilderConverter::convertFontVariantLigat
ures(StyleResolverState&, const CSSValue& value) | 314 FontDescription::VariantLigatures StyleBuilderConverter::convertFontVariantLigat
ures(StyleResolverState&, const CSSValue& value) |
314 { | 315 { |
315 if (value.isValueList()) { | 316 if (value.isValueList()) { |
316 FontDescription::VariantLigatures ligatures; | 317 FontDescription::VariantLigatures ligatures; |
317 const CSSValueList& valueList = toCSSValueList(value); | 318 const CSSValueList& valueList = toCSSValueList(value); |
318 for (size_t i = 0; i < valueList.length(); ++i) { | 319 for (size_t i = 0; i < valueList.length(); ++i) { |
319 const CSSValue& item = valueList.item(i); | 320 const CSSValue& item = valueList.item(i); |
320 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(item); | 321 switch (toCSSIdentifierValue(item).getValueID()) { |
321 switch (primitiveValue.getValueID()) { | |
322 case CSSValueNoCommonLigatures: | 322 case CSSValueNoCommonLigatures: |
323 ligatures.common = FontDescription::DisabledLigaturesState; | 323 ligatures.common = FontDescription::DisabledLigaturesState; |
324 break; | 324 break; |
325 case CSSValueCommonLigatures: | 325 case CSSValueCommonLigatures: |
326 ligatures.common = FontDescription::EnabledLigaturesState; | 326 ligatures.common = FontDescription::EnabledLigaturesState; |
327 break; | 327 break; |
328 case CSSValueNoDiscretionaryLigatures: | 328 case CSSValueNoDiscretionaryLigatures: |
329 ligatures.discretionary = FontDescription::DisabledLigaturesStat
e; | 329 ligatures.discretionary = FontDescription::DisabledLigaturesStat
e; |
330 break; | 330 break; |
331 case CSSValueDiscretionaryLigatures: | 331 case CSSValueDiscretionaryLigatures: |
(...skipping 12 matching lines...) Expand all Loading... |
344 ligatures.contextual = FontDescription::EnabledLigaturesState; | 344 ligatures.contextual = FontDescription::EnabledLigaturesState; |
345 break; | 345 break; |
346 default: | 346 default: |
347 ASSERT_NOT_REACHED(); | 347 ASSERT_NOT_REACHED(); |
348 break; | 348 break; |
349 } | 349 } |
350 } | 350 } |
351 return ligatures; | 351 return ligatures; |
352 } | 352 } |
353 | 353 |
354 ASSERT_WITH_SECURITY_IMPLICATION(value.isPrimitiveValue()); | 354 SECURITY_DCHECK(value.isIdentifierValue()); |
355 | 355 if (toCSSIdentifierValue(value).getValueID() == CSSValueNone) { |
356 if (toCSSPrimitiveValue(value).getValueID() == CSSValueNone) { | |
357 return FontDescription::VariantLigatures(FontDescription::DisabledLigatu
resState); | 356 return FontDescription::VariantLigatures(FontDescription::DisabledLigatu
resState); |
358 } | 357 } |
359 | 358 |
360 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNormal); | 359 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNormal); |
361 return FontDescription::VariantLigatures(); | 360 return FontDescription::VariantLigatures(); |
362 } | 361 } |
363 | 362 |
364 FontVariantNumeric StyleBuilderConverter::convertFontVariantNumeric(StyleResolve
rState&, const CSSValue& value) | 363 FontVariantNumeric StyleBuilderConverter::convertFontVariantNumeric(StyleResolve
rState&, const CSSValue& value) |
365 { | 364 { |
366 if (value.isPrimitiveValue()) { | 365 if (value.isIdentifierValue()) { |
367 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNormal); | 366 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNormal); |
368 return FontVariantNumeric(); | 367 return FontVariantNumeric(); |
369 } | 368 } |
370 | 369 |
371 FontVariantNumeric variantNumeric; | 370 FontVariantNumeric variantNumeric; |
372 for (const CSSValue* feature : toCSSValueList(value)) { | 371 for (const CSSValue* feature : toCSSValueList(value)) { |
373 switch (toCSSPrimitiveValue(feature)->getValueID()) { | 372 switch (toCSSIdentifierValue(feature)->getValueID()) { |
374 case CSSValueLiningNums: | 373 case CSSValueLiningNums: |
375 variantNumeric.setNumericFigure(FontVariantNumeric::LiningNums); | 374 variantNumeric.setNumericFigure(FontVariantNumeric::LiningNums); |
376 break; | 375 break; |
377 case CSSValueOldstyleNums: | 376 case CSSValueOldstyleNums: |
378 variantNumeric.setNumericFigure(FontVariantNumeric::OldstyleNums); | 377 variantNumeric.setNumericFigure(FontVariantNumeric::OldstyleNums); |
379 break; | 378 break; |
380 case CSSValueProportionalNums: | 379 case CSSValueProportionalNums: |
381 variantNumeric.setNumericSpacing(FontVariantNumeric::ProportionalNum
s); | 380 variantNumeric.setNumericSpacing(FontVariantNumeric::ProportionalNum
s); |
382 break; | 381 break; |
383 case CSSValueTabularNums: | 382 case CSSValueTabularNums: |
(...skipping 17 matching lines...) Expand all Loading... |
401 } | 400 } |
402 } | 401 } |
403 return variantNumeric; | 402 return variantNumeric; |
404 } | 403 } |
405 | 404 |
406 StyleSelfAlignmentData StyleBuilderConverter::convertSelfOrDefaultAlignmentData(
StyleResolverState&, const CSSValue& value) | 405 StyleSelfAlignmentData StyleBuilderConverter::convertSelfOrDefaultAlignmentData(
StyleResolverState&, const CSSValue& value) |
407 { | 406 { |
408 StyleSelfAlignmentData alignmentData = ComputedStyle::initialSelfAlignment()
; | 407 StyleSelfAlignmentData alignmentData = ComputedStyle::initialSelfAlignment()
; |
409 if (value.isValuePair()) { | 408 if (value.isValuePair()) { |
410 const CSSValuePair& pair = toCSSValuePair(value); | 409 const CSSValuePair& pair = toCSSValuePair(value); |
411 if (toCSSPrimitiveValue(pair.first()).getValueID() == CSSValueLegacy) { | 410 if (toCSSIdentifierValue(pair.first()).getValueID() == CSSValueLegacy) { |
412 alignmentData.setPositionType(LegacyPosition); | 411 alignmentData.setPositionType(LegacyPosition); |
413 alignmentData.setPosition(toCSSPrimitiveValue(pair.second()).convert
To<ItemPosition>()); | 412 alignmentData.setPosition(toCSSIdentifierValue(pair.second()).conver
tTo<ItemPosition>()); |
414 } else { | 413 } else { |
415 alignmentData.setPosition(toCSSPrimitiveValue(pair.first()).convertT
o<ItemPosition>()); | 414 alignmentData.setPosition(toCSSIdentifierValue(pair.first()).convert
To<ItemPosition>()); |
416 alignmentData.setOverflow(toCSSPrimitiveValue(pair.second()).convert
To<OverflowAlignment>()); | 415 alignmentData.setOverflow(toCSSIdentifierValue(pair.second()).conver
tTo<OverflowAlignment>()); |
417 } | 416 } |
418 } else { | 417 } else { |
419 alignmentData.setPosition(toCSSPrimitiveValue(value).convertTo<ItemPosit
ion>()); | 418 alignmentData.setPosition(toCSSIdentifierValue(value).convertTo<ItemPosi
tion>()); |
420 } | 419 } |
421 return alignmentData; | 420 return alignmentData; |
422 } | 421 } |
423 | 422 |
424 StyleContentAlignmentData StyleBuilderConverter::convertContentAlignmentData(Sty
leResolverState&, const CSSValue& value) | 423 StyleContentAlignmentData StyleBuilderConverter::convertContentAlignmentData(Sty
leResolverState&, const CSSValue& value) |
425 { | 424 { |
426 StyleContentAlignmentData alignmentData = ComputedStyle::initialContentAlign
ment(); | 425 StyleContentAlignmentData alignmentData = ComputedStyle::initialContentAlign
ment(); |
427 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) { | 426 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) { |
428 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 427 const CSSIdentifierValue& identifierValue = toCSSIdentifierValue(value); |
429 switch (primitiveValue.getValueID()) { | 428 switch (identifierValue.getValueID()) { |
430 case CSSValueStretch: | 429 case CSSValueStretch: |
431 case CSSValueSpaceBetween: | 430 case CSSValueSpaceBetween: |
432 case CSSValueSpaceAround: | 431 case CSSValueSpaceAround: |
433 alignmentData.setDistribution(primitiveValue.convertTo<ContentDistri
butionType>()); | 432 alignmentData.setDistribution(identifierValue.convertTo<ContentDistr
ibutionType>()); |
434 break; | 433 break; |
435 case CSSValueFlexStart: | 434 case CSSValueFlexStart: |
436 case CSSValueFlexEnd: | 435 case CSSValueFlexEnd: |
437 case CSSValueCenter: | 436 case CSSValueCenter: |
438 alignmentData.setPosition(primitiveValue.convertTo<ContentPosition>(
)); | 437 alignmentData.setPosition(identifierValue.convertTo<ContentPosition>
()); |
439 break; | 438 break; |
440 default: | 439 default: |
441 ASSERT_NOT_REACHED(); | 440 ASSERT_NOT_REACHED(); |
442 } | 441 } |
443 return alignmentData; | 442 return alignmentData; |
444 } | 443 } |
445 const CSSContentDistributionValue& contentValue = toCSSContentDistributionVa
lue(value); | 444 const CSSContentDistributionValue& contentValue = toCSSContentDistributionVa
lue(value); |
446 if (contentValue.distribution()->getValueID() != CSSValueInvalid) | 445 if (contentValue.distribution()->getValueID() != CSSValueInvalid) |
447 alignmentData.setDistribution(contentValue.distribution()->convertTo<Con
tentDistributionType>()); | 446 alignmentData.setDistribution(contentValue.distribution()->convertTo<Con
tentDistributionType>()); |
448 if (contentValue.position()->getValueID() != CSSValueInvalid) | 447 if (contentValue.position()->getValueID() != CSSValueInvalid) |
449 alignmentData.setPosition(contentValue.position()->convertTo<ContentPosi
tion>()); | 448 alignmentData.setPosition(contentValue.position()->convertTo<ContentPosi
tion>()); |
450 if (contentValue.overflow()->getValueID() != CSSValueInvalid) | 449 if (contentValue.overflow()->getValueID() != CSSValueInvalid) |
451 alignmentData.setOverflow(contentValue.overflow()->convertTo<OverflowAli
gnment>()); | 450 alignmentData.setOverflow(contentValue.overflow()->convertTo<OverflowAli
gnment>()); |
452 return alignmentData; | 451 return alignmentData; |
453 } | 452 } |
454 | 453 |
455 GridAutoFlow StyleBuilderConverter::convertGridAutoFlow(StyleResolverState&, con
st CSSValue& value) | 454 GridAutoFlow StyleBuilderConverter::convertGridAutoFlow(StyleResolverState&, con
st CSSValue& value) |
456 { | 455 { |
457 const CSSValueList& list = toCSSValueList(value); | 456 const CSSValueList& list = toCSSValueList(value); |
458 | 457 |
459 ASSERT(list.length() >= 1); | 458 ASSERT(list.length() >= 1); |
460 const CSSPrimitiveValue& first = toCSSPrimitiveValue(list.item(0)); | 459 const CSSIdentifierValue& first = toCSSIdentifierValue(list.item(0)); |
461 const CSSPrimitiveValue* second = list.length() == 2 ? &toCSSPrimitiveValue(
list.item(1)) : nullptr; | 460 const CSSIdentifierValue* second = list.length() == 2 ? &toCSSIdentifierValu
e(list.item(1)) : nullptr; |
462 | 461 |
463 switch (first.getValueID()) { | 462 switch (first.getValueID()) { |
464 case CSSValueRow: | 463 case CSSValueRow: |
465 if (second && second->getValueID() == CSSValueDense) | 464 if (second && second->getValueID() == CSSValueDense) |
466 return AutoFlowRowDense; | 465 return AutoFlowRowDense; |
467 return AutoFlowRow; | 466 return AutoFlowRow; |
468 case CSSValueColumn: | 467 case CSSValueColumn: |
469 if (second && second->getValueID() == CSSValueDense) | 468 if (second && second->getValueID() == CSSValueDense) |
470 return AutoFlowColumnDense; | 469 return AutoFlowColumnDense; |
471 return AutoFlowColumn; | 470 return AutoFlowColumn; |
(...skipping 14 matching lines...) Expand all Loading... |
486 | 485 |
487 GridPosition position; | 486 GridPosition position; |
488 | 487 |
489 if (value.isCustomIdentValue()) { | 488 if (value.isCustomIdentValue()) { |
490 // We translate <custom-ident> to <string> during parsing as it | 489 // We translate <custom-ident> to <string> during parsing as it |
491 // makes handling it more simple. | 490 // makes handling it more simple. |
492 position.setNamedGridArea(toCSSCustomIdentValue(value).value()); | 491 position.setNamedGridArea(toCSSCustomIdentValue(value).value()); |
493 return position; | 492 return position; |
494 } | 493 } |
495 | 494 |
496 if (value.isPrimitiveValue()) { | 495 if (value.isIdentifierValue()) { |
497 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueAuto); | 496 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueAuto); |
498 return position; | 497 return position; |
499 } | 498 } |
500 | 499 |
501 const CSSValueList& values = toCSSValueList(value); | 500 const CSSValueList& values = toCSSValueList(value); |
502 ASSERT(values.length()); | 501 ASSERT(values.length()); |
503 | 502 |
504 bool isSpanPosition = false; | 503 bool isSpanPosition = false; |
505 // The specification makes the <integer> optional, in which case it default
to '1'. | 504 // The specification makes the <integer> optional, in which case it default
to '1'. |
506 int gridLineNumber = 1; | 505 int gridLineNumber = 1; |
507 AtomicString gridLineName; | 506 AtomicString gridLineName; |
508 | 507 |
509 auto it = values.begin(); | 508 auto it = values.begin(); |
510 const CSSValue* currentValue = it->get(); | 509 const CSSValue* currentValue = it->get(); |
511 if (currentValue->isPrimitiveValue() && toCSSPrimitiveValue(currentValue)->g
etValueID() == CSSValueSpan) { | 510 if (currentValue->isIdentifierValue() && toCSSIdentifierValue(currentValue)-
>getValueID() == CSSValueSpan) { |
512 isSpanPosition = true; | 511 isSpanPosition = true; |
513 ++it; | 512 ++it; |
514 currentValue = it != values.end() ? it->get() : nullptr; | 513 currentValue = it != values.end() ? it->get() : nullptr; |
515 } | 514 } |
516 | 515 |
517 if (currentValue && currentValue->isPrimitiveValue() && toCSSPrimitiveValue(
currentValue)->isNumber()) { | 516 if (currentValue && currentValue->isPrimitiveValue() && toCSSPrimitiveValue(
currentValue)->isNumber()) { |
518 gridLineNumber = toCSSPrimitiveValue(currentValue)->getIntValue(); | 517 gridLineNumber = toCSSPrimitiveValue(currentValue)->getIntValue(); |
519 ++it; | 518 ++it; |
520 currentValue = it != values.end() ? it->get() : nullptr; | 519 currentValue = it != values.end() ? it->get() : nullptr; |
521 } | 520 } |
522 | 521 |
523 if (currentValue && currentValue->isCustomIdentValue()) { | 522 if (currentValue && currentValue->isCustomIdentValue()) { |
524 gridLineName = toCSSCustomIdentValue(currentValue)->value(); | 523 gridLineName = toCSSCustomIdentValue(currentValue)->value(); |
525 ++it; | 524 ++it; |
526 } | 525 } |
527 | 526 |
528 ASSERT(it == values.end()); | 527 ASSERT(it == values.end()); |
529 if (isSpanPosition) | 528 if (isSpanPosition) |
530 position.setSpanPosition(gridLineNumber, gridLineName); | 529 position.setSpanPosition(gridLineNumber, gridLineName); |
531 else | 530 else |
532 position.setExplicitPosition(gridLineNumber, gridLineName); | 531 position.setExplicitPosition(gridLineNumber, gridLineName); |
533 | 532 |
534 return position; | 533 return position; |
535 } | 534 } |
536 | 535 |
537 GridTrackSize StyleBuilderConverter::convertGridTrackSize(StyleResolverState& st
ate, const CSSValue& value) | 536 GridTrackSize StyleBuilderConverter::convertGridTrackSize(StyleResolverState& st
ate, const CSSValue& value) |
538 { | 537 { |
539 if (value.isPrimitiveValue()) | 538 if (value.isPrimitiveValue()) |
540 return GridTrackSize(convertGridTrackBreadth(state, toCSSPrimitiveValue(
value))); | 539 return GridTrackSize(convertGridTrackBreadth(state, value)); |
541 | 540 |
542 auto& function = toCSSFunctionValue(value); | 541 auto& function = toCSSFunctionValue(value); |
543 if (function.functionType() == CSSValueFitContent) { | 542 if (function.functionType() == CSSValueFitContent) { |
544 SECURITY_DCHECK(function.length() == 1); | 543 SECURITY_DCHECK(function.length() == 1); |
545 return GridTrackSize(convertGridTrackBreadth(state, toCSSPrimitiveValue(
function.item(0))), FitContentTrackSizing); | 544 return GridTrackSize(convertGridTrackBreadth(state, function.item(0)), F
itContentTrackSizing); |
546 } | 545 } |
547 | 546 |
548 SECURITY_DCHECK(function.length() == 2); | 547 SECURITY_DCHECK(function.length() == 2); |
549 GridLength minTrackBreadth(convertGridTrackBreadth(state, toCSSPrimitiveValu
e(function.item(0)))); | 548 GridLength minTrackBreadth(convertGridTrackBreadth(state, function.item(0)))
; |
550 GridLength maxTrackBreadth(convertGridTrackBreadth(state, toCSSPrimitiveValu
e(function.item(1)))); | 549 GridLength maxTrackBreadth(convertGridTrackBreadth(state, function.item(1)))
; |
551 return GridTrackSize(minTrackBreadth, maxTrackBreadth); | 550 return GridTrackSize(minTrackBreadth, maxTrackBreadth); |
552 } | 551 } |
553 | 552 |
554 static void convertGridLineNamesList(const CSSValue& value, size_t currentNamedG
ridLine, NamedGridLinesMap& namedGridLines, OrderedNamedGridLines& orderedNamedG
ridLines) | 553 static void convertGridLineNamesList(const CSSValue& value, size_t currentNamedG
ridLine, NamedGridLinesMap& namedGridLines, OrderedNamedGridLines& orderedNamedG
ridLines) |
555 { | 554 { |
556 ASSERT(value.isGridLineNamesValue()); | 555 ASSERT(value.isGridLineNamesValue()); |
557 | 556 |
558 for (auto& namedGridLineValue : toCSSValueList(value)) { | 557 for (auto& namedGridLineValue : toCSSValueList(value)) { |
559 String namedGridLine = toCSSCustomIdentValue(*namedGridLineValue).value(
); | 558 String namedGridLine = toCSSCustomIdentValue(*namedGridLineValue).value(
); |
560 NamedGridLinesMap::AddResult result = namedGridLines.add(namedGridLine,
Vector<size_t>()); | 559 NamedGridLinesMap::AddResult result = namedGridLines.add(namedGridLine,
Vector<size_t>()); |
(...skipping 10 matching lines...) Expand all Loading... |
571 for (auto& currValue : toCSSValueList(value)) { | 570 for (auto& currValue : toCSSValueList(value)) { |
572 DCHECK(!currValue->isGridLineNamesValue()); | 571 DCHECK(!currValue->isGridLineNamesValue()); |
573 DCHECK(!currValue->isGridAutoRepeatValue()); | 572 DCHECK(!currValue->isGridAutoRepeatValue()); |
574 trackSizes.append(convertGridTrackSize(state, *currValue)); | 573 trackSizes.append(convertGridTrackSize(state, *currValue)); |
575 } | 574 } |
576 return trackSizes; | 575 return trackSizes; |
577 } | 576 } |
578 | 577 |
579 void StyleBuilderConverter::convertGridTrackList(const CSSValue& value, Vector<G
ridTrackSize>& trackSizes, NamedGridLinesMap& namedGridLines, OrderedNamedGridLi
nes& orderedNamedGridLines, Vector<GridTrackSize>& autoRepeatTrackSizes, NamedGr
idLinesMap& autoRepeatNamedGridLines, OrderedNamedGridLines& autoRepeatOrderedNa
medGridLines, size_t& autoRepeatInsertionPoint, AutoRepeatType &autoRepeatType,
StyleResolverState& state) | 578 void StyleBuilderConverter::convertGridTrackList(const CSSValue& value, Vector<G
ridTrackSize>& trackSizes, NamedGridLinesMap& namedGridLines, OrderedNamedGridLi
nes& orderedNamedGridLines, Vector<GridTrackSize>& autoRepeatTrackSizes, NamedGr
idLinesMap& autoRepeatNamedGridLines, OrderedNamedGridLines& autoRepeatOrderedNa
medGridLines, size_t& autoRepeatInsertionPoint, AutoRepeatType &autoRepeatType,
StyleResolverState& state) |
580 { | 579 { |
581 if (value.isPrimitiveValue()) { | 580 if (value.isIdentifierValue()) { |
582 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNone); | 581 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); |
583 return; | 582 return; |
584 } | 583 } |
585 | 584 |
586 size_t currentNamedGridLine = 0; | 585 size_t currentNamedGridLine = 0; |
587 for (auto currValue : toCSSValueList(value)) { | 586 for (auto currValue : toCSSValueList(value)) { |
588 if (currValue->isGridLineNamesValue()) { | 587 if (currValue->isGridLineNamesValue()) { |
589 convertGridLineNamesList(*currValue, currentNamedGridLine, namedGrid
Lines, orderedNamedGridLines); | 588 convertGridLineNamesList(*currValue, currentNamedGridLine, namedGrid
Lines, orderedNamedGridLines); |
590 continue; | 589 continue; |
591 } | 590 } |
592 | 591 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 return toCSSPrimitiveValue(value).convertToLength(state.cssToLengthConversio
nData()); | 658 return toCSSPrimitiveValue(value).convertToLength(state.cssToLengthConversio
nData()); |
660 } | 659 } |
661 | 660 |
662 UnzoomedLength StyleBuilderConverter::convertUnzoomedLength(const StyleResolverS
tate& state, const CSSValue& value) | 661 UnzoomedLength StyleBuilderConverter::convertUnzoomedLength(const StyleResolverS
tate& state, const CSSValue& value) |
663 { | 662 { |
664 return UnzoomedLength(toCSSPrimitiveValue(value).convertToLength(state.cssTo
LengthConversionData().copyWithAdjustedZoom(1.0f))); | 663 return UnzoomedLength(toCSSPrimitiveValue(value).convertToLength(state.cssTo
LengthConversionData().copyWithAdjustedZoom(1.0f))); |
665 } | 664 } |
666 | 665 |
667 Length StyleBuilderConverter::convertLengthOrAuto(const StyleResolverState& stat
e, const CSSValue& value) | 666 Length StyleBuilderConverter::convertLengthOrAuto(const StyleResolverState& stat
e, const CSSValue& value) |
668 { | 667 { |
669 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 668 if (value.isIdentifierValue() && toCSSIdentifierValue(value).getValueID() ==
CSSValueAuto) |
670 if (primitiveValue.getValueID() == CSSValueAuto) | |
671 return Length(Auto); | 669 return Length(Auto); |
672 return primitiveValue.convertToLength(state.cssToLengthConversionData()); | 670 return toCSSPrimitiveValue(value).convertToLength(state.cssToLengthConversio
nData()); |
673 } | 671 } |
674 | 672 |
675 Length StyleBuilderConverter::convertLengthSizing(StyleResolverState& state, con
st CSSValue& value) | 673 Length StyleBuilderConverter::convertLengthSizing(StyleResolverState& state, con
st CSSValue& value) |
676 { | 674 { |
677 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 675 if (!value.isIdentifierValue()) |
678 switch (primitiveValue.getValueID()) { | |
679 case CSSValueInvalid: | |
680 return convertLength(state, value); | 676 return convertLength(state, value); |
| 677 |
| 678 const CSSIdentifierValue& identifierValue = toCSSIdentifierValue(value); |
| 679 switch (identifierValue.getValueID()) { |
681 case CSSValueMinContent: | 680 case CSSValueMinContent: |
682 case CSSValueWebkitMinContent: | 681 case CSSValueWebkitMinContent: |
683 return Length(MinContent); | 682 return Length(MinContent); |
684 case CSSValueMaxContent: | 683 case CSSValueMaxContent: |
685 case CSSValueWebkitMaxContent: | 684 case CSSValueWebkitMaxContent: |
686 return Length(MaxContent); | 685 return Length(MaxContent); |
687 case CSSValueWebkitFillAvailable: | 686 case CSSValueWebkitFillAvailable: |
688 return Length(FillAvailable); | 687 return Length(FillAvailable); |
689 case CSSValueWebkitFitContent: | 688 case CSSValueWebkitFitContent: |
690 case CSSValueFitContent: | 689 case CSSValueFitContent: |
691 return Length(FitContent); | 690 return Length(FitContent); |
692 case CSSValueAuto: | 691 case CSSValueAuto: |
693 return Length(Auto); | 692 return Length(Auto); |
694 default: | 693 default: |
695 ASSERT_NOT_REACHED(); | 694 ASSERT_NOT_REACHED(); |
696 return Length(); | 695 return Length(); |
697 } | 696 } |
698 } | 697 } |
699 | 698 |
700 Length StyleBuilderConverter::convertLengthMaxSizing(StyleResolverState& state,
const CSSValue& value) | 699 Length StyleBuilderConverter::convertLengthMaxSizing(StyleResolverState& state,
const CSSValue& value) |
701 { | 700 { |
702 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 701 if (value.isIdentifierValue() && toCSSIdentifierValue(value).getValueID() ==
CSSValueNone) |
703 if (primitiveValue.getValueID() == CSSValueNone) | |
704 return Length(MaxSizeNone); | 702 return Length(MaxSizeNone); |
705 return convertLengthSizing(state, value); | 703 return convertLengthSizing(state, value); |
706 } | 704 } |
707 | 705 |
708 TabSize StyleBuilderConverter::convertLengthOrTabSpaces(StyleResolverState& stat
e, const CSSValue& value) | 706 TabSize StyleBuilderConverter::convertLengthOrTabSpaces(StyleResolverState& stat
e, const CSSValue& value) |
709 { | 707 { |
710 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 708 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
711 if (primitiveValue.isNumber()) | 709 if (primitiveValue.isNumber()) |
712 return TabSize(primitiveValue.getIntValue()); | 710 return TabSize(primitiveValue.getIntValue()); |
713 return TabSize(primitiveValue.computeLength<float>(state.cssToLengthConversi
onData())); | 711 return TabSize(primitiveValue.computeLength<float>(state.cssToLengthConversi
onData())); |
714 } | 712 } |
715 | 713 |
716 static CSSToLengthConversionData lineHeightToLengthConversionData(StyleResolverS
tate& state) | 714 static CSSToLengthConversionData lineHeightToLengthConversionData(StyleResolverS
tate& state) |
717 { | 715 { |
718 float multiplier = state.style()->effectiveZoom(); | 716 float multiplier = state.style()->effectiveZoom(); |
719 if (LocalFrame* frame = state.document().frame()) | 717 if (LocalFrame* frame = state.document().frame()) |
720 multiplier *= frame->textZoomFactor(); | 718 multiplier *= frame->textZoomFactor(); |
721 return state.cssToLengthConversionData().copyWithAdjustedZoom(multiplier); | 719 return state.cssToLengthConversionData().copyWithAdjustedZoom(multiplier); |
722 } | 720 } |
723 | 721 |
724 Length StyleBuilderConverter::convertLineHeight(StyleResolverState& state, const
CSSValue& value) | 722 Length StyleBuilderConverter::convertLineHeight(StyleResolverState& state, const
CSSValue& value) |
725 { | 723 { |
726 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 724 if (value.isPrimitiveValue()) { |
727 | 725 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
728 if (primitiveValue.isLength()) | 726 if (primitiveValue.isLength()) |
729 return primitiveValue.computeLength<Length>(lineHeightToLengthConversion
Data(state)); | 727 return primitiveValue.computeLength<Length>(lineHeightToLengthConver
sionData(state)); |
730 if (primitiveValue.isPercentage()) | 728 if (primitiveValue.isPercentage()) |
731 return Length((state.style()->computedFontSize() * primitiveValue.getInt
Value()) / 100.0, Fixed); | 729 return Length((state.style()->computedFontSize() * primitiveValue.ge
tIntValue()) / 100.0, Fixed); |
732 if (primitiveValue.isNumber()) | 730 if (primitiveValue.isNumber()) |
733 return Length(primitiveValue.getDoubleValue() * 100.0, Percent); | 731 return Length(primitiveValue.getDoubleValue() * 100.0, Percent); |
734 if (primitiveValue.isCalculated()) { | 732 if (primitiveValue.isCalculated()) { |
735 Length zoomedLength = Length(primitiveValue.cssCalcValue()->toCalcValue(
lineHeightToLengthConversionData(state))); | 733 Length zoomedLength = Length(primitiveValue.cssCalcValue()->toCalcVa
lue(lineHeightToLengthConversionData(state))); |
736 return Length(valueForLength(zoomedLength, LayoutUnit(state.style()->com
putedFontSize())), Fixed); | 734 return Length(valueForLength(zoomedLength, LayoutUnit(state.style()-
>computedFontSize())), Fixed); |
| 735 } |
737 } | 736 } |
738 | 737 |
739 ASSERT(primitiveValue.getValueID() == CSSValueNormal); | 738 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNormal); |
740 return ComputedStyle::initialLineHeight(); | 739 return ComputedStyle::initialLineHeight(); |
741 } | 740 } |
742 | 741 |
743 float StyleBuilderConverter::convertNumberOrPercentage(StyleResolverState& state
, const CSSValue& value) | 742 float StyleBuilderConverter::convertNumberOrPercentage(StyleResolverState& state
, const CSSValue& value) |
744 { | 743 { |
745 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 744 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
746 ASSERT(primitiveValue.isNumber() || primitiveValue.isPercentage()); | 745 ASSERT(primitiveValue.isNumber() || primitiveValue.isPercentage()); |
747 if (primitiveValue.isNumber()) | 746 if (primitiveValue.isNumber()) |
748 return primitiveValue.getFloatValue(); | 747 return primitiveValue.getFloatValue(); |
749 return primitiveValue.getFloatValue() / 100.0f; | 748 return primitiveValue.getFloatValue() / 100.0f; |
750 } | 749 } |
751 | 750 |
752 StyleMotionRotation StyleBuilderConverter::convertMotionRotation(StyleResolverSt
ate&, const CSSValue& value) | 751 StyleMotionRotation StyleBuilderConverter::convertMotionRotation(StyleResolverSt
ate&, const CSSValue& value) |
753 { | 752 { |
754 return convertMotionRotation(value); | 753 return convertMotionRotation(value); |
755 } | 754 } |
756 | 755 |
757 StyleMotionRotation StyleBuilderConverter::convertMotionRotation(const CSSValue&
value) | 756 StyleMotionRotation StyleBuilderConverter::convertMotionRotation(const CSSValue&
value) |
758 { | 757 { |
759 StyleMotionRotation result(0, MotionRotationFixed); | 758 StyleMotionRotation result(0, MotionRotationFixed); |
760 | 759 |
761 const CSSValueList& list = toCSSValueList(value); | 760 const CSSValueList& list = toCSSValueList(value); |
762 ASSERT(list.length() == 1 || list.length() == 2); | 761 ASSERT(list.length() == 1 || list.length() == 2); |
763 for (const auto& item : list) { | 762 for (const auto& item : list) { |
764 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(*item); | 763 if (item->isIdentifierValue() && toCSSIdentifierValue(*item).getValueID(
) == CSSValueAuto) { |
765 if (primitiveValue.getValueID() == CSSValueAuto) { | |
766 result.type = MotionRotationAuto; | 764 result.type = MotionRotationAuto; |
767 } else if (primitiveValue.getValueID() == CSSValueReverse) { | 765 } else if (item->isIdentifierValue() && toCSSIdentifierValue(*item).getV
alueID() == CSSValueReverse) { |
768 result.type = MotionRotationAuto; | 766 result.type = MotionRotationAuto; |
769 result.angle += 180; | 767 result.angle += 180; |
770 } else { | 768 } else { |
| 769 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(*item)
; |
771 result.angle += primitiveValue.computeDegrees(); | 770 result.angle += primitiveValue.computeDegrees(); |
772 } | 771 } |
773 } | 772 } |
774 result.angle = clampTo<float>(result.angle); | 773 result.angle = clampTo<float>(result.angle); |
775 | 774 |
776 return result; | 775 return result; |
777 } | 776 } |
778 | 777 |
779 template <CSSValueID cssValueFor0, CSSValueID cssValueFor100> | 778 template <CSSValueID cssValueFor0, CSSValueID cssValueFor100> |
780 Length StyleBuilderConverter::convertPositionLength(StyleResolverState& state, c
onst CSSValue& value) | 779 Length StyleBuilderConverter::convertPositionLength(StyleResolverState& state, c
onst CSSValue& value) |
781 { | 780 { |
782 if (value.isValuePair()) { | 781 if (value.isValuePair()) { |
783 const CSSValuePair& pair = toCSSValuePair(value); | 782 const CSSValuePair& pair = toCSSValuePair(value); |
784 Length length = StyleBuilderConverter::convertLength(state, pair.second(
)); | 783 Length length = StyleBuilderConverter::convertLength(state, pair.second(
)); |
785 if (toCSSPrimitiveValue(pair.first()).getValueID() == cssValueFor0) | 784 if (toCSSIdentifierValue(pair.first()).getValueID() == cssValueFor0) |
786 return length; | 785 return length; |
787 ASSERT(toCSSPrimitiveValue(pair.first()).getValueID() == cssValueFor100)
; | 786 DCHECK_EQ(toCSSIdentifierValue(pair.first()).getValueID(), cssValueFor10
0); |
788 return length.subtractFromOneHundredPercent(); | 787 return length.subtractFromOneHundredPercent(); |
789 } | 788 } |
790 | 789 |
791 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 790 if (value.isIdentifierValue()) { |
792 if (primitiveValue.isValueID()) { | 791 switch (toCSSIdentifierValue(value).getValueID()) { |
793 switch (primitiveValue.getValueID()) { | |
794 case cssValueFor0: | 792 case cssValueFor0: |
795 return Length(0, Percent); | 793 return Length(0, Percent); |
796 case cssValueFor100: | 794 case cssValueFor100: |
797 return Length(100, Percent); | 795 return Length(100, Percent); |
798 case CSSValueCenter: | 796 case CSSValueCenter: |
799 return Length(50, Percent); | 797 return Length(50, Percent); |
800 default: | 798 default: |
801 ASSERT_NOT_REACHED(); | 799 ASSERT_NOT_REACHED(); |
802 } | 800 } |
803 } | 801 } |
804 | 802 |
805 return StyleBuilderConverter::convertLength(state, primitiveValue); | 803 return StyleBuilderConverter::convertLength(state, toCSSPrimitiveValue(value
)); |
806 } | 804 } |
807 | 805 |
808 LengthPoint StyleBuilderConverter::convertPosition(StyleResolverState& state, co
nst CSSValue& value) | 806 LengthPoint StyleBuilderConverter::convertPosition(StyleResolverState& state, co
nst CSSValue& value) |
809 { | 807 { |
810 const CSSValuePair& pair = toCSSValuePair(value); | 808 const CSSValuePair& pair = toCSSValuePair(value); |
811 return LengthPoint( | 809 return LengthPoint( |
812 convertPositionLength<CSSValueLeft, CSSValueRight>(state, pair.first()), | 810 convertPositionLength<CSSValueLeft, CSSValueRight>(state, pair.first()), |
813 convertPositionLength<CSSValueTop, CSSValueBottom>(state, pair.second()) | 811 convertPositionLength<CSSValueTop, CSSValueBottom>(state, pair.second()) |
814 ); | 812 ); |
815 } | 813 } |
816 | 814 |
817 static float convertPerspectiveLength(StyleResolverState& state, const CSSPrimit
iveValue& primitiveValue) | 815 static float convertPerspectiveLength(StyleResolverState& state, const CSSPrimit
iveValue& primitiveValue) |
818 { | 816 { |
819 return std::max(primitiveValue.computeLength<float>(state.cssToLengthConvers
ionData()), 0.0f); | 817 return std::max(primitiveValue.computeLength<float>(state.cssToLengthConvers
ionData()), 0.0f); |
820 } | 818 } |
821 | 819 |
822 float StyleBuilderConverter::convertPerspective(StyleResolverState& state, const
CSSValue& value) | 820 float StyleBuilderConverter::convertPerspective(StyleResolverState& state, const
CSSValue& value) |
823 { | 821 { |
824 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 822 if (value.isIdentifierValue() && toCSSIdentifierValue(value).getValueID() ==
CSSValueNone) |
825 | |
826 if (primitiveValue.getValueID() == CSSValueNone) | |
827 return ComputedStyle::initialPerspective(); | 823 return ComputedStyle::initialPerspective(); |
828 return convertPerspectiveLength(state, primitiveValue); | 824 return convertPerspectiveLength(state, toCSSPrimitiveValue(value)); |
829 } | 825 } |
830 | 826 |
831 EPaintOrder StyleBuilderConverter::convertPaintOrder(StyleResolverState&, const
CSSValue& cssPaintOrder) | 827 EPaintOrder StyleBuilderConverter::convertPaintOrder(StyleResolverState&, const
CSSValue& cssPaintOrder) |
832 { | 828 { |
833 if (cssPaintOrder.isValueList()) { | 829 if (cssPaintOrder.isValueList()) { |
834 const CSSValueList& orderTypeList = toCSSValueList(cssPaintOrder); | 830 const CSSValueList& orderTypeList = toCSSValueList(cssPaintOrder); |
835 switch (toCSSPrimitiveValue(orderTypeList.item(0)).getValueID()) { | 831 switch (toCSSIdentifierValue(orderTypeList.item(0)).getValueID()) { |
836 case CSSValueFill: | 832 case CSSValueFill: |
837 return orderTypeList.length() > 1 ? PaintOrderFillMarkersStroke : Pa
intOrderFillStrokeMarkers; | 833 return orderTypeList.length() > 1 ? PaintOrderFillMarkersStroke : Pa
intOrderFillStrokeMarkers; |
838 case CSSValueStroke: | 834 case CSSValueStroke: |
839 return orderTypeList.length() > 1 ? PaintOrderStrokeMarkersFill : Pa
intOrderStrokeFillMarkers; | 835 return orderTypeList.length() > 1 ? PaintOrderStrokeMarkersFill : Pa
intOrderStrokeFillMarkers; |
840 case CSSValueMarkers: | 836 case CSSValueMarkers: |
841 return orderTypeList.length() > 1 ? PaintOrderMarkersStrokeFill : Pa
intOrderMarkersFillStroke; | 837 return orderTypeList.length() > 1 ? PaintOrderMarkersStrokeFill : Pa
intOrderMarkersFillStroke; |
842 default: | 838 default: |
843 ASSERT_NOT_REACHED(); | 839 ASSERT_NOT_REACHED(); |
844 return PaintOrderNormal; | 840 return PaintOrderNormal; |
845 } | 841 } |
846 } | 842 } |
847 | 843 |
848 return PaintOrderNormal; | 844 return PaintOrderNormal; |
849 } | 845 } |
850 | 846 |
851 Length StyleBuilderConverter::convertQuirkyLength(StyleResolverState& state, con
st CSSValue& value) | 847 Length StyleBuilderConverter::convertQuirkyLength(StyleResolverState& state, con
st CSSValue& value) |
852 { | 848 { |
853 Length length = convertLengthOrAuto(state, value); | 849 Length length = convertLengthOrAuto(state, value); |
854 // This is only for margins which use __qem | 850 // This is only for margins which use __qem |
855 length.setQuirk(toCSSPrimitiveValue(value).isQuirkyEms()); | 851 length.setQuirk(value.isPrimitiveValue() && toCSSPrimitiveValue(value).isQui
rkyEms()); |
856 return length; | 852 return length; |
857 } | 853 } |
858 | 854 |
859 PassRefPtr<QuotesData> StyleBuilderConverter::convertQuotes(StyleResolverState&,
const CSSValue& value) | 855 PassRefPtr<QuotesData> StyleBuilderConverter::convertQuotes(StyleResolverState&,
const CSSValue& value) |
860 { | 856 { |
861 if (value.isValueList()) { | 857 if (value.isValueList()) { |
862 const CSSValueList& list = toCSSValueList(value); | 858 const CSSValueList& list = toCSSValueList(value); |
863 RefPtr<QuotesData> quotes = QuotesData::create(); | 859 RefPtr<QuotesData> quotes = QuotesData::create(); |
864 for (size_t i = 0; i < list.length(); i += 2) { | 860 for (size_t i = 0; i < list.length(); i += 2) { |
865 String startQuote = toCSSStringValue(list.item(i)).value(); | 861 String startQuote = toCSSStringValue(list.item(i)).value(); |
866 String endQuote = toCSSStringValue(list.item(i + 1)).value(); | 862 String endQuote = toCSSStringValue(list.item(i + 1)).value(); |
867 quotes->addPair(std::make_pair(startQuote, endQuote)); | 863 quotes->addPair(std::make_pair(startQuote, endQuote)); |
868 } | 864 } |
869 return quotes.release(); | 865 return quotes.release(); |
870 } | 866 } |
871 ASSERT(value.isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID() =
= CSSValueNone); | 867 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); |
872 return QuotesData::create(); | 868 return QuotesData::create(); |
873 } | 869 } |
874 | 870 |
875 LengthSize StyleBuilderConverter::convertRadius(StyleResolverState& state, const
CSSValue& value) | 871 LengthSize StyleBuilderConverter::convertRadius(StyleResolverState& state, const
CSSValue& value) |
876 { | 872 { |
877 const CSSValuePair& pair = toCSSValuePair(value); | 873 const CSSValuePair& pair = toCSSValuePair(value); |
878 Length radiusWidth = toCSSPrimitiveValue(pair.first()).convertToLength(state
.cssToLengthConversionData()); | 874 Length radiusWidth = toCSSPrimitiveValue(pair.first()).convertToLength(state
.cssToLengthConversionData()); |
879 Length radiusHeight = toCSSPrimitiveValue(pair.second()).convertToLength(sta
te.cssToLengthConversionData()); | 875 Length radiusHeight = toCSSPrimitiveValue(pair.second()).convertToLength(sta
te.cssToLengthConversionData()); |
880 return LengthSize(radiusWidth, radiusHeight); | 876 return LengthSize(radiusWidth, radiusHeight); |
881 } | 877 } |
882 | 878 |
883 PassRefPtr<ShadowList> StyleBuilderConverter::convertShadow(StyleResolverState&
state, const CSSValue& value) | 879 PassRefPtr<ShadowList> StyleBuilderConverter::convertShadow(StyleResolverState&
state, const CSSValue& value) |
884 { | 880 { |
885 if (value.isPrimitiveValue()) { | 881 if (value.isIdentifierValue()) { |
886 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNone); | 882 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); |
887 return PassRefPtr<ShadowList>(); | 883 return PassRefPtr<ShadowList>(); |
888 } | 884 } |
889 | 885 |
890 const CSSValueList& valueList = toCSSValueList(value); | 886 const CSSValueList& valueList = toCSSValueList(value); |
891 size_t shadowCount = valueList.length(); | 887 size_t shadowCount = valueList.length(); |
892 ShadowDataVector shadows; | 888 ShadowDataVector shadows; |
893 for (size_t i = 0; i < shadowCount; ++i) { | 889 for (size_t i = 0; i < shadowCount; ++i) { |
894 const CSSShadowValue& item = toCSSShadowValue(valueList.item(i)); | 890 const CSSShadowValue& item = toCSSShadowValue(valueList.item(i)); |
895 float x = item.x->computeLength<float>(state.cssToLengthConversionData()
); | 891 float x = item.x->computeLength<float>(state.cssToLengthConversionData()
); |
896 float y = item.y->computeLength<float>(state.cssToLengthConversionData()
); | 892 float y = item.y->computeLength<float>(state.cssToLengthConversionData()
); |
897 float blur = item.blur ? item.blur->computeLength<float>(state.cssToLeng
thConversionData()) : 0; | 893 float blur = item.blur ? item.blur->computeLength<float>(state.cssToLeng
thConversionData()) : 0; |
898 float spread = item.spread ? item.spread->computeLength<float>(state.css
ToLengthConversionData()) : 0; | 894 float spread = item.spread ? item.spread->computeLength<float>(state.css
ToLengthConversionData()) : 0; |
899 ShadowStyle shadowStyle = item.style && item.style->getValueID() == CSSV
alueInset ? Inset : Normal; | 895 ShadowStyle shadowStyle = item.style && item.style->getValueID() == CSSV
alueInset ? Inset : Normal; |
900 StyleColor color = StyleColor::currentColor(); | 896 StyleColor color = StyleColor::currentColor(); |
901 if (item.color) | 897 if (item.color) |
902 color = convertStyleColor(state, *item.color); | 898 color = convertStyleColor(state, *item.color); |
903 shadows.append(ShadowData(FloatPoint(x, y), blur, spread, shadowStyle, c
olor)); | 899 shadows.append(ShadowData(FloatPoint(x, y), blur, spread, shadowStyle, c
olor)); |
904 } | 900 } |
905 return ShadowList::adopt(shadows); | 901 return ShadowList::adopt(shadows); |
906 } | 902 } |
907 | 903 |
908 ShapeValue* StyleBuilderConverter::convertShapeValue(StyleResolverState& state,
const CSSValue& value) | 904 ShapeValue* StyleBuilderConverter::convertShapeValue(StyleResolverState& state,
const CSSValue& value) |
909 { | 905 { |
910 if (value.isPrimitiveValue()) { | 906 if (value.isIdentifierValue()) { |
911 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNone); | 907 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); |
912 return nullptr; | 908 return nullptr; |
913 } | 909 } |
914 | 910 |
915 if (value.isImageValue() || value.isImageGeneratorValue() || value.isImageSe
tValue()) | 911 if (value.isImageValue() || value.isImageGeneratorValue() || value.isImageSe
tValue()) |
916 return ShapeValue::createImageValue(state.styleImage(CSSPropertyShapeOut
side, value)); | 912 return ShapeValue::createImageValue(state.styleImage(CSSPropertyShapeOut
side, value)); |
917 | 913 |
918 RefPtr<BasicShape> shape; | 914 RefPtr<BasicShape> shape; |
919 CSSBoxType cssBox = BoxMissing; | 915 CSSBoxType cssBox = BoxMissing; |
920 const CSSValueList& valueList = toCSSValueList(value); | 916 const CSSValueList& valueList = toCSSValueList(value); |
921 for (unsigned i = 0; i < valueList.length(); ++i) { | 917 for (unsigned i = 0; i < valueList.length(); ++i) { |
922 const CSSValue& value = valueList.item(i); | 918 const CSSValue& value = valueList.item(i); |
923 if (value.isBasicShapeValue()) { | 919 if (value.isBasicShapeValue()) { |
924 shape = basicShapeForValue(state, value); | 920 shape = basicShapeForValue(state, value); |
925 } else { | 921 } else { |
926 cssBox = toCSSPrimitiveValue(value).convertTo<CSSBoxType>(); | 922 cssBox = toCSSIdentifierValue(value).convertTo<CSSBoxType>(); |
927 } | 923 } |
928 } | 924 } |
929 | 925 |
930 if (shape) | 926 if (shape) |
931 return ShapeValue::createShapeValue(shape.release(), cssBox); | 927 return ShapeValue::createShapeValue(shape.release(), cssBox); |
932 | 928 |
933 ASSERT(cssBox != BoxMissing); | 929 ASSERT(cssBox != BoxMissing); |
934 return ShapeValue::createBoxShapeValue(cssBox); | 930 return ShapeValue::createBoxShapeValue(cssBox); |
935 } | 931 } |
936 | 932 |
937 float StyleBuilderConverter::convertSpacing(StyleResolverState& state, const CSS
Value& value) | 933 float StyleBuilderConverter::convertSpacing(StyleResolverState& state, const CSS
Value& value) |
938 { | 934 { |
939 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 935 if (value.isIdentifierValue() && toCSSIdentifierValue(value).getValueID() ==
CSSValueNormal) |
940 if (primitiveValue.getValueID() == CSSValueNormal) | |
941 return 0; | 936 return 0; |
942 return primitiveValue.computeLength<float>(state.cssToLengthConversionData()
); | 937 return toCSSPrimitiveValue(value).computeLength<float>(state.cssToLengthConv
ersionData()); |
943 } | 938 } |
944 | 939 |
945 PassRefPtr<SVGDashArray> StyleBuilderConverter::convertStrokeDasharray(StyleReso
lverState& state, const CSSValue& value) | 940 PassRefPtr<SVGDashArray> StyleBuilderConverter::convertStrokeDasharray(StyleReso
lverState& state, const CSSValue& value) |
946 { | 941 { |
947 if (!value.isValueList()) | 942 if (!value.isValueList()) |
948 return SVGComputedStyle::initialStrokeDashArray(); | 943 return SVGComputedStyle::initialStrokeDashArray(); |
949 | 944 |
950 const CSSValueList& dashes = toCSSValueList(value); | 945 const CSSValueList& dashes = toCSSValueList(value); |
951 | 946 |
952 RefPtr<SVGDashArray> array = SVGDashArray::create(); | 947 RefPtr<SVGDashArray> array = SVGDashArray::create(); |
953 size_t length = dashes.length(); | 948 size_t length = dashes.length(); |
954 for (size_t i = 0; i < length; ++i) { | 949 for (size_t i = 0; i < length; ++i) { |
955 array->append(convertLength(state, toCSSPrimitiveValue(dashes.item(i))))
; | 950 array->append(convertLength(state, toCSSPrimitiveValue(dashes.item(i))))
; |
956 } | 951 } |
957 | 952 |
958 return array.release(); | 953 return array.release(); |
959 } | 954 } |
960 | 955 |
961 StyleColor StyleBuilderConverter::convertStyleColor(StyleResolverState& state, c
onst CSSValue& value, bool forVisitedLink) | 956 StyleColor StyleBuilderConverter::convertStyleColor(StyleResolverState& state, c
onst CSSValue& value, bool forVisitedLink) |
962 { | 957 { |
963 if (value.isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID() == C
SSValueCurrentcolor) | 958 if (value.isIdentifierValue() && toCSSIdentifierValue(value).getValueID() ==
CSSValueCurrentcolor) |
964 return StyleColor::currentColor(); | 959 return StyleColor::currentColor(); |
965 return state.document().textLinkColors().colorFromCSSValue(value, Color(), f
orVisitedLink); | 960 return state.document().textLinkColors().colorFromCSSValue(value, Color(), f
orVisitedLink); |
966 } | 961 } |
967 | 962 |
968 float StyleBuilderConverter::convertTextStrokeWidth(StyleResolverState& state, c
onst CSSValue& value) | 963 float StyleBuilderConverter::convertTextStrokeWidth(StyleResolverState& state, c
onst CSSValue& value) |
969 { | 964 { |
970 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 965 if (value.isIdentifierValue() && toCSSIdentifierValue(value).getValueID()) { |
971 if (primitiveValue.getValueID()) { | |
972 float multiplier = convertLineWidth<float>(state, value); | 966 float multiplier = convertLineWidth<float>(state, value); |
973 return CSSPrimitiveValue::create(multiplier / 48, CSSPrimitiveValue::Uni
tType::Ems)->computeLength<float>(state.cssToLengthConversionData()); | 967 return CSSPrimitiveValue::create(multiplier / 48, CSSPrimitiveValue::Uni
tType::Ems)->computeLength<float>(state.cssToLengthConversionData()); |
974 } | 968 } |
975 return primitiveValue.computeLength<float>(state.cssToLengthConversionData()
); | 969 return toCSSPrimitiveValue(value).computeLength<float>(state.cssToLengthConv
ersionData()); |
976 } | 970 } |
977 | 971 |
978 TextSizeAdjust StyleBuilderConverter::convertTextSizeAdjust(StyleResolverState&
state, const CSSValue& value) | 972 TextSizeAdjust StyleBuilderConverter::convertTextSizeAdjust(StyleResolverState&
state, const CSSValue& value) |
979 { | 973 { |
| 974 if (value.isIdentifierValue() && toCSSIdentifierValue(value).getValueID() ==
CSSValueNone) |
| 975 return TextSizeAdjust::adjustNone(); |
| 976 if (value.isIdentifierValue() && toCSSIdentifierValue(value).getValueID() ==
CSSValueAuto) |
| 977 return TextSizeAdjust::adjustAuto(); |
980 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 978 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
981 if (primitiveValue.getValueID() == CSSValueNone) | |
982 return TextSizeAdjust::adjustNone(); | |
983 if (primitiveValue.getValueID() == CSSValueAuto) | |
984 return TextSizeAdjust::adjustAuto(); | |
985 DCHECK(primitiveValue.isPercentage()); | 979 DCHECK(primitiveValue.isPercentage()); |
986 return TextSizeAdjust(primitiveValue.getFloatValue() / 100.0f); | 980 return TextSizeAdjust(primitiveValue.getFloatValue() / 100.0f); |
987 } | 981 } |
988 | 982 |
989 TransformOrigin StyleBuilderConverter::convertTransformOrigin(StyleResolverState
& state, const CSSValue& value) | 983 TransformOrigin StyleBuilderConverter::convertTransformOrigin(StyleResolverState
& state, const CSSValue& value) |
990 { | 984 { |
991 const CSSValueList& list = toCSSValueList(value); | 985 const CSSValueList& list = toCSSValueList(value); |
992 ASSERT(list.length() == 3); | 986 DCHECK_EQ(list.length(), 3U); |
993 | 987 DCHECK(list.item(0).isPrimitiveValue() || list.item(0).isIdentifierValue()); |
994 const CSSPrimitiveValue& primitiveValueX = toCSSPrimitiveValue(list.item(0))
; | 988 DCHECK(list.item(1).isPrimitiveValue() || list.item(1).isIdentifierValue()); |
995 const CSSPrimitiveValue& primitiveValueY = toCSSPrimitiveValue(list.item(1))
; | 989 DCHECK(list.item(2).isPrimitiveValue()); |
996 const CSSPrimitiveValue& primitiveValueZ = toCSSPrimitiveValue(list.item(2))
; | |
997 | 990 |
998 return TransformOrigin( | 991 return TransformOrigin( |
999 convertPositionLength<CSSValueLeft, CSSValueRight>(state, primitiveValue
X), | 992 convertPositionLength<CSSValueLeft, CSSValueRight>(state, list.item(0)), |
1000 convertPositionLength<CSSValueTop, CSSValueBottom>(state, primitiveValue
Y), | 993 convertPositionLength<CSSValueTop, CSSValueBottom>(state, list.item(1)), |
1001 StyleBuilderConverter::convertComputedLength<float>(state, primitiveValu
eZ) | 994 StyleBuilderConverter::convertComputedLength<float>(state, list.item(2)) |
1002 ); | 995 ); |
1003 } | 996 } |
1004 | 997 |
1005 ScrollSnapPoints StyleBuilderConverter::convertSnapPoints(StyleResolverState& st
ate, const CSSValue& value) | 998 ScrollSnapPoints StyleBuilderConverter::convertSnapPoints(StyleResolverState& st
ate, const CSSValue& value) |
1006 { | 999 { |
1007 // Handles: none | repeat(<length>) | 1000 // Handles: none | repeat(<length>) |
1008 ScrollSnapPoints points; | 1001 ScrollSnapPoints points; |
1009 points.hasRepeat = false; | 1002 points.hasRepeat = false; |
1010 | 1003 |
1011 if (!value.isFunctionValue()) | 1004 if (!value.isFunctionValue()) |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1082 if (list.length() >= 2) | 1075 if (list.length() >= 2) |
1083 sy = toCSSPrimitiveValue(list.item(1)).getDoubleValue(); | 1076 sy = toCSSPrimitiveValue(list.item(1)).getDoubleValue(); |
1084 if (list.length() == 3) | 1077 if (list.length() == 3) |
1085 sz = toCSSPrimitiveValue(list.item(2)).getDoubleValue(); | 1078 sz = toCSSPrimitiveValue(list.item(2)).getDoubleValue(); |
1086 | 1079 |
1087 return ScaleTransformOperation::create(sx, sy, sz, TransformOperation::Scale
3D); | 1080 return ScaleTransformOperation::create(sx, sy, sz, TransformOperation::Scale
3D); |
1088 } | 1081 } |
1089 | 1082 |
1090 RespectImageOrientationEnum StyleBuilderConverter::convertImageOrientation(Style
ResolverState& state, const CSSValue& value) | 1083 RespectImageOrientationEnum StyleBuilderConverter::convertImageOrientation(Style
ResolverState& state, const CSSValue& value) |
1091 { | 1084 { |
1092 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 1085 return value.isIdentifierValue() && toCSSIdentifierValue(value).getValueID()
== CSSValueFromImage ? RespectImageOrientation : DoNotRespectImageOrientation; |
1093 return primitiveValue.getValueID() == CSSValueFromImage ? RespectImageOrient
ation : DoNotRespectImageOrientation; | |
1094 } | 1086 } |
1095 | 1087 |
1096 PassRefPtr<StylePath> StyleBuilderConverter::convertPathOrNone(StyleResolverStat
e& state, const CSSValue& value) | 1088 PassRefPtr<StylePath> StyleBuilderConverter::convertPathOrNone(StyleResolverStat
e& state, const CSSValue& value) |
1097 { | 1089 { |
1098 if (value.isPathValue()) | 1090 if (value.isPathValue()) |
1099 return toCSSPathValue(value).stylePath(); | 1091 return toCSSPathValue(value).stylePath(); |
1100 ASSERT(value.isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID() =
= CSSValueNone); | 1092 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); |
1101 return nullptr; | 1093 return nullptr; |
1102 } | 1094 } |
1103 | 1095 |
1104 const CSSValue& StyleBuilderConverter::convertRegisteredPropertyValue(const Styl
eResolverState& state, const CSSValue& value) | 1096 const CSSValue& StyleBuilderConverter::convertRegisteredPropertyValue(const Styl
eResolverState& state, const CSSValue& value) |
1105 { | 1097 { |
1106 // TODO(timloh): Resolve ems, etc. | 1098 // TODO(timloh): Resolve ems, etc. |
1107 return value; | 1099 return value; |
1108 } | 1100 } |
1109 | 1101 |
1110 } // namespace blink | 1102 } // namespace blink |
OLD | NEW |