/* * This file is part of the DOM implementation for KDE. * * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2001 Dirk Mueller (mueller@kde.org) * Copyright (C) 2003 Apple Computer, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * */ #ifndef _DOM_DocumentImpl_h_ #define _DOM_DocumentImpl_h_ #include "xml/dom_elementimpl.h" #include "xml/dom2_traversalimpl.h" #include "misc/shared.h" #include #include #include #include #include #include #include #if APPLE_CHANGES #include "KWQSignal.h" #include "decoder.h" #endif class QPaintDevice; class QPaintDeviceMetrics; class KHTMLView; class KHTMLPart; class Tokenizer; class RenderArena; #if APPLE_CHANGES class KWQAccObjectCache; #endif namespace khtml { class CSSStyleSelector; class DocLoader; class CSSStyleSelectorList; class RenderImage; } namespace DOM { class AbstractViewImpl; class AttrImpl; class CDATASectionImpl; class CSSStyleSheetImpl; class CommentImpl; class DocumentFragmentImpl; class DocumentImpl; class DocumentType; class DocumentTypeImpl; #if APPLE_CHANGES class DOMImplementation; #endif class ElementImpl; class EntityReferenceImpl; class EventImpl; class EventListener; class GenericRONamedNodeMapImpl; class HTMLDocumentImpl; class HTMLElementImpl; class NodeFilter; class NodeFilterImpl; class NodeIteratorImpl; class NodeListImpl; class ProcessingInstructionImpl; class RangeImpl; class RegisteredEventListener; class StyleSheetImpl; class StyleSheetListImpl; class TextImpl; class TreeWalkerImpl; class DOMImplementationImpl : public khtml::Shared { public: DOMImplementationImpl(); ~DOMImplementationImpl(); // DOM methods & attributes for DOMImplementation bool hasFeature ( const DOMString &feature, const DOMString &version ); DocumentTypeImpl *createDocumentType( const DOMString &qualifiedName, const DOMString &publicId, const DOMString &systemId, int &exceptioncode ); DocumentImpl *createDocument( const DOMString &namespaceURI, const DOMString &qualifiedName, const DocumentType &doctype, int &exceptioncode ); DOMImplementationImpl* getInterface(const DOMString& feature) const; // From the DOMImplementationCSS interface CSSStyleSheetImpl *createCSSStyleSheet(DOMStringImpl *title, DOMStringImpl *media, int &exceptioncode); // From the HTMLDOMImplementation interface HTMLDocumentImpl* createHTMLDocument( const DOMString& title); // Other methods (not part of DOM) DocumentImpl *createDocument( KHTMLView *v = 0 ); HTMLDocumentImpl *createHTMLDocument( KHTMLView *v = 0 ); // Returns the static instance of this class - only one instance of this class should // ever be present, and is used as a factory method for creating DocumentImpl objects static DOMImplementationImpl *instance(); #if APPLE_CHANGES static DOMImplementation createInstance (DOMImplementationImpl *impl); #endif protected: static DOMImplementationImpl *m_instance; }; /** * @internal */ class DocumentImpl : public QObject, public NodeBaseImpl { Q_OBJECT public: DocumentImpl(DOMImplementationImpl *_implementation, KHTMLView *v); ~DocumentImpl(); // DOM methods & attributes for Document DocumentTypeImpl *doctype() const; DOMImplementationImpl *implementation() const; ElementImpl *documentElement() const; virtual ElementImpl *createElement ( const DOMString &tagName, int &exceptioncode ); DocumentFragmentImpl *createDocumentFragment (); TextImpl *createTextNode ( const DOMString &data ); CommentImpl *createComment ( const DOMString &data ); CDATASectionImpl *createCDATASection ( const DOMString &data ); ProcessingInstructionImpl *createProcessingInstruction ( const DOMString &target, const DOMString &data ); Attr createAttribute(NodeImpl::Id id); EntityReferenceImpl *createEntityReference ( const DOMString &name ); NodeImpl *importNode( NodeImpl *importedNode, bool deep, int &exceptioncode ); virtual ElementImpl *createElementNS ( const DOMString &_namespaceURI, const DOMString &_qualifiedName, int &exceptioncode ); ElementImpl *getElementById ( const DOMString &elementId ) const; // Actually part of HTMLDocument, but used for giving XML documents a window title as well DOMString title() const { return m_title; } void setTitle(DOMString _title); // DOM methods overridden from parent classes virtual DOMString nodeName() const; virtual unsigned short nodeType() const; // Other methods (not part of DOM) virtual bool isDocumentNode() const { return true; } virtual bool isHTMLDocument() const { return false; } virtual ElementImpl *createHTMLElement ( const DOMString &tagName, int &exceptioncode ); khtml::CSSStyleSelector *styleSelector() { return m_styleSelector; } ElementImpl *DocumentImpl::getElementByAccessKey( const DOMString &key ); /** * Updates the pending sheet count and then calls updateStyleSelector. */ void stylesheetLoaded(); /** * This method returns true if all top-level stylesheets have loaded (including * any @imports that they may be loading). */ bool haveStylesheetsLoaded() { return m_pendingStylesheets <= 0 || m_ignorePendingStylesheets; } /** * Increments the number of pending sheets. The elements * invoke this to add themselves to the loading list. */ void addPendingSheet() { m_pendingStylesheets++; } /** * Called when one or more stylesheets in the document may have been added, removed or changed. * * Creates a new style selector and assign it to this document. This is done by iterating through all nodes in * document (or those before in a HTML document), searching for stylesheets. Stylesheets can be contained in * ,