diff options
Diffstat (limited to 'Source/WebCore/svg/animation/SVGSMILElement.h')
-rw-r--r-- | Source/WebCore/svg/animation/SVGSMILElement.h | 102 |
1 files changed, 43 insertions, 59 deletions
diff --git a/Source/WebCore/svg/animation/SVGSMILElement.h b/Source/WebCore/svg/animation/SVGSMILElement.h index b8d38236b..cb7bd159e 100644 --- a/Source/WebCore/svg/animation/SVGSMILElement.h +++ b/Source/WebCore/svg/animation/SVGSMILElement.h @@ -23,18 +23,21 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SVGSMILElement_h -#define SVGSMILElement_h -#if ENABLE(SVG) +#pragma once + #include "SMILTime.h" #include "SVGElement.h" - -#include <wtf/HashMap.h> +#include <wtf/HashSet.h> namespace WebCore { class ConditionEventListener; class SMILTimeContainer; +class SVGSMILElement; + +template<typename T> class EventSender; + +using SMILEventSender = EventSender<SVGSMILElement>; // This class implements SMIL interval timing model as needed for SVG animation. class SVGSMILElement : public SVGElement { @@ -42,36 +45,26 @@ public: SVGSMILElement(const QualifiedName&, Document&); virtual ~SVGSMILElement(); - bool isSupportedAttribute(const QualifiedName&); - virtual void parseAttribute(const QualifiedName&, const AtomicString&) override; - virtual void svgAttributeChanged(const QualifiedName&) override; - virtual InsertionNotificationRequest insertedInto(ContainerNode&) override; - virtual void removedFrom(ContainerNode&) override; + void parseAttribute(const QualifiedName&, const AtomicString&) override; + void svgAttributeChanged(const QualifiedName&) override; + InsertionNotificationRequest insertedInto(ContainerNode&) override; + void removedFrom(ContainerNode&) override; virtual bool hasValidAttributeType() = 0; virtual bool hasValidAttributeName(); virtual void animationAttributeChanged() = 0; - SMILTimeContainer* timeContainer() const { return m_timeContainer.get(); } + SMILTimeContainer* timeContainer() { return m_timeContainer.get(); } SVGElement* targetElement() const { return m_targetElement; } const QualifiedName& attributeName() const { return m_attributeName; } void beginByLinkActivation(); - enum Restart { - RestartAlways, - RestartWhenNotActive, - RestartNever - }; - + enum Restart { RestartAlways, RestartWhenNotActive, RestartNever }; Restart restart() const; - enum FillMode { - FillRemove, - FillFreeze - }; - + enum FillMode { FillRemove, FillFreeze }; FillMode fill() const; SMILTime dur() const; @@ -108,28 +101,40 @@ public: virtual void clearAnimatedType(SVGElement* targetElement) = 0; virtual void applyResultsToTarget() = 0; + void connectConditions(); + bool hasConditionsConnected() const { return m_conditionsConnected; } + + void dispatchPendingEvent(SMILEventSender*); + protected: void addBeginTime(SMILTime eventTime, SMILTime endTime, SMILTimeWithOrigin::Origin = SMILTimeWithOrigin::ParserOrigin); void addEndTime(SMILTime eventTime, SMILTime endTime, SMILTimeWithOrigin::Origin = SMILTimeWithOrigin::ParserOrigin); void setInactive() { m_activeState = Inactive; } - virtual bool rendererIsNeeded(const RenderStyle&) override { return false; } + bool rendererIsNeeded(const RenderStyle&) override { return false; } // Sub-classes may need to take action when the target is changed. virtual void setTargetElement(SVGElement*); virtual void setAttributeName(const QualifiedName&); + void finishedInsertingSubtree() override; + private: void buildPendingResource() override; void clearResourceReferences(); + void clearTarget() override; + virtual void startedActiveInterval() = 0; void endedActiveInterval(); virtual void updateAnimation(float percent, unsigned repeat, SVGSMILElement* resultElement) = 0; + static bool isSupportedAttribute(const QualifiedName&); + QualifiedName constructAttributeName() const; + void updateAttributeName(); + enum BeginOrEnd { Begin, End }; - SMILTime findInstanceTime(BeginOrEnd, SMILTime minimumTime, bool equalsMinimumOK) const; void resolveFirstInterval(); void resolveNextInterval(bool notifyDependents); @@ -143,19 +148,14 @@ private: // This represents conditions on elements begin or end list that need to be resolved on runtime // for example <animate begin="otherElement.begin + 8s; button.click" ... /> struct Condition { - enum Type { - EventBase, - Syncbase, - AccessKey - }; - + enum Type { EventBase, Syncbase, AccessKey }; Condition(Type, BeginOrEnd, const String& baseID, const String& name, SMILTime offset, int repeats = -1); Type m_type; BeginOrEnd m_beginOrEnd; String m_baseID; String m_name; SMILTime m_offset; - int m_repeats; + int m_repeats { -1 }; RefPtr<Element> m_syncbase; RefPtr<ConditionEventListener> m_eventListener; }; @@ -163,38 +163,28 @@ private: void parseBeginOrEnd(const String&, BeginOrEnd beginOrEnd); Element* eventBaseFor(const Condition&); - void connectConditions(); void disconnectConditions(); // Event base timing void handleConditionEvent(Event*, Condition*); // Syncbase timing - enum NewOrExistingInterval { - NewInterval, - ExistingInterval - }; - + enum NewOrExistingInterval { NewInterval, ExistingInterval }; void notifyDependentsIntervalChanged(NewOrExistingInterval); void createInstanceTimesFromSyncbase(SVGSMILElement* syncbase, NewOrExistingInterval); void addTimeDependent(SVGSMILElement*); void removeTimeDependent(SVGSMILElement*); - enum ActiveState { - Inactive, - Active, - Frozen - }; - - QualifiedName m_attributeName; - + enum ActiveState { Inactive, Active, Frozen }; ActiveState determineActiveState(SMILTime elapsed) const; float calculateAnimationPercentAndRepeat(SMILTime elapsed, unsigned& repeat) const; SMILTime calculateNextProgressTime(SMILTime elapsed) const; - virtual bool isSMILElement() const override final { return true; } + bool isSMILElement() const final { return true; } + + QualifiedName m_attributeName; - mutable SVGElement* m_targetElement; + SVGElement* m_targetElement; Vector<Condition> m_conditions; bool m_conditionsConnected; @@ -202,8 +192,7 @@ private: bool m_isWaitingForFirstInterval; - typedef HashSet<SVGSMILElement*> TimeDependentSet; - TimeDependentSet m_timeDependents; + HashSet<SVGSMILElement*> m_timeDependents; // Instance time lists Vector<SMILTimeWithOrigin> m_beginTimes; @@ -233,14 +222,9 @@ private: friend class ConditionEventListener; }; -void isSVGSMILElement(const SVGSMILElement&); // Catch unnecessary runtime check of type known at compile time. -inline bool isSVGSMILElement(const SVGElement& element) { return element.isSMILElement(); } -inline bool isSVGSMILElement(const Node& node) { return node.isSVGElement() && toSVGElement(node).isSMILElement(); } -template <> inline bool isElementOfType<const SVGSMILElement>(const Element& element) { return isSVGSMILElement(element); } - -NODE_TYPE_CASTS(SVGSMILElement) - -} +} // namespace WebCore -#endif // ENABLE(SVG) -#endif // SVGSMILElement_h +SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::SVGSMILElement) + static bool isType(const WebCore::SVGElement& element) { return element.isSMILElement(); } + static bool isType(const WebCore::Node& node) { return is<WebCore::SVGElement>(node) && isType(downcast<WebCore::SVGElement>(node)); } +SPECIALIZE_TYPE_TRAITS_END() |