mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-05 08:35:26 +00:00
Make HTML5 createContextualFragment support text nodes and documents as context
This commit is contained in:
parent
566e463f3c
commit
5802f70246
@ -3591,11 +3591,7 @@ nsContentUtils::CreateContextualFragment(nsIDOMNode* aContextNode,
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(document));
|
||||
PRBool bHTML = htmlDoc && !bCaseSensitive;
|
||||
|
||||
nsCOMPtr<nsIContent> contextAsContent = do_QueryInterface(aContextNode);
|
||||
|
||||
if (bHTML && contextAsContent && nsContentUtils::GetBoolPref("html5.enable", PR_TRUE)) {
|
||||
// XXX the HTML5 parser can't yet deal with context not being nsIContent
|
||||
|
||||
if (bHTML && nsContentUtils::GetBoolPref("html5.enable", PR_TRUE)) {
|
||||
// See if the document has a cached fragment parser. nsHTMLDocument is the
|
||||
// only one that should really have one at the moment.
|
||||
nsCOMPtr<nsIParser> parser = document->GetFragmentParser();
|
||||
@ -3615,11 +3611,28 @@ nsContentUtils::CreateContextualFragment(nsIDOMNode* aContextNode,
|
||||
rv = NS_NewDocumentFragment(getter_AddRefs(frag), document->NodeInfoManager());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIContent> contextAsContent = do_QueryInterface(aContextNode);
|
||||
if (contextAsContent && !contextAsContent->IsNodeOfType(nsINode::eELEMENT)) {
|
||||
contextAsContent = contextAsContent->GetParent();
|
||||
if (contextAsContent && !contextAsContent->IsNodeOfType(nsINode::eELEMENT)) {
|
||||
// can this even happen?
|
||||
contextAsContent = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
if (contextAsContent) {
|
||||
parser->ParseFragment(aFragment,
|
||||
frag,
|
||||
contextAsContent->Tag(),
|
||||
contextAsContent->GetNameSpaceID(),
|
||||
(document->GetCompatibilityMode() == eCompatibility_NavQuirks));
|
||||
} else {
|
||||
parser->ParseFragment(aFragment,
|
||||
frag,
|
||||
nsGkAtoms::body,
|
||||
kNameSpaceID_XHTML,
|
||||
(document->GetCompatibilityMode() == eCompatibility_NavQuirks));
|
||||
}
|
||||
|
||||
NS_ADDREF(*aReturn = frag);
|
||||
return NS_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user