Chromium Code Reviews| Index: Source/core/css/resolver/StyleResolver.cpp |
| diff --git a/Source/core/css/resolver/StyleResolver.cpp b/Source/core/css/resolver/StyleResolver.cpp |
| index 30d450de65d64e0fb1d1e3ea882e79266044490c..616e1d72e569d12e59f0a6d647f4d17e7ba01db5 100644 |
| --- a/Source/core/css/resolver/StyleResolver.cpp |
| +++ b/Source/core/css/resolver/StyleResolver.cpp |
| @@ -36,6 +36,7 @@ |
| #include "core/animation/AnimatableValue.h" |
| #include "core/animation/Animation.h" |
| #include "core/animation/DocumentTimeline.h" |
| +#include "core/animation/css/CSSAnimations.h" |
| #include "core/css/CSSCalculationValue.h" |
| #include "core/css/CSSDefaultStyleSheets.h" |
| #include "core/css/CSSFontSelector.h" |
| @@ -623,6 +624,7 @@ PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS |
| PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(Element* e, const RenderStyle* elementStyle, const StyleKeyframe* keyframe, KeyframeValue& keyframeValue) |
| { |
| + ASSERT(!RuntimeEnabledFeatures::webAnimationsCSSEnabled()); |
| ASSERT(document()->frame()); |
| ASSERT(documentSettings()); |
| @@ -703,6 +705,39 @@ const StyleRuleKeyframes* StyleResolver::matchScopedKeyframesRule(Element* e, co |
| return 0; |
| } |
| +void StyleResolver::keyframeStylesForAnimation(Element* element, const StringImpl* name, KeyframeAnimationEffect::KeyframeVector& keyframes) |
|
dglazkov
2013/07/29 18:15:39
Not for this patch, but just curious: does this ha
dstockwell
2013/07/30 01:12:48
I think most of the logic can move out and I can w
|
| +{ |
| + ASSERT(RuntimeEnabledFeatures::webAnimationsCSSEnabled()); |
| + |
| + const StyleRuleKeyframes* keyframesRule = matchScopedKeyframesRule(element, name); |
| + if (!keyframesRule) |
| + return; |
| + |
| + // Construct and populate the style for each keyframe |
| + const Vector<RefPtr<StyleKeyframe> >& styleKeyframes = keyframesRule->keyframes(); |
| + for (unsigned i = 0; i < styleKeyframes.size(); ++i) { |
| + const StyleKeyframe* styleKeyframe = styleKeyframes[i].get(); |
| + |
| + Vector<float> offsets; |
| + styleKeyframe->getKeys(offsets); |
| + for (size_t j = 0; j < offsets.size(); ++j) { |
| + RefPtr<Keyframe> keyframe = Keyframe::create(); |
| + keyframe->setOffset(offsets[j]); |
| + const StylePropertySet* properties = styleKeyframe->properties(); |
| + // FIXME: AnimatableValues should be shared between the keyframes at different offsets. |
| + for (unsigned k = 0; k < properties->propertyCount(); k++) { |
| + CSSPropertyID property = properties->propertyAt(k).id(); |
| + // FIXME: CSSValue needs to be resolved. |
| + keyframe->setPropertyValue(property, AnimatableValue::create(properties->getPropertyCSSValue(property).get()).get()); |
| + } |
| + keyframes.append(keyframe); |
| + } |
| + } |
| + |
| + // FIXME: If the 0% keyframe is missing, create it (but only if there is at least one other keyframe) |
| + // FIXME: If the 100% keyframe is missing, create it (but only if there is at least one other keyframe) |
| +} |
| + |
| void StyleResolver::keyframeStylesForAnimation(Element* e, const RenderStyle* elementStyle, KeyframeList& list) |
| { |
| list.clear(); |
| @@ -1190,7 +1225,7 @@ void StyleResolver::invalidateMatchedPropertiesCache() |
| void StyleResolver::applyMatchedProperties(StyleResolverState& state, const MatchResult& matchResult) |
| { |
| - const Element* element = state.element(); |
| + Element* element = state.element(); |
|
dglazkov
2013/07/29 18:15:39
Whoops. This seems wrong. We _just_ did a pass at
dstockwell
2013/07/30 01:12:48
The only mutation here is the call to ensureActive
|
| ASSERT(element); |
| STYLE_STATS_ADD_MATCHED_PROPERTIES_SEARCH(); |
| @@ -1231,7 +1266,14 @@ void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc |
| applyMatchedProperties<AnimationProperties>(state, matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly); |
| applyMatchedProperties<AnimationProperties>(state, matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly); |
| applyMatchedProperties<AnimationProperties>(state, matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); |
| - // FIXME: animations should be triggered here |
| + |
| + if (RuntimeEnabledFeatures::webAnimationsCSSEnabled()) { |
| + const CSSAnimationDataList* animations = state.style()->animations(); |
| + EDisplay display = state.style()->display(); |
| + if ((display != NONE && animations && animations->size()) || element->hasActiveAnimations()) { |
| + element->ensureActiveAnimations()->cssAnimations()->update(element, display, this, animations); |
|
dglazkov
2013/07/29 18:15:39
Curious: why does a DOM element hold information a
dstockwell
2013/07/30 01:12:48
I was going to store it in animation-land in a Map
dglazkov
2013/07/30 22:07:27
I just spoke with shans@ about this, and I think w
|
| + } |
| + } |
| // Now we have all of the matched rules in the appropriate order. Walk the rules and apply |
| // high-priority properties first, i.e., those properties that other properties depend on. |