| 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() || value.isIdentifierValue()) |
| 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 StyleOffsetRotation StyleBuilderConverter::convertOffsetRotation(StyleResolverSt
ate&, const CSSValue& value) | 751 StyleOffsetRotation StyleBuilderConverter::convertOffsetRotation(StyleResolverSt
ate&, const CSSValue& value) |
| 753 { | 752 { |
| 754 return convertOffsetRotation(value); | 753 return convertOffsetRotation(value); |
| 755 } | 754 } |
| 756 | 755 |
| 757 StyleOffsetRotation StyleBuilderConverter::convertOffsetRotation(const CSSValue&
value) | 756 StyleOffsetRotation StyleBuilderConverter::convertOffsetRotation(const CSSValue&
value) |
| 758 { | 757 { |
| 759 StyleOffsetRotation result(0, OffsetRotationFixed); | 758 StyleOffsetRotation result(0, OffsetRotationFixed); |
| 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 = OffsetRotationAuto; | 764 result.type = OffsetRotationAuto; |
| 767 } else if (primitiveValue.getValueID() == CSSValueReverse) { | 765 } else if (item->isIdentifierValue() && toCSSIdentifierValue(*item).getV
alueID() == CSSValueReverse) { |
| 768 result.type = OffsetRotationAuto; | 766 result.type = OffsetRotationAuto; |
| 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 LengthPoint StyleBuilderConverter::convertPositionOrAuto(StyleResolverState& sta
te, const CSSValue& value) | 815 LengthPoint StyleBuilderConverter::convertPositionOrAuto(StyleResolverState& sta
te, const CSSValue& value) |
| 818 { | 816 { |
| 819 if (value.isValuePair()) | 817 if (value.isValuePair()) |
| 820 return convertPosition(state, value); | 818 return convertPosition(state, value); |
| 821 DCHECK(toCSSPrimitiveValue(value).getValueID() == CSSValueAuto); | 819 DCHECK(toCSSIdentifierValue(value).getValueID() == CSSValueAuto); |
| 822 return LengthPoint(Length(Auto), Length(Auto)); | 820 return LengthPoint(Length(Auto), Length(Auto)); |
| 823 } | 821 } |
| 824 | 822 |
| 825 static float convertPerspectiveLength(StyleResolverState& state, const CSSPrimit
iveValue& primitiveValue) | 823 static float convertPerspectiveLength(StyleResolverState& state, const CSSPrimit
iveValue& primitiveValue) |
| 826 { | 824 { |
| 827 return std::max(primitiveValue.computeLength<float>(state.cssToLengthConvers
ionData()), 0.0f); | 825 return std::max(primitiveValue.computeLength<float>(state.cssToLengthConvers
ionData()), 0.0f); |
| 828 } | 826 } |
| 829 | 827 |
| 830 float StyleBuilderConverter::convertPerspective(StyleResolverState& state, const
CSSValue& value) | 828 float StyleBuilderConverter::convertPerspective(StyleResolverState& state, const
CSSValue& value) |
| 831 { | 829 { |
| 832 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 830 if (value.isIdentifierValue() && toCSSIdentifierValue(value).getValueID() ==
CSSValueNone) |
| 833 | |
| 834 if (primitiveValue.getValueID() == CSSValueNone) | |
| 835 return ComputedStyle::initialPerspective(); | 831 return ComputedStyle::initialPerspective(); |
| 836 return convertPerspectiveLength(state, primitiveValue); | 832 return convertPerspectiveLength(state, toCSSPrimitiveValue(value)); |
| 837 } | 833 } |
| 838 | 834 |
| 839 EPaintOrder StyleBuilderConverter::convertPaintOrder(StyleResolverState&, const
CSSValue& cssPaintOrder) | 835 EPaintOrder StyleBuilderConverter::convertPaintOrder(StyleResolverState&, const
CSSValue& cssPaintOrder) |
| 840 { | 836 { |
| 841 if (cssPaintOrder.isValueList()) { | 837 if (cssPaintOrder.isValueList()) { |
| 842 const CSSValueList& orderTypeList = toCSSValueList(cssPaintOrder); | 838 const CSSValueList& orderTypeList = toCSSValueList(cssPaintOrder); |
| 843 switch (toCSSPrimitiveValue(orderTypeList.item(0)).getValueID()) { | 839 switch (toCSSIdentifierValue(orderTypeList.item(0)).getValueID()) { |
| 844 case CSSValueFill: | 840 case CSSValueFill: |
| 845 return orderTypeList.length() > 1 ? PaintOrderFillMarkersStroke : Pa
intOrderFillStrokeMarkers; | 841 return orderTypeList.length() > 1 ? PaintOrderFillMarkersStroke : Pa
intOrderFillStrokeMarkers; |
| 846 case CSSValueStroke: | 842 case CSSValueStroke: |
| 847 return orderTypeList.length() > 1 ? PaintOrderStrokeMarkersFill : Pa
intOrderStrokeFillMarkers; | 843 return orderTypeList.length() > 1 ? PaintOrderStrokeMarkersFill : Pa
intOrderStrokeFillMarkers; |
| 848 case CSSValueMarkers: | 844 case CSSValueMarkers: |
| 849 return orderTypeList.length() > 1 ? PaintOrderMarkersStrokeFill : Pa
intOrderMarkersFillStroke; | 845 return orderTypeList.length() > 1 ? PaintOrderMarkersStrokeFill : Pa
intOrderMarkersFillStroke; |
| 850 default: | 846 default: |
| 851 ASSERT_NOT_REACHED(); | 847 ASSERT_NOT_REACHED(); |
| 852 return PaintOrderNormal; | 848 return PaintOrderNormal; |
| 853 } | 849 } |
| 854 } | 850 } |
| 855 | 851 |
| 856 return PaintOrderNormal; | 852 return PaintOrderNormal; |
| 857 } | 853 } |
| 858 | 854 |
| 859 Length StyleBuilderConverter::convertQuirkyLength(StyleResolverState& state, con
st CSSValue& value) | 855 Length StyleBuilderConverter::convertQuirkyLength(StyleResolverState& state, con
st CSSValue& value) |
| 860 { | 856 { |
| 861 Length length = convertLengthOrAuto(state, value); | 857 Length length = convertLengthOrAuto(state, value); |
| 862 // This is only for margins which use __qem | 858 // This is only for margins which use __qem |
| 863 length.setQuirk(toCSSPrimitiveValue(value).isQuirkyEms()); | 859 length.setQuirk(value.isPrimitiveValue() && toCSSPrimitiveValue(value).isQui
rkyEms()); |
| 864 return length; | 860 return length; |
| 865 } | 861 } |
| 866 | 862 |
| 867 PassRefPtr<QuotesData> StyleBuilderConverter::convertQuotes(StyleResolverState&,
const CSSValue& value) | 863 PassRefPtr<QuotesData> StyleBuilderConverter::convertQuotes(StyleResolverState&,
const CSSValue& value) |
| 868 { | 864 { |
| 869 if (value.isValueList()) { | 865 if (value.isValueList()) { |
| 870 const CSSValueList& list = toCSSValueList(value); | 866 const CSSValueList& list = toCSSValueList(value); |
| 871 RefPtr<QuotesData> quotes = QuotesData::create(); | 867 RefPtr<QuotesData> quotes = QuotesData::create(); |
| 872 for (size_t i = 0; i < list.length(); i += 2) { | 868 for (size_t i = 0; i < list.length(); i += 2) { |
| 873 String startQuote = toCSSStringValue(list.item(i)).value(); | 869 String startQuote = toCSSStringValue(list.item(i)).value(); |
| 874 String endQuote = toCSSStringValue(list.item(i + 1)).value(); | 870 String endQuote = toCSSStringValue(list.item(i + 1)).value(); |
| 875 quotes->addPair(std::make_pair(startQuote, endQuote)); | 871 quotes->addPair(std::make_pair(startQuote, endQuote)); |
| 876 } | 872 } |
| 877 return quotes.release(); | 873 return quotes.release(); |
| 878 } | 874 } |
| 879 ASSERT(value.isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID() =
= CSSValueNone); | 875 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); |
| 880 return QuotesData::create(); | 876 return QuotesData::create(); |
| 881 } | 877 } |
| 882 | 878 |
| 883 LengthSize StyleBuilderConverter::convertRadius(StyleResolverState& state, const
CSSValue& value) | 879 LengthSize StyleBuilderConverter::convertRadius(StyleResolverState& state, const
CSSValue& value) |
| 884 { | 880 { |
| 885 const CSSValuePair& pair = toCSSValuePair(value); | 881 const CSSValuePair& pair = toCSSValuePair(value); |
| 886 Length radiusWidth = toCSSPrimitiveValue(pair.first()).convertToLength(state
.cssToLengthConversionData()); | 882 Length radiusWidth = toCSSPrimitiveValue(pair.first()).convertToLength(state
.cssToLengthConversionData()); |
| 887 Length radiusHeight = toCSSPrimitiveValue(pair.second()).convertToLength(sta
te.cssToLengthConversionData()); | 883 Length radiusHeight = toCSSPrimitiveValue(pair.second()).convertToLength(sta
te.cssToLengthConversionData()); |
| 888 return LengthSize(radiusWidth, radiusHeight); | 884 return LengthSize(radiusWidth, radiusHeight); |
| 889 } | 885 } |
| 890 | 886 |
| 891 PassRefPtr<ShadowList> StyleBuilderConverter::convertShadow(StyleResolverState&
state, const CSSValue& value) | 887 PassRefPtr<ShadowList> StyleBuilderConverter::convertShadow(StyleResolverState&
state, const CSSValue& value) |
| 892 { | 888 { |
| 893 if (value.isPrimitiveValue()) { | 889 if (value.isIdentifierValue()) { |
| 894 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNone); | 890 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); |
| 895 return PassRefPtr<ShadowList>(); | 891 return PassRefPtr<ShadowList>(); |
| 896 } | 892 } |
| 897 | 893 |
| 898 const CSSValueList& valueList = toCSSValueList(value); | 894 const CSSValueList& valueList = toCSSValueList(value); |
| 899 size_t shadowCount = valueList.length(); | 895 size_t shadowCount = valueList.length(); |
| 900 ShadowDataVector shadows; | 896 ShadowDataVector shadows; |
| 901 for (size_t i = 0; i < shadowCount; ++i) { | 897 for (size_t i = 0; i < shadowCount; ++i) { |
| 902 const CSSShadowValue& item = toCSSShadowValue(valueList.item(i)); | 898 const CSSShadowValue& item = toCSSShadowValue(valueList.item(i)); |
| 903 float x = item.x->computeLength<float>(state.cssToLengthConversionData()
); | 899 float x = item.x->computeLength<float>(state.cssToLengthConversionData()
); |
| 904 float y = item.y->computeLength<float>(state.cssToLengthConversionData()
); | 900 float y = item.y->computeLength<float>(state.cssToLengthConversionData()
); |
| 905 float blur = item.blur ? item.blur->computeLength<float>(state.cssToLeng
thConversionData()) : 0; | 901 float blur = item.blur ? item.blur->computeLength<float>(state.cssToLeng
thConversionData()) : 0; |
| 906 float spread = item.spread ? item.spread->computeLength<float>(state.css
ToLengthConversionData()) : 0; | 902 float spread = item.spread ? item.spread->computeLength<float>(state.css
ToLengthConversionData()) : 0; |
| 907 ShadowStyle shadowStyle = item.style && item.style->getValueID() == CSSV
alueInset ? Inset : Normal; | 903 ShadowStyle shadowStyle = item.style && item.style->getValueID() == CSSV
alueInset ? Inset : Normal; |
| 908 StyleColor color = StyleColor::currentColor(); | 904 StyleColor color = StyleColor::currentColor(); |
| 909 if (item.color) | 905 if (item.color) |
| 910 color = convertStyleColor(state, *item.color); | 906 color = convertStyleColor(state, *item.color); |
| 911 shadows.append(ShadowData(FloatPoint(x, y), blur, spread, shadowStyle, c
olor)); | 907 shadows.append(ShadowData(FloatPoint(x, y), blur, spread, shadowStyle, c
olor)); |
| 912 } | 908 } |
| 913 return ShadowList::adopt(shadows); | 909 return ShadowList::adopt(shadows); |
| 914 } | 910 } |
| 915 | 911 |
| 916 ShapeValue* StyleBuilderConverter::convertShapeValue(StyleResolverState& state,
const CSSValue& value) | 912 ShapeValue* StyleBuilderConverter::convertShapeValue(StyleResolverState& state,
const CSSValue& value) |
| 917 { | 913 { |
| 918 if (value.isPrimitiveValue()) { | 914 if (value.isIdentifierValue()) { |
| 919 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNone); | 915 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); |
| 920 return nullptr; | 916 return nullptr; |
| 921 } | 917 } |
| 922 | 918 |
| 923 if (value.isImageValue() || value.isImageGeneratorValue() || value.isImageSe
tValue()) | 919 if (value.isImageValue() || value.isImageGeneratorValue() || value.isImageSe
tValue()) |
| 924 return ShapeValue::createImageValue(state.styleImage(CSSPropertyShapeOut
side, value)); | 920 return ShapeValue::createImageValue(state.styleImage(CSSPropertyShapeOut
side, value)); |
| 925 | 921 |
| 926 RefPtr<BasicShape> shape; | 922 RefPtr<BasicShape> shape; |
| 927 CSSBoxType cssBox = BoxMissing; | 923 CSSBoxType cssBox = BoxMissing; |
| 928 const CSSValueList& valueList = toCSSValueList(value); | 924 const CSSValueList& valueList = toCSSValueList(value); |
| 929 for (unsigned i = 0; i < valueList.length(); ++i) { | 925 for (unsigned i = 0; i < valueList.length(); ++i) { |
| 930 const CSSValue& value = valueList.item(i); | 926 const CSSValue& value = valueList.item(i); |
| 931 if (value.isBasicShapeValue()) { | 927 if (value.isBasicShapeValue()) { |
| 932 shape = basicShapeForValue(state, value); | 928 shape = basicShapeForValue(state, value); |
| 933 } else { | 929 } else { |
| 934 cssBox = toCSSPrimitiveValue(value).convertTo<CSSBoxType>(); | 930 cssBox = toCSSIdentifierValue(value).convertTo<CSSBoxType>(); |
| 935 } | 931 } |
| 936 } | 932 } |
| 937 | 933 |
| 938 if (shape) | 934 if (shape) |
| 939 return ShapeValue::createShapeValue(shape.release(), cssBox); | 935 return ShapeValue::createShapeValue(shape.release(), cssBox); |
| 940 | 936 |
| 941 ASSERT(cssBox != BoxMissing); | 937 ASSERT(cssBox != BoxMissing); |
| 942 return ShapeValue::createBoxShapeValue(cssBox); | 938 return ShapeValue::createBoxShapeValue(cssBox); |
| 943 } | 939 } |
| 944 | 940 |
| 945 float StyleBuilderConverter::convertSpacing(StyleResolverState& state, const CSS
Value& value) | 941 float StyleBuilderConverter::convertSpacing(StyleResolverState& state, const CSS
Value& value) |
| 946 { | 942 { |
| 947 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 943 if (value.isIdentifierValue() && toCSSIdentifierValue(value).getValueID() ==
CSSValueNormal) |
| 948 if (primitiveValue.getValueID() == CSSValueNormal) | |
| 949 return 0; | 944 return 0; |
| 950 return primitiveValue.computeLength<float>(state.cssToLengthConversionData()
); | 945 return toCSSPrimitiveValue(value).computeLength<float>(state.cssToLengthConv
ersionData()); |
| 951 } | 946 } |
| 952 | 947 |
| 953 PassRefPtr<SVGDashArray> StyleBuilderConverter::convertStrokeDasharray(StyleReso
lverState& state, const CSSValue& value) | 948 PassRefPtr<SVGDashArray> StyleBuilderConverter::convertStrokeDasharray(StyleReso
lverState& state, const CSSValue& value) |
| 954 { | 949 { |
| 955 if (!value.isValueList()) | 950 if (!value.isValueList()) |
| 956 return SVGComputedStyle::initialStrokeDashArray(); | 951 return SVGComputedStyle::initialStrokeDashArray(); |
| 957 | 952 |
| 958 const CSSValueList& dashes = toCSSValueList(value); | 953 const CSSValueList& dashes = toCSSValueList(value); |
| 959 | 954 |
| 960 RefPtr<SVGDashArray> array = SVGDashArray::create(); | 955 RefPtr<SVGDashArray> array = SVGDashArray::create(); |
| 961 size_t length = dashes.length(); | 956 size_t length = dashes.length(); |
| 962 for (size_t i = 0; i < length; ++i) { | 957 for (size_t i = 0; i < length; ++i) { |
| 963 array->append(convertLength(state, toCSSPrimitiveValue(dashes.item(i))))
; | 958 array->append(convertLength(state, toCSSPrimitiveValue(dashes.item(i))))
; |
| 964 } | 959 } |
| 965 | 960 |
| 966 return array.release(); | 961 return array.release(); |
| 967 } | 962 } |
| 968 | 963 |
| 969 StyleColor StyleBuilderConverter::convertStyleColor(StyleResolverState& state, c
onst CSSValue& value, bool forVisitedLink) | 964 StyleColor StyleBuilderConverter::convertStyleColor(StyleResolverState& state, c
onst CSSValue& value, bool forVisitedLink) |
| 970 { | 965 { |
| 971 if (value.isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID() == C
SSValueCurrentcolor) | 966 if (value.isIdentifierValue() && toCSSIdentifierValue(value).getValueID() ==
CSSValueCurrentcolor) |
| 972 return StyleColor::currentColor(); | 967 return StyleColor::currentColor(); |
| 973 return state.document().textLinkColors().colorFromCSSValue(value, Color(), f
orVisitedLink); | 968 return state.document().textLinkColors().colorFromCSSValue(value, Color(), f
orVisitedLink); |
| 974 } | 969 } |
| 975 | 970 |
| 976 float StyleBuilderConverter::convertTextStrokeWidth(StyleResolverState& state, c
onst CSSValue& value) | 971 float StyleBuilderConverter::convertTextStrokeWidth(StyleResolverState& state, c
onst CSSValue& value) |
| 977 { | 972 { |
| 978 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 973 if (value.isIdentifierValue() && toCSSIdentifierValue(value).getValueID()) { |
| 979 if (primitiveValue.getValueID()) { | |
| 980 float multiplier = convertLineWidth<float>(state, value); | 974 float multiplier = convertLineWidth<float>(state, value); |
| 981 return CSSPrimitiveValue::create(multiplier / 48, CSSPrimitiveValue::Uni
tType::Ems)->computeLength<float>(state.cssToLengthConversionData()); | 975 return CSSPrimitiveValue::create(multiplier / 48, CSSPrimitiveValue::Uni
tType::Ems)->computeLength<float>(state.cssToLengthConversionData()); |
| 982 } | 976 } |
| 983 return primitiveValue.computeLength<float>(state.cssToLengthConversionData()
); | 977 return toCSSPrimitiveValue(value).computeLength<float>(state.cssToLengthConv
ersionData()); |
| 984 } | 978 } |
| 985 | 979 |
| 986 TextSizeAdjust StyleBuilderConverter::convertTextSizeAdjust(StyleResolverState&
state, const CSSValue& value) | 980 TextSizeAdjust StyleBuilderConverter::convertTextSizeAdjust(StyleResolverState&
state, const CSSValue& value) |
| 987 { | 981 { |
| 982 if (value.isIdentifierValue() && toCSSIdentifierValue(value).getValueID() ==
CSSValueNone) |
| 983 return TextSizeAdjust::adjustNone(); |
| 984 if (value.isIdentifierValue() && toCSSIdentifierValue(value).getValueID() ==
CSSValueAuto) |
| 985 return TextSizeAdjust::adjustAuto(); |
| 988 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 986 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 989 if (primitiveValue.getValueID() == CSSValueNone) | |
| 990 return TextSizeAdjust::adjustNone(); | |
| 991 if (primitiveValue.getValueID() == CSSValueAuto) | |
| 992 return TextSizeAdjust::adjustAuto(); | |
| 993 DCHECK(primitiveValue.isPercentage()); | 987 DCHECK(primitiveValue.isPercentage()); |
| 994 return TextSizeAdjust(primitiveValue.getFloatValue() / 100.0f); | 988 return TextSizeAdjust(primitiveValue.getFloatValue() / 100.0f); |
| 995 } | 989 } |
| 996 | 990 |
| 997 TransformOrigin StyleBuilderConverter::convertTransformOrigin(StyleResolverState
& state, const CSSValue& value) | 991 TransformOrigin StyleBuilderConverter::convertTransformOrigin(StyleResolverState
& state, const CSSValue& value) |
| 998 { | 992 { |
| 999 const CSSValueList& list = toCSSValueList(value); | 993 const CSSValueList& list = toCSSValueList(value); |
| 1000 ASSERT(list.length() == 3); | 994 DCHECK_EQ(list.length(), 3U); |
| 1001 | 995 DCHECK(list.item(0).isPrimitiveValue() || list.item(0).isIdentifierValue()); |
| 1002 const CSSPrimitiveValue& primitiveValueX = toCSSPrimitiveValue(list.item(0))
; | 996 DCHECK(list.item(1).isPrimitiveValue() || list.item(1).isIdentifierValue()); |
| 1003 const CSSPrimitiveValue& primitiveValueY = toCSSPrimitiveValue(list.item(1))
; | 997 DCHECK(list.item(2).isPrimitiveValue()); |
| 1004 const CSSPrimitiveValue& primitiveValueZ = toCSSPrimitiveValue(list.item(2))
; | |
| 1005 | 998 |
| 1006 return TransformOrigin( | 999 return TransformOrigin( |
| 1007 convertPositionLength<CSSValueLeft, CSSValueRight>(state, primitiveValue
X), | 1000 convertPositionLength<CSSValueLeft, CSSValueRight>(state, list.item(0)), |
| 1008 convertPositionLength<CSSValueTop, CSSValueBottom>(state, primitiveValue
Y), | 1001 convertPositionLength<CSSValueTop, CSSValueBottom>(state, list.item(1)), |
| 1009 StyleBuilderConverter::convertComputedLength<float>(state, primitiveValu
eZ) | 1002 StyleBuilderConverter::convertComputedLength<float>(state, list.item(2)) |
| 1010 ); | 1003 ); |
| 1011 } | 1004 } |
| 1012 | 1005 |
| 1013 ScrollSnapPoints StyleBuilderConverter::convertSnapPoints(StyleResolverState& st
ate, const CSSValue& value) | 1006 ScrollSnapPoints StyleBuilderConverter::convertSnapPoints(StyleResolverState& st
ate, const CSSValue& value) |
| 1014 { | 1007 { |
| 1015 // Handles: none | repeat(<length>) | 1008 // Handles: none | repeat(<length>) |
| 1016 ScrollSnapPoints points; | 1009 ScrollSnapPoints points; |
| 1017 points.hasRepeat = false; | 1010 points.hasRepeat = false; |
| 1018 | 1011 |
| 1019 if (!value.isFunctionValue()) | 1012 if (!value.isFunctionValue()) |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1090 if (list.length() >= 2) | 1083 if (list.length() >= 2) |
| 1091 sy = toCSSPrimitiveValue(list.item(1)).getDoubleValue(); | 1084 sy = toCSSPrimitiveValue(list.item(1)).getDoubleValue(); |
| 1092 if (list.length() == 3) | 1085 if (list.length() == 3) |
| 1093 sz = toCSSPrimitiveValue(list.item(2)).getDoubleValue(); | 1086 sz = toCSSPrimitiveValue(list.item(2)).getDoubleValue(); |
| 1094 | 1087 |
| 1095 return ScaleTransformOperation::create(sx, sy, sz, TransformOperation::Scale
3D); | 1088 return ScaleTransformOperation::create(sx, sy, sz, TransformOperation::Scale
3D); |
| 1096 } | 1089 } |
| 1097 | 1090 |
| 1098 RespectImageOrientationEnum StyleBuilderConverter::convertImageOrientation(Style
ResolverState& state, const CSSValue& value) | 1091 RespectImageOrientationEnum StyleBuilderConverter::convertImageOrientation(Style
ResolverState& state, const CSSValue& value) |
| 1099 { | 1092 { |
| 1100 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 1093 return value.isIdentifierValue() && toCSSIdentifierValue(value).getValueID()
== CSSValueFromImage ? RespectImageOrientation : DoNotRespectImageOrientation; |
| 1101 return primitiveValue.getValueID() == CSSValueFromImage ? RespectImageOrient
ation : DoNotRespectImageOrientation; | |
| 1102 } | 1094 } |
| 1103 | 1095 |
| 1104 PassRefPtr<StylePath> StyleBuilderConverter::convertPathOrNone(StyleResolverStat
e& state, const CSSValue& value) | 1096 PassRefPtr<StylePath> StyleBuilderConverter::convertPathOrNone(StyleResolverStat
e& state, const CSSValue& value) |
| 1105 { | 1097 { |
| 1106 if (value.isPathValue()) | 1098 if (value.isPathValue()) |
| 1107 return toCSSPathValue(value).stylePath(); | 1099 return toCSSPathValue(value).stylePath(); |
| 1108 ASSERT(value.isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID() =
= CSSValueNone); | 1100 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); |
| 1109 return nullptr; | 1101 return nullptr; |
| 1110 } | 1102 } |
| 1111 | 1103 |
| 1112 const CSSValue& StyleBuilderConverter::convertRegisteredPropertyValue(const Styl
eResolverState& state, const CSSValue& value) | 1104 const CSSValue& StyleBuilderConverter::convertRegisteredPropertyValue(const Styl
eResolverState& state, const CSSValue& value) |
| 1113 { | 1105 { |
| 1114 // TODO(timloh): Images and transform-function values can also contain lengt
hs. | 1106 // TODO(timloh): Images and transform-function values can also contain lengt
hs. |
| 1115 if (value.isValueList()) { | 1107 if (value.isValueList()) { |
| 1116 CSSValueList* newList = CSSValueList::createSpaceSeparated(); | 1108 CSSValueList* newList = CSSValueList::createSpaceSeparated(); |
| 1117 for (const CSSValue* innerValue : toCSSValueList(value)) | 1109 for (const CSSValue* innerValue : toCSSValueList(value)) |
| 1118 newList->append(convertRegisteredPropertyValue(state, *innerValue)); | 1110 newList->append(convertRegisteredPropertyValue(state, *innerValue)); |
| 1119 return *newList; | 1111 return *newList; |
| 1120 } | 1112 } |
| 1121 | 1113 |
| 1122 if (value.isPrimitiveValue()) { | 1114 if (value.isPrimitiveValue()) { |
| 1123 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 1115 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 1124 if (primitiveValue.isCalculated() || CSSPrimitiveValue::isRelativeUnit(p
rimitiveValue.typeWithCalcResolved())) { | 1116 if (primitiveValue.isCalculated() || CSSPrimitiveValue::isRelativeUnit(p
rimitiveValue.typeWithCalcResolved())) { |
| 1125 // Instead of the actual zoom, use 1 to avoid potential rounding err
ors | 1117 // Instead of the actual zoom, use 1 to avoid potential rounding err
ors |
| 1126 Length length = primitiveValue.convertToLength(state.cssToLengthConv
ersionData().copyWithAdjustedZoom(1)); | 1118 Length length = primitiveValue.convertToLength(state.cssToLengthConv
ersionData().copyWithAdjustedZoom(1)); |
| 1127 return *CSSPrimitiveValue::create(length, 1); | 1119 return *CSSPrimitiveValue::create(length, 1); |
| 1128 } | 1120 } |
| 1129 } | 1121 } |
| 1130 return value; | 1122 return value; |
| 1131 } | 1123 } |
| 1132 | 1124 |
| 1133 } // namespace blink | 1125 } // namespace blink |
| OLD | NEW |