KHTML
dom_node.h
Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 #ifndef _DOM_Node_h_
00034 #define _DOM_Node_h_
00035 
00036 #include <qstring.h>
00037 #include <kdelibs_export.h>
00038 
00039 class QRect;
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 KHTML_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 KHTML_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     Q_UINT32 elementId() const;
00879 
00892     bool isNull() const { return !impl; }
00893 
00897     NodeImpl *handle() const { return impl; }
00898 
00902     unsigned long index() const;
00903     QString toHTML() KDE_DEPRECATED;
00904     void applyChanges();
00908     void getCursor(int offset, int &_x, int &_y, int &height) KDE_DEPRECATED;
00913     QRect getRect();
00914 
00915 protected:
00916     NodeImpl *impl;
00917 };
00918 
00919 
00920 class NodeListImpl;
00921 
00931 class KHTML_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 } 
00991 #endif