| 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 21 matching lines...) Expand all Loading... |
| 32 #include "core/animation/css/CSSAnimatableValueFactory.h" | 32 #include "core/animation/css/CSSAnimatableValueFactory.h" |
| 33 | 33 |
| 34 #include "CSSValueKeywords.h" | 34 #include "CSSValueKeywords.h" |
| 35 #include "core/animation/AnimatableClipPathOperation.h" | 35 #include "core/animation/AnimatableClipPathOperation.h" |
| 36 #include "core/animation/AnimatableColor.h" | 36 #include "core/animation/AnimatableColor.h" |
| 37 #include "core/animation/AnimatableDouble.h" | 37 #include "core/animation/AnimatableDouble.h" |
| 38 #include "core/animation/AnimatableImage.h" | 38 #include "core/animation/AnimatableImage.h" |
| 39 #include "core/animation/AnimatableLength.h" | 39 #include "core/animation/AnimatableLength.h" |
| 40 #include "core/animation/AnimatableLengthBox.h" | 40 #include "core/animation/AnimatableLengthBox.h" |
| 41 #include "core/animation/AnimatableLengthSize.h" | 41 #include "core/animation/AnimatableLengthSize.h" |
| 42 #include "core/animation/AnimatableRepeatable.h" |
| 42 #include "core/animation/AnimatableSVGLength.h" | 43 #include "core/animation/AnimatableSVGLength.h" |
| 43 #include "core/animation/AnimatableSVGPaint.h" | 44 #include "core/animation/AnimatableSVGPaint.h" |
| 44 #include "core/animation/AnimatableShapeValue.h" | 45 #include "core/animation/AnimatableShapeValue.h" |
| 45 #include "core/animation/AnimatableTransform.h" | 46 #include "core/animation/AnimatableTransform.h" |
| 46 #include "core/animation/AnimatableUnknown.h" | 47 #include "core/animation/AnimatableUnknown.h" |
| 47 #include "core/animation/AnimatableVisibility.h" | 48 #include "core/animation/AnimatableVisibility.h" |
| 48 #include "core/animation/css/CSSAnimations.h" | 49 #include "core/animation/css/CSSAnimations.h" |
| 49 #include "core/css/CSSPrimitiveValue.h" | 50 #include "core/css/CSSPrimitiveValue.h" |
| 50 #include "core/platform/Length.h" | 51 #include "core/platform/Length.h" |
| 51 #include "core/platform/LengthBox.h" | 52 #include "core/platform/LengthBox.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 createFromLength(lengthBox.bottom(), style)); | 106 createFromLength(lengthBox.bottom(), style)); |
| 106 } | 107 } |
| 107 | 108 |
| 108 inline static PassRefPtr<AnimatableValue> createFromLengthSize(const LengthSize
lengthSize, const RenderStyle* style) | 109 inline static PassRefPtr<AnimatableValue> createFromLengthSize(const LengthSize
lengthSize, const RenderStyle* style) |
| 109 { | 110 { |
| 110 return AnimatableLengthSize::create( | 111 return AnimatableLengthSize::create( |
| 111 createFromLength(lengthSize.width(), style), | 112 createFromLength(lengthSize.width(), style), |
| 112 createFromLength(lengthSize.height(), style)); | 113 createFromLength(lengthSize.height(), style)); |
| 113 } | 114 } |
| 114 | 115 |
| 116 template<CSSPropertyID property> |
| 117 inline static PassRefPtr<AnimatableValue> createFromFillLayers(const FillLayer*
fillLayer, const RenderStyle* style) |
| 118 { |
| 119 ASSERT(fillLayer); |
| 120 Vector<RefPtr<AnimatableValue> > values; |
| 121 while (fillLayer) { |
| 122 if (property == CSSPropertyBackgroundImage) { |
| 123 if (!fillLayer->isImageSet()) |
| 124 break; |
| 125 values.append(AnimatableImage::create(fillLayer->image())); |
| 126 } else if (property == CSSPropertyBackgroundPositionX) { |
| 127 if (!fillLayer->isXPositionSet()) |
| 128 break; |
| 129 values.append(createFromLength(fillLayer->xPosition(), style)); |
| 130 } else if (property == CSSPropertyBackgroundPositionY) { |
| 131 if (!fillLayer->isYPositionSet()) |
| 132 break; |
| 133 values.append(createFromLength(fillLayer->yPosition(), style)); |
| 134 } else { |
| 135 ASSERT_NOT_REACHED(); |
| 136 } |
| 137 fillLayer = fillLayer->next(); |
| 138 } |
| 139 return AnimatableRepeatable::create(values); |
| 140 } |
| 141 |
| 115 PassRefPtr<AnimatableValue> CSSAnimatableValueFactory::createFromColor(CSSProper
tyID property, const RenderStyle* style) | 142 PassRefPtr<AnimatableValue> CSSAnimatableValueFactory::createFromColor(CSSProper
tyID property, const RenderStyle* style) |
| 116 { | 143 { |
| 117 Color color = style->colorIncludingFallback(property, false); | 144 Color color = style->colorIncludingFallback(property, false); |
| 118 Color visitedLinkColor = style->colorIncludingFallback(property, true); | 145 Color visitedLinkColor = style->colorIncludingFallback(property, true); |
| 119 Color fallbackColor = style->color(); | 146 Color fallbackColor = style->color(); |
| 120 Color fallbackVisitedLinkColor = style->visitedLinkColor(); | 147 Color fallbackVisitedLinkColor = style->visitedLinkColor(); |
| 121 Color resolvedColor; | 148 Color resolvedColor; |
| 122 if (color.isValid()) | 149 if (color.isValid()) |
| 123 resolvedColor = color; | 150 resolvedColor = color; |
| 124 else | 151 else |
| 125 resolvedColor = fallbackColor; | 152 resolvedColor = fallbackColor; |
| 126 Color resolvedVisitedLinkColor; | 153 Color resolvedVisitedLinkColor; |
| 127 if (visitedLinkColor.isValid()) | 154 if (visitedLinkColor.isValid()) |
| 128 resolvedVisitedLinkColor = visitedLinkColor; | 155 resolvedVisitedLinkColor = visitedLinkColor; |
| 129 else | 156 else |
| 130 resolvedVisitedLinkColor = fallbackVisitedLinkColor; | 157 resolvedVisitedLinkColor = fallbackVisitedLinkColor; |
| 131 return AnimatableColor::create(resolvedColor, resolvedVisitedLinkColor); | 158 return AnimatableColor::create(resolvedColor, resolvedVisitedLinkColor); |
| 132 } | 159 } |
| 133 | 160 |
| 134 // FIXME: Generate this function. | 161 // FIXME: Generate this function. |
| 135 PassRefPtr<AnimatableValue> CSSAnimatableValueFactory::create(CSSPropertyID prop
erty, const RenderStyle* style) | 162 PassRefPtr<AnimatableValue> CSSAnimatableValueFactory::create(CSSPropertyID prop
erty, const RenderStyle* style) |
| 136 { | 163 { |
| 137 switch (property) { | 164 switch (property) { |
| 138 case CSSPropertyBackgroundColor: | 165 case CSSPropertyBackgroundColor: |
| 139 return createFromColor(property, style); | 166 return createFromColor(property, style); |
| 167 case CSSPropertyBackgroundImage: |
| 168 return createFromFillLayers<CSSPropertyBackgroundImage>(style->backgroun
dLayers(), style); |
| 169 case CSSPropertyBackgroundPositionX: |
| 170 return createFromFillLayers<CSSPropertyBackgroundPositionX>(style->backg
roundLayers(), style); |
| 171 case CSSPropertyBackgroundPositionY: |
| 172 return createFromFillLayers<CSSPropertyBackgroundPositionY>(style->backg
roundLayers(), style); |
| 140 case CSSPropertyBaselineShift: | 173 case CSSPropertyBaselineShift: |
| 141 return AnimatableSVGLength::create(style->baselineShiftValue()); | 174 return AnimatableSVGLength::create(style->baselineShiftValue()); |
| 142 case CSSPropertyBorderBottomColor: | 175 case CSSPropertyBorderBottomColor: |
| 143 return createFromColor(property, style); | 176 return createFromColor(property, style); |
| 144 case CSSPropertyBorderBottomLeftRadius: | 177 case CSSPropertyBorderBottomLeftRadius: |
| 145 return createFromLengthSize(style->borderBottomLeftRadius(), style); | 178 return createFromLengthSize(style->borderBottomLeftRadius(), style); |
| 146 case CSSPropertyBorderBottomRightRadius: | 179 case CSSPropertyBorderBottomRightRadius: |
| 147 return createFromLengthSize(style->borderBottomRightRadius(), style); | 180 return createFromLengthSize(style->borderBottomRightRadius(), style); |
| 148 case CSSPropertyBorderBottomWidth: | 181 case CSSPropertyBorderBottomWidth: |
| 149 return createFromDouble(style->borderBottomWidth()); | 182 return createFromDouble(style->borderBottomWidth()); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 case CSSPropertyZoom: | 337 case CSSPropertyZoom: |
| 305 return createFromDouble(style->zoom()); | 338 return createFromDouble(style->zoom()); |
| 306 default: | 339 default: |
| 307 RELEASE_ASSERT_WITH_MESSAGE(!CSSAnimations::isAnimatableProperty(propert
y), "Web Animations not yet implemented: Create AnimatableValue from render styl
e: %s", getPropertyNameString(property).utf8().data()); | 340 RELEASE_ASSERT_WITH_MESSAGE(!CSSAnimations::isAnimatableProperty(propert
y), "Web Animations not yet implemented: Create AnimatableValue from render styl
e: %s", getPropertyNameString(property).utf8().data()); |
| 308 ASSERT_NOT_REACHED(); | 341 ASSERT_NOT_REACHED(); |
| 309 return 0; | 342 return 0; |
| 310 } | 343 } |
| 311 } | 344 } |
| 312 | 345 |
| 313 } // namespace WebCore | 346 } // namespace WebCore |
| OLD | NEW |