Bug 1360137 - Part 2. Reduce QueryInterface by NativeInit. r?masayuki
nsIDocumentEncoder has nativeInit for nsIDocumnet, we should use it to reduce QueryInterface.
MozReview-Commit-ID: Ffn19yf9jra
--- a/editor/libeditor/TextEditor.cpp
+++ b/editor/libeditor/TextEditor.cpp
@@ -1186,22 +1186,23 @@ TextEditor::GetAndInitDocEncoder(const n
return nullptr;
}
mCachedDocumentEncoder = docEncoder;
mCachedDocumentEncoderType = aFormatType;
} else {
docEncoder = mCachedDocumentEncoder;
}
- nsCOMPtr<nsIDOMDocument> domDoc = do_QueryReferent(mDocWeak);
- NS_ASSERTION(domDoc, "Need a document");
+ nsCOMPtr<nsIDocument> doc = GetDocument();
+ NS_ASSERTION(doc, "Need a document");
nsresult rv =
- docEncoder->Init(domDoc, aFormatType,
- aFlags | nsIDocumentEncoder::RequiresReinitAfterOutput);
+ docEncoder->NativeInit(
+ doc, aFormatType,
+ aFlags | nsIDocumentEncoder::RequiresReinitAfterOutput);
if (NS_WARN_IF(NS_FAILED(rv))) {
return nullptr;
}
if (!aCharset.IsEmpty() && !aCharset.EqualsLiteral("null")) {
docEncoder->SetCharset(aCharset);
}