| 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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 } | 467 } |
| 468 | 468 |
| 469 for (Vector<CSSAnimationUpdate::NewAnimation>::const_iterator iter = update-
>newAnimations().begin(); iter != update->newAnimations().end(); ++iter) { | 469 for (Vector<CSSAnimationUpdate::NewAnimation>::const_iterator iter = update-
>newAnimations().begin(); iter != update->newAnimations().end(); ++iter) { |
| 470 OwnPtr<AnimationEventDelegate> eventDelegate = adoptPtr(new AnimationEve
ntDelegate(element, iter->name)); | 470 OwnPtr<AnimationEventDelegate> eventDelegate = adoptPtr(new AnimationEve
ntDelegate(element, iter->name)); |
| 471 HashSet<RefPtr<Player> > players; | 471 HashSet<RefPtr<Player> > players; |
| 472 for (HashSet<RefPtr<InertAnimation> >::const_iterator animationsIter = i
ter->animations.begin(); animationsIter != iter->animations.end(); ++animationsI
ter) { | 472 for (HashSet<RefPtr<InertAnimation> >::const_iterator animationsIter = i
ter->animations.begin(); animationsIter != iter->animations.end(); ++animationsI
ter) { |
| 473 const InertAnimation* inertAnimation = animationsIter->get(); | 473 const InertAnimation* inertAnimation = animationsIter->get(); |
| 474 // The event delegate is set on the the first animation only. We | 474 // The event delegate is set on the the first animation only. We |
| 475 // rely on the behavior of OwnPtr::release() to achieve this. | 475 // rely on the behavior of OwnPtr::release() to achieve this. |
| 476 RefPtr<Animation> animation = Animation::create(element, inertAnimat
ion->effect(), inertAnimation->specifiedTiming(), Animation::DefaultPriority, ev
entDelegate.release()); | 476 RefPtr<Animation> animation = Animation::create(element, inertAnimat
ion->effect(), inertAnimation->specifiedTiming(), Animation::DefaultPriority, ev
entDelegate.release()); |
| 477 Player* player = element->document().timeline()->createPlayer(animat
ion.get()); | 477 Player* player = element->document().timeline().createPlayer(animati
on.get()); |
| 478 if (inertAnimation->paused()) | 478 if (inertAnimation->paused()) |
| 479 player->pause(); | 479 player->pause(); |
| 480 element->document().cssPendingAnimations().add(player); | 480 element->document().cssPendingAnimations().add(player); |
| 481 player->update(); | 481 player->update(); |
| 482 players.add(player); | 482 players.add(player); |
| 483 } | 483 } |
| 484 m_animations.set(iter->name, players); | 484 m_animations.set(iter->name, players); |
| 485 } | 485 } |
| 486 | 486 |
| 487 // Transitions that are run on the compositor only update main-thread state | 487 // Transitions that are run on the compositor only update main-thread state |
| (...skipping 22 matching lines...) Expand all Loading... |
| 510 CSSPropertyID id = newTransition.id; | 510 CSSPropertyID id = newTransition.id; |
| 511 InertAnimation* inertAnimation = newTransition.animation.get(); | 511 InertAnimation* inertAnimation = newTransition.animation.get(); |
| 512 OwnPtr<TransitionEventDelegate> eventDelegate = adoptPtr(new TransitionE
ventDelegate(element, id)); | 512 OwnPtr<TransitionEventDelegate> eventDelegate = adoptPtr(new TransitionE
ventDelegate(element, id)); |
| 513 | 513 |
| 514 RefPtrWillBeRawPtr<AnimationEffect> effect = inertAnimation->effect(); | 514 RefPtrWillBeRawPtr<AnimationEffect> effect = inertAnimation->effect(); |
| 515 | 515 |
| 516 if (retargetedCompositorTransitions.contains(id)) { | 516 if (retargetedCompositorTransitions.contains(id)) { |
| 517 const std::pair<RefPtr<Animation>, double>& oldTransition = retarget
edCompositorTransitions.get(id); | 517 const std::pair<RefPtr<Animation>, double>& oldTransition = retarget
edCompositorTransitions.get(id); |
| 518 RefPtr<Animation> oldAnimation = oldTransition.first; | 518 RefPtr<Animation> oldAnimation = oldTransition.first; |
| 519 double oldStartTime = oldTransition.second; | 519 double oldStartTime = oldTransition.second; |
| 520 double inheritedTime = isNull(oldStartTime) ? 0 : element->document(
).transitionTimeline()->currentTime() - oldStartTime; | 520 double inheritedTime = isNull(oldStartTime) ? 0 : element->document(
).transitionTimeline().currentTime() - oldStartTime; |
| 521 oldAnimation->updateInheritedTime(inheritedTime); | 521 oldAnimation->updateInheritedTime(inheritedTime); |
| 522 KeyframeEffectModel* oldEffect = toKeyframeEffectModel(inertAnimatio
n->effect()); | 522 KeyframeEffectModel* oldEffect = toKeyframeEffectModel(inertAnimatio
n->effect()); |
| 523 const KeyframeEffectModel::KeyframeVector& frames = oldEffect->getFr
ames(); | 523 const KeyframeEffectModel::KeyframeVector& frames = oldEffect->getFr
ames(); |
| 524 KeyframeEffectModel::KeyframeVector newFrames; | 524 KeyframeEffectModel::KeyframeVector newFrames; |
| 525 newFrames.append(frames[0]->clone()); | 525 newFrames.append(frames[0]->clone()); |
| 526 newFrames[0]->clearPropertyValue(id); | 526 newFrames[0]->clearPropertyValue(id); |
| 527 ASSERT(oldAnimation->compositableValues()->size() == 1); | 527 ASSERT(oldAnimation->compositableValues()->size() == 1); |
| 528 const AnimationEffect::CompositableValue* compositableValue = oldAni
mation->compositableValues()->at(0).second.get(); | 528 const AnimationEffect::CompositableValue* compositableValue = oldAni
mation->compositableValues()->at(0).second.get(); |
| 529 ASSERT(!compositableValue->dependsOnUnderlyingValue()); | 529 ASSERT(!compositableValue->dependsOnUnderlyingValue()); |
| 530 newFrames[0]->setPropertyValue(id, compositableValue->compositeOnto(
0).get()); | 530 newFrames[0]->setPropertyValue(id, compositableValue->compositeOnto(
0).get()); |
| 531 newFrames.append(frames[1]->clone()); | 531 newFrames.append(frames[1]->clone()); |
| 532 effect = KeyframeEffectModel::create(newFrames); | 532 effect = KeyframeEffectModel::create(newFrames); |
| 533 } | 533 } |
| 534 RefPtr<Animation> transition = Animation::create(element, effect, inertA
nimation->specifiedTiming(), Animation::TransitionPriority, eventDelegate.releas
e()); | 534 RefPtr<Animation> transition = Animation::create(element, effect, inertA
nimation->specifiedTiming(), Animation::TransitionPriority, eventDelegate.releas
e()); |
| 535 RefPtr<Player> player = element->document().transitionTimeline()->create
Player(transition.get()); | 535 RefPtr<Player> player = element->document().transitionTimeline().createP
layer(transition.get()); |
| 536 player->update(); | 536 player->update(); |
| 537 element->document().cssPendingAnimations().add(player.get()); | 537 element->document().cssPendingAnimations().add(player.get()); |
| 538 runningTransition.transition = transition.get(); | 538 runningTransition.transition = transition.get(); |
| 539 m_transitions.set(id, runningTransition); | 539 m_transitions.set(id, runningTransition); |
| 540 ASSERT(id != CSSPropertyInvalid); | 540 ASSERT(id != CSSPropertyInvalid); |
| 541 blink::Platform::current()->histogramSparse("WebCore.Animation.CSSProper
ties", UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(id)); | 541 blink::Platform::current()->histogramSparse("WebCore.Animation.CSSProper
ties", UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(id)); |
| 542 } | 542 } |
| 543 } | 543 } |
| 544 | 544 |
| 545 void CSSAnimations::calculateTransitionUpdateForProperty(CSSPropertyID id, const
CSSAnimationData* anim, const RenderStyle& oldStyle, const RenderStyle& style,
const TransitionMap* activeTransitions, CSSAnimationUpdate* update, const Elemen
t* element) | 545 void CSSAnimations::calculateTransitionUpdateForProperty(CSSPropertyID id, const
CSSAnimationData* anim, const RenderStyle& oldStyle, const RenderStyle& style,
const TransitionMap* activeTransitions, CSSAnimationUpdate* update, const Elemen
t* element) |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 if (!update->compositableValuesForAnimations().isEmpty() && !compositableVal
uesForTransitions.isEmpty()) { | 730 if (!update->compositableValuesForAnimations().isEmpty() && !compositableVal
uesForTransitions.isEmpty()) { |
| 731 for (AnimationEffect::CompositableValueMap::const_iterator iter = update
->compositableValuesForAnimations().begin(); iter != update->compositableValuesF
orAnimations().end(); ++iter) | 731 for (AnimationEffect::CompositableValueMap::const_iterator iter = update
->compositableValuesForAnimations().begin(); iter != update->compositableValuesF
orAnimations().end(); ++iter) |
| 732 compositableValuesForTransitions.remove(iter->key); | 732 compositableValuesForTransitions.remove(iter->key); |
| 733 } | 733 } |
| 734 update->adoptCompositableValuesForTransitions(compositableValuesForTransitio
ns); | 734 update->adoptCompositableValuesForTransitions(compositableValuesForTransitio
ns); |
| 735 } | 735 } |
| 736 | 736 |
| 737 void CSSAnimations::AnimationEventDelegate::maybeDispatch(Document::ListenerType
listenerType, const AtomicString& eventName, double elapsedTime) | 737 void CSSAnimations::AnimationEventDelegate::maybeDispatch(Document::ListenerType
listenerType, const AtomicString& eventName, double elapsedTime) |
| 738 { | 738 { |
| 739 if (m_target->document().hasListenerType(listenerType)) | 739 if (m_target->document().hasListenerType(listenerType)) |
| 740 m_target->document().timeline()->addEventToDispatch(m_target, WebKitAnim
ationEvent::create(eventName, m_name, elapsedTime)); | 740 m_target->document().timeline().addEventToDispatch(m_target, WebKitAnima
tionEvent::create(eventName, m_name, elapsedTime)); |
| 741 } | 741 } |
| 742 | 742 |
| 743 void CSSAnimations::AnimationEventDelegate::onEventCondition(const TimedItem* ti
medItem, bool isFirstSample, TimedItem::Phase previousPhase, double previousIter
ation) | 743 void CSSAnimations::AnimationEventDelegate::onEventCondition(const TimedItem* ti
medItem, bool isFirstSample, TimedItem::Phase previousPhase, double previousIter
ation) |
| 744 { | 744 { |
| 745 // Events for a single document are queued and dispatched as a group at | 745 // Events for a single document are queued and dispatched as a group at |
| 746 // the end of DocumentTimeline::serviceAnimations. | 746 // the end of DocumentTimeline::serviceAnimations. |
| 747 // FIXME: Events which are queued outside of serviceAnimations should | 747 // FIXME: Events which are queued outside of serviceAnimations should |
| 748 // trigger a timer to dispatch when control is released. | 748 // trigger a timer to dispatch when control is released. |
| 749 const TimedItem::Phase currentPhase = timedItem->phase(); | 749 const TimedItem::Phase currentPhase = timedItem->phase(); |
| 750 const double currentIteration = timedItem->currentIteration(); | 750 const double currentIteration = timedItem->currentIteration(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 779 // the end of DocumentTimeline::serviceAnimations. | 779 // the end of DocumentTimeline::serviceAnimations. |
| 780 // FIXME: Events which are queued outside of serviceAnimations should | 780 // FIXME: Events which are queued outside of serviceAnimations should |
| 781 // trigger a timer to dispatch when control is released. | 781 // trigger a timer to dispatch when control is released. |
| 782 const TimedItem::Phase currentPhase = timedItem->phase(); | 782 const TimedItem::Phase currentPhase = timedItem->phase(); |
| 783 if (currentPhase == TimedItem::PhaseAfter && (isFirstSample || previousPhase
!= currentPhase) && m_target->document().hasListenerType(Document::TRANSITIONEN
D_LISTENER)) { | 783 if (currentPhase == TimedItem::PhaseAfter && (isFirstSample || previousPhase
!= currentPhase) && m_target->document().hasListenerType(Document::TRANSITIONEN
D_LISTENER)) { |
| 784 String propertyName = getPropertyNameString(m_property); | 784 String propertyName = getPropertyNameString(m_property); |
| 785 const Timing& timing = timedItem->specifiedTiming(); | 785 const Timing& timing = timedItem->specifiedTiming(); |
| 786 double elapsedTime = timing.iterationDuration; | 786 double elapsedTime = timing.iterationDuration; |
| 787 const AtomicString& eventType = EventTypeNames::transitionend; | 787 const AtomicString& eventType = EventTypeNames::transitionend; |
| 788 String pseudoElement = PseudoElement::pseudoElementNameForEvents(m_targe
t->pseudoId()); | 788 String pseudoElement = PseudoElement::pseudoElementNameForEvents(m_targe
t->pseudoId()); |
| 789 m_target->document().transitionTimeline()->addEventToDispatch(m_target,
TransitionEvent::create(eventType, propertyName, elapsedTime, pseudoElement)); | 789 m_target->document().transitionTimeline().addEventToDispatch(m_target, T
ransitionEvent::create(eventType, propertyName, elapsedTime, pseudoElement)); |
| 790 } | 790 } |
| 791 } | 791 } |
| 792 | 792 |
| 793 | 793 |
| 794 bool CSSAnimations::isAnimatableProperty(CSSPropertyID property) | 794 bool CSSAnimations::isAnimatableProperty(CSSPropertyID property) |
| 795 { | 795 { |
| 796 switch (property) { | 796 switch (property) { |
| 797 case CSSPropertyBackgroundColor: | 797 case CSSPropertyBackgroundColor: |
| 798 case CSSPropertyBackgroundImage: | 798 case CSSPropertyBackgroundImage: |
| 799 case CSSPropertyBackgroundPositionX: | 799 case CSSPropertyBackgroundPositionX: |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 CSSPropertyID id = convertToCSSPropertyID(i); | 919 CSSPropertyID id = convertToCSSPropertyID(i); |
| 920 if (isAnimatableProperty(id)) | 920 if (isAnimatableProperty(id)) |
| 921 properties.append(id); | 921 properties.append(id); |
| 922 } | 922 } |
| 923 propertyShorthand = StylePropertyShorthand(CSSPropertyInvalid, propertie
s.begin(), properties.size()); | 923 propertyShorthand = StylePropertyShorthand(CSSPropertyInvalid, propertie
s.begin(), properties.size()); |
| 924 } | 924 } |
| 925 return propertyShorthand; | 925 return propertyShorthand; |
| 926 } | 926 } |
| 927 | 927 |
| 928 } // namespace WebCore | 928 } // namespace WebCore |
| OLD | NEW |