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  */
00029 #ifndef _DOM_Node_h_
00030 #define _DOM_Node_h_
00031 
00032 #include <qstring.h>
00033 #include <kdelibs_export.h>
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     };
00395 
00401     DOMString nodeName() const;
00402 
00413     DOMString nodeValue() const;
00414 
00421     void setNodeValue( const DOMString & );
00422 
00428     unsigned short nodeType() const;
00429 
00438     Node parentNode() const;
00439 
00453     NodeList childNodes() const;
00454 
00460     Node firstChild() const;
00461 
00467     Node lastChild() const;
00468 
00474     Node previousSibling() const;
00475 
00481     Node nextSibling() const;
00482 
00489     NamedNodeMap attributes() const;
00490 
00498     Document ownerDocument() const;
00499 
00534     Node insertBefore ( const Node &newChild, const Node &refChild );
00535 
00564     Node replaceChild ( const Node &newChild, const Node &oldChild );
00565 
00581     Node removeChild ( const Node &oldChild );
00582 
00609     Node appendChild ( const Node &newChild );
00610 
00619     bool hasChildNodes (  );
00620 
00641     Node cloneNode ( bool deep );
00642 
00660     void normalize (  );
00661 
00679     bool isSupported( const DOMString &feature,
00680                       const DOMString &version ) const;
00681 
00698     DOMString namespaceURI(  ) const;
00699 
00715     DOMString prefix(  ) const;
00716 
00734     void setPrefix(const DOMString &prefix );
00735 
00744     DOMString localName(  ) const;
00745 
00751     bool hasAttributes (  );
00752 
00781     void addEventListener(const DOMString &type,
00782               EventListener *listener,
00783               const bool useCapture);
00784 
00810     void removeEventListener(const DOMString &type,
00811                  EventListener *listener,
00812                  bool useCapture);
00813 
00837     bool dispatchEvent(const Event &evt);
00838 
00844     Q_UINT32 elementId() const;
00845 
00858     bool isNull() const { return !impl; }
00859 
00863     NodeImpl *handle() const { return impl; }
00864 
00868     unsigned long index() const;
00869     QString toHTML() KDE_DEPRECATED;
00870     void applyChanges();
00874     void getCursor(int offset, int &_x, int &_y, int &height) KDE_DEPRECATED;
00879     QRect getRect();
00880 
00881 protected:
00882     NodeImpl *impl;
00883 };
00884 
00885 
00886 class NodeListImpl;
00887 
00897 class KHTML_EXPORT NodeList
00898 {
00899     friend class Element;
00900     friend class Node;
00901     friend class Document;
00902     friend class HTMLDocument;
00903     friend class KJS::HTMLDocument;
00904     friend class KJS::Window;
00905 
00906 public:
00907     NodeList();
00908     NodeList(const NodeList &other);
00909 
00910     NodeList & operator = (const NodeList &other);
00911 
00912     ~NodeList();
00913 
00919     unsigned long length() const;
00920 
00933     Node item ( unsigned long index ) const;
00934 
00939     NodeListImpl *handle() const { return impl; }
00940     bool isNull() const { return !impl; }
00941 
00942 protected:
00943     NodeList(const NodeListImpl *i);
00944     NodeListImpl *impl;
00945 };
00946 
00947 
00948 
00953 typedef unsigned long long DOMTimeStamp;
00954 
00955 
00956 } //namespace
00957 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys