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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 } | 93 } |
93 | 94 |
94 SVGLength animatableValueToNonNegativeSVGLength(const AnimatableValue* value) | 95 SVGLength animatableValueToNonNegativeSVGLength(const AnimatableValue* value) |
95 { | 96 { |
96 SVGLength length = toAnimatableSVGLength(value)->toSVGLength(); | 97 SVGLength length = toAnimatableSVGLength(value)->toSVGLength(); |
97 if (length.valueInSpecifiedUnits() < 0) | 98 if (length.valueInSpecifiedUnits() < 0) |
98 length.setValueInSpecifiedUnits(0); | 99 length.setValueInSpecifiedUnits(0); |
99 return length; | 100 return length; |
100 } | 101 } |
101 | 102 |
103 template <CSSPropertyID property> | |
104 void setOnFillLayers(FillLayer* fillLayer, const AnimatableValue* value, StyleRe solverState& state) | |
105 { | |
106 const Vector<RefPtr<AnimatableValue> >& values = toAnimatableRepeatable(valu e)->values(); | |
107 ASSERT(!values.isEmpty()); | |
108 FillLayer* prev = 0; | |
109 for (size_t i = 0; i < values.size(); ++i) { | |
110 if (!fillLayer) { | |
111 switch (property) { | |
dstockwell
2013/10/09 23:15:07
do we need this switch? if it's not one of these p
alancutter (OOO until 2018)
2013/10/10 00:58:38
Removed switch.
| |
112 case CSSPropertyBackgroundImage: | |
113 case CSSPropertyBackgroundPositionX: | |
114 case CSSPropertyBackgroundPositionY: | |
115 fillLayer = new FillLayer(BackgroundFillLayer); | |
116 break; | |
117 default: | |
118 ASSERT_NOT_REACHED(); | |
119 } | |
120 prev->setNext(fillLayer); | |
121 } | |
122 switch (property) { | |
123 case CSSPropertyBackgroundImage: | |
124 fillLayer->setImage(toAnimatableImage(values[i].get())->toStyleImage ()); | |
125 break; | |
126 case CSSPropertyBackgroundPositionX: | |
127 fillLayer->setXPosition(animatableValueToLength(values[i].get(), sta te)); | |
128 break; | |
129 case CSSPropertyBackgroundPositionY: | |
130 fillLayer->setYPosition(animatableValueToLength(values[i].get(), sta te)); | |
131 break; | |
132 default: | |
133 ASSERT_NOT_REACHED(); | |
134 } | |
135 prev = fillLayer; | |
136 fillLayer = fillLayer->next(); | |
137 } | |
138 while (fillLayer) { | |
139 switch (property) { | |
140 case CSSPropertyBackgroundImage: | |
141 fillLayer->clearImage(); | |
142 break; | |
143 case CSSPropertyBackgroundPositionX: | |
144 fillLayer->clearXPosition(); | |
145 break; | |
146 case CSSPropertyBackgroundPositionY: | |
147 fillLayer->clearYPosition(); | |
148 break; | |
149 default: | |
150 ASSERT_NOT_REACHED(); | |
151 } | |
152 fillLayer = fillLayer->next(); | |
153 } | |
154 } | |
155 | |
102 } // namespace | 156 } // namespace |
103 | 157 |
104 // FIXME: Generate this function. | 158 // FIXME: Generate this function. |
105 void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, StyleResolverSt ate& state, const AnimatableValue* value) | 159 void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, StyleResolverSt ate& state, const AnimatableValue* value) |
106 { | 160 { |
107 if (value->isUnknown()) { | 161 if (value->isUnknown()) { |
108 StyleBuilder::applyProperty(property, state, toAnimatableUnknown(value)- >toCSSValue().get()); | 162 StyleBuilder::applyProperty(property, state, toAnimatableUnknown(value)- >toCSSValue().get()); |
109 return; | 163 return; |
110 } | 164 } |
111 RenderStyle* style = state.style(); | 165 RenderStyle* style = state.style(); |
112 switch (property) { | 166 switch (property) { |
113 case CSSPropertyBackgroundColor: | 167 case CSSPropertyBackgroundColor: |
114 style->setBackgroundColor(toAnimatableColor(value)->color()); | 168 style->setBackgroundColor(toAnimatableColor(value)->color()); |
115 style->setVisitedLinkBackgroundColor(toAnimatableColor(value)->visitedLi nkColor()); | 169 style->setVisitedLinkBackgroundColor(toAnimatableColor(value)->visitedLi nkColor()); |
116 return; | 170 return; |
171 case CSSPropertyBackgroundImage: | |
172 setOnFillLayers<CSSPropertyBackgroundImage>(style->accessBackgroundLayer s(), value, state); | |
173 return; | |
174 case CSSPropertyBackgroundPositionX: | |
175 setOnFillLayers<CSSPropertyBackgroundPositionX>(style->accessBackgroundL ayers(), value, state); | |
176 return; | |
177 case CSSPropertyBackgroundPositionY: | |
178 setOnFillLayers<CSSPropertyBackgroundPositionY>(style->accessBackgroundL ayers(), value, state); | |
179 return; | |
117 case CSSPropertyBaselineShift: | 180 case CSSPropertyBaselineShift: |
118 style->setBaselineShiftValue(toAnimatableSVGLength(value)->toSVGLength() ); | 181 style->setBaselineShiftValue(toAnimatableSVGLength(value)->toSVGLength() ); |
119 return; | 182 return; |
120 case CSSPropertyBorderBottomColor: | 183 case CSSPropertyBorderBottomColor: |
121 style->setBorderBottomColor(toAnimatableColor(value)->color()); | 184 style->setBorderBottomColor(toAnimatableColor(value)->color()); |
122 style->setVisitedLinkBorderBottomColor(toAnimatableColor(value)->visited LinkColor()); | 185 style->setVisitedLinkBorderBottomColor(toAnimatableColor(value)->visited LinkColor()); |
123 return; | 186 return; |
124 case CSSPropertyBorderBottomLeftRadius: | 187 case CSSPropertyBorderBottomLeftRadius: |
125 style->setBorderBottomLeftRadius(animatableValueToLengthSize(value, stat e, NonNegativeValues)); | 188 style->setBorderBottomLeftRadius(animatableValueToLengthSize(value, stat e, NonNegativeValues)); |
126 return; | 189 return; |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
377 case CSSPropertyZoom: | 440 case CSSPropertyZoom: |
378 style->setZoom(clampTo<float>(toAnimatableDouble(value)->toDouble())); | 441 style->setZoom(clampTo<float>(toAnimatableDouble(value)->toDouble())); |
379 return; | 442 return; |
380 default: | 443 default: |
381 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()); | 444 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()); |
382 ASSERT_NOT_REACHED(); | 445 ASSERT_NOT_REACHED(); |
383 } | 446 } |
384 } | 447 } |
385 | 448 |
386 } // namespace WebCore | 449 } // namespace WebCore |
OLD | NEW |