KHTML
SVGElementInstance.h
Go to the documentation of this file.
00001 /* 00002 Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> 00003 00004 This file is part of the KDE project 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #ifndef SVGElementInstance_h 00023 #define SVGElementInstance_h 00024 00025 #if ENABLE(SVG) 00026 00027 /*#include "EventTarget.h"*/ 00028 #include "Document.h" //khtml 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 /*: public EventTarget*/ { 00039 public: 00040 SVGElementInstance(SVGUseElement*, PassRefPtr<SVGElement> originalElement); 00041 virtual ~SVGElementInstance(); 00042 00043 // 'SVGElementInstance' functions 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 // Internal usage only! 00057 SVGElement* shadowTreeElement() const; 00058 void setShadowTreeElement(SVGElement*); 00059 00060 // Model the TreeShared concept, integrated within EventTarget inheritance. 00061 virtual void refEventTarget() { ++m_refCount; } 00062 virtual void derefEventTarget() { if (--m_refCount <= 0 && !m_parent) delete this; } 00063 // khtml compat 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 // SVGElementInstance supports both toSVGElementInstance and toNode since so much mouse handling code depends on toNode returning a valid node. 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: // Helper methods 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 } // namespace WebCore 00108 00109 #endif // ENABLE(SVG) 00110 #endif 00111 00112 // vim:ts=4:noet
KDE 4.6 API Reference