Chromium Code Reviews| 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 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 | 64 |
| 65 namespace blink { | 65 namespace blink { |
| 66 | 66 |
| 67 namespace { | 67 namespace { |
| 68 | 68 |
| 69 Length animatableValueToLengthWithZoom(const AnimatableValue* value, | 69 Length animatableValueToLengthWithZoom(const AnimatableValue* value, |
| 70 float zoom, | 70 float zoom, |
| 71 ValueRange range = ValueRangeAll) { | 71 ValueRange range = ValueRangeAll) { |
| 72 if (value->isLength()) | 72 if (value->isLength()) |
| 73 return toAnimatableLength(value)->getLength(zoom, range); | 73 return toAnimatableLength(value)->getLength(zoom, range); |
| 74 ASSERT(toAnimatableUnknown(value)->toCSSValueID() == CSSValueAuto); | 74 DCHECK_EQ(toAnimatableUnknown(value)->toCSSValueID(), CSSValueAuto); |
| 75 return Length(Auto); | 75 return Length(Auto); |
| 76 } | 76 } |
| 77 | 77 |
| 78 Length animatableValueToLength(const AnimatableValue* value, | 78 Length animatableValueToLength(const AnimatableValue* value, |
| 79 const StyleResolverState& state, | 79 const StyleResolverState& state, |
| 80 ValueRange range = ValueRangeAll) { | 80 ValueRange range = ValueRangeAll) { |
| 81 return animatableValueToLengthWithZoom(value, state.style()->effectiveZoom(), | 81 return animatableValueToLengthWithZoom(value, state.style()->effectiveZoom(), |
| 82 range); | 82 range); |
| 83 } | 83 } |
| 84 | 84 |
| 85 UnzoomedLength animatableValueToUnzoomedLength( | 85 UnzoomedLength animatableValueToUnzoomedLength( |
| 86 const AnimatableValue* value, | 86 const AnimatableValue* value, |
| 87 const StyleResolverState&, | 87 const StyleResolverState&, |
| 88 ValueRange range = ValueRangeAll) { | 88 ValueRange range = ValueRangeAll) { |
| 89 return UnzoomedLength(animatableValueToLengthWithZoom(value, 1, range)); | 89 return UnzoomedLength(animatableValueToLengthWithZoom(value, 1, range)); |
| 90 } | 90 } |
| 91 | 91 |
| 92 BorderImageLength animatableValueToBorderImageLength( | 92 BorderImageLength animatableValueToBorderImageLength( |
| 93 const AnimatableValue* value, | 93 const AnimatableValue* value, |
| 94 const StyleResolverState& state) { | 94 const StyleResolverState& state) { |
| 95 if (value->isLength()) | 95 if (value->isLength()) |
| 96 return BorderImageLength(toAnimatableLength(value)->getLength( | 96 return BorderImageLength(toAnimatableLength(value)->getLength( |
| 97 state.style()->effectiveZoom(), ValueRangeNonNegative)); | 97 state.style()->effectiveZoom(), ValueRangeNonNegative)); |
| 98 if (value->isDouble()) | 98 if (value->isDouble()) |
| 99 return BorderImageLength( | 99 return BorderImageLength( |
| 100 clampTo<double>(toAnimatableDouble(value)->toDouble(), 0)); | 100 clampTo<double>(toAnimatableDouble(value)->toDouble(), 0)); |
| 101 ASSERT(toAnimatableUnknown(value)->toCSSValueID() == CSSValueAuto); | 101 DCHECK_EQ(toAnimatableUnknown(value)->toCSSValueID(), CSSValueAuto); |
| 102 return Length(Auto); | 102 return Length(Auto); |
| 103 } | 103 } |
| 104 | 104 |
| 105 double animatableValueToPixels(const AnimatableValue* value, | 105 double animatableValueToPixels(const AnimatableValue* value, |
| 106 const StyleResolverState& state) { | 106 const StyleResolverState& state) { |
| 107 return toAnimatableLength(value) | 107 return toAnimatableLength(value) |
| 108 ->getLength(state.style()->effectiveZoom(), ValueRangeAll) | 108 ->getLength(state.style()->effectiveZoom(), ValueRangeAll) |
| 109 .pixels(); | 109 .pixels(); |
| 110 } | 110 } |
| 111 | 111 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 CSSToStyleMap::mapFillSize(state, fillLayer, | 204 CSSToStyleMap::mapFillSize(state, fillLayer, |
| 205 *toAnimatableUnknown(value)->toCSSValue()); | 205 *toAnimatableUnknown(value)->toCSSValue()); |
| 206 } | 206 } |
| 207 | 207 |
| 208 template <CSSPropertyID property> | 208 template <CSSPropertyID property> |
| 209 void setOnFillLayers(FillLayer& fillLayers, | 209 void setOnFillLayers(FillLayer& fillLayers, |
| 210 const AnimatableValue* value, | 210 const AnimatableValue* value, |
| 211 StyleResolverState& state) { | 211 StyleResolverState& state) { |
| 212 const Vector<RefPtr<AnimatableValue>>& values = | 212 const Vector<RefPtr<AnimatableValue>>& values = |
| 213 toAnimatableRepeatable(value)->values(); | 213 toAnimatableRepeatable(value)->values(); |
| 214 ASSERT(!values.isEmpty()); | 214 DCHECK(!values.isEmpty()); |
| 215 FillLayer* fillLayer = &fillLayers; | 215 FillLayer* fillLayer = &fillLayers; |
| 216 FillLayer* prev = 0; | 216 FillLayer* prev = 0; |
| 217 for (size_t i = 0; i < values.size(); ++i) { | 217 for (size_t i = 0; i < values.size(); ++i) { |
| 218 if (!fillLayer) | 218 if (!fillLayer) |
| 219 fillLayer = prev->ensureNext(); | 219 fillLayer = prev->ensureNext(); |
| 220 const AnimatableValue* layerValue = values[i].get(); | 220 const AnimatableValue* layerValue = values[i].get(); |
| 221 switch (property) { | 221 switch (property) { |
| 222 case CSSPropertyBackgroundImage: | 222 case CSSPropertyBackgroundImage: |
| 223 case CSSPropertyWebkitMaskImage: | 223 case CSSPropertyWebkitMaskImage: |
| 224 if (layerValue->isImage()) { | 224 if (layerValue->isImage()) { |
| 225 fillLayer->setImage(state.styleImage( | 225 fillLayer->setImage(state.styleImage( |
| 226 property, *toAnimatableImage(layerValue)->toCSSValue())); | 226 property, *toAnimatableImage(layerValue)->toCSSValue())); |
| 227 } else { | 227 } else { |
| 228 ASSERT(toAnimatableUnknown(layerValue)->toCSSValueID() == | 228 DCHECK_EQ(toAnimatableUnknown(layerValue)->toCSSValueID(), |
| 229 CSSValueNone); | 229 CSSValueNone); |
| 230 fillLayer->setImage(nullptr); | 230 fillLayer->setImage(nullptr); |
| 231 } | 231 } |
| 232 break; | 232 break; |
| 233 case CSSPropertyBackgroundPositionX: | 233 case CSSPropertyBackgroundPositionX: |
| 234 case CSSPropertyWebkitMaskPositionX: | 234 case CSSPropertyWebkitMaskPositionX: |
| 235 fillLayer->setXPosition(animatableValueToLength(layerValue, state)); | 235 fillLayer->setXPosition(animatableValueToLength(layerValue, state)); |
| 236 break; | 236 break; |
| 237 case CSSPropertyBackgroundPositionY: | 237 case CSSPropertyBackgroundPositionY: |
| 238 case CSSPropertyWebkitMaskPositionY: | 238 case CSSPropertyWebkitMaskPositionY: |
| 239 fillLayer->setYPosition(animatableValueToLength(layerValue, state)); | 239 fillLayer->setYPosition(animatableValueToLength(layerValue, state)); |
| 240 break; | 240 break; |
| 241 case CSSPropertyBackgroundSize: | 241 case CSSPropertyBackgroundSize: |
| 242 case CSSPropertyWebkitMaskSize: | 242 case CSSPropertyWebkitMaskSize: |
| 243 setFillSize(fillLayer, layerValue, state); | 243 setFillSize(fillLayer, layerValue, state); |
| 244 break; | 244 break; |
| 245 default: | 245 default: |
| 246 ASSERT_NOT_REACHED(); | 246 NOTREACHED(); |
| 247 } | 247 } |
| 248 prev = fillLayer; | 248 prev = fillLayer; |
| 249 fillLayer = fillLayer->next(); | 249 fillLayer = fillLayer->next(); |
| 250 } | 250 } |
| 251 while (fillLayer) { | 251 while (fillLayer) { |
| 252 switch (property) { | 252 switch (property) { |
| 253 case CSSPropertyBackgroundImage: | 253 case CSSPropertyBackgroundImage: |
| 254 case CSSPropertyWebkitMaskImage: | 254 case CSSPropertyWebkitMaskImage: |
| 255 fillLayer->clearImage(); | 255 fillLayer->clearImage(); |
| 256 break; | 256 break; |
| 257 case CSSPropertyBackgroundPositionX: | 257 case CSSPropertyBackgroundPositionX: |
| 258 case CSSPropertyWebkitMaskPositionX: | 258 case CSSPropertyWebkitMaskPositionX: |
| 259 fillLayer->clearXPosition(); | 259 fillLayer->clearXPosition(); |
| 260 break; | 260 break; |
| 261 case CSSPropertyBackgroundPositionY: | 261 case CSSPropertyBackgroundPositionY: |
| 262 case CSSPropertyWebkitMaskPositionY: | 262 case CSSPropertyWebkitMaskPositionY: |
| 263 fillLayer->clearYPosition(); | 263 fillLayer->clearYPosition(); |
| 264 break; | 264 break; |
| 265 case CSSPropertyBackgroundSize: | 265 case CSSPropertyBackgroundSize: |
| 266 case CSSPropertyWebkitMaskSize: | 266 case CSSPropertyWebkitMaskSize: |
| 267 fillLayer->clearSize(); | 267 fillLayer->clearSize(); |
| 268 break; | 268 break; |
| 269 default: | 269 default: |
| 270 ASSERT_NOT_REACHED(); | 270 NOTREACHED(); |
| 271 } | 271 } |
| 272 fillLayer = fillLayer->next(); | 272 fillLayer = fillLayer->next(); |
| 273 } | 273 } |
| 274 } | 274 } |
| 275 | 275 |
| 276 FontStretch animatableValueToFontStretch(const AnimatableValue* value) { | 276 FontStretch animatableValueToFontStretch(const AnimatableValue* value) { |
| 277 ASSERT(FontStretchUltraCondensed == 1 && FontStretchUltraExpanded == 9); | 277 DCHECK_EQ(FontStretchUltraCondensed, 1); |
| 278 DCHECK_EQ(FontStretchUltraExpanded, 9); | |
| 278 unsigned index = round(toAnimatableDouble(value)->toDouble()) - 1; | 279 unsigned index = round(toAnimatableDouble(value)->toDouble()) - 1; |
| 279 static const FontStretch stretchValues[] = { | 280 static const FontStretch stretchValues[] = { |
| 280 FontStretchUltraCondensed, FontStretchExtraCondensed, | 281 FontStretchUltraCondensed, FontStretchExtraCondensed, |
| 281 FontStretchCondensed, FontStretchSemiCondensed, | 282 FontStretchCondensed, FontStretchSemiCondensed, |
| 282 FontStretchNormal, FontStretchSemiExpanded, | 283 FontStretchNormal, FontStretchSemiExpanded, |
| 283 FontStretchExpanded, FontStretchExtraExpanded, | 284 FontStretchExpanded, FontStretchExtraExpanded, |
| 284 FontStretchUltraExpanded}; | 285 FontStretchUltraExpanded}; |
| 285 | 286 |
| 286 index = clampTo<unsigned>(index, 0, WTF_ARRAY_LENGTH(stretchValues) - 1); | 287 index = clampTo<unsigned>(index, 0, WTF_ARRAY_LENGTH(stretchValues) - 1); |
| 287 return stretchValues[index]; | 288 return stretchValues[index]; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 304 return FontDescription::Size(0, size, true); | 305 return FontDescription::Size(0, size, true); |
| 305 } | 306 } |
| 306 | 307 |
| 307 TransformOperation* animatableValueToTransformOperation( | 308 TransformOperation* animatableValueToTransformOperation( |
| 308 const AnimatableValue* value, | 309 const AnimatableValue* value, |
| 309 TransformOperation::OperationType type) { | 310 TransformOperation::OperationType type) { |
| 310 const TransformOperations& transformList = | 311 const TransformOperations& transformList = |
| 311 toAnimatableTransform(value)->transformOperations(); | 312 toAnimatableTransform(value)->transformOperations(); |
| 312 if (transformList.size() == 0) | 313 if (transformList.size() == 0) |
| 313 return nullptr; | 314 return nullptr; |
| 314 ASSERT(transformList.size() == 1); | 315 DCHECK_EQ(transformList.size(), static_cast<unsigned>(1)); |
| 315 ASSERT(transformList.operations()[0].get()->type() == type); | 316 DCHECK(transformList.operations()[0].get()->type() == type); |
|
Srirama
2017/03/16 14:22:24
DCHECK_EQ
| |
| 316 return transformList.operations()[0].get(); | 317 return transformList.operations()[0].get(); |
| 317 } | 318 } |
| 318 | 319 |
| 319 } // namespace | 320 } // namespace |
| 320 | 321 |
| 321 // FIXME: Generate this function. | 322 // FIXME: Generate this function. |
| 322 void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, | 323 void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, |
| 323 StyleResolverState& state, | 324 StyleResolverState& state, |
| 324 const AnimatableValue* value) { | 325 const AnimatableValue* value) { |
| 325 ASSERT(CSSPropertyMetadata::isInterpolableProperty(property)); | 326 DCHECK(CSSPropertyMetadata::isInterpolableProperty(property)); |
| 326 if (value->isUnknown()) { | 327 if (value->isUnknown()) { |
| 327 StyleBuilder::applyProperty(property, state, | 328 StyleBuilder::applyProperty(property, state, |
| 328 *toAnimatableUnknown(value)->toCSSValue()); | 329 *toAnimatableUnknown(value)->toCSSValue()); |
| 329 return; | 330 return; |
| 330 } | 331 } |
| 331 ComputedStyle* style = state.style(); | 332 ComputedStyle* style = state.style(); |
| 332 switch (property) { | 333 switch (property) { |
| 333 case CSSPropertyBackgroundColor: | 334 case CSSPropertyBackgroundColor: |
| 334 style->setBackgroundColor(toAnimatableColor(value)->getColor()); | 335 style->setBackgroundColor(toAnimatableColor(value)->getColor()); |
| 335 style->setVisitedLinkBackgroundColor( | 336 style->setVisitedLinkBackgroundColor( |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 860 case CSSPropertyRx: | 861 case CSSPropertyRx: |
| 861 style->setRx( | 862 style->setRx( |
| 862 animatableValueToLength(value, state, ValueRangeNonNegative)); | 863 animatableValueToLength(value, state, ValueRangeNonNegative)); |
| 863 return; | 864 return; |
| 864 case CSSPropertyRy: | 865 case CSSPropertyRy: |
| 865 style->setRy( | 866 style->setRy( |
| 866 animatableValueToLength(value, state, ValueRangeNonNegative)); | 867 animatableValueToLength(value, state, ValueRangeNonNegative)); |
| 867 return; | 868 return; |
| 868 | 869 |
| 869 default: | 870 default: |
| 870 ASSERT_NOT_REACHED(); | 871 NOTREACHED(); |
| 871 } | 872 } |
| 872 } | 873 } |
| 873 | 874 |
| 874 } // namespace blink | 875 } // namespace blink |
| OLD | NEW |