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 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 // Properties being animated by animations don't get values from transitions
applied. | 729 // Properties being animated by animations don't get values from transitions
applied. |
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, WebKitAnima
tionEvent::create(eventName, m_name, elapsedTime)); | 740 RefPtr<WebKitAnimationEvent> event = WebKitAnimationEvent::create(eventN
ame, m_name, elapsedTime); |
| 741 event->setTarget(m_target); |
| 742 m_target->document().enqueueAnimationFrameEvent(event); |
| 743 } |
741 } | 744 } |
742 | 745 |
743 void CSSAnimations::AnimationEventDelegate::onEventCondition(const TimedItem* ti
medItem, bool isFirstSample, TimedItem::Phase previousPhase, double previousIter
ation) | 746 void CSSAnimations::AnimationEventDelegate::onEventCondition(const TimedItem* ti
medItem, bool isFirstSample, TimedItem::Phase previousPhase, double previousIter
ation) |
744 { | 747 { |
745 // Events for a single document are queued and dispatched as a group at | |
746 // the end of DocumentTimeline::serviceAnimations. | |
747 // FIXME: Events which are queued outside of serviceAnimations should | |
748 // trigger a timer to dispatch when control is released. | |
749 const TimedItem::Phase currentPhase = timedItem->phase(); | 748 const TimedItem::Phase currentPhase = timedItem->phase(); |
750 const double currentIteration = timedItem->currentIteration(); | 749 const double currentIteration = timedItem->currentIteration(); |
751 | 750 |
752 // Note that the elapsedTime is measured from when the animation starts play
ing. | 751 // Note that the elapsedTime is measured from when the animation starts play
ing. |
753 if (!isFirstSample && previousPhase == TimedItem::PhaseActive && currentPhas
e == TimedItem::PhaseActive && previousIteration != currentIteration) { | 752 if (!isFirstSample && previousPhase == TimedItem::PhaseActive && currentPhas
e == TimedItem::PhaseActive && previousIteration != currentIteration) { |
754 ASSERT(!isNull(previousIteration)); | 753 ASSERT(!isNull(previousIteration)); |
755 ASSERT(!isNull(currentIteration)); | 754 ASSERT(!isNull(currentIteration)); |
756 // We fire only a single event for all iterations thast terminate | 755 // We fire only a single event for all iterations thast terminate |
757 // between a single pair of samples. See http://crbug.com/275263. For | 756 // between a single pair of samples. See http://crbug.com/275263. For |
758 // compatibility with the existing implementation, this event uses | 757 // compatibility with the existing implementation, this event uses |
759 // the elapsedTime for the first iteration in question. | 758 // the elapsedTime for the first iteration in question. |
760 ASSERT(!std::isnan(timedItem->specifiedTiming().iterationDuration)); | 759 ASSERT(!std::isnan(timedItem->specifiedTiming().iterationDuration)); |
761 const double elapsedTime = timedItem->specifiedTiming().iterationDuratio
n * (previousIteration + 1); | 760 const double elapsedTime = timedItem->specifiedTiming().iterationDuratio
n * (previousIteration + 1); |
762 maybeDispatch(Document::ANIMATIONITERATION_LISTENER, EventTypeNames::ani
mationiteration, elapsedTime); | 761 maybeDispatch(Document::ANIMATIONITERATION_LISTENER, EventTypeNames::ani
mationiteration, elapsedTime); |
763 return; | 762 return; |
764 } | 763 } |
765 if ((isFirstSample || previousPhase == TimedItem::PhaseBefore) && isLaterPha
se(currentPhase, TimedItem::PhaseBefore)) { | 764 if ((isFirstSample || previousPhase == TimedItem::PhaseBefore) && isLaterPha
se(currentPhase, TimedItem::PhaseBefore)) { |
766 ASSERT(timedItem->specifiedTiming().startDelay > 0 || isFirstSample); | 765 ASSERT(timedItem->specifiedTiming().startDelay > 0 || isFirstSample); |
767 // The spec states that the elapsed time should be | 766 // The spec states that the elapsed time should be |
768 // 'delay < 0 ? -delay : 0', but we always use 0 to match the existing | 767 // 'delay < 0 ? -delay : 0', but we always use 0 to match the existing |
769 // implementation. See crbug.com/279611 | 768 // implementation. See crbug.com/279611 |
770 maybeDispatch(Document::ANIMATIONSTART_LISTENER, EventTypeNames::animati
onstart, 0); | 769 maybeDispatch(Document::ANIMATIONSTART_LISTENER, EventTypeNames::animati
onstart, 0); |
771 } | 770 } |
772 if ((isFirstSample || isEarlierPhase(previousPhase, TimedItem::PhaseAfter))
&& currentPhase == TimedItem::PhaseAfter) | 771 if ((isFirstSample || isEarlierPhase(previousPhase, TimedItem::PhaseAfter))
&& currentPhase == TimedItem::PhaseAfter) |
773 maybeDispatch(Document::ANIMATIONEND_LISTENER, EventTypeNames::animation
end, timedItem->activeDuration()); | 772 maybeDispatch(Document::ANIMATIONEND_LISTENER, EventTypeNames::animation
end, timedItem->activeDuration()); |
774 } | 773 } |
775 | 774 |
776 void CSSAnimations::TransitionEventDelegate::onEventCondition(const TimedItem* t
imedItem, bool isFirstSample, TimedItem::Phase previousPhase, double previousIte
ration) | 775 void CSSAnimations::TransitionEventDelegate::onEventCondition(const TimedItem* t
imedItem, bool isFirstSample, TimedItem::Phase previousPhase, double previousIte
ration) |
777 { | 776 { |
778 // Events for a single document are queued and dispatched as a group at | |
779 // the end of DocumentTimeline::serviceAnimations. | |
780 // FIXME: Events which are queued outside of serviceAnimations should | |
781 // trigger a timer to dispatch when control is released. | |
782 const TimedItem::Phase currentPhase = timedItem->phase(); | 777 const TimedItem::Phase currentPhase = timedItem->phase(); |
783 if (currentPhase == TimedItem::PhaseAfter && (isFirstSample || previousPhase
!= currentPhase) && m_target->document().hasListenerType(Document::TRANSITIONEN
D_LISTENER)) { | 778 if (currentPhase == TimedItem::PhaseAfter && (isFirstSample || previousPhase
!= currentPhase) && m_target->document().hasListenerType(Document::TRANSITIONEN
D_LISTENER)) { |
784 String propertyName = getPropertyNameString(m_property); | 779 String propertyName = getPropertyNameString(m_property); |
785 const Timing& timing = timedItem->specifiedTiming(); | 780 const Timing& timing = timedItem->specifiedTiming(); |
786 double elapsedTime = timing.iterationDuration; | 781 double elapsedTime = timing.iterationDuration; |
787 const AtomicString& eventType = EventTypeNames::transitionend; | 782 const AtomicString& eventType = EventTypeNames::transitionend; |
788 String pseudoElement = PseudoElement::pseudoElementNameForEvents(m_targe
t->pseudoId()); | 783 String pseudoElement = PseudoElement::pseudoElementNameForEvents(m_targe
t->pseudoId()); |
789 m_target->document().transitionTimeline().addEventToDispatch(m_target, T
ransitionEvent::create(eventType, propertyName, elapsedTime, pseudoElement)); | 784 RefPtr<TransitionEvent> event = TransitionEvent::create(eventType, prope
rtyName, elapsedTime, pseudoElement); |
| 785 event->setTarget(m_target); |
| 786 m_target->document().enqueueAnimationFrameEvent(event); |
790 } | 787 } |
791 } | 788 } |
792 | 789 |
793 | 790 |
794 bool CSSAnimations::isAnimatableProperty(CSSPropertyID property) | 791 bool CSSAnimations::isAnimatableProperty(CSSPropertyID property) |
795 { | 792 { |
796 switch (property) { | 793 switch (property) { |
797 case CSSPropertyBackgroundColor: | 794 case CSSPropertyBackgroundColor: |
798 case CSSPropertyBackgroundImage: | 795 case CSSPropertyBackgroundImage: |
799 case CSSPropertyBackgroundPositionX: | 796 case CSSPropertyBackgroundPositionX: |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
919 CSSPropertyID id = convertToCSSPropertyID(i); | 916 CSSPropertyID id = convertToCSSPropertyID(i); |
920 if (isAnimatableProperty(id)) | 917 if (isAnimatableProperty(id)) |
921 properties.append(id); | 918 properties.append(id); |
922 } | 919 } |
923 propertyShorthand = StylePropertyShorthand(CSSPropertyInvalid, propertie
s.begin(), properties.size()); | 920 propertyShorthand = StylePropertyShorthand(CSSPropertyInvalid, propertie
s.begin(), properties.size()); |
924 } | 921 } |
925 return propertyShorthand; | 922 return propertyShorthand; |
926 } | 923 } |
927 | 924 |
928 } // namespace WebCore | 925 } // namespace WebCore |
OLD | NEW |