Bug 1260651 part.36 Rename nsInternetCiter to mozilla::InternetCiter (and their files too) r=mccr8
MozReview-Commit-ID: IGznbRrkf23
rename from editor/libeditor/nsInternetCiter.cpp
rename to editor/libeditor/InternetCiter.cpp
--- a/editor/libeditor/nsInternetCiter.cpp
+++ b/editor/libeditor/InternetCiter.cpp
@@ -1,37 +1,41 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-#include "nsInternetCiter.h"
+#include "InternetCiter.h"
#include "nsAString.h"
#include "nsCOMPtr.h"
#include "nsCRT.h"
#include "nsDebug.h"
#include "nsDependentSubstring.h"
#include "nsError.h"
#include "nsILineBreaker.h"
#include "nsLWBrkCIID.h"
#include "nsServiceManagerUtils.h"
#include "nsString.h"
#include "nsStringIterator.h"
+namespace mozilla {
+
const char16_t gt ('>');
const char16_t space (' ');
const char16_t nl ('\n');
const char16_t cr('\r');
-/** Mail citations using the Internet style: > This is a citation
- */
+/**
+ * Mail citations using the Internet style: > This is a citation.
+ */
nsresult
-nsInternetCiter::GetCiteString(const nsAString& aInString, nsAString& aOutString)
+InternetCiter::GetCiteString(const nsAString& aInString,
+ nsAString& aOutString)
{
aOutString.Truncate();
char16_t uch = nl;
// Strip trailing new lines which will otherwise turn up
// as ugly quoted empty lines.
nsReadingIterator <char16_t> beginIter,endIter;
aInString.BeginReading(beginIter);
@@ -63,20 +67,20 @@ nsInternetCiter::GetCiteString(const nsA
if (uch != nl)
aOutString += nl;
return NS_OK;
}
nsresult
-nsInternetCiter::StripCitesAndLinebreaks(const nsAString& aInString,
- nsAString& aOutString,
- bool aLinebreaksToo,
- int32_t* aCiteLevel)
+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);
@@ -107,17 +111,18 @@ nsInternetCiter::StripCitesAndLinebreaks
// Done with this line -- update cite level
if (aCiteLevel && (thisLineCiteLevel > *aCiteLevel))
*aCiteLevel = thisLineCiteLevel;
}
return NS_OK;
}
nsresult
-nsInternetCiter::StripCites(const nsAString& aInString, nsAString& aOutString)
+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);
@@ -141,20 +146,21 @@ BreakLine(nsAString& aOutString, uint32_
static inline bool IsSpace(char16_t c)
{
const char16_t nbsp (0xa0);
return (nsCRT::IsAsciiSpace(c) || (c == nl) || (c == cr) || (c == nbsp));
}
nsresult
-nsInternetCiter::Rewrap(const nsAString& aInString,
- uint32_t aWrapCol, uint32_t aFirstLineOffset,
- bool aRespectNewlines,
- nsAString& aOutString)
+InternetCiter::Rewrap(const nsAString& aInString,
+ uint32_t aWrapCol,
+ uint32_t aFirstLineOffset,
+ bool aRespectNewlines,
+ nsAString& aOutString)
{
// There shouldn't be returns in this string, only dom newlines.
// Check to make sure:
#ifdef DEBUG
int32_t cr = aInString.FindChar(char16_t('\r'));
NS_ASSERTION((cr < 0), "Rewrap: CR in string gotten from DOM!\n");
#endif /* DEBUG */
@@ -356,9 +362,9 @@ nsInternetCiter::Rewrap(const nsAString&
BreakLine(aOutString, outStringCol, citeLevel);
} // end inner loop within one line of aInString
} // end outer loop over lines of aInString
return NS_OK;
}
-
+} // namespace mozilla
rename from editor/libeditor/nsInternetCiter.h
rename to editor/libeditor/InternetCiter.h
--- a/editor/libeditor/nsInternetCiter.h
+++ b/editor/libeditor/InternetCiter.h
@@ -1,32 +1,40 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-#ifndef nsInternetCiter_h__
-#define nsInternetCiter_h__
+#ifndef InternetCiter_h
+#define InternetCiter_h
#include "nscore.h"
#include "nsStringFwd.h"
-/** Mail citations using standard Internet style.
- */
-class nsInternetCiter
+namespace mozilla {
+
+/**
+ * Mail citations using standard Internet style.
+ */
+class InternetCiter final
{
public:
- static nsresult GetCiteString(const nsAString & aInString, nsAString & aOutString);
+ static nsresult GetCiteString(const nsAString& aInString,
+ nsAString& aOutString);
- static nsresult StripCites(const nsAString & aInString, nsAString & aOutString);
+ static nsresult StripCites(const nsAString& aInString,
+ nsAString& aOutString);
- static nsresult Rewrap(const nsAString & aInString,
+ static nsresult Rewrap(const nsAString& aInString,
uint32_t aWrapCol, uint32_t aFirstLineOffset,
bool aRespectNewlines,
- nsAString & aOutString);
+ nsAString& aOutString);
protected:
- static nsresult StripCitesAndLinebreaks(const nsAString& aInString, nsAString& aOutString,
- bool aLinebreaksToo, int32_t* aCiteLevel);
+ static nsresult StripCitesAndLinebreaks(const nsAString& aInString,
+ nsAString& aOutString,
+ bool aLinebreaksToo,
+ int32_t* aCiteLevel);
};
-#endif //nsInternetCiter_h__
+} // namespace mozilla
+#endif // #ifndef InternetCiter_h
--- a/editor/libeditor/moz.build
+++ b/editor/libeditor/moz.build
@@ -28,31 +28,31 @@ UNIFIED_SOURCES += [
'EditAggregateTransaction.cpp',
'EditorCommands.cpp',
'EditorController.cpp',
'EditorUtils.cpp',
'EditTransactionBase.cpp',
'HTMLEditUtils.cpp',
'InsertNodeTransaction.cpp',
'InsertTextTransaction.cpp',
+ 'InternetCiter.cpp',
'JoinNodeTransaction.cpp',
'nsEditor.cpp',
'nsEditorEventListener.cpp',
'nsHTMLAbsPosition.cpp',
'nsHTMLAnonymousUtils.cpp',
'nsHTMLCSSUtils.cpp',
'nsHTMLDataTransfer.cpp',
'nsHTMLEditor.cpp',
'nsHTMLEditorEventListener.cpp',
'nsHTMLEditorStyle.cpp',
'nsHTMLEditRules.cpp',
'nsHTMLInlineTableEditor.cpp',
'nsHTMLObjectResizer.cpp',
'nsHTMLURIRefObject.cpp',
- 'nsInternetCiter.cpp',
'nsPlaintextDataTransfer.cpp',
'nsPlaintextEditor.cpp',
'nsSelectionState.cpp',
'nsTableEditor.cpp',
'nsTextEditRules.cpp',
'nsTextEditRulesBidi.cpp',
'nsWSRunObject.cpp',
'PlaceholderTransaction.cpp',
--- a/editor/libeditor/nsHTMLEditorEventListener.cpp
+++ b/editor/libeditor/nsHTMLEditorEventListener.cpp
@@ -1,16 +1,17 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsHTMLEditorEventListener.h"
#include "HTMLEditUtils.h"
+#include "mozilla/dom/Event.h"
#include "mozilla/dom/Selection.h"
#include "nsCOMPtr.h"
#include "nsDebug.h"
#include "nsEditor.h"
#include "nsError.h"
#include "nsHTMLEditor.h"
#include "nsIDOMElement.h"
#include "nsIDOMEvent.h"
--- a/editor/libeditor/nsPlaintextEditor.cpp
+++ b/editor/libeditor/nsPlaintextEditor.cpp
@@ -1,16 +1,17 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsPlaintextEditor.h"
#include "EditorUtils.h" // AutoEditBatch, AutoRules
+#include "InternetCiter.h"
#include "TextEditUtils.h"
#include "gfxFontUtils.h"
#include "mozilla/Assertions.h"
#include "mozilla/Preferences.h"
#include "mozilla/dom/Selection.h"
#include "mozilla/dom/Event.h"
#include "mozilla/TextComposition.h"
#include "mozilla/TextEvents.h"
@@ -42,17 +43,16 @@
#include "nsIEditorIMESupport.h"
#include "nsNameSpaceManager.h"
#include "nsINode.h"
#include "nsIPresShell.h"
#include "nsISelectionController.h"
#include "nsISupportsPrimitives.h"
#include "nsITransferable.h"
#include "nsIWeakReferenceUtils.h"
-#include "nsInternetCiter.h"
#include "nsLiteralString.h"
#include "nsReadableUtils.h"
#include "nsServiceManagerUtils.h"
#include "nsString.h"
#include "nsStringFwd.h"
#include "nsSubstringTuple.h"
#include "nsTextEditRules.h"
#include "nsUnicharUtils.h"
@@ -1409,17 +1409,17 @@ NS_IMETHODIMP
nsPlaintextEditor::InsertAsQuotation(const nsAString& aQuotedText,
nsIDOMNode **aNodeInserted)
{
// Protect the edit rules object from dying
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
// Let the citer quote it for us:
nsString quotedStuff;
- nsresult rv = nsInternetCiter::GetCiteString(aQuotedText, quotedStuff);
+ nsresult rv = InternetCiter::GetCiteString(aQuotedText, quotedStuff);
NS_ENSURE_SUCCESS(rv, rv);
// It's best to put a blank line after the quoted text so that mails
// written without thinking won't be so ugly.
if (!aQuotedText.IsEmpty() && (aQuotedText.Last() != char16_t('\n')))
quotedStuff.Append(char16_t('\n'));
// get selection
@@ -1497,18 +1497,18 @@ nsPlaintextEditor::Rewrap(bool aRespectN
bool isCollapsed;
rv = SharedOutputString(nsIDocumentEncoder::OutputFormatted
| nsIDocumentEncoder::OutputLFLineBreak,
&isCollapsed, current);
NS_ENSURE_SUCCESS(rv, rv);
nsString wrapped;
uint32_t firstLineOffset = 0; // XXX need to reset this if there is a selection
- rv = nsInternetCiter::Rewrap(current, wrapCol, firstLineOffset, aRespectNewlines,
- wrapped);
+ rv = InternetCiter::Rewrap(current, wrapCol, firstLineOffset,
+ aRespectNewlines, wrapped);
NS_ENSURE_SUCCESS(rv, rv);
if (isCollapsed) // rewrap the whole document
SelectAll();
return InsertTextWithQuotations(wrapped);
}
@@ -1517,17 +1517,17 @@ nsPlaintextEditor::StripCites()
{
nsAutoString current;
bool isCollapsed;
nsresult rv = SharedOutputString(nsIDocumentEncoder::OutputFormatted,
&isCollapsed, current);
NS_ENSURE_SUCCESS(rv, rv);
nsString stripped;
- rv = nsInternetCiter::StripCites(current, stripped);
+ rv = InternetCiter::StripCites(current, stripped);
NS_ENSURE_SUCCESS(rv, rv);
if (isCollapsed) // rewrap the whole document
{
rv = SelectAll();
NS_ENSURE_SUCCESS(rv, rv);
}