Bug 596182 - Make fragment parsers global. Remove resulting dead code. r=Olli.Pettay, r=bzbarsky.

This commit is contained in:
Henri Sivonen
2011-08-01 10:48:24 +03:00
parent ca061c97f8
commit 2fa0fb46af
34 changed files with 359 additions and 1233 deletions

View File

@@ -2689,24 +2689,17 @@ nsresult nsHTMLEditor::ParseFragment(const nsAString & aFragStr,
nsCOMPtr<nsIDOMNode> *outNode,
PRBool aTrustedInput)
{
// The old code created a new parser every time. This is inefficient.
// However, the target document is not required to be an HTML document,
// So avoid using the cached parser of aDocument. Once bug 596182 is fixed,
// use the global parser here.
nsCOMPtr<nsIParser> parser = nsHtml5Module::NewHtml5Parser();
nsAHtml5FragmentParser* asFragmentParser =
static_cast<nsAHtml5FragmentParser*> (parser.get());
nsCOMPtr<nsIDOMDocumentFragment> frag;
NS_NewDocumentFragment(getter_AddRefs(frag),
aTargetDocument->NodeInfoManager());
nsCOMPtr<nsIContent> fragment = do_QueryInterface(frag);
asFragmentParser->ParseHtml5Fragment(aFragStr,
fragment,
aContextLocalName ?
aContextLocalName : nsGkAtoms::body,
kNameSpaceID_XHTML,
PR_FALSE,
PR_TRUE);
nsContentUtils::ParseFragmentHTML(aFragStr,
fragment,
aContextLocalName ?
aContextLocalName : nsGkAtoms::body,
kNameSpaceID_XHTML,
PR_FALSE,
PR_TRUE);
if (!aTrustedInput) {
nsTreeSanitizer sanitizer(!!aContextLocalName, !aContextLocalName);
sanitizer.Sanitize(fragment);