Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3466)

Side by Side Diff: Source/core/animation/css/CSSAnimatableValueFactory.cpp

Issue 26247003: Web Animations CSS: Support animation of background-position and background-image (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 createFromLength(lengthBox.bottom(), style)); 107 createFromLength(lengthBox.bottom(), style));
107 } 108 }
108 109
109 inline static PassRefPtr<AnimatableValue> createFromLengthSize(const LengthSize lengthSize, const RenderStyle* style) 110 inline static PassRefPtr<AnimatableValue> createFromLengthSize(const LengthSize lengthSize, const RenderStyle* style)
110 { 111 {
111 return AnimatableLengthSize::create( 112 return AnimatableLengthSize::create(
112 createFromLength(lengthSize.width(), style), 113 createFromLength(lengthSize.width(), style),
113 createFromLength(lengthSize.height(), style)); 114 createFromLength(lengthSize.height(), style));
114 } 115 }
115 116
117 template<typename T>
118 static inline PassRefPtr<AnimatableValue> createFrom(T, const RenderStyle*);
119
120 template <>
121 PassRefPtr<AnimatableValue> createFrom<Length>(Length length, const RenderStyle* style)
122 {
123 return createFromLength(length, style);
124 }
125
126 template <>
127 PassRefPtr<AnimatableValue> createFrom<StyleImage*>(StyleImage* image, const Ren derStyle*)
128 {
129 return AnimatableImage::create(image);
130 }
131
132 template<typename T>
133 inline static PassRefPtr<AnimatableValue> createFromFillLayers(const FillLayer* fillLayer, T getter, bool (FillLayer::*isSet)() const, const RenderStyle* style)
dstockwell 2013/10/08 23:02:46 This seems a bit yuck. Couldn't this just be a sin
alancutter (OOO until 2018) 2013/10/09 07:20:55 I agree that function pointers and code duplicatio
134 {
135 Vector<RefPtr<AnimatableValue> > values;
136 while (fillLayer && (fillLayer->*isSet)()) {
137 values.append(createFrom((fillLayer->*getter)(), style));
138 fillLayer = fillLayer->next();
139 }
140 return AnimatableRepeatable::create(values);
141 }
142
116 PassRefPtr<AnimatableValue> CSSAnimatableValueFactory::createFromColor(CSSProper tyID property, const RenderStyle* style) 143 PassRefPtr<AnimatableValue> CSSAnimatableValueFactory::createFromColor(CSSProper tyID property, const RenderStyle* style)
117 { 144 {
118 Color color = style->colorIncludingFallback(property, false); 145 Color color = style->colorIncludingFallback(property, false);
119 Color visitedLinkColor = style->colorIncludingFallback(property, true); 146 Color visitedLinkColor = style->colorIncludingFallback(property, true);
120 Color fallbackColor = style->color(); 147 Color fallbackColor = style->color();
121 Color fallbackVisitedLinkColor = style->visitedLinkColor(); 148 Color fallbackVisitedLinkColor = style->visitedLinkColor();
122 Color resolvedColor; 149 Color resolvedColor;
123 if (color.isValid()) 150 if (color.isValid())
124 resolvedColor = color; 151 resolvedColor = color;
125 else 152 else
126 resolvedColor = fallbackColor; 153 resolvedColor = fallbackColor;
127 Color resolvedVisitedLinkColor; 154 Color resolvedVisitedLinkColor;
128 if (visitedLinkColor.isValid()) 155 if (visitedLinkColor.isValid())
129 resolvedVisitedLinkColor = visitedLinkColor; 156 resolvedVisitedLinkColor = visitedLinkColor;
130 else 157 else
131 resolvedVisitedLinkColor = fallbackVisitedLinkColor; 158 resolvedVisitedLinkColor = fallbackVisitedLinkColor;
132 return AnimatableColor::create(resolvedColor, resolvedVisitedLinkColor); 159 return AnimatableColor::create(resolvedColor, resolvedVisitedLinkColor);
133 } 160 }
134 161
135 // FIXME: Generate this function. 162 // FIXME: Generate this function.
136 PassRefPtr<AnimatableValue> CSSAnimatableValueFactory::create(CSSPropertyID prop erty, const RenderStyle* style) 163 PassRefPtr<AnimatableValue> CSSAnimatableValueFactory::create(CSSPropertyID prop erty, const RenderStyle* style)
137 { 164 {
138 switch (property) { 165 switch (property) {
139 case CSSPropertyBackgroundColor: 166 case CSSPropertyBackgroundColor:
140 return createFromColor(property, style); 167 return createFromColor(property, style);
168 case CSSPropertyBackgroundImage:
169 return createFromFillLayers(style->backgroundLayers(), &FillLayer::image , &FillLayer::isImageSet, style);
170 case CSSPropertyBackgroundPositionX:
171 return createFromFillLayers(style->backgroundLayers(), &FillLayer::xPosi tion, &FillLayer::isXPositionSet, style);
172 case CSSPropertyBackgroundPositionY:
173 return createFromFillLayers(style->backgroundLayers(), &FillLayer::yPosi tion, &FillLayer::isYPositionSet, style);
141 case CSSPropertyBaselineShift: 174 case CSSPropertyBaselineShift:
142 return AnimatableSVGLength::create(style->baselineShiftValue()); 175 return AnimatableSVGLength::create(style->baselineShiftValue());
143 case CSSPropertyBorderBottomColor: 176 case CSSPropertyBorderBottomColor:
144 return createFromColor(property, style); 177 return createFromColor(property, style);
145 case CSSPropertyBorderBottomLeftRadius: 178 case CSSPropertyBorderBottomLeftRadius:
146 return createFromLengthSize(style->borderBottomLeftRadius(), style); 179 return createFromLengthSize(style->borderBottomLeftRadius(), style);
147 case CSSPropertyBorderBottomRightRadius: 180 case CSSPropertyBorderBottomRightRadius:
148 return createFromLengthSize(style->borderBottomRightRadius(), style); 181 return createFromLengthSize(style->borderBottomRightRadius(), style);
149 case CSSPropertyBorderBottomWidth: 182 case CSSPropertyBorderBottomWidth:
150 return createFromDouble(style->borderBottomWidth()); 183 return createFromDouble(style->borderBottomWidth());
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 case CSSPropertyZoom: 334 case CSSPropertyZoom:
302 return createFromDouble(style->zoom()); 335 return createFromDouble(style->zoom());
303 default: 336 default:
304 RELEASE_ASSERT_WITH_MESSAGE(!CSSAnimations::isAnimatableProperty(propert y), "Web Animations not yet implemented: Create AnimatableValue from render styl e: %s", getPropertyNameString(property).utf8().data()); 337 RELEASE_ASSERT_WITH_MESSAGE(!CSSAnimations::isAnimatableProperty(propert y), "Web Animations not yet implemented: Create AnimatableValue from render styl e: %s", getPropertyNameString(property).utf8().data());
305 ASSERT_NOT_REACHED(); 338 ASSERT_NOT_REACHED();
306 return 0; 339 return 0;
307 } 340 }
308 } 341 }
309 342
310 } // namespace WebCore 343 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698