27 #ifndef SVGSMILElement_h
28 #define SVGSMILElement_h
29 #if ENABLE(SVG_ANIMATION)
33 #include <wtf/HashMap.h>
37 class ConditionEventListener;
38 class SMILTimeContainer;
41 class SVGSMILElement :
public SVGElement
44 SVGSMILElement(
const QualifiedName&, Document*);
45 virtual ~SVGSMILElement();
47 static bool isSMILElement(Node* node);
49 virtual void parseMappedAttribute(MappedAttribute*);
50 virtual void attributeChanged(Attribute*,
bool preserveDecls);
51 virtual void insertedIntoDocument();
52 virtual void removedFromDocument();
53 virtual void finishParsingChildren();
55 SMILTimeContainer* timeContainer()
const {
return m_timeContainer.get(); }
57 SVGElement* targetElement()
const;
58 String attributeName()
const;
60 void beginByLinkActivation();
62 enum Restart { RestartAlways, RestartWhenNotActive, RestartNever };
63 Restart restart()
const;
65 enum FillMode { FillRemove, FillFreeze };
66 FillMode fill()
const;
71 SMILTime repeatDur()
const;
72 SMILTime repeatCount()
const;
73 SMILTime maxValue()
const;
74 SMILTime minValue()
const;
76 SMILTime elapsed()
const;
78 SMILTime intervalBegin()
const {
return m_intervalBegin; }
79 SMILTime intervalEnd()
const {
return m_intervalEnd; }
80 SMILTime previousIntervalBegin()
const {
return m_previousIntervalBegin; }
81 SMILTime simpleDuration()
const;
83 void progress(SMILTime elapsed, SVGSMILElement* resultsElement);
84 SMILTime nextProgressTime()
const;
86 static SMILTime parseClockValue(
const String&);
87 static SMILTime parseOffsetValue(
const String&);
89 bool isContributing(SMILTime elapsed)
const;
90 bool isInactive()
const;
91 bool isFrozen()
const;
93 unsigned documentOrderIndex()
const {
return m_documentOrderIndex; }
94 void setDocumentOrderIndex(
unsigned index) { m_documentOrderIndex = index; }
96 virtual bool isAdditive()
const = 0;
97 virtual void resetToBaseValue(
const String&) = 0;
98 virtual void applyResultsToTarget() = 0;
101 void addBeginTime(SMILTime time);
102 void addEndTime(SMILTime time);
105 virtual void startedActiveInterval() = 0;
106 virtual void updateAnimation(
float percent,
unsigned repeat, SVGSMILElement* resultElement) = 0;
107 virtual void endedActiveInterval() = 0;
110 SMILTime findInstanceTime(BeginOrEnd beginOrEnd, SMILTime minimumTime,
bool equalsMinimumOK)
const;
111 void resolveFirstInterval();
112 void resolveNextInterval();
113 void resolveInterval(
bool first, SMILTime& beginResult, SMILTime& endResult)
const;
114 SMILTime resolveActiveEnd(SMILTime resolvedBegin, SMILTime resolvedEnd)
const;
115 SMILTime repeatingDuration()
const;
116 void checkRestart(SMILTime elapsed);
117 void beginListChanged();
118 void endListChanged();
124 enum Type { EventBase, Syncbase, AccessKey };
125 Condition(
Type, BeginOrEnd beginOrEnd,
const String& baseID,
const String& name, SMILTime offset,
int repeats = -1);
127 BeginOrEnd m_beginOrEnd;
132 RefPtr<Element> m_syncbase;
133 RefPtr<ConditionEventListener> m_eventListener;
135 bool parseCondition(
const String&, BeginOrEnd beginOrEnd);
136 void parseBeginOrEnd(
const String&, BeginOrEnd beginOrEnd);
138 void connectConditions();
139 void disconnectConditions();
142 void handleConditionEvent(Event*, Condition*);
145 enum NewOrExistingInterval { NewInterval, ExistingInterval };
146 void notifyDependentsIntervalChanged(NewOrExistingInterval);
147 void createInstanceTimesFromSyncbase(SVGSMILElement* syncbase, NewOrExistingInterval);
148 void addTimeDependent(SVGSMILElement*);
149 void removeTimeDependent(SVGSMILElement*);
151 enum ActiveState { Inactive, Active, Frozen };
152 ActiveState determineActiveState(SMILTime elapsed)
const;
153 float calculateAnimationPercentAndRepeat(SMILTime elapsed,
unsigned& repeat)
const;
154 SMILTime calculateNextProgressTime(SMILTime elapsed)
const;
156 Vector<Condition> m_conditions;
157 bool m_conditionsConnected;
158 bool m_hasEndEventConditions;
160 typedef HashSet<SVGSMILElement*> TimeDependentSet;
161 TimeDependentSet m_timeDependents;
164 Vector<SMILTime> m_beginTimes;
165 Vector<SMILTime> m_endTimes;
168 SMILTime m_intervalBegin;
169 SMILTime m_intervalEnd;
171 SMILTime m_previousIntervalBegin;
173 bool m_isWaitingForFirstInterval;
175 ActiveState m_activeState;
177 unsigned m_lastRepeat;
179 SMILTime m_nextProgressTime;
181 RefPtr<SMILTimeContainer> m_timeContainer;
182 unsigned m_documentOrderIndex;
184 mutable SMILTime m_cachedDur;
185 mutable SMILTime m_cachedRepeatDur;
186 mutable SMILTime m_cachedRepeatCount;
187 mutable SMILTime m_cachedMin;
188 mutable SMILTime m_cachedMax;
190 friend class ConditionEventListener;