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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 } | 462 } |
463 } | 463 } |
464 | 464 |
465 for (Vector<CSSAnimationUpdate::NewAnimation>::const_iterator iter = update-
>newAnimations().begin(); iter != update->newAnimations().end(); ++iter) { | 465 for (Vector<CSSAnimationUpdate::NewAnimation>::const_iterator iter = update-
>newAnimations().begin(); iter != update->newAnimations().end(); ++iter) { |
466 OwnPtr<AnimationEventDelegate> eventDelegate = adoptPtr(new AnimationEve
ntDelegate(element, iter->name)); | 466 OwnPtr<AnimationEventDelegate> eventDelegate = adoptPtr(new AnimationEve
ntDelegate(element, iter->name)); |
467 HashSet<RefPtr<Player> > players; | 467 HashSet<RefPtr<Player> > players; |
468 for (HashSet<RefPtr<InertAnimation> >::const_iterator animationsIter = i
ter->animations.begin(); animationsIter != iter->animations.end(); ++animationsI
ter) { | 468 for (HashSet<RefPtr<InertAnimation> >::const_iterator animationsIter = i
ter->animations.begin(); animationsIter != iter->animations.end(); ++animationsI
ter) { |
469 const InertAnimation* inertAnimation = animationsIter->get(); | 469 const InertAnimation* inertAnimation = animationsIter->get(); |
470 // The event delegate is set on the the first animation only. We | 470 // The event delegate is set on the the first animation only. We |
471 // rely on the behavior of OwnPtr::release() to achieve this. | 471 // rely on the behavior of OwnPtr::release() to achieve this. |
472 RefPtr<Animation> animation = Animation::create(element, inertAnimat
ion->effect(), inertAnimation->specified(), Animation::DefaultPriority, eventDel
egate.release()); | 472 RefPtr<Animation> animation = Animation::create(element, inertAnimat
ion->effect(), inertAnimation->specifiedTiming(), Animation::DefaultPriority, ev
entDelegate.release()); |
473 Player* player = element->document().timeline()->createPlayer(animat
ion.get()); | 473 Player* player = element->document().timeline()->createPlayer(animat
ion.get()); |
474 if (inertAnimation->paused()) | 474 if (inertAnimation->paused()) |
475 player->pause(); | 475 player->pause(); |
476 element->document().cssPendingAnimations().add(player); | 476 element->document().cssPendingAnimations().add(player); |
477 player->update(); | 477 player->update(); |
478 players.add(player); | 478 players.add(player); |
479 } | 479 } |
480 m_animations.set(iter->name, players); | 480 m_animations.set(iter->name, players); |
481 } | 481 } |
482 | 482 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 KeyframeEffectModel::KeyframeVector newFrames; | 520 KeyframeEffectModel::KeyframeVector newFrames; |
521 newFrames.append(frames[0]->clone()); | 521 newFrames.append(frames[0]->clone()); |
522 newFrames[0]->clearPropertyValue(id); | 522 newFrames[0]->clearPropertyValue(id); |
523 ASSERT(oldAnimation->compositableValues()->size() == 1); | 523 ASSERT(oldAnimation->compositableValues()->size() == 1); |
524 const AnimationEffect::CompositableValue* compositableValue = oldAni
mation->compositableValues()->at(0).second.get(); | 524 const AnimationEffect::CompositableValue* compositableValue = oldAni
mation->compositableValues()->at(0).second.get(); |
525 ASSERT(!compositableValue->dependsOnUnderlyingValue()); | 525 ASSERT(!compositableValue->dependsOnUnderlyingValue()); |
526 newFrames[0]->setPropertyValue(id, compositableValue->compositeOnto(
0).get()); | 526 newFrames[0]->setPropertyValue(id, compositableValue->compositeOnto(
0).get()); |
527 newFrames.append(frames[1]->clone()); | 527 newFrames.append(frames[1]->clone()); |
528 effect = KeyframeEffectModel::create(newFrames); | 528 effect = KeyframeEffectModel::create(newFrames); |
529 } | 529 } |
530 RefPtr<Animation> transition = Animation::create(element, effect, inertA
nimation->specified(), Animation::TransitionPriority, eventDelegate.release()); | 530 RefPtr<Animation> transition = Animation::create(element, effect, inertA
nimation->specifiedTiming(), Animation::TransitionPriority, eventDelegate.releas
e()); |
531 RefPtr<Player> player = element->document().transitionTimeline()->create
Player(transition.get()); | 531 RefPtr<Player> player = element->document().transitionTimeline()->create
Player(transition.get()); |
532 player->update(); | 532 player->update(); |
533 element->document().cssPendingAnimations().add(player.get()); | 533 element->document().cssPendingAnimations().add(player.get()); |
534 runningTransition.transition = transition.get(); | 534 runningTransition.transition = transition.get(); |
535 m_transitions.set(id, runningTransition); | 535 m_transitions.set(id, runningTransition); |
536 ASSERT(id != CSSPropertyInvalid); | 536 ASSERT(id != CSSPropertyInvalid); |
537 blink::Platform::current()->histogramSparse("WebCore.Animation.CSSProper
ties", UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(id)); | 537 blink::Platform::current()->histogramSparse("WebCore.Animation.CSSProper
ties", UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(id)); |
538 } | 538 } |
539 } | 539 } |
540 | 540 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 const double currentIteration = timedItem->currentIteration(); | 746 const double currentIteration = timedItem->currentIteration(); |
747 | 747 |
748 // Note that the elapsedTime is measured from when the animation starts play
ing. | 748 // Note that the elapsedTime is measured from when the animation starts play
ing. |
749 if (!isFirstSample && previousPhase == TimedItem::PhaseActive && currentPhas
e == TimedItem::PhaseActive && previousIteration != currentIteration) { | 749 if (!isFirstSample && previousPhase == TimedItem::PhaseActive && currentPhas
e == TimedItem::PhaseActive && previousIteration != currentIteration) { |
750 ASSERT(!isNull(previousIteration)); | 750 ASSERT(!isNull(previousIteration)); |
751 ASSERT(!isNull(currentIteration)); | 751 ASSERT(!isNull(currentIteration)); |
752 // We fire only a single event for all iterations thast terminate | 752 // We fire only a single event for all iterations thast terminate |
753 // between a single pair of samples. See http://crbug.com/275263. For | 753 // between a single pair of samples. See http://crbug.com/275263. For |
754 // compatibility with the existing implementation, this event uses | 754 // compatibility with the existing implementation, this event uses |
755 // the elapsedTime for the first iteration in question. | 755 // the elapsedTime for the first iteration in question. |
756 ASSERT(!std::isnan(timedItem->specified().iterationDuration)); | 756 ASSERT(!std::isnan(timedItem->specifiedTiming().iterationDuration)); |
757 const double elapsedTime = timedItem->specified().iterationDuration * (p
reviousIteration + 1); | 757 const double elapsedTime = timedItem->specifiedTiming().iterationDuratio
n * (previousIteration + 1); |
758 maybeDispatch(Document::ANIMATIONITERATION_LISTENER, EventTypeNames::ani
mationiteration, elapsedTime); | 758 maybeDispatch(Document::ANIMATIONITERATION_LISTENER, EventTypeNames::ani
mationiteration, elapsedTime); |
759 return; | 759 return; |
760 } | 760 } |
761 if ((isFirstSample || previousPhase == TimedItem::PhaseBefore) && isLaterPha
se(currentPhase, TimedItem::PhaseBefore)) { | 761 if ((isFirstSample || previousPhase == TimedItem::PhaseBefore) && isLaterPha
se(currentPhase, TimedItem::PhaseBefore)) { |
762 ASSERT(timedItem->specified().startDelay > 0 || isFirstSample); | 762 ASSERT(timedItem->specifiedTiming().startDelay > 0 || isFirstSample); |
763 // The spec states that the elapsed time should be | 763 // The spec states that the elapsed time should be |
764 // 'delay < 0 ? -delay : 0', but we always use 0 to match the existing | 764 // 'delay < 0 ? -delay : 0', but we always use 0 to match the existing |
765 // implementation. See crbug.com/279611 | 765 // implementation. See crbug.com/279611 |
766 maybeDispatch(Document::ANIMATIONSTART_LISTENER, EventTypeNames::animati
onstart, 0); | 766 maybeDispatch(Document::ANIMATIONSTART_LISTENER, EventTypeNames::animati
onstart, 0); |
767 } | 767 } |
768 if ((isFirstSample || isEarlierPhase(previousPhase, TimedItem::PhaseAfter))
&& currentPhase == TimedItem::PhaseAfter) | 768 if ((isFirstSample || isEarlierPhase(previousPhase, TimedItem::PhaseAfter))
&& currentPhase == TimedItem::PhaseAfter) |
769 maybeDispatch(Document::ANIMATIONEND_LISTENER, EventTypeNames::animation
end, timedItem->activeDuration()); | 769 maybeDispatch(Document::ANIMATIONEND_LISTENER, EventTypeNames::animation
end, timedItem->activeDuration()); |
770 } | 770 } |
771 | 771 |
772 void CSSAnimations::TransitionEventDelegate::onEventCondition(const TimedItem* t
imedItem, bool isFirstSample, TimedItem::Phase previousPhase, double previousIte
ration) | 772 void CSSAnimations::TransitionEventDelegate::onEventCondition(const TimedItem* t
imedItem, bool isFirstSample, TimedItem::Phase previousPhase, double previousIte
ration) |
773 { | 773 { |
774 // Events for a single document are queued and dispatched as a group at | 774 // Events for a single document are queued and dispatched as a group at |
775 // the end of DocumentTimeline::serviceAnimations. | 775 // the end of DocumentTimeline::serviceAnimations. |
776 // FIXME: Events which are queued outside of serviceAnimations should | 776 // FIXME: Events which are queued outside of serviceAnimations should |
777 // trigger a timer to dispatch when control is released. | 777 // trigger a timer to dispatch when control is released. |
778 const TimedItem::Phase currentPhase = timedItem->phase(); | 778 const TimedItem::Phase currentPhase = timedItem->phase(); |
779 if (currentPhase == TimedItem::PhaseAfter && (isFirstSample || previousPhase
!= currentPhase) && m_target->document().hasListenerType(Document::TRANSITIONEN
D_LISTENER)) { | 779 if (currentPhase == TimedItem::PhaseAfter && (isFirstSample || previousPhase
!= currentPhase) && m_target->document().hasListenerType(Document::TRANSITIONEN
D_LISTENER)) { |
780 String propertyName = getPropertyNameString(m_property); | 780 String propertyName = getPropertyNameString(m_property); |
781 const Timing& timing = timedItem->specified(); | 781 const Timing& timing = timedItem->specifiedTiming(); |
782 double elapsedTime = timing.iterationDuration; | 782 double elapsedTime = timing.iterationDuration; |
783 const AtomicString& eventType = EventTypeNames::transitionend; | 783 const AtomicString& eventType = EventTypeNames::transitionend; |
784 String pseudoElement = PseudoElement::pseudoElementNameForEvents(m_targe
t->pseudoId()); | 784 String pseudoElement = PseudoElement::pseudoElementNameForEvents(m_targe
t->pseudoId()); |
785 m_target->document().transitionTimeline()->addEventToDispatch(m_target,
TransitionEvent::create(eventType, propertyName, elapsedTime, pseudoElement)); | 785 m_target->document().transitionTimeline()->addEventToDispatch(m_target,
TransitionEvent::create(eventType, propertyName, elapsedTime, pseudoElement)); |
786 } | 786 } |
787 } | 787 } |
788 | 788 |
789 | 789 |
790 bool CSSAnimations::isAnimatableProperty(CSSPropertyID property) | 790 bool CSSAnimations::isAnimatableProperty(CSSPropertyID property) |
791 { | 791 { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 CSSPropertyID id = convertToCSSPropertyID(i); | 914 CSSPropertyID id = convertToCSSPropertyID(i); |
915 if (isAnimatableProperty(id)) | 915 if (isAnimatableProperty(id)) |
916 properties.append(id); | 916 properties.append(id); |
917 } | 917 } |
918 propertyShorthand = StylePropertyShorthand(CSSPropertyInvalid, propertie
s.begin(), properties.size()); | 918 propertyShorthand = StylePropertyShorthand(CSSPropertyInvalid, propertie
s.begin(), properties.size()); |
919 } | 919 } |
920 return propertyShorthand; | 920 return propertyShorthand; |
921 } | 921 } |
922 | 922 |
923 } // namespace WebCore | 923 } // namespace WebCore |
OLD | NEW |