dom_node.h
00001 /* 00002 * This file is part of the DOM implementation for KDE. 00003 * 00004 * (C) 1999 Lars Knoll (knoll@kde.org) 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 * This file includes excerpts from the Document Object Model (DOM) 00022 * Level 1 Specification (Recommendation) 00023 * http://www.w3.org/TR/REC-DOM-Level-1/ 00024 * Copyright World Wide Web Consortium , (Massachusetts Institute of 00025 * Technology , Institut National de Recherche en Informatique et en 00026 * Automatique , Keio University ). All Rights Reserved. 00027 * 00028 * This file includes excerpts from the Document Object Model (DOM) 00029 * Level 3 Core Specification (Recommendation) 00030 * http://www.w3.org/TR/DOM-Level-3-Core/ 00031 * Copyright ©2004 W3C® (MIT, ERCIM, Keio), All Rights Reserved. 00032 */ 00033 #ifndef _DOM_Node_h_ 00034 #define _DOM_Node_h_ 00035 00036 #include <tqstring.h> 00037 #include <tdelibs_export.h> 00038 00039 class TQRect; 00040 00041 namespace KJS { 00042 class HTMLDocument; 00043 class Window; 00044 } 00045 namespace DOM { 00046 00047 class Node; 00048 class DOMString; 00049 class NodeImpl; 00050 class NamedNodeMapImpl; 00051 class EventListener; 00052 class Event; 00053 00066 class TDEHTML_EXPORT NamedNodeMap 00067 { 00068 public: 00069 NamedNodeMap(); 00070 NamedNodeMap(const NamedNodeMap &other); 00071 00072 NamedNodeMap & operator = (const NamedNodeMap &other); 00073 00074 ~NamedNodeMap(); 00075 00081 unsigned long length() const; 00082 00093 Node getNamedItem ( const DOMString &name ) const; 00094 00127 Node setNamedItem ( const Node &arg ); 00128 00144 Node removeNamedItem ( const DOMString &name ); 00145 00158 Node item ( unsigned long index ) const; 00159 00173 Node getNamedItemNS( const DOMString &namespaceURI, 00174 const DOMString &localName ) const; 00175 00200 Node setNamedItemNS( const Node &arg ); 00201 00226 Node removeNamedItemNS( const DOMString &namespaceURI, 00227 const DOMString &localName ); 00228 00233 NamedNodeMapImpl *handle() const { return impl; } 00234 bool isNull() const { return !impl; } 00235 00236 protected: 00237 NamedNodeMap( NamedNodeMapImpl *i); 00238 NamedNodeMapImpl *impl; 00239 00240 friend class Node; 00241 friend class DocumentType; 00242 friend class NodeImpl; 00243 }; 00244 00245 class NamedNodeMap; 00246 class NodeList; 00247 class Document; 00248 class DOMString; 00249 class StyleSheet; 00250 00251 class NodeImpl; 00252 00274 class TDEHTML_EXPORT Node 00275 { 00276 friend class NamedNodeMap; 00277 friend class NodeList; 00278 friend class HTMLCollection; 00279 friend class StyleSheet; 00280 00281 public: 00282 Node() : impl(0) {} 00283 Node(const Node &other); 00284 00288 Node( NodeImpl *_impl); 00289 00290 Node & operator = (const Node &other); 00291 00292 bool operator == (const Node &other) const; 00293 00294 bool operator != (const Node &other) const; 00295 00296 virtual ~Node(); 00385 enum NodeType { 00386 ELEMENT_NODE = 1, 00387 ATTRIBUTE_NODE = 2, 00388 TEXT_NODE = 3, 00389 CDATA_SECTION_NODE = 4, 00390 ENTITY_REFERENCE_NODE = 5, 00391 ENTITY_NODE = 6, 00392 PROCESSING_INSTRUCTION_NODE = 7, 00393 COMMENT_NODE = 8, 00394 DOCUMENT_NODE = 9, 00395 DOCUMENT_TYPE_NODE = 10, 00396 DOCUMENT_FRAGMENT_NODE = 11, 00397 NOTATION_NODE = 12 00398 }; 00399 00405 DOMString nodeName() const; 00406 00417 DOMString nodeValue() const; 00418 00425 void setNodeValue( const DOMString & ); 00426 00432 unsigned short nodeType() const; 00433 00442 Node parentNode() const; 00443 00457 NodeList childNodes() const; 00458 00464 Node firstChild() const; 00465 00471 Node lastChild() const; 00472 00478 Node previousSibling() const; 00479 00485 Node nextSibling() const; 00486 00493 NamedNodeMap attributes() const; 00494 00502 Document ownerDocument() const; 00503 00538 Node insertBefore ( const Node &newChild, const Node &refChild ); 00539 00568 Node replaceChild ( const Node &newChild, const Node &oldChild ); 00569 00585 Node removeChild ( const Node &oldChild ); 00586 00613 Node appendChild ( const Node &newChild ); 00614 00623 bool hasChildNodes ( ); 00624 00645 Node cloneNode ( bool deep ); 00646 00664 void normalize ( ); 00665 00683 bool isSupported( const DOMString &feature, 00684 const DOMString &version ) const; 00685 00702 DOMString namespaceURI( ) const; 00703 00719 DOMString prefix( ) const; 00720 00738 void setPrefix(const DOMString &prefix ); 00739 00748 DOMString localName( ) const; 00749 00755 bool hasAttributes ( ); 00756 00765 DOMString textContent( ) const; 00766 00783 void setTextContent(const DOMString &content) const; 00784 00813 void addEventListener(const DOMString &type, 00814 EventListener *listener, 00815 const bool useCapture); 00816 00842 void removeEventListener(const DOMString &type, 00843 EventListener *listener, 00844 bool useCapture); 00845 00869 bool dispatchEvent(const Event &evt); 00870 00871 00872 00878 TQ_UINT32 elementId() const; 00879 00892 bool isNull() const { return !impl; } 00893 00897 NodeImpl *handle() const { return impl; } 00898 00902 unsigned long index() const; 00903 TQString toHTML() KDE_DEPRECATED; 00904 void applyChanges(); 00908 void getCursor(int offset, int &_x, int &_y, int &height) KDE_DEPRECATED; 00913 TQRect getRect(); 00914 00915 protected: 00916 NodeImpl *impl; 00917 }; 00918 00919 00920 class NodeListImpl; 00921 00931 class TDEHTML_EXPORT NodeList 00932 { 00933 friend class Element; 00934 friend class Node; 00935 friend class Document; 00936 friend class HTMLDocument; 00937 friend class KJS::HTMLDocument; 00938 friend class KJS::Window; 00939 00940 public: 00941 NodeList(); 00942 NodeList(const NodeList &other); 00943 00944 NodeList & operator = (const NodeList &other); 00945 00946 ~NodeList(); 00947 00953 unsigned long length() const; 00954 00967 Node item ( unsigned long index ) const; 00968 00973 NodeListImpl *handle() const { return impl; } 00974 bool isNull() const { return !impl; } 00975 00976 protected: 00977 NodeList(const NodeListImpl *i); 00978 NodeListImpl *impl; 00979 }; 00980 00981 00982 00987 typedef unsigned long long DOMTimeStamp; 00988 00989 00990 } //namespace 00991 #endif