KHTML
dom_node.h
Go to the documentation of this file.
00001 /* 00002 * This file is part of the DOM implementation for KDE. 00003 * 00004 * Copyright 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 */ 00029 #ifndef _DOM_Node_h_ 00030 #define _DOM_Node_h_ 00031 00032 #include <khtml_export.h> 00033 #include <QtCore/QString> 00034 00035 class QRect; 00036 00037 namespace KJS { 00038 class HTMLDocument; 00039 class Window; 00040 } 00041 namespace DOM { 00042 00043 class Node; 00044 class DOMString; 00045 class NodeImpl; 00046 class NamedNodeMapImpl; 00047 class EventListener; 00048 class Event; 00049 00062 class KHTML_EXPORT NamedNodeMap 00063 { 00064 public: 00065 NamedNodeMap(); 00066 NamedNodeMap(const NamedNodeMap &other); 00067 00068 NamedNodeMap & operator = (const NamedNodeMap &other); 00069 00070 ~NamedNodeMap(); 00071 00077 unsigned long length() const; 00078 00089 Node getNamedItem ( const DOMString &name ) const; 00090 00123 Node setNamedItem ( const Node &arg ); 00124 00140 Node removeNamedItem ( const DOMString &name ); 00141 00154 Node item ( unsigned long index ) const; 00155 00169 Node getNamedItemNS( const DOMString &namespaceURI, 00170 const DOMString &localName ) const; 00171 00196 Node setNamedItemNS( const Node &arg ); 00197 00222 Node removeNamedItemNS( const DOMString &namespaceURI, 00223 const DOMString &localName ); 00224 00229 NamedNodeMapImpl *handle() const { return impl; } 00230 bool isNull() const { return !impl; } 00231 00232 protected: 00233 NamedNodeMap( NamedNodeMapImpl *i); 00234 NamedNodeMapImpl *impl; 00235 00236 friend class Node; 00237 friend class DocumentType; 00238 friend class NodeImpl; 00239 }; 00240 00241 class NamedNodeMap; 00242 class NodeList; 00243 class Document; 00244 class DOMString; 00245 class StyleSheet; 00246 00247 class NodeImpl; 00248 00270 class KHTML_EXPORT Node 00271 { 00272 friend class NamedNodeMap; 00273 friend class NodeList; 00274 friend class HTMLCollection; 00275 friend class StyleSheet; 00276 00277 public: 00278 Node() : impl(0) {} 00279 Node(const Node &other); 00280 00284 Node( NodeImpl *_impl); 00285 00286 Node & operator = (const Node &other); 00287 00288 bool operator == (const Node &other) const; 00289 00290 bool operator != (const Node &other) const; 00291 00292 virtual ~Node(); 00381 enum NodeType { 00382 ELEMENT_NODE = 1, 00383 ATTRIBUTE_NODE = 2, 00384 TEXT_NODE = 3, 00385 CDATA_SECTION_NODE = 4, 00386 ENTITY_REFERENCE_NODE = 5, 00387 ENTITY_NODE = 6, 00388 PROCESSING_INSTRUCTION_NODE = 7, 00389 COMMENT_NODE = 8, 00390 DOCUMENT_NODE = 9, 00391 DOCUMENT_TYPE_NODE = 10, 00392 DOCUMENT_FRAGMENT_NODE = 11, 00393 NOTATION_NODE = 12, 00394 XPATH_NAMESPACE_NODE = 13 //< Part of DOM L3 XPath, @since 4.5 00395 }; 00396 00402 DOMString nodeName() const; 00403 00414 DOMString nodeValue() const; 00415 00422 void setNodeValue( const DOMString & ); 00423 00429 unsigned short nodeType() const; 00430 00439 Node parentNode() const; 00440 00454 NodeList childNodes() const; 00455 00461 Node firstChild() const; 00462 00468 Node lastChild() const; 00469 00475 Node previousSibling() const; 00476 00482 Node nextSibling() const; 00483 00490 NamedNodeMap attributes() const; 00491 00499 Document ownerDocument() const; 00500 00535 Node insertBefore ( const Node &newChild, const Node &refChild ); 00536 00565 Node replaceChild ( const Node &newChild, const Node &oldChild ); 00566 00582 Node removeChild ( const Node &oldChild ); 00583 00610 Node appendChild ( const Node &newChild ); 00611 00620 bool hasChildNodes ( ); 00621 00642 Node cloneNode ( bool deep ); 00643 00661 void normalize ( ); 00662 00680 bool isSupported( const DOMString &feature, 00681 const DOMString &version ) const; 00682 00699 DOMString namespaceURI( ) const; 00700 00716 DOMString prefix( ) const; 00717 00735 void setPrefix(const DOMString &prefix ); 00736 00745 DOMString localName( ) const; 00746 00752 bool hasAttributes ( ); 00753 00782 void addEventListener(const DOMString &type, 00783 EventListener *listener, 00784 const bool useCapture); 00785 00811 void removeEventListener(const DOMString &type, 00812 EventListener *listener, 00813 bool useCapture); 00814 00838 bool dispatchEvent(const Event &evt); 00839 00857 DOMString textContent() const; 00858 00865 void setTextContent(const DOMString& text); 00866 00875 enum DocumentPosition { 00876 DOCUMENT_POSITION_DISCONNECTED = 0x01, 00877 DOCUMENT_POSITION_PRECEDING = 0x02, 00878 DOCUMENT_POSITION_FOLLOWING = 0x04, 00879 DOCUMENT_POSITION_CONTAINS = 0x08, 00880 DOCUMENT_POSITION_CONTAINED_BY = 0x10, 00881 DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20 00882 }; 00883 00899 unsigned compareDocumentPosition(const DOM::Node& other); 00900 00906 quint32 elementId() const; 00907 00920 bool isNull() const { return !impl; } 00921 00925 NodeImpl *handle() const { return impl; } 00926 00930 unsigned long index() const; 00931 #ifndef KDE_NO_DEPRECATED 00932 KDE_DEPRECATED QString toHTML(); 00933 #endif 00934 void applyChanges(); 00938 #ifndef KDE_NO_DEPRECATED 00939 KDE_DEPRECATED void getCursor(int offset, int &_x, int &_y, int &height); 00940 #endif 00941 00945 QRect getRect(); 00946 00947 protected: 00948 NodeImpl *impl; 00949 }; 00950 00951 00952 class NodeListImpl; 00953 00963 class KHTML_EXPORT NodeList 00964 { 00965 friend class Element; 00966 friend class Node; 00967 friend class Document; 00968 friend class DocumentFragment; 00969 friend class HTMLDocument; 00970 friend class KJS::HTMLDocument; 00971 friend class KJS::Window; 00972 00973 public: 00974 NodeList(); 00975 NodeList(const NodeList &other); 00976 00977 NodeList & operator = (const NodeList &other); 00978 00979 ~NodeList(); 00980 00986 unsigned long length() const; 00987 01000 Node item ( unsigned long index ) const; 01001 01006 NodeListImpl *handle() const { return impl; } 01007 bool isNull() const { return !impl; } 01008 01009 protected: 01010 NodeList(const NodeListImpl *i); 01011 NodeListImpl *impl; 01012 }; 01013 01014 01015 01020 typedef unsigned long long DOMTimeStamp; 01021 01022 01023 } //namespace 01024 #endif
KDE 4.6 API Reference