2 This file is part of the KDE libraries
4 Copyright (C) 1997 Martin Jones (mjones@kde.org)
5 (C) 1997 Torben Weis (weis@kde.org)
6 (C) 1998 Waldo Bastian (bastian@kde.org)
7 (C) 1999 Lars Knoll (knoll@kde.org)
8 (C) 2003 Apple Computer, Inc.
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Library General Public
12 License as published by the Free Software Foundation; either
13 version 2 of the License, or (at your option) any later version.
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Library General Public License for more details.
20 You should have received a copy of the GNU Library General Public License
21 along with this library; see the file COPYING.LIB. If not, write to
22 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 Boston, MA 02110-1301, USA.
25 //----------------------------------------------------------------------------
27 // KDE HTML Widget -- HTML Parser
33 // 1 domtree + rendertree + styleForElement, no layouting
42 #include "dom/dom_string.h"
43 #include "xml/dom_nodeimpl.h"
44 #include "html/html_documentimpl.h"
50 class HTMLDocumentImpl
;
53 class HTMLFormElementImpl
;
54 class HTMLMapElementImpl
;
55 class HTMLHeadElementImpl
;
56 class DocumentFragmentImpl
;
65 * The parser for html. It receives a stream of tokens from the HTMLTokenizer, and
66 * builds up the Document structure form it.
71 KHTMLParser( KHTMLView
*w
, DOM::DocumentImpl
*i
);
72 KHTMLParser( DOM::DocumentFragmentImpl
*frag
, DOM::DocumentImpl
*doc
);
73 virtual ~KHTMLParser();
76 * parses one token delivered by the tokenizer
78 void parseToken(Token
*_t
);
81 * parses a doctype token delivered by the tokenizer
83 void parseDoctypeToken(DoctypeToken
*_t
);
90 bool skipMode() const { return (discard_until
!= 0); }
91 bool noSpaces() const { return (inSelect
|| !m_inline
|| !inBody
); }
92 bool selectMode() const { return inSelect
; }
94 DOM::HTMLDocumentImpl
*doc() const { return static_cast<DOM::HTMLDocumentImpl
*>(document
); }
95 DOM::DocumentImpl
*docPtr() const { return document
; }
99 KHTMLView
*HTMLWidget
;
100 DOM::DocumentImpl
*document
;
103 * generate an element from the token
105 DOM::NodeImpl
*getElement(Token
*);
107 void processCloseTag(Token
*);
109 bool insertNode(DOM::NodeImpl
*n
, bool flat
= false);
112 * The currently active element (the one new elements will be added to)
114 void setCurrent( DOM::NodeImpl
* newNode
)
116 if ( newNode
) newNode
->ref();
117 if ( current
) current
->deref();
122 DOM::NodeImpl
*current
;
124 HTMLStackElem
*blockStack
;
126 void pushBlock( int _id
, int _level
);
128 void generateImpliedEndTags( int _id
);
129 void popOptionalBlock( int _id
);
130 void popBlock( int _id
);
131 void popOneBlock(bool delBlock
= true);
132 void popInlineBlocks();
134 void freeBlock( void);
138 bool isResidualStyleTag(int _id
);
139 bool isAffectedByResidualStyle(int _id
);
140 void handleResidualStyleCloseTagAcrossBlocks(HTMLStackElem
* elem
);
141 void reopenResidualStyleTags(HTMLStackElem
* elem
, DOM::NodeImpl
* malformedTableParent
);
143 ushort
*forbiddenTag
;
146 * currently active form
148 DOM::HTMLFormElementImpl
*form
;
153 DOM::HTMLMapElementImpl
*map
;
156 * the head element. Needed for crappy html which defines <base> after </head>
158 DOM::HTMLHeadElementImpl
*head
;
161 * a possible <isindex> element in the head. Compatibility hack for
162 * html from the stone age
164 DOM::NodeImpl
*isindex
;
165 DOM::NodeImpl
*handleIsindex( Token
*t
);
168 * inserts the stupid isIndex element.
183 * tells the parser to discard all tags, until it reaches the one specified
188 int inStrayTableContent
;
197 #endif // HTMLPARSER_H