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

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

Issue 1033943002: Rename LayoutStyle to papayawhip (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: ensureComputedStyle Created 5 years, 8 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "core/animation/animatable/AnimatableShadow.h" 49 #include "core/animation/animatable/AnimatableShadow.h"
50 #include "core/animation/animatable/AnimatableShapeValue.h" 50 #include "core/animation/animatable/AnimatableShapeValue.h"
51 #include "core/animation/animatable/AnimatableStrokeDasharrayList.h" 51 #include "core/animation/animatable/AnimatableStrokeDasharrayList.h"
52 #include "core/animation/animatable/AnimatableTransform.h" 52 #include "core/animation/animatable/AnimatableTransform.h"
53 #include "core/animation/animatable/AnimatableUnknown.h" 53 #include "core/animation/animatable/AnimatableUnknown.h"
54 #include "core/animation/animatable/AnimatableVisibility.h" 54 #include "core/animation/animatable/AnimatableVisibility.h"
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/layout/style/LayoutStyle.h" 59 #include "core/layout/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 PassRefPtrWillBeRawPtr<AnimatableValue> createFromLengthWithZoom(const Le ngth& length, float zoom)
66 { 66 {
67 switch (length.type()) { 67 switch (length.type()) {
68 case Fixed: 68 case Fixed:
69 case Percent: 69 case Percent:
(...skipping 12 matching lines...) Expand all
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 LayoutStyle& style) 92 static PassRefPtrWillBeRawPtr<AnimatableValue> createFromLength(const Length& le ngth, const ComputedStyle& 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 PassRefPtrWillBeRawPtr<AnimatableValue> createFromUnzoomedLength(const Un zoomedLength& unzoomedLength)
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 LayoutStyle& style) 102 static PassRefPtrWillBeRawPtr<AnimatableValue> createFromLineHeight(const Length & length, const ComputedStyle& 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 PassRefPtrWillBeRawPtr<AnimatableValue> createFromDouble(double va lue, 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 LayoutStyle& style) 119 inline static PassRefPtrWillBeRawPtr<AnimatableValue> createFromLengthBox(const LengthBox& lengthBox, const 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 LayoutStyle& style) 128 static PassRefPtrWillBeRawPtr<AnimatableValue> createFromBorderImageLength(const BorderImageLength& borderImageLength, 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 LayoutStyle& style) 135 inline static PassRefPtrWillBeRawPtr<AnimatableValue> createFromBorderImageLengt hBox(const BorderImageLengthBox& borderImageLengthBox, const ComputedStyle& styl e)
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 LayoutStyle& style) 144 inline static PassRefPtrWillBeRawPtr<AnimatableValue> createFromLengthBoxAndBool (const LengthBox lengthBox, 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 LayoutStyle& style) 151 inline static PassRefPtrWillBeRawPtr<AnimatableValue> createFromDoubleAndBool(do uble 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 LayoutStyle& style) 156 inline static PassRefPtrWillBeRawPtr<AnimatableValue> createFromLengthPoint(cons t LengthPoint& lengthPoint, 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 LayoutStyle& style) 163 inline static PassRefPtrWillBeRawPtr<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 LayoutStyle& style) 171 inline static PassRefPtrWillBeRawPtr<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 PassRefPtrWillBeRawPtr<AnimatableValue> createFromStyleImage(Style Image* 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 LayoutStyle& style) 187 inline static PassRefPtrWillBeRawPtr<AnimatableValue> createFromFillSize(const F illSize& fillSize, const 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 La youtStyle& style) 202 inline static PassRefPtrWillBeRawPtr<AnimatableValue> createFromBackgroundPositi on(const Length& length, bool originIsSet, BackgroundEdgeOrigin origin, const Co mputedStyle& 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 LayoutStyle& style) 210 inline static PassRefPtrWillBeRawPtr<AnimatableValue> createFromFillLayers(const FillLayer& fillLayers, const ComputedStyle& style)
211 { 211 {
212 WillBeHeapVector<RefPtrWillBeMember<AnimatableValue>> values; 212 WillBeHeapVector<RefPtrWillBeMember<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 LayoutStyle& style) 237 PassRefPtrWillBeRawPtr<AnimatableValue> CSSAnimatableValueFactory::createFromCol or(CSSPropertyID property, 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 PassRefPtrWillBeRawPtr<AnimatableValue> createFromShapeValue(Shape Value* value)
245 { 245 {
246 if (value) 246 if (value)
247 return AnimatableShapeValue::create(value); 247 return AnimatableShapeValue::create(value);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 LayoutStyle& style) 301 PassRefPtrWillBeRawPtr<AnimatableValue> CSSAnimatableValueFactory::create(CSSPro pertyID 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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 return createFromLength(style.svgStyle().ry(), style); 565 return createFromLength(style.svgStyle().ry(), style);
566 case CSSPropertyZIndex: 566 case CSSPropertyZIndex:
567 return createFromDouble(style.zIndex()); 567 return createFromDouble(style.zIndex());
568 default: 568 default:
569 ASSERT_NOT_REACHED(); 569 ASSERT_NOT_REACHED();
570 return nullptr; 570 return nullptr;
571 } 571 }
572 } 572 }
573 573
574 } // namespace blink 574 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/animation/css/CSSAnimatableValueFactory.h ('k') | Source/core/animation/css/CSSAnimationData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698