Bug 1360137 - Part 2. Reduce QueryInterface by NativeInit. r?masayuki draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Thu, 27 Apr 2017 17:41:26 +0900
changeset 569280 a285938311b4d75a3caada99a56da13c5a2ae45f
parent 569279 26b6039441fe31dd0930f0a63bd99a5787c990f7
child 626162 f6047dc18e2ae1fd86beae3e4c33e43c3b0244e0
push id56124
push userm_kato@ga2.so-net.ne.jp
push dateThu, 27 Apr 2017 08:50:23 +0000
reviewersmasayuki
bugs1360137
milestone55.0a1
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
editor/libeditor/TextEditor.cpp
--- 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);
   }