Bug 414637 - "createContextualFragment() throws NS_ERROR_NOT_AVAILABLE" (allow contextfragments when container is document) [p=Olli.Pettay@gmail.com (Smaug) r+sr=sicking a=blocking1.9+]

This commit is contained in:
reed@reedloden.com 2008-02-07 01:45:14 -08:00
parent cd62dde4a7
commit fe86f10203

View File

@ -3329,19 +3329,19 @@ nsContentUtils::CreateContextualFragment(nsIDOMNode* aContextNode,
nsCOMPtr<nsIParser> parser = do_CreateInstance(kCParserCID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIContent> content = do_QueryInterface(aContextNode);
NS_ENSURE_TRUE(content, NS_ERROR_NOT_AVAILABLE);
nsCOMPtr<nsINode> node = do_QueryInterface(aContextNode);
NS_ENSURE_TRUE(node, NS_ERROR_NOT_AVAILABLE);
// If we don't have a document here, we can't get the right security context
// for compiling event handlers... so just bail out.
nsCOMPtr<nsIDocument> document = content->GetOwnerDoc();
nsCOMPtr<nsIDocument> document = node->GetOwnerDoc();
NS_ENSURE_TRUE(document, NS_ERROR_NOT_AVAILABLE);
nsAutoTArray<nsAutoString, 32> tagStack;
nsAutoString uriStr, nameStr;
nsCOMPtr<nsIContent> content = do_QueryInterface(aContextNode);
// just in case we have a text node
if (!content->IsNodeOfType(nsINode::eELEMENT))
if (content && !content->IsNodeOfType(nsINode::eELEMENT))
content = content->GetParent();
while (content && content->IsNodeOfType(nsINode::eELEMENT)) {