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 12 matching lines...) Expand all Loading... |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "core/animation/css/CSSAnimatableValueFactory.h" | 31 #include "core/animation/css/CSSAnimatableValueFactory.h" |
32 | 32 |
33 #include "core/CSSValueKeywords.h" | 33 #include "core/animation/CompositorAnimations.h" |
34 #include "core/animation/FontWeightConversion.h" | |
35 #include "core/animation/LengthPropertyFunctions.h" | |
36 #include "core/animation/PropertyHandle.h" | |
37 #include "core/animation/animatable/AnimatableClipPathOperation.h" | |
38 #include "core/animation/animatable/AnimatableColor.h" | |
39 #include "core/animation/animatable/AnimatableDouble.h" | 34 #include "core/animation/animatable/AnimatableDouble.h" |
40 #include "core/animation/animatable/AnimatableDoubleAndBool.h" | |
41 #include "core/animation/animatable/AnimatableFilterOperations.h" | 35 #include "core/animation/animatable/AnimatableFilterOperations.h" |
42 #include "core/animation/animatable/AnimatableFontVariationSettings.h" | |
43 #include "core/animation/animatable/AnimatableImage.h" | |
44 #include "core/animation/animatable/AnimatableLength.h" | |
45 #include "core/animation/animatable/AnimatableLengthBox.h" | |
46 #include "core/animation/animatable/AnimatableLengthBoxAndBool.h" | |
47 #include "core/animation/animatable/AnimatableLengthPoint.h" | |
48 #include "core/animation/animatable/AnimatableLengthPoint3D.h" | |
49 #include "core/animation/animatable/AnimatableLengthSize.h" | |
50 #include "core/animation/animatable/AnimatablePath.h" | |
51 #include "core/animation/animatable/AnimatableRepeatable.h" | |
52 #include "core/animation/animatable/AnimatableSVGPaint.h" | |
53 #include "core/animation/animatable/AnimatableShadow.h" | |
54 #include "core/animation/animatable/AnimatableShapeValue.h" | |
55 #include "core/animation/animatable/AnimatableStrokeDasharrayList.h" | |
56 #include "core/animation/animatable/AnimatableTransform.h" | 36 #include "core/animation/animatable/AnimatableTransform.h" |
57 #include "core/animation/animatable/AnimatableUnknown.h" | |
58 #include "core/animation/animatable/AnimatableVisibility.h" | |
59 #include "core/css/CSSCalculationValue.h" | |
60 #include "core/css/CSSIdentifierValue.h" | |
61 #include "core/css/CSSPrimitiveValue.h" | |
62 #include "core/css/CSSPrimitiveValueMappings.h" | |
63 #include "core/css/CSSPropertyMetadata.h" | |
64 #include "core/style/ComputedStyle.h" | 37 #include "core/style/ComputedStyle.h" |
65 #include "platform/Length.h" | |
66 #include "platform/LengthBox.h" | |
67 #include "platform/wtf/StdLibExtras.h" | |
68 | 38 |
69 namespace blink { | 39 namespace blink { |
70 | 40 |
71 static PassRefPtr<AnimatableValue> CreateFromLengthWithZoom( | |
72 const Length& length, | |
73 float zoom) { | |
74 switch (length.GetType()) { | |
75 case kFixed: | |
76 case kPercent: | |
77 case kCalculated: | |
78 return AnimatableLength::Create(length, zoom); | |
79 case kAuto: | |
80 case kMinContent: | |
81 case kMaxContent: | |
82 case kFillAvailable: | |
83 case kFitContent: | |
84 return AnimatableUnknown::Create(CSSValue::Create(length, 1)); | |
85 case kMaxSizeNone: | |
86 return AnimatableUnknown::Create(CSSValueNone); | |
87 case kExtendToZoom: // Does not apply to elements. | |
88 case kDeviceWidth: | |
89 case kDeviceHeight: | |
90 NOTREACHED(); | |
91 return nullptr; | |
92 } | |
93 NOTREACHED(); | |
94 return nullptr; | |
95 } | |
96 | |
97 static PassRefPtr<AnimatableValue> CreateFromLength( | |
98 const Length& length, | |
99 const ComputedStyle& style) { | |
100 return CreateFromLengthWithZoom(length, style.EffectiveZoom()); | |
101 } | |
102 | |
103 static PassRefPtr<AnimatableValue> CreateFromPropertyLength( | |
104 CSSPropertyID property, | |
105 const ComputedStyle& style) { | |
106 Length length; | |
107 bool success = LengthPropertyFunctions::GetLength(property, style, length); | |
108 DCHECK(success); | |
109 return CreateFromLength(length, style); | |
110 } | |
111 | |
112 static PassRefPtr<AnimatableValue> CreateFromUnzoomedLength( | |
113 const UnzoomedLength& unzoomed_length) { | |
114 return CreateFromLengthWithZoom(unzoomed_length.length(), 1); | |
115 } | |
116 | |
117 static PassRefPtr<AnimatableValue> CreateFromLineHeight( | |
118 const Length& length, | |
119 const ComputedStyle& style) { | |
120 if (length.GetType() == kPercent) { | |
121 double value = length.Value(); | |
122 // -100% is used to represent "normal" line height. | |
123 if (value == -100) | |
124 return AnimatableUnknown::Create(CSSValueNormal); | |
125 return AnimatableDouble::Create(value); | |
126 } | |
127 return CreateFromLength(length, style); | |
128 } | |
129 | |
130 inline static PassRefPtr<AnimatableValue> CreateFromDouble(double value) { | |
131 return AnimatableDouble::Create(value); | |
132 } | |
133 | |
134 inline static PassRefPtr<AnimatableValue> CreateFromLengthBox( | |
135 const LengthBox& length_box, | |
136 const ComputedStyle& style) { | |
137 return AnimatableLengthBox::Create( | |
138 CreateFromLength(length_box.Left(), style), | |
139 CreateFromLength(length_box.Right(), style), | |
140 CreateFromLength(length_box.Top(), style), | |
141 CreateFromLength(length_box.Bottom(), style)); | |
142 } | |
143 | |
144 static PassRefPtr<AnimatableValue> CreateFromBorderImageLength( | |
145 const BorderImageLength& border_image_length, | |
146 const ComputedStyle& style) { | |
147 if (border_image_length.IsNumber()) | |
148 return CreateFromDouble(border_image_length.Number()); | |
149 return CreateFromLength(border_image_length.length(), style); | |
150 } | |
151 | |
152 inline static PassRefPtr<AnimatableValue> CreateFromBorderImageLengthBox( | |
153 const BorderImageLengthBox& border_image_length_box, | |
154 const ComputedStyle& style) { | |
155 return AnimatableLengthBox::Create( | |
156 CreateFromBorderImageLength(border_image_length_box.Left(), style), | |
157 CreateFromBorderImageLength(border_image_length_box.Right(), style), | |
158 CreateFromBorderImageLength(border_image_length_box.Top(), style), | |
159 CreateFromBorderImageLength(border_image_length_box.Bottom(), style)); | |
160 } | |
161 | |
162 inline static PassRefPtr<AnimatableValue> CreateFromLengthBoxAndBool( | |
163 const LengthBox length_box, | |
164 const bool flag, | |
165 const ComputedStyle& style) { | |
166 return AnimatableLengthBoxAndBool::Create( | |
167 CreateFromLengthBox(length_box, style), flag); | |
168 } | |
169 | |
170 inline static PassRefPtr<AnimatableValue> CreateFromDoubleAndBool( | |
171 double number, | |
172 const bool flag, | |
173 const ComputedStyle& style) { | |
174 return AnimatableDoubleAndBool::Create(number, flag); | |
175 } | |
176 | |
177 inline static PassRefPtr<AnimatableValue> CreateFromLengthPoint( | |
178 const LengthPoint& length_point, | |
179 const ComputedStyle& style) { | |
180 return AnimatableLengthPoint::Create( | |
181 CreateFromLength(length_point.X(), style), | |
182 CreateFromLength(length_point.Y(), style)); | |
183 } | |
184 | |
185 inline static PassRefPtr<AnimatableValue> CreateFromTransformOrigin( | |
186 const TransformOrigin& transform_origin, | |
187 const ComputedStyle& style) { | |
188 return AnimatableLengthPoint3D::Create( | |
189 CreateFromLength(transform_origin.X(), style), | |
190 CreateFromLength(transform_origin.Y(), style), | |
191 CreateFromLength(Length(transform_origin.Z(), kFixed), style)); | |
192 } | |
193 | |
194 inline static PassRefPtr<AnimatableValue> CreateFromLengthSize( | |
195 const LengthSize& length_size, | |
196 const ComputedStyle& style) { | |
197 return AnimatableLengthSize::Create( | |
198 CreateFromLength(length_size.Width(), style), | |
199 CreateFromLength(length_size.Height(), style)); | |
200 } | |
201 | |
202 inline static PassRefPtr<AnimatableValue> CreateFromStyleImage( | |
203 StyleImage* image) { | |
204 if (image) { | |
205 if (CSSValue* css_value = image->CssValue()) | |
206 return AnimatableImage::Create(css_value); | |
207 } | |
208 return AnimatableUnknown::Create(CSSValueNone); | |
209 } | |
210 | |
211 inline static PassRefPtr<AnimatableValue> CreateFromFillSize( | |
212 const FillSize& fill_size, | |
213 const ComputedStyle& style) { | |
214 switch (fill_size.type) { | |
215 case kSizeLength: | |
216 return CreateFromLengthSize(fill_size.size, style); | |
217 case kContain: | |
218 case kCover: | |
219 case kSizeNone: | |
220 return AnimatableUnknown::Create( | |
221 CSSIdentifierValue::Create(fill_size.type)); | |
222 default: | |
223 NOTREACHED(); | |
224 return nullptr; | |
225 } | |
226 } | |
227 | |
228 inline static PassRefPtr<AnimatableValue> CreateFromBackgroundPosition( | |
229 const Length& length, | |
230 bool origin_is_set, | |
231 BackgroundEdgeOrigin origin, | |
232 const ComputedStyle& style) { | |
233 if (!origin_is_set || origin == kLeftEdge || origin == kTopEdge) | |
234 return CreateFromLength(length, style); | |
235 return CreateFromLength(length.SubtractFromOneHundredPercent(), style); | |
236 } | |
237 | |
238 template <CSSPropertyID property> | |
239 inline static PassRefPtr<AnimatableValue> CreateFromFillLayers( | |
240 const FillLayer& fill_layers, | |
241 const ComputedStyle& style) { | |
242 Vector<RefPtr<AnimatableValue>> values; | |
243 for (const FillLayer* fill_layer = &fill_layers; fill_layer; | |
244 fill_layer = fill_layer->Next()) { | |
245 if (property == CSSPropertyBackgroundImage || | |
246 property == CSSPropertyWebkitMaskImage) { | |
247 if (!fill_layer->IsImageSet()) | |
248 break; | |
249 values.push_back(CreateFromStyleImage(fill_layer->GetImage())); | |
250 } else if (property == CSSPropertyBackgroundPositionX || | |
251 property == CSSPropertyWebkitMaskPositionX) { | |
252 if (!fill_layer->IsXPositionSet()) | |
253 break; | |
254 values.push_back(CreateFromBackgroundPosition( | |
255 fill_layer->XPosition(), fill_layer->IsBackgroundXOriginSet(), | |
256 fill_layer->BackgroundXOrigin(), style)); | |
257 } else if (property == CSSPropertyBackgroundPositionY || | |
258 property == CSSPropertyWebkitMaskPositionY) { | |
259 if (!fill_layer->IsYPositionSet()) | |
260 break; | |
261 values.push_back(CreateFromBackgroundPosition( | |
262 fill_layer->YPosition(), fill_layer->IsBackgroundYOriginSet(), | |
263 fill_layer->BackgroundYOrigin(), style)); | |
264 } else if (property == CSSPropertyBackgroundSize || | |
265 property == CSSPropertyWebkitMaskSize) { | |
266 if (!fill_layer->IsSizeSet()) | |
267 break; | |
268 values.push_back(CreateFromFillSize(fill_layer->Size(), style)); | |
269 } else { | |
270 NOTREACHED(); | |
271 } | |
272 } | |
273 return AnimatableRepeatable::Create(values); | |
274 } | |
275 | |
276 PassRefPtr<AnimatableValue> CSSAnimatableValueFactory::CreateFromColor( | |
277 CSSPropertyID property, | |
278 const ComputedStyle& style) { | |
279 Color color = style.ColorIncludingFallback(property, false); | |
280 Color visited_link_color = style.ColorIncludingFallback(property, true); | |
281 return AnimatableColor::Create(color, visited_link_color); | |
282 } | |
283 | |
284 inline static PassRefPtr<AnimatableValue> CreateFromShapeValue( | |
285 ShapeValue* value) { | |
286 if (value) | |
287 return AnimatableShapeValue::Create(value); | |
288 return AnimatableUnknown::Create(CSSValueNone); | |
289 } | |
290 | |
291 static PassRefPtr<AnimatableValue> CreateFromPath(StylePath* path) { | |
292 return AnimatablePath::Create(path); | |
293 } | |
294 | |
295 static double FontStretchToDouble(FontStretch font_stretch) { | |
296 return static_cast<unsigned>(font_stretch); | |
297 } | |
298 | |
299 static PassRefPtr<AnimatableValue> CreateFromFontStretch( | |
300 FontStretch font_stretch) { | |
301 return CreateFromDouble(FontStretchToDouble(font_stretch)); | |
302 } | |
303 | |
304 static PassRefPtr<AnimatableValue> CreateFromFontVariationSettings( | |
305 FontVariationSettings* settings) { | |
306 return AnimatableFontVariationSettings::Create(settings); | |
307 } | |
308 | |
309 static PassRefPtr<AnimatableValue> CreateFromTransformProperties( | 41 static PassRefPtr<AnimatableValue> CreateFromTransformProperties( |
310 PassRefPtr<TransformOperation> transform, | 42 PassRefPtr<TransformOperation> transform, |
311 double zoom, | 43 double zoom, |
312 PassRefPtr<TransformOperation> initial_transform) { | 44 PassRefPtr<TransformOperation> initial_transform) { |
313 TransformOperations operation; | 45 TransformOperations operation; |
314 bool has_transform = static_cast<bool>(transform); | 46 bool has_transform = static_cast<bool>(transform); |
315 if (has_transform || initial_transform) { | 47 if (has_transform || initial_transform) { |
316 operation.Operations().push_back( | 48 operation.Operations().push_back( |
317 std::move(has_transform ? transform : initial_transform)); | 49 std::move(has_transform ? transform : initial_transform)); |
318 } | 50 } |
319 return AnimatableTransform::Create(operation, has_transform ? zoom : 1); | 51 return AnimatableTransform::Create(operation, has_transform ? zoom : 1); |
320 } | 52 } |
321 | 53 |
322 static PassRefPtr<AnimatableValue> CreateFromFontWeight( | |
323 FontWeight font_weight) { | |
324 return CreateFromDouble(FontWeightToDouble(font_weight)); | |
325 } | |
326 | |
327 static SVGPaintType NormalizeSVGPaintType(SVGPaintType paint_type) { | |
328 // If the <paint> is 'currentColor', then create an AnimatableSVGPaint with | |
329 // a <rgbcolor> type. This is similar in vein to the handling of colors. | |
330 return paint_type == SVG_PAINTTYPE_CURRENTCOLOR ? SVG_PAINTTYPE_RGBCOLOR | |
331 : paint_type; | |
332 } | |
333 | |
334 PassRefPtr<AnimatableValue> CSSAnimatableValueFactory::Create( | 54 PassRefPtr<AnimatableValue> CSSAnimatableValueFactory::Create( |
335 const PropertyHandle& property, | 55 CSSPropertyID property, |
336 const ComputedStyle& style) { | 56 const ComputedStyle& style) { |
337 if (property.IsCSSCustomProperty()) { | 57 DCHECK(CSSPropertyMetadata::IsInterpolableProperty(property)); |
338 return AnimatableUnknown::Create( | 58 DCHECK(CompositorAnimations::IsCompositableProperty(property)); |
339 style.GetRegisteredVariable(property.CustomPropertyName())); | 59 switch (property) { |
340 } | |
341 | |
342 CSSPropertyID property_id = property.CssProperty(); | |
343 DCHECK(CSSPropertyMetadata::IsInterpolableProperty(property_id)); | |
344 switch (property_id) { | |
345 case CSSPropertyBackgroundColor: | |
346 return CreateFromColor(property_id, style); | |
347 case CSSPropertyBackgroundImage: | |
348 return CreateFromFillLayers<CSSPropertyBackgroundImage>( | |
349 style.BackgroundLayers(), style); | |
350 case CSSPropertyBackgroundPositionX: | |
351 return CreateFromFillLayers<CSSPropertyBackgroundPositionX>( | |
352 style.BackgroundLayers(), style); | |
353 case CSSPropertyBackgroundPositionY: | |
354 return CreateFromFillLayers<CSSPropertyBackgroundPositionY>( | |
355 style.BackgroundLayers(), style); | |
356 case CSSPropertyBackgroundSize: | |
357 return CreateFromFillLayers<CSSPropertyBackgroundSize>( | |
358 style.BackgroundLayers(), style); | |
359 case CSSPropertyBaselineShift: | |
360 switch (style.SvgStyle().BaselineShift()) { | |
361 case BS_SUPER: | |
362 return AnimatableUnknown::Create( | |
363 CSSIdentifierValue::Create(CSSValueSuper)); | |
364 case BS_SUB: | |
365 return AnimatableUnknown::Create( | |
366 CSSIdentifierValue::Create(CSSValueSub)); | |
367 default: | |
368 return CreateFromLength(style.BaselineShiftValue(), style); | |
369 } | |
370 case CSSPropertyBorderBottomColor: | |
371 return CreateFromColor(property_id, style); | |
372 case CSSPropertyBorderBottomLeftRadius: | |
373 return CreateFromLengthSize(style.BorderBottomLeftRadius(), style); | |
374 case CSSPropertyBorderBottomRightRadius: | |
375 return CreateFromLengthSize(style.BorderBottomRightRadius(), style); | |
376 case CSSPropertyBorderBottomWidth: | |
377 return CreateFromPropertyLength(property_id, style); | |
378 case CSSPropertyBorderImageOutset: | |
379 return CreateFromBorderImageLengthBox(style.BorderImageOutset(), style); | |
380 case CSSPropertyBorderImageSlice: | |
381 return CreateFromLengthBoxAndBool(style.BorderImageSlices(), | |
382 style.BorderImageSlicesFill(), style); | |
383 case CSSPropertyBorderImageSource: | |
384 return CreateFromStyleImage(style.BorderImageSource()); | |
385 case CSSPropertyBorderImageWidth: | |
386 return CreateFromBorderImageLengthBox(style.BorderImageWidth(), style); | |
387 case CSSPropertyBorderLeftColor: | |
388 return CreateFromColor(property_id, style); | |
389 case CSSPropertyBorderLeftWidth: | |
390 return CreateFromPropertyLength(property_id, style); | |
391 case CSSPropertyBorderRightColor: | |
392 return CreateFromColor(property_id, style); | |
393 case CSSPropertyBorderRightWidth: | |
394 return CreateFromPropertyLength(property_id, style); | |
395 case CSSPropertyBorderTopColor: | |
396 return CreateFromColor(property_id, style); | |
397 case CSSPropertyBorderTopLeftRadius: | |
398 return CreateFromLengthSize(style.BorderTopLeftRadius(), style); | |
399 case CSSPropertyBorderTopRightRadius: | |
400 return CreateFromLengthSize(style.BorderTopRightRadius(), style); | |
401 case CSSPropertyBorderTopWidth: | |
402 return CreateFromPropertyLength(property_id, style); | |
403 case CSSPropertyBottom: | |
404 return CreateFromLength(style.Bottom(), style); | |
405 case CSSPropertyBoxShadow: | |
406 return AnimatableShadow::Create(style.BoxShadow()); | |
407 case CSSPropertyClip: | |
408 if (style.HasAutoClip()) { | |
409 return AnimatableUnknown::Create( | |
410 CSSIdentifierValue::Create(CSSValueAuto)); | |
411 } | |
412 return CreateFromLengthBox(style.Clip(), style); | |
413 case CSSPropertyCaretColor: | |
414 if (style.CaretColor().IsAutoColor()) { | |
415 return AnimatableUnknown::Create( | |
416 CSSIdentifierValue::Create(CSSValueAuto)); | |
417 } | |
418 return CreateFromColor(property_id, style); | |
419 case CSSPropertyColor: | |
420 return CreateFromColor(property_id, style); | |
421 case CSSPropertyFillOpacity: | |
422 return CreateFromDouble(style.FillOpacity()); | |
423 case CSSPropertyFill: | |
424 return AnimatableSVGPaint::Create( | |
425 NormalizeSVGPaintType(style.SvgStyle().FillPaintType()), | |
426 NormalizeSVGPaintType(style.SvgStyle().VisitedLinkFillPaintType()), | |
427 style.SvgStyle().FillPaintColor(), | |
428 style.SvgStyle().VisitedLinkFillPaintColor(), | |
429 style.SvgStyle().FillPaintUri(), | |
430 style.SvgStyle().VisitedLinkFillPaintUri()); | |
431 case CSSPropertyFlexGrow: | |
432 return CreateFromDouble(style.FlexGrow()); | |
433 case CSSPropertyFlexShrink: | |
434 return CreateFromDouble(style.FlexShrink()); | |
435 case CSSPropertyFlexBasis: | |
436 return CreateFromLength(style.FlexBasis(), style); | |
437 case CSSPropertyFloodColor: | |
438 return CreateFromColor(property_id, style); | |
439 case CSSPropertyFloodOpacity: | |
440 return CreateFromDouble(style.FloodOpacity()); | |
441 case CSSPropertyFontSize: | |
442 // Must pass a specified size to setFontSize if Text Autosizing is | |
443 // enabled, but a computed size if text zoom is enabled (if neither is | |
444 // enabled it's irrelevant as they're probably the same). | |
445 // FIXME: Should we introduce an option to pass the computed font size | |
446 // here, allowing consumers to enable text zoom rather than Text | |
447 // Autosizing? See http://crbug.com/227545. | |
448 return CreateFromDouble(style.SpecifiedFontSize()); | |
449 case CSSPropertyFontSizeAdjust: | |
450 return style.HasFontSizeAdjust() | |
451 ? CreateFromDouble(style.FontSizeAdjust()) | |
452 : AnimatableUnknown::Create(CSSValueNone); | |
453 case CSSPropertyFontStretch: | |
454 return CreateFromFontStretch(style.GetFontStretch()); | |
455 case CSSPropertyFontVariationSettings: | |
456 return CreateFromFontVariationSettings( | |
457 style.GetFontDescription().VariationSettings()); | |
458 case CSSPropertyFontWeight: | |
459 return CreateFromFontWeight(style.GetFontWeight()); | |
460 case CSSPropertyHeight: | |
461 return CreateFromLength(style.Height(), style); | |
462 case CSSPropertyLightingColor: | |
463 return CreateFromColor(property_id, style); | |
464 case CSSPropertyListStyleImage: | |
465 return CreateFromStyleImage(style.ListStyleImage()); | |
466 case CSSPropertyLeft: | |
467 return CreateFromLength(style.Left(), style); | |
468 case CSSPropertyLetterSpacing: | |
469 return CreateFromPropertyLength(property_id, style); | |
470 case CSSPropertyLineHeight: | |
471 return CreateFromLineHeight(style.SpecifiedLineHeight(), style); | |
472 case CSSPropertyMarginBottom: | |
473 return CreateFromLength(style.MarginBottom(), style); | |
474 case CSSPropertyMarginLeft: | |
475 return CreateFromLength(style.MarginLeft(), style); | |
476 case CSSPropertyMarginRight: | |
477 return CreateFromLength(style.MarginRight(), style); | |
478 case CSSPropertyMarginTop: | |
479 return CreateFromLength(style.MarginTop(), style); | |
480 case CSSPropertyMaxHeight: | |
481 return CreateFromLength(style.MaxHeight(), style); | |
482 case CSSPropertyMaxWidth: | |
483 return CreateFromLength(style.MaxWidth(), style); | |
484 case CSSPropertyMinHeight: | |
485 return CreateFromLength(style.MinHeight(), style); | |
486 case CSSPropertyMinWidth: | |
487 return CreateFromLength(style.MinWidth(), style); | |
488 case CSSPropertyObjectPosition: | |
489 return CreateFromLengthPoint(style.ObjectPosition(), style); | |
490 case CSSPropertyOpacity: | 60 case CSSPropertyOpacity: |
491 return CreateFromDouble(style.Opacity()); | 61 return AnimatableDouble::Create(style.Opacity()); |
492 case CSSPropertyOrder: | |
493 return CreateFromDouble(style.Order()); | |
494 case CSSPropertyOrphans: | |
495 return CreateFromDouble(style.Orphans()); | |
496 case CSSPropertyOutlineColor: | |
497 return CreateFromColor(property_id, style); | |
498 case CSSPropertyOutlineOffset: | |
499 return CreateFromPropertyLength(property_id, style); | |
500 case CSSPropertyOutlineWidth: | |
501 return CreateFromPropertyLength(property_id, style); | |
502 case CSSPropertyPaddingBottom: | |
503 return CreateFromLength(style.PaddingBottom(), style); | |
504 case CSSPropertyPaddingLeft: | |
505 return CreateFromLength(style.PaddingLeft(), style); | |
506 case CSSPropertyPaddingRight: | |
507 return CreateFromLength(style.PaddingRight(), style); | |
508 case CSSPropertyPaddingTop: | |
509 return CreateFromLength(style.PaddingTop(), style); | |
510 case CSSPropertyRight: | |
511 return CreateFromLength(style.Right(), style); | |
512 case CSSPropertyStrokeWidth: | |
513 return CreateFromUnzoomedLength(style.StrokeWidth()); | |
514 case CSSPropertyStopColor: | |
515 return CreateFromColor(property_id, style); | |
516 case CSSPropertyStopOpacity: | |
517 return CreateFromDouble(style.StopOpacity()); | |
518 case CSSPropertyStrokeDasharray: | |
519 return AnimatableStrokeDasharrayList::Create(style.StrokeDashArray(), | |
520 style.EffectiveZoom()); | |
521 case CSSPropertyStrokeDashoffset: | |
522 return CreateFromLength(style.StrokeDashOffset(), style); | |
523 case CSSPropertyStrokeMiterlimit: | |
524 return CreateFromDouble(style.StrokeMiterLimit()); | |
525 case CSSPropertyStrokeOpacity: | |
526 return CreateFromDouble(style.StrokeOpacity()); | |
527 case CSSPropertyStroke: | |
528 return AnimatableSVGPaint::Create( | |
529 NormalizeSVGPaintType(style.SvgStyle().StrokePaintType()), | |
530 NormalizeSVGPaintType(style.SvgStyle().VisitedLinkStrokePaintType()), | |
531 style.SvgStyle().StrokePaintColor(), | |
532 style.SvgStyle().VisitedLinkStrokePaintColor(), | |
533 style.SvgStyle().StrokePaintUri(), | |
534 style.SvgStyle().VisitedLinkStrokePaintUri()); | |
535 case CSSPropertyTextDecorationColor: | |
536 return CreateFromColor(property_id, style); | |
537 case CSSPropertyTextIndent: | |
538 return CreateFromLength(style.TextIndent(), style); | |
539 case CSSPropertyTextShadow: | |
540 return AnimatableShadow::Create(style.TextShadow()); | |
541 case CSSPropertyTop: | |
542 return CreateFromLength(style.Top(), style); | |
543 case CSSPropertyWebkitBorderHorizontalSpacing: | |
544 return CreateFromPropertyLength(property_id, style); | |
545 case CSSPropertyWebkitBorderVerticalSpacing: | |
546 return CreateFromPropertyLength(property_id, style); | |
547 case CSSPropertyClipPath: | |
548 if (ClipPathOperation* operation = style.ClipPath()) | |
549 return AnimatableClipPathOperation::Create(operation); | |
550 return AnimatableUnknown::Create(CSSValueNone); | |
551 case CSSPropertyColumnCount: | |
552 if (style.HasAutoColumnCount()) | |
553 return AnimatableUnknown::Create(CSSValueAuto); | |
554 return CreateFromDouble(style.ColumnCount()); | |
555 case CSSPropertyColumnGap: | |
556 return CreateFromPropertyLength(property_id, style); | |
557 case CSSPropertyColumnRuleColor: | |
558 return CreateFromColor(property_id, style); | |
559 case CSSPropertyColumnRuleWidth: | |
560 return CreateFromPropertyLength(property_id, style); | |
561 case CSSPropertyColumnWidth: | |
562 if (style.HasAutoColumnWidth()) | |
563 return AnimatableUnknown::Create(CSSValueAuto); | |
564 return CreateFromPropertyLength(property_id, style); | |
565 case CSSPropertyFilter: | 62 case CSSPropertyFilter: |
566 return AnimatableFilterOperations::Create(style.Filter()); | 63 return AnimatableFilterOperations::Create(style.Filter()); |
567 case CSSPropertyBackdropFilter: | 64 case CSSPropertyBackdropFilter: |
568 return AnimatableFilterOperations::Create(style.BackdropFilter()); | 65 return AnimatableFilterOperations::Create(style.BackdropFilter()); |
569 case CSSPropertyWebkitMaskBoxImageOutset: | |
570 return CreateFromBorderImageLengthBox(style.MaskBoxImageOutset(), style); | |
571 case CSSPropertyWebkitMaskBoxImageSlice: | |
572 return CreateFromLengthBoxAndBool(style.MaskBoxImageSlices(), | |
573 style.MaskBoxImageSlicesFill(), style); | |
574 case CSSPropertyWebkitMaskBoxImageSource: | |
575 return CreateFromStyleImage(style.MaskBoxImageSource()); | |
576 case CSSPropertyWebkitMaskBoxImageWidth: | |
577 return CreateFromBorderImageLengthBox(style.MaskBoxImageWidth(), style); | |
578 case CSSPropertyWebkitMaskImage: | |
579 return CreateFromFillLayers<CSSPropertyWebkitMaskImage>( | |
580 style.MaskLayers(), style); | |
581 case CSSPropertyWebkitMaskPositionX: | |
582 return CreateFromFillLayers<CSSPropertyWebkitMaskPositionX>( | |
583 style.MaskLayers(), style); | |
584 case CSSPropertyWebkitMaskPositionY: | |
585 return CreateFromFillLayers<CSSPropertyWebkitMaskPositionY>( | |
586 style.MaskLayers(), style); | |
587 case CSSPropertyWebkitMaskSize: | |
588 return CreateFromFillLayers<CSSPropertyWebkitMaskSize>(style.MaskLayers(), | |
589 style); | |
590 case CSSPropertyPerspective: | |
591 if (style.Perspective() == 0) { | |
592 return AnimatableUnknown::Create( | |
593 CSSIdentifierValue::Create(CSSValueNone)); | |
594 } | |
595 return CreateFromPropertyLength(property_id, style); | |
596 case CSSPropertyPerspectiveOrigin: | |
597 return CreateFromLengthPoint(style.PerspectiveOrigin(), style); | |
598 case CSSPropertyShapeOutside: | |
599 return CreateFromShapeValue(style.ShapeOutside()); | |
600 case CSSPropertyShapeMargin: | |
601 return CreateFromLength(style.ShapeMargin(), style); | |
602 case CSSPropertyShapeImageThreshold: | |
603 return CreateFromDouble(style.ShapeImageThreshold()); | |
604 case CSSPropertyWebkitTextStrokeColor: | |
605 return CreateFromColor(property_id, style); | |
606 case CSSPropertyTransform: | 66 case CSSPropertyTransform: |
607 return AnimatableTransform::Create(style.Transform(), | 67 return AnimatableTransform::Create(style.Transform(), |
608 style.EffectiveZoom()); | 68 style.EffectiveZoom()); |
609 case CSSPropertyTranslate: { | 69 case CSSPropertyTranslate: { |
610 return CreateFromTransformProperties(style.Translate(), | 70 return CreateFromTransformProperties(style.Translate(), |
611 style.EffectiveZoom(), nullptr); | 71 style.EffectiveZoom(), nullptr); |
612 } | 72 } |
613 case CSSPropertyRotate: { | 73 case CSSPropertyRotate: { |
614 return CreateFromTransformProperties(style.Rotate(), | 74 return CreateFromTransformProperties(style.Rotate(), |
615 style.EffectiveZoom(), nullptr); | 75 style.EffectiveZoom(), nullptr); |
616 } | 76 } |
617 case CSSPropertyScale: { | 77 case CSSPropertyScale: { |
618 return CreateFromTransformProperties(style.Scale(), style.EffectiveZoom(), | 78 return CreateFromTransformProperties(style.Scale(), style.EffectiveZoom(), |
619 nullptr); | 79 nullptr); |
620 } | 80 } |
621 case CSSPropertyOffsetAnchor: | |
622 return CreateFromLengthPoint(style.OffsetAnchor(), style); | |
623 case CSSPropertyOffsetDistance: | |
624 return CreateFromLength(style.OffsetDistance(), style); | |
625 case CSSPropertyOffsetPosition: | |
626 return CreateFromLengthPoint(style.OffsetPosition(), style); | |
627 case CSSPropertyOffsetRotate: | |
628 return CreateFromDoubleAndBool( | |
629 style.OffsetRotate().angle, | |
630 style.OffsetRotate().type == kOffsetRotationAuto, style); | |
631 case CSSPropertyTransformOrigin: | |
632 return CreateFromTransformOrigin(style.GetTransformOrigin(), style); | |
633 case CSSPropertyWebkitPerspectiveOriginX: | |
634 return CreateFromLength(style.PerspectiveOriginX(), style); | |
635 case CSSPropertyWebkitPerspectiveOriginY: | |
636 return CreateFromLength(style.PerspectiveOriginY(), style); | |
637 case CSSPropertyWebkitTransformOriginX: | |
638 return CreateFromLength(style.TransformOriginX(), style); | |
639 case CSSPropertyWebkitTransformOriginY: | |
640 return CreateFromLength(style.TransformOriginY(), style); | |
641 case CSSPropertyWebkitTransformOriginZ: | |
642 return CreateFromPropertyLength(property_id, style); | |
643 case CSSPropertyWidows: | |
644 return CreateFromDouble(style.Widows()); | |
645 case CSSPropertyWidth: | |
646 return CreateFromLength(style.Width(), style); | |
647 case CSSPropertyWordSpacing: | |
648 return CreateFromPropertyLength(property_id, style); | |
649 case CSSPropertyVerticalAlign: | |
650 if (style.VerticalAlign() == EVerticalAlign::kLength) | |
651 return CreateFromLength(style.GetVerticalAlignLength(), style); | |
652 return AnimatableUnknown::Create( | |
653 CSSIdentifierValue::Create(style.VerticalAlign())); | |
654 case CSSPropertyVisibility: | |
655 return AnimatableVisibility::Create(style.Visibility()); | |
656 case CSSPropertyD: | |
657 return CreateFromPath(style.SvgStyle().D()); | |
658 case CSSPropertyCx: | |
659 return CreateFromLength(style.SvgStyle().Cx(), style); | |
660 case CSSPropertyCy: | |
661 return CreateFromLength(style.SvgStyle().Cy(), style); | |
662 case CSSPropertyX: | |
663 return CreateFromLength(style.SvgStyle().X(), style); | |
664 case CSSPropertyY: | |
665 return CreateFromLength(style.SvgStyle().Y(), style); | |
666 case CSSPropertyR: | |
667 return CreateFromLength(style.SvgStyle().R(), style); | |
668 case CSSPropertyRx: | |
669 return CreateFromLength(style.SvgStyle().Rx(), style); | |
670 case CSSPropertyRy: | |
671 return CreateFromLength(style.SvgStyle().Ry(), style); | |
672 case CSSPropertyZIndex: | |
673 if (style.HasAutoZIndex()) | |
674 return AnimatableUnknown::Create(CSSValueAuto); | |
675 return CreateFromDouble(style.ZIndex()); | |
676 default: | 81 default: |
677 NOTREACHED(); | 82 NOTREACHED(); |
678 return nullptr; | 83 return nullptr; |
679 } | 84 } |
680 } | 85 } |
681 | 86 |
682 } // namespace blink | 87 } // namespace blink |
OLD | NEW |