Chromium Code Reviews| Index: Source/core/animation/KeyframeEffectModel.cpp |
| diff --git a/Source/core/animation/KeyframeEffectModel.cpp b/Source/core/animation/KeyframeEffectModel.cpp |
| index fc1f34f527f23625c0e39c8a4883b41ff85e1b13..25402fff6d31775c65b56b8d4ec714864e8ec529 100644 |
| --- a/Source/core/animation/KeyframeEffectModel.cpp |
| +++ b/Source/core/animation/KeyframeEffectModel.cpp |
| @@ -33,6 +33,10 @@ |
| #include "core/StylePropertyShorthand.h" |
| #include "core/animation/AnimationNode.h" |
| +#include "core/animation/CompositorAnimations.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 +64,55 @@ 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) |
| +{ |
| + ensureKeyframeGroups(); |
| + for (CSSPropertyID property : CompositorAnimations::CompositableProperties) { |
| + if (affects(property)) { |
| + for (auto& keyframe : m_keyframeGroups->get(property)->m_keyframes) { |
| + auto& stringKeyframe = toStringPropertySpecificKeyframe(*keyframe); |
| + if (!stringKeyframe.value()) { |
| + stringKeyframe.setAnimatableValue(CSSAnimatableValueFactory::create(property, style)); |
| + } else { |
| + ASSERT(!stringKeyframe.getAnimatableValue()); |
| + stringKeyframe.setAnimatableValue(StyleResolver::createAnimatableValueSnapshot(const_cast<Element&>(*element), property, *stringKeyframe.value())); |
| + } |
| + } |
| + } |
| + } |
| +} |
| + |
| +void KeyframeEffectModelBase::updateNeutralKeyframeAnimatableValues(CSSPropertyID property, PassRefPtrWillBeRawPtr<AnimatableValue> value) |
| +{ |
| + ASSERT(CompositorAnimations::isCompositableProperty(property)); |
| + |
| + if (!value) |
| + return; |
| + |
| + ensureKeyframeGroups(); |
| + auto& keyframes = m_keyframeGroups->get(property)->m_keyframes; |
| + |
| + ASSERT(keyframes.size() >= 2); |
| + if (!toStringPropertySpecificKeyframe(*keyframes[0]).value()) |
|
dstockwell
2015/02/05 23:04:52
ASSERT that start or end is a neutral keyframe
FIX
shend
2015/02/06 03:16:25
Done.
|
| + toStringPropertySpecificKeyframe(*keyframes[0]).setAnimatableValue(value); |
| + if (!toStringPropertySpecificKeyframe(*keyframes[keyframes.size() - 1]).value()) |
| + toStringPropertySpecificKeyframe(*keyframes[keyframes.size() - 1]).setAnimatableValue(value); |
| +} |
| + |
| +void KeyframeEffectModelBase::setNeutralKeyframeEasings(RefPtrWillBeRawPtr<TimingFunction> easing) |
| +{ |
| + ensureKeyframeGroups(); |
| + for (const auto& entry : *m_keyframeGroups) { |
| + auto& keyframes = entry.value->keyframes(); |
| + |
| + ASSERT(keyframes.size() >= 2); |
| + if (!toStringPropertySpecificKeyframe(*keyframes[0]).value()) |
| + toStringPropertySpecificKeyframe(*keyframes[0]).setEasing(easing); |
| + if (!toStringPropertySpecificKeyframe(*keyframes[keyframes.size() - 1]).value()) |
| + toStringPropertySpecificKeyframe(*keyframes[keyframes.size() - 1]).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); |
| 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) |