diff -r 30342f40acbf -r e1bea15f9a39 webengine/osswebengine/WebCore/html/HTMLParser.cpp --- a/webengine/osswebengine/WebCore/html/HTMLParser.cpp Thu Jul 15 19:53:20 2010 +0300 +++ b/webengine/osswebengine/WebCore/html/HTMLParser.cpp Thu Aug 19 10:58:56 2010 +0300 @@ -380,7 +380,7 @@ } } else if (h->hasLocalName(htmlTag)) { if (!current->isDocumentNode() ) { - if (document->documentElement()->hasTagName(htmlTag)) { + if (document->documentElement()->hasTagName(htmlTag) && !m_isParsingFragment) { reportError(RedundantHTMLBodyError, &localName); // we have another element.... apply attributes to existing one // make sure we don't overwrite already existing attributes @@ -422,7 +422,7 @@ return false; } } else if (h->hasLocalName(bodyTag)) { - if (inBody && document->body()) { + if (inBody && document->body() && !m_isParsingFragment) { // we have another element.... apply attributes to existing one // make sure we don't overwrite already existing attributes // some sites use ... @@ -677,7 +677,7 @@ // we can't implement that behaviour now because it could cause too many // regressions and the headaches are not worth the work as long as there is // no site actually relying on that detail (Dirk) - if (document->body()) + if (document->body() && !m_isParsingFragment) document->body()->setAttribute(styleAttr, "display:none"); inBody = false; } @@ -1162,7 +1162,8 @@ prevMaxElem->next = elem; ASSERT(newNodePtr); prevMaxElem->node = newNodePtr; - prevMaxElem->didRefNode = false; + newNodePtr->ref(); + prevMaxElem->didRefNode = true; } else delete elem; } @@ -1392,6 +1393,10 @@ return; head = new HTMLHeadElement(document); + + if (m_isParsingFragment) + return; + HTMLElement* body = document->body(); ExceptionCode ec = 0; document->documentElement()->insertBefore(head, body, ec);