khtml Library API Documentation

htmlparser.h

00001 /*
00002     This file is part of the KDE libraries
00003 
00004     Copyright (C) 1997 Martin Jones (mjones@kde.org)
00005               (C) 1997 Torben Weis (weis@kde.org)
00006               (C) 1998 Waldo Bastian (bastian@kde.org)
00007               (C) 1999 Lars Knoll (knoll@kde.org)
00008 
00009     This library is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU Library General Public
00011     License as published by the Free Software Foundation; either
00012     version 2 of the License, or (at your option) any later version.
00013 
00014     This library is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017     Library General Public License for more details.
00018 
00019     You should have received a copy of the GNU Library General Public License
00020     along with this library; see the file COPYING.LIB.  If not, write to
00021     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00022     Boston, MA 02111-1307, USA.
00023 */
00024 //----------------------------------------------------------------------------
00025 //
00026 // KDE HTML Widget -- HTML Parser
00027 // $Id: htmlparser.h,v 1.59.2.2 2003/01/13 22:04:48 mueller Exp $
00028 
00029 #ifndef HTMLPARSER_H
00030 #define HTMLPARSER_H
00031 
00032 // 0 all
00033 // 1 domtree + rendertree + styleForElement, no layouting
00034 // 2 domtree only
00035 #define SPEED_DEBUG 0
00036 
00037 #ifdef SPEED_DEBUG
00038 #include <qdatetime.h>
00039 #endif
00040 
00041 
00042 #include "dom/dom_string.h"
00043 #include "xml/dom_nodeimpl.h"
00044 #include "html/html_documentimpl.h"
00045 
00046 class KHTMLView;
00047 class HTMLStackElem;
00048 
00049 namespace DOM {
00050     class HTMLDocumentImpl;
00051     class DocumentPtr;
00052     class HTMLElementImpl;
00053     class NodeImpl;
00054     class HTMLFormElementImpl;
00055     class HTMLMapElementImpl;
00056     class HTMLHeadElementImpl;
00057     class DocumentFragmentImpl;
00058 };
00059 
00060 namespace khtml {
00061 
00062 class Token;
00063 
00068 class KHTMLParser
00069 {
00070 public:
00071     KHTMLParser( KHTMLView *w, DOM::DocumentPtr *i );
00072     KHTMLParser( DOM::DocumentFragmentImpl *frag, DOM::DocumentPtr *doc );
00073     virtual ~KHTMLParser();
00074 
00078     void parseToken(Token *_t);
00079 
00083     void reset();
00084 
00085     bool skipMode() const { return (discard_until != 0); }
00086     bool noSpaces() const { return (inSelect || !m_inline  || !inBody); }
00087     bool preMode() const { return inPre; }
00088     bool selectMode() const { return inSelect; }
00089 
00090     DOM::HTMLDocumentImpl *doc() const { return static_cast<DOM::HTMLDocumentImpl *>(document->document()); }
00091     DOM::DocumentPtr *docPtr() const { return document; }
00092 
00093 protected:
00094 
00095     KHTMLView *HTMLWidget;
00096     DOM::DocumentPtr *document;
00097 
00098     /*
00099      * generate an element from the token
00100      */
00101     DOM::NodeImpl *getElement(Token *);
00102 
00103     void processCloseTag(Token *);
00104 
00105     bool insertNode(DOM::NodeImpl *n, bool flat = false);
00106 
00107     /*
00108      * The currently active element (the one new elements will be added to)
00109      */
00110     DOM::NodeImpl *current;
00111 
00112     HTMLStackElem *blockStack;
00113 
00114     void pushBlock( int _id, int _level);
00115 
00116     void popBlock( int _id );
00117     void popOneBlock();
00118     void popInlineBlocks();
00119 
00120     void freeBlock( void);
00121 
00122     void createHead();
00123 
00124     ushort *forbiddenTag;
00125 
00126     /*
00127      * currently active form
00128      */
00129     DOM::HTMLFormElementImpl *form;
00130 
00131     /*
00132      * current map
00133      */
00134     DOM::HTMLMapElementImpl *map;
00135 
00136     /*
00137      * the head element. Needed for crappy html which defines <base> after </head>
00138      */
00139     DOM::HTMLHeadElementImpl *head;
00140 
00141     /*
00142      * a possible <isindex> element in the head. Compatibility hack for
00143      * html from the stone age
00144      */
00145     DOM::NodeImpl *isindex;
00146     DOM::NodeImpl *handleIsindex( Token *t );
00147 
00148     /*
00149      * inserts the stupid isIndex element.
00150      */
00151     void startBody();
00152 
00153     bool inBody;
00154     bool haveContent;
00155     bool haveBody;
00156     bool haveFrameSet;
00157     bool m_inline;
00158     bool end;
00159     bool haveKonqBlock;
00160     bool inSelect;
00161 
00162 
00163     int inPre;
00164 
00165     /*
00166      * tells the parser to discard all tags, until it reaches the one specified
00167      */
00168     int discard_until;
00169 
00170     bool headLoaded;
00171 
00172 #if SPEED_DEBUG > 0
00173     QTime qt;
00174 #endif
00175 };
00176 
00177 }; // namespace khtml
00178 
00179 #endif // HTMLPARSER_H
00180 
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.0.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Oct 8 12:22:38 2003 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2001