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

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

Issue 22385010: [SVG] Handle endEvent 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 | « Source/core/svg/animation/SVGSMILElement.h ('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 13 matching lines...) Expand all
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "core/svg/animation/SVGSMILElement.h" 27 #include "core/svg/animation/SVGSMILElement.h"
28 28
29 #include "SVGNames.h" 29 #include "SVGNames.h"
30 #include "XLinkNames.h" 30 #include "XLinkNames.h"
31 #include "bindings/v8/ExceptionStatePlaceholder.h" 31 #include "bindings/v8/ExceptionStatePlaceholder.h"
32 #include "core/dom/Document.h" 32 #include "core/dom/Document.h"
33 #include "core/dom/EventListener.h" 33 #include "core/dom/EventListener.h"
34 #include "core/dom/EventSender.h"
34 #include "core/platform/FloatConversion.h" 35 #include "core/platform/FloatConversion.h"
35 #include "core/svg/SVGDocumentExtensions.h" 36 #include "core/svg/SVGDocumentExtensions.h"
36 #include "core/svg/SVGSVGElement.h" 37 #include "core/svg/SVGSVGElement.h"
37 #include "core/svg/SVGURIReference.h" 38 #include "core/svg/SVGURIReference.h"
38 #include "core/svg/animation/SMILTimeContainer.h" 39 #include "core/svg/animation/SMILTimeContainer.h"
39 #include "wtf/MathExtras.h" 40 #include "wtf/MathExtras.h"
40 #include "wtf/StdLibExtras.h" 41 #include "wtf/StdLibExtras.h"
41 #include "wtf/Vector.h" 42 #include "wtf/Vector.h"
42 43
43 using namespace std; 44 using namespace std;
44 45
45 namespace WebCore { 46 namespace WebCore {
46 47
48 static SMILEventSender& smilEndEventSender()
49 {
50 DEFINE_STATIC_LOCAL(SMILEventSender, sender, ("endEvent"));
51 return sender;
52 }
53
47 // This is used for duration type time values that can't be negative. 54 // This is used for duration type time values that can't be negative.
48 static const double invalidCachedTime = -1.; 55 static const double invalidCachedTime = -1.;
49 56
50 class ConditionEventListener : public EventListener { 57 class ConditionEventListener : public EventListener {
51 public: 58 public:
52 static PassRefPtr<ConditionEventListener> create(SVGSMILElement* animation, SVGSMILElement::Condition* condition) 59 static PassRefPtr<ConditionEventListener> create(SVGSMILElement* animation, SVGSMILElement::Condition* condition)
53 { 60 {
54 return adoptRef(new ConditionEventListener(animation, condition)); 61 return adoptRef(new ConditionEventListener(animation, condition));
55 } 62 }
56 63
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 , m_cachedRepeatCount(invalidCachedTime) 133 , m_cachedRepeatCount(invalidCachedTime)
127 , m_cachedMin(invalidCachedTime) 134 , m_cachedMin(invalidCachedTime)
128 , m_cachedMax(invalidCachedTime) 135 , m_cachedMax(invalidCachedTime)
129 { 136 {
130 resolveFirstInterval(); 137 resolveFirstInterval();
131 } 138 }
132 139
133 SVGSMILElement::~SVGSMILElement() 140 SVGSMILElement::~SVGSMILElement()
134 { 141 {
135 clearResourceReferences(); 142 clearResourceReferences();
143 smilEndEventSender().cancelEvent(this);
136 disconnectConditions(); 144 disconnectConditions();
137 if (m_timeContainer && m_targetElement && hasValidAttributeName()) 145 if (m_timeContainer && m_targetElement && hasValidAttributeName())
138 m_timeContainer->unschedule(this, m_targetElement, m_attributeName); 146 m_timeContainer->unschedule(this, m_targetElement, m_attributeName);
139 } 147 }
140 148
141 void SVGSMILElement::clearResourceReferences() 149 void SVGSMILElement::clearResourceReferences()
142 { 150 {
143 ASSERT(document()); 151 ASSERT(document());
144 document()->accessSVGExtensions()->removeAllTargetReferencesForElement(this) ; 152 document()->accessSVGExtensions()->removeAllTargetReferencesForElement(this) ;
145 } 153 }
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 // Animation does not contribute during the active time if it is past its re peating duration and has fill=remove. 1052 // Animation does not contribute during the active time if it is past its re peating duration and has fill=remove.
1045 return (m_activeState == Active && (fill() == FillFreeze || elapsed <= m_int ervalBegin + repeatingDuration())) || m_activeState == Frozen; 1053 return (m_activeState == Active && (fill() == FillFreeze || elapsed <= m_int ervalBegin + repeatingDuration())) || m_activeState == Frozen;
1046 } 1054 }
1047 1055
1048 bool SVGSMILElement::progress(SMILTime elapsed, SVGSMILElement* resultElement, b ool seekToTime) 1056 bool SVGSMILElement::progress(SMILTime elapsed, SVGSMILElement* resultElement, b ool seekToTime)
1049 { 1057 {
1050 ASSERT(resultElement); 1058 ASSERT(resultElement);
1051 ASSERT(m_timeContainer); 1059 ASSERT(m_timeContainer);
1052 ASSERT(m_isWaitingForFirstInterval || m_intervalBegin.isFinite()); 1060 ASSERT(m_isWaitingForFirstInterval || m_intervalBegin.isFinite());
1053 1061
1054 if (!m_conditionsConnected)
1055 connectConditions();
1056
1057 if (!m_intervalBegin.isFinite()) { 1062 if (!m_intervalBegin.isFinite()) {
1058 ASSERT(m_activeState == Inactive); 1063 ASSERT(m_activeState == Inactive);
1059 m_nextProgressTime = SMILTime::unresolved(); 1064 m_nextProgressTime = SMILTime::unresolved();
1060 return false; 1065 return false;
1061 } 1066 }
1062 1067
1063 if (elapsed < m_intervalBegin) { 1068 if (elapsed < m_intervalBegin) {
1064 ASSERT(m_activeState != Active); 1069 ASSERT(m_activeState != Active);
1065 if (m_activeState == Frozen) { 1070 if (m_activeState == Frozen) {
1066 if (this == resultElement) 1071 if (this == resultElement)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 if (animationIsContributing) { 1108 if (animationIsContributing) {
1104 if (oldActiveState == Inactive) 1109 if (oldActiveState == Inactive)
1105 startedActiveInterval(); 1110 startedActiveInterval();
1106 1111
1107 updateAnimation(percent, repeat, resultElement); 1112 updateAnimation(percent, repeat, resultElement);
1108 m_lastPercent = percent; 1113 m_lastPercent = percent;
1109 m_lastRepeat = repeat; 1114 m_lastRepeat = repeat;
1110 } 1115 }
1111 1116
1112 if (oldActiveState == Active && m_activeState != Active) { 1117 if (oldActiveState == Active && m_activeState != Active) {
1118 smilEndEventSender().dispatchEventSoon(this);
1113 endedActiveInterval(); 1119 endedActiveInterval();
1114 if (m_activeState != Frozen && this == resultElement) 1120 if (m_activeState != Frozen && this == resultElement)
1115 clearAnimatedType(m_targetElement); 1121 clearAnimatedType(m_targetElement);
1116 } 1122 }
1117 1123
1124 // Triggering all the pending events if the animation timeline is changed.
1125 if (seekToTime) {
1126 if (m_activeState == Inactive || m_activeState == Frozen)
1127 smilEndEventSender().dispatchEventSoon(this);
1128 }
1129
1118 m_nextProgressTime = calculateNextProgressTime(elapsed); 1130 m_nextProgressTime = calculateNextProgressTime(elapsed);
1119 return animationIsContributing; 1131 return animationIsContributing;
1120 } 1132 }
1121 1133
1122 void SVGSMILElement::notifyDependentsIntervalChanged(NewOrExistingInterval newOr Existing) 1134 void SVGSMILElement::notifyDependentsIntervalChanged(NewOrExistingInterval newOr Existing)
1123 { 1135 {
1124 ASSERT(m_intervalBegin.isFinite()); 1136 ASSERT(m_intervalBegin.isFinite());
1125 DEFINE_STATIC_LOCAL(HashSet<SVGSMILElement*>, loopBreaker, ()); 1137 DEFINE_STATIC_LOCAL(HashSet<SVGSMILElement*>, loopBreaker, ());
1126 if (!loopBreaker.add(this).isNewEntry) 1138 if (!loopBreaker.add(this).isNewEntry)
1127 return; 1139 return;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 SMILTime elapsed = this->elapsed(); 1196 SMILTime elapsed = this->elapsed();
1185 addBeginTime(elapsed, elapsed); 1197 addBeginTime(elapsed, elapsed);
1186 } 1198 }
1187 1199
1188 void SVGSMILElement::endedActiveInterval() 1200 void SVGSMILElement::endedActiveInterval()
1189 { 1201 {
1190 clearTimesWithDynamicOrigins(m_beginTimes); 1202 clearTimesWithDynamicOrigins(m_beginTimes);
1191 clearTimesWithDynamicOrigins(m_endTimes); 1203 clearTimesWithDynamicOrigins(m_endTimes);
1192 } 1204 }
1193 1205
1206 void SVGSMILElement::dispatchPendingEvent(SMILEventSender* eventSender)
1207 {
1208 ASSERT(eventSender == &smilEndEventSender());
1209 const AtomicString& eventType = eventSender->eventType();
1210 dispatchEvent(Event::create(eventType));
1194 } 1211 }
1212
1213 }
OLDNEW
« no previous file with comments | « Source/core/svg/animation/SVGSMILElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698