Commit 1f64f81b authored by Lars Knoll's avatar Lars Knoll

another fix for really stupid HTML that NS accepts.

<html><center><frameset> will now load the frameset.

svn path=/trunk/kdelibs/; revision=79402
parent 59fd345a
......@@ -137,7 +137,7 @@ HTMLElement HTMLDocument::body() const
void HTMLDocument::setBody(const HTMLElement &_body)
{
if (!impl) return;
((HTMLDocumentImpl *)impl)->setBody(_body);
((HTMLDocumentImpl *)impl)->setBody(static_cast<HTMLElementImpl *>(_body.handle()));
return;
}
......
......@@ -115,9 +115,16 @@ HTMLElementImpl *HTMLDocumentImpl::body()
return static_cast<HTMLElementImpl *>(b);
}
void HTMLDocumentImpl::setBody(const HTMLElement &/*_body*/)
{
// ###
void HTMLDocumentImpl::setBody(HTMLElementImpl *_body)
{
int exceptioncode = 0;
HTMLElementImpl *b = body();
if ( !_body && !b ) return;
if ( !_body )
documentElement()->removeChild( body(), exceptioncode );
if ( !b )
documentElement()->appendChild( _body, exceptioncode );
documentElement()->replaceChild( _body, body(), exceptioncode );
}
Tokenizer *HTMLDocumentImpl::createTokenizer()
......
......@@ -60,7 +60,7 @@ public:
DOMString domain() const;
HTMLElementImpl *body();
void setBody(const HTMLElement &_body);
void setBody(HTMLElementImpl *_body);
virtual Tokenizer *createTokenizer();
NodeListImpl *getElementsByName ( const DOMString &elementName );
......
......@@ -128,7 +128,7 @@ void HTMLOListElementImpl::parseAttribute(AttrImpl *attr)
addCSSProperty(CSS_PROP_LIST_STYLE_TYPE, "decimal");
break;
case ATTR_START:
// ###
_start = attr->val() ? attr->val()->toInt() : 1;
default:
HTMLUListElementImpl::parseAttribute(attr);
}
......
......@@ -50,6 +50,7 @@ public:
virtual void parseAttribute(AttrImpl *);
virtual void attach(KHTMLView *);
virtual int start() const { return 1; }
};
// -------------------------------------------------------------------------
......@@ -103,6 +104,10 @@ public:
virtual void parseAttribute(AttrImpl *);
virtual void attach(KHTMLView *);
int start() const { return _start; }
private:
int _start;
};
// -------------------------------------------------------------------------
......
......@@ -273,6 +273,7 @@ void KHTMLParser::reset()
memset(forbiddenTag, 0, (ID_CLOSE_TAG+1)*sizeof(ushort));
inBody = false;
noRealBody = true;
haveFrameSet = false;
_inline = false;
......@@ -317,13 +318,16 @@ void KHTMLParser::parseToken(Token *t)
}
// ignore spaces, if we're not inside a paragraph or other inline code
if( t->id == ID_TEXT && (!_inline || !inBody) )
{
if( t->id == ID_TEXT ) {
#ifdef PARSER_DEBUG
kdDebug(6035) << "length="<< t->text.length() << "text='" << t->text.string() << "'" << endl;
kdDebug(6035) << "length="<< t->text.length() << "text='" << t->text.string() << "'" << endl;
#endif
if(t->text.length() == 1 && t->text[0].latin1() == ' ')
return;
if (!_inline || !inBody) {
if(t->text.length() == 1 && t->text[0].latin1() == ' ')
return;
} else if ( inBody ) {
noRealBody = false;
}
}
......@@ -517,6 +521,7 @@ bool KHTMLParser::insertNode(NodeImpl *n)
if(!bodymap->getNamedItem(static_cast<AttrImpl*>(map->item(attrNo))->name()))
document->body()->setAttributeNode(static_cast<AttrImpl*>(map->item(attrNo)->cloneNode(false,exceptioncode)), exceptioncode);
document->body()->applyChanges();
noRealBody = false;
} else if ( current->isDocumentNode() )
break;
return false;
......@@ -864,6 +869,7 @@ NodeImpl *KHTMLParser::getElement(Token *t)
popBlock(ID_HEAD);
n = new HTMLBodyElementImpl(document);
startBody();
noRealBody = false;
break;
// head elements
......@@ -889,11 +895,14 @@ NodeImpl *KHTMLParser::getElement(Token *t)
break;
case ID_FRAMESET:
popBlock(ID_HEAD);
if ( inBody && noRealBody )
removeBody();
if ( haveFrameSet && current->id() == ID_HTML )
break;
n = new HTMLFrameSetElementImpl(document);
haveFrameSet = true;
startBody();
noRealBody = false;
break;
// a bit a special case, since the frame is inlined...
case ID_IFRAME:
......@@ -1345,3 +1354,11 @@ void KHTMLParser::startBody()
isindex = 0;
}
}
void KHTMLParser::removeBody()
{
popBlock( ID_BODY );
document->setBody( 0 );
inBody = false;
noRealBody = true;
}
......@@ -134,8 +134,16 @@ protected:
* inserts the stupid isIndex element.
*/
void startBody();
/*
* removes the body element with it's contents. Needed for broken stuff as <html><center><frameset>
*/
void removeBody();
bool inBody;
// in case we haven't found an explicit body element up to now, this is true.
// needed for broken HTML as: <center><frameset>... as the center element creates an implicit body
bool noRealBody;
bool haveFrameSet;
bool _inline;
bool end;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment