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

Unified Diff: Source/core/animation/KeyframeEffectModel.cpp

Issue 851693007: Prepare for responsive CSS animations. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Clean up includes Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/animation/KeyframeEffectModel.cpp
diff --git a/Source/core/animation/KeyframeEffectModel.cpp b/Source/core/animation/KeyframeEffectModel.cpp
index fc1f34f527f23625c0e39c8a4883b41ff85e1b13..79182a525d1dab8e063b6d576695fe8e9311442e 100644
--- a/Source/core/animation/KeyframeEffectModel.cpp
+++ b/Source/core/animation/KeyframeEffectModel.cpp
@@ -33,6 +33,9 @@
#include "core/StylePropertyShorthand.h"
#include "core/animation/AnimationNode.h"
+#include "core/animation/css/CSSAnimatableValueFactory.h"
+#include "core/animation/css/CSSPropertyEquality.h"
+#include "core/css/resolver/StyleResolver.h"
#include "platform/animation/AnimationUtilities.h"
#include "platform/geometry/FloatBox.h"
#include "platform/transforms/TransformationMatrix.h"
@@ -60,6 +63,56 @@ void KeyframeEffectModelBase::sample(int iteration, double fraction, double iter
return m_interpolationEffect->getActiveInterpolations(fraction, iterationDuration, result);
}
+void KeyframeEffectModelBase::snapshotCompositableProperties(const Element* element, const RenderStyle& style)
+{
+ if (affects(CSSPropertyOpacity))
+ snapshotCompositableProperty(CSSPropertyOpacity, element, style);
+ if (affects(CSSPropertyTransform))
+ snapshotCompositableProperty(CSSPropertyTransform, element, style);
+ if (affects(CSSPropertyWebkitFilter))
+ snapshotCompositableProperty(CSSPropertyWebkitFilter, element, style);
+}
+
+void KeyframeEffectModelBase::snapshotCompositableProperty(CSSPropertyID property, const Element* element, const RenderStyle& style)
+{
+ ensureKeyframeGroups();
+ auto& keyframes = m_keyframeGroups->get(property)->m_keyframes;
+ for (size_t i = 0; i < keyframes.size(); i++) {
+ auto& keyframe = toStringPropertySpecificKeyframe(*keyframes[i]);
+ if (!keyframe.value())
+ keyframe.setAnimatableValue(CSSAnimatableValueFactory::create(property, style));
+ else if (!keyframe.getAnimatableValue())
Timothy Loh 2015/02/04 05:31:44 assert there's no animatable value? only do this i
shend 2015/02/04 22:51:34 Done.
+ keyframe.setAnimatableValue(StyleResolver::createAnimatableValueSnapshot(const_cast<Element&>(*element), property, *keyframe.value()));
+ }
+}
+
+void KeyframeEffectModelBase::updateNeutralKeyframeAnimatableValues(CSSPropertyID property, PassRefPtrWillBeRawPtr<AnimatableValue> value)
+{
+ if (!value)
+ return;
+
+ ensureKeyframeGroups();
+ auto& keyframes = m_keyframeGroups->get(property)->m_keyframes;
+ for (size_t i = 0; i < keyframes.size(); i++) {
+ auto& keyframe = toStringPropertySpecificKeyframe(*keyframes[i]);
+ if (!keyframe.value())
+ keyframe.setAnimatableValue(value);
+ }
+}
+
+void KeyframeEffectModelBase::setNeutralKeyframeEasings(RefPtrWillBeRawPtr<TimingFunction> easing)
+{
+ ensureKeyframeGroups();
+ for (const auto& entry : *m_keyframeGroups) {
+ auto& keyframes = entry.value->keyframes();
+ for (size_t i = 0; i < keyframes.size(); i++) {
+ auto& keyframe = toStringPropertySpecificKeyframe(*keyframes[i]);
+ if (!keyframe.value())
+ keyframe.setEasing(easing);
+ }
+ }
+}
+
KeyframeEffectModelBase::KeyframeVector KeyframeEffectModelBase::normalizedKeyframes(const KeyframeVector& keyframes)
{
double lastOffset = 0;
@@ -140,9 +193,9 @@ void KeyframeEffectModelBase::ensureInterpolationEffect(Element* element) const
for (const auto& entry : *m_keyframeGroups) {
const PropertySpecificKeyframeVector& keyframes = entry.value->keyframes();
- ASSERT(keyframes[0]->composite() == AnimationEffect::CompositeReplace);
+ ASSERT(keyframes[0]->composite() == AnimationEffect::CompositeReplace || keyframes[0]->composite() == AnimationEffect::CompositeAdd);
for (size_t i = 0; i < keyframes.size() - 1; i++) {
- ASSERT(keyframes[i + 1]->composite() == AnimationEffect::CompositeReplace);
+ ASSERT(keyframes[i + 1]->composite() == AnimationEffect::CompositeReplace || keyframes[i + 1]->composite() == AnimationEffect::CompositeAdd);
alancutter (OOO until 2018) 2015/02/05 04:59:02 Remove these asserts.
shend 2015/02/06 03:16:24 Done.
double applyFrom = i ? keyframes[i]->offset() : (-std::numeric_limits<double>::infinity());
double applyTo = i == keyframes.size() - 2 ? std::numeric_limits<double>::infinity() : keyframes[i + 1]->offset();
if (applyTo == 1)

Powered by Google App Engine
This is Rietveld 408576698