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

Unified Diff: Source/core/css/resolver/StyleResolver.cpp

Issue 24085002: Correctly apply per-keyframe timing functions (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/resolver/StyleResolver.h ('k') | Source/core/frame/animation/KeyframeAnimation.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/resolver/StyleResolver.cpp
diff --git a/Source/core/css/resolver/StyleResolver.cpp b/Source/core/css/resolver/StyleResolver.cpp
index 919cf9c2ef751be31dd55101c5c66592e3e451f5..54f8ca728d655869ba29cf67313594eda519d97b 100644
--- a/Source/core/css/resolver/StyleResolver.cpp
+++ b/Source/core/css/resolver/StyleResolver.cpp
@@ -782,7 +782,7 @@ PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS
return state.takeStyle();
}
-PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(Element* e, const RenderStyle& elementStyle, const StyleKeyframe* keyframe)
+PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(Element* e, const RenderStyle& elementStyle, const StyleKeyframe* keyframe, const AtomicString& animationName)
{
ASSERT(document().frame());
ASSERT(documentSettings());
@@ -802,6 +802,18 @@ PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(Element* e, const Render
state.setStyle(RenderStyle::clone(&elementStyle));
state.setLineHeightValue(0);
+ // Make sure that the CSSAnimationData for the animation to which this
+ // keyframe belongs is first in the list. This makes sure that if the
+ // animation-timing-function property is set for this keyframe, it will be
+ // applied to the correct CSSAnimationData object. Note that objects other
+ // than the first in the list are ignored when reading the timing function
+ // value. See KeyframeValue::timingFunction().
+ CSSAnimationDataList* animations = state.style()->accessAnimations();
+ ASSERT(animations && !animations->isEmpty());
+ while (animations->animation(0)->name() != animationName)
+ animations->remove(0);
+ ASSERT(!animations->isEmpty() && animations->animation(0)->name() == animationName);
+
state.fontBuilder().initForStyleResolve(state.document(), state.style(), state.useSVGZoomRules());
// We don't need to bother with !important. Since there is only ever one
@@ -852,13 +864,14 @@ void StyleResolver::keyframeStylesForAnimation(Element* e, const RenderStyle& el
return;
// Construct and populate the style for each keyframe
+ const AtomicString& name = list.animationName();
const Vector<RefPtr<StyleKeyframe> >& keyframes = keyframesRule->keyframes();
for (unsigned i = 0; i < keyframes.size(); ++i) {
// Apply the declaration to the style. This is a simplified version of the logic in styleForElement
const StyleKeyframe* keyframe = keyframes[i].get();
KeyframeValue keyframeValue(0, 0);
- keyframeValue.setStyle(styleForKeyframe(e, elementStyle, keyframe));
+ keyframeValue.setStyle(styleForKeyframe(e, elementStyle, keyframe, name));
keyframeValue.addProperties(keyframe->properties());
// Add this keyframe style to all the indicated key times
@@ -878,7 +891,7 @@ void StyleResolver::keyframeStylesForAnimation(Element* e, const RenderStyle& el
zeroPercentKeyframe->setKeyText("0%");
}
KeyframeValue keyframeValue(0, 0);
- keyframeValue.setStyle(styleForKeyframe(e, elementStyle, zeroPercentKeyframe));
+ keyframeValue.setStyle(styleForKeyframe(e, elementStyle, zeroPercentKeyframe, name));
keyframeValue.addProperties(zeroPercentKeyframe->properties());
list.insert(keyframeValue);
}
@@ -891,7 +904,7 @@ void StyleResolver::keyframeStylesForAnimation(Element* e, const RenderStyle& el
hundredPercentKeyframe->setKeyText("100%");
}
KeyframeValue keyframeValue(1, 0);
- keyframeValue.setStyle(styleForKeyframe(e, elementStyle, hundredPercentKeyframe));
+ keyframeValue.setStyle(styleForKeyframe(e, elementStyle, hundredPercentKeyframe, name));
keyframeValue.addProperties(hundredPercentKeyframe->properties());
list.insert(keyframeValue);
}
« no previous file with comments | « Source/core/css/resolver/StyleResolver.h ('k') | Source/core/frame/animation/KeyframeAnimation.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698