Bug 677495 - Image documents shouldn't have things other than the <img> in the <body> r=roc

This commit is contained in:
Michael Ventnor
2011-08-11 14:23:00 +10:00
parent de721b2b61
commit b9d4c80dd1
4 changed files with 82 additions and 4 deletions

View File

@@ -649,9 +649,9 @@ ImageDocument::CreateSyntheticDocument()
// This is bad during printing, it means tall image frames won't know
// the size of the paper and cannot break into continuations along
// multiple pages.
Element* body = GetBodyElement();
if (!body) {
NS_WARNING("no body on image document!");
Element* head = GetHeadElement();
if (!head) {
NS_WARNING("no head on image document!");
return NS_ERROR_FAILURE;
}
@@ -666,9 +666,15 @@ ImageDocument::CreateSyntheticDocument()
}
styleContent->SetTextContent(NS_LITERAL_STRING("img { display: block; }"));
body->AppendChildTo(styleContent, PR_FALSE);
head->AppendChildTo(styleContent, PR_FALSE);
// Add the image element
Element* body = GetBodyElement();
if (!body) {
NS_WARNING("no body on image document!");
return NS_ERROR_FAILURE;
}
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::img, nsnull,
kNameSpaceID_XHTML,
nsIDOMNode::ELEMENT_NODE);