2 Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
4 This file is part of the KDE project
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
22 #ifndef SVGElementInstance_h
23 #define SVGElementInstance_h
27 /*#include "EventTarget.h"*/
28 #include "Document.h" //khtml
30 #include <wtf/RefPtr.h>
31 #include <wtf/PassRefPtr.h>
36 class SVGElementInstanceList
;
38 class SVGElementInstance
/*: public EventTarget*/ {
40 SVGElementInstance(SVGUseElement
*, PassRefPtr
<SVGElement
> originalElement
);
41 virtual ~SVGElementInstance();
43 // 'SVGElementInstance' functions
44 SVGElement
* correspondingElement() const;
45 SVGUseElement
* correspondingUseElement() const;
47 SVGElementInstance
* parentNode() const;
48 PassRefPtr
<SVGElementInstanceList
> childNodes();
50 SVGElementInstance
* previousSibling() const;
51 SVGElementInstance
* nextSibling() const;
53 SVGElementInstance
* firstChild() const;
54 SVGElementInstance
* lastChild() const;
56 // Internal usage only!
57 SVGElement
* shadowTreeElement() const;
58 void setShadowTreeElement(SVGElement
*);
60 // Model the TreeShared concept, integrated within EventTarget inheritance.
61 virtual void refEventTarget() { ++m_refCount
; }
62 virtual void derefEventTarget() { if (--m_refCount
<= 0 && !m_parent
) delete this; }
64 virtual void ref() { refEventTarget(); }
65 virtual void deref() { derefEventTarget(); }
67 bool hasOneRef() { return m_refCount
== 1; }
68 int refCount() const { return m_refCount
; }
70 void setParent(SVGElementInstance
* parent
) { m_parent
= parent
; }
71 SVGElementInstance
* parent() const { return m_parent
; }
73 // SVGElementInstance supports both toSVGElementInstance and toNode since so much mouse handling code depends on toNode returning a valid node.
74 virtual EventTargetNode
* toNode();
75 virtual SVGElementInstance
* toSVGElementInstance();
77 virtual void addEventListener(const AtomicString
& eventType
, PassRefPtr
<EventListener
>, bool useCapture
);
78 virtual void removeEventListener(const AtomicString
& eventType
, EventListener
*, bool useCapture
);
79 virtual bool dispatchEvent(PassRefPtr
<Event
>, ExceptionCode
&, bool tempEvent
= false);
82 SVGElementInstance(const SVGElementInstance
&);
83 SVGElementInstance
& operator=(const SVGElementInstance
&);
85 private: // Helper methods
86 friend class SVGUseElement
;
87 void appendChild(PassRefPtr
<SVGElementInstance
> child
);
89 friend class SVGStyledElement
;
90 void updateInstance(SVGElement
*);
94 SVGElementInstance
* m_parent
;
96 SVGUseElement
* m_useElement
;
97 RefPtr
<SVGElement
> m_element
;
98 SVGElement
* m_shadowTreeElement
;
100 SVGElementInstance
* m_previousSibling
;
101 SVGElementInstance
* m_nextSibling
;
103 SVGElementInstance
* m_firstChild
;
104 SVGElementInstance
* m_lastChild
;
107 } // namespace WebCore
109 #endif // ENABLE(SVG)