| 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 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1067 if (animation_target_->GetDocument().HasListenerType(listener_type)) { | 1067 if (animation_target_->GetDocument().HasListenerType(listener_type)) { |
| 1068 AnimationEvent* event = | 1068 AnimationEvent* event = |
| 1069 AnimationEvent::Create(event_name, name_, elapsed_time); | 1069 AnimationEvent::Create(event_name, name_, elapsed_time); |
| 1070 event->SetTarget(GetEventTarget()); | 1070 event->SetTarget(GetEventTarget()); |
| 1071 GetDocument().EnqueueAnimationFrameEvent(event); | 1071 GetDocument().EnqueueAnimationFrameEvent(event); |
| 1072 } | 1072 } |
| 1073 } | 1073 } |
| 1074 | 1074 |
| 1075 bool CSSAnimations::AnimationEventDelegate::RequiresIterationEvents( | 1075 bool CSSAnimations::AnimationEventDelegate::RequiresIterationEvents( |
| 1076 const AnimationEffectReadOnly& animation_node) { | 1076 const AnimationEffectReadOnly& animation_node) { |
| 1077 return GetDocument().HasListenerType(Document::ANIMATIONITERATION_LISTENER); | 1077 return GetDocument().HasListenerType(Document::kAnimationIterationListener); |
| 1078 } | 1078 } |
| 1079 | 1079 |
| 1080 void CSSAnimations::AnimationEventDelegate::OnEventCondition( | 1080 void CSSAnimations::AnimationEventDelegate::OnEventCondition( |
| 1081 const AnimationEffectReadOnly& animation_node) { | 1081 const AnimationEffectReadOnly& animation_node) { |
| 1082 const AnimationEffectReadOnly::Phase current_phase = | 1082 const AnimationEffectReadOnly::Phase current_phase = |
| 1083 animation_node.GetPhase(); | 1083 animation_node.GetPhase(); |
| 1084 const double current_iteration = animation_node.CurrentIteration(); | 1084 const double current_iteration = animation_node.CurrentIteration(); |
| 1085 | 1085 |
| 1086 if (previous_phase_ != current_phase && | 1086 if (previous_phase_ != current_phase && |
| 1087 (current_phase == AnimationEffectReadOnly::kPhaseActive || | 1087 (current_phase == AnimationEffectReadOnly::kPhaseActive || |
| 1088 current_phase == AnimationEffectReadOnly::kPhaseAfter) && | 1088 current_phase == AnimationEffectReadOnly::kPhaseAfter) && |
| 1089 (previous_phase_ == AnimationEffectReadOnly::kPhaseNone || | 1089 (previous_phase_ == AnimationEffectReadOnly::kPhaseNone || |
| 1090 previous_phase_ == AnimationEffectReadOnly::kPhaseBefore)) { | 1090 previous_phase_ == AnimationEffectReadOnly::kPhaseBefore)) { |
| 1091 const double start_delay = animation_node.SpecifiedTiming().start_delay; | 1091 const double start_delay = animation_node.SpecifiedTiming().start_delay; |
| 1092 const double elapsed_time = start_delay < 0 ? -start_delay : 0; | 1092 const double elapsed_time = start_delay < 0 ? -start_delay : 0; |
| 1093 MaybeDispatch(Document::ANIMATIONSTART_LISTENER, | 1093 MaybeDispatch(Document::kAnimationStartListener, |
| 1094 EventTypeNames::animationstart, elapsed_time); | 1094 EventTypeNames::animationstart, elapsed_time); |
| 1095 } | 1095 } |
| 1096 | 1096 |
| 1097 if (current_phase == AnimationEffectReadOnly::kPhaseActive && | 1097 if (current_phase == AnimationEffectReadOnly::kPhaseActive && |
| 1098 previous_phase_ == current_phase && | 1098 previous_phase_ == current_phase && |
| 1099 previous_iteration_ != current_iteration) { | 1099 previous_iteration_ != current_iteration) { |
| 1100 // We fire only a single event for all iterations thast terminate | 1100 // We fire only a single event for all iterations thast terminate |
| 1101 // between a single pair of samples. See http://crbug.com/275263. For | 1101 // between a single pair of samples. See http://crbug.com/275263. For |
| 1102 // compatibility with the existing implementation, this event uses | 1102 // compatibility with the existing implementation, this event uses |
| 1103 // the elapsedTime for the first iteration in question. | 1103 // the elapsedTime for the first iteration in question. |
| 1104 DCHECK(!std::isnan(animation_node.SpecifiedTiming().iteration_duration)); | 1104 DCHECK(!std::isnan(animation_node.SpecifiedTiming().iteration_duration)); |
| 1105 const double elapsed_time = | 1105 const double elapsed_time = |
| 1106 animation_node.SpecifiedTiming().iteration_duration * | 1106 animation_node.SpecifiedTiming().iteration_duration * |
| 1107 (previous_iteration_ + 1); | 1107 (previous_iteration_ + 1); |
| 1108 MaybeDispatch(Document::ANIMATIONITERATION_LISTENER, | 1108 MaybeDispatch(Document::kAnimationIterationListener, |
| 1109 EventTypeNames::animationiteration, elapsed_time); | 1109 EventTypeNames::animationiteration, elapsed_time); |
| 1110 } | 1110 } |
| 1111 | 1111 |
| 1112 if (current_phase == AnimationEffectReadOnly::kPhaseAfter && | 1112 if (current_phase == AnimationEffectReadOnly::kPhaseAfter && |
| 1113 previous_phase_ != AnimationEffectReadOnly::kPhaseAfter) | 1113 previous_phase_ != AnimationEffectReadOnly::kPhaseAfter) |
| 1114 MaybeDispatch(Document::ANIMATIONEND_LISTENER, EventTypeNames::animationend, | 1114 MaybeDispatch(Document::kAnimationEndListener, EventTypeNames::animationend, |
| 1115 animation_node.ActiveDurationInternal()); | 1115 animation_node.ActiveDurationInternal()); |
| 1116 | 1116 |
| 1117 previous_phase_ = current_phase; | 1117 previous_phase_ = current_phase; |
| 1118 previous_iteration_ = current_iteration; | 1118 previous_iteration_ = current_iteration; |
| 1119 } | 1119 } |
| 1120 | 1120 |
| 1121 DEFINE_TRACE(CSSAnimations::AnimationEventDelegate) { | 1121 DEFINE_TRACE(CSSAnimations::AnimationEventDelegate) { |
| 1122 visitor->Trace(animation_target_); | 1122 visitor->Trace(animation_target_); |
| 1123 AnimationEffectReadOnly::EventDelegate::Trace(visitor); | 1123 AnimationEffectReadOnly::EventDelegate::Trace(visitor); |
| 1124 } | 1124 } |
| 1125 | 1125 |
| 1126 EventTarget* CSSAnimations::TransitionEventDelegate::GetEventTarget() const { | 1126 EventTarget* CSSAnimations::TransitionEventDelegate::GetEventTarget() const { |
| 1127 return EventPath::EventTargetRespectingTargetRules(*transition_target_); | 1127 return EventPath::EventTargetRespectingTargetRules(*transition_target_); |
| 1128 } | 1128 } |
| 1129 | 1129 |
| 1130 void CSSAnimations::TransitionEventDelegate::OnEventCondition( | 1130 void CSSAnimations::TransitionEventDelegate::OnEventCondition( |
| 1131 const AnimationEffectReadOnly& animation_node) { | 1131 const AnimationEffectReadOnly& animation_node) { |
| 1132 const AnimationEffectReadOnly::Phase current_phase = | 1132 const AnimationEffectReadOnly::Phase current_phase = |
| 1133 animation_node.GetPhase(); | 1133 animation_node.GetPhase(); |
| 1134 if (current_phase == AnimationEffectReadOnly::kPhaseAfter && | 1134 if (current_phase == AnimationEffectReadOnly::kPhaseAfter && |
| 1135 current_phase != previous_phase_ && | 1135 current_phase != previous_phase_ && |
| 1136 GetDocument().HasListenerType(Document::TRANSITIONEND_LISTENER)) { | 1136 GetDocument().HasListenerType(Document::kTransitionEndListener)) { |
| 1137 String property_name = property_.IsCSSCustomProperty() | 1137 String property_name = property_.IsCSSCustomProperty() |
| 1138 ? property_.CustomPropertyName() | 1138 ? property_.CustomPropertyName() |
| 1139 : getPropertyNameString(property_.CssProperty()); | 1139 : getPropertyNameString(property_.CssProperty()); |
| 1140 const Timing& timing = animation_node.SpecifiedTiming(); | 1140 const Timing& timing = animation_node.SpecifiedTiming(); |
| 1141 double elapsed_time = timing.iteration_duration; | 1141 double elapsed_time = timing.iteration_duration; |
| 1142 const AtomicString& event_type = EventTypeNames::transitionend; | 1142 const AtomicString& event_type = EventTypeNames::transitionend; |
| 1143 String pseudo_element = | 1143 String pseudo_element = |
| 1144 PseudoElement::PseudoElementNameForEvents(GetPseudoId()); | 1144 PseudoElement::PseudoElementNameForEvents(GetPseudoId()); |
| 1145 TransitionEvent* event = TransitionEvent::Create( | 1145 TransitionEvent* event = TransitionEvent::Create( |
| 1146 event_type, property_name, elapsed_time, pseudo_element); | 1146 event_type, property_name, elapsed_time, pseudo_element); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1230 IsCustomPropertyHandle); | 1230 IsCustomPropertyHandle); |
| 1231 } | 1231 } |
| 1232 | 1232 |
| 1233 DEFINE_TRACE(CSSAnimations) { | 1233 DEFINE_TRACE(CSSAnimations) { |
| 1234 visitor->Trace(transitions_); | 1234 visitor->Trace(transitions_); |
| 1235 visitor->Trace(pending_update_); | 1235 visitor->Trace(pending_update_); |
| 1236 visitor->Trace(running_animations_); | 1236 visitor->Trace(running_animations_); |
| 1237 } | 1237 } |
| 1238 | 1238 |
| 1239 } // namespace blink | 1239 } // namespace blink |
| OLD | NEW |