| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 timing.direction = Timing::PlaybackDirectionAlternateReverse; | 129 timing.direction = Timing::PlaybackDirectionAlternateReverse; |
| 130 break; | 130 break; |
| 131 default: | 131 default: |
| 132 ASSERT_NOT_REACHED(); | 132 ASSERT_NOT_REACHED(); |
| 133 } | 133 } |
| 134 } | 134 } |
| 135 isPaused = animationData->isPlayStateSet() && animationData->playState() ==
AnimPlayStatePaused; | 135 isPaused = animationData->isPlayStateSet() && animationData->playState() ==
AnimPlayStatePaused; |
| 136 return animationData->isTimingFunctionSet() ? animationData->timingFunction(
) : CSSAnimationData::initialAnimationTimingFunction(); | 136 return animationData->isTimingFunctionSet() ? animationData->timingFunction(
) : CSSAnimationData::initialAnimationTimingFunction(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void calculateCandidateTransitionForProperty(const CSSAnimationData* anim, CSSPr
opertyID id, const RenderStyle* oldStyle, const RenderStyle* newStyle, Candidate
TransitionMap& candidateMap) | 139 static void calculateCandidateTransitionForProperty(const CSSAnimationData* anim
, CSSPropertyID id, const RenderStyle& oldStyle, const RenderStyle& newStyle, Ca
ndidateTransitionMap& candidateMap) |
| 140 { | 140 { |
| 141 if (!CSSPropertyAnimation::propertiesEqual(id, oldStyle, newStyle)) { | 141 if (!CSSPropertyAnimation::propertiesEqual(id, &oldStyle, &newStyle)) { |
| 142 RefPtr<AnimatableValue> from = CSSAnimatableValueFactory::create(id, old
Style); | 142 RefPtr<AnimatableValue> from = CSSAnimatableValueFactory::create(id, old
Style); |
| 143 RefPtr<AnimatableValue> to = CSSAnimatableValueFactory::create(id, newSt
yle); | 143 RefPtr<AnimatableValue> to = CSSAnimatableValueFactory::create(id, newSt
yle); |
| 144 // If we have multiple transitions on the same property, we will use the | 144 // If we have multiple transitions on the same property, we will use the |
| 145 // last one since we iterate over them in order and this will override | 145 // last one since we iterate over them in order and this will override |
| 146 // a previously set CandidateTransition. | 146 // a previously set CandidateTransition. |
| 147 if (from->usesNonDefaultInterpolationWith(to.get())) | 147 if (from->usesNonDefaultInterpolationWith(to.get())) |
| 148 candidateMap.add(id, CandidateTransition(from.release(), to.release(
), anim)); | 148 candidateMap.add(id, CandidateTransition(from.release(), to.release(
), anim)); |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 | 151 |
| 152 void computeCandidateTransitions(const RenderStyle* oldStyle, const RenderStyle*
newStyle, CandidateTransitionMap& candidateMap, HashSet<CSSPropertyID>& listedP
roperties) | 152 static void computeCandidateTransitions(const RenderStyle& oldStyle, const Rende
rStyle& newStyle, CandidateTransitionMap& candidateMap, HashSet<CSSPropertyID>&
listedProperties) |
| 153 { | 153 { |
| 154 if (!newStyle->transitions()) | 154 if (!newStyle.transitions()) |
| 155 return; | 155 return; |
| 156 | 156 |
| 157 for (size_t i = 0; i < newStyle->transitions()->size(); ++i) { | 157 for (size_t i = 0; i < newStyle.transitions()->size(); ++i) { |
| 158 const CSSAnimationData* anim = newStyle->transitions()->animation(i); | 158 const CSSAnimationData* anim = newStyle.transitions()->animation(i); |
| 159 CSSAnimationData::AnimationMode mode = anim->animationMode(); | 159 CSSAnimationData::AnimationMode mode = anim->animationMode(); |
| 160 if (anim->duration() + anim->delay() <= 0 || mode == CSSAnimationData::A
nimateNone) | 160 if (anim->duration() + anim->delay() <= 0 || mode == CSSAnimationData::A
nimateNone) |
| 161 continue; | 161 continue; |
| 162 | 162 |
| 163 bool animateAll = mode == CSSAnimationData::AnimateAll; | 163 bool animateAll = mode == CSSAnimationData::AnimateAll; |
| 164 ASSERT(animateAll || mode == CSSAnimationData::AnimateSingleProperty); | 164 ASSERT(animateAll || mode == CSSAnimationData::AnimateSingleProperty); |
| 165 const StylePropertyShorthand& propertyList = animateAll ? CSSAnimations:
:animatableProperties() : shorthandForProperty(anim->property()); | 165 const StylePropertyShorthand& propertyList = animateAll ? CSSAnimations:
:animatableProperties() : shorthandForProperty(anim->property()); |
| 166 if (!propertyList.length()) { | 166 if (!propertyList.length()) { |
| 167 if (!CSSAnimations::isAnimatableProperty(anim->property())) | 167 if (!CSSAnimations::isAnimatableProperty(anim->property())) |
| 168 continue; | 168 continue; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 195 } | 195 } |
| 196 | 196 |
| 197 CSSAnimationUpdateScope::~CSSAnimationUpdateScope() | 197 CSSAnimationUpdateScope::~CSSAnimationUpdateScope() |
| 198 { | 198 { |
| 199 if (!m_target) | 199 if (!m_target) |
| 200 return; | 200 return; |
| 201 if (ActiveAnimations* activeAnimations = m_target->activeAnimations()) | 201 if (ActiveAnimations* activeAnimations = m_target->activeAnimations()) |
| 202 activeAnimations->cssAnimations().maybeApplyPendingUpdate(m_target); | 202 activeAnimations->cssAnimations().maybeApplyPendingUpdate(m_target); |
| 203 } | 203 } |
| 204 | 204 |
| 205 PassOwnPtr<CSSAnimationUpdate> CSSAnimations::calculateUpdate(Element* element,
const RenderStyle* style, StyleResolver* resolver) | 205 PassOwnPtr<CSSAnimationUpdate> CSSAnimations::calculateUpdate(Element* element,
const RenderStyle& style, StyleResolver* resolver) |
| 206 { | 206 { |
| 207 ASSERT(RuntimeEnabledFeatures::webAnimationsCSSEnabled()); | 207 ASSERT(RuntimeEnabledFeatures::webAnimationsCSSEnabled()); |
| 208 OwnPtr<CSSAnimationUpdate> update = adoptPtr(new CSSAnimationUpdate()); | 208 OwnPtr<CSSAnimationUpdate> update = adoptPtr(new CSSAnimationUpdate()); |
| 209 calculateAnimationUpdate(update.get(), element, style, resolver); | 209 calculateAnimationUpdate(update.get(), element, style, resolver); |
| 210 calculateAnimationCompositableValues(update.get(), element); | 210 calculateAnimationCompositableValues(update.get(), element); |
| 211 calculateTransitionUpdate(update.get(), element, style); | 211 calculateTransitionUpdate(update.get(), element, style); |
| 212 calculateTransitionCompositableValues(update.get(), element); | 212 calculateTransitionCompositableValues(update.get(), element); |
| 213 return update->isEmpty() ? nullptr : update.release(); | 213 return update->isEmpty() ? nullptr : update.release(); |
| 214 } | 214 } |
| 215 | 215 |
| 216 void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate* update, Element
* element, const RenderStyle* style, StyleResolver* resolver) | 216 void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate* update, Element
* element, const RenderStyle& style, StyleResolver* resolver) |
| 217 { | 217 { |
| 218 const CSSAnimationDataList* animationDataList = style->animations(); | 218 const CSSAnimationDataList* animationDataList = style.animations(); |
| 219 const CSSAnimations* cssAnimations = element->activeAnimations() ? &element-
>activeAnimations()->cssAnimations() : 0; | 219 const CSSAnimations* cssAnimations = element->activeAnimations() ? &element-
>activeAnimations()->cssAnimations() : 0; |
| 220 | 220 |
| 221 HashSet<AtomicString> inactive; | 221 HashSet<AtomicString> inactive; |
| 222 if (cssAnimations) | 222 if (cssAnimations) |
| 223 for (AnimationMap::const_iterator iter = cssAnimations->m_animations.beg
in(); iter != cssAnimations->m_animations.end(); ++iter) | 223 for (AnimationMap::const_iterator iter = cssAnimations->m_animations.beg
in(); iter != cssAnimations->m_animations.end(); ++iter) |
| 224 inactive.add(iter->key); | 224 inactive.add(iter->key); |
| 225 | 225 |
| 226 if (style->display() != NONE) { | 226 if (style.display() != NONE) { |
| 227 for (size_t i = 0; animationDataList && i < animationDataList->size(); +
+i) { | 227 for (size_t i = 0; animationDataList && i < animationDataList->size(); +
+i) { |
| 228 const CSSAnimationData* animationData = animationDataList->animation
(i); | 228 const CSSAnimationData* animationData = animationDataList->animation
(i); |
| 229 if (animationData->isNoneAnimation()) | 229 if (animationData->isNoneAnimation()) |
| 230 continue; | 230 continue; |
| 231 ASSERT(animationData->isValidAnimation()); | 231 ASSERT(animationData->isValidAnimation()); |
| 232 AtomicString animationName(animationData->name()); | 232 AtomicString animationName(animationData->name()); |
| 233 | 233 |
| 234 // Keyframes and animation properties are snapshotted when the | 234 // Keyframes and animation properties are snapshotted when the |
| 235 // animation starts, so we don't need to track changes to these, | 235 // animation starts, so we don't need to track changes to these, |
| 236 // with the exception of play-state. | 236 // with the exception of play-state. |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 bool isPaused; | 372 bool isPaused; |
| 373 RefPtr<TimingFunction> timingFunction = timingFromAnimationData(newTransitio
n.anim, timing, isPaused); | 373 RefPtr<TimingFunction> timingFunction = timingFromAnimationData(newTransitio
n.anim, timing, isPaused); |
| 374 ASSERT(!isPaused); | 374 ASSERT(!isPaused); |
| 375 timing.timingFunction = timingFunction; | 375 timing.timingFunction = timingFunction; |
| 376 // Note that the backwards part is required for delay to work. | 376 // Note that the backwards part is required for delay to work. |
| 377 timing.fillMode = Timing::FillModeBoth; | 377 timing.fillMode = Timing::FillModeBoth; |
| 378 | 378 |
| 379 update->startTransition(id, newTransition.from.get(), newTransition.to.get()
, InertAnimation::create(effect, timing, isPaused)); | 379 update->startTransition(id, newTransition.from.get(), newTransition.to.get()
, InertAnimation::create(effect, timing, isPaused)); |
| 380 } | 380 } |
| 381 | 381 |
| 382 void CSSAnimations::calculateTransitionUpdate(CSSAnimationUpdate* update, const
Element* element, const RenderStyle* style) | 382 void CSSAnimations::calculateTransitionUpdate(CSSAnimationUpdate* update, const
Element* element, const RenderStyle& style) |
| 383 { | 383 { |
| 384 ActiveAnimations* activeAnimations = element->activeAnimations(); | 384 ActiveAnimations* activeAnimations = element->activeAnimations(); |
| 385 const TransitionMap* transitions = activeAnimations ? &activeAnimations->css
Animations().m_transitions : 0; | 385 const TransitionMap* transitions = activeAnimations ? &activeAnimations->css
Animations().m_transitions : 0; |
| 386 | 386 |
| 387 HashSet<CSSPropertyID> listedProperties; | 387 HashSet<CSSPropertyID> listedProperties; |
| 388 if (style->display() != NONE && element->renderer() && element->renderer()->
style()) { | 388 if (style.display() != NONE && element->renderer() && element->renderer()->s
tyle()) { |
| 389 CandidateTransitionMap candidateMap; | 389 CandidateTransitionMap candidateMap; |
| 390 computeCandidateTransitions(element->renderer()->style(), style, candida
teMap, listedProperties); | 390 computeCandidateTransitions(*element->renderer()->style(), style, candid
ateMap, listedProperties); |
| 391 for (CandidateTransitionMap::const_iterator iter = candidateMap.begin();
iter != candidateMap.end(); ++iter) { | 391 for (CandidateTransitionMap::const_iterator iter = candidateMap.begin();
iter != candidateMap.end(); ++iter) { |
| 392 // FIXME: We should transition if an !important property changes eve
n when an animation is running, | 392 // FIXME: We should transition if an !important property changes eve
n when an animation is running, |
| 393 // but this is a bit hard to do with the current applyMatchedPropert
ies system. | 393 // but this is a bit hard to do with the current applyMatchedPropert
ies system. |
| 394 if (!update->compositableValuesForAnimations().contains(iter->key) | 394 if (!update->compositableValuesForAnimations().contains(iter->key) |
| 395 && (!activeAnimations || !activeAnimations->cssAnimations().m_pr
eviousCompositableValuesForAnimations.contains(iter->key))) | 395 && (!activeAnimations || !activeAnimations->cssAnimations().m_pr
eviousCompositableValuesForAnimations.contains(iter->key))) |
| 396 calculateTransitionUpdateForProperty(update, iter->key, iter->va
lue, transitions); | 396 calculateTransitionUpdateForProperty(update, iter->key, iter->va
lue, transitions); |
| 397 } | 397 } |
| 398 } | 398 } |
| 399 | 399 |
| 400 if (transitions) { | 400 if (transitions) { |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 CSSPropertyID id = convertToCSSPropertyID(i); | 665 CSSPropertyID id = convertToCSSPropertyID(i); |
| 666 if (isAnimatableProperty(id)) | 666 if (isAnimatableProperty(id)) |
| 667 properties.append(id); | 667 properties.append(id); |
| 668 } | 668 } |
| 669 propertyShorthand = StylePropertyShorthand(CSSPropertyInvalid, propertie
s.begin(), properties.size()); | 669 propertyShorthand = StylePropertyShorthand(CSSPropertyInvalid, propertie
s.begin(), properties.size()); |
| 670 } | 670 } |
| 671 return propertyShorthand; | 671 return propertyShorthand; |
| 672 } | 672 } |
| 673 | 673 |
| 674 } // namespace WebCore | 674 } // namespace WebCore |
| OLD | NEW |