Bug 1467802 - part 3: Create EditorBase::GetDocumentCharsetInternal() for internal use of nsIEditor::GetDocumentCharacterSet() r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 18 Jul 2018 21:11:32 +0900
changeset 485147 3348025c8857339635a5b413998cc282b42037b1
parent 485146 c4f14b9849d8e72ade887dada544dc0eae32306c
child 485148 47f713574cb269d5fb0bbb9bbc908131256ad81c
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1467802
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1467802 - part 3: Create EditorBase::GetDocumentCharsetInternal() for internal use of nsIEditor::GetDocumentCharacterSet() r=m_kato This patch creates non-virtual method, EditorBase::GetDocumentCharsetInternal(), for internal use of nsIEditor::GetDocumentCharacterSet() since the virtual call method is redundant and the caller cannot be marked as const. MozReview-Commit-ID: v6kDo2eKg3
editor/libeditor/EditorBase.cpp
editor/libeditor/EditorBase.h
editor/libeditor/TextEditor.cpp
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -1127,23 +1127,29 @@ EditorBase::GetDocumentModified(bool* ou
   int32_t  modCount = 0;
   GetModificationCount(&modCount);
 
   *outDocModified = (modCount != 0);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-EditorBase::GetDocumentCharacterSet(nsACString& characterSet)
+EditorBase::GetDocumentCharacterSet(nsACString& aCharset)
+{
+  return GetDocumentCharsetInternal(aCharset);
+}
+
+nsresult
+EditorBase::GetDocumentCharsetInternal(nsACString& aCharset) const
 {
   nsCOMPtr<nsIDocument> document = GetDocument();
   if (NS_WARN_IF(!document)) {
     return NS_ERROR_UNEXPECTED;
   }
-  document->GetDocumentCharacterSet()->Name(characterSet);
+  document->GetDocumentCharacterSet()->Name(aCharset);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 EditorBase::SetDocumentCharacterSet(const nsACString& characterSet)
 {
   nsCOMPtr<nsIDocument> document = GetDocument();
   if (NS_WARN_IF(!document)) {
--- a/editor/libeditor/EditorBase.h
+++ b/editor/libeditor/EditorBase.h
@@ -1646,16 +1646,21 @@ protected: // Called by helper classes.
 protected: // Shouldn't be used by friend classes
   /**
    * The default destructor. This should suffice. Should this be pure virtual
    * for someone to derive from the EditorBase later? I don't believe so.
    */
   virtual ~EditorBase();
 
   /**
+   * GetDocumentCharsetInternal() returns charset of the document.
+   */
+  nsresult GetDocumentCharsetInternal(nsACString& aCharset) const;
+
+  /**
    * SelectAllInternal() should be used instead of SelectAll() in editor
    * because SelectAll() creates AutoEditActionSetter but we should avoid
    * to create it as far as possible.
    */
   virtual nsresult SelectAllInternal();
 
   nsresult DetermineCurrentDirection();
   void FireInputEvent();
--- a/editor/libeditor/TextEditor.cpp
+++ b/editor/libeditor/TextEditor.cpp
@@ -1806,24 +1806,24 @@ TextEditor::OutputToString(const nsAStri
   if (cancel || NS_FAILED(rv)) {
     return rv;
   }
   if (handled) {
     // This case will get triggered by password fields or single text node only.
     return rv;
   }
 
-  nsAutoCString charsetStr;
-  rv = GetDocumentCharacterSet(charsetStr);
-  if (NS_FAILED(rv) || charsetStr.IsEmpty()) {
-    charsetStr.AssignLiteral("windows-1252");
+  nsAutoCString charset;
+  rv = GetDocumentCharsetInternal(charset);
+  if (NS_FAILED(rv) || charset.IsEmpty()) {
+    charset.AssignLiteral("windows-1252");
   }
 
   nsCOMPtr<nsIDocumentEncoder> encoder =
-    GetAndInitDocEncoder(aFormatType, aFlags, charsetStr);
+    GetAndInitDocEncoder(aFormatType, aFlags, charset);
   if (NS_WARN_IF(!encoder)) {
     return NS_ERROR_FAILURE;
   }
 
   // XXX Why don't we call TextEditRules::DidDoAction() here?
   return encoder->EncodeToString(aOutputString);
 }