Bug 1264876 - Remove StripCites() from nsIEditorMailSupport r?m_kato draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 19 Jul 2018 16:55:31 +0900
changeset 820240 0c7e8fb44aa8f820a9a5a38b11f674387e1dff77
parent 820239 3d6bc34b5042e6cda4b72e95b86f6298628fdf87
child 820345 80a38c74f2e7c3c479e4711b1c7120ad75bc272c
push id116766
push usermasayuki@d-toybox.com
push dateThu, 19 Jul 2018 08:59:06 +0000
reviewersm_kato
bugs1264876
milestone63.0a1
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();
 };