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

Unified Diff: Source/core/animation/css/CSSAnimations.cpp

Issue 215883005: Web Animations: Introduce String based KeyframeEffectModel (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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/css/CSSAnimations.cpp
diff --git a/Source/core/animation/css/CSSAnimations.cpp b/Source/core/animation/css/CSSAnimations.cpp
index 7c1dbcc1d3f59b59f1f5f6b1d4322ea1240fe2c2..70d86f736bdeae2c8b53ad6dbf83bd04f23ca4a9 100644
--- a/Source/core/animation/css/CSSAnimations.cpp
+++ b/Source/core/animation/css/CSSAnimations.cpp
@@ -73,7 +73,7 @@ bool isLaterPhase(TimedItem::Phase target, TimedItem::Phase reference)
}
static void resolveKeyframes(StyleResolver* resolver, Element* element, const Element& parentElement, const RenderStyle& style, RenderStyle* parentStyle, const AtomicString& name, TimingFunction* defaultTimingFunction,
- WillBeHeapVector<KeyframeEffectModel::KeyframeVector>& resolvedKeyframes)
+ WillBeHeapVector<AnimatableValueKeyframeVector>& resolvedKeyframes)
{
// When the element is null, use its parent for scoping purposes.
const Element* elementForScoping = element ? element : &parentElement;
@@ -87,12 +87,12 @@ static void resolveKeyframes(StyleResolver* resolver, Element* element, const El
// Construct and populate the style for each keyframe
PropertySet specifiedProperties;
- KeyframeEffectModel::KeyframeVector keyframes;
+ AnimatableValueKeyframeVector keyframes;
for (size_t i = 0; i < styleKeyframes.size(); ++i) {
const StyleKeyframe* styleKeyframe = styleKeyframes[i].get();
// It's OK to pass a null element here.
RefPtr<RenderStyle> keyframeStyle = resolver->styleForKeyframe(element, style, parentStyle, styleKeyframe, name);
- RefPtrWillBeRawPtr<Keyframe> keyframe = Keyframe::create();
+ RefPtrWillBeRawPtr<AnimatableValueKeyframe> keyframe = AnimatableValueKeyframe::create();
const Vector<double>& offsets = styleKeyframe->keys();
ASSERT(!offsets.isEmpty());
keyframe->setOffset(offsets[0]);
@@ -109,7 +109,7 @@ static void resolveKeyframes(StyleResolver* resolver, Element* element, const El
keyframes.append(keyframe);
// The last keyframe specified at a given offset is used.
for (size_t j = 1; j < offsets.size(); ++j) {
- keyframes.append(keyframe->cloneWithOffset(offsets[j]));
+ keyframes.append(toAnimatableValueKeyframe(keyframe->cloneWithOffset(offsets[j]).get()));
}
}
ASSERT(!keyframes.isEmpty());
@@ -132,15 +132,15 @@ static void resolveKeyframes(StyleResolver* resolver, Element* element, const El
keyframes.shrink(targetIndex + 1);
// Add 0% and 100% keyframes if absent.
- RefPtrWillBeRawPtr<Keyframe> startKeyframe = keyframes[0];
+ RefPtrWillBeRawPtr<AnimatableValueKeyframe> startKeyframe = keyframes[0];
if (startKeyframe->offset()) {
- startKeyframe = Keyframe::create();
+ startKeyframe = AnimatableValueKeyframe::create();
startKeyframe->setOffset(0);
keyframes.prepend(startKeyframe);
}
- RefPtrWillBeRawPtr<Keyframe> endKeyframe = keyframes[keyframes.size() - 1];
+ RefPtrWillBeRawPtr<AnimatableValueKeyframe> endKeyframe = keyframes[keyframes.size() - 1];
if (endKeyframe->offset() != 1) {
- endKeyframe = Keyframe::create();
+ endKeyframe = AnimatableValueKeyframe::create();
endKeyframe->setOffset(1);
keyframes.append(endKeyframe);
}
@@ -197,14 +197,14 @@ static void resolveKeyframes(StyleResolver* resolver, Element* element, const El
ASSERT(count <= numKeyframes);
if (count == numKeyframes)
continue;
- KeyframeEffectModel::KeyframeVector splitOutKeyframes;
+ AnimatableValueKeyframeVector splitOutKeyframes;
for (size_t i = 0; i < numKeyframes; i++) {
- Keyframe* keyframe = keyframes[i].get();
+ AnimatableValueKeyframe* keyframe = keyframes[i].get();
if (!keyframe->properties().contains(property)) {
ASSERT(i && i != numKeyframes - 1);
continue;
}
- RefPtrWillBeRawPtr<Keyframe> clonedKeyframe = Keyframe::create();
+ RefPtrWillBeRawPtr<AnimatableValueKeyframe> clonedKeyframe = AnimatableValueKeyframe::create();
clonedKeyframe->setOffset(keyframe->offset());
clonedKeyframe->setEasing(keyframe->easing());
clonedKeyframe->setComposite(keyframe->composite());
@@ -381,7 +381,7 @@ void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate* update, Element
Timing timing;
bool isPaused;
RefPtr<TimingFunction> defaultTimingFunction = timingFromAnimationData(animationData, timing, isPaused);
- WillBeHeapVector<KeyframeEffectModel::KeyframeVector> resolvedKeyframes;
+ WillBeHeapVector<AnimatableValueKeyframeVector> resolvedKeyframes;
resolveKeyframes(resolver, element, parentElement, style, parentStyle, animationName, defaultTimingFunction.get(), resolvedKeyframes);
if (!resolvedKeyframes.isEmpty()) {
HashSet<RefPtr<InertAnimation> > animations;
@@ -389,7 +389,7 @@ void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate* update, Element
ASSERT(!resolvedKeyframes[j].isEmpty());
timing.timingFunction = LinearTimingFunction::preset();
// FIXME: crbug.com/268791 - Keyframes are already normalized, perhaps there should be a flag on KeyframeEffectModel to skip normalization.
- animations.add(InertAnimation::create(KeyframeEffectModel::create(resolvedKeyframes[j]), timing, isPaused));
+ animations.add(InertAnimation::create(AnimatableValueKeyframeEffectModel::create(resolvedKeyframes[j]), timing, isPaused));
}
ASSERT(!activeAnimations || !activeAnimations->isAnimationStyleChange());
update->startAnimation(animationName, animations);
@@ -493,16 +493,16 @@ void CSSAnimations::maybeApplyPendingUpdate(Element* element)
double oldStartTime = oldTransition.second;
double inheritedTime = isNull(oldStartTime) ? 0 : element->document().transitionTimeline().currentTime() - oldStartTime;
oldAnimation->updateInheritedTime(inheritedTime);
- KeyframeEffectModel* oldEffect = toKeyframeEffectModel(inertAnimation->effect());
- const KeyframeEffectModel::KeyframeVector& frames = oldEffect->getFrames();
- KeyframeEffectModel::KeyframeVector newFrames;
- newFrames.append(frames[0]->clone());
+ AnimatableValueKeyframeEffectModel* oldEffect = toAnimatableValueKeyframeEffectModel(inertAnimation->effect());
+ const KeyframeVector& frames = oldEffect->getFrames();
+ AnimatableValueKeyframeVector newFrames;
+ newFrames.append(toAnimatableValueKeyframe(frames[0]->clone().get()));
newFrames[0]->clearPropertyValue(id);
ASSERT(oldAnimation->activeInterpolations().size() == 1);
- const AnimatableValue* value = toLegacyStyleInterpolation(oldAnimation->activeInterpolations()[0].get())->currentValue();
- newFrames[0]->setPropertyValue(id, value);
- newFrames.append(frames[1]->clone());
- effect = KeyframeEffectModel::create(newFrames);
+ RefPtr<AnimatableValue> value = toLegacyStyleInterpolation(oldAnimation->activeInterpolations()[0].get())->currentValue();
+ newFrames[0]->setPropertyValue(id, value.release());
+ newFrames.append(toAnimatableValueKeyframe(frames[1]->clone().get()));
+ effect = AnimatableValueKeyframeEffectModel::create(newFrames);
}
RefPtr<Animation> transition = Animation::create(element, effect, inertAnimation->specifiedTiming(), Animation::TransitionPriority, eventDelegate.release());
RefPtr<AnimationPlayer> player = element->document().transitionTimeline().createAnimationPlayer(transition.get());
@@ -551,20 +551,20 @@ void CSSAnimations::calculateTransitionUpdateForProperty(CSSPropertyID id, const
// Note that the backwards part is required for delay to work.
timing.fillMode = Timing::FillModeBoth;
- KeyframeEffectModel::KeyframeVector keyframes;
+ AnimatableValueKeyframeVector keyframes;
- RefPtrWillBeRawPtr<Keyframe> startKeyframe = Keyframe::create();
+ RefPtrWillBeRawPtr<AnimatableValueKeyframe> startKeyframe = AnimatableValueKeyframe::create();
startKeyframe->setPropertyValue(id, from.get());
startKeyframe->setOffset(0);
startKeyframe->setEasing(timingFunction);
keyframes.append(startKeyframe);
- RefPtrWillBeRawPtr<Keyframe> endKeyframe = Keyframe::create();
+ RefPtrWillBeRawPtr<AnimatableValueKeyframe> endKeyframe = AnimatableValueKeyframe::create();
endKeyframe->setPropertyValue(id, to.get());
endKeyframe->setOffset(1);
keyframes.append(endKeyframe);
- RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes);
+ RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableValueKeyframeEffectModel::create(keyframes);
update->startTransition(id, from.get(), to.get(), InertAnimation::create(effect, timing, isPaused));
ASSERT(!element->activeAnimations() || !element->activeAnimations()->isAnimationStyleChange());

Powered by Google App Engine
This is Rietveld 408576698