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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 case CSSPropertyWebkitPerspectiveOrigin: | 74 case CSSPropertyWebkitPerspectiveOrigin: |
75 return CSSPropertyPerspectiveOrigin; | 75 return CSSPropertyPerspectiveOrigin; |
76 case CSSPropertyWebkitTransformOrigin: | 76 case CSSPropertyWebkitTransformOrigin: |
77 return CSSPropertyTransformOrigin; | 77 return CSSPropertyTransformOrigin; |
78 default: | 78 default: |
79 break; | 79 break; |
80 } | 80 } |
81 return property; | 81 return property; |
82 } | 82 } |
83 | 83 |
84 static PassRefPtrWillBeRawPtr<StringKeyframeEffectModel> createKeyframeEffect(St
yleResolver* resolver, const Element* animatingElement, Element& element, const
LayoutStyle* style, const LayoutStyle* parentStyle, const AtomicString& name, Ti
mingFunction* defaultTimingFunction) | 84 static PassRefPtrWillBeRawPtr<StringKeyframeEffectModel> createKeyframeEffect(St
yleResolver* resolver, const Element* animatingElement, Element& element, const
ComputedStyle* style, const ComputedStyle* parentStyle, const AtomicString& name
, TimingFunction* defaultTimingFunction) |
85 { | 85 { |
86 // When the animating element is null, use its parent for scoping purposes. | 86 // When the animating element is null, use its parent for scoping purposes. |
87 const Element* elementForScoping = animatingElement ? animatingElement : &el
ement; | 87 const Element* elementForScoping = animatingElement ? animatingElement : &el
ement; |
88 const StyleRuleKeyframes* keyframesRule = resolver->findKeyframesRule(elemen
tForScoping, name); | 88 const StyleRuleKeyframes* keyframesRule = resolver->findKeyframesRule(elemen
tForScoping, name); |
89 ASSERT(keyframesRule); | 89 ASSERT(keyframesRule); |
90 | 90 |
91 StringKeyframeVector keyframes; | 91 StringKeyframeVector keyframes; |
92 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleKeyframe>>& styleKeyframe
s = keyframesRule->keyframes(); | 92 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleKeyframe>>& styleKeyframe
s = keyframesRule->keyframes(); |
93 | 93 |
94 // Construct and populate the style for each keyframe | 94 // Construct and populate the style for each keyframe |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 | 209 |
210 bool CSSAnimations::isTransitionAnimationForInspector(const AnimationPlayer& pla
yer) const | 210 bool CSSAnimations::isTransitionAnimationForInspector(const AnimationPlayer& pla
yer) const |
211 { | 211 { |
212 for (const auto& it : m_transitions) { | 212 for (const auto& it : m_transitions) { |
213 if (it.value.player->sequenceNumber() == player.sequenceNumber()) | 213 if (it.value.player->sequenceNumber() == player.sequenceNumber()) |
214 return true; | 214 return true; |
215 } | 215 } |
216 return false; | 216 return false; |
217 } | 217 } |
218 | 218 |
219 PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> CSSAnimations::calculateUpdate(const
Element* animatingElement, Element& element, const LayoutStyle& style, LayoutSty
le* parentStyle, StyleResolver* resolver) | 219 PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> CSSAnimations::calculateUpdate(const
Element* animatingElement, Element& element, const ComputedStyle& style, Compute
dStyle* parentStyle, StyleResolver* resolver) |
220 { | 220 { |
221 OwnPtrWillBeRawPtr<CSSAnimationUpdate> update = adoptPtrWillBeNoop(new CSSAn
imationUpdate()); | 221 OwnPtrWillBeRawPtr<CSSAnimationUpdate> update = adoptPtrWillBeNoop(new CSSAn
imationUpdate()); |
222 calculateAnimationUpdate(update.get(), animatingElement, element, style, par
entStyle, resolver); | 222 calculateAnimationUpdate(update.get(), animatingElement, element, style, par
entStyle, resolver); |
223 calculateAnimationActiveInterpolations(update.get(), animatingElement, eleme
nt.document().timeline().currentTimeInternal()); | 223 calculateAnimationActiveInterpolations(update.get(), animatingElement, eleme
nt.document().timeline().currentTimeInternal()); |
224 calculateTransitionUpdate(update.get(), animatingElement, style); | 224 calculateTransitionUpdate(update.get(), animatingElement, style); |
225 calculateTransitionActiveInterpolations(update.get(), animatingElement, elem
ent.document().timeline().currentTimeInternal()); | 225 calculateTransitionActiveInterpolations(update.get(), animatingElement, elem
ent.document().timeline().currentTimeInternal()); |
226 return update->isEmpty() ? nullptr : update.release(); | 226 return update->isEmpty() ? nullptr : update.release(); |
227 } | 227 } |
228 | 228 |
229 void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate* update, const E
lement* animatingElement, Element& element, const LayoutStyle& style, LayoutStyl
e* parentStyle, StyleResolver* resolver) | 229 void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate* update, const E
lement* animatingElement, Element& element, const ComputedStyle& style, Computed
Style* parentStyle, StyleResolver* resolver) |
230 { | 230 { |
231 const ElementAnimations* elementAnimations = animatingElement ? animatingEle
ment->elementAnimations() : nullptr; | 231 const ElementAnimations* elementAnimations = animatingElement ? animatingEle
ment->elementAnimations() : nullptr; |
232 | 232 |
233 bool isAnimationStyleChange = elementAnimations && elementAnimations->isAnim
ationStyleChange(); | 233 bool isAnimationStyleChange = elementAnimations && elementAnimations->isAnim
ationStyleChange(); |
234 | 234 |
235 #if !ENABLE(ASSERT) | 235 #if !ENABLE(ASSERT) |
236 // If we're in an animation style change, no animations can have started, be
en cancelled or changed play state. | 236 // If we're in an animation style change, no animations can have started, be
en cancelled or changed play state. |
237 // When ASSERT is enabled, we verify this optimization. | 237 // When ASSERT is enabled, we verify this optimization. |
238 if (isAnimationStyleChange) | 238 if (isAnimationStyleChange) |
239 return; | 239 return; |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 transition->setName(inertAnimation->name()); | 459 transition->setName(inertAnimation->name()); |
460 RefPtrWillBeRawPtr<AnimationPlayer> player = element->document().timelin
e().play(transition.get()); | 460 RefPtrWillBeRawPtr<AnimationPlayer> player = element->document().timelin
e().play(transition.get()); |
461 player->update(TimingUpdateOnDemand); | 461 player->update(TimingUpdateOnDemand); |
462 runningTransition.player = player; | 462 runningTransition.player = player; |
463 m_transitions.set(id, runningTransition); | 463 m_transitions.set(id, runningTransition); |
464 ASSERT(id != CSSPropertyInvalid); | 464 ASSERT(id != CSSPropertyInvalid); |
465 blink::Platform::current()->histogramSparse("WebCore.Animation.CSSProper
ties", UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(id)); | 465 blink::Platform::current()->histogramSparse("WebCore.Animation.CSSProper
ties", UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(id)); |
466 } | 466 } |
467 } | 467 } |
468 | 468 |
469 void CSSAnimations::calculateTransitionUpdateForProperty(CSSPropertyID id, CSSPr
opertyID eventId, const CSSTransitionData& transitionData, size_t transitionInde
x, const LayoutStyle& oldStyle, const LayoutStyle& style, const TransitionMap* a
ctiveTransitions, CSSAnimationUpdate* update, const Element* element) | 469 void CSSAnimations::calculateTransitionUpdateForProperty(CSSPropertyID id, CSSPr
opertyID eventId, const CSSTransitionData& transitionData, size_t transitionInde
x, const ComputedStyle& oldStyle, const ComputedStyle& style, const TransitionMa
p* activeTransitions, CSSAnimationUpdate* update, const Element* element) |
470 { | 470 { |
471 RefPtrWillBeRawPtr<AnimatableValue> to = nullptr; | 471 RefPtrWillBeRawPtr<AnimatableValue> to = nullptr; |
472 if (activeTransitions) { | 472 if (activeTransitions) { |
473 TransitionMap::const_iterator activeTransitionIter = activeTransitions->
find(id); | 473 TransitionMap::const_iterator activeTransitionIter = activeTransitions->
find(id); |
474 if (activeTransitionIter != activeTransitions->end()) { | 474 if (activeTransitionIter != activeTransitions->end()) { |
475 to = CSSAnimatableValueFactory::create(id, style); | 475 to = CSSAnimatableValueFactory::create(id, style); |
476 const AnimatableValue* activeTo = activeTransitionIter->value.to; | 476 const AnimatableValue* activeTo = activeTransitionIter->value.to; |
477 if (to->equals(activeTo)) | 477 if (to->equals(activeTo)) |
478 return; | 478 return; |
479 update->cancelTransition(id); | 479 update->cancelTransition(id); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 RefPtrWillBeRawPtr<AnimatableValueKeyframe> endKeyframe = AnimatableValueKey
frame::create(); | 520 RefPtrWillBeRawPtr<AnimatableValueKeyframe> endKeyframe = AnimatableValueKey
frame::create(); |
521 endKeyframe->setPropertyValue(id, to.get()); | 521 endKeyframe->setPropertyValue(id, to.get()); |
522 endKeyframe->setOffset(1); | 522 endKeyframe->setOffset(1); |
523 keyframes.append(endKeyframe); | 523 keyframes.append(endKeyframe); |
524 | 524 |
525 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableVa
lueKeyframeEffectModel::create(keyframes); | 525 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableVa
lueKeyframeEffectModel::create(keyframes); |
526 update->startTransition(id, eventId, from.get(), to.get(), InertAnimation::c
reate(effect, timing, false, 0)); | 526 update->startTransition(id, eventId, from.get(), to.get(), InertAnimation::c
reate(effect, timing, false, 0)); |
527 ASSERT(!element->elementAnimations() || !element->elementAnimations()->isAni
mationStyleChange()); | 527 ASSERT(!element->elementAnimations() || !element->elementAnimations()->isAni
mationStyleChange()); |
528 } | 528 } |
529 | 529 |
530 void CSSAnimations::calculateTransitionUpdate(CSSAnimationUpdate* update, const
Element* animatingElement, const LayoutStyle& style) | 530 void CSSAnimations::calculateTransitionUpdate(CSSAnimationUpdate* update, const
Element* animatingElement, const ComputedStyle& style) |
531 { | 531 { |
532 if (!animatingElement) | 532 if (!animatingElement) |
533 return; | 533 return; |
534 | 534 |
535 ElementAnimations* elementAnimations = animatingElement->elementAnimations()
; | 535 ElementAnimations* elementAnimations = animatingElement->elementAnimations()
; |
536 const TransitionMap* activeTransitions = elementAnimations ? &elementAnimati
ons->cssAnimations().m_transitions : nullptr; | 536 const TransitionMap* activeTransitions = elementAnimations ? &elementAnimati
ons->cssAnimations().m_transitions : nullptr; |
537 const CSSTransitionData* transitionData = style.transitions(); | 537 const CSSTransitionData* transitionData = style.transitions(); |
538 | 538 |
539 #if ENABLE(ASSERT) | 539 #if ENABLE(ASSERT) |
540 // In debug builds we verify that it would have been safe to avoid populatin
g and testing listedProperties if the style recalc is due to animation. | 540 // In debug builds we verify that it would have been safe to avoid populatin
g and testing listedProperties if the style recalc is due to animation. |
541 const bool animationStyleRecalc = false; | 541 const bool animationStyleRecalc = false; |
542 #else | 542 #else |
543 // In release builds we avoid the cost of checking for new and interrupted t
ransitions if the style recalc is due to animation. | 543 // In release builds we avoid the cost of checking for new and interrupted t
ransitions if the style recalc is due to animation. |
544 const bool animationStyleRecalc = elementAnimations && elementAnimations->is
AnimationStyleChange(); | 544 const bool animationStyleRecalc = elementAnimations && elementAnimations->is
AnimationStyleChange(); |
545 #endif | 545 #endif |
546 | 546 |
547 BitArray<numCSSProperties> listedProperties; | 547 BitArray<numCSSProperties> listedProperties; |
548 bool anyTransitionHadTransitionAll = false; | 548 bool anyTransitionHadTransitionAll = false; |
549 const LayoutObject* renderer = animatingElement->layoutObject(); | 549 const LayoutObject* renderer = animatingElement->layoutObject(); |
550 if (!animationStyleRecalc && style.display() != NONE && renderer && renderer
->style() && transitionData) { | 550 if (!animationStyleRecalc && style.display() != NONE && renderer && renderer
->style() && transitionData) { |
551 const LayoutStyle& oldStyle = *renderer->style(); | 551 const ComputedStyle& oldStyle = *renderer->style(); |
552 | 552 |
553 for (size_t i = 0; i < transitionData->propertyList().size(); ++i) { | 553 for (size_t i = 0; i < transitionData->propertyList().size(); ++i) { |
554 const CSSTransitionData::TransitionProperty& transitionProperty = tr
ansitionData->propertyList()[i]; | 554 const CSSTransitionData::TransitionProperty& transitionProperty = tr
ansitionData->propertyList()[i]; |
555 CSSTransitionData::TransitionPropertyType mode = transitionProperty.
propertyType; | 555 CSSTransitionData::TransitionPropertyType mode = transitionProperty.
propertyType; |
556 CSSPropertyID property = transitionProperty.propertyId; | 556 CSSPropertyID property = transitionProperty.propertyId; |
557 if (mode == CSSTransitionData::TransitionNone || mode == CSSTransiti
onData::TransitionUnknown) | 557 if (mode == CSSTransitionData::TransitionNone || mode == CSSTransiti
onData::TransitionUnknown) |
558 continue; | 558 continue; |
559 | 559 |
560 bool animateAll = mode == CSSTransitionData::TransitionAll; | 560 bool animateAll = mode == CSSTransitionData::TransitionAll; |
561 ASSERT(animateAll || mode == CSSTransitionData::TransitionSingleProp
erty); | 561 ASSERT(animateAll || mode == CSSTransitionData::TransitionSingleProp
erty); |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 visitor->trace(m_activeInterpolationsForAnimations); | 833 visitor->trace(m_activeInterpolationsForAnimations); |
834 visitor->trace(m_activeInterpolationsForTransitions); | 834 visitor->trace(m_activeInterpolationsForTransitions); |
835 visitor->trace(m_newAnimations); | 835 visitor->trace(m_newAnimations); |
836 visitor->trace(m_suppressedAnimationPlayers); | 836 visitor->trace(m_suppressedAnimationPlayers); |
837 visitor->trace(m_animationsWithUpdates); | 837 visitor->trace(m_animationsWithUpdates); |
838 visitor->trace(m_animationsWithStyleUpdates); | 838 visitor->trace(m_animationsWithStyleUpdates); |
839 #endif | 839 #endif |
840 } | 840 } |
841 | 841 |
842 } // namespace blink | 842 } // namespace blink |
OLD | NEW |