File indexing completed on 2024-04-28 15:22:56

0001 /*
0002  * This file is part of the DOM implementation for KDE.
0003  *
0004  * Copyright 1999 Lars Knoll (knoll@kde.org)
0005  *
0006  * This library is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Library General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2 of the License, or (at your option) any later version.
0010  *
0011  * This library is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * Library General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Library General Public License
0017  * along with this library; see the file COPYING.LIB.  If not, write to
0018  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019  * Boston, MA 02110-1301, USA.
0020  *
0021  * This file includes excerpts from the Document Object Model (DOM)
0022  * Level 1 Specification (Recommendation)
0023  * https://www.w3.org/TR/REC-DOM-Level-1/
0024  * Copyright © World Wide Web Consortium , (Massachusetts Institute of
0025  * Technology , Institut National de Recherche en Informatique et en
0026  * Automatique , Keio University ). All Rights Reserved.
0027  */
0028 
0029 #ifndef _DOM_Document_h_
0030 #define _DOM_Document_h_
0031 
0032 #include <dom/dom_node.h>
0033 #include <dom/css_stylesheet.h>
0034 
0035 class KHTMLView;
0036 class KHTMLPart;
0037 
0038 namespace DOM
0039 {
0040 
0041 class DOMString;
0042 class DocumentType;
0043 class NodeList;
0044 class CDATASection;
0045 class Comment;
0046 class DocumentFragment;
0047 class Text;
0048 class DOMImplementation;
0049 class Element;
0050 class Attr;
0051 class EntityReference;
0052 class ProcessingInstruction;
0053 class DocumentImpl;
0054 class Range;
0055 class NodeIterator;
0056 class TreeWalker;
0057 class NodeFilter;
0058 class DOMImplementationImpl;
0059 class DocumentTypeImpl;
0060 class Event;
0061 class AbstractView;
0062 class CSSStyleDeclaration;
0063 class HTMLElementImpl;
0064 class HTMLFrameElement;
0065 class HTMLElementImpl;
0066 class HTMLIFrameElement;
0067 class HTMLObjectElement;
0068 class HTMLDocument;
0069 
0070 /**
0071  * The \c DOMImplementation interface provides a number of
0072  * methods for performing operations that are independent of any
0073  * particular instance of the document object model.
0074  *
0075  * DOM Level 2 and newer provide means for creating documents directly,
0076  * which was not possible with DOM Level 1.
0077  */
0078 class KHTML_EXPORT DOMImplementation
0079 {
0080     friend class Document;
0081 public:
0082     DOMImplementation();
0083     DOMImplementation(const DOMImplementation &other);
0084 
0085     DOMImplementation &operator = (const DOMImplementation &other);
0086     ~DOMImplementation();
0087 
0088     /**
0089      * Test if the DOM implementation implements a specific feature.
0090      *
0091      * @param feature The package name of the feature to test. In
0092      * Level 1, the legal values are "HTML" and "XML"
0093      * (case-insensitive).
0094      *
0095      * @param version This is the version number of the package name
0096      * to test. In Level 1, this is the string "1.0". If the version
0097      * is not specified, supporting any version of the feature will
0098      * cause the method to return \c true .
0099      *
0100      * @return \c true if the feature is implemented in
0101      * the specified version, \c false otherwise.
0102      *
0103      */
0104     bool hasFeature(const DOMString &feature, const DOMString &version);
0105 
0106     /**
0107      * Introduced in DOM Level 2
0108      *
0109      * Creates an empty DocumentType node. Entity declarations and notations
0110      * are not made available. Entity reference expansions and default
0111      * attribute additions do not occur. It is expected that a future version
0112      * of the DOM will provide a way for populating a DocumentType.
0113      *
0114      * HTML-only DOM implementations do not need to implement this method.
0115      *
0116      * @param qualifiedName The qualified name of the document type to be
0117      * created.
0118      *
0119      * @param publicId The external subset public identifier.
0120      *
0121      * @param systemId The external subset system identifier.
0122      *
0123      * @return A new DocumentType node with Node.ownerDocument set to null.
0124      *
0125      * @exception DOMException
0126      * INVALID_CHARACTER_ERR: Raised if the specified qualified name contains
0127      * an illegal character.
0128      *
0129      * NAMESPACE_ERR: Raised if the qualifiedName is malformed.
0130      */
0131     DocumentType createDocumentType(const DOMString &qualifiedName,
0132                                     const DOMString &publicId,
0133                                     const DOMString &systemId);
0134 
0135     /**
0136      * Introduced in DOM Level 2
0137      *
0138      * Creates an XML Document object of the specified type with its document
0139      * element. HTML-only DOM implementations do not need to implement this
0140      * method.
0141      *
0142      * @param namespaceURI The namespace URI of the document element to create.
0143      *
0144      * @param qualifiedName The qualified name of the document element to be
0145      * created.
0146      *
0147      * @param doctype The type of document to be created or null. When doctype
0148      * is not null, its Node.ownerDocument attribute is set to the document
0149      * being created.
0150      *
0151      * @return A new Document object.
0152      *
0153      * @exception DOMException
0154      * INVALID_CHARACTER_ERR: Raised if the specified qualified name contains
0155      * an illegal character.
0156      *
0157      * NAMESPACE_ERR: Raised if the qualifiedName is malformed, if the
0158      * qualifiedName has a prefix and the namespaceURI is null, or if the
0159      * qualifiedName has a prefix that is "xml" and the namespaceURI is
0160      * different from "http://www.w3.org/XML/1998/namespace" [Namespaces].
0161      *
0162      * WRONG_DOCUMENT_ERR: Raised if doctype has already been used with a
0163      * different document or was created from a different implementation.
0164      */
0165     Document createDocument(const DOMString &namespaceURI,
0166                             const DOMString &qualifiedName,
0167                             const DocumentType &doctype);
0168 
0169     /**
0170      * Introduced in DOM Level 3
0171      * This method makes available a DOMImplementation's specialized
0172      * interface.
0173      *
0174      * @param feature The name of the feature requested (case-insensitive)
0175      *
0176      * @return Returns an alternate DOMImplementation which implements
0177      * the specialized APIs of the specified feature, if any, or null
0178      * if there is no alternate DOMImplementation object which implements
0179      * interfaces associated with that feature. Any alternate DOMImplementation
0180      * returned by this method must delegate to the primary core DOMImplementation
0181      * and not return results inconsistent with the primary DOMImplementation.
0182      */
0183     DOMImplementation getInterface(const DOMString &feature) const;
0184 
0185     /**
0186      * Introduced in DOM Level 2
0187      * This method is from the DOMImplementationCSS interface
0188      *
0189      * Creates a new CSSStyleSheet.
0190      *
0191      * @param title The advisory title. See also the Style Sheet Interfaces
0192      * section.
0193      *
0194      * @param media The comma-separated list of media associated with the
0195      * new style sheet. See also the Style Sheet Interfaces section.
0196      *
0197      * @return A new CSS style sheet.
0198      *
0199      * @exception SYNTAX_ERR: Raised if the specified media string value has a syntax error and is unparsable.
0200      */
0201     CSSStyleSheet createCSSStyleSheet(const DOMString &title, const DOMString &media);
0202 
0203     /**
0204      * Introduced in DOM Level 2
0205      * This method is from the HTMLDOMImplementation interface
0206      *
0207      * Creates an HTMLDocument with the minimal tree made of these
0208      * elements: HTML,HEAD,TITLE and BODY.
0209      * It extends the core interface which can be used to create an
0210      * XHTML document by passing the XHTML namespace as the namespace
0211      * for the root element.
0212      *
0213      * @param title The title of the document to be set as the content
0214      * of the TITLE element, through a child Text node.
0215      *
0216      * @return the HTMLdocument
0217      */
0218     HTMLDocument createHTMLDocument(const DOMString &title);
0219 
0220     /**
0221      * @internal
0222      * not part of the DOM
0223      */
0224     DOMImplementationImpl *handle() const;
0225     bool isNull() const;
0226 
0227 protected:
0228     DOMImplementation(DOMImplementationImpl *i);
0229     DOMImplementationImpl *impl;
0230 };
0231 
0232 /**
0233  * The \c Document interface represents the entire HTML or
0234  * XML document. Conceptually, it is the root of the document tree,
0235  * and provides the primary access to the document's data.
0236  *
0237  *  Since elements, text nodes, comments, processing instructions,
0238  * etc. cannot exist outside the context of a \c Document
0239  * , the \c Document interface also contains the factory
0240  * methods needed to create these objects. The \c Node
0241  * objects created have a \c ownerDocument attribute which
0242  * associates them with the \c Document within whose
0243  * context they were created.
0244  *
0245  */
0246 class KHTML_EXPORT Document : public Node
0247 {
0248     friend class ::KHTMLView;
0249     friend class ::KHTMLPart;
0250     friend class AbstractView;
0251     friend class DOMImplementation;
0252     friend class HTMLFrameElement;
0253     friend class HTMLIFrameElement;
0254     friend class HTMLObjectElement;
0255 
0256 public:
0257     Document();
0258     /**
0259      * don't create an implementation if false
0260      * use at own risk
0261      */
0262     Document(bool);
0263     Document(const Document &other);
0264     Document(const Node &other) : Node()
0265     {
0266         (*this) = other;
0267     }
0268 
0269     Document &operator = (const Node &other);
0270     Document &operator = (const Document &other);
0271 
0272     ~Document();
0273 
0274     /**
0275      * The Document Type Declaration (see \c DocumentType
0276      * ) associated with this document. For HTML documents as well as
0277      * XML documents without a document type declaration this returns
0278      * \c null . The DOM Level 1 does not support editing
0279      * the Document Type Declaration, therefore \c docType
0280      * cannot be altered in any way.
0281      *
0282      */
0283     DocumentType doctype() const;
0284 
0285     /**
0286      * The \c DOMImplementation object that handles this
0287      * document. A DOM application may use objects from multiple
0288      * implementations.
0289      *
0290      */
0291     DOMImplementation implementation() const;
0292 
0293     /**
0294      * This is a convenience attribute that allows direct access to
0295      * the child node that is the root element of the document. For
0296      * HTML documents, this is the element with the tagName "HTML".
0297      *
0298      */
0299     Element documentElement() const;
0300 
0301     /**
0302      * Creates an element of the type specified. Note that the
0303      * instance returned implements the Element interface, so
0304      * attributes can be specified directly on the returned object.
0305      *
0306      * @param tagName The name of the element type to instantiate. For
0307      * XML, this is case-sensitive. For HTML, the \c tagName
0308      * parameter may be provided in any case, but it must be
0309      * mapped to the canonical uppercase form by the DOM
0310      * implementation.
0311      *
0312      * @return A new \c Element object.
0313      *
0314      * @exception DOMException
0315      * INVALID_CHARACTER_ERR: Raised if the specified name contains an
0316      * invalid character.
0317      *
0318      */
0319     Element createElement(const DOMString &tagName);
0320 
0321     /**
0322      * Introduced in DOM Level 2
0323      * Creates an element of the given qualified name and namespace URI.
0324      *
0325      * @param namespaceURI The namespace URI of the element to create.
0326      *
0327      * @param qualifiedName The qualified name of the element type to instantiate.
0328      *
0329      * @return A new Element object with the following attributes:
0330      *
0331      * @exception INVALID_CHARACTER_ERR Raised if the specified qualified name
0332      * contains an illegal character.
0333      *
0334      * @exception NAMESPACE_ERR Raised if the qualifiedName is malformed, if
0335      * the qualifiedName has a prefix and the namespaceURI is null, or if the
0336      * qualifiedName has a prefix that is "xml" and the namespaceURI is
0337      * different from "http://www.w3.org/XML/1998/namespace"
0338      */
0339     Element createElementNS(const DOMString &namespaceURI,
0340                             const DOMString &qualifiedName);
0341 
0342     /**
0343      * Creates an empty \c DocumentFragment object.
0344      *
0345      * @return A new \c DocumentFragment .
0346      *
0347      */
0348     DocumentFragment createDocumentFragment();
0349 
0350     /**
0351      * Creates a \c Text node given the specified string.
0352      *
0353      * @param data The data for the node.
0354      *
0355      * @return The new \c Text object.
0356      *
0357      */
0358     Text createTextNode(const DOMString &data);
0359 
0360     /**
0361      * Creates a \c Comment node given the specified
0362      * string.
0363      *
0364      * @param data The data for the node.
0365      *
0366      * @return The new \c Comment object.
0367      *
0368      */
0369     Comment createComment(const DOMString &data);
0370 
0371     /**
0372      * Creates a \c CDATASection node whose value is the
0373      * specified string.
0374      *
0375      * @param data The data for the \c CDATASection
0376      * contents.
0377      *
0378      * @return The new \c CDATASection object.
0379      *
0380      * @exception DOMException
0381      * NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
0382      *
0383      */
0384     CDATASection createCDATASection(const DOMString &data);
0385 
0386     /**
0387      * Creates a \c ProcessingInstruction node given the
0388      * specified name and data strings.
0389      *
0390      * @param target The target part of the processing instruction.
0391      *
0392      * @param data The data for the node.
0393      *
0394      * @return The new \c ProcessingInstruction object.
0395      *
0396      * @exception DOMException
0397      * INVALID_CHARACTER_ERR: Raised if an invalid character is
0398      * specified.
0399      *
0400      *  NOT_SUPPORTED_ERR: Raised if this document is an HTML
0401      * document.
0402      *
0403      */
0404     ProcessingInstruction createProcessingInstruction(const DOMString &target,
0405             const DOMString &data);
0406 
0407     /**
0408      * Creates an \c Attr of the given name. Note that the
0409      * \c Attr instance can then be set on an \c Element
0410      * using the \c setAttribute method.
0411      *
0412      * @param name The name of the attribute.
0413      *
0414      * @return A new \c Attr object.
0415      *
0416      * @exception DOMException
0417      * INVALID_CHARACTER_ERR: Raised if the specified name contains an
0418      * invalid character.
0419      *
0420      */
0421     Attr createAttribute(const DOMString &name);
0422 
0423     /**
0424      * Introduced in DOM Level 2
0425      * Creates an attribute of the given qualified name and namespace URI.
0426      * HTML-only DOM implementations do not need to implement this method.
0427      *
0428      * @param namespaceURI The namespace URI of the attribute to create.
0429      *
0430      * @param qualifiedName The qualified name of the attribute to instantiate.
0431      *
0432      * @return A new Attr object with the following attributes:
0433      * Node.nodeName - qualifiedName
0434      * Node.namespaceURI - namespaceURI
0435      * Node.prefix - prefix, extracted from qualifiedName, or null if there is
0436      * no prefix
0437      * Node.localName - local name, extracted from qualifiedName
0438      * Attr.name - qualifiedName
0439      * Node.nodeValue - the empty string
0440      *
0441      * @exception INVALID_CHARACTER_ERR Raised if the specified qualified name
0442      * contains an illegal character.
0443      *
0444      * @exception NAMESPACE_ERR Raised if the qualifiedName is malformed, if
0445      * the qualifiedName has a prefix and the namespaceURI is null, if the
0446      * qualifiedName has a prefix that is "xml" and the namespaceURI is
0447      * different from "http://www.w3.org/XML/1998/namespace", or if the
0448      * qualifiedName is "xmlns" and the namespaceURI is different from
0449      * "http://www.w3.org/2000/xmlns/".
0450      */
0451     Attr createAttributeNS(const DOMString &namespaceURI,
0452                            const DOMString &qualifiedName);
0453 
0454     /**
0455      * Creates an EntityReference object.
0456      *
0457      * @param name The name of the entity to reference.
0458      *
0459      * @return The new \c EntityReference object.
0460      *
0461      * @exception DOMException
0462      * INVALID_CHARACTER_ERR: Raised if the specified name contains an
0463      * invalid character.
0464      *
0465      *  NOT_SUPPORTED_ERR: Raised if this document is an HTML
0466      * document.
0467      *
0468      */
0469     EntityReference createEntityReference(const DOMString &name);
0470 
0471     /**
0472      * Moved from HTMLDocument in DOM Level 2
0473      * Returns the Element whose \c id is given by
0474      * elementId. If no such element exists, returns \c null
0475      * . Behavior is not defined if more than one element has
0476      * this \c id .
0477      *
0478      * @param elementId The unique \c id value for an
0479      * element.
0480      *
0481      * @return The matching element.
0482      *
0483      */
0484     Element getElementById(const DOMString &elementId) const;
0485 
0486     /**
0487      * No Exceptions.
0488      *
0489      * Returns a \c NodeList of all the \c Element 's
0490      * with a given tag name in the order in which they
0491      * would be encountered in a preorder traversal of the
0492      * \c Document tree.
0493      *
0494      * @param tagname The name of the tag to match on. The special
0495      * value "*" matches all tags.
0496      *
0497      * @return A new \c NodeList object containing all the
0498      * matched \c Element s.
0499      *
0500      */
0501     NodeList getElementsByTagName(const DOMString &tagname);
0502 
0503     /**
0504      * Introduced in DOM Level 2
0505      * No Exceptions
0506      *
0507      * Returns a NodeList of all the Elements with a given local name and
0508      * namespace URI in the order in which they are encountered in a preorder
0509      * traversal of the Document tree.
0510      *
0511      * @param namespaceURI The namespace URI of the elements to match on. The
0512      * special value "*" matches all namespaces.
0513      *
0514      * @param localName The local name of the elements to match on. The special
0515      * value "*" matches all local names.
0516      *
0517      * @return A new NodeList object containing all the matched Elements.
0518      */
0519     NodeList getElementsByTagNameNS(const DOMString &namespaceURI,
0520                                     const DOMString &localName);
0521 
0522     /**
0523      * Introduced in HTML 5.
0524      * No Exceptions.
0525      *
0526      * Returns a \c NodeList of all the \c Element 's
0527      * with a given class name in the order in which they
0528      * would be encountered in a preorder traversal of the
0529      * \c Document tree.
0530      *
0531      * @param tagname An unordered set of unique space-separated
0532      * tokens representing classes.
0533      *
0534      * @return A new \c NodeList object containing all the
0535      * matched \c Element s.
0536      *
0537      * @since 4.1
0538      */
0539     NodeList getElementsByClassName(const DOMString &className);
0540 
0541     /**
0542      * Introduced in DOM Level 2
0543      *
0544      * Imports a node from another document to this document. The returned node
0545      * has no parent; (parentNode is null). The source node is not altered or
0546      * removed from the original document; this method creates a new copy of
0547      * the source node.
0548      *
0549      * For all nodes, importing a node creates a node object owned by the
0550      * importing document, with attribute values identical to the source node's
0551      * nodeName and nodeType, plus the attributes related to namespaces
0552      * (prefix, localName, and namespaceURI).
0553      *
0554      * As in the cloneNode operation on a Node, the source node is not altered.
0555      * Additional information is copied as appropriate to the nodeType,
0556      * attempting to mirror the behavior expected if a fragment of XML or HTML
0557      * source was copied from one document to another, recognizing that the two
0558      * documents may have different DTDs in the XML case. The following list
0559      * describes the specifics for each type of node.
0560      *
0561      * ATTRIBUTE_NODE
0562      * The ownerElement attribute is set to null and the specified flag is set
0563      * to true on the generated Attr. The descendants of the source Attr are
0564      * recursively imported and the resulting nodes reassembled to form the
0565      * corresponding subtree. Note that the deep parameter has no effect on
0566      * Attr nodes; they always carry their children with them when imported.
0567      *
0568      * DOCUMENT_FRAGMENT_NODE
0569      * If the deep option was set to true, the descendants of the source
0570      * element are recursively imported and the resulting nodes reassembled to
0571      * form the corresponding subtree. Otherwise, this simply generates an
0572      * empty DocumentFragment.
0573      *
0574      * DOCUMENT_NODE
0575      * Document nodes cannot be imported.
0576      *
0577      * DOCUMENT_TYPE_NODE
0578      * DocumentType nodes cannot be imported.
0579      *
0580      * ELEMENT_NODE
0581      * Specified attribute nodes of the source element are imported, and the
0582      * generated Attr nodes are attached to the generated Element. Default
0583      * attributes are not copied, though if the document being imported into
0584      * defines default attributes for this element name, those are assigned. If
0585      * the importNode deep parameter was set to true, the descendants of the
0586      * source element are recursively imported and the resulting nodes
0587      * reassembled to form the corresponding subtree.
0588      *
0589      * ENTITY_NODE
0590      * Entity nodes can be imported, however in the current release of the DOM
0591      * the DocumentType is readonly. Ability to add these imported nodes to a
0592      * DocumentType will be considered for addition to a future release of the
0593      * DOM.
0594      * On import, the publicId, systemId, and notationName attributes are
0595      * copied. If a deep import is requested, the descendants of the source
0596      * Entity are recursively imported and the resulting nodes reassembled to
0597      * form the corresponding subtree.
0598      *
0599      * ENTITY_REFERENCE_NODE Only the EntityReference itself is copied, even if
0600      * a deep import is requested, since the source and destination documents
0601      * might have defined the entity differently. If the document being
0602      * imported into provides a definition for this entity name, its value is
0603      * assigned.
0604      *
0605      * NOTATION_NODE
0606      * Notation nodes can be imported, however in the current release of the
0607      * DOM the DocumentType is readonly. Ability to add these imported nodes to
0608      * a DocumentType will be considered for addition to a future release of
0609      * the DOM.
0610      * On import, the publicId and systemId attributes are copied.
0611      * Note that the deep parameter has no effect on Notation nodes since they
0612      * never have any children.
0613      *
0614      * PROCESSING_INSTRUCTION_NODE
0615      * The imported node copies its target and data values from those of the
0616      * source node.
0617      *
0618      * TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE
0619      * These three types of nodes inheriting from CharacterData copy their data
0620      * and length attributes from those of the source node.
0621      *
0622      * @param importedNode The node to import.
0623      *
0624      * @param deep If true, recursively import the subtree under the specified
0625      * node; if false, import only the node itself, as explained above. This
0626      * has no effect on Attr, EntityReference, and Notation nodes.
0627      *
0628      * @return The imported node that belongs to this Document.
0629      *
0630      * @exception DOMException
0631      * NOT_SUPPORTED_ERR: Raised if the type of node being imported is not
0632      * supported.
0633      */
0634     Node importNode(const Node &importedNode, bool deep);
0635 
0636     /**
0637      * @internal
0638      * not part of the DOM
0639      */
0640     bool isHTMLDocument() const;
0641 
0642     /**
0643      * Introduced in DOM Level 2
0644      * This method is from the DocumentRange interface
0645      *
0646      * @return Range
0647      * The initial state of the Range returned from this method is such that
0648      * both of its boundary-points are positioned at the beginning of the
0649      * corresponding Document, before any content. The Range returned can only
0650      * be used to select content associated with this Document, or with
0651      * DocumentFragments and Attrs for which this Document is the ownerDocument.
0652      */
0653     Range createRange();
0654 
0655     /**
0656      * Introduced in DOM Level 2
0657      * This method is from the DocumentTraversal interface
0658      *
0659      * Create a new NodeIterator over the subtree rooted at the specified node.
0660      *
0661      * @param root The node which will be iterated together with its children.
0662      * The iterator is initially positioned just before this node. The
0663      * whatToShow flags and the filter, if any, are not considered when setting
0664      * this position. The root must not be null.
0665      *
0666      * @param whatToShow This flag specifies which node types may appear in the
0667      * logical view of the tree presented by the iterator. See the description
0668      * of NodeFilter for the set of possible SHOW_ values. These flags can be
0669      * combined using OR.
0670      *
0671      * @param filter The NodeFilter to be used with this NodeIterator, or null to
0672      * indicate no filter.
0673      *
0674      * @param entityReferenceExpansion The value of this flag determines
0675      * whether entity reference nodes are expanded.
0676      *
0677      * @return NodeIterator The newly created NodeIterator.
0678      *
0679      * @exception DOMException
0680      * NOT_SUPPORTED_ERR: Raised if the specified root is null.
0681      */
0682     NodeIterator createNodeIterator(Node root, unsigned long whatToShow,
0683                                     NodeFilter filter,
0684                                     bool entityReferenceExpansion);
0685 
0686     /**
0687      * Introduced in DOM Level 2
0688      * This method is from the DocumentTraversal interface
0689      *
0690      * Create a new TreeWalker over the subtree rooted at the specified node.
0691      *
0692      * @param root The node which will serve as the root for the TreeWalker.
0693      * The whatToShow flags and the NodeFilter are not considered when setting
0694      * this value; any node type will be accepted as the root. The currentNode
0695      * of the TreeWalker is initialized to this node, whether or not it is
0696      * visible. The root functions as a stopping point for traversal methods
0697      * that look upward in the document structure, such as parentNode and
0698      * nextNode. The root must not be null.
0699      *
0700      * @param whatToShow This flag specifies which node types may appear in the
0701      * logical view of the tree presented by the tree-walker. See the
0702      * description of NodeFilter for the set of possible SHOW_ values. These
0703      * flags can be combined using OR.
0704      *
0705      * @param filter The NodeFilter to be used with this TreeWalker, or null to
0706      * indicate no filter.
0707      *
0708      * @param entityReferenceExpansion If this flag is false, the contents of
0709      * EntityReference nodes are not presented in the logical view.
0710      *
0711      * @return The newly created TreeWalker.
0712      *
0713      * @exception DOMException
0714      * NOT_SUPPORTED_ERR: Raised if the specified root is null.
0715      */
0716     TreeWalker createTreeWalker(Node root, unsigned long whatToShow,
0717                                 NodeFilter filter,
0718                                 bool entityReferenceExpansion);
0719 
0720     /**
0721      * Introduced in DOM Level 2
0722      * This method is from the DocumentEvent interface
0723      *
0724      * The createEvent method is used in creating Events when it is either
0725      * inconvenient or unnecessary for the user to create an Event themselves.
0726      * In cases where the implementation provided Event is insufficient, users
0727      * may supply their own Event implementations for use with the
0728      * dispatchEvent method.
0729      *
0730      * @param eventType The eventType parameter specifies the type of Event
0731      * interface to be created. If the Event interface specified is supported
0732      * by the implementation this method will return a new Event of the
0733      * interface type requested. If the Event is to be dispatched via the
0734      * dispatchEvent method the appropriate event init method must be called
0735      * after creation in order to initialize the Event's values. As an example,
0736      * a user wishing to synthesize some kind of UIEvent would call createEvent
0737      * with the parameter "UIEvents". The initUIEvent method could then be
0738      * called on the newly created UIEvent to set the specific type of UIEvent
0739      * to be dispatched and set its context information.
0740      *
0741      * @return The newly created EventExceptions
0742      *
0743      * @exception DOMException
0744      * NOT_SUPPORTED_ERR: Raised if the implementation does not support the
0745      * type of Event interface requested
0746      */
0747     Event createEvent(const DOMString &eventType);
0748 
0749     /**
0750      * Introduced in DOM Level 2
0751      * This method is from the DocumentView interface
0752      *
0753      * The default AbstractView for this Document, or null if none available.
0754      */
0755     AbstractView defaultView() const;
0756 
0757     /**
0758      * Introduced in DOM Level 2
0759      * This method is from the DocumentStyle interface
0760      *
0761      * A list containing all the style sheets explicitly linked into or
0762      * embedded in a document. For HTML documents, this includes external style
0763      * sheets, included via the HTML LINK element, and inline STYLE elements.
0764      * In XML, this includes external style sheets, included via style sheet
0765      * processing instructions (see [XML-StyleSheet]).
0766      */
0767     StyleSheetList styleSheets() const;
0768 
0769     /**
0770      * CSS3 mechanism for selecting alternate stylesheets using the DOM.
0771      * Might change without further notice.
0772      */
0773 
0774     DOMString preferredStylesheetSet();
0775     DOMString selectedStylesheetSet();
0776     void setSelectedStylesheetSet(const DOMString &aString);
0777 
0778     /**
0779      * Adds a new style sheet to the list of style sheets.
0780      *
0781      * The new style sheet will be applied after all author and implicit
0782      * style sheets, but before the user style sheet.
0783      *
0784      * Create new style sheets with e. g.
0785      * \c DOMImplementation::createCSSStyleSheet
0786      *
0787      * This is not part of the official DOM.
0788      *
0789      * @param sheet style sheet
0790      * @exception DOMException
0791      */
0792     void addStyleSheet(const StyleSheet &sheet);
0793 
0794     /**
0795      * Removes a style sheet to the list of style sheets.
0796      *
0797      * Only sheets added by \c addStyleSheet may be removed.
0798      *
0799      * This is not part of the official DOM.
0800      *
0801      * @param sheet style sheet to remove
0802      * @exception DOMException
0803      * NOT_FOUND_ERR \c sheet is not contained in the list of style sheets or
0804      * it has not been added by \c addStyleSheet
0805      */
0806     void removeStyleSheet(const StyleSheet &sheet);
0807 
0808     /**
0809      * @return The KHTML view widget of this document.
0810      */
0811     KHTMLView *view() const;
0812 
0813     /**
0814      * Introduced in DOM Level 2
0815      * This method is from the DocumentCSS interface
0816      *
0817      * This method is used to retrieve the override style declaration for a
0818      * specified element and a specified pseudo-element.
0819      *
0820      * @param elt The element whose style is to be modified. This parameter
0821      * cannot be null.
0822      *
0823      * @param pseudoElt The pseudo-element or null if none.
0824      *
0825      * @return The override style declaration.
0826      */
0827     CSSStyleDeclaration getOverrideStyle(const Element &elt,
0828                                          const DOMString &pseudoElt);
0829 
0830     /**
0831      * Introduced in DOM Level 3
0832      * This method is from the DocumentLS interface
0833      *
0834      * Indicates whether the method DocumentLS.load() should be synchronous or
0835      * asynchronous. When the async attribute is set to true the load method
0836      * returns control to the caller before the document has completed loading.
0837      * The default value of this attribute is true.
0838      */
0839     bool async() const;
0840 
0841     /**
0842      * Introduced in DOM Level 3
0843      * This method is from the DocumentLS interface
0844      *
0845      * see async
0846      *
0847      * @exception DOMException
0848      * NOT_SUPPORTED_ERR: Raised if the implementation doesn't support the mode
0849      * the attribute is being set to.
0850      */
0851     void setAsync(bool);
0852 
0853     /**
0854      * Introduced in DOM Level 3
0855      * This method is from the DocumentLS interface
0856      *
0857      * If the document is currently being loaded as a result of the method load
0858      * being invoked the loading and parsing is immediately aborted. The
0859      * possibly partial result of parsing the document is discarded and the
0860      * document is cleared.
0861      */
0862     void abort();
0863 
0864     /**
0865      * Introduced in DOM Level 3
0866      * This method is from the DocumentLS interface
0867      *
0868      * Replaces the content of the document with the result of parsing the
0869      * given URI. Invoking this method will either block the caller or return
0870      * to the caller immediately depending on the value of the async attribute.
0871      * Once the document is fully loaded a "load" event (as defined in
0872      * [DOM Level 3 Events], except that the Event.targetNode will be the
0873      * document, not an element) will be dispatched on the document. If an
0874      * error occurs, an implementation dependent "error" event will be
0875      * dispatched on the document. If this method is called on a document that
0876      * is currently loading, the current load is interrupted and the new URI
0877      * load is initiated.
0878      *
0879      * When invoking this method the parameters used in the DOMParser interface
0880      * are assumed to have their default values with the exception that the
0881      * parameters "entities", "normalize-characters",
0882      * "check-character-normalization" are set to "false".
0883      *
0884      * The result of a call to this method is the same the result of a call to
0885      * DOMParser.parseWithContext with an input stream referencing the URI that
0886      * was passed to this call, the document as the context node, and the
0887      * action ACTION_REPLACE_CHILDREN.
0888      *
0889      * @param uri of type DOMString
0890      * The URI reference for the XML file to be loaded. If this is a relative
0891      * URI, the base URI used by the implementation is implementation dependent.
0892      *
0893      * @return If async is set to true load returns true if the document load
0894      * was successfully initiated. If an error occurred when initiating the
0895      * document load, load returns false.
0896      * If async is set to false load returns true if the document was
0897      * successfully loaded and parsed. If an error occurred when either loading
0898      * or parsing the URI, load returns false.
0899      */
0900     void load(const DOMString &uri);
0901 
0902     /**
0903      * Introduced in DOM Level 3
0904      * This method is from the DocumentLS interface
0905      *
0906      * Replace the content of the document with the result of parsing the input
0907      * string, this method is always synchronous. This method always parses
0908      * from a DOMString, which means the data is always UTF-16. All other
0909      * encoding information is ignored.
0910      *
0911      * The parameters used in the DOMParser interface are assumed to have their
0912      * default values when invoking this method.
0913      *
0914      * The result of a call to this method is the same as the result of a call
0915      * to DOMParser.parseWithContext with an input stream containing the string
0916      * passed to this call, the document as the context node, and the action
0917      * ACTION_REPLACE_CHILDREN.
0918      *
0919      * @param source A string containing an XML document.
0920      */
0921     void loadXML(const DOMString &source);
0922 
0923     /**
0924      * Introduced in Selectors Level 1.
0925      *
0926      * Returns the first (in document order) element matching the given
0927      * CSS selector @p query.
0928      *
0929      * @since 4.5
0930      */
0931     Element querySelector(const DOMString &query) const;
0932 
0933     /**
0934      * Introduced in Selectors Level 1.
0935      *
0936      * Returns all (in document order) elements matching the given
0937      * CSS selector @p query. Note that the returned NodeList is
0938      * static and not live, and will not be updated when the document
0939      * changes
0940      *
0941      * @since 4.5
0942      */
0943     NodeList querySelectorAll(const DOMString &query) const;
0944 
0945     /**
0946      * not part of the official DOM
0947      *
0948      * Documents are read-only by default, but they can be made editable by
0949      * entering "design mode".
0950      *
0951      * @return whether this document is in design mode.
0952      */
0953     bool designMode() const;
0954 
0955     /**
0956      * not part of the official DOM
0957      *
0958      * @param enable @p true to enable design mode, @p false to disable.
0959      * @see designMode
0960      */
0961     void setDesignMode(bool enable);
0962 
0963     /**
0964      * not part of the DOM
0965      *
0966      * completes a given URL
0967      */
0968     DOMString completeURL(const DOMString &url);
0969 
0970     DOMString toString() const;
0971 
0972     /**
0973      * not part of the DOM
0974      *
0975      * javascript editing command support
0976      */
0977     bool execCommand(const DOMString &command, bool userInterface, const DOMString &value);
0978     bool queryCommandEnabled(const DOMString &command);
0979     bool queryCommandIndeterm(const DOMString &command);
0980     bool queryCommandState(const DOMString &command);
0981     bool queryCommandSupported(const DOMString &command);
0982     DOMString queryCommandValue(const DOMString &command);
0983 
0984     /**
0985      * not part of the DOM
0986      *
0987      * Updates the rendered display after one or more changes to
0988      * the DOM structure
0989      */
0990     void updateRendering();
0991 
0992     Document(DocumentImpl *i);
0993 protected:
0994 
0995     friend class Node;
0996 };
0997 
0998 class DocumentFragmentImpl;
0999 
1000 /**
1001  * \c DocumentFragment is a "lightweight" or "minimal"
1002  * \c Document object. It is very common to want to be
1003  * able to extract a portion of a document's tree or to create a new
1004  * fragment of a document. Imagine implementing a user command like
1005  * cut or rearranging a document by moving fragments around. It is
1006  * desirable to have an object which can hold such fragments and it is
1007  * quite natural to use a Node for this purpose. While it is true that
1008  * a \c Document object could fulfil this role, a
1009  * \c Document object can potentially be a heavyweight object,
1010  * depending on the underlying implementation. What is really needed
1011  * for this is a very lightweight object. \c DocumentFragment
1012  * is such an object.
1013  *
1014  *  Furthermore, various operations -- such as inserting nodes as
1015  * children of another \c Node -- may take
1016  * \c DocumentFragment objects as arguments; this results in all
1017  * the child nodes of the \c DocumentFragment being moved
1018  * to the child list of this node.
1019  *
1020  *  The children of a \c DocumentFragment node are zero or
1021  * more nodes representing the tops of any sub-trees defining the
1022  * structure of the document. \c DocumentFragment nodes do
1023  * not need to be well-formed XML documents (although they do need to
1024  * follow the rules imposed upon well-formed XML parsed entities,
1025  * which can have multiple top nodes). For example, a
1026  * \c DocumentFragment might have only one child and that child
1027  * node could be a \c Text node. Such a structure model
1028  * represents neither an HTML document nor a well-formed XML document.
1029  *
1030  *  When a \c DocumentFragment is inserted into a
1031  * \c Document (or indeed any other \c Node that may
1032  * take children) the children of the \c DocumentFragment
1033  * and not the \c DocumentFragment itself are inserted
1034  * into the \c Node . This makes the
1035  * \c DocumentFragment very useful when the user wishes to create
1036  * nodes that are siblings; the \c DocumentFragment acts
1037  * as the parent of these nodes so that the user can use the standard
1038  * methods from the \c Node interface, such as
1039  * \c insertBefore() and \c appendChild() .
1040  *
1041  */
1042 class KHTML_EXPORT DocumentFragment : public Node
1043 {
1044     friend class Document;
1045     friend class HTMLElementImpl;
1046     friend class Range;
1047 
1048 public:
1049     DocumentFragment();
1050     DocumentFragment(const DocumentFragment &other);
1051     DocumentFragment(const Node &other) : Node()
1052     {
1053         (*this) = other;
1054     }
1055 
1056     DocumentFragment &operator = (const Node &other);
1057     DocumentFragment &operator = (const DocumentFragment &other);
1058 
1059     ~DocumentFragment();
1060 
1061     /**
1062      * Introduced in Selectors Level 1.
1063      *
1064      * Returns the first (in document order) element in this fragment
1065      * matching the given CSS selector @p query.
1066      *
1067      * @since 4.5
1068      */
1069     Element querySelector(const DOMString &query) const;
1070 
1071     /**
1072      * Introduced in Selectors Level 1.
1073      *
1074      * Returns all (in document order) elements in this fragment matching the
1075      * given CSS selector @p query. Note that the returned NodeList is
1076      * static and not live, and will not be updated when the document
1077      * changes
1078      *
1079      * @since 4.5
1080      */
1081     NodeList querySelectorAll(const DOMString &query) const;
1082 protected:
1083     DocumentFragment(DocumentFragmentImpl *i);
1084 };
1085 
1086 class NamedNodeMap;
1087 class DOMString;
1088 
1089 /**
1090  * Each \c Document has a \c doctype attribute
1091  * whose value is either \c null or a \c DocumentType
1092  * object. The \c DocumentType interface in the
1093  * DOM Level 1 Core provides an interface to the list of entities that
1094  * are defined for the document, and little else because the effect of
1095  * namespaces and the various XML scheme efforts on DTD representation
1096  * are not clearly understood as of this writing.
1097  *
1098  *  The DOM Level 1 doesn't support editing \c DocumentType
1099  * nodes.
1100  *
1101  */
1102 class KHTML_EXPORT DocumentType : public Node
1103 {
1104     friend class Document;
1105     friend class DOMImplementation;
1106 public:
1107     DocumentType();
1108     DocumentType(const DocumentType &other);
1109 
1110     DocumentType(const Node &other) : Node()
1111     {
1112         (*this) = other;
1113     }
1114     DocumentType &operator = (const Node &other);
1115     DocumentType &operator = (const DocumentType &other);
1116 
1117     ~DocumentType();
1118 
1119     /**
1120      * The name of DTD; i.e., the name immediately following the
1121      * \c DOCTYPE keyword.
1122      *
1123      */
1124     DOMString name() const;
1125 
1126     /**
1127      * A \c NamedNodeMap containing the general entities,
1128      * both external and internal, declared in the DTD. Duplicates are
1129      * discarded. For example in: &lt;!DOCTYPE ex SYSTEM "ex.dtd" [
1130      * &lt;!ENTITY foo "foo"> &lt;!ENTITY bar "bar"> &lt;!ENTITY % baz
1131      * "baz"> ]> &lt;ex/> the interface provides access to \c foo
1132      * and \c bar but not \c baz .
1133      * Every node in this map also implements the \c Entity
1134      * interface.
1135      *
1136      *  The DOM Level 1 does not support editing entities, therefore
1137      * \c entities cannot be altered in any way.
1138      *
1139      */
1140     NamedNodeMap entities() const;
1141 
1142     /**
1143      * A \c NamedNodeMap containing the notations declared
1144      * in the DTD. Duplicates are discarded. Every node in this map
1145      * also implements the \c Notation interface.
1146      *
1147      *  The DOM Level 1 does not support editing notations, therefore
1148      * \c notations cannot be altered in any way.
1149      *
1150      */
1151     NamedNodeMap notations() const;
1152 
1153     /**
1154      * Introduced in DOM Level 2
1155      *
1156      * The public identifier of the external subset.
1157      */
1158     DOMString publicId() const;
1159 
1160     /**
1161      * Introduced in DOM Level 2
1162      *
1163      * The system identifier of the external subset.
1164      */
1165     DOMString systemId() const;
1166 
1167     /**
1168      * Introduced in DOM Level 2
1169      *
1170      * The internal subset as a string.
1171      *
1172      * Note: The actual content returned depends on how much information is
1173      * available to the implementation. This may vary depending on various
1174      * parameters, including the XML processor used to build the document.
1175      */
1176     DOMString internalSubset() const;
1177 
1178 protected:
1179     DocumentType(DocumentTypeImpl *impl);
1180 };
1181 
1182 } //namespace
1183 #endif