| 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( | 61 static GridLength convertGridTrackBreadth(const StyleResolverState& state, |
| 61 const StyleResolverState& state, | 62 const CSSValue& value) { |
| 62 const CSSPrimitiveValue& primitiveValue) { | 63 // Fractional unit. |
| 63 if (primitiveValue.getValueID() == CSSValueMinContent) | 64 if (value.isPrimitiveValue() && toCSSPrimitiveValue(value).isFlex()) |
| 65 return GridLength(toCSSPrimitiveValue(value).getDoubleValue()); |
| 66 |
| 67 if (value.isIdentifierValue() && |
| 68 toCSSIdentifierValue(value).getValueID() == CSSValueMinContent) |
| 64 return Length(MinContent); | 69 return Length(MinContent); |
| 65 | 70 |
| 66 if (primitiveValue.getValueID() == CSSValueMaxContent) | 71 if (value.isIdentifierValue() && |
| 72 toCSSIdentifierValue(value).getValueID() == CSSValueMaxContent) |
| 67 return Length(MaxContent); | 73 return Length(MaxContent); |
| 68 | 74 |
| 69 // Fractional unit. | 75 return StyleBuilderConverter::convertLengthOrAuto(state, value); |
| 70 if (primitiveValue.isFlex()) | |
| 71 return GridLength(primitiveValue.getDoubleValue()); | |
| 72 | |
| 73 return StyleBuilderConverter::convertLengthOrAuto(state, primitiveValue); | |
| 74 } | 76 } |
| 75 | 77 |
| 76 } // namespace | 78 } // namespace |
| 77 | 79 |
| 78 PassRefPtr<StyleReflection> StyleBuilderConverter::convertBoxReflect( | 80 PassRefPtr<StyleReflection> StyleBuilderConverter::convertBoxReflect( |
| 79 StyleResolverState& state, | 81 StyleResolverState& state, |
| 80 const CSSValue& value) { | 82 const CSSValue& value) { |
| 81 if (value.isPrimitiveValue()) { | 83 if (value.isIdentifierValue()) { |
| 82 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNone); | 84 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); |
| 83 return ComputedStyle::initialBoxReflect(); | 85 return ComputedStyle::initialBoxReflect(); |
| 84 } | 86 } |
| 85 | 87 |
| 86 const CSSReflectValue& reflectValue = toCSSReflectValue(value); | 88 const CSSReflectValue& reflectValue = toCSSReflectValue(value); |
| 87 RefPtr<StyleReflection> reflection = StyleReflection::create(); | 89 RefPtr<StyleReflection> reflection = StyleReflection::create(); |
| 88 reflection->setDirection( | 90 reflection->setDirection( |
| 89 reflectValue.direction()->convertTo<CSSReflectionDirection>()); | 91 reflectValue.direction()->convertTo<CSSReflectionDirection>()); |
| 90 if (reflectValue.offset()) | 92 if (reflectValue.offset()) |
| 91 reflection->setOffset(reflectValue.offset()->convertToLength( | 93 reflection->setOffset(reflectValue.offset()->convertToLength( |
| 92 state.cssToLengthConversionData())); | 94 state.cssToLengthConversionData())); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 state.document()); | 139 state.document()); |
| 138 // If the reference is non-local, then the fragment will remain as a | 140 // If the reference is non-local, then the fragment will remain as a |
| 139 // null string, which makes the element lookup fail. | 141 // null string, which makes the element lookup fail. |
| 140 AtomicString fragmentIdentifier; | 142 AtomicString fragmentIdentifier; |
| 141 if (resolver.isLocal()) | 143 if (resolver.isLocal()) |
| 142 fragmentIdentifier = resolver.fragmentIdentifier(); | 144 fragmentIdentifier = resolver.fragmentIdentifier(); |
| 143 // TODO(fs): Doesn't work with forward or external SVG references (crbug.com
/391604, crbug.com/109212, ...) | 145 // TODO(fs): Doesn't work with forward or external SVG references (crbug.com
/391604, crbug.com/109212, ...) |
| 144 return ReferenceClipPathOperation::create(toCSSURIValue(value).value(), | 146 return ReferenceClipPathOperation::create(toCSSURIValue(value).value(), |
| 145 fragmentIdentifier); | 147 fragmentIdentifier); |
| 146 } | 148 } |
| 147 DCHECK(value.isPrimitiveValue() && | 149 DCHECK(value.isIdentifierValue() && |
| 148 toCSSPrimitiveValue(value).getValueID() == CSSValueNone); | 150 toCSSIdentifierValue(value).getValueID() == CSSValueNone); |
| 149 return nullptr; | 151 return nullptr; |
| 150 } | 152 } |
| 151 | 153 |
| 152 FilterOperations StyleBuilderConverter::convertFilterOperations( | 154 FilterOperations StyleBuilderConverter::convertFilterOperations( |
| 153 StyleResolverState& state, | 155 StyleResolverState& state, |
| 154 const CSSValue& value) { | 156 const CSSValue& value) { |
| 155 return FilterOperationResolver::createFilterOperations(state, value); | 157 return FilterOperationResolver::createFilterOperations(state, value); |
| 156 } | 158 } |
| 157 | 159 |
| 158 static FontDescription::GenericFamilyType convertGenericFamily( | 160 static FontDescription::GenericFamilyType convertGenericFamily( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 180 static bool convertFontFamilyName( | 182 static bool convertFontFamilyName( |
| 181 StyleResolverState& state, | 183 StyleResolverState& state, |
| 182 const CSSValue& value, | 184 const CSSValue& value, |
| 183 FontDescription::GenericFamilyType& genericFamily, | 185 FontDescription::GenericFamilyType& genericFamily, |
| 184 AtomicString& familyName) { | 186 AtomicString& familyName) { |
| 185 if (value.isFontFamilyValue()) { | 187 if (value.isFontFamilyValue()) { |
| 186 genericFamily = FontDescription::NoFamily; | 188 genericFamily = FontDescription::NoFamily; |
| 187 familyName = AtomicString(toCSSFontFamilyValue(value).value()); | 189 familyName = AtomicString(toCSSFontFamilyValue(value).value()); |
| 188 } else if (state.document().settings()) { | 190 } else if (state.document().settings()) { |
| 189 genericFamily = | 191 genericFamily = |
| 190 convertGenericFamily(toCSSPrimitiveValue(value).getValueID()); | 192 convertGenericFamily(toCSSIdentifierValue(value).getValueID()); |
| 191 familyName = state.fontBuilder().genericFontFamilyName(genericFamily); | 193 familyName = state.fontBuilder().genericFontFamilyName(genericFamily); |
| 192 } | 194 } |
| 193 | 195 |
| 194 return !familyName.isEmpty(); | 196 return !familyName.isEmpty(); |
| 195 } | 197 } |
| 196 | 198 |
| 197 FontDescription::FamilyDescription StyleBuilderConverter::convertFontFamily( | 199 FontDescription::FamilyDescription StyleBuilderConverter::convertFontFamily( |
| 198 StyleResolverState& state, | 200 StyleResolverState& state, |
| 199 const CSSValue& value) { | 201 const CSSValue& value) { |
| 200 ASSERT(value.isValueList()); | 202 ASSERT(value.isValueList()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 223 if (genericFamily != FontDescription::NoFamily) | 225 if (genericFamily != FontDescription::NoFamily) |
| 224 desc.genericFamily = genericFamily; | 226 desc.genericFamily = genericFamily; |
| 225 } | 227 } |
| 226 | 228 |
| 227 return desc; | 229 return desc; |
| 228 } | 230 } |
| 229 | 231 |
| 230 PassRefPtr<FontFeatureSettings> | 232 PassRefPtr<FontFeatureSettings> |
| 231 StyleBuilderConverter::convertFontFeatureSettings(StyleResolverState& state, | 233 StyleBuilderConverter::convertFontFeatureSettings(StyleResolverState& state, |
| 232 const CSSValue& value) { | 234 const CSSValue& value) { |
| 233 if (value.isPrimitiveValue() && | 235 if (value.isIdentifierValue() && |
| 234 toCSSPrimitiveValue(value).getValueID() == CSSValueNormal) | 236 toCSSIdentifierValue(value).getValueID() == CSSValueNormal) |
| 235 return FontBuilder::initialFeatureSettings(); | 237 return FontBuilder::initialFeatureSettings(); |
| 236 | 238 |
| 237 const CSSValueList& list = toCSSValueList(value); | 239 const CSSValueList& list = toCSSValueList(value); |
| 238 RefPtr<FontFeatureSettings> settings = FontFeatureSettings::create(); | 240 RefPtr<FontFeatureSettings> settings = FontFeatureSettings::create(); |
| 239 int len = list.length(); | 241 int len = list.length(); |
| 240 for (int i = 0; i < len; ++i) { | 242 for (int i = 0; i < len; ++i) { |
| 241 const CSSFontFeatureValue& feature = toCSSFontFeatureValue(list.item(i)); | 243 const CSSFontFeatureValue& feature = toCSSFontFeatureValue(list.item(i)); |
| 242 settings->append(FontFeature(feature.tag(), feature.value())); | 244 settings->append(FontFeature(feature.tag(), feature.value())); |
| 243 } | 245 } |
| 244 return settings; | 246 return settings; |
| 245 } | 247 } |
| 246 | 248 |
| 247 static float computeFontSize(StyleResolverState& state, | 249 static float computeFontSize(StyleResolverState& state, |
| 248 const CSSPrimitiveValue& primitiveValue, | 250 const CSSPrimitiveValue& primitiveValue, |
| 249 const FontDescription::Size& parentSize) { | 251 const FontDescription::Size& parentSize) { |
| 250 if (primitiveValue.isLength()) | 252 if (primitiveValue.isLength()) |
| 251 return primitiveValue.computeLength<float>(state.fontSizeConversionData()); | 253 return primitiveValue.computeLength<float>(state.fontSizeConversionData()); |
| 252 if (primitiveValue.isCalculatedPercentageWithLength()) | 254 if (primitiveValue.isCalculatedPercentageWithLength()) |
| 253 return primitiveValue.cssCalcValue() | 255 return primitiveValue.cssCalcValue() |
| 254 ->toCalcValue(state.fontSizeConversionData()) | 256 ->toCalcValue(state.fontSizeConversionData()) |
| 255 ->evaluate(parentSize.value); | 257 ->evaluate(parentSize.value); |
| 256 | 258 |
| 257 ASSERT_NOT_REACHED(); | 259 ASSERT_NOT_REACHED(); |
| 258 return 0; | 260 return 0; |
| 259 } | 261 } |
| 260 | 262 |
| 261 FontDescription::Size StyleBuilderConverter::convertFontSize( | 263 FontDescription::Size StyleBuilderConverter::convertFontSize( |
| 262 StyleResolverState& state, | 264 StyleResolverState& state, |
| 263 const CSSValue& value) { | 265 const CSSValue& value) { |
| 264 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | |
| 265 | |
| 266 FontDescription::Size parentSize(0, 0.0f, false); | 266 FontDescription::Size parentSize(0, 0.0f, false); |
| 267 | 267 |
| 268 // FIXME: Find out when parentStyle could be 0? | 268 // FIXME: Find out when parentStyle could be 0? |
| 269 if (state.parentStyle()) | 269 if (state.parentStyle()) |
| 270 parentSize = state.parentFontDescription().getSize(); | 270 parentSize = state.parentFontDescription().getSize(); |
| 271 | 271 |
| 272 if (CSSValueID valueID = primitiveValue.getValueID()) { | 272 if (value.isIdentifierValue()) { |
| 273 CSSValueID valueID = toCSSIdentifierValue(value).getValueID(); |
| 273 if (FontSize::isValidValueID(valueID)) | 274 if (FontSize::isValidValueID(valueID)) |
| 274 return FontDescription::Size(FontSize::keywordSize(valueID), 0.0f, false); | 275 return FontDescription::Size(FontSize::keywordSize(valueID), 0.0f, false); |
| 275 if (valueID == CSSValueSmaller) | 276 if (valueID == CSSValueSmaller) |
| 276 return FontDescription::smallerSize(parentSize); | 277 return FontDescription::smallerSize(parentSize); |
| 277 if (valueID == CSSValueLarger) | 278 if (valueID == CSSValueLarger) |
| 278 return FontDescription::largerSize(parentSize); | 279 return FontDescription::largerSize(parentSize); |
| 279 ASSERT_NOT_REACHED(); | 280 ASSERT_NOT_REACHED(); |
| 280 return FontBuilder::initialSize(); | 281 return FontBuilder::initialSize(); |
| 281 } | 282 } |
| 282 | 283 |
| 283 bool parentIsAbsoluteSize = state.parentFontDescription().isAbsoluteSize(); | 284 bool parentIsAbsoluteSize = state.parentFontDescription().isAbsoluteSize(); |
| 284 | 285 |
| 286 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 285 if (primitiveValue.isPercentage()) | 287 if (primitiveValue.isPercentage()) |
| 286 return FontDescription::Size( | 288 return FontDescription::Size( |
| 287 0, (primitiveValue.getFloatValue() * parentSize.value / 100.0f), | 289 0, (primitiveValue.getFloatValue() * parentSize.value / 100.0f), |
| 288 parentIsAbsoluteSize); | 290 parentIsAbsoluteSize); |
| 289 | 291 |
| 290 return FontDescription::Size( | 292 return FontDescription::Size( |
| 291 0, computeFontSize(state, primitiveValue, parentSize), | 293 0, computeFontSize(state, primitiveValue, parentSize), |
| 292 parentIsAbsoluteSize || !primitiveValue.isFontRelativeLength()); | 294 parentIsAbsoluteSize || !primitiveValue.isFontRelativeLength()); |
| 293 } | 295 } |
| 294 | 296 |
| 295 float StyleBuilderConverter::convertFontSizeAdjust(StyleResolverState& state, | 297 float StyleBuilderConverter::convertFontSizeAdjust(StyleResolverState& state, |
| 296 const CSSValue& value) { | 298 const CSSValue& value) { |
| 297 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 299 if (value.isIdentifierValue() && |
| 298 if (primitiveValue.getValueID() == CSSValueNone) | 300 toCSSIdentifierValue(value).getValueID() == CSSValueNone) |
| 299 return FontBuilder::initialSizeAdjust(); | 301 return FontBuilder::initialSizeAdjust(); |
| 300 | 302 |
| 303 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 301 ASSERT(primitiveValue.isNumber()); | 304 ASSERT(primitiveValue.isNumber()); |
| 302 return primitiveValue.getFloatValue(); | 305 return primitiveValue.getFloatValue(); |
| 303 } | 306 } |
| 304 | 307 |
| 305 FontWeight StyleBuilderConverter::convertFontWeight(StyleResolverState& state, | 308 FontWeight StyleBuilderConverter::convertFontWeight(StyleResolverState& state, |
| 306 const CSSValue& value) { | 309 const CSSValue& value) { |
| 307 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 310 const CSSIdentifierValue& identifierValue = toCSSIdentifierValue(value); |
| 308 switch (primitiveValue.getValueID()) { | 311 switch (identifierValue.getValueID()) { |
| 309 case CSSValueBolder: | 312 case CSSValueBolder: |
| 310 return FontDescription::bolderWeight( | 313 return FontDescription::bolderWeight( |
| 311 state.parentStyle()->getFontDescription().weight()); | 314 state.parentStyle()->getFontDescription().weight()); |
| 312 case CSSValueLighter: | 315 case CSSValueLighter: |
| 313 return FontDescription::lighterWeight( | 316 return FontDescription::lighterWeight( |
| 314 state.parentStyle()->getFontDescription().weight()); | 317 state.parentStyle()->getFontDescription().weight()); |
| 315 default: | 318 default: |
| 316 return primitiveValue.convertTo<FontWeight>(); | 319 return identifierValue.convertTo<FontWeight>(); |
| 317 } | 320 } |
| 318 } | 321 } |
| 319 | 322 |
| 320 FontDescription::FontVariantCaps StyleBuilderConverter::convertFontVariantCaps( | 323 FontDescription::FontVariantCaps StyleBuilderConverter::convertFontVariantCaps( |
| 321 StyleResolverState&, | 324 StyleResolverState&, |
| 322 const CSSValue& value) { | 325 const CSSValue& value) { |
| 323 ASSERT_WITH_SECURITY_IMPLICATION(value.isPrimitiveValue()); | 326 SECURITY_DCHECK(value.isIdentifierValue()); |
| 324 CSSValueID valueID = toCSSPrimitiveValue(value).getValueID(); | 327 CSSValueID valueID = toCSSIdentifierValue(value).getValueID(); |
| 325 switch (valueID) { | 328 switch (valueID) { |
| 326 case CSSValueNormal: | 329 case CSSValueNormal: |
| 327 return FontDescription::CapsNormal; | 330 return FontDescription::CapsNormal; |
| 328 case CSSValueSmallCaps: | 331 case CSSValueSmallCaps: |
| 329 return FontDescription::SmallCaps; | 332 return FontDescription::SmallCaps; |
| 330 case CSSValueAllSmallCaps: | 333 case CSSValueAllSmallCaps: |
| 331 return FontDescription::AllSmallCaps; | 334 return FontDescription::AllSmallCaps; |
| 332 case CSSValuePetiteCaps: | 335 case CSSValuePetiteCaps: |
| 333 return FontDescription::PetiteCaps; | 336 return FontDescription::PetiteCaps; |
| 334 case CSSValueAllPetiteCaps: | 337 case CSSValueAllPetiteCaps: |
| 335 return FontDescription::AllPetiteCaps; | 338 return FontDescription::AllPetiteCaps; |
| 336 case CSSValueUnicase: | 339 case CSSValueUnicase: |
| 337 return FontDescription::Unicase; | 340 return FontDescription::Unicase; |
| 338 case CSSValueTitlingCaps: | 341 case CSSValueTitlingCaps: |
| 339 return FontDescription::TitlingCaps; | 342 return FontDescription::TitlingCaps; |
| 340 default: | 343 default: |
| 341 return FontDescription::CapsNormal; | 344 return FontDescription::CapsNormal; |
| 342 } | 345 } |
| 343 } | 346 } |
| 344 | 347 |
| 345 FontDescription::VariantLigatures | 348 FontDescription::VariantLigatures |
| 346 StyleBuilderConverter::convertFontVariantLigatures(StyleResolverState&, | 349 StyleBuilderConverter::convertFontVariantLigatures(StyleResolverState&, |
| 347 const CSSValue& value) { | 350 const CSSValue& value) { |
| 348 if (value.isValueList()) { | 351 if (value.isValueList()) { |
| 349 FontDescription::VariantLigatures ligatures; | 352 FontDescription::VariantLigatures ligatures; |
| 350 const CSSValueList& valueList = toCSSValueList(value); | 353 const CSSValueList& valueList = toCSSValueList(value); |
| 351 for (size_t i = 0; i < valueList.length(); ++i) { | 354 for (size_t i = 0; i < valueList.length(); ++i) { |
| 352 const CSSValue& item = valueList.item(i); | 355 const CSSValue& item = valueList.item(i); |
| 353 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(item); | 356 switch (toCSSIdentifierValue(item).getValueID()) { |
| 354 switch (primitiveValue.getValueID()) { | |
| 355 case CSSValueNoCommonLigatures: | 357 case CSSValueNoCommonLigatures: |
| 356 ligatures.common = FontDescription::DisabledLigaturesState; | 358 ligatures.common = FontDescription::DisabledLigaturesState; |
| 357 break; | 359 break; |
| 358 case CSSValueCommonLigatures: | 360 case CSSValueCommonLigatures: |
| 359 ligatures.common = FontDescription::EnabledLigaturesState; | 361 ligatures.common = FontDescription::EnabledLigaturesState; |
| 360 break; | 362 break; |
| 361 case CSSValueNoDiscretionaryLigatures: | 363 case CSSValueNoDiscretionaryLigatures: |
| 362 ligatures.discretionary = FontDescription::DisabledLigaturesState; | 364 ligatures.discretionary = FontDescription::DisabledLigaturesState; |
| 363 break; | 365 break; |
| 364 case CSSValueDiscretionaryLigatures: | 366 case CSSValueDiscretionaryLigatures: |
| (...skipping 12 matching lines...) Expand all Loading... |
| 377 ligatures.contextual = FontDescription::EnabledLigaturesState; | 379 ligatures.contextual = FontDescription::EnabledLigaturesState; |
| 378 break; | 380 break; |
| 379 default: | 381 default: |
| 380 ASSERT_NOT_REACHED(); | 382 ASSERT_NOT_REACHED(); |
| 381 break; | 383 break; |
| 382 } | 384 } |
| 383 } | 385 } |
| 384 return ligatures; | 386 return ligatures; |
| 385 } | 387 } |
| 386 | 388 |
| 387 ASSERT_WITH_SECURITY_IMPLICATION(value.isPrimitiveValue()); | 389 SECURITY_DCHECK(value.isIdentifierValue()); |
| 388 | 390 if (toCSSIdentifierValue(value).getValueID() == CSSValueNone) { |
| 389 if (toCSSPrimitiveValue(value).getValueID() == CSSValueNone) { | |
| 390 return FontDescription::VariantLigatures( | 391 return FontDescription::VariantLigatures( |
| 391 FontDescription::DisabledLigaturesState); | 392 FontDescription::DisabledLigaturesState); |
| 392 } | 393 } |
| 393 | 394 |
| 394 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNormal); | 395 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNormal); |
| 395 return FontDescription::VariantLigatures(); | 396 return FontDescription::VariantLigatures(); |
| 396 } | 397 } |
| 397 | 398 |
| 398 FontVariantNumeric StyleBuilderConverter::convertFontVariantNumeric( | 399 FontVariantNumeric StyleBuilderConverter::convertFontVariantNumeric( |
| 399 StyleResolverState&, | 400 StyleResolverState&, |
| 400 const CSSValue& value) { | 401 const CSSValue& value) { |
| 401 if (value.isPrimitiveValue()) { | 402 if (value.isIdentifierValue()) { |
| 402 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNormal); | 403 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNormal); |
| 403 return FontVariantNumeric(); | 404 return FontVariantNumeric(); |
| 404 } | 405 } |
| 405 | 406 |
| 406 FontVariantNumeric variantNumeric; | 407 FontVariantNumeric variantNumeric; |
| 407 for (const CSSValue* feature : toCSSValueList(value)) { | 408 for (const CSSValue* feature : toCSSValueList(value)) { |
| 408 switch (toCSSPrimitiveValue(feature)->getValueID()) { | 409 switch (toCSSIdentifierValue(feature)->getValueID()) { |
| 409 case CSSValueLiningNums: | 410 case CSSValueLiningNums: |
| 410 variantNumeric.setNumericFigure(FontVariantNumeric::LiningNums); | 411 variantNumeric.setNumericFigure(FontVariantNumeric::LiningNums); |
| 411 break; | 412 break; |
| 412 case CSSValueOldstyleNums: | 413 case CSSValueOldstyleNums: |
| 413 variantNumeric.setNumericFigure(FontVariantNumeric::OldstyleNums); | 414 variantNumeric.setNumericFigure(FontVariantNumeric::OldstyleNums); |
| 414 break; | 415 break; |
| 415 case CSSValueProportionalNums: | 416 case CSSValueProportionalNums: |
| 416 variantNumeric.setNumericSpacing(FontVariantNumeric::ProportionalNums); | 417 variantNumeric.setNumericSpacing(FontVariantNumeric::ProportionalNums); |
| 417 break; | 418 break; |
| 418 case CSSValueTabularNums: | 419 case CSSValueTabularNums: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 438 } | 439 } |
| 439 return variantNumeric; | 440 return variantNumeric; |
| 440 } | 441 } |
| 441 | 442 |
| 442 StyleSelfAlignmentData StyleBuilderConverter::convertSelfOrDefaultAlignmentData( | 443 StyleSelfAlignmentData StyleBuilderConverter::convertSelfOrDefaultAlignmentData( |
| 443 StyleResolverState&, | 444 StyleResolverState&, |
| 444 const CSSValue& value) { | 445 const CSSValue& value) { |
| 445 StyleSelfAlignmentData alignmentData = ComputedStyle::initialSelfAlignment(); | 446 StyleSelfAlignmentData alignmentData = ComputedStyle::initialSelfAlignment(); |
| 446 if (value.isValuePair()) { | 447 if (value.isValuePair()) { |
| 447 const CSSValuePair& pair = toCSSValuePair(value); | 448 const CSSValuePair& pair = toCSSValuePair(value); |
| 448 if (toCSSPrimitiveValue(pair.first()).getValueID() == CSSValueLegacy) { | 449 if (toCSSIdentifierValue(pair.first()).getValueID() == CSSValueLegacy) { |
| 449 alignmentData.setPositionType(LegacyPosition); | 450 alignmentData.setPositionType(LegacyPosition); |
| 450 alignmentData.setPosition( | 451 alignmentData.setPosition( |
| 451 toCSSPrimitiveValue(pair.second()).convertTo<ItemPosition>()); | 452 toCSSIdentifierValue(pair.second()).convertTo<ItemPosition>()); |
| 452 } else { | 453 } else { |
| 453 alignmentData.setPosition( | 454 alignmentData.setPosition( |
| 454 toCSSPrimitiveValue(pair.first()).convertTo<ItemPosition>()); | 455 toCSSIdentifierValue(pair.first()).convertTo<ItemPosition>()); |
| 455 alignmentData.setOverflow( | 456 alignmentData.setOverflow( |
| 456 toCSSPrimitiveValue(pair.second()).convertTo<OverflowAlignment>()); | 457 toCSSIdentifierValue(pair.second()).convertTo<OverflowAlignment>()); |
| 457 } | 458 } |
| 458 } else { | 459 } else { |
| 459 alignmentData.setPosition( | 460 alignmentData.setPosition( |
| 460 toCSSPrimitiveValue(value).convertTo<ItemPosition>()); | 461 toCSSIdentifierValue(value).convertTo<ItemPosition>()); |
| 461 } | 462 } |
| 462 return alignmentData; | 463 return alignmentData; |
| 463 } | 464 } |
| 464 | 465 |
| 465 StyleContentAlignmentData StyleBuilderConverter::convertContentAlignmentData( | 466 StyleContentAlignmentData StyleBuilderConverter::convertContentAlignmentData( |
| 466 StyleResolverState&, | 467 StyleResolverState&, |
| 467 const CSSValue& value) { | 468 const CSSValue& value) { |
| 468 StyleContentAlignmentData alignmentData = | 469 StyleContentAlignmentData alignmentData = |
| 469 ComputedStyle::initialContentAlignment(); | 470 ComputedStyle::initialContentAlignment(); |
| 470 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) { | 471 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) { |
| 471 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 472 const CSSIdentifierValue& identifierValue = toCSSIdentifierValue(value); |
| 472 switch (primitiveValue.getValueID()) { | 473 switch (identifierValue.getValueID()) { |
| 473 case CSSValueStretch: | 474 case CSSValueStretch: |
| 474 case CSSValueSpaceBetween: | 475 case CSSValueSpaceBetween: |
| 475 case CSSValueSpaceAround: | 476 case CSSValueSpaceAround: |
| 476 alignmentData.setDistribution( | 477 alignmentData.setDistribution( |
| 477 primitiveValue.convertTo<ContentDistributionType>()); | 478 identifierValue.convertTo<ContentDistributionType>()); |
| 478 break; | 479 break; |
| 479 case CSSValueFlexStart: | 480 case CSSValueFlexStart: |
| 480 case CSSValueFlexEnd: | 481 case CSSValueFlexEnd: |
| 481 case CSSValueCenter: | 482 case CSSValueCenter: |
| 482 alignmentData.setPosition(primitiveValue.convertTo<ContentPosition>()); | 483 alignmentData.setPosition(identifierValue.convertTo<ContentPosition>()); |
| 483 break; | 484 break; |
| 484 default: | 485 default: |
| 485 ASSERT_NOT_REACHED(); | 486 ASSERT_NOT_REACHED(); |
| 486 } | 487 } |
| 487 return alignmentData; | 488 return alignmentData; |
| 488 } | 489 } |
| 489 const CSSContentDistributionValue& contentValue = | 490 const CSSContentDistributionValue& contentValue = |
| 490 toCSSContentDistributionValue(value); | 491 toCSSContentDistributionValue(value); |
| 491 if (contentValue.distribution()->getValueID() != CSSValueInvalid) | 492 if (contentValue.distribution()->getValueID() != CSSValueInvalid) |
| 492 alignmentData.setDistribution( | 493 alignmentData.setDistribution( |
| 493 contentValue.distribution()->convertTo<ContentDistributionType>()); | 494 contentValue.distribution()->convertTo<ContentDistributionType>()); |
| 494 if (contentValue.position()->getValueID() != CSSValueInvalid) | 495 if (contentValue.position()->getValueID() != CSSValueInvalid) |
| 495 alignmentData.setPosition( | 496 alignmentData.setPosition( |
| 496 contentValue.position()->convertTo<ContentPosition>()); | 497 contentValue.position()->convertTo<ContentPosition>()); |
| 497 if (contentValue.overflow()->getValueID() != CSSValueInvalid) | 498 if (contentValue.overflow()->getValueID() != CSSValueInvalid) |
| 498 alignmentData.setOverflow( | 499 alignmentData.setOverflow( |
| 499 contentValue.overflow()->convertTo<OverflowAlignment>()); | 500 contentValue.overflow()->convertTo<OverflowAlignment>()); |
| 500 return alignmentData; | 501 return alignmentData; |
| 501 } | 502 } |
| 502 | 503 |
| 503 GridAutoFlow StyleBuilderConverter::convertGridAutoFlow(StyleResolverState&, | 504 GridAutoFlow StyleBuilderConverter::convertGridAutoFlow(StyleResolverState&, |
| 504 const CSSValue& value) { | 505 const CSSValue& value) { |
| 505 const CSSValueList& list = toCSSValueList(value); | 506 const CSSValueList& list = toCSSValueList(value); |
| 506 | 507 |
| 507 ASSERT(list.length() >= 1); | 508 ASSERT(list.length() >= 1); |
| 508 const CSSPrimitiveValue& first = toCSSPrimitiveValue(list.item(0)); | 509 const CSSIdentifierValue& first = toCSSIdentifierValue(list.item(0)); |
| 509 const CSSPrimitiveValue* second = | 510 const CSSIdentifierValue* second = |
| 510 list.length() == 2 ? &toCSSPrimitiveValue(list.item(1)) : nullptr; | 511 list.length() == 2 ? &toCSSIdentifierValue(list.item(1)) : nullptr; |
| 511 | 512 |
| 512 switch (first.getValueID()) { | 513 switch (first.getValueID()) { |
| 513 case CSSValueRow: | 514 case CSSValueRow: |
| 514 if (second && second->getValueID() == CSSValueDense) | 515 if (second && second->getValueID() == CSSValueDense) |
| 515 return AutoFlowRowDense; | 516 return AutoFlowRowDense; |
| 516 return AutoFlowRow; | 517 return AutoFlowRow; |
| 517 case CSSValueColumn: | 518 case CSSValueColumn: |
| 518 if (second && second->getValueID() == CSSValueDense) | 519 if (second && second->getValueID() == CSSValueDense) |
| 519 return AutoFlowColumnDense; | 520 return AutoFlowColumnDense; |
| 520 return AutoFlowColumn; | 521 return AutoFlowColumn; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 535 | 536 |
| 536 GridPosition position; | 537 GridPosition position; |
| 537 | 538 |
| 538 if (value.isCustomIdentValue()) { | 539 if (value.isCustomIdentValue()) { |
| 539 // We translate <custom-ident> to <string> during parsing as it | 540 // We translate <custom-ident> to <string> during parsing as it |
| 540 // makes handling it more simple. | 541 // makes handling it more simple. |
| 541 position.setNamedGridArea(toCSSCustomIdentValue(value).value()); | 542 position.setNamedGridArea(toCSSCustomIdentValue(value).value()); |
| 542 return position; | 543 return position; |
| 543 } | 544 } |
| 544 | 545 |
| 545 if (value.isPrimitiveValue()) { | 546 if (value.isIdentifierValue()) { |
| 546 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueAuto); | 547 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueAuto); |
| 547 return position; | 548 return position; |
| 548 } | 549 } |
| 549 | 550 |
| 550 const CSSValueList& values = toCSSValueList(value); | 551 const CSSValueList& values = toCSSValueList(value); |
| 551 ASSERT(values.length()); | 552 ASSERT(values.length()); |
| 552 | 553 |
| 553 bool isSpanPosition = false; | 554 bool isSpanPosition = false; |
| 554 // The specification makes the <integer> optional, in which case it default to
'1'. | 555 // The specification makes the <integer> optional, in which case it default to
'1'. |
| 555 int gridLineNumber = 1; | 556 int gridLineNumber = 1; |
| 556 AtomicString gridLineName; | 557 AtomicString gridLineName; |
| 557 | 558 |
| 558 auto it = values.begin(); | 559 auto it = values.begin(); |
| 559 const CSSValue* currentValue = it->get(); | 560 const CSSValue* currentValue = it->get(); |
| 560 if (currentValue->isPrimitiveValue() && | 561 if (currentValue->isIdentifierValue() && |
| 561 toCSSPrimitiveValue(currentValue)->getValueID() == CSSValueSpan) { | 562 toCSSIdentifierValue(currentValue)->getValueID() == CSSValueSpan) { |
| 562 isSpanPosition = true; | 563 isSpanPosition = true; |
| 563 ++it; | 564 ++it; |
| 564 currentValue = it != values.end() ? it->get() : nullptr; | 565 currentValue = it != values.end() ? it->get() : nullptr; |
| 565 } | 566 } |
| 566 | 567 |
| 567 if (currentValue && currentValue->isPrimitiveValue() && | 568 if (currentValue && currentValue->isPrimitiveValue() && |
| 568 toCSSPrimitiveValue(currentValue)->isNumber()) { | 569 toCSSPrimitiveValue(currentValue)->isNumber()) { |
| 569 gridLineNumber = toCSSPrimitiveValue(currentValue)->getIntValue(); | 570 gridLineNumber = toCSSPrimitiveValue(currentValue)->getIntValue(); |
| 570 ++it; | 571 ++it; |
| 571 currentValue = it != values.end() ? it->get() : nullptr; | 572 currentValue = it != values.end() ? it->get() : nullptr; |
| 572 } | 573 } |
| 573 | 574 |
| 574 if (currentValue && currentValue->isCustomIdentValue()) { | 575 if (currentValue && currentValue->isCustomIdentValue()) { |
| 575 gridLineName = toCSSCustomIdentValue(currentValue)->value(); | 576 gridLineName = toCSSCustomIdentValue(currentValue)->value(); |
| 576 ++it; | 577 ++it; |
| 577 } | 578 } |
| 578 | 579 |
| 579 ASSERT(it == values.end()); | 580 ASSERT(it == values.end()); |
| 580 if (isSpanPosition) | 581 if (isSpanPosition) |
| 581 position.setSpanPosition(gridLineNumber, gridLineName); | 582 position.setSpanPosition(gridLineNumber, gridLineName); |
| 582 else | 583 else |
| 583 position.setExplicitPosition(gridLineNumber, gridLineName); | 584 position.setExplicitPosition(gridLineNumber, gridLineName); |
| 584 | 585 |
| 585 return position; | 586 return position; |
| 586 } | 587 } |
| 587 | 588 |
| 588 GridTrackSize StyleBuilderConverter::convertGridTrackSize( | 589 GridTrackSize StyleBuilderConverter::convertGridTrackSize( |
| 589 StyleResolverState& state, | 590 StyleResolverState& state, |
| 590 const CSSValue& value) { | 591 const CSSValue& value) { |
| 591 if (value.isPrimitiveValue()) | 592 if (value.isPrimitiveValue() || value.isIdentifierValue()) |
| 592 return GridTrackSize( | 593 return GridTrackSize(convertGridTrackBreadth(state, value)); |
| 593 convertGridTrackBreadth(state, toCSSPrimitiveValue(value))); | |
| 594 | 594 |
| 595 auto& function = toCSSFunctionValue(value); | 595 auto& function = toCSSFunctionValue(value); |
| 596 if (function.functionType() == CSSValueFitContent) { | 596 if (function.functionType() == CSSValueFitContent) { |
| 597 SECURITY_DCHECK(function.length() == 1); | 597 SECURITY_DCHECK(function.length() == 1); |
| 598 return GridTrackSize( | 598 return GridTrackSize(convertGridTrackBreadth(state, function.item(0)), |
| 599 convertGridTrackBreadth(state, toCSSPrimitiveValue(function.item(0))), | 599 FitContentTrackSizing); |
| 600 FitContentTrackSizing); | |
| 601 } | 600 } |
| 602 | 601 |
| 603 SECURITY_DCHECK(function.length() == 2); | 602 SECURITY_DCHECK(function.length() == 2); |
| 604 GridLength minTrackBreadth( | 603 GridLength minTrackBreadth(convertGridTrackBreadth(state, function.item(0))); |
| 605 convertGridTrackBreadth(state, toCSSPrimitiveValue(function.item(0)))); | 604 GridLength maxTrackBreadth(convertGridTrackBreadth(state, function.item(1))); |
| 606 GridLength maxTrackBreadth( | |
| 607 convertGridTrackBreadth(state, toCSSPrimitiveValue(function.item(1)))); | |
| 608 return GridTrackSize(minTrackBreadth, maxTrackBreadth); | 605 return GridTrackSize(minTrackBreadth, maxTrackBreadth); |
| 609 } | 606 } |
| 610 | 607 |
| 611 static void convertGridLineNamesList( | 608 static void convertGridLineNamesList( |
| 612 const CSSValue& value, | 609 const CSSValue& value, |
| 613 size_t currentNamedGridLine, | 610 size_t currentNamedGridLine, |
| 614 NamedGridLinesMap& namedGridLines, | 611 NamedGridLinesMap& namedGridLines, |
| 615 OrderedNamedGridLines& orderedNamedGridLines) { | 612 OrderedNamedGridLines& orderedNamedGridLines) { |
| 616 ASSERT(value.isGridLineNamesValue()); | 613 ASSERT(value.isGridLineNamesValue()); |
| 617 | 614 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 643 const CSSValue& value, | 640 const CSSValue& value, |
| 644 Vector<GridTrackSize>& trackSizes, | 641 Vector<GridTrackSize>& trackSizes, |
| 645 NamedGridLinesMap& namedGridLines, | 642 NamedGridLinesMap& namedGridLines, |
| 646 OrderedNamedGridLines& orderedNamedGridLines, | 643 OrderedNamedGridLines& orderedNamedGridLines, |
| 647 Vector<GridTrackSize>& autoRepeatTrackSizes, | 644 Vector<GridTrackSize>& autoRepeatTrackSizes, |
| 648 NamedGridLinesMap& autoRepeatNamedGridLines, | 645 NamedGridLinesMap& autoRepeatNamedGridLines, |
| 649 OrderedNamedGridLines& autoRepeatOrderedNamedGridLines, | 646 OrderedNamedGridLines& autoRepeatOrderedNamedGridLines, |
| 650 size_t& autoRepeatInsertionPoint, | 647 size_t& autoRepeatInsertionPoint, |
| 651 AutoRepeatType& autoRepeatType, | 648 AutoRepeatType& autoRepeatType, |
| 652 StyleResolverState& state) { | 649 StyleResolverState& state) { |
| 653 if (value.isPrimitiveValue()) { | 650 if (value.isIdentifierValue()) { |
| 654 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNone); | 651 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); |
| 655 return; | 652 return; |
| 656 } | 653 } |
| 657 | 654 |
| 658 size_t currentNamedGridLine = 0; | 655 size_t currentNamedGridLine = 0; |
| 659 for (auto currValue : toCSSValueList(value)) { | 656 for (auto currValue : toCSSValueList(value)) { |
| 660 if (currValue->isGridLineNamesValue()) { | 657 if (currValue->isGridLineNamesValue()) { |
| 661 convertGridLineNamesList(*currValue, currentNamedGridLine, namedGridLines, | 658 convertGridLineNamesList(*currValue, currentNamedGridLine, namedGridLines, |
| 662 orderedNamedGridLines); | 659 orderedNamedGridLines); |
| 663 continue; | 660 continue; |
| 664 } | 661 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 UnzoomedLength StyleBuilderConverter::convertUnzoomedLength( | 747 UnzoomedLength StyleBuilderConverter::convertUnzoomedLength( |
| 751 const StyleResolverState& state, | 748 const StyleResolverState& state, |
| 752 const CSSValue& value) { | 749 const CSSValue& value) { |
| 753 return UnzoomedLength(toCSSPrimitiveValue(value).convertToLength( | 750 return UnzoomedLength(toCSSPrimitiveValue(value).convertToLength( |
| 754 state.cssToLengthConversionData().copyWithAdjustedZoom(1.0f))); | 751 state.cssToLengthConversionData().copyWithAdjustedZoom(1.0f))); |
| 755 } | 752 } |
| 756 | 753 |
| 757 Length StyleBuilderConverter::convertLengthOrAuto( | 754 Length StyleBuilderConverter::convertLengthOrAuto( |
| 758 const StyleResolverState& state, | 755 const StyleResolverState& state, |
| 759 const CSSValue& value) { | 756 const CSSValue& value) { |
| 760 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 757 if (value.isIdentifierValue() && |
| 761 if (primitiveValue.getValueID() == CSSValueAuto) | 758 toCSSIdentifierValue(value).getValueID() == CSSValueAuto) |
| 762 return Length(Auto); | 759 return Length(Auto); |
| 763 return primitiveValue.convertToLength(state.cssToLengthConversionData()); | 760 return toCSSPrimitiveValue(value).convertToLength( |
| 761 state.cssToLengthConversionData()); |
| 764 } | 762 } |
| 765 | 763 |
| 766 Length StyleBuilderConverter::convertLengthSizing(StyleResolverState& state, | 764 Length StyleBuilderConverter::convertLengthSizing(StyleResolverState& state, |
| 767 const CSSValue& value) { | 765 const CSSValue& value) { |
| 768 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 766 if (!value.isIdentifierValue()) |
| 769 switch (primitiveValue.getValueID()) { | 767 return convertLength(state, value); |
| 770 case CSSValueInvalid: | 768 |
| 771 return convertLength(state, value); | 769 const CSSIdentifierValue& identifierValue = toCSSIdentifierValue(value); |
| 770 switch (identifierValue.getValueID()) { |
| 772 case CSSValueMinContent: | 771 case CSSValueMinContent: |
| 773 case CSSValueWebkitMinContent: | 772 case CSSValueWebkitMinContent: |
| 774 return Length(MinContent); | 773 return Length(MinContent); |
| 775 case CSSValueMaxContent: | 774 case CSSValueMaxContent: |
| 776 case CSSValueWebkitMaxContent: | 775 case CSSValueWebkitMaxContent: |
| 777 return Length(MaxContent); | 776 return Length(MaxContent); |
| 778 case CSSValueWebkitFillAvailable: | 777 case CSSValueWebkitFillAvailable: |
| 779 return Length(FillAvailable); | 778 return Length(FillAvailable); |
| 780 case CSSValueWebkitFitContent: | 779 case CSSValueWebkitFitContent: |
| 781 case CSSValueFitContent: | 780 case CSSValueFitContent: |
| 782 return Length(FitContent); | 781 return Length(FitContent); |
| 783 case CSSValueAuto: | 782 case CSSValueAuto: |
| 784 return Length(Auto); | 783 return Length(Auto); |
| 785 default: | 784 default: |
| 786 ASSERT_NOT_REACHED(); | 785 ASSERT_NOT_REACHED(); |
| 787 return Length(); | 786 return Length(); |
| 788 } | 787 } |
| 789 } | 788 } |
| 790 | 789 |
| 791 Length StyleBuilderConverter::convertLengthMaxSizing(StyleResolverState& state, | 790 Length StyleBuilderConverter::convertLengthMaxSizing(StyleResolverState& state, |
| 792 const CSSValue& value) { | 791 const CSSValue& value) { |
| 793 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 792 if (value.isIdentifierValue() && |
| 794 if (primitiveValue.getValueID() == CSSValueNone) | 793 toCSSIdentifierValue(value).getValueID() == CSSValueNone) |
| 795 return Length(MaxSizeNone); | 794 return Length(MaxSizeNone); |
| 796 return convertLengthSizing(state, value); | 795 return convertLengthSizing(state, value); |
| 797 } | 796 } |
| 798 | 797 |
| 799 TabSize StyleBuilderConverter::convertLengthOrTabSpaces( | 798 TabSize StyleBuilderConverter::convertLengthOrTabSpaces( |
| 800 StyleResolverState& state, | 799 StyleResolverState& state, |
| 801 const CSSValue& value) { | 800 const CSSValue& value) { |
| 802 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 801 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 803 if (primitiveValue.isNumber()) | 802 if (primitiveValue.isNumber()) |
| 804 return TabSize(primitiveValue.getIntValue()); | 803 return TabSize(primitiveValue.getIntValue()); |
| 805 return TabSize( | 804 return TabSize( |
| 806 primitiveValue.computeLength<float>(state.cssToLengthConversionData())); | 805 primitiveValue.computeLength<float>(state.cssToLengthConversionData())); |
| 807 } | 806 } |
| 808 | 807 |
| 809 static CSSToLengthConversionData lineHeightToLengthConversionData( | 808 static CSSToLengthConversionData lineHeightToLengthConversionData( |
| 810 StyleResolverState& state) { | 809 StyleResolverState& state) { |
| 811 float multiplier = state.style()->effectiveZoom(); | 810 float multiplier = state.style()->effectiveZoom(); |
| 812 if (LocalFrame* frame = state.document().frame()) | 811 if (LocalFrame* frame = state.document().frame()) |
| 813 multiplier *= frame->textZoomFactor(); | 812 multiplier *= frame->textZoomFactor(); |
| 814 return state.cssToLengthConversionData().copyWithAdjustedZoom(multiplier); | 813 return state.cssToLengthConversionData().copyWithAdjustedZoom(multiplier); |
| 815 } | 814 } |
| 816 | 815 |
| 817 Length StyleBuilderConverter::convertLineHeight(StyleResolverState& state, | 816 Length StyleBuilderConverter::convertLineHeight(StyleResolverState& state, |
| 818 const CSSValue& value) { | 817 const CSSValue& value) { |
| 819 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 818 if (value.isPrimitiveValue()) { |
| 820 | 819 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 821 if (primitiveValue.isLength()) | 820 if (primitiveValue.isLength()) { |
| 822 return primitiveValue.computeLength<Length>( | 821 return primitiveValue.computeLength<Length>( |
| 823 lineHeightToLengthConversionData(state)); | 822 lineHeightToLengthConversionData(state)); |
| 824 if (primitiveValue.isPercentage()) | 823 } |
| 825 return Length( | 824 if (primitiveValue.isPercentage()) { |
| 826 (state.style()->computedFontSize() * primitiveValue.getIntValue()) / | 825 return Length( |
| 827 100.0, | 826 (state.style()->computedFontSize() * primitiveValue.getIntValue()) / |
| 828 Fixed); | 827 100.0, |
| 829 if (primitiveValue.isNumber()) | 828 Fixed); |
| 830 return Length(primitiveValue.getDoubleValue() * 100.0, Percent); | 829 } |
| 831 if (primitiveValue.isCalculated()) { | 830 if (primitiveValue.isNumber()) |
| 832 Length zoomedLength = Length(primitiveValue.cssCalcValue()->toCalcValue( | 831 return Length(primitiveValue.getDoubleValue() * 100.0, Percent); |
| 833 lineHeightToLengthConversionData(state))); | 832 if (primitiveValue.isCalculated()) { |
| 834 return Length(valueForLength(zoomedLength, | 833 Length zoomedLength = Length(primitiveValue.cssCalcValue()->toCalcValue( |
| 835 LayoutUnit(state.style()->computedFontSize())), | 834 lineHeightToLengthConversionData(state))); |
| 836 Fixed); | 835 return Length( |
| 836 valueForLength(zoomedLength, |
| 837 LayoutUnit(state.style()->computedFontSize())), |
| 838 Fixed); |
| 839 } |
| 837 } | 840 } |
| 838 | 841 |
| 839 ASSERT(primitiveValue.getValueID() == CSSValueNormal); | 842 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNormal); |
| 840 return ComputedStyle::initialLineHeight(); | 843 return ComputedStyle::initialLineHeight(); |
| 841 } | 844 } |
| 842 | 845 |
| 843 float StyleBuilderConverter::convertNumberOrPercentage( | 846 float StyleBuilderConverter::convertNumberOrPercentage( |
| 844 StyleResolverState& state, | 847 StyleResolverState& state, |
| 845 const CSSValue& value) { | 848 const CSSValue& value) { |
| 846 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 849 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 847 ASSERT(primitiveValue.isNumber() || primitiveValue.isPercentage()); | 850 ASSERT(primitiveValue.isNumber() || primitiveValue.isPercentage()); |
| 848 if (primitiveValue.isNumber()) | 851 if (primitiveValue.isNumber()) |
| 849 return primitiveValue.getFloatValue(); | 852 return primitiveValue.getFloatValue(); |
| 850 return primitiveValue.getFloatValue() / 100.0f; | 853 return primitiveValue.getFloatValue() / 100.0f; |
| 851 } | 854 } |
| 852 | 855 |
| 853 StyleOffsetRotation StyleBuilderConverter::convertOffsetRotation( | 856 StyleOffsetRotation StyleBuilderConverter::convertOffsetRotation( |
| 854 StyleResolverState&, | 857 StyleResolverState&, |
| 855 const CSSValue& value) { | 858 const CSSValue& value) { |
| 856 return convertOffsetRotation(value); | 859 return convertOffsetRotation(value); |
| 857 } | 860 } |
| 858 | 861 |
| 859 StyleOffsetRotation StyleBuilderConverter::convertOffsetRotation( | 862 StyleOffsetRotation StyleBuilderConverter::convertOffsetRotation( |
| 860 const CSSValue& value) { | 863 const CSSValue& value) { |
| 861 StyleOffsetRotation result(0, OffsetRotationFixed); | 864 StyleOffsetRotation result(0, OffsetRotationFixed); |
| 862 | 865 |
| 863 const CSSValueList& list = toCSSValueList(value); | 866 const CSSValueList& list = toCSSValueList(value); |
| 864 ASSERT(list.length() == 1 || list.length() == 2); | 867 ASSERT(list.length() == 1 || list.length() == 2); |
| 865 for (const auto& item : list) { | 868 for (const auto& item : list) { |
| 866 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(*item); | 869 if (item->isIdentifierValue() && |
| 867 if (primitiveValue.getValueID() == CSSValueAuto) { | 870 toCSSIdentifierValue(*item).getValueID() == CSSValueAuto) { |
| 868 result.type = OffsetRotationAuto; | 871 result.type = OffsetRotationAuto; |
| 869 } else if (primitiveValue.getValueID() == CSSValueReverse) { | 872 } else if (item->isIdentifierValue() && |
| 873 toCSSIdentifierValue(*item).getValueID() == CSSValueReverse) { |
| 870 result.type = OffsetRotationAuto; | 874 result.type = OffsetRotationAuto; |
| 871 result.angle += 180; | 875 result.angle += 180; |
| 872 } else { | 876 } else { |
| 877 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(*item); |
| 873 result.angle += primitiveValue.computeDegrees(); | 878 result.angle += primitiveValue.computeDegrees(); |
| 874 } | 879 } |
| 875 } | 880 } |
| 876 result.angle = clampTo<float>(result.angle); | 881 result.angle = clampTo<float>(result.angle); |
| 877 | 882 |
| 878 return result; | 883 return result; |
| 879 } | 884 } |
| 880 | 885 |
| 881 template <CSSValueID cssValueFor0, CSSValueID cssValueFor100> | 886 template <CSSValueID cssValueFor0, CSSValueID cssValueFor100> |
| 882 Length StyleBuilderConverter::convertPositionLength(StyleResolverState& state, | 887 Length StyleBuilderConverter::convertPositionLength(StyleResolverState& state, |
| 883 const CSSValue& value) { | 888 const CSSValue& value) { |
| 884 if (value.isValuePair()) { | 889 if (value.isValuePair()) { |
| 885 const CSSValuePair& pair = toCSSValuePair(value); | 890 const CSSValuePair& pair = toCSSValuePair(value); |
| 886 Length length = StyleBuilderConverter::convertLength(state, pair.second()); | 891 Length length = StyleBuilderConverter::convertLength(state, pair.second()); |
| 887 if (toCSSPrimitiveValue(pair.first()).getValueID() == cssValueFor0) | 892 if (toCSSIdentifierValue(pair.first()).getValueID() == cssValueFor0) |
| 888 return length; | 893 return length; |
| 889 ASSERT(toCSSPrimitiveValue(pair.first()).getValueID() == cssValueFor100); | 894 DCHECK_EQ(toCSSIdentifierValue(pair.first()).getValueID(), cssValueFor100); |
| 890 return length.subtractFromOneHundredPercent(); | 895 return length.subtractFromOneHundredPercent(); |
| 891 } | 896 } |
| 892 | 897 |
| 893 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 898 if (value.isIdentifierValue()) { |
| 894 if (primitiveValue.isValueID()) { | 899 switch (toCSSIdentifierValue(value).getValueID()) { |
| 895 switch (primitiveValue.getValueID()) { | |
| 896 case cssValueFor0: | 900 case cssValueFor0: |
| 897 return Length(0, Percent); | 901 return Length(0, Percent); |
| 898 case cssValueFor100: | 902 case cssValueFor100: |
| 899 return Length(100, Percent); | 903 return Length(100, Percent); |
| 900 case CSSValueCenter: | 904 case CSSValueCenter: |
| 901 return Length(50, Percent); | 905 return Length(50, Percent); |
| 902 default: | 906 default: |
| 903 ASSERT_NOT_REACHED(); | 907 ASSERT_NOT_REACHED(); |
| 904 } | 908 } |
| 905 } | 909 } |
| 906 | 910 |
| 907 return StyleBuilderConverter::convertLength(state, primitiveValue); | 911 return StyleBuilderConverter::convertLength(state, |
| 912 toCSSPrimitiveValue(value)); |
| 908 } | 913 } |
| 909 | 914 |
| 910 LengthPoint StyleBuilderConverter::convertPosition(StyleResolverState& state, | 915 LengthPoint StyleBuilderConverter::convertPosition(StyleResolverState& state, |
| 911 const CSSValue& value) { | 916 const CSSValue& value) { |
| 912 const CSSValuePair& pair = toCSSValuePair(value); | 917 const CSSValuePair& pair = toCSSValuePair(value); |
| 913 return LengthPoint( | 918 return LengthPoint( |
| 914 convertPositionLength<CSSValueLeft, CSSValueRight>(state, pair.first()), | 919 convertPositionLength<CSSValueLeft, CSSValueRight>(state, pair.first()), |
| 915 convertPositionLength<CSSValueTop, CSSValueBottom>(state, pair.second())); | 920 convertPositionLength<CSSValueTop, CSSValueBottom>(state, pair.second())); |
| 916 } | 921 } |
| 917 | 922 |
| 918 LengthPoint StyleBuilderConverter::convertPositionOrAuto( | 923 LengthPoint StyleBuilderConverter::convertPositionOrAuto( |
| 919 StyleResolverState& state, | 924 StyleResolverState& state, |
| 920 const CSSValue& value) { | 925 const CSSValue& value) { |
| 921 if (value.isValuePair()) | 926 if (value.isValuePair()) |
| 922 return convertPosition(state, value); | 927 return convertPosition(state, value); |
| 923 DCHECK(toCSSPrimitiveValue(value).getValueID() == CSSValueAuto); | 928 DCHECK(toCSSIdentifierValue(value).getValueID() == CSSValueAuto); |
| 924 return LengthPoint(Length(Auto), Length(Auto)); | 929 return LengthPoint(Length(Auto), Length(Auto)); |
| 925 } | 930 } |
| 926 | 931 |
| 927 static float convertPerspectiveLength(StyleResolverState& state, | 932 static float convertPerspectiveLength(StyleResolverState& state, |
| 928 const CSSPrimitiveValue& primitiveValue) { | 933 const CSSPrimitiveValue& primitiveValue) { |
| 929 return std::max( | 934 return std::max( |
| 930 primitiveValue.computeLength<float>(state.cssToLengthConversionData()), | 935 primitiveValue.computeLength<float>(state.cssToLengthConversionData()), |
| 931 0.0f); | 936 0.0f); |
| 932 } | 937 } |
| 933 | 938 |
| 934 float StyleBuilderConverter::convertPerspective(StyleResolverState& state, | 939 float StyleBuilderConverter::convertPerspective(StyleResolverState& state, |
| 935 const CSSValue& value) { | 940 const CSSValue& value) { |
| 936 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 941 if (value.isIdentifierValue() && |
| 937 | 942 toCSSIdentifierValue(value).getValueID() == CSSValueNone) |
| 938 if (primitiveValue.getValueID() == CSSValueNone) | |
| 939 return ComputedStyle::initialPerspective(); | 943 return ComputedStyle::initialPerspective(); |
| 940 return convertPerspectiveLength(state, primitiveValue); | 944 return convertPerspectiveLength(state, toCSSPrimitiveValue(value)); |
| 941 } | 945 } |
| 942 | 946 |
| 943 EPaintOrder StyleBuilderConverter::convertPaintOrder( | 947 EPaintOrder StyleBuilderConverter::convertPaintOrder( |
| 944 StyleResolverState&, | 948 StyleResolverState&, |
| 945 const CSSValue& cssPaintOrder) { | 949 const CSSValue& cssPaintOrder) { |
| 946 if (cssPaintOrder.isValueList()) { | 950 if (cssPaintOrder.isValueList()) { |
| 947 const CSSValueList& orderTypeList = toCSSValueList(cssPaintOrder); | 951 const CSSValueList& orderTypeList = toCSSValueList(cssPaintOrder); |
| 948 switch (toCSSPrimitiveValue(orderTypeList.item(0)).getValueID()) { | 952 switch (toCSSIdentifierValue(orderTypeList.item(0)).getValueID()) { |
| 949 case CSSValueFill: | 953 case CSSValueFill: |
| 950 return orderTypeList.length() > 1 ? PaintOrderFillMarkersStroke | 954 return orderTypeList.length() > 1 ? PaintOrderFillMarkersStroke |
| 951 : PaintOrderFillStrokeMarkers; | 955 : PaintOrderFillStrokeMarkers; |
| 952 case CSSValueStroke: | 956 case CSSValueStroke: |
| 953 return orderTypeList.length() > 1 ? PaintOrderStrokeMarkersFill | 957 return orderTypeList.length() > 1 ? PaintOrderStrokeMarkersFill |
| 954 : PaintOrderStrokeFillMarkers; | 958 : PaintOrderStrokeFillMarkers; |
| 955 case CSSValueMarkers: | 959 case CSSValueMarkers: |
| 956 return orderTypeList.length() > 1 ? PaintOrderMarkersStrokeFill | 960 return orderTypeList.length() > 1 ? PaintOrderMarkersStrokeFill |
| 957 : PaintOrderMarkersFillStroke; | 961 : PaintOrderMarkersFillStroke; |
| 958 default: | 962 default: |
| 959 ASSERT_NOT_REACHED(); | 963 ASSERT_NOT_REACHED(); |
| 960 return PaintOrderNormal; | 964 return PaintOrderNormal; |
| 961 } | 965 } |
| 962 } | 966 } |
| 963 | 967 |
| 964 return PaintOrderNormal; | 968 return PaintOrderNormal; |
| 965 } | 969 } |
| 966 | 970 |
| 967 Length StyleBuilderConverter::convertQuirkyLength(StyleResolverState& state, | 971 Length StyleBuilderConverter::convertQuirkyLength(StyleResolverState& state, |
| 968 const CSSValue& value) { | 972 const CSSValue& value) { |
| 969 Length length = convertLengthOrAuto(state, value); | 973 Length length = convertLengthOrAuto(state, value); |
| 970 // This is only for margins which use __qem | 974 // This is only for margins which use __qem |
| 971 length.setQuirk(toCSSPrimitiveValue(value).isQuirkyEms()); | 975 length.setQuirk(value.isPrimitiveValue() && |
| 976 toCSSPrimitiveValue(value).isQuirkyEms()); |
| 972 return length; | 977 return length; |
| 973 } | 978 } |
| 974 | 979 |
| 975 PassRefPtr<QuotesData> StyleBuilderConverter::convertQuotes( | 980 PassRefPtr<QuotesData> StyleBuilderConverter::convertQuotes( |
| 976 StyleResolverState&, | 981 StyleResolverState&, |
| 977 const CSSValue& value) { | 982 const CSSValue& value) { |
| 978 if (value.isValueList()) { | 983 if (value.isValueList()) { |
| 979 const CSSValueList& list = toCSSValueList(value); | 984 const CSSValueList& list = toCSSValueList(value); |
| 980 RefPtr<QuotesData> quotes = QuotesData::create(); | 985 RefPtr<QuotesData> quotes = QuotesData::create(); |
| 981 for (size_t i = 0; i < list.length(); i += 2) { | 986 for (size_t i = 0; i < list.length(); i += 2) { |
| 982 String startQuote = toCSSStringValue(list.item(i)).value(); | 987 String startQuote = toCSSStringValue(list.item(i)).value(); |
| 983 String endQuote = toCSSStringValue(list.item(i + 1)).value(); | 988 String endQuote = toCSSStringValue(list.item(i + 1)).value(); |
| 984 quotes->addPair(std::make_pair(startQuote, endQuote)); | 989 quotes->addPair(std::make_pair(startQuote, endQuote)); |
| 985 } | 990 } |
| 986 return quotes.release(); | 991 return quotes.release(); |
| 987 } | 992 } |
| 988 ASSERT(value.isPrimitiveValue() && | 993 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); |
| 989 toCSSPrimitiveValue(value).getValueID() == CSSValueNone); | |
| 990 return QuotesData::create(); | 994 return QuotesData::create(); |
| 991 } | 995 } |
| 992 | 996 |
| 993 LengthSize StyleBuilderConverter::convertRadius(StyleResolverState& state, | 997 LengthSize StyleBuilderConverter::convertRadius(StyleResolverState& state, |
| 994 const CSSValue& value) { | 998 const CSSValue& value) { |
| 995 const CSSValuePair& pair = toCSSValuePair(value); | 999 const CSSValuePair& pair = toCSSValuePair(value); |
| 996 Length radiusWidth = toCSSPrimitiveValue(pair.first()) | 1000 Length radiusWidth = toCSSPrimitiveValue(pair.first()) |
| 997 .convertToLength(state.cssToLengthConversionData()); | 1001 .convertToLength(state.cssToLengthConversionData()); |
| 998 Length radiusHeight = toCSSPrimitiveValue(pair.second()) | 1002 Length radiusHeight = toCSSPrimitiveValue(pair.second()) |
| 999 .convertToLength(state.cssToLengthConversionData()); | 1003 .convertToLength(state.cssToLengthConversionData()); |
| 1000 return LengthSize(radiusWidth, radiusHeight); | 1004 return LengthSize(radiusWidth, radiusHeight); |
| 1001 } | 1005 } |
| 1002 | 1006 |
| 1003 PassRefPtr<ShadowList> StyleBuilderConverter::convertShadow( | 1007 PassRefPtr<ShadowList> StyleBuilderConverter::convertShadow( |
| 1004 StyleResolverState& state, | 1008 StyleResolverState& state, |
| 1005 const CSSValue& value) { | 1009 const CSSValue& value) { |
| 1006 if (value.isPrimitiveValue()) { | 1010 if (value.isIdentifierValue()) { |
| 1007 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNone); | 1011 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); |
| 1008 return PassRefPtr<ShadowList>(); | 1012 return PassRefPtr<ShadowList>(); |
| 1009 } | 1013 } |
| 1010 | 1014 |
| 1011 const CSSValueList& valueList = toCSSValueList(value); | 1015 const CSSValueList& valueList = toCSSValueList(value); |
| 1012 size_t shadowCount = valueList.length(); | 1016 size_t shadowCount = valueList.length(); |
| 1013 ShadowDataVector shadows; | 1017 ShadowDataVector shadows; |
| 1014 for (size_t i = 0; i < shadowCount; ++i) { | 1018 for (size_t i = 0; i < shadowCount; ++i) { |
| 1015 const CSSShadowValue& item = toCSSShadowValue(valueList.item(i)); | 1019 const CSSShadowValue& item = toCSSShadowValue(valueList.item(i)); |
| 1016 float x = item.x->computeLength<float>(state.cssToLengthConversionData()); | 1020 float x = item.x->computeLength<float>(state.cssToLengthConversionData()); |
| 1017 float y = item.y->computeLength<float>(state.cssToLengthConversionData()); | 1021 float y = item.y->computeLength<float>(state.cssToLengthConversionData()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1030 if (item.color) | 1034 if (item.color) |
| 1031 color = convertStyleColor(state, *item.color); | 1035 color = convertStyleColor(state, *item.color); |
| 1032 shadows.append( | 1036 shadows.append( |
| 1033 ShadowData(FloatPoint(x, y), blur, spread, shadowStyle, color)); | 1037 ShadowData(FloatPoint(x, y), blur, spread, shadowStyle, color)); |
| 1034 } | 1038 } |
| 1035 return ShadowList::adopt(shadows); | 1039 return ShadowList::adopt(shadows); |
| 1036 } | 1040 } |
| 1037 | 1041 |
| 1038 ShapeValue* StyleBuilderConverter::convertShapeValue(StyleResolverState& state, | 1042 ShapeValue* StyleBuilderConverter::convertShapeValue(StyleResolverState& state, |
| 1039 const CSSValue& value) { | 1043 const CSSValue& value) { |
| 1040 if (value.isPrimitiveValue()) { | 1044 if (value.isIdentifierValue()) { |
| 1041 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNone); | 1045 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); |
| 1042 return nullptr; | 1046 return nullptr; |
| 1043 } | 1047 } |
| 1044 | 1048 |
| 1045 if (value.isImageValue() || value.isImageGeneratorValue() || | 1049 if (value.isImageValue() || value.isImageGeneratorValue() || |
| 1046 value.isImageSetValue()) | 1050 value.isImageSetValue()) |
| 1047 return ShapeValue::createImageValue( | 1051 return ShapeValue::createImageValue( |
| 1048 state.styleImage(CSSPropertyShapeOutside, value)); | 1052 state.styleImage(CSSPropertyShapeOutside, value)); |
| 1049 | 1053 |
| 1050 RefPtr<BasicShape> shape; | 1054 RefPtr<BasicShape> shape; |
| 1051 CSSBoxType cssBox = BoxMissing; | 1055 CSSBoxType cssBox = BoxMissing; |
| 1052 const CSSValueList& valueList = toCSSValueList(value); | 1056 const CSSValueList& valueList = toCSSValueList(value); |
| 1053 for (unsigned i = 0; i < valueList.length(); ++i) { | 1057 for (unsigned i = 0; i < valueList.length(); ++i) { |
| 1054 const CSSValue& value = valueList.item(i); | 1058 const CSSValue& value = valueList.item(i); |
| 1055 if (value.isBasicShapeValue()) { | 1059 if (value.isBasicShapeValue()) { |
| 1056 shape = basicShapeForValue(state, value); | 1060 shape = basicShapeForValue(state, value); |
| 1057 } else { | 1061 } else { |
| 1058 cssBox = toCSSPrimitiveValue(value).convertTo<CSSBoxType>(); | 1062 cssBox = toCSSIdentifierValue(value).convertTo<CSSBoxType>(); |
| 1059 } | 1063 } |
| 1060 } | 1064 } |
| 1061 | 1065 |
| 1062 if (shape) | 1066 if (shape) |
| 1063 return ShapeValue::createShapeValue(shape.release(), cssBox); | 1067 return ShapeValue::createShapeValue(shape.release(), cssBox); |
| 1064 | 1068 |
| 1065 ASSERT(cssBox != BoxMissing); | 1069 ASSERT(cssBox != BoxMissing); |
| 1066 return ShapeValue::createBoxShapeValue(cssBox); | 1070 return ShapeValue::createBoxShapeValue(cssBox); |
| 1067 } | 1071 } |
| 1068 | 1072 |
| 1069 float StyleBuilderConverter::convertSpacing(StyleResolverState& state, | 1073 float StyleBuilderConverter::convertSpacing(StyleResolverState& state, |
| 1070 const CSSValue& value) { | 1074 const CSSValue& value) { |
| 1071 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 1075 if (value.isIdentifierValue() && |
| 1072 if (primitiveValue.getValueID() == CSSValueNormal) | 1076 toCSSIdentifierValue(value).getValueID() == CSSValueNormal) |
| 1073 return 0; | 1077 return 0; |
| 1074 return primitiveValue.computeLength<float>(state.cssToLengthConversionData()); | 1078 return toCSSPrimitiveValue(value).computeLength<float>( |
| 1079 state.cssToLengthConversionData()); |
| 1075 } | 1080 } |
| 1076 | 1081 |
| 1077 PassRefPtr<SVGDashArray> StyleBuilderConverter::convertStrokeDasharray( | 1082 PassRefPtr<SVGDashArray> StyleBuilderConverter::convertStrokeDasharray( |
| 1078 StyleResolverState& state, | 1083 StyleResolverState& state, |
| 1079 const CSSValue& value) { | 1084 const CSSValue& value) { |
| 1080 if (!value.isValueList()) | 1085 if (!value.isValueList()) |
| 1081 return SVGComputedStyle::initialStrokeDashArray(); | 1086 return SVGComputedStyle::initialStrokeDashArray(); |
| 1082 | 1087 |
| 1083 const CSSValueList& dashes = toCSSValueList(value); | 1088 const CSSValueList& dashes = toCSSValueList(value); |
| 1084 | 1089 |
| 1085 RefPtr<SVGDashArray> array = SVGDashArray::create(); | 1090 RefPtr<SVGDashArray> array = SVGDashArray::create(); |
| 1086 size_t length = dashes.length(); | 1091 size_t length = dashes.length(); |
| 1087 for (size_t i = 0; i < length; ++i) { | 1092 for (size_t i = 0; i < length; ++i) { |
| 1088 array->append(convertLength(state, toCSSPrimitiveValue(dashes.item(i)))); | 1093 array->append(convertLength(state, toCSSPrimitiveValue(dashes.item(i)))); |
| 1089 } | 1094 } |
| 1090 | 1095 |
| 1091 return array.release(); | 1096 return array.release(); |
| 1092 } | 1097 } |
| 1093 | 1098 |
| 1094 StyleColor StyleBuilderConverter::convertStyleColor(StyleResolverState& state, | 1099 StyleColor StyleBuilderConverter::convertStyleColor(StyleResolverState& state, |
| 1095 const CSSValue& value, | 1100 const CSSValue& value, |
| 1096 bool forVisitedLink) { | 1101 bool forVisitedLink) { |
| 1097 if (value.isPrimitiveValue() && | 1102 if (value.isIdentifierValue() && |
| 1098 toCSSPrimitiveValue(value).getValueID() == CSSValueCurrentcolor) | 1103 toCSSIdentifierValue(value).getValueID() == CSSValueCurrentcolor) |
| 1099 return StyleColor::currentColor(); | 1104 return StyleColor::currentColor(); |
| 1100 return state.document().textLinkColors().colorFromCSSValue(value, Color(), | 1105 return state.document().textLinkColors().colorFromCSSValue(value, Color(), |
| 1101 forVisitedLink); | 1106 forVisitedLink); |
| 1102 } | 1107 } |
| 1103 | 1108 |
| 1104 float StyleBuilderConverter::convertTextStrokeWidth(StyleResolverState& state, | 1109 float StyleBuilderConverter::convertTextStrokeWidth(StyleResolverState& state, |
| 1105 const CSSValue& value) { | 1110 const CSSValue& value) { |
| 1106 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 1111 if (value.isIdentifierValue() && toCSSIdentifierValue(value).getValueID()) { |
| 1107 if (primitiveValue.getValueID()) { | |
| 1108 float multiplier = convertLineWidth<float>(state, value); | 1112 float multiplier = convertLineWidth<float>(state, value); |
| 1109 return CSSPrimitiveValue::create(multiplier / 48, | 1113 return CSSPrimitiveValue::create(multiplier / 48, |
| 1110 CSSPrimitiveValue::UnitType::Ems) | 1114 CSSPrimitiveValue::UnitType::Ems) |
| 1111 ->computeLength<float>(state.cssToLengthConversionData()); | 1115 ->computeLength<float>(state.cssToLengthConversionData()); |
| 1112 } | 1116 } |
| 1113 return primitiveValue.computeLength<float>(state.cssToLengthConversionData()); | 1117 return toCSSPrimitiveValue(value).computeLength<float>( |
| 1118 state.cssToLengthConversionData()); |
| 1114 } | 1119 } |
| 1115 | 1120 |
| 1116 TextSizeAdjust StyleBuilderConverter::convertTextSizeAdjust( | 1121 TextSizeAdjust StyleBuilderConverter::convertTextSizeAdjust( |
| 1117 StyleResolverState& state, | 1122 StyleResolverState& state, |
| 1118 const CSSValue& value) { | 1123 const CSSValue& value) { |
| 1124 if (value.isIdentifierValue() && |
| 1125 toCSSIdentifierValue(value).getValueID() == CSSValueNone) |
| 1126 return TextSizeAdjust::adjustNone(); |
| 1127 if (value.isIdentifierValue() && |
| 1128 toCSSIdentifierValue(value).getValueID() == CSSValueAuto) |
| 1129 return TextSizeAdjust::adjustAuto(); |
| 1119 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 1130 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 1120 if (primitiveValue.getValueID() == CSSValueNone) | |
| 1121 return TextSizeAdjust::adjustNone(); | |
| 1122 if (primitiveValue.getValueID() == CSSValueAuto) | |
| 1123 return TextSizeAdjust::adjustAuto(); | |
| 1124 DCHECK(primitiveValue.isPercentage()); | 1131 DCHECK(primitiveValue.isPercentage()); |
| 1125 return TextSizeAdjust(primitiveValue.getFloatValue() / 100.0f); | 1132 return TextSizeAdjust(primitiveValue.getFloatValue() / 100.0f); |
| 1126 } | 1133 } |
| 1127 | 1134 |
| 1128 TransformOrigin StyleBuilderConverter::convertTransformOrigin( | 1135 TransformOrigin StyleBuilderConverter::convertTransformOrigin( |
| 1129 StyleResolverState& state, | 1136 StyleResolverState& state, |
| 1130 const CSSValue& value) { | 1137 const CSSValue& value) { |
| 1131 const CSSValueList& list = toCSSValueList(value); | 1138 const CSSValueList& list = toCSSValueList(value); |
| 1132 ASSERT(list.length() == 3); | 1139 DCHECK_EQ(list.length(), 3U); |
| 1140 DCHECK(list.item(0).isPrimitiveValue() || list.item(0).isIdentifierValue()); |
| 1141 DCHECK(list.item(1).isPrimitiveValue() || list.item(1).isIdentifierValue()); |
| 1142 DCHECK(list.item(2).isPrimitiveValue()); |
| 1133 | 1143 |
| 1134 const CSSPrimitiveValue& primitiveValueX = toCSSPrimitiveValue(list.item(0)); | 1144 return TransformOrigin( |
| 1135 const CSSPrimitiveValue& primitiveValueY = toCSSPrimitiveValue(list.item(1)); | 1145 convertPositionLength<CSSValueLeft, CSSValueRight>(state, list.item(0)), |
| 1136 const CSSPrimitiveValue& primitiveValueZ = toCSSPrimitiveValue(list.item(2)); | 1146 convertPositionLength<CSSValueTop, CSSValueBottom>(state, list.item(1)), |
| 1137 | 1147 StyleBuilderConverter::convertComputedLength<float>(state, list.item(2))); |
| 1138 return TransformOrigin(convertPositionLength<CSSValueLeft, CSSValueRight>( | |
| 1139 state, primitiveValueX), | |
| 1140 convertPositionLength<CSSValueTop, CSSValueBottom>( | |
| 1141 state, primitiveValueY), | |
| 1142 StyleBuilderConverter::convertComputedLength<float>( | |
| 1143 state, primitiveValueZ)); | |
| 1144 } | 1148 } |
| 1145 | 1149 |
| 1146 ScrollSnapPoints StyleBuilderConverter::convertSnapPoints( | 1150 ScrollSnapPoints StyleBuilderConverter::convertSnapPoints( |
| 1147 StyleResolverState& state, | 1151 StyleResolverState& state, |
| 1148 const CSSValue& value) { | 1152 const CSSValue& value) { |
| 1149 // Handles: none | repeat(<length>) | 1153 // Handles: none | repeat(<length>) |
| 1150 ScrollSnapPoints points; | 1154 ScrollSnapPoints points; |
| 1151 points.hasRepeat = false; | 1155 points.hasRepeat = false; |
| 1152 | 1156 |
| 1153 if (!value.isFunctionValue()) | 1157 if (!value.isFunctionValue()) |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1233 if (list.length() == 3) | 1237 if (list.length() == 3) |
| 1234 sz = toCSSPrimitiveValue(list.item(2)).getDoubleValue(); | 1238 sz = toCSSPrimitiveValue(list.item(2)).getDoubleValue(); |
| 1235 | 1239 |
| 1236 return ScaleTransformOperation::create(sx, sy, sz, | 1240 return ScaleTransformOperation::create(sx, sy, sz, |
| 1237 TransformOperation::Scale3D); | 1241 TransformOperation::Scale3D); |
| 1238 } | 1242 } |
| 1239 | 1243 |
| 1240 RespectImageOrientationEnum StyleBuilderConverter::convertImageOrientation( | 1244 RespectImageOrientationEnum StyleBuilderConverter::convertImageOrientation( |
| 1241 StyleResolverState& state, | 1245 StyleResolverState& state, |
| 1242 const CSSValue& value) { | 1246 const CSSValue& value) { |
| 1243 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 1247 return value.isIdentifierValue() && |
| 1244 return primitiveValue.getValueID() == CSSValueFromImage | 1248 toCSSIdentifierValue(value).getValueID() == CSSValueFromImage |
| 1245 ? RespectImageOrientation | 1249 ? RespectImageOrientation |
| 1246 : DoNotRespectImageOrientation; | 1250 : DoNotRespectImageOrientation; |
| 1247 } | 1251 } |
| 1248 | 1252 |
| 1249 PassRefPtr<StylePath> StyleBuilderConverter::convertPathOrNone( | 1253 PassRefPtr<StylePath> StyleBuilderConverter::convertPathOrNone( |
| 1250 StyleResolverState& state, | 1254 StyleResolverState& state, |
| 1251 const CSSValue& value) { | 1255 const CSSValue& value) { |
| 1252 if (value.isPathValue()) | 1256 if (value.isPathValue()) |
| 1253 return toCSSPathValue(value).stylePath(); | 1257 return toCSSPathValue(value).stylePath(); |
| 1254 ASSERT(value.isPrimitiveValue() && | 1258 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); |
| 1255 toCSSPrimitiveValue(value).getValueID() == CSSValueNone); | |
| 1256 return nullptr; | 1259 return nullptr; |
| 1257 } | 1260 } |
| 1258 | 1261 |
| 1259 const CSSValue& StyleBuilderConverter::convertRegisteredPropertyValue( | 1262 const CSSValue& StyleBuilderConverter::convertRegisteredPropertyValue( |
| 1260 const StyleResolverState& state, | 1263 const StyleResolverState& state, |
| 1261 const CSSValue& value) { | 1264 const CSSValue& value) { |
| 1262 // TODO(timloh): Images and transform-function values can also contain lengths
. | 1265 // TODO(timloh): Images and transform-function values can also contain lengths
. |
| 1263 if (value.isValueList()) { | 1266 if (value.isValueList()) { |
| 1264 CSSValueList* newList = CSSValueList::createSpaceSeparated(); | 1267 CSSValueList* newList = CSSValueList::createSpaceSeparated(); |
| 1265 for (const CSSValue* innerValue : toCSSValueList(value)) | 1268 for (const CSSValue* innerValue : toCSSValueList(value)) |
| 1266 newList->append(convertRegisteredPropertyValue(state, *innerValue)); | 1269 newList->append(convertRegisteredPropertyValue(state, *innerValue)); |
| 1267 return *newList; | 1270 return *newList; |
| 1268 } | 1271 } |
| 1269 | 1272 |
| 1270 if (value.isPrimitiveValue()) { | 1273 if (value.isPrimitiveValue()) { |
| 1271 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 1274 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 1272 if (primitiveValue.isCalculated() || | 1275 if (primitiveValue.isCalculated() || |
| 1273 CSSPrimitiveValue::isRelativeUnit( | 1276 CSSPrimitiveValue::isRelativeUnit( |
| 1274 primitiveValue.typeWithCalcResolved())) { | 1277 primitiveValue.typeWithCalcResolved())) { |
| 1275 // Instead of the actual zoom, use 1 to avoid potential rounding errors | 1278 // Instead of the actual zoom, use 1 to avoid potential rounding errors |
| 1276 Length length = primitiveValue.convertToLength( | 1279 Length length = primitiveValue.convertToLength( |
| 1277 state.cssToLengthConversionData().copyWithAdjustedZoom(1)); | 1280 state.cssToLengthConversionData().copyWithAdjustedZoom(1)); |
| 1278 return *CSSPrimitiveValue::create(length, 1); | 1281 return *CSSPrimitiveValue::create(length, 1); |
| 1279 } | 1282 } |
| 1280 } | 1283 } |
| 1281 return value; | 1284 return value; |
| 1282 } | 1285 } |
| 1283 | 1286 |
| 1284 } // namespace blink | 1287 } // namespace blink |
| OLD | NEW |