| OLD | NEW |
| 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 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 class ConditionEventListener; | 39 class ConditionEventListener; |
| 40 class SMILTimeContainer; | 40 class SMILTimeContainer; |
| 41 class SVGSMILElement; | 41 class SVGSMILElement; |
| 42 | 42 |
| 43 template<typename T> class EventSender; | 43 template<typename T> class EventSender; |
| 44 using SMILEventSender = EventSender<SVGSMILElement>; | 44 using SMILEventSender = EventSender<SVGSMILElement>; |
| 45 | 45 |
| 46 // This class implements SMIL interval timing model as needed for SVG animation. | 46 // This class implements SMIL interval timing model as needed for SVG animation. |
| 47 class CORE_EXPORT SVGSMILElement : public SVGElement, public SVGTests { | 47 class CORE_EXPORT SVGSMILElement : public SVGElement, public SVGTests { |
| 48 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(SVGSMILElement); | 48 USING_GARBAGE_COLLECTED_MIXIN(SVGSMILElement); |
| 49 public: | 49 public: |
| 50 SVGSMILElement(const QualifiedName&, Document&); | 50 SVGSMILElement(const QualifiedName&, Document&); |
| 51 ~SVGSMILElement() override; | 51 ~SVGSMILElement() override; |
| 52 | 52 |
| 53 void parseAttribute(const QualifiedName&, const AtomicString&, const AtomicS
tring&) override; | 53 void parseAttribute(const QualifiedName&, const AtomicString&, const AtomicS
tring&) override; |
| 54 void svgAttributeChanged(const QualifiedName&) override; | 54 void svgAttributeChanged(const QualifiedName&) override; |
| 55 InsertionNotificationRequest insertedInto(ContainerNode*) override; | 55 InsertionNotificationRequest insertedInto(ContainerNode*) override; |
| 56 void removedFrom(ContainerNode*) override; | 56 void removedFrom(ContainerNode*) override; |
| 57 | 57 |
| 58 virtual bool hasValidAttributeType() = 0; | 58 virtual bool hasValidAttributeType() = 0; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 DidNotRestartInterval, | 168 DidNotRestartInterval, |
| 169 DidRestartInterval | 169 DidRestartInterval |
| 170 }; | 170 }; |
| 171 | 171 |
| 172 RestartedInterval maybeRestartInterval(SMILTime elapsed); | 172 RestartedInterval maybeRestartInterval(SMILTime elapsed); |
| 173 void beginListChanged(SMILTime eventTime); | 173 void beginListChanged(SMILTime eventTime); |
| 174 void endListChanged(SMILTime eventTime); | 174 void endListChanged(SMILTime eventTime); |
| 175 | 175 |
| 176 // This represents conditions on elements begin or end list that need to be
resolved on runtime | 176 // This represents conditions on elements begin or end list that need to be
resolved on runtime |
| 177 // for example <animate begin="otherElement.begin + 8s; button.click" ... /> | 177 // for example <animate begin="otherElement.begin + 8s; button.click" ... /> |
| 178 class Condition : public NoBaseWillBeGarbageCollectedFinalized<Condition> { | 178 class Condition : public GarbageCollectedFinalized<Condition> { |
| 179 public: | 179 public: |
| 180 enum Type { | 180 enum Type { |
| 181 EventBase, | 181 EventBase, |
| 182 Syncbase, | 182 Syncbase, |
| 183 AccessKey | 183 AccessKey |
| 184 }; | 184 }; |
| 185 | 185 |
| 186 Condition(Type, BeginOrEnd, const String& baseID, const String& name, SM
ILTime offset, int repeat = -1); | 186 Condition(Type, BeginOrEnd, const String& baseID, const String& name, SM
ILTime offset, int repeat = -1); |
| 187 static PassOwnPtrWillBeRawPtr<Condition> create(Type type, BeginOrEnd be
ginOrEnd, const String& baseID, const String& name, SMILTime offset, int repeat
= -1) | 187 static RawPtr<Condition> create(Type type, BeginOrEnd beginOrEnd, const
String& baseID, const String& name, SMILTime offset, int repeat = -1) |
| 188 { | 188 { |
| 189 return adoptPtrWillBeNoop(new Condition(type, beginOrEnd, baseID, na
me, offset, repeat)); | 189 return new Condition(type, beginOrEnd, baseID, name, offset, repeat)
; |
| 190 } | 190 } |
| 191 ~Condition(); | 191 ~Condition(); |
| 192 DECLARE_TRACE(); | 192 DECLARE_TRACE(); |
| 193 | 193 |
| 194 Type getType() const { return m_type; } | 194 Type getType() const { return m_type; } |
| 195 BeginOrEnd getBeginOrEnd() const { return m_beginOrEnd; } | 195 BeginOrEnd getBeginOrEnd() const { return m_beginOrEnd; } |
| 196 String baseID() const { return m_baseID; } | 196 String baseID() const { return m_baseID; } |
| 197 String name() const { return m_name; } | 197 String name() const { return m_name; } |
| 198 SMILTime offset() const { return m_offset; } | 198 SMILTime offset() const { return m_offset; } |
| 199 int repeat() const { return m_repeat; } | 199 int repeat() const { return m_repeat; } |
| 200 SVGSMILElement* syncBase() const { return m_syncBase.get(); } | 200 SVGSMILElement* syncBase() const { return m_syncBase.get(); } |
| 201 void setSyncBase(SVGSMILElement* element) { m_syncBase = element; } | 201 void setSyncBase(SVGSMILElement* element) { m_syncBase = element; } |
| 202 ConditionEventListener* eventListener() const { return m_eventListener.g
et(); } | 202 ConditionEventListener* eventListener() const { return m_eventListener.g
et(); } |
| 203 void setEventListener(PassRefPtrWillBeRawPtr<ConditionEventListener>); | 203 void setEventListener(RawPtr<ConditionEventListener>); |
| 204 | 204 |
| 205 private: | 205 private: |
| 206 Type m_type; | 206 Type m_type; |
| 207 BeginOrEnd m_beginOrEnd; | 207 BeginOrEnd m_beginOrEnd; |
| 208 String m_baseID; | 208 String m_baseID; |
| 209 String m_name; | 209 String m_name; |
| 210 SMILTime m_offset; | 210 SMILTime m_offset; |
| 211 int m_repeat; | 211 int m_repeat; |
| 212 RefPtrWillBeMember<SVGSMILElement> m_syncBase; | 212 Member<SVGSMILElement> m_syncBase; |
| 213 RefPtrWillBeMember<ConditionEventListener> m_eventListener; | 213 Member<ConditionEventListener> m_eventListener; |
| 214 }; | 214 }; |
| 215 bool parseCondition(const String&, BeginOrEnd beginOrEnd); | 215 bool parseCondition(const String&, BeginOrEnd beginOrEnd); |
| 216 void parseBeginOrEnd(const String&, BeginOrEnd beginOrEnd); | 216 void parseBeginOrEnd(const String&, BeginOrEnd beginOrEnd); |
| 217 SVGElement* eventBaseFor(const Condition&); | 217 SVGElement* eventBaseFor(const Condition&); |
| 218 | 218 |
| 219 void disconnectSyncBaseConditions(); | 219 void disconnectSyncBaseConditions(); |
| 220 void disconnectEventBaseConditions(); | 220 void disconnectEventBaseConditions(); |
| 221 | 221 |
| 222 // Event base timing | 222 // Event base timing |
| 223 void handleConditionEvent(Event*, Condition*); | 223 void handleConditionEvent(Event*, Condition*); |
| 224 | 224 |
| 225 void notifyDependentsIntervalChanged(); | 225 void notifyDependentsIntervalChanged(); |
| 226 void createInstanceTimesFromSyncbase(SVGSMILElement* syncbase); | 226 void createInstanceTimesFromSyncbase(SVGSMILElement* syncbase); |
| 227 void addSyncBaseDependent(SVGSMILElement*); | 227 void addSyncBaseDependent(SVGSMILElement*); |
| 228 void removeSyncBaseDependent(SVGSMILElement*); | 228 void removeSyncBaseDependent(SVGSMILElement*); |
| 229 | 229 |
| 230 enum ActiveState { | 230 enum ActiveState { |
| 231 Inactive, | 231 Inactive, |
| 232 Active, | 232 Active, |
| 233 Frozen | 233 Frozen |
| 234 }; | 234 }; |
| 235 | 235 |
| 236 QualifiedName m_attributeName; | 236 QualifiedName m_attributeName; |
| 237 | 237 |
| 238 ActiveState determineActiveState(SMILTime elapsed) const; | 238 ActiveState determineActiveState(SMILTime elapsed) const; |
| 239 float calculateAnimationPercentAndRepeat(SMILTime elapsed, unsigned& repeat)
const; | 239 float calculateAnimationPercentAndRepeat(SMILTime elapsed, unsigned& repeat)
const; |
| 240 SMILTime calculateNextProgressTime(SMILTime elapsed) const; | 240 SMILTime calculateNextProgressTime(SMILTime elapsed) const; |
| 241 | 241 |
| 242 RawPtrWillBeMember<SVGElement> m_targetElement; | 242 Member<SVGElement> m_targetElement; |
| 243 | 243 |
| 244 WillBeHeapVector<OwnPtrWillBeMember<Condition>> m_conditions; | 244 HeapVector<Member<Condition>> m_conditions; |
| 245 bool m_syncBaseConditionsConnected; | 245 bool m_syncBaseConditionsConnected; |
| 246 bool m_hasEndEventConditions; | 246 bool m_hasEndEventConditions; |
| 247 | 247 |
| 248 bool m_isWaitingForFirstInterval; | 248 bool m_isWaitingForFirstInterval; |
| 249 bool m_isScheduled; | 249 bool m_isScheduled; |
| 250 | 250 |
| 251 using TimeDependentSet = WillBeHeapHashSet<RawPtrWillBeMember<SVGSMILElement
>>; | 251 using TimeDependentSet = HeapHashSet<Member<SVGSMILElement>>; |
| 252 TimeDependentSet m_syncBaseDependents; | 252 TimeDependentSet m_syncBaseDependents; |
| 253 | 253 |
| 254 // Instance time lists | 254 // Instance time lists |
| 255 Vector<SMILTimeWithOrigin> m_beginTimes; | 255 Vector<SMILTimeWithOrigin> m_beginTimes; |
| 256 Vector<SMILTimeWithOrigin> m_endTimes; | 256 Vector<SMILTimeWithOrigin> m_endTimes; |
| 257 | 257 |
| 258 // This is the upcoming or current interval | 258 // This is the upcoming or current interval |
| 259 SMILInterval m_interval; | 259 SMILInterval m_interval; |
| 260 | 260 |
| 261 SMILTime m_previousIntervalBegin; | 261 SMILTime m_previousIntervalBegin; |
| 262 | 262 |
| 263 ActiveState m_activeState; | 263 ActiveState m_activeState; |
| 264 float m_lastPercent; | 264 float m_lastPercent; |
| 265 unsigned m_lastRepeat; | 265 unsigned m_lastRepeat; |
| 266 | 266 |
| 267 SMILTime m_nextProgressTime; | 267 SMILTime m_nextProgressTime; |
| 268 | 268 |
| 269 RefPtrWillBeMember<SMILTimeContainer> m_timeContainer; | 269 Member<SMILTimeContainer> m_timeContainer; |
| 270 unsigned m_documentOrderIndex; | 270 unsigned m_documentOrderIndex; |
| 271 | 271 |
| 272 Vector<unsigned> m_repeatEventCountList; | 272 Vector<unsigned> m_repeatEventCountList; |
| 273 | 273 |
| 274 mutable SMILTime m_cachedDur; | 274 mutable SMILTime m_cachedDur; |
| 275 mutable SMILTime m_cachedRepeatDur; | 275 mutable SMILTime m_cachedRepeatDur; |
| 276 mutable SMILTime m_cachedRepeatCount; | 276 mutable SMILTime m_cachedRepeatCount; |
| 277 mutable SMILTime m_cachedMin; | 277 mutable SMILTime m_cachedMin; |
| 278 mutable SMILTime m_cachedMax; | 278 mutable SMILTime m_cachedMax; |
| 279 | 279 |
| 280 friend class ConditionEventListener; | 280 friend class ConditionEventListener; |
| 281 }; | 281 }; |
| 282 | 282 |
| 283 inline bool isSVGSMILElement(const SVGElement& element) | 283 inline bool isSVGSMILElement(const SVGElement& element) |
| 284 { | 284 { |
| 285 return element.hasTagName(SVGNames::setTag) || element.hasTagName(SVGNames::
animateTag) || element.hasTagName(SVGNames::animateMotionTag) | 285 return element.hasTagName(SVGNames::setTag) || element.hasTagName(SVGNames::
animateTag) || element.hasTagName(SVGNames::animateMotionTag) |
| 286 || element.hasTagName(SVGNames::animateTransformTag) || element.hasTagNa
me((SVGNames::discardTag)); | 286 || element.hasTagName(SVGNames::animateTransformTag) || element.hasTagNa
me((SVGNames::discardTag)); |
| 287 } | 287 } |
| 288 | 288 |
| 289 DEFINE_SVGELEMENT_TYPE_CASTS_WITH_FUNCTION(SVGSMILElement); | 289 DEFINE_SVGELEMENT_TYPE_CASTS_WITH_FUNCTION(SVGSMILElement); |
| 290 | 290 |
| 291 } // namespace blink | 291 } // namespace blink |
| 292 | 292 |
| 293 #endif // SVGSMILElement_h | 293 #endif // SVGSMILElement_h |
| OLD | NEW |