KHtml

SVGElementInstance.h
1 /*
2  Copyright (C) 2007 Nikolas Zimmermann <[email protected]>
3 
4  This file is part of the KDE project
5 
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.
10 
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.
15 
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.
20 */
21 
22 #ifndef SVGElementInstance_h
23 #define SVGElementInstance_h
24 
25 #if ENABLE(SVG)
26 
27 /*#include "EventTarget.h"*/
28 #include "Document.h" //khtml
29 
30 #include <wtf/RefPtr.h>
31 #include <wtf/PassRefPtr.h>
32 
33 namespace WebCore
34 {
35 class SVGElement;
36 class SVGUseElement;
37 class SVGElementInstanceList;
38 
39 class SVGElementInstance /*: public EventTarget*/
40 {
41 public:
42  SVGElementInstance(SVGUseElement *, PassRefPtr<SVGElement> originalElement);
43  virtual ~SVGElementInstance();
44 
45  // 'SVGElementInstance' functions
46  SVGElement *correspondingElement() const;
47  SVGUseElement *correspondingUseElement() const;
48 
49  SVGElementInstance *parentNode() const;
50  PassRefPtr<SVGElementInstanceList> childNodes();
51 
52  SVGElementInstance *previousSibling() const;
53  SVGElementInstance *nextSibling() const;
54 
55  SVGElementInstance *firstChild() const;
56  SVGElementInstance *lastChild() const;
57 
58  // Internal usage only!
59  SVGElement *shadowTreeElement() const;
60  void setShadowTreeElement(SVGElement *);
61 
62  // Model the TreeShared concept, integrated within EventTarget inheritance.
63  virtual void refEventTarget()
64  {
65  ++m_refCount;
66  }
67  virtual void derefEventTarget()
68  {
69  if (--m_refCount <= 0 && !m_parent) {
70  delete this;
71  }
72  }
73  // khtml compat
74  virtual void ref()
75  {
76  refEventTarget();
77  }
78  virtual void deref()
79  {
80  derefEventTarget();
81  }
82 
83  bool hasOneRef()
84  {
85  return m_refCount == 1;
86  }
87  int refCount() const
88  {
89  return m_refCount;
90  }
91 
92  void setParent(SVGElementInstance *parent)
93  {
94  m_parent = parent;
95  }
96  SVGElementInstance *parent() const
97  {
98  return m_parent;
99  }
100 
101  // SVGElementInstance supports both toSVGElementInstance and toNode since so much mouse handling code depends on toNode returning a valid node.
102  virtual EventTargetNode *toNode();
103  virtual SVGElementInstance *toSVGElementInstance();
104 
105  virtual void addEventListener(const AtomicString &eventType, PassRefPtr<EventListener>, bool useCapture);
106  virtual void removeEventListener(const AtomicString &eventType, EventListener *, bool useCapture);
107  virtual bool dispatchEvent(PassRefPtr<Event>, ExceptionCode &, bool tempEvent = false);
108 
109 private:
110  SVGElementInstance(const SVGElementInstance &);
111  SVGElementInstance &operator=(const SVGElementInstance &);
112 
113 private: // Helper methods
114  friend class SVGUseElement;
115  void appendChild(PassRefPtr<SVGElementInstance> child);
116 
117  friend class SVGStyledElement;
118  void updateInstance(SVGElement *);
119 
120 private:
121  int m_refCount;
122  SVGElementInstance *m_parent;
123 
124  SVGUseElement *m_useElement;
125  RefPtr<SVGElement> m_element;
126  SVGElement *m_shadowTreeElement;
127 
128  SVGElementInstance *m_previousSibling;
129  SVGElementInstance *m_nextSibling;
130 
131  SVGElementInstance *m_firstChild;
132  SVGElementInstance *m_lastChild;
133 };
134 
135 } // namespace WebCore
136 
137 #endif // ENABLE(SVG)
138 #endif
139 
void ref()
void deref()
MESSAGECORE_EXPORT KMime::Content * firstChild(const KMime::Content *node)
MESSAGECORE_EXPORT KMime::Content * nextSibling(const KMime::Content *node)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:48:09 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.