KHTML
SVGElementInstance.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef SVGElementInstance_h
00023 #define SVGElementInstance_h
00024
00025 #if ENABLE(SVG)
00026
00027
00028 #include "Document.h"
00029
00030 #include <wtf/RefPtr.h>
00031 #include <wtf/PassRefPtr.h>
00032
00033 namespace WebCore {
00034 class SVGElement;
00035 class SVGUseElement;
00036 class SVGElementInstanceList;
00037
00038 class SVGElementInstance {
00039 public:
00040 SVGElementInstance(SVGUseElement*, PassRefPtr<SVGElement> originalElement);
00041 virtual ~SVGElementInstance();
00042
00043
00044 SVGElement* correspondingElement() const;
00045 SVGUseElement* correspondingUseElement() const;
00046
00047 SVGElementInstance* parentNode() const;
00048 PassRefPtr<SVGElementInstanceList> childNodes();
00049
00050 SVGElementInstance* previousSibling() const;
00051 SVGElementInstance* nextSibling() const;
00052
00053 SVGElementInstance* firstChild() const;
00054 SVGElementInstance* lastChild() const;
00055
00056
00057 SVGElement* shadowTreeElement() const;
00058 void setShadowTreeElement(SVGElement*);
00059
00060
00061 virtual void refEventTarget() { ++m_refCount; }
00062 virtual void derefEventTarget() { if (--m_refCount <= 0 && !m_parent) delete this; }
00063
00064 virtual void ref() { refEventTarget(); }
00065 virtual void deref() { derefEventTarget(); }
00066
00067 bool hasOneRef() { return m_refCount == 1; }
00068 int refCount() const { return m_refCount; }
00069
00070 void setParent(SVGElementInstance* parent) { m_parent = parent; }
00071 SVGElementInstance* parent() const { return m_parent; }
00072
00073
00074 virtual EventTargetNode* toNode();
00075 virtual SVGElementInstance* toSVGElementInstance();
00076
00077 virtual void addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture);
00078 virtual void removeEventListener(const AtomicString& eventType, EventListener*, bool useCapture);
00079 virtual bool dispatchEvent(PassRefPtr<Event>, ExceptionCode&, bool tempEvent = false);
00080
00081 private:
00082 SVGElementInstance(const SVGElementInstance&);
00083 SVGElementInstance& operator=(const SVGElementInstance&);
00084
00085 private:
00086 friend class SVGUseElement;
00087 void appendChild(PassRefPtr<SVGElementInstance> child);
00088
00089 friend class SVGStyledElement;
00090 void updateInstance(SVGElement*);
00091
00092 private:
00093 int m_refCount;
00094 SVGElementInstance* m_parent;
00095
00096 SVGUseElement* m_useElement;
00097 RefPtr<SVGElement> m_element;
00098 SVGElement* m_shadowTreeElement;
00099
00100 SVGElementInstance* m_previousSibling;
00101 SVGElementInstance* m_nextSibling;
00102
00103 SVGElementInstance* m_firstChild;
00104 SVGElementInstance* m_lastChild;
00105 };
00106
00107 }
00108
00109 #endif // ENABLE(SVG)
00110 #endif
00111
00112