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

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

Issue 1120003002: [Oilpan] Migrate most classes under core/animations to Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Resize expect size of Persistent Created 5 years, 6 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
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 #include "core/css/CSSCalculationValue.h" 55 #include "core/css/CSSCalculationValue.h"
56 #include "core/css/CSSPrimitiveValue.h" 56 #include "core/css/CSSPrimitiveValue.h"
57 #include "core/css/CSSPrimitiveValueMappings.h" 57 #include "core/css/CSSPrimitiveValueMappings.h"
58 #include "core/css/CSSPropertyMetadata.h" 58 #include "core/css/CSSPropertyMetadata.h"
59 #include "core/style/ComputedStyle.h" 59 #include "core/style/ComputedStyle.h"
60 #include "platform/Length.h" 60 #include "platform/Length.h"
61 #include "platform/LengthBox.h" 61 #include "platform/LengthBox.h"
62 62
63 namespace blink { 63 namespace blink {
64 64
65 static PassRefPtrWillBeRawPtr<AnimatableValue> createFromLengthWithZoom(const Le ngth& length, float zoom) 65 static AnimatableValue* createFromLengthWithZoom(const Length& length, float zoo m)
66 { 66 {
67 switch (length.type()) { 67 switch (length.type()) {
68 case Fixed: 68 case Fixed:
69 case Percent: 69 case Percent:
70 case Calculated: 70 case Calculated:
71 return AnimatableLength::create(length, zoom); 71 return AnimatableLength::create(length, zoom);
72 case Auto: 72 case Auto:
73 case Intrinsic: 73 case Intrinsic:
74 case MinIntrinsic: 74 case MinIntrinsic:
75 case MinContent: 75 case MinContent:
76 case MaxContent: 76 case MaxContent:
77 case FillAvailable: 77 case FillAvailable:
78 case FitContent: 78 case FitContent:
79 return AnimatableUnknown::create(CSSPrimitiveValue::create(length, 1)); 79 return AnimatableUnknown::create(CSSPrimitiveValue::create(length, 1));
80 case MaxSizeNone: 80 case MaxSizeNone:
81 return AnimatableUnknown::create(CSSValueNone); 81 return AnimatableUnknown::create(CSSValueNone);
82 case ExtendToZoom: // Does not apply to elements. 82 case ExtendToZoom: // Does not apply to elements.
83 case DeviceWidth: 83 case DeviceWidth:
84 case DeviceHeight: 84 case DeviceHeight:
85 ASSERT_NOT_REACHED(); 85 ASSERT_NOT_REACHED();
86 return nullptr; 86 return nullptr;
87 } 87 }
88 ASSERT_NOT_REACHED(); 88 ASSERT_NOT_REACHED();
89 return nullptr; 89 return nullptr;
90 } 90 }
91 91
92 static PassRefPtrWillBeRawPtr<AnimatableValue> createFromLength(const Length& le ngth, const ComputedStyle& style) 92 static AnimatableValue* createFromLength(const Length& length, const ComputedSty le& style)
93 { 93 {
94 return createFromLengthWithZoom(length, style.effectiveZoom()); 94 return createFromLengthWithZoom(length, style.effectiveZoom());
95 } 95 }
96 96
97 static PassRefPtrWillBeRawPtr<AnimatableValue> createFromUnzoomedLength(const Un zoomedLength& unzoomedLength) 97 static AnimatableValue* createFromUnzoomedLength(const UnzoomedLength& unzoomedL ength)
98 { 98 {
99 return createFromLengthWithZoom(unzoomedLength.length(), 1); 99 return createFromLengthWithZoom(unzoomedLength.length(), 1);
100 } 100 }
101 101
102 static PassRefPtrWillBeRawPtr<AnimatableValue> createFromLineHeight(const Length & length, const ComputedStyle& style) 102 static AnimatableValue* createFromLineHeight(const Length& length, const Compute dStyle& style)
103 { 103 {
104 if (length.type() == Percent) { 104 if (length.type() == Percent) {
105 double value = length.value(); 105 double value = length.value();
106 // -100% is used to represent "normal" line height. 106 // -100% is used to represent "normal" line height.
107 if (value == -100) 107 if (value == -100)
108 return AnimatableUnknown::create(CSSValueNormal); 108 return AnimatableUnknown::create(CSSValueNormal);
109 return AnimatableDouble::create(value); 109 return AnimatableDouble::create(value);
110 } 110 }
111 return createFromLength(length, style); 111 return createFromLength(length, style);
112 } 112 }
113 113
114 inline static PassRefPtrWillBeRawPtr<AnimatableValue> createFromDouble(double va lue, AnimatableDouble::Constraint constraint = AnimatableDouble::Unconstrained) 114 inline static AnimatableValue* createFromDouble(double value, AnimatableDouble:: Constraint constraint = AnimatableDouble::Unconstrained)
115 { 115 {
116 return AnimatableDouble::create(value, constraint); 116 return AnimatableDouble::create(value, constraint);
117 } 117 }
118 118
119 inline static PassRefPtrWillBeRawPtr<AnimatableValue> createFromLengthBox(const LengthBox& lengthBox, const ComputedStyle& style) 119 inline static AnimatableValue* createFromLengthBox(const LengthBox& lengthBox, c onst ComputedStyle& style)
120 { 120 {
121 return AnimatableLengthBox::create( 121 return AnimatableLengthBox::create(
122 createFromLength(lengthBox.left(), style), 122 createFromLength(lengthBox.left(), style),
123 createFromLength(lengthBox.right(), style), 123 createFromLength(lengthBox.right(), style),
124 createFromLength(lengthBox.top(), style), 124 createFromLength(lengthBox.top(), style),
125 createFromLength(lengthBox.bottom(), style)); 125 createFromLength(lengthBox.bottom(), style));
126 } 126 }
127 127
128 static PassRefPtrWillBeRawPtr<AnimatableValue> createFromBorderImageLength(const BorderImageLength& borderImageLength, const ComputedStyle& style) 128 static AnimatableValue* createFromBorderImageLength(const BorderImageLength& bor derImageLength, const ComputedStyle& style)
129 { 129 {
130 if (borderImageLength.isNumber()) 130 if (borderImageLength.isNumber())
131 return createFromDouble(borderImageLength.number()); 131 return createFromDouble(borderImageLength.number());
132 return createFromLength(borderImageLength.length(), style); 132 return createFromLength(borderImageLength.length(), style);
133 } 133 }
134 134
135 inline static PassRefPtrWillBeRawPtr<AnimatableValue> createFromBorderImageLengt hBox(const BorderImageLengthBox& borderImageLengthBox, const ComputedStyle& styl e) 135 inline static AnimatableValue* createFromBorderImageLengthBox(const BorderImageL engthBox& borderImageLengthBox, const ComputedStyle& style)
136 { 136 {
137 return AnimatableLengthBox::create( 137 return AnimatableLengthBox::create(
138 createFromBorderImageLength(borderImageLengthBox.left(), style), 138 createFromBorderImageLength(borderImageLengthBox.left(), style),
139 createFromBorderImageLength(borderImageLengthBox.right(), style), 139 createFromBorderImageLength(borderImageLengthBox.right(), style),
140 createFromBorderImageLength(borderImageLengthBox.top(), style), 140 createFromBorderImageLength(borderImageLengthBox.top(), style),
141 createFromBorderImageLength(borderImageLengthBox.bottom(), style)); 141 createFromBorderImageLength(borderImageLengthBox.bottom(), style));
142 } 142 }
143 143
144 inline static PassRefPtrWillBeRawPtr<AnimatableValue> createFromLengthBoxAndBool (const LengthBox lengthBox, const bool flag, const ComputedStyle& style) 144 inline static AnimatableValue* createFromLengthBoxAndBool(const LengthBox length Box, const bool flag, const ComputedStyle& style)
145 { 145 {
146 return AnimatableLengthBoxAndBool::create( 146 return AnimatableLengthBoxAndBool::create(
147 createFromLengthBox(lengthBox, style), 147 createFromLengthBox(lengthBox, style),
148 flag); 148 flag);
149 } 149 }
150 150
151 inline static PassRefPtrWillBeRawPtr<AnimatableValue> createFromDoubleAndBool(do uble number, const bool flag, const ComputedStyle& style) 151 inline static AnimatableValue* createFromDoubleAndBool(double number, const bool flag, const ComputedStyle& style)
152 { 152 {
153 return AnimatableDoubleAndBool::create(number, flag); 153 return AnimatableDoubleAndBool::create(number, flag);
154 } 154 }
155 155
156 inline static PassRefPtrWillBeRawPtr<AnimatableValue> createFromLengthPoint(cons t LengthPoint& lengthPoint, const ComputedStyle& style) 156 inline static AnimatableValue* createFromLengthPoint(const LengthPoint& lengthPo int, const ComputedStyle& style)
157 { 157 {
158 return AnimatableLengthPoint::create( 158 return AnimatableLengthPoint::create(
159 createFromLength(lengthPoint.x(), style), 159 createFromLength(lengthPoint.x(), style),
160 createFromLength(lengthPoint.y(), style)); 160 createFromLength(lengthPoint.y(), style));
161 } 161 }
162 162
163 inline static PassRefPtrWillBeRawPtr<AnimatableValue> createFromTransformOrigin( const TransformOrigin& transformOrigin, const ComputedStyle& style) 163 inline static AnimatableValue* createFromTransformOrigin(const TransformOrigin& transformOrigin, const ComputedStyle& style)
164 { 164 {
165 return AnimatableLengthPoint3D::create( 165 return AnimatableLengthPoint3D::create(
166 createFromLength(transformOrigin.x(), style), 166 createFromLength(transformOrigin.x(), style),
167 createFromLength(transformOrigin.y(), style), 167 createFromLength(transformOrigin.y(), style),
168 createFromDouble(transformOrigin.z())); 168 createFromDouble(transformOrigin.z()));
169 } 169 }
170 170
171 inline static PassRefPtrWillBeRawPtr<AnimatableValue> createFromLengthSize(const LengthSize& lengthSize, const ComputedStyle& style) 171 inline static AnimatableValue* createFromLengthSize(const LengthSize& lengthSize , const ComputedStyle& style)
172 { 172 {
173 return AnimatableLengthSize::create( 173 return AnimatableLengthSize::create(
174 createFromLength(lengthSize.width(), style), 174 createFromLength(lengthSize.width(), style),
175 createFromLength(lengthSize.height(), style)); 175 createFromLength(lengthSize.height(), style));
176 } 176 }
177 177
178 inline static PassRefPtrWillBeRawPtr<AnimatableValue> createFromStyleImage(Style Image* image) 178 inline static AnimatableValue* createFromStyleImage(StyleImage* image)
179 { 179 {
180 if (image) { 180 if (image) {
181 if (RefPtrWillBeRawPtr<CSSValue> cssValue = image->cssValue()) 181 if (RefPtrWillBeRawPtr<CSSValue> cssValue = image->cssValue())
182 return AnimatableImage::create(cssValue.release()); 182 return AnimatableImage::create(cssValue.release());
183 } 183 }
184 return AnimatableUnknown::create(CSSValueNone); 184 return AnimatableUnknown::create(CSSValueNone);
185 } 185 }
186 186
187 inline static PassRefPtrWillBeRawPtr<AnimatableValue> createFromFillSize(const F illSize& fillSize, const ComputedStyle& style) 187 inline static AnimatableValue* createFromFillSize(const FillSize& fillSize, cons t ComputedStyle& style)
188 { 188 {
189 switch (fillSize.type) { 189 switch (fillSize.type) {
190 case SizeLength: 190 case SizeLength:
191 return createFromLengthSize(fillSize.size, style); 191 return createFromLengthSize(fillSize.size, style);
192 case Contain: 192 case Contain:
193 case Cover: 193 case Cover:
194 case SizeNone: 194 case SizeNone:
195 return AnimatableUnknown::create(CSSPrimitiveValue::create(fillSize.type )); 195 return AnimatableUnknown::create(CSSPrimitiveValue::create(fillSize.type ));
196 default: 196 default:
197 ASSERT_NOT_REACHED(); 197 ASSERT_NOT_REACHED();
198 return nullptr; 198 return nullptr;
199 } 199 }
200 } 200 }
201 201
202 inline static PassRefPtrWillBeRawPtr<AnimatableValue> createFromBackgroundPositi on(const Length& length, bool originIsSet, BackgroundEdgeOrigin origin, const Co mputedStyle& style) 202 inline static AnimatableValue* createFromBackgroundPosition(const Length& length , bool originIsSet, BackgroundEdgeOrigin origin, const ComputedStyle& style)
203 { 203 {
204 if (!originIsSet || origin == LeftEdge || origin == TopEdge) 204 if (!originIsSet || origin == LeftEdge || origin == TopEdge)
205 return createFromLength(length, style); 205 return createFromLength(length, style);
206 return createFromLength(length.subtractFromOneHundredPercent(), style); 206 return createFromLength(length.subtractFromOneHundredPercent(), style);
207 } 207 }
208 208
209 template<CSSPropertyID property> 209 template<CSSPropertyID property>
210 inline static PassRefPtrWillBeRawPtr<AnimatableValue> createFromFillLayers(const FillLayer& fillLayers, const ComputedStyle& style) 210 inline static AnimatableValue* createFromFillLayers(const FillLayer& fillLayers, const ComputedStyle& style)
211 { 211 {
212 WillBeHeapVector<RefPtrWillBeMember<AnimatableValue>> values; 212 HeapVector<Member<AnimatableValue>> values;
213 for (const FillLayer* fillLayer = &fillLayers; fillLayer; fillLayer = fillLa yer->next()) { 213 for (const FillLayer* fillLayer = &fillLayers; fillLayer; fillLayer = fillLa yer->next()) {
214 if (property == CSSPropertyBackgroundImage || property == CSSPropertyWeb kitMaskImage) { 214 if (property == CSSPropertyBackgroundImage || property == CSSPropertyWeb kitMaskImage) {
215 if (!fillLayer->isImageSet()) 215 if (!fillLayer->isImageSet())
216 break; 216 break;
217 values.append(createFromStyleImage(fillLayer->image())); 217 values.append(createFromStyleImage(fillLayer->image()));
218 } else if (property == CSSPropertyBackgroundPositionX || property == CSS PropertyWebkitMaskPositionX) { 218 } else if (property == CSSPropertyBackgroundPositionX || property == CSS PropertyWebkitMaskPositionX) {
219 if (!fillLayer->isXPositionSet()) 219 if (!fillLayer->isXPositionSet())
220 break; 220 break;
221 values.append(createFromBackgroundPosition(fillLayer->xPosition(), f illLayer->isBackgroundXOriginSet(), fillLayer->backgroundXOrigin(), style)); 221 values.append(createFromBackgroundPosition(fillLayer->xPosition(), f illLayer->isBackgroundXOriginSet(), fillLayer->backgroundXOrigin(), style));
222 } else if (property == CSSPropertyBackgroundPositionY || property == CSS PropertyWebkitMaskPositionY) { 222 } else if (property == CSSPropertyBackgroundPositionY || property == CSS PropertyWebkitMaskPositionY) {
223 if (!fillLayer->isYPositionSet()) 223 if (!fillLayer->isYPositionSet())
224 break; 224 break;
225 values.append(createFromBackgroundPosition(fillLayer->yPosition(), f illLayer->isBackgroundYOriginSet(), fillLayer->backgroundYOrigin(), style)); 225 values.append(createFromBackgroundPosition(fillLayer->yPosition(), f illLayer->isBackgroundYOriginSet(), fillLayer->backgroundYOrigin(), style));
226 } else if (property == CSSPropertyBackgroundSize || property == CSSPrope rtyWebkitMaskSize) { 226 } else if (property == CSSPropertyBackgroundSize || property == CSSPrope rtyWebkitMaskSize) {
227 if (!fillLayer->isSizeSet()) 227 if (!fillLayer->isSizeSet())
228 break; 228 break;
229 values.append(createFromFillSize(fillLayer->size(), style)); 229 values.append(createFromFillSize(fillLayer->size(), style));
230 } else { 230 } else {
231 ASSERT_NOT_REACHED(); 231 ASSERT_NOT_REACHED();
232 } 232 }
233 } 233 }
234 return AnimatableRepeatable::create(values); 234 return AnimatableRepeatable::create(values);
235 } 235 }
236 236
237 PassRefPtrWillBeRawPtr<AnimatableValue> CSSAnimatableValueFactory::createFromCol or(CSSPropertyID property, const ComputedStyle& style) 237 AnimatableValue* CSSAnimatableValueFactory::createFromColor(CSSPropertyID proper ty, const ComputedStyle& style)
238 { 238 {
239 Color color = style.colorIncludingFallback(property, false); 239 Color color = style.colorIncludingFallback(property, false);
240 Color visitedLinkColor = style.colorIncludingFallback(property, true); 240 Color visitedLinkColor = style.colorIncludingFallback(property, true);
241 return AnimatableColor::create(color, visitedLinkColor); 241 return AnimatableColor::create(color, visitedLinkColor);
242 } 242 }
243 243
244 inline static PassRefPtrWillBeRawPtr<AnimatableValue> createFromShapeValue(Shape Value* value) 244 inline static AnimatableValue* createFromShapeValue(ShapeValue* value)
245 { 245 {
246 if (value) 246 if (value)
247 return AnimatableShapeValue::create(value); 247 return AnimatableShapeValue::create(value);
248 return AnimatableUnknown::create(CSSValueNone); 248 return AnimatableUnknown::create(CSSValueNone);
249 } 249 }
250 250
251 static double fontStretchToDouble(FontStretch fontStretch) 251 static double fontStretchToDouble(FontStretch fontStretch)
252 { 252 {
253 return static_cast<unsigned>(fontStretch); 253 return static_cast<unsigned>(fontStretch);
254 } 254 }
255 255
256 static PassRefPtrWillBeRawPtr<AnimatableValue> createFromFontStretch(FontStretch fontStretch) 256 static AnimatableValue* createFromFontStretch(FontStretch fontStretch)
257 { 257 {
258 return createFromDouble(fontStretchToDouble(fontStretch)); 258 return createFromDouble(fontStretchToDouble(fontStretch));
259 } 259 }
260 260
261 static double fontWeightToDouble(FontWeight fontWeight) 261 static double fontWeightToDouble(FontWeight fontWeight)
262 { 262 {
263 switch (fontWeight) { 263 switch (fontWeight) {
264 case FontWeight100: 264 case FontWeight100:
265 return 100; 265 return 100;
266 case FontWeight200: 266 case FontWeight200:
(...skipping 11 matching lines...) Expand all
278 case FontWeight800: 278 case FontWeight800:
279 return 800; 279 return 800;
280 case FontWeight900: 280 case FontWeight900:
281 return 900; 281 return 900;
282 } 282 }
283 283
284 ASSERT_NOT_REACHED(); 284 ASSERT_NOT_REACHED();
285 return 400; 285 return 400;
286 } 286 }
287 287
288 static PassRefPtrWillBeRawPtr<AnimatableValue> createFromFontWeight(FontWeight f ontWeight) 288 static AnimatableValue* createFromFontWeight(FontWeight fontWeight)
289 { 289 {
290 return createFromDouble(fontWeightToDouble(fontWeight)); 290 return createFromDouble(fontWeightToDouble(fontWeight));
291 } 291 }
292 292
293 static SVGPaintType normalizeSVGPaintType(SVGPaintType paintType) 293 static SVGPaintType normalizeSVGPaintType(SVGPaintType paintType)
294 { 294 {
295 // If the <paint> is 'currentColor', then create an AnimatableSVGPaint with 295 // If the <paint> is 'currentColor', then create an AnimatableSVGPaint with
296 // a <rgbcolor> type. This is similar in vein to the handling of colors. 296 // a <rgbcolor> type. This is similar in vein to the handling of colors.
297 return paintType == SVG_PAINTTYPE_CURRENTCOLOR ? SVG_PAINTTYPE_RGBCOLOR : pa intType; 297 return paintType == SVG_PAINTTYPE_CURRENTCOLOR ? SVG_PAINTTYPE_RGBCOLOR : pa intType;
298 } 298 }
299 299
300 // FIXME: Generate this function. 300 // FIXME: Generate this function.
301 PassRefPtrWillBeRawPtr<AnimatableValue> CSSAnimatableValueFactory::create(CSSPro pertyID property, const ComputedStyle& style) 301 AnimatableValue* CSSAnimatableValueFactory::create(CSSPropertyID property, const ComputedStyle& style)
302 { 302 {
303 ASSERT(CSSPropertyMetadata::isAnimatableProperty(property)); 303 ASSERT(CSSPropertyMetadata::isAnimatableProperty(property));
304 switch (property) { 304 switch (property) {
305 case CSSPropertyBackgroundColor: 305 case CSSPropertyBackgroundColor:
306 return createFromColor(property, style); 306 return createFromColor(property, style);
307 case CSSPropertyBackgroundImage: 307 case CSSPropertyBackgroundImage:
308 return createFromFillLayers<CSSPropertyBackgroundImage>(style.background Layers(), style); 308 return createFromFillLayers<CSSPropertyBackgroundImage>(style.background Layers(), style);
309 case CSSPropertyBackgroundPositionX: 309 case CSSPropertyBackgroundPositionX:
310 return createFromFillLayers<CSSPropertyBackgroundPositionX>(style.backgr oundLayers(), style); 310 return createFromFillLayers<CSSPropertyBackgroundPositionX>(style.backgr oundLayers(), style);
311 case CSSPropertyBackgroundPositionY: 311 case CSSPropertyBackgroundPositionY:
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 return createFromLength(style.svgStyle().ry(), style); 563 return createFromLength(style.svgStyle().ry(), style);
564 case CSSPropertyZIndex: 564 case CSSPropertyZIndex:
565 return createFromDouble(style.zIndex()); 565 return createFromDouble(style.zIndex());
566 default: 566 default:
567 ASSERT_NOT_REACHED(); 567 ASSERT_NOT_REACHED();
568 return nullptr; 568 return nullptr;
569 } 569 }
570 } 570 }
571 571
572 } // namespace blink 572 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698