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..0b36450299356b96f34a86ba86ca772882dffacf 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()); |
@@ -686,7 +688,7 @@ PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(Element* e, const Render |
return state.takeStyle(); |
} |
-const StyleRuleKeyframes* StyleResolver::matchScopedKeyframesRule(Element* e, const StringImpl* animationName) |
+const StyleRuleKeyframes* StyleResolver::matchScopedKeyframesRule(const Element* e, const StringImpl* animationName) |
{ |
if (m_styleTree.hasOnlyScopedResolverForDocument()) |
return m_styleTree.scopedStyleResolverForDocument()->keyframeStylesForAnimation(animationName); |
@@ -976,10 +978,18 @@ PassRefPtr<CSSRuleList> StyleResolver::pseudoStyleRulesForElement(Element* e, Ps |
// this is mostly boring stuff on how to apply a certain rule to the renderstyle... |
template <StyleResolver::StyleApplicationPass pass> |
-void StyleResolver::applyAnimatedProperties(StyleResolverState& state, const Element* target, const DocumentTimeline* timeline) |
+void StyleResolver::applyAnimatedProperties(StyleResolverState& state, const Element* target, const DocumentTimeline* timeline, const CSSAnimationUpdate* update) |
{ |
ASSERT(pass != VariableDefinitions); |
ASSERT(pass != AnimationProperties); |
+ if (update && update->styles()) { |
+ bool applyInheritedOnly = false; |
+ bool isImportant = false; |
+ StyleRule* rule = 0; |
+ applyProperties<pass>(state, update->styles(), rule, isImportant, applyInheritedOnly, PropertyWhitelistNone); |
+ isImportant = true; |
+ applyProperties<pass>(state, update->styles(), rule, isImportant, applyInheritedOnly, PropertyWhitelistNone); |
+ } |
AnimationStack* animationStack = timeline->animationStack(target); |
if (!animationStack) |
return; |
@@ -987,6 +997,8 @@ void StyleResolver::applyAnimatedProperties(StyleResolverState& state, const Ele |
for (size_t i = 0; i < animations.size(); ++i) { |
RefPtr<Animation> animation = animations.at(i); |
+ if (update && update->isFiltered(animation->player())) |
+ continue; |
const AnimationEffect::CompositableValueMap* compositableValues = animation->compositableValues(); |
for (AnimationEffect::CompositableValueMap::const_iterator iter = compositableValues->begin(); iter != compositableValues->end(); ++iter) { |
CSSPropertyID property = iter->key; |
@@ -1188,6 +1200,24 @@ void StyleResolver::invalidateMatchedPropertiesCache() |
m_matchedPropertiesCache.clear(); |
} |
+PassOwnPtr<CSSAnimationUpdate> StyleResolver::calculateCSSAnimationUpdate(StyleResolverState& state) |
dglazkov
2013/08/01 16:12:46
This guy sits awkwardly here. Ideally, it would ta
dstockwell
2013/08/02 00:11:01
Done.
|
+{ |
+ if (!RuntimeEnabledFeatures::webAnimationsCSSEnabled()) |
+ return nullptr; |
+ |
+ const Element* element = state.element(); |
+ ASSERT(element); |
+ |
+ if (CSSAnimations::needsUpdate(element, state.style())) { |
dglazkov
2013/08/01 16:12:46
early return?
dstockwell
2013/08/02 00:11:01
Done.
|
+ ActiveAnimations* activeAnimations = element->activeAnimations(); |
+ const CSSAnimationDataList* animations = state.style()->animations(); |
+ const CSSAnimations* cssAnimations = activeAnimations ? activeAnimations->cssAnimations() : nullptr; |
+ EDisplay display = state.style()->display(); |
+ return CSSAnimations::calculateUpdate(element, display, cssAnimations, animations, this); |
+ } |
+ return nullptr; |
+} |
+ |
void StyleResolver::applyMatchedProperties(StyleResolverState& state, const MatchResult& matchResult) |
{ |
const Element* element = state.element(); |
@@ -1231,7 +1261,8 @@ 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 |
+ |
+ OwnPtr<CSSAnimationUpdate> cssAnimationUpdate = calculateCSSAnimationUpdate(state); |
// 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. |
@@ -1240,8 +1271,8 @@ void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc |
state.setLineHeightValue(0); |
applyMatchedProperties<HighPriorityProperties>(state, matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly); |
// Animation contributions are processed here because CSS Animations are overridable by user !important rules. |
- if (RuntimeEnabledFeatures::webAnimationsEnabled()) |
- applyAnimatedProperties<HighPriorityProperties>(state, element, element->document()->timeline()); |
+ if (RuntimeEnabledFeatures::webAnimationsEnabled() && !applyInheritedOnly) |
+ applyAnimatedProperties<HighPriorityProperties>(state, element, element->document()->timeline(), cssAnimationUpdate.get()); |
applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly); |
applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly); |
applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); |
@@ -1270,8 +1301,8 @@ void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc |
// Now do the author and user normal priority properties and all the !important properties. |
applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, matchResult.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyInheritedOnly); |
- if (RuntimeEnabledFeatures::webAnimationsEnabled()) |
- applyAnimatedProperties<LowPriorityProperties>(state, element, element->document()->timeline()); |
+ if (RuntimeEnabledFeatures::webAnimationsEnabled() && !applyInheritedOnly) |
+ applyAnimatedProperties<LowPriorityProperties>(state, element, element->document()->timeline(), cssAnimationUpdate.get()); |
applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly); |
applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly); |
applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); |