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 13 matching lines...) Expand all Loading... |
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 "config.h" | 31 #include "config.h" |
32 #include "core/animation/KeyframeEffectModel.h" | 32 #include "core/animation/KeyframeEffectModel.h" |
33 | 33 |
| 34 #include "StylePropertyShorthand.h" |
34 #include "core/animation/TimedItem.h" | 35 #include "core/animation/TimedItem.h" |
35 #include "wtf/text/StringHash.h" | 36 #include "wtf/text/StringHash.h" |
36 | 37 |
37 namespace WebCore { | 38 namespace WebCore { |
38 | 39 |
39 bool Keyframe::compareOffsets(const RefPtrWillBeMember<Keyframe>& a, const RefPt
rWillBeMember<Keyframe>& b) | 40 bool Keyframe::compareOffsets(const RefPtrWillBeMember<Keyframe>& a, const RefPt
rWillBeMember<Keyframe>& b) |
40 { | 41 { |
41 return a->offset() < b->offset(); | 42 return a->offset() < b->offset(); |
42 } | 43 } |
43 | 44 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 if (m_keyframeGroups) | 138 if (m_keyframeGroups) |
138 return; | 139 return; |
139 | 140 |
140 m_keyframeGroups = adoptPtrWillBeNoop(new KeyframeGroupMap); | 141 m_keyframeGroups = adoptPtrWillBeNoop(new KeyframeGroupMap); |
141 const KeyframeVector keyframes = normalizedKeyframes(getFrames()); | 142 const KeyframeVector keyframes = normalizedKeyframes(getFrames()); |
142 for (KeyframeVector::const_iterator keyframeIter = keyframes.begin(); keyfra
meIter != keyframes.end(); ++keyframeIter) { | 143 for (KeyframeVector::const_iterator keyframeIter = keyframes.begin(); keyfra
meIter != keyframes.end(); ++keyframeIter) { |
143 const Keyframe* keyframe = keyframeIter->get(); | 144 const Keyframe* keyframe = keyframeIter->get(); |
144 PropertySet keyframeProperties = keyframe->properties(); | 145 PropertySet keyframeProperties = keyframe->properties(); |
145 for (PropertySet::const_iterator propertyIter = keyframeProperties.begin
(); propertyIter != keyframeProperties.end(); ++propertyIter) { | 146 for (PropertySet::const_iterator propertyIter = keyframeProperties.begin
(); propertyIter != keyframeProperties.end(); ++propertyIter) { |
146 CSSPropertyID property = *propertyIter; | 147 CSSPropertyID property = *propertyIter; |
| 148 ASSERT_WITH_MESSAGE(!isExpandedShorthand(property), "Web Animations:
Encountered shorthand CSS property (%d) in normalized keyframes.", property); |
147 KeyframeGroupMap::iterator groupIter = m_keyframeGroups->find(proper
ty); | 149 KeyframeGroupMap::iterator groupIter = m_keyframeGroups->find(proper
ty); |
148 PropertySpecificKeyframeGroup* group; | 150 PropertySpecificKeyframeGroup* group; |
149 if (groupIter == m_keyframeGroups->end()) | 151 if (groupIter == m_keyframeGroups->end()) |
150 group = m_keyframeGroups->add(property, adoptPtrWillBeNoop(new P
ropertySpecificKeyframeGroup)).storedValue->value.get(); | 152 group = m_keyframeGroups->add(property, adoptPtrWillBeNoop(new P
ropertySpecificKeyframeGroup)).storedValue->value.get(); |
151 else | 153 else |
152 group = groupIter->value.get(); | 154 group = groupIter->value.get(); |
153 | 155 |
154 ASSERT(keyframe->composite() == AnimationEffect::CompositeReplace); | 156 ASSERT(keyframe->composite() == AnimationEffect::CompositeReplace); |
155 group->appendKeyframe(keyframe->createPropertySpecificKeyframe(prope
rty)); | 157 group->appendKeyframe(keyframe->createPropertySpecificKeyframe(prope
rty)); |
156 } | 158 } |
157 } | 159 } |
158 | 160 |
159 // Add synthetic keyframes. | 161 // Add synthetic keyframes. |
160 for (KeyframeGroupMap::iterator iter = m_keyframeGroups->begin(); iter != m_
keyframeGroups->end(); ++iter) { | 162 for (KeyframeGroupMap::iterator iter = m_keyframeGroups->begin(); iter != m_
keyframeGroups->end(); ++iter) { |
161 iter->value->addSyntheticKeyframeIfRequired(this); | 163 iter->value->addSyntheticKeyframeIfRequired(this); |
162 iter->value->removeRedundantKeyframes(); | 164 iter->value->removeRedundantKeyframes(); |
163 } | 165 } |
164 } | 166 } |
165 | 167 |
166 void KeyframeEffectModelBase::ensureInterpolationEffect() const | 168 void KeyframeEffectModelBase::ensureInterpolationEffect(Element* element) const |
167 { | 169 { |
168 if (m_interpolationEffect) | 170 if (m_interpolationEffect) |
169 return; | 171 return; |
170 m_interpolationEffect = InterpolationEffect::create(); | 172 m_interpolationEffect = InterpolationEffect::create(); |
171 | 173 |
172 for (KeyframeGroupMap::const_iterator iter = m_keyframeGroups->begin(); iter
!= m_keyframeGroups->end(); ++iter) { | 174 for (KeyframeGroupMap::const_iterator iter = m_keyframeGroups->begin(); iter
!= m_keyframeGroups->end(); ++iter) { |
173 const PropertySpecificKeyframeVector& keyframes = iter->value->keyframes
(); | 175 const PropertySpecificKeyframeVector& keyframes = iter->value->keyframes
(); |
174 ASSERT(keyframes[0]->composite() == AnimationEffect::CompositeReplace); | 176 ASSERT(keyframes[0]->composite() == AnimationEffect::CompositeReplace); |
175 for (size_t i = 0; i < keyframes.size() - 1; i++) { | 177 for (size_t i = 0; i < keyframes.size() - 1; i++) { |
176 ASSERT(keyframes[i + 1]->composite() == AnimationEffect::CompositeRe
place); | 178 ASSERT(keyframes[i + 1]->composite() == AnimationEffect::CompositeRe
place); |
177 double applyFrom = i ? keyframes[i]->offset() : (-std::numeric_limit
s<double>::infinity()); | 179 double applyFrom = i ? keyframes[i]->offset() : (-std::numeric_limit
s<double>::infinity()); |
178 double applyTo = i == keyframes.size() - 2 ? std::numeric_limits<dou
ble>::infinity() : keyframes[i + 1]->offset(); | 180 double applyTo = i == keyframes.size() - 2 ? std::numeric_limits<dou
ble>::infinity() : keyframes[i + 1]->offset(); |
179 if (applyTo == 1) | 181 if (applyTo == 1) |
180 applyTo = std::numeric_limits<double>::infinity(); | 182 applyTo = std::numeric_limits<double>::infinity(); |
181 | 183 |
182 m_interpolationEffect->addInterpolation(keyframes[i]->createInterpol
ation(iter->key, keyframes[i + 1].get()), | 184 m_interpolationEffect->addInterpolation(keyframes[i]->createInterpol
ation(iter->key, keyframes[i + 1].get(), element), |
183 keyframes[i]->easing(), keyframes[i]->offset(), keyframes[i + 1]
->offset(), applyFrom, applyTo); | 185 keyframes[i]->easing(), keyframes[i]->offset(), keyframes[i + 1]
->offset(), applyFrom, applyTo); |
184 } | 186 } |
185 } | 187 } |
186 } | 188 } |
187 | 189 |
188 bool KeyframeEffectModelBase::isReplaceOnly() | 190 bool KeyframeEffectModelBase::isReplaceOnly() |
189 { | 191 { |
190 ensureKeyframeGroups(); | 192 ensureKeyframeGroups(); |
191 for (KeyframeGroupMap::iterator iter = m_keyframeGroups->begin(); iter != m_
keyframeGroups->end(); ++iter) { | 193 for (KeyframeGroupMap::iterator iter = m_keyframeGroups->begin(); iter != m_
keyframeGroups->end(); ++iter) { |
192 const PropertySpecificKeyframeVector& keyframeVector = iter->value->keyf
rames(); | 194 const PropertySpecificKeyframeVector& keyframeVector = iter->value->keyf
rames(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 } | 251 } |
250 | 252 |
251 void KeyframeEffectModelBase::PropertySpecificKeyframeGroup::trace(Visitor* visi
tor) | 253 void KeyframeEffectModelBase::PropertySpecificKeyframeGroup::trace(Visitor* visi
tor) |
252 { | 254 { |
253 #if ENABLE(OILPAN) | 255 #if ENABLE(OILPAN) |
254 visitor->trace(m_keyframes); | 256 visitor->trace(m_keyframes); |
255 #endif | 257 #endif |
256 } | 258 } |
257 | 259 |
258 } // namespace | 260 } // namespace |
OLD | NEW |