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

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: Review changes 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) {
dstockwell 2013/10/09 23:15:07 Hmm, yeah I guess there's a bit too much going on
alancutter (OOO until 2018) 2013/10/10 00:58:38 Merged the switch statements using an if chain.
122 bool isSet;
123 switch (property) {
124 case CSSPropertyBackgroundImage:
125 isSet = fillLayer->isImageSet();
126 break;
127 case CSSPropertyBackgroundPositionX:
128 isSet = fillLayer->isXPositionSet();
129 break;
130 case CSSPropertyBackgroundPositionY:
131 isSet = fillLayer->isYPositionSet();
132 break;
133 default:
134 ASSERT_NOT_REACHED();
135 }
136 if (!isSet)
137 break;
138 switch (property) {
139 case CSSPropertyBackgroundImage:
140 values.append(AnimatableImage::create(fillLayer->image()));
141 break;
142 case CSSPropertyBackgroundPositionX:
143 values.append(createFromLength(fillLayer->xPosition(), style));
144 break;
145 case CSSPropertyBackgroundPositionY:
146 values.append(createFromLength(fillLayer->yPosition(), style));
147 break;
148 default:
149 ASSERT_NOT_REACHED();
150 }
151 fillLayer = fillLayer->next();
152 }
153 return AnimatableRepeatable::create(values);
154 }
155
115 PassRefPtr<AnimatableValue> CSSAnimatableValueFactory::createFromColor(CSSProper tyID property, const RenderStyle* style) 156 PassRefPtr<AnimatableValue> CSSAnimatableValueFactory::createFromColor(CSSProper tyID property, const RenderStyle* style)
116 { 157 {
117 Color color = style->colorIncludingFallback(property, false); 158 Color color = style->colorIncludingFallback(property, false);
118 Color visitedLinkColor = style->colorIncludingFallback(property, true); 159 Color visitedLinkColor = style->colorIncludingFallback(property, true);
119 Color fallbackColor = style->color(); 160 Color fallbackColor = style->color();
120 Color fallbackVisitedLinkColor = style->visitedLinkColor(); 161 Color fallbackVisitedLinkColor = style->visitedLinkColor();
121 Color resolvedColor; 162 Color resolvedColor;
122 if (color.isValid()) 163 if (color.isValid())
123 resolvedColor = color; 164 resolvedColor = color;
124 else 165 else
125 resolvedColor = fallbackColor; 166 resolvedColor = fallbackColor;
126 Color resolvedVisitedLinkColor; 167 Color resolvedVisitedLinkColor;
127 if (visitedLinkColor.isValid()) 168 if (visitedLinkColor.isValid())
128 resolvedVisitedLinkColor = visitedLinkColor; 169 resolvedVisitedLinkColor = visitedLinkColor;
129 else 170 else
130 resolvedVisitedLinkColor = fallbackVisitedLinkColor; 171 resolvedVisitedLinkColor = fallbackVisitedLinkColor;
131 return AnimatableColor::create(resolvedColor, resolvedVisitedLinkColor); 172 return AnimatableColor::create(resolvedColor, resolvedVisitedLinkColor);
132 } 173 }
133 174
134 // FIXME: Generate this function. 175 // FIXME: Generate this function.
135 PassRefPtr<AnimatableValue> CSSAnimatableValueFactory::create(CSSPropertyID prop erty, const RenderStyle* style) 176 PassRefPtr<AnimatableValue> CSSAnimatableValueFactory::create(CSSPropertyID prop erty, const RenderStyle* style)
136 { 177 {
137 switch (property) { 178 switch (property) {
138 case CSSPropertyBackgroundColor: 179 case CSSPropertyBackgroundColor:
139 return createFromColor(property, style); 180 return createFromColor(property, style);
181 case CSSPropertyBackgroundImage:
182 return createFromFillLayers<CSSPropertyBackgroundImage>(style->backgroun dLayers(), style);
183 case CSSPropertyBackgroundPositionX:
184 return createFromFillLayers<CSSPropertyBackgroundPositionX>(style->backg roundLayers(), style);
185 case CSSPropertyBackgroundPositionY:
186 return createFromFillLayers<CSSPropertyBackgroundPositionY>(style->backg roundLayers(), style);
140 case CSSPropertyBaselineShift: 187 case CSSPropertyBaselineShift:
141 return AnimatableSVGLength::create(style->baselineShiftValue()); 188 return AnimatableSVGLength::create(style->baselineShiftValue());
142 case CSSPropertyBorderBottomColor: 189 case CSSPropertyBorderBottomColor:
143 return createFromColor(property, style); 190 return createFromColor(property, style);
144 case CSSPropertyBorderBottomLeftRadius: 191 case CSSPropertyBorderBottomLeftRadius:
145 return createFromLengthSize(style->borderBottomLeftRadius(), style); 192 return createFromLengthSize(style->borderBottomLeftRadius(), style);
146 case CSSPropertyBorderBottomRightRadius: 193 case CSSPropertyBorderBottomRightRadius:
147 return createFromLengthSize(style->borderBottomRightRadius(), style); 194 return createFromLengthSize(style->borderBottomRightRadius(), style);
148 case CSSPropertyBorderBottomWidth: 195 case CSSPropertyBorderBottomWidth:
149 return createFromDouble(style->borderBottomWidth()); 196 return createFromDouble(style->borderBottomWidth());
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 case CSSPropertyZoom: 349 case CSSPropertyZoom:
303 return createFromDouble(style->zoom()); 350 return createFromDouble(style->zoom());
304 default: 351 default:
305 RELEASE_ASSERT_WITH_MESSAGE(!CSSAnimations::isAnimatableProperty(propert y), "Web Animations not yet implemented: Create AnimatableValue from render styl e: %s", getPropertyNameString(property).utf8().data()); 352 RELEASE_ASSERT_WITH_MESSAGE(!CSSAnimations::isAnimatableProperty(propert y), "Web Animations not yet implemented: Create AnimatableValue from render styl e: %s", getPropertyNameString(property).utf8().data());
306 ASSERT_NOT_REACHED(); 353 ASSERT_NOT_REACHED();
307 return 0; 354 return 0;
308 } 355 }
309 } 356 }
310 357
311 } // namespace WebCore 358 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698