#ifndef HTMLPARSER_H
#define HTMLPARSER_H
#define SPEED_DEBUG 0
#ifdef SPEED_DEBUG
#include <qdatetime.h>
#endif
#include "dom/dom_string.h"
#include "xml/dom_nodeimpl.h"
#include "html/html_documentimpl.h"
class KHTMLView;
class HTMLStackElem;
namespace DOM {
class HTMLDocumentImpl;
class DocumentPtr;
class HTMLElementImpl;
class NodeImpl;
class HTMLFormElementImpl;
class HTMLMapElementImpl;
class HTMLHeadElementImpl;
class DocumentFragmentImpl;
}
namespace khtml {
class Token;
};
class KHTMLParser;
class KHTMLParser
{
public:
KHTMLParser( KHTMLView *w, DOM::DocumentPtr *i );
KHTMLParser( DOM::DocumentFragmentImpl *frag, DOM::DocumentPtr *doc );
virtual ~KHTMLParser();
void parseToken(khtml::Token *_t);
void finished();
void reset();
bool skipMode() const { return (discard_until != 0); }
bool noSpaces() const { return !inBody; }
bool selectMode() const { return inSelect; }
DOM::HTMLDocumentImpl *doc() const { return static_cast<DOM::HTMLDocumentImpl *>(document->document()); }
DOM::DocumentPtr *docPtr() const { return document; }
protected:
void setCurrent(DOM::NodeImpl *newCurrent);
KHTMLView *HTMLWidget;
DOM::DocumentPtr *document;
DOM::NodeImpl *getElement(khtml::Token *);
void processCloseTag(khtml::Token *);
bool insertNode(DOM::NodeImpl *n, bool flat = false);
DOM::NodeImpl *current;
HTMLStackElem *blockStack;
void pushBlock( int _id, int _level);
void popBlock( int _id );
void popOneBlock(bool delBlock = true);
void popInlineBlocks();
void freeBlock( void);
void createHead();
bool isResidualStyleTag(int _id);
bool isAffectedByResidualStyle(int _id);
void handleResidualStyleCloseTagAcrossBlocks(HTMLStackElem* elem);
void reopenResidualStyleTags(HTMLStackElem* elem, DOM::NodeImpl* malformedTableParent);
bool allowNestedRedundantTag(int _id);
ushort *forbiddenTag;
DOM::HTMLFormElementImpl *form;
DOM::HTMLMapElementImpl *map;
DOM::HTMLHeadElementImpl *head;
DOM::NodeImpl *isindex;
DOM::NodeImpl *handleIsindex( khtml::Token *t );
void startBody();
bool inBody;
bool haveContent;
bool haveFrameSet;
bool end;
bool inSelect;
int discard_until;
bool headLoaded;
int inStrayTableContent;
#if SPEED_DEBUG > 0
QTime qt;
#endif
};
#endif // HTMLPARSER_H