htmlparser.h
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 #ifndef HTMLPARSER_H
00030 #define HTMLPARSER_H
00031
00032
00033
00034
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
00100
00101 DOM::NodeImpl *getElement(Token *);
00102
00103 void processCloseTag(Token *);
00104
00105 bool insertNode(DOM::NodeImpl *n, bool flat = false);
00106
00107
00108
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
00128
00129 DOM::HTMLFormElementImpl *form;
00130
00131
00132
00133
00134 DOM::HTMLMapElementImpl *map;
00135
00136
00137
00138
00139 DOM::HTMLHeadElementImpl *head;
00140
00141
00142
00143
00144
00145 DOM::NodeImpl *isindex;
00146 DOM::NodeImpl *handleIsindex( Token *t );
00147
00148
00149
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
00167
00168 int discard_until;
00169
00170 bool headLoaded;
00171
00172 #if SPEED_DEBUG > 0
00173 QTime qt;
00174 #endif
00175 };
00176
00177 };
00178
00179 #endif // HTMLPARSER_H
00180
This file is part of the documentation for kdelibs Version 3.1.0.