• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KHTML

  • sources
  • kde-4.12
  • kdelibs
  • khtml
  • svg
  • animation
SVGSMILElement.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 
27 #ifndef SVGSMILElement_h
28 #define SVGSMILElement_h
29 #if ENABLE(SVG_ANIMATION)
30 
31 #include "SVGElement.h"
32 #include "SMILTime.h"
33 #include <wtf/HashMap.h>
34 
35 namespace WebCore {
36 
37  class ConditionEventListener;
38  class SMILTimeContainer;
39 
40  // This class implements SMIL interval timing model as needed for SVG animation.
41  class SVGSMILElement : public SVGElement
42  {
43  public:
44  SVGSMILElement(const QualifiedName&, Document*);
45  virtual ~SVGSMILElement();
46 
47  static bool isSMILElement(Node* node);
48 
49  virtual void parseMappedAttribute(MappedAttribute*);
50  virtual void attributeChanged(Attribute*, bool preserveDecls);
51  virtual void insertedIntoDocument();
52  virtual void removedFromDocument();
53  virtual void finishParsingChildren();
54 
55  SMILTimeContainer* timeContainer() const { return m_timeContainer.get(); }
56 
57  SVGElement* targetElement() const;
58  String attributeName() const;
59 
60  void beginByLinkActivation();
61 
62  enum Restart { RestartAlways, RestartWhenNotActive, RestartNever };
63  Restart restart() const;
64 
65  enum FillMode { FillRemove, FillFreeze };
66  FillMode fill() const;
67 
68  String xlinkHref() const;
69 
70  SMILTime dur() const;
71  SMILTime repeatDur() const;
72  SMILTime repeatCount() const;
73  SMILTime maxValue() const;
74  SMILTime minValue() const;
75 
76  SMILTime elapsed() const;
77 
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;
82 
83  void progress(SMILTime elapsed, SVGSMILElement* resultsElement);
84  SMILTime nextProgressTime() const;
85 
86  static SMILTime parseClockValue(const String&);
87  static SMILTime parseOffsetValue(const String&);
88 
89  bool isContributing(SMILTime elapsed) const;
90  bool isInactive() const;
91  bool isFrozen() const;
92 
93  unsigned documentOrderIndex() const { return m_documentOrderIndex; }
94  void setDocumentOrderIndex(unsigned index) { m_documentOrderIndex = index; }
95 
96  virtual bool isAdditive() const = 0;
97  virtual void resetToBaseValue(const String&) = 0;
98  virtual void applyResultsToTarget() = 0;
99 
100 protected:
101  void addBeginTime(SMILTime time);
102  void addEndTime(SMILTime time);
103 
104 private:
105  virtual void startedActiveInterval() = 0;
106  virtual void updateAnimation(float percent, unsigned repeat, SVGSMILElement* resultElement) = 0;
107  virtual void endedActiveInterval() = 0;
108 
109  enum BeginOrEnd { Begin, End };
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();
119  void reschedule();
120 
121  // This represents conditions on elements begin or end list that need to be resolved on runtime
122  // for example <animate begin="otherElement.begin + 8s; button.click" ... />
123  struct Condition {
124  enum Type { EventBase, Syncbase, AccessKey };
125  Condition(Type, BeginOrEnd beginOrEnd, const String& baseID, const String& name, SMILTime offset, int repeats = -1);
126  Type m_type;
127  BeginOrEnd m_beginOrEnd;
128  String m_baseID;
129  String m_name;
130  SMILTime m_offset;
131  int m_repeats;
132  RefPtr<Element> m_syncbase;
133  RefPtr<ConditionEventListener> m_eventListener;
134  };
135  bool parseCondition(const String&, BeginOrEnd beginOrEnd);
136  void parseBeginOrEnd(const String&, BeginOrEnd beginOrEnd);
137 
138  void connectConditions();
139  void disconnectConditions();
140 
141  // Event base timing
142  void handleConditionEvent(Event*, Condition*);
143 
144  // Syncbase timing
145  enum NewOrExistingInterval { NewInterval, ExistingInterval };
146  void notifyDependentsIntervalChanged(NewOrExistingInterval);
147  void createInstanceTimesFromSyncbase(SVGSMILElement* syncbase, NewOrExistingInterval);
148  void addTimeDependent(SVGSMILElement*);
149  void removeTimeDependent(SVGSMILElement*);
150 
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;
155 
156  Vector<Condition> m_conditions;
157  bool m_conditionsConnected;
158  bool m_hasEndEventConditions;
159 
160  typedef HashSet<SVGSMILElement*> TimeDependentSet;
161  TimeDependentSet m_timeDependents;
162 
163  // Instance time lists
164  Vector<SMILTime> m_beginTimes;
165  Vector<SMILTime> m_endTimes;
166 
167  // This is the upcoming or current interval
168  SMILTime m_intervalBegin;
169  SMILTime m_intervalEnd;
170 
171  SMILTime m_previousIntervalBegin;
172 
173  bool m_isWaitingForFirstInterval;
174 
175  ActiveState m_activeState;
176  float m_lastPercent;
177  unsigned m_lastRepeat;
178 
179  SMILTime m_nextProgressTime;
180 
181  RefPtr<SMILTimeContainer> m_timeContainer;
182  unsigned m_documentOrderIndex;
183 
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;
189 
190  friend class ConditionEventListener;
191  };
192 
193 }
194 
195 #endif
196 #endif
197 
SMILTime.h
Type
Type
End
Begin
SVGElement.h
WebCore::String
DOM::DOMString String
Definition: PlatformString.h:8
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:51:22 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal