| 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 29 matching lines...) Expand all Loading... |
| 40 #include "core/svg/SVGElement.h" | 40 #include "core/svg/SVGElement.h" |
| 41 #include "core/svg/SVGURIReference.h" | 41 #include "core/svg/SVGURIReference.h" |
| 42 #include "platform/transforms/RotateTransformOperation.h" | 42 #include "platform/transforms/RotateTransformOperation.h" |
| 43 #include "platform/transforms/ScaleTransformOperation.h" | 43 #include "platform/transforms/ScaleTransformOperation.h" |
| 44 #include "platform/transforms/TranslateTransformOperation.h" | 44 #include "platform/transforms/TranslateTransformOperation.h" |
| 45 | 45 |
| 46 namespace blink { | 46 namespace blink { |
| 47 | 47 |
| 48 namespace { | 48 namespace { |
| 49 | 49 |
| 50 static GridLength convertGridTrackBreadth(const StyleResolverState& state, CSSPr
imitiveValue* primitiveValue) | 50 static GridLength convertGridTrackBreadth(const StyleResolverState& state, CSSPr
imitiveValue primitiveValue) |
| 51 { | 51 { |
| 52 if (primitiveValue->getValueID() == CSSValueMinContent) | 52 if (primitiveValue.getValueID() == CSSValueMinContent) |
| 53 return Length(MinContent); | 53 return Length(MinContent); |
| 54 | 54 |
| 55 if (primitiveValue->getValueID() == CSSValueMaxContent) | 55 if (primitiveValue.getValueID() == CSSValueMaxContent) |
| 56 return Length(MaxContent); | 56 return Length(MaxContent); |
| 57 | 57 |
| 58 // Fractional unit. | 58 // Fractional unit. |
| 59 if (primitiveValue->isFlex()) | 59 if (primitiveValue.isFlex()) |
| 60 return GridLength(primitiveValue->getDoubleValue()); | 60 return GridLength(primitiveValue.getDoubleValue()); |
| 61 | 61 |
| 62 return StyleBuilderConverter::convertLengthOrAuto(state, CSSValue(*primitive
Value)); | 62 return StyleBuilderConverter::convertLengthOrAuto(state, primitiveValue); |
| 63 } | 63 } |
| 64 | 64 |
| 65 } // namespace | 65 } // namespace |
| 66 | 66 |
| 67 PassRefPtr<StyleReflection> StyleBuilderConverter::convertBoxReflect(StyleResolv
erState& state, const CSSValue& value) | 67 PassRefPtr<StyleReflection> StyleBuilderConverter::convertBoxReflect(StyleResolv
erState& state, const CSSValue& value) |
| 68 { | 68 { |
| 69 if (value.isPrimitiveValue()) { | 69 if (value.isPrimitiveValue()) { |
| 70 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNone); | 70 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNone); |
| 71 return ComputedStyle::initialBoxReflect(); | 71 return ComputedStyle::initialBoxReflect(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 CSSReflectValue& reflectValue = toCSSReflectValue(value); | 74 CSSReflectValue& reflectValue = toCSSReflectValue(value); |
| 75 RefPtr<StyleReflection> reflection = StyleReflection::create(); | 75 RefPtr<StyleReflection> reflection = StyleReflection::create(); |
| 76 reflection->setDirection(*reflectValue.direction()); | 76 reflection->setDirection(reflectValue.direction()); |
| 77 if (reflectValue.offset()) | 77 reflection->setOffset(reflectValue.offset().convertToLength(state.cssToLengt
hConversionData())); |
| 78 reflection->setOffset(reflectValue.offset()->convertToLength(state.cssTo
LengthConversionData())); | |
| 79 NinePieceImage mask; | 78 NinePieceImage mask; |
| 80 mask.setMaskDefaults(); | 79 mask.setMaskDefaults(); |
| 81 CSSToStyleMap::mapNinePieceImage(state, CSSPropertyWebkitBoxReflect, reflect
Value.mask(), mask); | 80 CSSToStyleMap::mapNinePieceImage(state, CSSPropertyWebkitBoxReflect, reflect
Value.mask(), mask); |
| 82 reflection->setMask(mask); | 81 reflection->setMask(mask); |
| 83 | 82 |
| 84 return reflection.release(); | 83 return reflection.release(); |
| 85 } | 84 } |
| 86 | 85 |
| 87 Color StyleBuilderConverter::convertColor(StyleResolverState& state, const CSSVa
lue& value, bool forVisitedLink) | 86 Color StyleBuilderConverter::convertColor(StyleResolverState& state, const CSSVa
lue& value, bool forVisitedLink) |
| 88 { | 87 { |
| 89 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 88 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 90 return state.document().textLinkColors().colorFromPrimitiveValue(primitiveVa
lue, state.style()->color(), forVisitedLink); | 89 return state.document().textLinkColors().colorFromPrimitiveValue(primitiveVa
lue, state.style()->color(), forVisitedLink); |
| 91 } | 90 } |
| 92 | 91 |
| 93 AtomicString StyleBuilderConverter::convertFragmentIdentifier(StyleResolverState
& state, const CSSValue& value) | 92 AtomicString StyleBuilderConverter::convertFragmentIdentifier(StyleResolverState
& state, const CSSValue& value) |
| 94 { | 93 { |
| 95 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 94 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 96 if (primitiveValue.isURI()) | 95 if (primitiveValue.isURI()) |
| 97 return SVGURIReference::fragmentIdentifierFromIRIString(primitiveValue.g
etStringValue(), state.element()->treeScope()); | 96 return SVGURIReference::fragmentIdentifierFromIRIString(primitiveValue.g
etStringValue(), state.element()->treeScope()); |
| 98 return nullAtom; | 97 return nullAtom; |
| 99 } | 98 } |
| 100 | 99 |
| 101 LengthBox StyleBuilderConverter::convertClip(StyleResolverState& state, const CS
SValue& value) | 100 LengthBox StyleBuilderConverter::convertClip(StyleResolverState& state, const CS
SValue& value) |
| 102 { | 101 { |
| 103 Rect* rect = toCSSPrimitiveValue(value).getRectValue(); | 102 Rect* rect = toCSSPrimitiveValue(value).getRectValue(); |
| 104 | 103 |
| 105 return LengthBox(convertLengthOrAuto(state, CSSValue(*rect->top())), | 104 return LengthBox(convertLengthOrAuto(state, rect->top()), |
| 106 convertLengthOrAuto(state, CSSValue(*rect->right())), | 105 convertLengthOrAuto(state, rect->right()), |
| 107 convertLengthOrAuto(state, CSSValue(*rect->bottom())), | 106 convertLengthOrAuto(state, rect->bottom()), |
| 108 convertLengthOrAuto(state, CSSValue(*rect->left()))); | 107 convertLengthOrAuto(state, rect->left())); |
| 109 } | 108 } |
| 110 | 109 |
| 111 static FontDescription::GenericFamilyType convertGenericFamily(CSSValueID valueI
D) | 110 static FontDescription::GenericFamilyType convertGenericFamily(CSSValueID valueI
D) |
| 112 { | 111 { |
| 113 switch (valueID) { | 112 switch (valueID) { |
| 114 case CSSValueWebkitBody: | 113 case CSSValueWebkitBody: |
| 115 return FontDescription::StandardFamily; | 114 return FontDescription::StandardFamily; |
| 116 case CSSValueSerif: | 115 case CSSValueSerif: |
| 117 return FontDescription::SerifFamily; | 116 return FontDescription::SerifFamily; |
| 118 case CSSValueSansSerif: | 117 case CSSValueSansSerif: |
| 119 return FontDescription::SansSerifFamily; | 118 return FontDescription::SansSerifFamily; |
| 120 case CSSValueCursive: | 119 case CSSValueCursive: |
| 121 return FontDescription::CursiveFamily; | 120 return FontDescription::CursiveFamily; |
| 122 case CSSValueFantasy: | 121 case CSSValueFantasy: |
| 123 return FontDescription::FantasyFamily; | 122 return FontDescription::FantasyFamily; |
| 124 case CSSValueMonospace: | 123 case CSSValueMonospace: |
| 125 return FontDescription::MonospaceFamily; | 124 return FontDescription::MonospaceFamily; |
| 126 case CSSValueWebkitPictograph: | 125 case CSSValueWebkitPictograph: |
| 127 return FontDescription::PictographFamily; | 126 return FontDescription::PictographFamily; |
| 128 default: | 127 default: |
| 129 return FontDescription::NoFamily; | 128 return FontDescription::NoFamily; |
| 130 } | 129 } |
| 131 } | 130 } |
| 132 | 131 |
| 133 static bool convertFontFamilyName(StyleResolverState& state, CSSPrimitiveValue&
primitiveValue, | 132 static bool convertFontFamilyName(StyleResolverState& state, CSSPrimitiveValue p
rimitiveValue, |
| 134 FontDescription::GenericFamilyType& genericFamily, AtomicString& familyName) | 133 FontDescription::GenericFamilyType& genericFamily, AtomicString& familyName) |
| 135 { | 134 { |
| 136 if (primitiveValue.isCustomIdent()) { | 135 if (primitiveValue.isCustomIdent()) { |
| 137 genericFamily = FontDescription::NoFamily; | 136 genericFamily = FontDescription::NoFamily; |
| 138 familyName = AtomicString(primitiveValue.getStringValue()); | 137 familyName = AtomicString(primitiveValue.getStringValue()); |
| 139 } else if (state.document().settings()) { | 138 } else if (state.document().settings()) { |
| 140 genericFamily = convertGenericFamily(primitiveValue.getValueID()); | 139 genericFamily = convertGenericFamily(primitiveValue.getValueID()); |
| 141 familyName = state.fontBuilder().genericFontFamilyName(genericFamily); | 140 familyName = state.fontBuilder().genericFontFamilyName(genericFamily); |
| 142 } | 141 } |
| 143 | 142 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 CSSValueList& list = toCSSValueList(value); | 182 CSSValueList& list = toCSSValueList(value); |
| 184 RefPtr<FontFeatureSettings> settings = FontFeatureSettings::create(); | 183 RefPtr<FontFeatureSettings> settings = FontFeatureSettings::create(); |
| 185 int len = list.length(); | 184 int len = list.length(); |
| 186 for (int i = 0; i < len; ++i) { | 185 for (int i = 0; i < len; ++i) { |
| 187 CSSFontFeatureValue& feature = toCSSFontFeatureValue(list.item(i)); | 186 CSSFontFeatureValue& feature = toCSSFontFeatureValue(list.item(i)); |
| 188 settings->append(FontFeature(feature.tag(), feature.value())); | 187 settings->append(FontFeature(feature.tag(), feature.value())); |
| 189 } | 188 } |
| 190 return settings; | 189 return settings; |
| 191 } | 190 } |
| 192 | 191 |
| 193 static float computeFontSize(StyleResolverState& state, CSSPrimitiveValue& primi
tiveValue, const FontDescription::Size& parentSize) | 192 static float computeFontSize(StyleResolverState& state, CSSPrimitiveValue primit
iveValue, const FontDescription::Size& parentSize) |
| 194 { | 193 { |
| 195 float em = state.parentStyle()->specifiedFontSize(); | 194 float em = state.parentStyle()->specifiedFontSize(); |
| 196 float rem = state.rootElementStyle() ? state.rootElementStyle()->specifiedFo
ntSize() : 1.0f; | 195 float rem = state.rootElementStyle() ? state.rootElementStyle()->specifiedFo
ntSize() : 1.0f; |
| 197 CSSToLengthConversionData::FontSizes fontSizes(em, rem, &state.parentStyle()
->font()); | 196 CSSToLengthConversionData::FontSizes fontSizes(em, rem, &state.parentStyle()
->font()); |
| 198 CSSToLengthConversionData::ViewportSize viewportSize(state.document().layout
View()); | 197 CSSToLengthConversionData::ViewportSize viewportSize(state.document().layout
View()); |
| 199 | 198 |
| 200 CSSToLengthConversionData conversionData(state.style(), fontSizes, viewportS
ize, 1.0f); | 199 CSSToLengthConversionData conversionData(state.style(), fontSizes, viewportS
ize, 1.0f); |
| 201 if (primitiveValue.isLength()) | 200 if (primitiveValue.isLength()) |
| 202 return primitiveValue.computeLength<float>(conversionData); | 201 return primitiveValue.computeLength<float>(conversionData); |
| 203 if (primitiveValue.isCalculatedPercentageWithLength()) | 202 if (primitiveValue.isCalculatedPercentageWithLength()) |
| 204 return primitiveValue.cssCalcValue()->toCalcValue(conversionData)->evalu
ate(parentSize.value); | 203 return primitiveValue.cssCalcValue()->toCalcValue(conversionData)->evalu
ate(parentSize.value); |
| 205 | 204 |
| 206 ASSERT_NOT_REACHED(); | 205 ASSERT_NOT_REACHED(); |
| 207 return 0; | 206 return 0; |
| 208 } | 207 } |
| 209 | 208 |
| 210 FontDescription::Size StyleBuilderConverter::convertFontSize(StyleResolverState&
state, const CSSValue& value) | 209 FontDescription::Size StyleBuilderConverter::convertFontSize(StyleResolverState&
state, const CSSValue& value) |
| 211 { | 210 { |
| 212 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 211 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 213 | 212 |
| 214 FontDescription::Size parentSize(0, 0.0f, false); | 213 FontDescription::Size parentSize(0, 0.0f, false); |
| 215 | 214 |
| 216 // FIXME: Find out when parentStyle could be 0? | 215 // FIXME: Find out when parentStyle could be 0? |
| 217 if (state.parentStyle()) | 216 if (state.parentStyle()) |
| 218 parentSize = state.parentFontDescription().size(); | 217 parentSize = state.parentFontDescription().size(); |
| 219 | 218 |
| 220 if (CSSValueID valueID = primitiveValue.getValueID()) { | 219 if (CSSValueID valueID = primitiveValue.getValueID()) { |
| 221 switch (valueID) { | 220 switch (valueID) { |
| 222 case CSSValueXxSmall: | 221 case CSSValueXxSmall: |
| (...skipping 18 matching lines...) Expand all Loading... |
| 241 bool parentIsAbsoluteSize = state.parentFontDescription().isAbsoluteSize(); | 240 bool parentIsAbsoluteSize = state.parentFontDescription().isAbsoluteSize(); |
| 242 | 241 |
| 243 if (primitiveValue.isPercentage()) | 242 if (primitiveValue.isPercentage()) |
| 244 return FontDescription::Size(0, (primitiveValue.getFloatValue() * parent
Size.value / 100.0f), parentIsAbsoluteSize); | 243 return FontDescription::Size(0, (primitiveValue.getFloatValue() * parent
Size.value / 100.0f), parentIsAbsoluteSize); |
| 245 | 244 |
| 246 return FontDescription::Size(0, computeFontSize(state, primitiveValue, paren
tSize), parentIsAbsoluteSize || !primitiveValue.isFontRelativeLength()); | 245 return FontDescription::Size(0, computeFontSize(state, primitiveValue, paren
tSize), parentIsAbsoluteSize || !primitiveValue.isFontRelativeLength()); |
| 247 } | 246 } |
| 248 | 247 |
| 249 float StyleBuilderConverter::convertFontSizeAdjust(StyleResolverState& state, co
nst CSSValue& value) | 248 float StyleBuilderConverter::convertFontSizeAdjust(StyleResolverState& state, co
nst CSSValue& value) |
| 250 { | 249 { |
| 251 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 250 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 252 if (primitiveValue.getValueID() == CSSValueNone) | 251 if (primitiveValue.getValueID() == CSSValueNone) |
| 253 return FontBuilder::initialSizeAdjust(); | 252 return FontBuilder::initialSizeAdjust(); |
| 254 | 253 |
| 255 ASSERT(primitiveValue.isNumber()); | 254 ASSERT(primitiveValue.isNumber()); |
| 256 return primitiveValue.getFloatValue(); | 255 return primitiveValue.getFloatValue(); |
| 257 } | 256 } |
| 258 | 257 |
| 259 FontWeight StyleBuilderConverter::convertFontWeight(StyleResolverState& state, c
onst CSSValue& value) | 258 FontWeight StyleBuilderConverter::convertFontWeight(StyleResolverState& state, c
onst CSSValue& value) |
| 260 { | 259 { |
| 261 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 260 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 262 switch (primitiveValue.getValueID()) { | 261 switch (primitiveValue.getValueID()) { |
| 263 case CSSValueBolder: | 262 case CSSValueBolder: |
| 264 return FontDescription::bolderWeight(state.parentStyle()->fontDescriptio
n().weight()); | 263 return FontDescription::bolderWeight(state.parentStyle()->fontDescriptio
n().weight()); |
| 265 case CSSValueLighter: | 264 case CSSValueLighter: |
| 266 return FontDescription::lighterWeight(state.parentStyle()->fontDescripti
on().weight()); | 265 return FontDescription::lighterWeight(state.parentStyle()->fontDescripti
on().weight()); |
| 267 default: | 266 default: |
| 268 return primitiveValue; | 267 return primitiveValue; |
| 269 } | 268 } |
| 270 } | 269 } |
| 271 | 270 |
| 272 FontDescription::VariantLigatures StyleBuilderConverter::convertFontVariantLigat
ures(StyleResolverState&, const CSSValue& value) | 271 FontDescription::VariantLigatures StyleBuilderConverter::convertFontVariantLigat
ures(StyleResolverState&, const CSSValue& value) |
| 273 { | 272 { |
| 274 if (value.isValueList()) { | 273 if (value.isValueList()) { |
| 275 FontDescription::VariantLigatures ligatures; | 274 FontDescription::VariantLigatures ligatures; |
| 276 CSSValueList& valueList = toCSSValueList(value); | 275 CSSValueList& valueList = toCSSValueList(value); |
| 277 for (size_t i = 0; i < valueList.length(); ++i) { | 276 for (size_t i = 0; i < valueList.length(); ++i) { |
| 278 CSSValue item = valueList.item(i); | 277 const CSSValue& item = valueList.item(i); |
| 279 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(item); | 278 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(item); |
| 280 switch (primitiveValue.getValueID()) { | 279 switch (primitiveValue.getValueID()) { |
| 281 case CSSValueNoCommonLigatures: | 280 case CSSValueNoCommonLigatures: |
| 282 ligatures.common = FontDescription::DisabledLigaturesState; | 281 ligatures.common = FontDescription::DisabledLigaturesState; |
| 283 break; | 282 break; |
| 284 case CSSValueCommonLigatures: | 283 case CSSValueCommonLigatures: |
| 285 ligatures.common = FontDescription::EnabledLigaturesState; | 284 ligatures.common = FontDescription::EnabledLigaturesState; |
| 286 break; | 285 break; |
| 287 case CSSValueNoDiscretionaryLigatures: | 286 case CSSValueNoDiscretionaryLigatures: |
| 288 ligatures.discretionary = FontDescription::DisabledLigaturesStat
e; | 287 ligatures.discretionary = FontDescription::DisabledLigaturesStat
e; |
| 289 break; | 288 break; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 313 ASSERT_WITH_SECURITY_IMPLICATION(value.isPrimitiveValue()); | 312 ASSERT_WITH_SECURITY_IMPLICATION(value.isPrimitiveValue()); |
| 314 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNormal); | 313 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNormal); |
| 315 return FontDescription::VariantLigatures(); | 314 return FontDescription::VariantLigatures(); |
| 316 } | 315 } |
| 317 | 316 |
| 318 EGlyphOrientation StyleBuilderConverter::convertGlyphOrientation(StyleResolverSt
ate&, const CSSValue& value) | 317 EGlyphOrientation StyleBuilderConverter::convertGlyphOrientation(StyleResolverSt
ate&, const CSSValue& value) |
| 319 { | 318 { |
| 320 if (!value.isPrimitiveValue()) | 319 if (!value.isPrimitiveValue()) |
| 321 return GO_0DEG; | 320 return GO_0DEG; |
| 322 | 321 |
| 323 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 322 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 324 if (primitiveValue.primitiveType() != CSSPrimitiveValue::CSS_DEG) | 323 if (primitiveValue.primitiveType() != CSSPrimitiveValue::CSS_DEG) |
| 325 return GO_0DEG; | 324 return GO_0DEG; |
| 326 | 325 |
| 327 float angle = fabsf(fmodf(primitiveValue.getFloatValue(), 360.0f)); | 326 float angle = fabsf(fmodf(primitiveValue.getFloatValue(), 360.0f)); |
| 328 | 327 |
| 329 if (angle <= 45.0f || angle > 315.0f) | 328 if (angle <= 45.0f || angle > 315.0f) |
| 330 return GO_0DEG; | 329 return GO_0DEG; |
| 331 if (angle > 45.0f && angle <= 135.0f) | 330 if (angle > 45.0f && angle <= 135.0f) |
| 332 return GO_90DEG; | 331 return GO_90DEG; |
| 333 if (angle > 135.0f && angle <= 225.0f) | 332 if (angle > 135.0f && angle <= 225.0f) |
| 334 return GO_180DEG; | 333 return GO_180DEG; |
| 335 return GO_270DEG; | 334 return GO_270DEG; |
| 336 } | 335 } |
| 337 | 336 |
| 338 StyleSelfAlignmentData StyleBuilderConverter::convertSelfOrDefaultAlignmentData(
StyleResolverState&, const CSSValue& value) | 337 StyleSelfAlignmentData StyleBuilderConverter::convertSelfOrDefaultAlignmentData(
StyleResolverState&, const CSSValue& value) |
| 339 { | 338 { |
| 340 StyleSelfAlignmentData alignmentData = ComputedStyle::initialSelfAlignment()
; | 339 StyleSelfAlignmentData alignmentData = ComputedStyle::initialSelfAlignment()
; |
| 341 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 340 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 342 if (Pair* pairValue = primitiveValue.getPairValue()) { | 341 if (Pair* pairValue = primitiveValue.getPairValue()) { |
| 343 if (pairValue->first()->getValueID() == CSSValueLegacy) { | 342 if (pairValue->first().getValueID() == CSSValueLegacy) { |
| 344 alignmentData.setPositionType(LegacyPosition); | 343 alignmentData.setPositionType(LegacyPosition); |
| 345 alignmentData.setPosition(*pairValue->second()); | 344 alignmentData.setPosition(pairValue->second()); |
| 346 } else { | 345 } else { |
| 347 alignmentData.setPosition(*pairValue->first()); | 346 alignmentData.setPosition(pairValue->first()); |
| 348 alignmentData.setOverflow(*pairValue->second()); | 347 alignmentData.setOverflow(pairValue->second()); |
| 349 } | 348 } |
| 350 } else { | 349 } else { |
| 351 alignmentData.setPosition(primitiveValue); | 350 alignmentData.setPosition(primitiveValue); |
| 352 } | 351 } |
| 353 return alignmentData; | 352 return alignmentData; |
| 354 } | 353 } |
| 355 | 354 |
| 356 StyleContentAlignmentData StyleBuilderConverter::convertContentAlignmentData(Sty
leResolverState&, const CSSValue& value) | 355 StyleContentAlignmentData StyleBuilderConverter::convertContentAlignmentData(Sty
leResolverState&, const CSSValue& value) |
| 357 { | 356 { |
| 358 StyleContentAlignmentData alignmentData = ComputedStyle::initialContentAlign
ment(); | 357 StyleContentAlignmentData alignmentData = ComputedStyle::initialContentAlign
ment(); |
| 359 CSSContentDistributionValue& contentValue = toCSSContentDistributionValue(va
lue); | 358 CSSContentDistributionValue& contentValue = toCSSContentDistributionValue(va
lue); |
| 360 if (contentValue.distribution()->getValueID() != CSSValueInvalid) | 359 if (contentValue.distribution().getValueID() != CSSValueInvalid) |
| 361 alignmentData.setDistribution(*contentValue.distribution()); | 360 alignmentData.setDistribution(contentValue.distribution()); |
| 362 if (contentValue.position()->getValueID() != CSSValueInvalid) | 361 if (contentValue.position().getValueID() != CSSValueInvalid) |
| 363 alignmentData.setPosition(*contentValue.position()); | 362 alignmentData.setPosition(contentValue.position()); |
| 364 if (contentValue.overflow()->getValueID() != CSSValueInvalid) | 363 if (contentValue.overflow().getValueID() != CSSValueInvalid) |
| 365 alignmentData.setOverflow(*contentValue.overflow()); | 364 alignmentData.setOverflow(contentValue.overflow()); |
| 366 return alignmentData; | 365 return alignmentData; |
| 367 } | 366 } |
| 368 | 367 |
| 369 GridAutoFlow StyleBuilderConverter::convertGridAutoFlow(StyleResolverState&, con
st CSSValue& value) | 368 GridAutoFlow StyleBuilderConverter::convertGridAutoFlow(StyleResolverState&, con
st CSSValue& value) |
| 370 { | 369 { |
| 371 CSSValueList& list = toCSSValueList(value); | 370 CSSValueList& list = toCSSValueList(value); |
| 372 | 371 |
| 373 ASSERT(list.length() >= 1); | 372 ASSERT(list.length() >= 1); |
| 374 CSSPrimitiveValue* first = &toCSSPrimitiveValue(list.item(0)); | 373 const CSSPrimitiveValue& first = toCSSPrimitiveValue(list.item(0)); |
| 375 CSSPrimitiveValue* second = list.length() == 2 ? &toCSSPrimitiveValue(list.i
tem(1)) : nullptr; | 374 NullableCSSValue second = list.length() == 2 ? NullableCSSValue(list.item(1)
) : nullptr; |
| 376 | 375 |
| 377 switch (first->getValueID()) { | 376 switch (first.getValueID()) { |
| 378 case CSSValueRow: | 377 case CSSValueRow: |
| 379 if (second && second->getValueID() == CSSValueDense) | 378 if (second && toCSSPrimitiveValue(second).getValueID() == CSSValueDense) |
| 380 return AutoFlowRowDense; | 379 return AutoFlowRowDense; |
| 381 return AutoFlowRow; | 380 return AutoFlowRow; |
| 382 case CSSValueColumn: | 381 case CSSValueColumn: |
| 383 if (second && second->getValueID() == CSSValueDense) | 382 if (second && toCSSPrimitiveValue(second).getValueID() == CSSValueDense) |
| 384 return AutoFlowColumnDense; | 383 return AutoFlowColumnDense; |
| 385 return AutoFlowColumn; | 384 return AutoFlowColumn; |
| 386 case CSSValueDense: | 385 case CSSValueDense: |
| 387 if (second && second->getValueID() == CSSValueColumn) | 386 if (second && toCSSPrimitiveValue(second).getValueID() == CSSValueColumn
) |
| 388 return AutoFlowColumnDense; | 387 return AutoFlowColumnDense; |
| 389 return AutoFlowRowDense; | 388 return AutoFlowRowDense; |
| 390 default: | 389 default: |
| 391 ASSERT_NOT_REACHED(); | 390 ASSERT_NOT_REACHED(); |
| 392 return ComputedStyle::initialGridAutoFlow(); | 391 return ComputedStyle::initialGridAutoFlow(); |
| 393 } | 392 } |
| 394 } | 393 } |
| 395 | 394 |
| 396 GridPosition StyleBuilderConverter::convertGridPosition(StyleResolverState&, con
st CSSValue& value) | 395 GridPosition StyleBuilderConverter::convertGridPosition(StyleResolverState&, con
st CSSValue& value) |
| 397 { | 396 { |
| 398 // We accept the specification's grammar: | 397 // We accept the specification's grammar: |
| 399 // 'auto' | [ <integer> || <custom-ident> ] | [ span && [ <integer> || <cust
om-ident> ] ] | <custom-ident> | 398 // 'auto' | [ <integer> || <custom-ident> ] | [ span && [ <integer> || <cust
om-ident> ] ] | <custom-ident> |
| 400 | 399 |
| 401 GridPosition position; | 400 GridPosition position; |
| 402 | 401 |
| 403 if (value.isPrimitiveValue()) { | 402 if (value.isPrimitiveValue()) { |
| 404 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 403 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 405 // We translate <custom-ident> to <string> during parsing as it | 404 // We translate <custom-ident> to <string> during parsing as it |
| 406 // makes handling it more simple. | 405 // makes handling it more simple. |
| 407 if (primitiveValue.isCustomIdent()) { | 406 if (primitiveValue.isCustomIdent()) { |
| 408 position.setNamedGridArea(primitiveValue.getStringValue()); | 407 position.setNamedGridArea(primitiveValue.getStringValue()); |
| 409 return position; | 408 return position; |
| 410 } | 409 } |
| 411 | 410 |
| 412 ASSERT(primitiveValue.getValueID() == CSSValueAuto); | 411 ASSERT(primitiveValue.getValueID() == CSSValueAuto); |
| 413 return position; | 412 return position; |
| 414 } | 413 } |
| 415 | 414 |
| 416 CSSValueList& values = toCSSValueList(value); | 415 CSSValueList& values = toCSSValueList(value); |
| 417 ASSERT(values.length()); | 416 ASSERT(values.length()); |
| 418 | 417 |
| 419 bool isSpanPosition = false; | 418 bool isSpanPosition = false; |
| 420 // The specification makes the <integer> optional, in which case it default
to '1'. | 419 // The specification makes the <integer> optional, in which case it default
to '1'. |
| 421 int gridLineNumber = 1; | 420 int gridLineNumber = 1; |
| 422 String gridLineName; | 421 String gridLineName; |
| 423 | 422 |
| 424 auto it = values.begin(); | 423 auto it = values.begin(); |
| 425 CSSPrimitiveValue* currentValue = &toCSSPrimitiveValue(*it); | 424 NullableCSSValue currentValue = *it; |
| 426 if (currentValue->getValueID() == CSSValueSpan) { | 425 if (toCSSPrimitiveValue(currentValue).getValueID() == CSSValueSpan) { |
| 427 isSpanPosition = true; | 426 isSpanPosition = true; |
| 428 ++it; | 427 ++it; |
| 429 currentValue = it != values.end() ? &toCSSPrimitiveValue(*it) : 0; | 428 currentValue = it != values.end() ? *it : NullableCSSValue(); |
| 430 } | 429 } |
| 431 | 430 |
| 432 if (currentValue && currentValue->isNumber()) { | 431 if (currentValue && toCSSPrimitiveValue(currentValue).isNumber()) { |
| 433 gridLineNumber = currentValue->getIntValue(); | 432 gridLineNumber = toCSSPrimitiveValue(currentValue).getIntValue(); |
| 434 ++it; | 433 ++it; |
| 435 currentValue = it != values.end() ? &toCSSPrimitiveValue(*it) : 0; | 434 currentValue = it != values.end() ? *it : NullableCSSValue(); |
| 436 } | 435 } |
| 437 | 436 |
| 438 if (currentValue && currentValue->isCustomIdent()) { | 437 if (currentValue && toCSSPrimitiveValue(currentValue).isCustomIdent()) { |
| 439 gridLineName = currentValue->getStringValue(); | 438 gridLineName = toCSSPrimitiveValue(currentValue).getStringValue(); |
| 440 ++it; | 439 ++it; |
| 441 } | 440 } |
| 442 | 441 |
| 443 ASSERT(it == values.end()); | 442 ASSERT(it == values.end()); |
| 444 if (isSpanPosition) | 443 if (isSpanPosition) |
| 445 position.setSpanPosition(gridLineNumber, gridLineName); | 444 position.setSpanPosition(gridLineNumber, gridLineName); |
| 446 else | 445 else |
| 447 position.setExplicitPosition(gridLineNumber, gridLineName); | 446 position.setExplicitPosition(gridLineNumber, gridLineName); |
| 448 | 447 |
| 449 return position; | 448 return position; |
| 450 } | 449 } |
| 451 | 450 |
| 452 GridTrackSize StyleBuilderConverter::convertGridTrackSize(StyleResolverState& st
ate, const CSSValue& value) | 451 GridTrackSize StyleBuilderConverter::convertGridTrackSize(StyleResolverState& st
ate, const CSSValue& value) |
| 453 { | 452 { |
| 454 if (value.isPrimitiveValue()) | 453 if (value.isPrimitiveValue()) |
| 455 return GridTrackSize(convertGridTrackBreadth(state, &toCSSPrimitiveValue
(value))); | 454 return GridTrackSize(convertGridTrackBreadth(state, toCSSPrimitiveValue(
value))); |
| 456 | 455 |
| 457 CSSFunctionValue& minmaxFunction = toCSSFunctionValue(value); | 456 CSSFunctionValue& minmaxFunction = toCSSFunctionValue(value); |
| 458 ASSERT_WITH_SECURITY_IMPLICATION(minmaxFunction.length() == 2); | 457 ASSERT_WITH_SECURITY_IMPLICATION(minmaxFunction.length() == 2); |
| 459 GridLength minTrackBreadth(convertGridTrackBreadth(state, &toCSSPrimitiveVal
ue(minmaxFunction.item(0)))); | 458 GridLength minTrackBreadth(convertGridTrackBreadth(state, toCSSPrimitiveValu
e(minmaxFunction.item(0)))); |
| 460 GridLength maxTrackBreadth(convertGridTrackBreadth(state, &toCSSPrimitiveVal
ue(minmaxFunction.item(1)))); | 459 GridLength maxTrackBreadth(convertGridTrackBreadth(state, toCSSPrimitiveValu
e(minmaxFunction.item(1)))); |
| 461 return GridTrackSize(minTrackBreadth, maxTrackBreadth); | 460 return GridTrackSize(minTrackBreadth, maxTrackBreadth); |
| 462 } | 461 } |
| 463 | 462 |
| 464 bool StyleBuilderConverter::convertGridTrackList(CSSValue value, Vector<GridTrac
kSize>& trackSizes, NamedGridLinesMap& namedGridLines, OrderedNamedGridLines& or
deredNamedGridLines, StyleResolverState& state) | 463 bool StyleBuilderConverter::convertGridTrackList(const CSSValue& value, Vector<G
ridTrackSize>& trackSizes, NamedGridLinesMap& namedGridLines, OrderedNamedGridLi
nes& orderedNamedGridLines, StyleResolverState& state) |
| 465 { | 464 { |
| 466 // Handle 'none'. | 465 // Handle 'none'. |
| 467 if (value.isPrimitiveValue()) { | 466 if (value.isPrimitiveValue()) { |
| 468 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 467 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 469 return primitiveValue.getValueID() == CSSValueNone; | 468 return primitiveValue.getValueID() == CSSValueNone; |
| 470 } | 469 } |
| 471 | 470 |
| 472 if (!value.isValueList()) | 471 if (!value.isValueList()) |
| 473 return false; | 472 return false; |
| 474 | 473 |
| 475 size_t currentNamedGridLine = 0; | 474 size_t currentNamedGridLine = 0; |
| 476 for (auto& currValue : toCSSValueList(value)) { | 475 for (auto& currValue : toCSSValueList(value)) { |
| 477 if (currValue.isGridLineNamesValue()) { | 476 if (currValue.isGridLineNamesValue()) { |
| 478 for (auto& namedGridLineValue : toCSSGridLineNamesValue(currValue))
{ | 477 for (auto& namedGridLineValue : toCSSGridLineNamesValue(currValue))
{ |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 return toCSSPrimitiveValue(value).convertToLength(state.cssToLengthConversio
nData()); | 536 return toCSSPrimitiveValue(value).convertToLength(state.cssToLengthConversio
nData()); |
| 538 } | 537 } |
| 539 | 538 |
| 540 UnzoomedLength StyleBuilderConverter::convertUnzoomedLength(const StyleResolverS
tate& state, const CSSValue& value) | 539 UnzoomedLength StyleBuilderConverter::convertUnzoomedLength(const StyleResolverS
tate& state, const CSSValue& value) |
| 541 { | 540 { |
| 542 return UnzoomedLength(toCSSPrimitiveValue(value).convertToLength(state.cssTo
LengthConversionData().copyWithAdjustedZoom(1.0f))); | 541 return UnzoomedLength(toCSSPrimitiveValue(value).convertToLength(state.cssTo
LengthConversionData().copyWithAdjustedZoom(1.0f))); |
| 543 } | 542 } |
| 544 | 543 |
| 545 Length StyleBuilderConverter::convertLengthOrAuto(const StyleResolverState& stat
e, const CSSValue& value) | 544 Length StyleBuilderConverter::convertLengthOrAuto(const StyleResolverState& stat
e, const CSSValue& value) |
| 546 { | 545 { |
| 547 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 546 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 548 if (primitiveValue.getValueID() == CSSValueAuto) | 547 if (primitiveValue.getValueID() == CSSValueAuto) |
| 549 return Length(Auto); | 548 return Length(Auto); |
| 550 return primitiveValue.convertToLength(state.cssToLengthConversionData()); | 549 return primitiveValue.convertToLength(state.cssToLengthConversionData()); |
| 551 } | 550 } |
| 552 | 551 |
| 553 Length StyleBuilderConverter::convertLengthSizing(StyleResolverState& state, con
st CSSValue& value) | 552 Length StyleBuilderConverter::convertLengthSizing(StyleResolverState& state, con
st CSSValue& value) |
| 554 { | 553 { |
| 555 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 554 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 556 switch (primitiveValue.getValueID()) { | 555 switch (primitiveValue.getValueID()) { |
| 557 case CSSValueInvalid: | 556 case CSSValueInvalid: |
| 558 return convertLength(state, value); | 557 return convertLength(state, value); |
| 559 case CSSValueIntrinsic: | 558 case CSSValueIntrinsic: |
| 560 return Length(Intrinsic); | 559 return Length(Intrinsic); |
| 561 case CSSValueMinIntrinsic: | 560 case CSSValueMinIntrinsic: |
| 562 return Length(MinIntrinsic); | 561 return Length(MinIntrinsic); |
| 563 case CSSValueMinContent: | 562 case CSSValueMinContent: |
| 564 case CSSValueWebkitMinContent: | 563 case CSSValueWebkitMinContent: |
| 565 return Length(MinContent); | 564 return Length(MinContent); |
| 566 case CSSValueMaxContent: | 565 case CSSValueMaxContent: |
| 567 case CSSValueWebkitMaxContent: | 566 case CSSValueWebkitMaxContent: |
| 568 return Length(MaxContent); | 567 return Length(MaxContent); |
| 569 case CSSValueWebkitFillAvailable: | 568 case CSSValueWebkitFillAvailable: |
| 570 return Length(FillAvailable); | 569 return Length(FillAvailable); |
| 571 case CSSValueWebkitFitContent: | 570 case CSSValueWebkitFitContent: |
| 572 return Length(FitContent); | 571 return Length(FitContent); |
| 573 case CSSValueAuto: | 572 case CSSValueAuto: |
| 574 return Length(Auto); | 573 return Length(Auto); |
| 575 default: | 574 default: |
| 576 ASSERT_NOT_REACHED(); | 575 ASSERT_NOT_REACHED(); |
| 577 return Length(); | 576 return Length(); |
| 578 } | 577 } |
| 579 } | 578 } |
| 580 | 579 |
| 581 Length StyleBuilderConverter::convertLengthMaxSizing(StyleResolverState& state,
const CSSValue& value) | 580 Length StyleBuilderConverter::convertLengthMaxSizing(StyleResolverState& state,
const CSSValue& value) |
| 582 { | 581 { |
| 583 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 582 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 584 if (primitiveValue.getValueID() == CSSValueNone) | 583 if (primitiveValue.getValueID() == CSSValueNone) |
| 585 return Length(MaxSizeNone); | 584 return Length(MaxSizeNone); |
| 586 return convertLengthSizing(state, value); | 585 return convertLengthSizing(state, value); |
| 587 } | 586 } |
| 588 | 587 |
| 589 TabSize StyleBuilderConverter::convertLengthOrTabSpaces(StyleResolverState& stat
e, const CSSValue& value) | 588 TabSize StyleBuilderConverter::convertLengthOrTabSpaces(StyleResolverState& stat
e, const CSSValue& value) |
| 590 { | 589 { |
| 591 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 590 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 592 if (primitiveValue.isNumber()) | 591 if (primitiveValue.isNumber()) |
| 593 return TabSize(primitiveValue.getIntValue()); | 592 return TabSize(primitiveValue.getIntValue()); |
| 594 return TabSize(primitiveValue.computeLength<float>(state.cssToLengthConversi
onData())); | 593 return TabSize(primitiveValue.computeLength<float>(state.cssToLengthConversi
onData())); |
| 595 } | 594 } |
| 596 | 595 |
| 597 LineBoxContain StyleBuilderConverter::convertLineBoxContain(StyleResolverState&,
const CSSValue& value) | 596 LineBoxContain StyleBuilderConverter::convertLineBoxContain(StyleResolverState&,
const CSSValue& value) |
| 598 { | 597 { |
| 599 if (value.isPrimitiveValue()) { | 598 if (value.isPrimitiveValue()) { |
| 600 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNone); | 599 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNone); |
| 601 return LineBoxContainNone; | 600 return LineBoxContainNone; |
| 602 } | 601 } |
| 603 | 602 |
| 604 return toCSSLineBoxContainValue(value).value(); | 603 return toCSSLineBoxContainValue(value).value(); |
| 605 } | 604 } |
| 606 | 605 |
| 607 static CSSToLengthConversionData lineHeightToLengthConversionData(StyleResolverS
tate& state) | 606 static CSSToLengthConversionData lineHeightToLengthConversionData(StyleResolverS
tate& state) |
| 608 { | 607 { |
| 609 float multiplier = state.style()->effectiveZoom(); | 608 float multiplier = state.style()->effectiveZoom(); |
| 610 if (LocalFrame* frame = state.document().frame()) | 609 if (LocalFrame* frame = state.document().frame()) |
| 611 multiplier *= frame->textZoomFactor(); | 610 multiplier *= frame->textZoomFactor(); |
| 612 return state.cssToLengthConversionData().copyWithAdjustedZoom(multiplier); | 611 return state.cssToLengthConversionData().copyWithAdjustedZoom(multiplier); |
| 613 } | 612 } |
| 614 | 613 |
| 615 Length StyleBuilderConverter::convertLineHeight(StyleResolverState& state, const
CSSValue& value) | 614 Length StyleBuilderConverter::convertLineHeight(StyleResolverState& state, const
CSSValue& value) |
| 616 { | 615 { |
| 617 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 616 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 618 | 617 |
| 619 if (primitiveValue.isLength()) | 618 if (primitiveValue.isLength()) |
| 620 return primitiveValue.computeLength<Length>(lineHeightToLengthConversion
Data(state)); | 619 return primitiveValue.computeLength<Length>(lineHeightToLengthConversion
Data(state)); |
| 621 if (primitiveValue.isPercentage()) | 620 if (primitiveValue.isPercentage()) |
| 622 return Length((state.style()->computedFontSize() * primitiveValue.getInt
Value()) / 100.0, Fixed); | 621 return Length((state.style()->computedFontSize() * primitiveValue.getInt
Value()) / 100.0, Fixed); |
| 623 if (primitiveValue.isNumber()) | 622 if (primitiveValue.isNumber()) |
| 624 return Length(primitiveValue.getDoubleValue() * 100.0, Percent); | 623 return Length(primitiveValue.getDoubleValue() * 100.0, Percent); |
| 625 if (primitiveValue.isCalculated()) { | 624 if (primitiveValue.isCalculated()) { |
| 626 Length zoomedLength = Length(primitiveValue.cssCalcValue()->toCalcValue(
lineHeightToLengthConversionData(state))); | 625 Length zoomedLength = Length(primitiveValue.cssCalcValue()->toCalcValue(
lineHeightToLengthConversionData(state))); |
| 627 return Length(valueForLength(zoomedLength, state.style()->fontSize()), F
ixed); | 626 return Length(valueForLength(zoomedLength, state.style()->fontSize()), F
ixed); |
| 628 } | 627 } |
| 629 | 628 |
| 630 ASSERT(primitiveValue.getValueID() == CSSValueNormal); | 629 ASSERT(primitiveValue.getValueID() == CSSValueNormal); |
| 631 return ComputedStyle::initialLineHeight(); | 630 return ComputedStyle::initialLineHeight(); |
| 632 } | 631 } |
| 633 | 632 |
| 634 float StyleBuilderConverter::convertNumberOrPercentage(StyleResolverState& state
, const CSSValue& value) | 633 float StyleBuilderConverter::convertNumberOrPercentage(StyleResolverState& state
, const CSSValue& value) |
| 635 { | 634 { |
| 636 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 635 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 637 ASSERT(primitiveValue.isNumber() || primitiveValue.isPercentage()); | 636 ASSERT(primitiveValue.isNumber() || primitiveValue.isPercentage()); |
| 638 if (primitiveValue.isNumber()) | 637 if (primitiveValue.isNumber()) |
| 639 return primitiveValue.getFloatValue(); | 638 return primitiveValue.getFloatValue(); |
| 640 return primitiveValue.getFloatValue() / 100.0f; | 639 return primitiveValue.getFloatValue() / 100.0f; |
| 641 } | 640 } |
| 642 | 641 |
| 643 template <CSSValueID cssValueFor0, CSSValueID cssValueFor100> | 642 template <CSSValueID cssValueFor0, CSSValueID cssValueFor100> |
| 644 static Length convertPositionLength(StyleResolverState& state, CSSPrimitiveValue
* primitiveValue) | 643 static Length convertPositionLength(StyleResolverState& state, CSSPrimitiveValue
primitiveValue) |
| 645 { | 644 { |
| 646 if (Pair* pair = primitiveValue->getPairValue()) { | 645 if (Pair* pair = primitiveValue.getPairValue()) { |
| 647 Length length = StyleBuilderConverter::convertLength(state, CSSValue(*pa
ir->second())); | 646 Length length = StyleBuilderConverter::convertLength(state, CSSValue(pai
r->second())); |
| 648 if (pair->first()->getValueID() == cssValueFor0) | 647 if (pair->first().getValueID() == cssValueFor0) |
| 649 return length; | 648 return length; |
| 650 ASSERT(pair->first()->getValueID() == cssValueFor100); | 649 ASSERT(pair->first().getValueID() == cssValueFor100); |
| 651 return length.subtractFromOneHundredPercent(); | 650 return length.subtractFromOneHundredPercent(); |
| 652 } | 651 } |
| 653 | 652 |
| 654 return StyleBuilderConverter::convertLength(state, CSSValue(*primitiveValue)
); | 653 return StyleBuilderConverter::convertLength(state, primitiveValue); |
| 655 } | 654 } |
| 656 | 655 |
| 657 LengthPoint StyleBuilderConverter::convertPosition(StyleResolverState& state, co
nst CSSValue& value) | 656 LengthPoint StyleBuilderConverter::convertPosition(StyleResolverState& state, co
nst CSSValue& value) |
| 658 { | 657 { |
| 659 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 658 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 660 Pair* pair = primitiveValue.getPairValue(); | 659 Pair* pair = primitiveValue.getPairValue(); |
| 661 return LengthPoint( | 660 return LengthPoint( |
| 662 convertPositionLength<CSSValueLeft, CSSValueRight>(state, pair->first())
, | 661 convertPositionLength<CSSValueLeft, CSSValueRight>(state, pair->first())
, |
| 663 convertPositionLength<CSSValueTop, CSSValueBottom>(state, pair->second()
) | 662 convertPositionLength<CSSValueTop, CSSValueBottom>(state, pair->second()
) |
| 664 ); | 663 ); |
| 665 } | 664 } |
| 666 | 665 |
| 667 static float convertPerspectiveLength(StyleResolverState& state, CSSPrimitiveVal
ue& primitiveValue) | 666 static float convertPerspectiveLength(StyleResolverState& state, CSSPrimitiveVal
ue primitiveValue) |
| 668 { | 667 { |
| 669 return std::max(primitiveValue.computeLength<float>(state.cssToLengthConvers
ionData()), 0.0f); | 668 return std::max(primitiveValue.computeLength<float>(state.cssToLengthConvers
ionData()), 0.0f); |
| 670 } | 669 } |
| 671 | 670 |
| 672 float StyleBuilderConverter::convertPerspective(StyleResolverState& state, const
CSSValue& value) | 671 float StyleBuilderConverter::convertPerspective(StyleResolverState& state, const
CSSValue& value) |
| 673 { | 672 { |
| 674 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 673 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 675 | 674 |
| 676 if (primitiveValue.getValueID() == CSSValueNone) | 675 if (primitiveValue.getValueID() == CSSValueNone) |
| 677 return ComputedStyle::initialPerspective(); | 676 return ComputedStyle::initialPerspective(); |
| 678 return convertPerspectiveLength(state, primitiveValue); | 677 return convertPerspectiveLength(state, primitiveValue); |
| 679 } | 678 } |
| 680 | 679 |
| 681 template <CSSValueID cssValueFor0, CSSValueID cssValueFor100> | 680 template <CSSValueID cssValueFor0, CSSValueID cssValueFor100> |
| 682 static Length convertOriginLength(StyleResolverState& state, CSSPrimitiveValue&
primitiveValue) | 681 static Length convertOriginLength(StyleResolverState& state, CSSPrimitiveValue p
rimitiveValue) |
| 683 { | 682 { |
| 684 if (primitiveValue.isValueID()) { | 683 if (primitiveValue.isValueID()) { |
| 685 switch (primitiveValue.getValueID()) { | 684 switch (primitiveValue.getValueID()) { |
| 686 case cssValueFor0: | 685 case cssValueFor0: |
| 687 return Length(0, Percent); | 686 return Length(0, Percent); |
| 688 case cssValueFor100: | 687 case cssValueFor100: |
| 689 return Length(100, Percent); | 688 return Length(100, Percent); |
| 690 case CSSValueCenter: | 689 case CSSValueCenter: |
| 691 return Length(50, Percent); | 690 return Length(50, Percent); |
| 692 default: | 691 default: |
| 693 ASSERT_NOT_REACHED(); | 692 ASSERT_NOT_REACHED(); |
| 694 } | 693 } |
| 695 } | 694 } |
| 696 | 695 |
| 697 return StyleBuilderConverter::convertLength(state, CSSValue(primitiveValue))
; | 696 return StyleBuilderConverter::convertLength(state, CSSValue(primitiveValue))
; |
| 698 } | 697 } |
| 699 | 698 |
| 700 LengthPoint StyleBuilderConverter::convertPerspectiveOrigin(StyleResolverState&
state, const CSSValue& value) | 699 LengthPoint StyleBuilderConverter::convertPerspectiveOrigin(StyleResolverState&
state, const CSSValue& value) |
| 701 { | 700 { |
| 702 CSSValueList& list = toCSSValueList(value); | 701 CSSValueList& list = toCSSValueList(value); |
| 703 ASSERT(list.length() == 2); | 702 ASSERT(list.length() == 2); |
| 704 | 703 |
| 705 CSSPrimitiveValue& primitiveValueX = toCSSPrimitiveValue(list.item(0)); | 704 const CSSPrimitiveValue& primitiveValueX = toCSSPrimitiveValue(list.item(0))
; |
| 706 CSSPrimitiveValue& primitiveValueY = toCSSPrimitiveValue(list.item(1)); | 705 const CSSPrimitiveValue& primitiveValueY = toCSSPrimitiveValue(list.item(1))
; |
| 707 | 706 |
| 708 return LengthPoint( | 707 return LengthPoint( |
| 709 convertOriginLength<CSSValueLeft, CSSValueRight>(state, primitiveValueX)
, | 708 convertOriginLength<CSSValueLeft, CSSValueRight>(state, primitiveValueX)
, |
| 710 convertOriginLength<CSSValueTop, CSSValueBottom>(state, primitiveValueY) | 709 convertOriginLength<CSSValueTop, CSSValueBottom>(state, primitiveValueY) |
| 711 ); | 710 ); |
| 712 } | 711 } |
| 713 | 712 |
| 714 EPaintOrder StyleBuilderConverter::convertPaintOrder(StyleResolverState&, const
CSSValue& cssPaintOrder) | 713 EPaintOrder StyleBuilderConverter::convertPaintOrder(StyleResolverState&, const
CSSValue& cssPaintOrder) |
| 715 { | 714 { |
| 716 if (cssPaintOrder.isValueList()) { | 715 if (cssPaintOrder.isValueList()) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 quotes->addPair(std::make_pair(startQuote, endQuote)); | 761 quotes->addPair(std::make_pair(startQuote, endQuote)); |
| 763 } | 762 } |
| 764 return quotes.release(); | 763 return quotes.release(); |
| 765 } | 764 } |
| 766 // FIXME: We should assert we're a primitive value with valueID = CSSValueNo
ne | 765 // FIXME: We should assert we're a primitive value with valueID = CSSValueNo
ne |
| 767 return QuotesData::create(); | 766 return QuotesData::create(); |
| 768 } | 767 } |
| 769 | 768 |
| 770 LengthSize StyleBuilderConverter::convertRadius(StyleResolverState& state, const
CSSValue& value) | 769 LengthSize StyleBuilderConverter::convertRadius(StyleResolverState& state, const
CSSValue& value) |
| 771 { | 770 { |
| 772 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 771 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 773 Pair* pair = primitiveValue.getPairValue(); | 772 Pair* pair = primitiveValue.getPairValue(); |
| 774 Length radiusWidth = pair->first()->convertToLength(state.cssToLengthConvers
ionData()); | 773 Length radiusWidth = pair->first().convertToLength(state.cssToLengthConversi
onData()); |
| 775 Length radiusHeight = pair->second()->convertToLength(state.cssToLengthConve
rsionData()); | 774 Length radiusHeight = pair->second().convertToLength(state.cssToLengthConver
sionData()); |
| 776 float width = radiusWidth.value(); | 775 float width = radiusWidth.value(); |
| 777 float height = radiusHeight.value(); | 776 float height = radiusHeight.value(); |
| 778 ASSERT(width >= 0 && height >= 0); | 777 ASSERT(width >= 0 && height >= 0); |
| 779 if (width <= 0 || height <= 0) | 778 if (width <= 0 || height <= 0) |
| 780 return LengthSize(Length(0, Fixed), Length(0, Fixed)); | 779 return LengthSize(Length(0, Fixed), Length(0, Fixed)); |
| 781 return LengthSize(radiusWidth, radiusHeight); | 780 return LengthSize(radiusWidth, radiusHeight); |
| 782 } | 781 } |
| 783 | 782 |
| 784 PassRefPtr<ShadowList> StyleBuilderConverter::convertShadow(StyleResolverState&
state, const CSSValue& value) | 783 PassRefPtr<ShadowList> StyleBuilderConverter::convertShadow(StyleResolverState&
state, const CSSValue& value) |
| 785 { | 784 { |
| 786 if (value.isPrimitiveValue()) { | 785 if (value.isPrimitiveValue()) { |
| 787 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNone); | 786 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNone); |
| 788 return PassRefPtr<ShadowList>(); | 787 return PassRefPtr<ShadowList>(); |
| 789 } | 788 } |
| 790 | 789 |
| 791 const CSSValueList& valueList = toCSSValueList(value); | 790 const CSSValueList& valueList = toCSSValueList(value); |
| 792 size_t shadowCount = valueList.length(); | 791 size_t shadowCount = valueList.length(); |
| 793 ShadowDataVector shadows; | 792 ShadowDataVector shadows; |
| 794 for (size_t i = 0; i < shadowCount; ++i) { | 793 for (size_t i = 0; i < shadowCount; ++i) { |
| 795 const CSSShadowValue& item = toCSSShadowValue(valueList.item(i)); | 794 const CSSShadowValue& item = toCSSShadowValue(valueList.item(i)); |
| 796 float x = item.x->computeLength<float>(state.cssToLengthConversionData()
); | 795 float x = toCSSPrimitiveValue(item.x).computeLength<float>(state.cssToLe
ngthConversionData()); |
| 797 float y = item.y->computeLength<float>(state.cssToLengthConversionData()
); | 796 float y = toCSSPrimitiveValue(item.y).computeLength<float>(state.cssToLe
ngthConversionData()); |
| 798 float blur = item.blur ? item.blur->computeLength<float>(state.cssToLeng
thConversionData()) : 0; | 797 float blur = item.blur ? toCSSPrimitiveValue(item.blur).computeLength<fl
oat>(state.cssToLengthConversionData()) : 0; |
| 799 float spread = item.spread ? item.spread->computeLength<float>(state.css
ToLengthConversionData()) : 0; | 798 float spread = item.spread ? toCSSPrimitiveValue(item.spread).computeLen
gth<float>(state.cssToLengthConversionData()) : 0; |
| 800 ShadowStyle shadowStyle = item.style && item.style->getValueID() == CSSV
alueInset ? Inset : Normal; | 799 ShadowStyle shadowStyle = item.style && toCSSPrimitiveValue(item.style).
getValueID() == CSSValueInset ? Inset : Normal; |
| 801 StyleColor color = StyleColor::currentColor(); | 800 StyleColor color = StyleColor::currentColor(); |
| 802 if (item.color) | 801 if (item.color) |
| 803 color = convertStyleColor(state, CSSValue(item.color)); | 802 color = convertStyleColor(state, *item.color); |
| 804 shadows.append(ShadowData(FloatPoint(x, y), blur, spread, shadowStyle, c
olor)); | 803 shadows.append(ShadowData(FloatPoint(x, y), blur, spread, shadowStyle, c
olor)); |
| 805 } | 804 } |
| 806 return ShadowList::adopt(shadows); | 805 return ShadowList::adopt(shadows); |
| 807 } | 806 } |
| 808 | 807 |
| 809 PassRefPtr<ShapeValue> StyleBuilderConverter::convertShapeValue(StyleResolverSta
te& state, const CSSValue& value) | 808 PassRefPtr<ShapeValue> StyleBuilderConverter::convertShapeValue(StyleResolverSta
te& state, const CSSValue& value) |
| 810 { | 809 { |
| 811 if (value.isPrimitiveValue()) { | 810 if (value.isPrimitiveValue()) { |
| 812 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNone); | 811 ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueNone); |
| 813 return nullptr; | 812 return nullptr; |
| 814 } | 813 } |
| 815 | 814 |
| 816 if (value.isImageValue() || value.isImageGeneratorValue() || value.isImageSe
tValue()) | 815 if (value.isImageValue() || value.isImageGeneratorValue() || value.isImageSe
tValue()) |
| 817 return ShapeValue::createImageValue(state.styleImage(CSSPropertyShapeOut
side, value)); | 816 return ShapeValue::createImageValue(state.styleImage(CSSPropertyShapeOut
side, value)); |
| 818 | 817 |
| 819 RefPtr<BasicShape> shape; | 818 RefPtr<BasicShape> shape; |
| 820 CSSBoxType cssBox = BoxMissing; | 819 CSSBoxType cssBox = BoxMissing; |
| 821 CSSValueList& valueList = toCSSValueList(value); | 820 CSSValueList& valueList = toCSSValueList(value); |
| 822 for (unsigned i = 0; i < valueList.length(); ++i) { | 821 for (unsigned i = 0; i < valueList.length(); ++i) { |
| 823 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(valueList.item(i
)); | 822 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(valueList.
item(i)); |
| 824 if (primitiveValue.isShape()) | 823 if (primitiveValue.isShape()) |
| 825 shape = basicShapeForValue(state, primitiveValue.getShapeValue()); | 824 shape = basicShapeForValue(state, primitiveValue.getShapeValue()); |
| 826 else | 825 else |
| 827 cssBox = CSSBoxType(primitiveValue); | 826 cssBox = CSSBoxType(primitiveValue); |
| 828 } | 827 } |
| 829 | 828 |
| 830 if (shape) | 829 if (shape) |
| 831 return ShapeValue::createShapeValue(shape.release(), cssBox); | 830 return ShapeValue::createShapeValue(shape.release(), cssBox); |
| 832 | 831 |
| 833 ASSERT(cssBox != BoxMissing); | 832 ASSERT(cssBox != BoxMissing); |
| 834 return ShapeValue::createBoxShapeValue(cssBox); | 833 return ShapeValue::createBoxShapeValue(cssBox); |
| 835 } | 834 } |
| 836 | 835 |
| 837 float StyleBuilderConverter::convertSpacing(StyleResolverState& state, const CSS
Value& value) | 836 float StyleBuilderConverter::convertSpacing(StyleResolverState& state, const CSS
Value& value) |
| 838 { | 837 { |
| 839 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 838 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 840 if (primitiveValue.getValueID() == CSSValueNormal) | 839 if (primitiveValue.getValueID() == CSSValueNormal) |
| 841 return 0; | 840 return 0; |
| 842 return primitiveValue.computeLength<float>(state.cssToLengthConversionData()
); | 841 return primitiveValue.computeLength<float>(state.cssToLengthConversionData()
); |
| 843 } | 842 } |
| 844 | 843 |
| 845 PassRefPtr<SVGDashArray> StyleBuilderConverter::convertStrokeDasharray(StyleReso
lverState& state, const CSSValue& value) | 844 PassRefPtr<SVGDashArray> StyleBuilderConverter::convertStrokeDasharray(StyleReso
lverState& state, const CSSValue& value) |
| 846 { | 845 { |
| 847 if (!value.isValueList()) | 846 if (!value.isValueList()) |
| 848 return SVGComputedStyle::initialStrokeDashArray(); | 847 return SVGComputedStyle::initialStrokeDashArray(); |
| 849 | 848 |
| 850 CSSValueList& dashes = toCSSValueList(value); | 849 CSSValueList& dashes = toCSSValueList(value); |
| 851 | 850 |
| 852 RefPtr<SVGDashArray> array = SVGDashArray::create(); | 851 RefPtr<SVGDashArray> array = SVGDashArray::create(); |
| 853 size_t length = dashes.length(); | 852 size_t length = dashes.length(); |
| 854 for (size_t i = 0; i < length; ++i) { | 853 for (size_t i = 0; i < length; ++i) { |
| 855 CSSValue currValue = dashes.item(i); | 854 CSSValue currValue = dashes.item(i); |
| 856 if (!currValue.isPrimitiveValue()) | 855 if (!currValue.isPrimitiveValue()) |
| 857 continue; | 856 continue; |
| 858 | 857 |
| 859 array->append(convertLength(state, currValue)); | 858 array->append(convertLength(state, currValue)); |
| 860 } | 859 } |
| 861 | 860 |
| 862 return array.release(); | 861 return array.release(); |
| 863 } | 862 } |
| 864 | 863 |
| 865 StyleColor StyleBuilderConverter::convertStyleColor(StyleResolverState& state, C
SSValue value, bool forVisitedLink) | 864 StyleColor StyleBuilderConverter::convertStyleColor(StyleResolverState& state, c
onst CSSValue& value, bool forVisitedLink) |
| 866 { | 865 { |
| 867 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 866 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 868 if (primitiveValue.getValueID() == CSSValueCurrentcolor) | 867 if (primitiveValue.getValueID() == CSSValueCurrentcolor) |
| 869 return StyleColor::currentColor(); | 868 return StyleColor::currentColor(); |
| 870 return state.document().textLinkColors().colorFromPrimitiveValue(primitiveVa
lue, Color(), forVisitedLink); | 869 return state.document().textLinkColors().colorFromPrimitiveValue(primitiveVa
lue, Color(), forVisitedLink); |
| 871 } | 870 } |
| 872 | 871 |
| 873 float StyleBuilderConverter::convertTextStrokeWidth(StyleResolverState& state, c
onst CSSValue& value) | 872 float StyleBuilderConverter::convertTextStrokeWidth(StyleResolverState& state, c
onst CSSValue& value) |
| 874 { | 873 { |
| 875 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 874 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 876 if (primitiveValue.getValueID()) { | 875 if (primitiveValue.getValueID()) { |
| 877 float multiplier = convertLineWidth<float>(state, value); | 876 float multiplier = convertLineWidth<float>(state, value); |
| 878 return CSSPrimitiveValue::create(multiplier / 48, CSSPrimitiveValue::CSS
_EMS)->computeLength<float>(state.cssToLengthConversionData()); | 877 return CSSPrimitiveValue::create(multiplier / 48, CSSPrimitiveValue::CSS
_EMS).computeLength<float>(state.cssToLengthConversionData()); |
| 879 } | 878 } |
| 880 return primitiveValue.computeLength<float>(state.cssToLengthConversionData()
); | 879 return primitiveValue.computeLength<float>(state.cssToLengthConversionData()
); |
| 881 } | 880 } |
| 882 | 881 |
| 883 TransformOrigin StyleBuilderConverter::convertTransformOrigin(StyleResolverState
& state, const CSSValue& value) | 882 TransformOrigin StyleBuilderConverter::convertTransformOrigin(StyleResolverState
& state, const CSSValue& value) |
| 884 { | 883 { |
| 885 CSSValueList& list = toCSSValueList(value); | 884 CSSValueList& list = toCSSValueList(value); |
| 886 ASSERT(list.length() == 3); | 885 ASSERT(list.length() == 3); |
| 887 | 886 |
| 888 CSSPrimitiveValue& primitiveValueX = toCSSPrimitiveValue(list.item(0)); | 887 const CSSPrimitiveValue& primitiveValueX = toCSSPrimitiveValue(list.item(0))
; |
| 889 CSSPrimitiveValue& primitiveValueY = toCSSPrimitiveValue(list.item(1)); | 888 const CSSPrimitiveValue& primitiveValueY = toCSSPrimitiveValue(list.item(1))
; |
| 890 | 889 |
| 891 return TransformOrigin( | 890 return TransformOrigin( |
| 892 convertOriginLength<CSSValueLeft, CSSValueRight>(state, primitiveValueX)
, | 891 convertOriginLength<CSSValueLeft, CSSValueRight>(state, primitiveValueX)
, |
| 893 convertOriginLength<CSSValueTop, CSSValueBottom>(state, primitiveValueY)
, | 892 convertOriginLength<CSSValueTop, CSSValueBottom>(state, primitiveValueY)
, |
| 894 StyleBuilderConverter::convertComputedLength<float>(state, list.item(2)) | 893 StyleBuilderConverter::convertComputedLength<float>(state, list.item(2)) |
| 895 ); | 894 ); |
| 896 } | 895 } |
| 897 | 896 |
| 898 ScrollSnapPoints StyleBuilderConverter::convertSnapPoints(StyleResolverState& st
ate, const CSSValue& value) | 897 ScrollSnapPoints StyleBuilderConverter::convertSnapPoints(StyleResolverState& st
ate, const CSSValue& value) |
| 899 { | 898 { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 double sz = 1; | 969 double sz = 1; |
| 971 if (list.length() >= 2) | 970 if (list.length() >= 2) |
| 972 sy = toCSSPrimitiveValue(list.item(1)).getDoubleValue(); | 971 sy = toCSSPrimitiveValue(list.item(1)).getDoubleValue(); |
| 973 if (list.length() == 3) | 972 if (list.length() == 3) |
| 974 sz = toCSSPrimitiveValue(list.item(2)).getDoubleValue(); | 973 sz = toCSSPrimitiveValue(list.item(2)).getDoubleValue(); |
| 975 | 974 |
| 976 return ScaleTransformOperation::create(sx, sy, sz, TransformOperation::Scale
3D); | 975 return ScaleTransformOperation::create(sx, sy, sz, TransformOperation::Scale
3D); |
| 977 } | 976 } |
| 978 | 977 |
| 979 } // namespace blink | 978 } // namespace blink |
| OLD | NEW |