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

Side by Side Diff: Source/core/animation/css/CSSAnimations.cpp

Issue 24085002: Correctly apply per-keyframe timing functions (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years 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
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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 const Vector<RefPtr<StyleKeyframe> >& styleKeyframes = keyframesRule->keyfra mes(); 116 const Vector<RefPtr<StyleKeyframe> >& styleKeyframes = keyframesRule->keyfra mes();
117 if (styleKeyframes.isEmpty()) 117 if (styleKeyframes.isEmpty())
118 return; 118 return;
119 119
120 // Construct and populate the style for each keyframe 120 // Construct and populate the style for each keyframe
121 PropertySet specifiedProperties; 121 PropertySet specifiedProperties;
122 KeyframeAnimationEffect::KeyframeVector keyframes; 122 KeyframeAnimationEffect::KeyframeVector keyframes;
123 HashMap<double, RefPtr<TimingFunction> > perKeyframeTimingFunctions; 123 HashMap<double, RefPtr<TimingFunction> > perKeyframeTimingFunctions;
124 for (size_t i = 0; i < styleKeyframes.size(); ++i) { 124 for (size_t i = 0; i < styleKeyframes.size(); ++i) {
125 const StyleKeyframe* styleKeyframe = styleKeyframes[i].get(); 125 const StyleKeyframe* styleKeyframe = styleKeyframes[i].get();
126 RefPtr<RenderStyle> keyframeStyle = resolver->styleForKeyframe(element, style, styleKeyframe); 126 RefPtr<RenderStyle> keyframeStyle = resolver->styleForKeyframe(element, style, styleKeyframe, name);
127 RefPtr<Keyframe> keyframe = Keyframe::create(); 127 RefPtr<Keyframe> keyframe = Keyframe::create();
128 const Vector<double>& offsets = styleKeyframe->keys(); 128 const Vector<double>& offsets = styleKeyframe->keys();
129 ASSERT(!offsets.isEmpty()); 129 ASSERT(!offsets.isEmpty());
130 keyframe->setOffset(offsets[0]); 130 keyframe->setOffset(offsets[0]);
131 TimingFunction* timingFunction = defaultTimingFunction; 131 TimingFunction* timingFunction = defaultTimingFunction;
132 const StylePropertySet* properties = styleKeyframe->properties(); 132 const StylePropertySet* properties = styleKeyframe->properties();
133 for (unsigned j = 0; j < properties->propertyCount(); j++) { 133 for (unsigned j = 0; j < properties->propertyCount(); j++) {
134 CSSPropertyID property = properties->propertyAt(j).id(); 134 CSSPropertyID property = properties->propertyAt(j).id();
135 specifiedProperties.add(property); 135 specifiedProperties.add(property);
136 if (property == CSSPropertyWebkitAnimationTimingFunction || property == CSSPropertyAnimationTimingFunction) { 136 if (property == CSSPropertyWebkitAnimationTimingFunction || property == CSSPropertyAnimationTimingFunction)
137 // FIXME: This sometimes gets the wrong timing function. See crb ug.com/288540. 137 timingFunction = KeyframeValue::timingFunction(*keyframeStyle);
138 timingFunction = KeyframeValue::timingFunction(keyframeStyle.get (), name); 138 else if (CSSAnimations::isAnimatableProperty(property))
139 } else if (CSSAnimations::isAnimatableProperty(property)) {
140 keyframe->setPropertyValue(property, CSSAnimatableValueFactory:: create(property, *keyframeStyle).get()); 139 keyframe->setPropertyValue(property, CSSAnimatableValueFactory:: create(property, *keyframeStyle).get());
141 }
142 } 140 }
143 keyframes.append(keyframe); 141 keyframes.append(keyframe);
144 // The last keyframe specified at a given offset is used. 142 // The last keyframe specified at a given offset is used.
145 perKeyframeTimingFunctions.set(offsets[0], timingFunction); 143 perKeyframeTimingFunctions.set(offsets[0], timingFunction);
146 for (size_t j = 1; j < offsets.size(); ++j) { 144 for (size_t j = 1; j < offsets.size(); ++j) {
147 keyframes.append(keyframe->cloneWithOffset(offsets[j])); 145 keyframes.append(keyframe->cloneWithOffset(offsets[j]));
148 perKeyframeTimingFunctions.set(offsets[j], timingFunction); 146 perKeyframeTimingFunctions.set(offsets[j], timingFunction);
149 } 147 }
150 } 148 }
151 ASSERT(!keyframes.isEmpty()); 149 ASSERT(!keyframes.isEmpty());
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 CSSPropertyID id = convertToCSSPropertyID(i); 916 CSSPropertyID id = convertToCSSPropertyID(i);
919 if (isAnimatableProperty(id)) 917 if (isAnimatableProperty(id))
920 properties.append(id); 918 properties.append(id);
921 } 919 }
922 propertyShorthand = StylePropertyShorthand(CSSPropertyInvalid, propertie s.begin(), properties.size()); 920 propertyShorthand = StylePropertyShorthand(CSSPropertyInvalid, propertie s.begin(), properties.size());
923 } 921 }
924 return propertyShorthand; 922 return propertyShorthand;
925 } 923 }
926 924
927 } // namespace WebCore 925 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698