Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: Source/core/svg/animation/SVGSMILElement.cpp

Issue 23621018: [SVG] Handle repeatEvent for svg animations (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LayoutTests/svg/animations/repeat-event-expected.svg ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 DEFINE_STATIC_LOCAL(SMILEventSender, sender, ("endEvent")); 50 DEFINE_STATIC_LOCAL(SMILEventSender, sender, ("endEvent"));
51 return sender; 51 return sender;
52 } 52 }
53 53
54 static SMILEventSender& smilBeginEventSender() 54 static SMILEventSender& smilBeginEventSender()
55 { 55 {
56 DEFINE_STATIC_LOCAL(SMILEventSender, sender, ("beginEvent")); 56 DEFINE_STATIC_LOCAL(SMILEventSender, sender, ("beginEvent"));
57 return sender; 57 return sender;
58 } 58 }
59 59
60 static SMILEventSender& smilRepeatEventSender()
61 {
62 DEFINE_STATIC_LOCAL(SMILEventSender, sender, ("repeatEvent"));
63 return sender;
64 }
65
60 // This is used for duration type time values that can't be negative. 66 // This is used for duration type time values that can't be negative.
61 static const double invalidCachedTime = -1.; 67 static const double invalidCachedTime = -1.;
62 68
63 class ConditionEventListener : public EventListener { 69 class ConditionEventListener : public EventListener {
64 public: 70 public:
65 static PassRefPtr<ConditionEventListener> create(SVGSMILElement* animation, SVGSMILElement::Condition* condition) 71 static PassRefPtr<ConditionEventListener> create(SVGSMILElement* animation, SVGSMILElement::Condition* condition)
66 { 72 {
67 return adoptRef(new ConditionEventListener(animation, condition)); 73 return adoptRef(new ConditionEventListener(animation, condition));
68 } 74 }
69 75
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 , m_cachedMax(invalidCachedTime) 147 , m_cachedMax(invalidCachedTime)
142 { 148 {
143 resolveFirstInterval(); 149 resolveFirstInterval();
144 } 150 }
145 151
146 SVGSMILElement::~SVGSMILElement() 152 SVGSMILElement::~SVGSMILElement()
147 { 153 {
148 clearResourceReferences(); 154 clearResourceReferences();
149 smilEndEventSender().cancelEvent(this); 155 smilEndEventSender().cancelEvent(this);
150 smilBeginEventSender().cancelEvent(this); 156 smilBeginEventSender().cancelEvent(this);
157 smilRepeatEventSender().cancelEvent(this);
151 disconnectConditions(); 158 disconnectConditions();
152 if (m_timeContainer && m_targetElement && hasValidAttributeName()) 159 if (m_timeContainer && m_targetElement && hasValidAttributeName())
153 m_timeContainer->unschedule(this, m_targetElement, m_attributeName); 160 m_timeContainer->unschedule(this, m_targetElement, m_attributeName);
154 } 161 }
155 162
156 void SVGSMILElement::clearResourceReferences() 163 void SVGSMILElement::clearResourceReferences()
157 { 164 {
158 document().accessSVGExtensions()->removeAllTargetReferencesForElement(this); 165 document().accessSVGExtensions()->removeAllTargetReferencesForElement(this);
159 } 166 }
160 167
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 // Only reset the animated type to the base value once for the lowest priori ty animation that animates and contributes to a particular element/attribute pai r. 1117 // Only reset the animated type to the base value once for the lowest priori ty animation that animates and contributes to a particular element/attribute pai r.
1111 if (this == resultElement && animationIsContributing) 1118 if (this == resultElement && animationIsContributing)
1112 resetAnimatedType(); 1119 resetAnimatedType();
1113 1120
1114 if (animationIsContributing) { 1121 if (animationIsContributing) {
1115 if (oldActiveState == Inactive) { 1122 if (oldActiveState == Inactive) {
1116 smilBeginEventSender().dispatchEventSoon(this); 1123 smilBeginEventSender().dispatchEventSoon(this);
1117 startedActiveInterval(); 1124 startedActiveInterval();
1118 } 1125 }
1119 1126
1127 if (repeat && repeat != m_lastRepeat)
1128 smilRepeatEventSender().dispatchEventSoon(this);
1129
1120 updateAnimation(percent, repeat, resultElement); 1130 updateAnimation(percent, repeat, resultElement);
1121 m_lastPercent = percent; 1131 m_lastPercent = percent;
1122 m_lastRepeat = repeat; 1132 m_lastRepeat = repeat;
1123 } 1133 }
1124 1134
1125 if (oldActiveState == Active && m_activeState != Active) { 1135 if (oldActiveState == Active && m_activeState != Active) {
1126 smilEndEventSender().dispatchEventSoon(this); 1136 smilEndEventSender().dispatchEventSoon(this);
1127 endedActiveInterval(); 1137 endedActiveInterval();
1128 if (m_activeState != Frozen && this == resultElement) 1138 if (m_activeState != Frozen && this == resultElement)
1129 clearAnimatedType(m_targetElement); 1139 clearAnimatedType(m_targetElement);
1130 } 1140 }
1131 1141
1132 // Triggering all the pending events if the animation timeline is changed. 1142 // Triggering all the pending events if the animation timeline is changed.
1133 if (seekToTime) { 1143 if (seekToTime) {
1134 if (m_activeState == Inactive) 1144 if (m_activeState == Inactive)
1135 smilBeginEventSender().dispatchEventSoon(this); 1145 smilBeginEventSender().dispatchEventSoon(this);
1146
1147 if (repeat) {
1148 for (unsigned repeatEventCount = 1; repeatEventCount < repeat; repea tEventCount++) {
1149 smilRepeatEventSender().dispatchEventSoon(this);
1150 }
1151 if (m_activeState == Inactive)
1152 smilRepeatEventSender().dispatchEventSoon(this);
1153 }
1154
1136 if (m_activeState == Inactive || m_activeState == Frozen) 1155 if (m_activeState == Inactive || m_activeState == Frozen)
1137 smilEndEventSender().dispatchEventSoon(this); 1156 smilEndEventSender().dispatchEventSoon(this);
1138 } 1157 }
1139 1158
1140 m_nextProgressTime = calculateNextProgressTime(elapsed); 1159 m_nextProgressTime = calculateNextProgressTime(elapsed);
1141 return animationIsContributing; 1160 return animationIsContributing;
1142 } 1161 }
1143 1162
1144 void SVGSMILElement::notifyDependentsIntervalChanged(NewOrExistingInterval newOr Existing) 1163 void SVGSMILElement::notifyDependentsIntervalChanged(NewOrExistingInterval newOr Existing)
1145 { 1164 {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 } 1227 }
1209 1228
1210 void SVGSMILElement::endedActiveInterval() 1229 void SVGSMILElement::endedActiveInterval()
1211 { 1230 {
1212 clearTimesWithDynamicOrigins(m_beginTimes); 1231 clearTimesWithDynamicOrigins(m_beginTimes);
1213 clearTimesWithDynamicOrigins(m_endTimes); 1232 clearTimesWithDynamicOrigins(m_endTimes);
1214 } 1233 }
1215 1234
1216 void SVGSMILElement::dispatchPendingEvent(SMILEventSender* eventSender) 1235 void SVGSMILElement::dispatchPendingEvent(SMILEventSender* eventSender)
1217 { 1236 {
1218 ASSERT(eventSender == &smilEndEventSender() || eventSender == &smilBeginEven tSender()); 1237 ASSERT(eventSender == &smilEndEventSender() || eventSender == &smilBeginEven tSender() || eventSender == &smilRepeatEventSender());
1219 const AtomicString& eventType = eventSender->eventType(); 1238 const AtomicString& eventType = eventSender->eventType();
1220 dispatchEvent(Event::create(eventType)); 1239 dispatchEvent(Event::create(eventType));
1221 } 1240 }
1222 1241
1223 } 1242 }
OLDNEW
« no previous file with comments | « LayoutTests/svg/animations/repeat-event-expected.svg ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698