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