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

Side by Side Diff: Source/core/animation/KeyframeEffectModel.cpp

Issue 194733002: Web Animations: Use StringKeyframes for element.animate() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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
« no previous file with comments | « Source/core/animation/KeyframeEffectModel.h ('k') | Source/core/css/resolver/StyleResolver.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 13 matching lines...) Expand all
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/AnimatableDouble.h" 35 #include "core/animation/AnimatableDouble.h"
35 #include "core/animation/TimedItem.h" 36 #include "core/animation/TimedItem.h"
37 #include "core/animation/css/CSSAnimations.h"
38 #include "core/css/StylePropertySet.h"
39 #include "core/css/resolver/StyleResolver.h"
36 #include "wtf/text/StringHash.h" 40 #include "wtf/text/StringHash.h"
37 41
38 namespace WebCore { 42 namespace WebCore {
39 43
40 bool KeyframeEffectModelBase::Keyframe::compareOffsets(const RefPtrWillBeRawPtr< Keyframe>& a, const RefPtrWillBeRawPtr<Keyframe>& b) 44 bool KeyframeEffectModelBase::Keyframe::compareOffsets(const RefPtrWillBeRawPtr< Keyframe>& a, const RefPtrWillBeRawPtr<Keyframe>& b)
41 { 45 {
42 return a->offset() < b->offset(); 46 return a->offset() < b->offset();
43 } 47 }
44 48
45 PropertySet KeyframeEffectModelBase::properties() const 49 PropertySet KeyframeEffectModelBase::properties() const
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 if (m_keyframeGroups) 142 if (m_keyframeGroups)
139 return; 143 return;
140 144
141 m_keyframeGroups = adoptPtr(new KeyframeGroupMap); 145 m_keyframeGroups = adoptPtr(new KeyframeGroupMap);
142 const KeyframeVector keyframes = normalizedKeyframes(getFrames()); 146 const KeyframeVector keyframes = normalizedKeyframes(getFrames());
143 for (KeyframeVector::const_iterator keyframeIter = keyframes.begin(); keyfra meIter != keyframes.end(); ++keyframeIter) { 147 for (KeyframeVector::const_iterator keyframeIter = keyframes.begin(); keyfra meIter != keyframes.end(); ++keyframeIter) {
144 const Keyframe* keyframe = keyframeIter->get(); 148 const Keyframe* keyframe = keyframeIter->get();
145 PropertySet keyframeProperties = keyframe->properties(); 149 PropertySet keyframeProperties = keyframe->properties();
146 for (PropertySet::const_iterator propertyIter = keyframeProperties.begin (); propertyIter != keyframeProperties.end(); ++propertyIter) { 150 for (PropertySet::const_iterator propertyIter = keyframeProperties.begin (); propertyIter != keyframeProperties.end(); ++propertyIter) {
147 CSSPropertyID property = *propertyIter; 151 CSSPropertyID property = *propertyIter;
152 ASSERT_WITH_MESSAGE(!isExpandedShorthand(property), "Web Animations: Encountered shorthand CSS property (%d) in normalized keyframes.", property);
148 KeyframeGroupMap::iterator groupIter = m_keyframeGroups->find(proper ty); 153 KeyframeGroupMap::iterator groupIter = m_keyframeGroups->find(proper ty);
149 PropertySpecificKeyframeGroup* group; 154 PropertySpecificKeyframeGroup* group;
150 if (groupIter == m_keyframeGroups->end()) 155 if (groupIter == m_keyframeGroups->end())
151 group = m_keyframeGroups->add(property, adoptPtr(new PropertySpe cificKeyframeGroup)).storedValue->value.get(); 156 group = m_keyframeGroups->add(property, adoptPtr(new PropertySpe cificKeyframeGroup)).storedValue->value.get();
152 else 157 else
153 group = groupIter->value.get(); 158 group = groupIter->value.get();
154 159
155 group->appendKeyframe(keyframe->createPropertySpecificKeyframe(prope rty)); 160 group->appendKeyframe(keyframe->createPropertySpecificKeyframe(prope rty));
156 } 161 }
157 } 162 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 if (property == CSSPropertyOpacity) 253 if (property == CSSPropertyOpacity)
249 return OpacityStyleInterpolation::create(toAnimatableDouble(from->value( ))->toDouble(), toAnimatableDouble(to->value())->toDouble()); 254 return OpacityStyleInterpolation::create(toAnimatableDouble(from->value( ))->toDouble(), toAnimatableDouble(to->value())->toDouble());
250 return LegacyStyleInterpolation::create(from->value(), to->value(), property ); 255 return LegacyStyleInterpolation::create(from->value(), to->value(), property );
251 } 256 }
252 257
253 PassOwnPtr<KeyframeEffectModelBase::PropertySpecificKeyframe> AVKeyframeEffectMo del::neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const 258 PassOwnPtr<KeyframeEffectModelBase::PropertySpecificKeyframe> AVKeyframeEffectMo del::neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const
254 { 259 {
255 return adoptPtr(new PropertySpecificKeyframe(offset, easing, AnimatableValue ::neutralValue(), CompositeAdd)); 260 return adoptPtr(new PropertySpecificKeyframe(offset, easing, AnimatableValue ::neutralValue(), CompositeAdd));
256 } 261 }
257 262
263 void SKeyframe::setPropertyValue(CSSPropertyID property, const String& value)
264 {
265 ASSERT(property != CSSPropertyInvalid);
266 RefPtr<MutableStylePropertySet> propertySet = MutableStylePropertySet::creat e();
267 propertySet->setProperty(property, value);
268 for (size_t i = 0; i < propertySet->propertyCount(); ++i) {
269 CSSPropertyID id = propertySet->propertyAt(i).id();
270 if (CSSAnimations::isAnimatableProperty(id))
271 m_propertyValues.add(id, propertySet->getPropertyCSSValue(id));
272 }
273 }
274
275 static bool checkDocumentAndRenderer(Element& element)
276 {
277 if (!element.inActiveDocument())
278 return false;
279 element.document().updateStyleIfNeeded();
280 return element.renderer();
281 }
282
258 PassRefPtr<Interpolation> SKeyframeEffectModel::createInterpolation(CSSPropertyI D property, KeyframeEffectModelBase::PropertySpecificKeyframe *start, KeyframeEf fectModelBase::PropertySpecificKeyframe *end) const 283 PassRefPtr<Interpolation> SKeyframeEffectModel::createInterpolation(CSSPropertyI D property, KeyframeEffectModelBase::PropertySpecificKeyframe *start, KeyframeEf fectModelBase::PropertySpecificKeyframe *end) const
259 { 284 {
260 PropertySpecificKeyframe *from = toPropertySpecificKeyframe(start); 285 // FIXME: This check will not be neccessary once we can avoid snapshotting c omputed style values for keyframes.
261 PropertySpecificKeyframe *to = toPropertySpecificKeyframe(end); 286 RELEASE_ASSERT(checkDocumentAndRenderer(*m_element.get()));
262 ASSERT_UNUSED(from, from); 287
263 ASSERT_UNUSED(to, to); 288 CSSValue* fromCSSValue = toPropertySpecificKeyframe(start)->value();
264 // create Interpolation here 289 CSSValue* toCSSValue = toPropertySpecificKeyframe(end)->value();
265 return RefPtr<Interpolation>(); 290
291 RefPtr<AnimatableValue> from = StyleResolver::createAnimatableValueSnapshot( *m_element.get(), *m_renderStyle.get(), property, fromCSSValue);
292 RefPtr<AnimatableValue> to = StyleResolver::createAnimatableValueSnapshot(*m _element.get(), *m_renderStyle.get(), property, toCSSValue);
293
294 return LegacyStyleInterpolation::create(from, to, property);
alancutter (OOO until 2018) 2014/03/11 09:45:33 from.release(), to.release()
266 } 295 }
267 296
268 PassOwnPtr<KeyframeEffectModelBase::PropertySpecificKeyframe> SKeyframeEffectMod el::neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const 297 PassOwnPtr<KeyframeEffectModelBase::PropertySpecificKeyframe> SKeyframeEffectMod el::neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const
269 { 298 {
270 return adoptPtr(new PropertySpecificKeyframe(offset, easing, "invalid", Comp ositeAdd)); 299 return adoptPtr(new PropertySpecificKeyframe(offset, easing, nullptr, Compos iteAdd));
271 } 300 }
272 301
273 } // namespace 302 } // namespace
OLDNEW
« no previous file with comments | « Source/core/animation/KeyframeEffectModel.h ('k') | Source/core/css/resolver/StyleResolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698