Bug 1264876 - Remove StripCites() from nsIEditorMailSupport r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 19 Jul 2018 16:55:31 +0900
changeset 427455 b891899b2036de7b47cf96790c581fb704588c78
parent 427454 c736dc02532d32e5befd401b89fcdd520832b6ef
child 427456 b2f2361ee3175a867335952705274d8d08cc086f
push id34306
push usercsabou@mozilla.com
push dateFri, 20 Jul 2018 21:41:18 +0000
treeherdermozilla-central@d6a5e8aea651 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1264876
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 1264876 - Remove StripCites() from nsIEditorMailSupport r=m_kato nsIEditorMailSupport::StripCites() is used only by QA addon of Seamonkey. So, this is not necessary API now. This patch removes it and removes its helper classes in InternetCiter. MozReview-Commit-ID: 4Esl3GXzo0U
editor/libeditor/HTMLEditorDataTransfer.cpp
editor/libeditor/InternetCiter.cpp
editor/libeditor/InternetCiter.h
editor/libeditor/TextEditor.cpp
editor/nsIEditorMailSupport.idl
--- a/editor/libeditor/HTMLEditorDataTransfer.cpp
+++ b/editor/libeditor/HTMLEditorDataTransfer.cpp
@@ -1858,22 +1858,16 @@ HTMLEditor::InsertAsPlaintextQuotation(c
     }
   }
 
   // XXX Why don't we call HTMLEditRules::DidDoAction() here?
   return rv;
 }
 
 NS_IMETHODIMP
-HTMLEditor::StripCites()
-{
-  return TextEditor::StripCites();
-}
-
-NS_IMETHODIMP
 HTMLEditor::Rewrap(bool aRespectNewlines)
 {
   return TextEditor::Rewrap(aRespectNewlines);
 }
 
 NS_IMETHODIMP
 HTMLEditor::InsertAsCitedQuotation(const nsAString& aQuotedText,
                                    const nsAString& aCitation,
--- a/editor/libeditor/InternetCiter.cpp
+++ b/editor/libeditor/InternetCiter.cpp
@@ -62,69 +62,16 @@ InternetCiter::GetCiteString(const nsASt
   }
 
   if (uch != nl) {
     aOutString += nl;
   }
   return NS_OK;
 }
 
-nsresult
-InternetCiter::StripCitesAndLinebreaks(const nsAString& aInString,
-                                       nsAString& aOutString,
-                                       bool aLinebreaksToo,
-                                       int32_t* aCiteLevel)
-{
-  if (aCiteLevel) {
-    *aCiteLevel = 0;
-  }
-
-  aOutString.Truncate();
-  nsReadingIterator <char16_t> beginIter,endIter;
-  aInString.BeginReading(beginIter);
-  aInString.EndReading(endIter);
-  while (beginIter!= endIter) { // loop over lines
-    // Clear out cites first, at the beginning of the line:
-    int32_t thisLineCiteLevel = 0;
-    while (beginIter!= endIter &&
-           (*beginIter == gt || nsCRT::IsAsciiSpace(*beginIter))) {
-      if (*beginIter == gt) {
-        ++thisLineCiteLevel;
-      }
-      ++beginIter;
-    }
-    // Now copy characters until line end:
-    while (beginIter != endIter && (*beginIter != '\r' && *beginIter != '\n')) {
-      aOutString.Append(*beginIter);
-      ++beginIter;
-    }
-    if (aLinebreaksToo) {
-      aOutString.Append(char16_t(' '));
-    } else {
-      aOutString.Append(char16_t('\n'));    // DOM linebreaks, not NS_LINEBREAK
-    }
-    // Skip over any more consecutive linebreak-like characters:
-    while (beginIter != endIter && (*beginIter == '\r' || *beginIter == '\n')) {
-      ++beginIter;
-    }
-    // Done with this line -- update cite level
-    if (aCiteLevel && (thisLineCiteLevel > *aCiteLevel)) {
-      *aCiteLevel = thisLineCiteLevel;
-    }
-  }
-  return NS_OK;
-}
-
-nsresult
-InternetCiter::StripCites(const nsAString& aInString,
-                          nsAString& aOutString)
-{
-  return StripCitesAndLinebreaks(aInString, aOutString, false, 0);
-}
-
 static void AddCite(nsAString& aOutString, int32_t citeLevel)
 {
   for (int32_t i = 0; i < citeLevel; ++i) {
     aOutString.Append(gt);
   }
   if (citeLevel > 0) {
     aOutString.Append(space);
   }
--- a/editor/libeditor/InternetCiter.h
+++ b/editor/libeditor/InternetCiter.h
@@ -15,26 +15,17 @@ namespace mozilla {
  * Mail citations using standard Internet style.
  */
 class InternetCiter final
 {
 public:
   static nsresult GetCiteString(const nsAString& aInString,
                                 nsAString& aOutString);
 
-  static nsresult StripCites(const nsAString& aInString,
-                             nsAString& aOutString);
-
   static nsresult Rewrap(const nsAString& aInString,
                          uint32_t aWrapCol, uint32_t aFirstLineOffset,
                          bool aRespectNewlines,
                          nsAString& aOutString);
-
-protected:
-  static nsresult StripCitesAndLinebreaks(const nsAString& aInString,
-                                          nsAString& aOutString,
-                                          bool aLinebreaksToo,
-                                          int32_t* aCiteLevel);
 };
 
 } // namespace mozilla
 
 #endif // #ifndef InternetCiter_h
--- a/editor/libeditor/TextEditor.cpp
+++ b/editor/libeditor/TextEditor.cpp
@@ -1994,43 +1994,16 @@ TextEditor::Rewrap(bool aRespectNewlines
     DebugOnly<nsresult> rv = SelectAllInternal();
     NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),  "Failed to select all text");
   }
 
   return InsertTextWithQuotations(wrapped);
 }
 
 NS_IMETHODIMP
-TextEditor::StripCites()
-{
-  nsAutoString current;
-  bool isCollapsed;
-  nsresult rv = SharedOutputString(nsIDocumentEncoder::OutputFormatted,
-                                   &isCollapsed, current);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsString stripped;
-  rv = InternetCiter::StripCites(current, stripped);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  if (isCollapsed) {
-    rv = SelectAllInternal();
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      return rv;
-    }
-  }
-
-  rv = InsertTextAsAction(stripped);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return rv;
-  }
-  return NS_OK;
-}
-
-NS_IMETHODIMP
 TextEditor::GetEmbeddedObjects(nsIArray** aNodeList)
 {
   if (NS_WARN_IF(!aNodeList)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   *aNodeList = nullptr;
   return NS_OK;
--- a/editor/nsIEditorMailSupport.idl
+++ b/editor/nsIEditorMailSupport.idl
@@ -55,19 +55,13 @@ interface nsIEditorMailSupport : nsISupp
 
   /**
    * Rewrap the selected part of the document, re-quoting if necessary.
    * @param aRespectNewlines  Try to maintain newlines in the original?
    */
   void rewrap(in boolean aRespectNewlines);
 
   /**
-   * Strip any citations in the selected part of the document.
-   */
-  void stripCites();
-
-
-  /**
    * Get a list of IMG and OBJECT tags in the current document.
    */
   nsIArray getEmbeddedObjects();
 };