KHtml

dom_node.h
1 /*
2  * This file is part of the DOM implementation for KDE.
3  *
4  * Copyright 1999 Lars Knoll ([email protected])
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  * This file includes excerpts from the Document Object Model (DOM)
22  * Level 1 Specification (Recommendation)
23  * https://www.w3.org/TR/REC-DOM-Level-1/
24  * Copyright © World Wide Web Consortium , (Massachusetts Institute of
25  * Technology , Institut National de Recherche en Informatique et en
26  * Automatique , Keio University ). All Rights Reserved.
27  *
28  */
29 #ifndef _DOM_Node_h_
30 #define _DOM_Node_h_
31 
32 #include <khtml_export.h>
33 #include <QString>
34 
35 class QRect;
36 
37 namespace KJS
38 {
39 class HTMLDocument;
40 class Window;
41 }
42 namespace DOM
43 {
44 
45 class Node;
46 class DOMString;
47 class NodeImpl;
48 class NamedNodeMapImpl;
49 class EventListener;
50 class Event;
51 
64 class KHTML_EXPORT NamedNodeMap
65 {
66 public:
67  NamedNodeMap();
68  NamedNodeMap(const NamedNodeMap &other);
69 
70  NamedNodeMap &operator = (const NamedNodeMap &other);
71 
72  ~NamedNodeMap();
73 
79  unsigned long length() const;
80 
91  Node getNamedItem(const DOMString &name) const;
92 
125  Node setNamedItem(const Node &arg);
126 
142  Node removeNamedItem(const DOMString &name);
143 
156  Node item(unsigned long index) const;
157 
171  Node getNamedItemNS(const DOMString &namespaceURI,
172  const DOMString &localName) const;
173 
198  Node setNamedItemNS(const Node &arg);
199 
224  Node removeNamedItemNS(const DOMString &namespaceURI,
225  const DOMString &localName);
226 
231  NamedNodeMapImpl *handle() const
232  {
233  return impl;
234  }
235  bool isNull() const
236  {
237  return !impl;
238  }
239 
240 protected:
241  NamedNodeMap(NamedNodeMapImpl *i);
242  NamedNodeMapImpl *impl;
243 
244  friend class Node;
245  friend class DocumentType;
246  friend class NodeImpl;
247 };
248 
249 class NamedNodeMap;
250 class NodeList;
251 class Document;
252 class DOMString;
253 class StyleSheet;
254 
255 class NodeImpl;
256 
278 class KHTML_EXPORT Node
279 {
280  friend class NamedNodeMap;
281  friend class NodeList;
282  friend class HTMLCollection;
283  friend class StyleSheet;
284 
285 public:
286  Node() : impl(nullptr) {}
287  Node(const Node &other);
288 
292  Node(NodeImpl *_impl);
293 
294  Node &operator = (const Node &other);
295 
296  bool operator == (const Node &other) const;
297 
298  bool operator != (const Node &other) const;
299 
300  virtual ~Node();
389  enum NodeType {
390  ELEMENT_NODE = 1,
391  ATTRIBUTE_NODE = 2,
392  TEXT_NODE = 3,
393  CDATA_SECTION_NODE = 4,
394  ENTITY_REFERENCE_NODE = 5,
395  ENTITY_NODE = 6,
396  PROCESSING_INSTRUCTION_NODE = 7,
397  COMMENT_NODE = 8,
398  DOCUMENT_NODE = 9,
399  DOCUMENT_TYPE_NODE = 10,
400  DOCUMENT_FRAGMENT_NODE = 11,
401  NOTATION_NODE = 12,
402  XPATH_NAMESPACE_NODE = 13 //< Part of DOM L3 XPath, @since 4.5
403  };
404 
410  DOMString nodeName() const;
411 
422  DOMString nodeValue() const;
423 
430  void setNodeValue(const DOMString &);
431 
437  unsigned short nodeType() const;
438 
447  Node parentNode() const;
448 
462  NodeList childNodes() const;
463 
469  Node firstChild() const;
470 
476  Node lastChild() const;
477 
483  Node previousSibling() const;
484 
490  Node nextSibling() const;
491 
498  NamedNodeMap attributes() const;
499 
507  Document ownerDocument() const;
508 
543  Node insertBefore(const Node &newChild, const Node &refChild);
544 
573  Node replaceChild(const Node &newChild, const Node &oldChild);
574 
590  Node removeChild(const Node &oldChild);
591 
618  Node appendChild(const Node &newChild);
619 
628  bool hasChildNodes();
629 
650  Node cloneNode(bool deep);
651 
669  void normalize();
670 
688  bool isSupported(const DOMString &feature,
689  const DOMString &version) const;
690 
707  DOMString namespaceURI() const;
708 
724  DOMString prefix() const;
725 
743  void setPrefix(const DOMString &prefix);
744 
753  DOMString localName() const;
754 
760  bool hasAttributes();
761 
790  void addEventListener(const DOMString &type,
791  EventListener *listener,
792  const bool useCapture);
793 
819  void removeEventListener(const DOMString &type,
820  EventListener *listener,
821  bool useCapture);
822 
846  bool dispatchEvent(const Event &evt);
847 
865  DOMString textContent() const;
866 
873  void setTextContent(const DOMString &text);
874 
884  DOCUMENT_POSITION_DISCONNECTED = 0x01,
885  DOCUMENT_POSITION_PRECEDING = 0x02,
886  DOCUMENT_POSITION_FOLLOWING = 0x04,
887  DOCUMENT_POSITION_CONTAINS = 0x08,
888  DOCUMENT_POSITION_CONTAINED_BY = 0x10,
889  DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20
890  };
891 
907  unsigned compareDocumentPosition(const DOM::Node &other);
908 
914  quint32 elementId() const;
915 
928  bool isNull() const
929  {
930  return !impl;
931  }
932 
936  NodeImpl *handle() const
937  {
938  return impl;
939  }
940 
944  unsigned long index() const;
945 #ifndef KHTML_NO_DEPRECATED
946  KHTML_DEPRECATED QString toHTML();
947 #endif
948  void applyChanges();
952 #ifndef KHTML_NO_DEPRECATED
953  KHTML_DEPRECATED void getCursor(int offset, int &_x, int &_y, int &height);
954 #endif
955 
959  QRect getRect();
960 
961 protected:
962  NodeImpl *impl;
963 };
964 
965 class NodeListImpl;
966 
976 class KHTML_EXPORT NodeList
977 {
978  friend class Element;
979  friend class Node;
980  friend class Document;
981  friend class DocumentFragment;
982  friend class HTMLDocument;
983  friend class KJS::HTMLDocument;
984  friend class KJS::Window;
985 
986 public:
987  NodeList();
988  NodeList(const NodeList &other);
989 
990  NodeList &operator = (const NodeList &other);
991 
992  ~NodeList();
993 
999  unsigned long length() const;
1000 
1013  Node item(unsigned long index) const;
1014 
1019  NodeListImpl *handle() const
1020  {
1021  return impl;
1022  }
1023  bool isNull() const
1024  {
1025  return !impl;
1026  }
1027 
1028 protected:
1029  NodeList(const NodeListImpl *i);
1030  NodeListImpl *impl;
1031 };
1032 
1037 typedef unsigned long long DOMTimeStamp;
1038 
1039 } //namespace
1040 #endif
The Node interface is the primary datatype for the entire Document Object Model.
Definition: dom_node.h:278
An HTMLDocument is the root of the HTML hierarchy and holds the entire content.
Definition: html_document.h:74
DocumentFragment is a "lightweight" or "minimal" Document object.
Definition: dom_doc.h:1042
NamedNodeMapImpl * handle() const
Definition: dom_node.h:231
NodeType
An integer indicating which type of node this is.
Definition: dom_node.h:389
Objects implementing the NamedNodeMap interface are used to represent collections of nodes that can b...
Definition: dom_node.h:64
An HTMLCollection is a list of nodes.
Definition: html_misc.h:133
By far the vast majority of objects (apart from text) that authors encounter when traversing a docume...
Definition: dom_element.h:212
QCA_EXPORT bool isSupported(const char *features, const QString &provider=QString())
bool isNull() const
tests if this Node is 0.
Definition: dom_node.h:928
This class implements the basic string we use in the DOM.
Definition: dom_string.h:44
The Document interface represents the entire HTML or XML document.
Definition: dom_doc.h:246
DocumentPosition
Introduced in DOM Level 3.
Definition: dom_node.h:883
Each Document has a doctype attribute whose value is either null or a DocumentType object...
Definition: dom_doc.h:1102
The NodeList interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented.
Definition: dom_node.h:976
Introduced in DOM Level 2.
Definition: dom2_events.h:69
This library provides a full-featured HTML parser and widget.
Introduced in DOM Level 2.
Definition: dom2_events.h:116
NodeListImpl * handle() const
Definition: dom_node.h:1019
The StyleSheet interface is the abstract base interface for any type of style sheet.
unsigned long long DOMTimeStamp
NodeImpl * handle() const
Definition: dom_node.h:936
Window
Definition: kjs_window.h:393
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Sep 24 2020 22:46:38 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.