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 20 matching lines...) Expand all Loading... | |
31 #include "config.h" | 31 #include "config.h" |
32 #include "core/css/resolver/AnimatedStyleBuilder.h" | 32 #include "core/css/resolver/AnimatedStyleBuilder.h" |
33 | 33 |
34 #include "core/animation/AnimatableClipPathOperation.h" | 34 #include "core/animation/AnimatableClipPathOperation.h" |
35 #include "core/animation/AnimatableColor.h" | 35 #include "core/animation/AnimatableColor.h" |
36 #include "core/animation/AnimatableDouble.h" | 36 #include "core/animation/AnimatableDouble.h" |
37 #include "core/animation/AnimatableImage.h" | 37 #include "core/animation/AnimatableImage.h" |
38 #include "core/animation/AnimatableLength.h" | 38 #include "core/animation/AnimatableLength.h" |
39 #include "core/animation/AnimatableLengthBox.h" | 39 #include "core/animation/AnimatableLengthBox.h" |
40 #include "core/animation/AnimatableLengthSize.h" | 40 #include "core/animation/AnimatableLengthSize.h" |
41 #include "core/animation/AnimatableRepeatable.h" | |
41 #include "core/animation/AnimatableSVGLength.h" | 42 #include "core/animation/AnimatableSVGLength.h" |
42 #include "core/animation/AnimatableSVGPaint.h" | 43 #include "core/animation/AnimatableSVGPaint.h" |
43 #include "core/animation/AnimatableShapeValue.h" | 44 #include "core/animation/AnimatableShapeValue.h" |
44 #include "core/animation/AnimatableTransform.h" | 45 #include "core/animation/AnimatableTransform.h" |
45 #include "core/animation/AnimatableUnknown.h" | 46 #include "core/animation/AnimatableUnknown.h" |
46 #include "core/animation/AnimatableValue.h" | 47 #include "core/animation/AnimatableValue.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/CSSPrimitiveValueMappings.h" | 50 #include "core/css/CSSPrimitiveValueMappings.h" |
50 #include "core/css/resolver/StyleBuilder.h" | 51 #include "core/css/resolver/StyleBuilder.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 } | 85 } |
85 | 86 |
86 LengthSize animatableValueToLengthSize(const AnimatableValue* value, const Style ResolverState& state, NumberRange range) | 87 LengthSize animatableValueToLengthSize(const AnimatableValue* value, const Style ResolverState& state, NumberRange range) |
87 { | 88 { |
88 const AnimatableLengthSize* animatableLengthSize = toAnimatableLengthSize(va lue); | 89 const AnimatableLengthSize* animatableLengthSize = toAnimatableLengthSize(va lue); |
89 return LengthSize( | 90 return LengthSize( |
90 animatableValueToLength(animatableLengthSize->width(), state, range), | 91 animatableValueToLength(animatableLengthSize->width(), state, range), |
91 animatableValueToLength(animatableLengthSize->height(), state, range)); | 92 animatableValueToLength(animatableLengthSize->height(), state, range)); |
92 } | 93 } |
93 | 94 |
95 void setLengthOnFillLayers(void (FillLayer::*setter)(Length), void (FillLayer::* clear)(), const AnimatableValue* value, StyleResolverState& state) | |
96 { | |
97 FillLayer* fillLayer = state.style()->accessBackgroundLayers(); | |
98 const Vector<RefPtr<AnimatableValue> >& values = toAnimatableRepeatable(valu e)->values(); | |
99 ASSERT(!values.isEmpty()); | |
dstockwell
2013/10/08 22:57:31
I didn't see this assertion in the factory.
alancutter (OOO until 2018)
2013/10/09 07:20:55
Added assertion to factory.
| |
100 FillLayer* prev = 0; | |
101 for (size_t i = 0; i < values.size(); ++i) { | |
102 if (!fillLayer) { | |
103 fillLayer = new FillLayer(BackgroundFillLayer); | |
104 prev->setNext(fillLayer); | |
105 } | |
106 (fillLayer->*setter)(animatableValueToLength(values[i].get(), state)); | |
107 prev = fillLayer; | |
108 fillLayer = fillLayer->next(); | |
109 } | |
110 while (fillLayer) { | |
111 (fillLayer->*clear)(); | |
112 fillLayer = fillLayer->next(); | |
113 } | |
114 } | |
115 | |
116 void setImageOnFillLayers(FillLayer* fillLayer, const AnimatableValue* value) | |
dstockwell
2013/10/08 23:02:46
and here, if we template on CSSPropertyID we shoul
alancutter (OOO until 2018)
2013/10/09 07:20:55
Done.
| |
117 { | |
118 const Vector<RefPtr<AnimatableValue> >& values = toAnimatableRepeatable(valu e)->values(); | |
119 ASSERT(!values.isEmpty()); | |
120 FillLayer* prev = 0; | |
121 for (size_t i = 0; i < values.size(); ++i) { | |
122 if (!fillLayer) { | |
123 fillLayer = new FillLayer(BackgroundFillLayer); | |
124 prev->setNext(fillLayer); | |
125 } | |
126 fillLayer->setImage(toAnimatableImage(values[i].get())->toStyleImage()); | |
127 prev = fillLayer; | |
128 fillLayer = fillLayer->next(); | |
129 } | |
130 while (fillLayer) { | |
131 fillLayer->clearImage(); | |
132 fillLayer = fillLayer->next(); | |
133 } | |
134 } | |
135 | |
94 } // namespace | 136 } // namespace |
95 | 137 |
96 // FIXME: Generate this function. | 138 // FIXME: Generate this function. |
97 void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, StyleResolverSt ate& state, const AnimatableValue* value) | 139 void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, StyleResolverSt ate& state, const AnimatableValue* value) |
98 { | 140 { |
99 if (value->isUnknown()) { | 141 if (value->isUnknown()) { |
100 StyleBuilder::applyProperty(property, state, toAnimatableUnknown(value)- >toCSSValue().get()); | 142 StyleBuilder::applyProperty(property, state, toAnimatableUnknown(value)- >toCSSValue().get()); |
101 return; | 143 return; |
102 } | 144 } |
103 RenderStyle* style = state.style(); | 145 RenderStyle* style = state.style(); |
104 switch (property) { | 146 switch (property) { |
105 case CSSPropertyBackgroundColor: | 147 case CSSPropertyBackgroundColor: |
106 style->setBackgroundColor(toAnimatableColor(value)->color()); | 148 style->setBackgroundColor(toAnimatableColor(value)->color()); |
107 style->setVisitedLinkBackgroundColor(toAnimatableColor(value)->visitedLi nkColor()); | 149 style->setVisitedLinkBackgroundColor(toAnimatableColor(value)->visitedLi nkColor()); |
108 return; | 150 return; |
151 case CSSPropertyBackgroundImage: | |
152 setImageOnFillLayers(style->accessBackgroundLayers(), value); | |
153 return; | |
154 case CSSPropertyBackgroundPositionX: | |
155 setLengthOnFillLayers(&FillLayer::setXPosition, &FillLayer::clearXPositi on, value, state); | |
156 return; | |
157 case CSSPropertyBackgroundPositionY: | |
158 setLengthOnFillLayers(&FillLayer::setYPosition, &FillLayer::clearYPositi on, value, state); | |
159 return; | |
109 case CSSPropertyBaselineShift: | 160 case CSSPropertyBaselineShift: |
110 style->setBaselineShiftValue(toAnimatableSVGLength(value)->toSVGLength() ); | 161 style->setBaselineShiftValue(toAnimatableSVGLength(value)->toSVGLength() ); |
111 return; | 162 return; |
112 case CSSPropertyBorderBottomColor: | 163 case CSSPropertyBorderBottomColor: |
113 style->setBorderBottomColor(toAnimatableColor(value)->color()); | 164 style->setBorderBottomColor(toAnimatableColor(value)->color()); |
114 style->setVisitedLinkBorderBottomColor(toAnimatableColor(value)->visited LinkColor()); | 165 style->setVisitedLinkBorderBottomColor(toAnimatableColor(value)->visited LinkColor()); |
115 return; | 166 return; |
116 case CSSPropertyBorderBottomLeftRadius: | 167 case CSSPropertyBorderBottomLeftRadius: |
117 style->setBorderBottomLeftRadius(animatableValueToLengthSize(value, stat e, NonNegativeValues)); | 168 style->setBorderBottomLeftRadius(animatableValueToLengthSize(value, stat e, NonNegativeValues)); |
118 return; | 169 return; |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
366 case CSSPropertyZoom: | 417 case CSSPropertyZoom: |
367 style->setZoom(clampTo<float>(toAnimatableDouble(value)->toDouble())); | 418 style->setZoom(clampTo<float>(toAnimatableDouble(value)->toDouble())); |
368 return; | 419 return; |
369 default: | 420 default: |
370 RELEASE_ASSERT_WITH_MESSAGE(!CSSAnimations::isAnimatableProperty(propert y), "Web Animations not yet implemented: Unable to apply AnimatableValue to Rend erStyle: %s", getPropertyNameString(property).utf8().data()); | 421 RELEASE_ASSERT_WITH_MESSAGE(!CSSAnimations::isAnimatableProperty(propert y), "Web Animations not yet implemented: Unable to apply AnimatableValue to Rend erStyle: %s", getPropertyNameString(property).utf8().data()); |
371 ASSERT_NOT_REACHED(); | 422 ASSERT_NOT_REACHED(); |
372 } | 423 } |
373 } | 424 } |
374 | 425 |
375 } // namespace WebCore | 426 } // namespace WebCore |
OLD | NEW |